Open History to see the last commit
1const legacyFailures = {
2 subscription_sharing_v2_user_not_eligible: {
3 message:
4 "ChatGPT sharing is unavailable for this account or workspace. Use another provider or check its sharing policy.",
5 },
6 subscription_sharing_usage_limit_exceeded: {
7 message:
8 "Your ChatGPT usage limit was reached. Check ChatGPT Usage settings for your available allowance.",
9 },
10 subscription_sharing_workplace_individual_usage_limit_exceeded: {
11 message:
12 "You reached your workspace's limit for using ChatGPT in other apps. Ask your workspace admin to increase it.",
13 },
14 subscription_sharing_usage_unavailable: {
15 message: "ChatGPT usage is temporarily unavailable. Try again shortly.",
16 },
17 subscription_sharing_unsupported_capability: {
18 message:
19 "Codex used a feature that ChatGPT sharing does not support. Use another provider for this request.",
20 },
21 subscription_sharing_v2_client_not_enabled: {
22 message:
23 "This app is not enabled for this ChatGPT connection. Use your existing CLI or another provider.",
24 },
25 subscription_sharing_v2_route_not_supported: {
26 message: "ChatGPT does not support this request route.",
27 },
28 subscription_sharing_v2_invalid_user: {
29 message:
30 "ChatGPT could not validate this connection. Check the selected account and sharing permissions.",
31 },
32 subscription_sharing_v2_user_unavailable: {
33 message: "ChatGPT is temporarily unavailable. Try again shortly.",
34 },
35} as const;
36const failures = {
37 ...legacyFailures,
38 subscription_sharing_user_not_eligible: legacyFailures.subscription_sharing_v2_user_not_eligible,
39 subscription_sharing_route_not_supported:
40 legacyFailures.subscription_sharing_v2_route_not_supported,
41 subscription_sharing_invalid_user: legacyFailures.subscription_sharing_v2_invalid_user,
42 subscription_sharing_user_unavailable: legacyFailures.subscription_sharing_v2_user_unavailable,
43 chatpass_v2_scope_not_authorized: {
44 message:
45 "This ChatGPT grant does not authorize the request. Check the connection's sharing permissions.",
46 },
47 chatpass_v2_invalid_authorization_context: {
48 message:
49 "ChatGPT could not authorize this connection. Check the client and sharing permissions.",
50 },
51};
52export function classifyCodexManagedError(value: unknown) {
53 let text: string;
54 try {
55 text = typeof value === "string" ? value : JSON.stringify(value);
56 } catch {
57 return undefined;
58 }
59 if (typeof text !== "string") return undefined;
60 for (const [code, failure] of Object.entries(failures)) {
61 if (!text.includes(code)) continue;
62 if (code === "subscription_sharing_unsupported_capability") {
63 if (text.includes("tool 'namespace'"))
64 return {
65 ...failure,
66 code,
67 message:
68 "Codex sent a tool namespace that ChatGPT sharing does not support. Use another provider for this request.",
69 };
70 if (text.includes("additional_tools"))
71 return {
72 ...failure,
73 code,
74 message:
75 "Codex sent an input item that ChatGPT sharing does not support. Use another provider for this request.",
76 };
77 }
78 return { ...failure, code };
79 }
80 return undefined;
81}