oc-chatgpt-multi-auth 4.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/LICENSE +37 -0
  2. package/README.md +507 -0
  3. package/assets/opencode-logo-ornate-dark.svg +18 -0
  4. package/assets/readme-hero.svg +31 -0
  5. package/config/README.md +110 -0
  6. package/config/minimal-opencode.json +13 -0
  7. package/config/opencode-legacy.json +572 -0
  8. package/config/opencode-modern.json +240 -0
  9. package/dist/index.d.ts +45 -0
  10. package/dist/index.d.ts.map +1 -0
  11. package/dist/index.js +971 -0
  12. package/dist/index.js.map +1 -0
  13. package/dist/lib/accounts.d.ts +120 -0
  14. package/dist/lib/accounts.d.ts.map +1 -0
  15. package/dist/lib/accounts.js +579 -0
  16. package/dist/lib/accounts.js.map +1 -0
  17. package/dist/lib/auth/auth.d.ts +51 -0
  18. package/dist/lib/auth/auth.d.ts.map +1 -0
  19. package/dist/lib/auth/auth.js +180 -0
  20. package/dist/lib/auth/auth.js.map +1 -0
  21. package/dist/lib/auth/browser.d.ts +17 -0
  22. package/dist/lib/auth/browser.d.ts.map +1 -0
  23. package/dist/lib/auth/browser.js +83 -0
  24. package/dist/lib/auth/browser.js.map +1 -0
  25. package/dist/lib/auth/server.d.ts +10 -0
  26. package/dist/lib/auth/server.d.ts.map +1 -0
  27. package/dist/lib/auth/server.js +85 -0
  28. package/dist/lib/auth/server.js.map +1 -0
  29. package/dist/lib/auto-update-checker.d.ts +10 -0
  30. package/dist/lib/auto-update-checker.d.ts.map +1 -0
  31. package/dist/lib/auto-update-checker.js +129 -0
  32. package/dist/lib/auto-update-checker.js.map +1 -0
  33. package/dist/lib/cli.d.ts +9 -0
  34. package/dist/lib/cli.d.ts.map +1 -0
  35. package/dist/lib/cli.js +50 -0
  36. package/dist/lib/cli.js.map +1 -0
  37. package/dist/lib/config.d.ts +17 -0
  38. package/dist/lib/config.d.ts.map +1 -0
  39. package/dist/lib/config.js +102 -0
  40. package/dist/lib/config.js.map +1 -0
  41. package/dist/lib/constants.d.ts +74 -0
  42. package/dist/lib/constants.d.ts.map +1 -0
  43. package/dist/lib/constants.js +74 -0
  44. package/dist/lib/constants.js.map +1 -0
  45. package/dist/lib/context-overflow.d.ts +27 -0
  46. package/dist/lib/context-overflow.d.ts.map +1 -0
  47. package/dist/lib/context-overflow.js +124 -0
  48. package/dist/lib/context-overflow.js.map +1 -0
  49. package/dist/lib/index.d.ts +13 -0
  50. package/dist/lib/index.d.ts.map +1 -0
  51. package/dist/lib/index.js +13 -0
  52. package/dist/lib/index.js.map +1 -0
  53. package/dist/lib/logger.d.ts +22 -0
  54. package/dist/lib/logger.d.ts.map +1 -0
  55. package/dist/lib/logger.js +175 -0
  56. package/dist/lib/logger.js.map +1 -0
  57. package/dist/lib/oauth-success.html +712 -0
  58. package/dist/lib/prompts/codex-opencode-bridge.d.ts +19 -0
  59. package/dist/lib/prompts/codex-opencode-bridge.d.ts.map +1 -0
  60. package/dist/lib/prompts/codex-opencode-bridge.js +152 -0
  61. package/dist/lib/prompts/codex-opencode-bridge.js.map +1 -0
  62. package/dist/lib/prompts/codex.d.ts +32 -0
  63. package/dist/lib/prompts/codex.d.ts.map +1 -0
  64. package/dist/lib/prompts/codex.js +262 -0
  65. package/dist/lib/prompts/codex.js.map +1 -0
  66. package/dist/lib/prompts/opencode-codex.d.ts +21 -0
  67. package/dist/lib/prompts/opencode-codex.d.ts.map +1 -0
  68. package/dist/lib/prompts/opencode-codex.js +91 -0
  69. package/dist/lib/prompts/opencode-codex.js.map +1 -0
  70. package/dist/lib/recovery/constants.d.ts +12 -0
  71. package/dist/lib/recovery/constants.d.ts.map +1 -0
  72. package/dist/lib/recovery/constants.js +25 -0
  73. package/dist/lib/recovery/constants.js.map +1 -0
  74. package/dist/lib/recovery/index.d.ts +12 -0
  75. package/dist/lib/recovery/index.d.ts.map +1 -0
  76. package/dist/lib/recovery/index.js +12 -0
  77. package/dist/lib/recovery/index.js.map +1 -0
  78. package/dist/lib/recovery/storage.d.ts +24 -0
  79. package/dist/lib/recovery/storage.d.ts.map +1 -0
  80. package/dist/lib/recovery/storage.js +354 -0
  81. package/dist/lib/recovery/storage.js.map +1 -0
  82. package/dist/lib/recovery/types.d.ts +116 -0
  83. package/dist/lib/recovery/types.d.ts.map +1 -0
  84. package/dist/lib/recovery/types.js +7 -0
  85. package/dist/lib/recovery/types.js.map +1 -0
  86. package/dist/lib/recovery.d.ts +31 -0
  87. package/dist/lib/recovery.d.ts.map +1 -0
  88. package/dist/lib/recovery.js +308 -0
  89. package/dist/lib/recovery.js.map +1 -0
  90. package/dist/lib/refresh-queue.d.ts +100 -0
  91. package/dist/lib/refresh-queue.d.ts.map +1 -0
  92. package/dist/lib/refresh-queue.js +196 -0
  93. package/dist/lib/refresh-queue.js.map +1 -0
  94. package/dist/lib/request/fetch-helpers.d.ts +81 -0
  95. package/dist/lib/request/fetch-helpers.d.ts.map +1 -0
  96. package/dist/lib/request/fetch-helpers.js +325 -0
  97. package/dist/lib/request/fetch-helpers.js.map +1 -0
  98. package/dist/lib/request/helpers/input-utils.d.ts +7 -0
  99. package/dist/lib/request/helpers/input-utils.d.ts.map +1 -0
  100. package/dist/lib/request/helpers/input-utils.js +213 -0
  101. package/dist/lib/request/helpers/input-utils.js.map +1 -0
  102. package/dist/lib/request/helpers/model-map.d.ts +28 -0
  103. package/dist/lib/request/helpers/model-map.d.ts.map +1 -0
  104. package/dist/lib/request/helpers/model-map.js +109 -0
  105. package/dist/lib/request/helpers/model-map.js.map +1 -0
  106. package/dist/lib/request/rate-limit-backoff.d.ts +17 -0
  107. package/dist/lib/request/rate-limit-backoff.d.ts.map +1 -0
  108. package/dist/lib/request/rate-limit-backoff.js +74 -0
  109. package/dist/lib/request/rate-limit-backoff.js.map +1 -0
  110. package/dist/lib/request/request-transformer.d.ts +93 -0
  111. package/dist/lib/request/request-transformer.d.ts.map +1 -0
  112. package/dist/lib/request/request-transformer.js +405 -0
  113. package/dist/lib/request/request-transformer.js.map +1 -0
  114. package/dist/lib/request/response-handler.d.ts +14 -0
  115. package/dist/lib/request/response-handler.d.ts.map +1 -0
  116. package/dist/lib/request/response-handler.js +90 -0
  117. package/dist/lib/request/response-handler.js.map +1 -0
  118. package/dist/lib/rotation.d.ts +121 -0
  119. package/dist/lib/rotation.d.ts.map +1 -0
  120. package/dist/lib/rotation.js +248 -0
  121. package/dist/lib/rotation.js.map +1 -0
  122. package/dist/lib/storage.d.ts +91 -0
  123. package/dist/lib/storage.d.ts.map +1 -0
  124. package/dist/lib/storage.js +323 -0
  125. package/dist/lib/storage.js.map +1 -0
  126. package/dist/lib/types.d.ts +185 -0
  127. package/dist/lib/types.d.ts.map +1 -0
  128. package/dist/lib/types.js +2 -0
  129. package/dist/lib/types.js.map +1 -0
  130. package/package.json +86 -0
  131. package/scripts/copy-oauth-success.js +37 -0
  132. package/scripts/install-opencode-codex-auth.js +193 -0
  133. package/scripts/test-all-models.sh +260 -0
  134. package/scripts/validate-model-map.sh +97 -0
@@ -0,0 +1,17 @@
1
+ import type { PluginConfig } from "./types.js";
2
+ /**
3
+ * Load plugin configuration from ~/.opencode/openai-codex-auth-config.json
4
+ * Falls back to defaults if file doesn't exist or is invalid
5
+ *
6
+ * @returns Plugin configuration
7
+ */
8
+ export declare function loadPluginConfig(): PluginConfig;
9
+ export declare function getCodexMode(pluginConfig: PluginConfig): boolean;
10
+ export declare function getRetryAllAccountsRateLimited(pluginConfig: PluginConfig): boolean;
11
+ export declare function getRetryAllAccountsMaxWaitMs(pluginConfig: PluginConfig): number;
12
+ export declare function getRetryAllAccountsMaxRetries(pluginConfig: PluginConfig): number;
13
+ export declare function getTokenRefreshSkewMs(pluginConfig: PluginConfig): number;
14
+ export declare function getRateLimitToastDebounceMs(pluginConfig: PluginConfig): number;
15
+ export declare function getSessionRecovery(pluginConfig: PluginConfig): boolean;
16
+ export declare function getAutoResume(pluginConfig: PluginConfig): boolean;
17
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../lib/config.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAmB/C;;;;;GAKG;AACH,wBAAgB,gBAAgB,IAAI,YAAY,CAqB/C;AA8CD,wBAAgB,YAAY,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAEhE;AAED,wBAAgB,8BAA8B,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAMlF;AAED,wBAAgB,4BAA4B,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM,CAO/E;AAED,wBAAgB,6BAA6B,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM,CAOhF;AAED,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM,CAOxE;AAED,wBAAgB,2BAA2B,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM,CAO9E;AAED,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAMtE;AAED,wBAAgB,aAAa,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAMjE"}
@@ -0,0 +1,102 @@
1
+ import { readFileSync, existsSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { homedir } from "node:os";
4
+ const CONFIG_PATH = join(homedir(), ".opencode", "openai-codex-auth-config.json");
5
+ /**
6
+ * Default plugin configuration
7
+ * CODEX_MODE is enabled by default for better Codex CLI parity
8
+ */
9
+ const DEFAULT_CONFIG = {
10
+ codexMode: true,
11
+ retryAllAccountsRateLimited: true,
12
+ retryAllAccountsMaxWaitMs: 0,
13
+ retryAllAccountsMaxRetries: Infinity,
14
+ tokenRefreshSkewMs: 60_000,
15
+ rateLimitToastDebounceMs: 60_000,
16
+ sessionRecovery: true,
17
+ autoResume: true,
18
+ };
19
+ /**
20
+ * Load plugin configuration from ~/.opencode/openai-codex-auth-config.json
21
+ * Falls back to defaults if file doesn't exist or is invalid
22
+ *
23
+ * @returns Plugin configuration
24
+ */
25
+ export function loadPluginConfig() {
26
+ try {
27
+ if (!existsSync(CONFIG_PATH)) {
28
+ return DEFAULT_CONFIG;
29
+ }
30
+ const fileContent = readFileSync(CONFIG_PATH, "utf-8");
31
+ const userConfig = JSON.parse(fileContent);
32
+ // Merge with defaults
33
+ return {
34
+ ...DEFAULT_CONFIG,
35
+ ...userConfig,
36
+ };
37
+ }
38
+ catch (error) {
39
+ console.warn(`[openai-codex-plugin] Failed to load config from ${CONFIG_PATH}:`, error.message);
40
+ return DEFAULT_CONFIG;
41
+ }
42
+ }
43
+ /**
44
+ * Get the effective CODEX_MODE setting
45
+ * Priority: environment variable > config file > default (true)
46
+ *
47
+ * @param pluginConfig - Plugin configuration from file
48
+ * @returns True if CODEX_MODE should be enabled
49
+ */
50
+ function parseBooleanEnv(value) {
51
+ if (value === undefined)
52
+ return undefined;
53
+ return value === "1";
54
+ }
55
+ function parseNumberEnv(value) {
56
+ if (value === undefined)
57
+ return undefined;
58
+ const parsed = Number(value);
59
+ if (!Number.isFinite(parsed))
60
+ return undefined;
61
+ return parsed;
62
+ }
63
+ function resolveBooleanSetting(envName, configValue, defaultValue) {
64
+ const envValue = parseBooleanEnv(process.env[envName]);
65
+ if (envValue !== undefined)
66
+ return envValue;
67
+ return configValue ?? defaultValue;
68
+ }
69
+ function resolveNumberSetting(envName, configValue, defaultValue, options) {
70
+ const envValue = parseNumberEnv(process.env[envName]);
71
+ const candidate = envValue ?? configValue ?? defaultValue;
72
+ const min = options?.min;
73
+ if (min !== undefined) {
74
+ return Math.max(min, candidate);
75
+ }
76
+ return candidate;
77
+ }
78
+ export function getCodexMode(pluginConfig) {
79
+ return resolveBooleanSetting("CODEX_MODE", pluginConfig.codexMode, true);
80
+ }
81
+ export function getRetryAllAccountsRateLimited(pluginConfig) {
82
+ return resolveBooleanSetting("CODEX_AUTH_RETRY_ALL_RATE_LIMITED", pluginConfig.retryAllAccountsRateLimited, true);
83
+ }
84
+ export function getRetryAllAccountsMaxWaitMs(pluginConfig) {
85
+ return resolveNumberSetting("CODEX_AUTH_RETRY_ALL_MAX_WAIT_MS", pluginConfig.retryAllAccountsMaxWaitMs, 0, { min: 0 });
86
+ }
87
+ export function getRetryAllAccountsMaxRetries(pluginConfig) {
88
+ return resolveNumberSetting("CODEX_AUTH_RETRY_ALL_MAX_RETRIES", pluginConfig.retryAllAccountsMaxRetries, Infinity, { min: 0 });
89
+ }
90
+ export function getTokenRefreshSkewMs(pluginConfig) {
91
+ return resolveNumberSetting("CODEX_AUTH_TOKEN_REFRESH_SKEW_MS", pluginConfig.tokenRefreshSkewMs, 60_000, { min: 0 });
92
+ }
93
+ export function getRateLimitToastDebounceMs(pluginConfig) {
94
+ return resolveNumberSetting("CODEX_AUTH_RATE_LIMIT_TOAST_DEBOUNCE_MS", pluginConfig.rateLimitToastDebounceMs, 60_000, { min: 0 });
95
+ }
96
+ export function getSessionRecovery(pluginConfig) {
97
+ return resolveBooleanSetting("CODEX_AUTH_SESSION_RECOVERY", pluginConfig.sessionRecovery, true);
98
+ }
99
+ export function getAutoResume(pluginConfig) {
100
+ return resolveBooleanSetting("CODEX_AUTH_AUTO_RESUME", pluginConfig.autoResume, true);
101
+ }
102
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../lib/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAGlC,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,+BAA+B,CAAC,CAAC;AAElF;;;GAGG;AACH,MAAM,cAAc,GAAiB;IACpC,SAAS,EAAE,IAAI;IACf,2BAA2B,EAAE,IAAI;IACjC,yBAAyB,EAAE,CAAC;IAC5B,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AAM,EACN,EAAE,GAAG,EAAE,CAAC,EAAE,CACV,CAAC;AACH,CAAC;AAED,MAAM,UAAU,2BAA2B,CAAC,YAA0B;IACrE,OAAO,oBAAoB,CAC1B,yCAAyC,EACzC,YAAY,CAAC,wBAAwB,EACrC,MAAM,EACN,EAAE,GAAG,EAAE,CAAC,EAAE,CACV,CAAC;AACH,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,YAA0B;IAC5D,OAAO,qBAAqB,CAC3B,6BAA6B,EAC7B,YAAY,CAAC,eAAe,EAC5B,IAAI,CACJ,CAAC;AACH,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,YAA0B;IACvD,OAAO,qBAAqB,CAC3B,wBAAwB,EACxB,YAAY,CAAC,UAAU,EACvB,IAAI,CACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Constants used throughout the plugin
3
+ * Centralized for easy maintenance and configuration
4
+ */
5
+ /** Plugin identifier for logging and error messages */
6
+ export declare const PLUGIN_NAME = "openai-codex-plugin";
7
+ /** Base URL for ChatGPT backend API */
8
+ export declare const CODEX_BASE_URL = "https://chatgpt.com/backend-api";
9
+ /** Dummy API key used for OpenAI SDK (actual auth via OAuth) */
10
+ export declare const DUMMY_API_KEY = "chatgpt-oauth";
11
+ /** Provider ID for UI display - shows under "OpenAI" in auth dropdown */
12
+ export declare const PROVIDER_ID = "openai";
13
+ /** HTTP Status Codes */
14
+ export declare const HTTP_STATUS: {
15
+ readonly OK: 200;
16
+ readonly UNAUTHORIZED: 401;
17
+ readonly NOT_FOUND: 404;
18
+ readonly TOO_MANY_REQUESTS: 429;
19
+ };
20
+ /** OpenAI-specific headers */
21
+ export declare const OPENAI_HEADERS: {
22
+ readonly BETA: "OpenAI-Beta";
23
+ readonly ACCOUNT_ID: "chatgpt-account-id";
24
+ readonly ORIGINATOR: "originator";
25
+ readonly SESSION_ID: "session_id";
26
+ readonly CONVERSATION_ID: "conversation_id";
27
+ };
28
+ /** OpenAI-specific header values */
29
+ export declare const OPENAI_HEADER_VALUES: {
30
+ readonly BETA_RESPONSES: "responses=experimental";
31
+ readonly ORIGINATOR_CODEX: "codex_cli_rs";
32
+ };
33
+ /** URL path segments */
34
+ export declare const URL_PATHS: {
35
+ readonly RESPONSES: "/responses";
36
+ readonly CODEX_RESPONSES: "/codex/responses";
37
+ };
38
+ /** JWT claim path for ChatGPT account ID */
39
+ export declare const JWT_CLAIM_PATH: "https://api.openai.com/auth";
40
+ /** Error messages */
41
+ export declare const ERROR_MESSAGES: {
42
+ readonly NO_ACCOUNT_ID: "Failed to extract accountId from token";
43
+ readonly TOKEN_REFRESH_FAILED: "Failed to refresh token, authentication required";
44
+ readonly REQUEST_PARSE_ERROR: "Error parsing request";
45
+ };
46
+ /** Log stages for request logging */
47
+ export declare const LOG_STAGES: {
48
+ readonly BEFORE_TRANSFORM: "before-transform";
49
+ readonly AFTER_TRANSFORM: "after-transform";
50
+ readonly RESPONSE: "response";
51
+ readonly ERROR_RESPONSE: "error-response";
52
+ };
53
+ /** Platform-specific browser opener commands */
54
+ export declare const PLATFORM_OPENERS: {
55
+ readonly darwin: "open";
56
+ readonly win32: "start";
57
+ readonly linux: "xdg-open";
58
+ };
59
+ /** OAuth authorization labels */
60
+ export declare const AUTH_LABELS: {
61
+ readonly OAUTH: "ChatGPT Plus/Pro MULTI (Codex Subscription)";
62
+ readonly OAUTH_MANUAL: "ChatGPT Plus/Pro MULTI (Manual URL Paste)";
63
+ readonly API_KEY: "Manually enter API Key MULTI";
64
+ readonly INSTRUCTIONS: "A browser window should open. If it doesn't, copy the URL and open it manually.";
65
+ readonly INSTRUCTIONS_MANUAL: "After logging in, copy the full redirect URL and paste it here.";
66
+ };
67
+ /** Multi-account configuration */
68
+ export declare const ACCOUNT_LIMITS: {
69
+ /** Maximum number of OAuth accounts that can be registered */
70
+ readonly MAX_ACCOUNTS: 10;
71
+ /** Cooldown period (ms) after auth failure before retrying account */
72
+ readonly AUTH_FAILURE_COOLDOWN_MS: 30000;
73
+ };
74
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../lib/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,uDAAuD;AACvD,eAAO,MAAM,WAAW,wBAAwB,CAAC;AAEjD,uCAAuC;AACvC,eAAO,MAAM,cAAc,oCAAoC,CAAC;AAEhE,gEAAgE;AAChE,eAAO,MAAM,aAAa,kBAAkB,CAAC;AAE7C,yEAAyE;AACzE,eAAO,MAAM,WAAW,WAAW,CAAC;AAEpC,wBAAwB;AACxB,eAAO,MAAM,WAAW;;;;;CAKd,CAAC;AAEX,8BAA8B;AAC9B,eAAO,MAAM,cAAc;;;;;;CAMjB,CAAC;AAEX,oCAAoC;AACpC,eAAO,MAAM,oBAAoB;;;CAGvB,CAAC;AAEX,wBAAwB;AACxB,eAAO,MAAM,SAAS;;;CAGZ,CAAC;AAEX,4CAA4C;AAC5C,eAAO,MAAM,cAAc,EAAG,6BAAsC,CAAC;AAErE,qBAAqB;AACrB,eAAO,MAAM,cAAc;;;;CAIjB,CAAC;AAEX,qCAAqC;AACrC,eAAO,MAAM,UAAU;;;;;CAKb,CAAC;AAEX,gDAAgD;AAChD,eAAO,MAAM,gBAAgB;;;;CAInB,CAAC;AAEX,iCAAiC;AACjC,eAAO,MAAM,WAAW;;;;;;CAQd,CAAC;AAEX,kCAAkC;AAClC,eAAO,MAAM,cAAc;IAC1B,8DAA8D;;IAE9D,sEAAsE;;CAE7D,CAAC"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Constants used throughout the plugin
3
+ * Centralized for easy maintenance and configuration
4
+ */
5
+ /** Plugin identifier for logging and error messages */
6
+ export const PLUGIN_NAME = "openai-codex-plugin";
7
+ /** Base URL for ChatGPT backend API */
8
+ export const CODEX_BASE_URL = "https://chatgpt.com/backend-api";
9
+ /** Dummy API key used for OpenAI SDK (actual auth via OAuth) */
10
+ export const DUMMY_API_KEY = "chatgpt-oauth";
11
+ /** Provider ID for UI display - shows under "OpenAI" in auth dropdown */
12
+ export const PROVIDER_ID = "openai";
13
+ /** HTTP Status Codes */
14
+ export const HTTP_STATUS = {
15
+ OK: 200,
16
+ UNAUTHORIZED: 401,
17
+ NOT_FOUND: 404,
18
+ TOO_MANY_REQUESTS: 429,
19
+ };
20
+ /** OpenAI-specific headers */
21
+ export const OPENAI_HEADERS = {
22
+ BETA: "OpenAI-Beta",
23
+ ACCOUNT_ID: "chatgpt-account-id",
24
+ ORIGINATOR: "originator",
25
+ SESSION_ID: "session_id",
26
+ CONVERSATION_ID: "conversation_id",
27
+ };
28
+ /** OpenAI-specific header values */
29
+ export const OPENAI_HEADER_VALUES = {
30
+ BETA_RESPONSES: "responses=experimental",
31
+ ORIGINATOR_CODEX: "codex_cli_rs",
32
+ };
33
+ /** URL path segments */
34
+ export const URL_PATHS = {
35
+ RESPONSES: "/responses",
36
+ CODEX_RESPONSES: "/codex/responses",
37
+ };
38
+ /** JWT claim path for ChatGPT account ID */
39
+ export const JWT_CLAIM_PATH = "https://api.openai.com/auth";
40
+ /** Error messages */
41
+ export const ERROR_MESSAGES = {
42
+ NO_ACCOUNT_ID: "Failed to extract accountId from token",
43
+ TOKEN_REFRESH_FAILED: "Failed to refresh token, authentication required",
44
+ REQUEST_PARSE_ERROR: "Error parsing request",
45
+ };
46
+ /** Log stages for request logging */
47
+ export const LOG_STAGES = {
48
+ BEFORE_TRANSFORM: "before-transform",
49
+ AFTER_TRANSFORM: "after-transform",
50
+ RESPONSE: "response",
51
+ ERROR_RESPONSE: "error-response",
52
+ };
53
+ /** Platform-specific browser opener commands */
54
+ export const PLATFORM_OPENERS = {
55
+ darwin: "open",
56
+ win32: "start",
57
+ linux: "xdg-open",
58
+ };
59
+ /** OAuth authorization labels */
60
+ export const AUTH_LABELS = {
61
+ OAUTH: "ChatGPT Plus/Pro MULTI (Codex Subscription)",
62
+ OAUTH_MANUAL: "ChatGPT Plus/Pro MULTI (Manual URL Paste)",
63
+ API_KEY: "Manually enter API Key MULTI",
64
+ INSTRUCTIONS: "A browser window should open. If it doesn't, copy the URL and open it manually.",
65
+ INSTRUCTIONS_MANUAL: "After logging in, copy the full redirect URL and paste it here.",
66
+ };
67
+ /** Multi-account configuration */
68
+ export const ACCOUNT_LIMITS = {
69
+ /** Maximum number of OAuth accounts that can be registered */
70
+ MAX_ACCOUNTS: 10,
71
+ /** Cooldown period (ms) after auth failure before retrying account */
72
+ AUTH_FAILURE_COOLDOWN_MS: 30_000,
73
+ };
74
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../lib/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,uDAAuD;AACvD,MAAM,CAAC,MAAM,WAAW,GAAG,qBAAqB,CAAC;AAEjD,uCAAuC;AACvC,MAAM,CAAC,MAAM,cAAc,GAAG,iCAAiC,CAAC;AAEhE,gEAAgE;AAChE,MAAM,CAAC,MAAM,aAAa,GAAG,eAAe,CAAC;AAE7C,yEAAyE;AACzE,MAAM,CAAC,MAAM,WAAW,GAAG,QAAQ,CAAC;AAEpC,wBAAwB;AACxB,MAAM,CAAC,MAAM,WAAW,GAAG;IAC1B,EAAE,EAAE,GAAG;IACP,YAAY,EAAE,GAAG;IACjB,SAAS,EAAE,GAAG;IACd,iBAAiB,EAAE,GAAG;CACb,CAAC;AAEX,8BAA8B;AAC9B,MAAM,CAAC,MAAM,cAAc,GAAG;IAC7B,IAAI,EAAE,aAAa;IACnB,UAAU,EAAE,oBAAoB;IAChC,UAAU,EAAE,YAAY;IACxB,UAAU,EAAE,YAAY;IACxB,eAAe,EAAE,iBAAiB;CACzB,CAAC;AAEX,oCAAoC;AACpC,MAAM,CAAC,MAAM,oBAAoB,GAAG;IACnC,cAAc,EAAE,wBAAwB;IACxC,gBAAgB,EAAE,cAAc;CACvB,CAAC;AAEX,wBAAwB;AACxB,MAAM,CAAC,MAAM,SAAS,GAAG;IACxB,SAAS,EAAE,YAAY;IACvB,eAAe,EAAE,kBAAkB;CAC1B,CAAC;AAEX,4CAA4C;AAC5C,MAAM,CAAC,MAAM,cAAc,GAAG,6BAAsC,CAAC;AAErE,qBAAqB;AACrB,MAAM,CAAC,MAAM,cAAc,GAAG;IAC7B,aAAa,EAAE,wCAAwC;IACvD,oBAAoB,EAAE,kDAAkD;IACxE,mBAAmB,EAAE,uBAAuB;CACnC,CAAC;AAEX,qCAAqC;AACrC,MAAM,CAAC,MAAM,UAAU,GAAG;IACzB,gBAAgB,EAAE,kBAAkB;IACpC,eAAe,EAAE,iBAAiB;IAClC,QAAQ,EAAE,UAAU;IACpB,cAAc,EAAE,gBAAgB;CACvB,CAAC;AAEX,gDAAgD;AAChD,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC/B,MAAM,EAAE,MAAM;IACd,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,UAAU;CACR,CAAC;AAEX,iCAAiC;AACjC,MAAM,CAAC,MAAM,WAAW,GAAG;IAC1B,KAAK,EAAE,6CAA6C;IACpD,YAAY,EAAE,2CAA2C;IACzD,OAAO,EAAE,8BAA8B;IACvC,YAAY,EACX,iFAAiF;IAClF,mBAAmB,EAClB,iEAAiE;CACzD,CAAC;AAEX,kCAAkC;AAClC,MAAM,CAAC,MAAM,cAAc,GAAG;IAC7B,8DAA8D;IAC9D,YAAY,EAAE,EAAE;IAChB,sEAAsE;IACtE,wBAAwB,EAAE,MAAM;CACvB,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Context Overflow Handler
3
+ *
4
+ * Handles "Prompt too long" / context length exceeded errors by returning
5
+ * a synthetic SSE response that advises the user to use /compact or /clear.
6
+ * This prevents the OpenCode session from getting locked on 400 errors.
7
+ */
8
+ /**
9
+ * Check if an error body indicates context overflow
10
+ */
11
+ export declare function isContextOverflowError(status: number, bodyText: string): boolean;
12
+ /**
13
+ * Creates a synthetic SSE response for context overflow errors.
14
+ * This returns a 200 OK with the error message as assistant text,
15
+ * preventing the session from getting locked.
16
+ */
17
+ export declare function createContextOverflowResponse(model?: string): Response;
18
+ /**
19
+ * Check response for context overflow and return synthetic response if needed
20
+ */
21
+ export declare function handleContextOverflow(response: Response, model?: string): Promise<{
22
+ handled: true;
23
+ response: Response;
24
+ } | {
25
+ handled: false;
26
+ }>;
27
+ //# sourceMappingURL=context-overflow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-overflow.d.ts","sourceRoot":"","sources":["../../lib/context-overflow.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAiBH;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAMhF;AAiBD;;;;GAIG;AACH,wBAAgB,6BAA6B,CAAC,KAAK,GAAE,MAAkB,GAAG,QAAQ,CAyDjF;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CACzC,QAAQ,EAAE,QAAQ,EAClB,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,QAAQ,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,KAAK,CAAA;CAAE,CAAC,CAmBrE"}
@@ -0,0 +1,124 @@
1
+ /**
2
+ * Context Overflow Handler
3
+ *
4
+ * Handles "Prompt too long" / context length exceeded errors by returning
5
+ * a synthetic SSE response that advises the user to use /compact or /clear.
6
+ * This prevents the OpenCode session from getting locked on 400 errors.
7
+ */
8
+ import { PLUGIN_NAME } from "./constants.js";
9
+ /**
10
+ * Error patterns that indicate context overflow
11
+ */
12
+ const CONTEXT_OVERFLOW_PATTERNS = [
13
+ "prompt is too long",
14
+ "prompt_too_long",
15
+ "context length exceeded",
16
+ "context_length_exceeded",
17
+ "maximum context length",
18
+ "token limit exceeded",
19
+ "too many tokens",
20
+ ];
21
+ /**
22
+ * Check if an error body indicates context overflow
23
+ */
24
+ export function isContextOverflowError(status, bodyText) {
25
+ if (status !== 400)
26
+ return false;
27
+ if (!bodyText)
28
+ return false;
29
+ const lowerBody = bodyText.toLowerCase();
30
+ return CONTEXT_OVERFLOW_PATTERNS.some(pattern => lowerBody.includes(pattern));
31
+ }
32
+ /**
33
+ * The message shown to users when context overflow occurs
34
+ */
35
+ const CONTEXT_OVERFLOW_MESSAGE = `[Plugin Notice] Context is too long for this model.
36
+
37
+ Please use one of these commands to reduce context size:
38
+
39
+ • **/compact** - Compress conversation history (recommended)
40
+ • **/clear** - Start fresh with empty context
41
+ • **/undo** - Remove recent messages
42
+
43
+ Then retry your request.
44
+
45
+ Alternatively, you can switch to a model with a larger context window.`;
46
+ /**
47
+ * Creates a synthetic SSE response for context overflow errors.
48
+ * This returns a 200 OK with the error message as assistant text,
49
+ * preventing the session from getting locked.
50
+ */
51
+ export function createContextOverflowResponse(model = "unknown") {
52
+ const messageId = `msg_synthetic_overflow_${Date.now()}`;
53
+ const events = [];
54
+ // message_start
55
+ events.push(`event: message_start\ndata: ${JSON.stringify({
56
+ type: "message_start",
57
+ message: {
58
+ id: messageId,
59
+ type: "message",
60
+ role: "assistant",
61
+ content: [],
62
+ model,
63
+ usage: { input_tokens: 0, output_tokens: 0 },
64
+ },
65
+ })}\n\n`);
66
+ // content_block_start
67
+ events.push(`event: content_block_start\ndata: ${JSON.stringify({
68
+ type: "content_block_start",
69
+ index: 0,
70
+ content_block: { type: "text", text: "" },
71
+ })}\n\n`);
72
+ // content_block_delta (the actual message)
73
+ events.push(`event: content_block_delta\ndata: ${JSON.stringify({
74
+ type: "content_block_delta",
75
+ index: 0,
76
+ delta: { type: "text_delta", text: CONTEXT_OVERFLOW_MESSAGE },
77
+ })}\n\n`);
78
+ // content_block_stop
79
+ events.push(`event: content_block_stop\ndata: ${JSON.stringify({
80
+ type: "content_block_stop",
81
+ index: 0,
82
+ })}\n\n`);
83
+ // message_delta (end_turn)
84
+ events.push(`event: message_delta\ndata: ${JSON.stringify({
85
+ type: "message_delta",
86
+ delta: { stop_reason: "end_turn" },
87
+ usage: { output_tokens: 0 },
88
+ })}\n\n`);
89
+ // message_stop
90
+ events.push(`event: message_stop\ndata: ${JSON.stringify({
91
+ type: "message_stop",
92
+ })}\n\n`);
93
+ return new Response(events.join(""), {
94
+ status: 200,
95
+ headers: {
96
+ "Content-Type": "text/event-stream",
97
+ "X-Codex-Plugin-Synthetic": "true",
98
+ "X-Codex-Plugin-Error-Type": "context_overflow",
99
+ },
100
+ });
101
+ }
102
+ /**
103
+ * Check response for context overflow and return synthetic response if needed
104
+ */
105
+ export async function handleContextOverflow(response, model) {
106
+ if (response.status !== 400) {
107
+ return { handled: false };
108
+ }
109
+ try {
110
+ const bodyText = await response.clone().text();
111
+ if (isContextOverflowError(response.status, bodyText)) {
112
+ console.log(`[${PLUGIN_NAME}] Context overflow detected, returning synthetic response`);
113
+ return {
114
+ handled: true,
115
+ response: createContextOverflowResponse(model),
116
+ };
117
+ }
118
+ }
119
+ catch {
120
+ // Ignore read errors
121
+ }
122
+ return { handled: false };
123
+ }
124
+ //# sourceMappingURL=context-overflow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-overflow.js","sourceRoot":"","sources":["../../lib/context-overflow.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;GAEG;AACH,MAAM,yBAAyB,GAAG;IAChC,oBAAoB;IACpB,iBAAiB;IACjB,yBAAyB;IACzB,yBAAyB;IACzB,wBAAwB;IACxB,sBAAsB;IACtB,iBAAiB;CAClB,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAc,EAAE,QAAgB;IACrE,IAAI,MAAM,KAAK,GAAG;QAAE,OAAO,KAAK,CAAC;IACjC,IAAI,CAAC,QAAQ;QAAE,OAAO,KAAK,CAAC;IAE5B,MAAM,SAAS,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;IACzC,OAAO,yBAAyB,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;IAED,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AAC5B,CAAC"}
@@ -0,0 +1,13 @@
1
+ export * from "./accounts.js";
2
+ export * from "./storage.js";
3
+ export * from "./config.js";
4
+ export * from "./constants.js";
5
+ export * from "./types.js";
6
+ export * from "./logger.js";
7
+ export * from "./auth/auth.js";
8
+ export * from "./request/fetch-helpers.js";
9
+ export * from "./request/request-transformer.js";
10
+ export * from "./request/response-handler.js";
11
+ export * from "./request/rate-limit-backoff.js";
12
+ export * from "./prompts/codex.js";
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kCAAkC,CAAC;AACjD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iCAAiC,CAAC;AAChD,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1,13 @@
1
+ export * from "./accounts.js";
2
+ export * from "./storage.js";
3
+ export * from "./config.js";
4
+ export * from "./constants.js";
5
+ export * from "./types.js";
6
+ export * from "./logger.js";
7
+ export * from "./auth/auth.js";
8
+ export * from "./request/fetch-helpers.js";
9
+ export * from "./request/request-transformer.js";
10
+ export * from "./request/response-handler.js";
11
+ export * from "./request/rate-limit-backoff.js";
12
+ export * from "./prompts/codex.js";
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kCAAkC,CAAC;AACjD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iCAAiC,CAAC;AAChD,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1,22 @@
1
+ export type LogLevel = "debug" | "info" | "warn" | "error";
2
+ export declare const LOGGING_ENABLED: boolean;
3
+ export declare const DEBUG_ENABLED: boolean;
4
+ export declare const LOG_LEVEL: LogLevel;
5
+ declare function formatDuration(ms: number): string;
6
+ export declare function logRequest(stage: string, data: Record<string, unknown>): void;
7
+ export declare function logDebug(message: string, data?: unknown): void;
8
+ export declare function logInfo(message: string, data?: unknown): void;
9
+ export declare function logWarn(message: string, data?: unknown): void;
10
+ export declare function logError(message: string, data?: unknown): void;
11
+ export interface ScopedLogger {
12
+ debug(message: string, data?: unknown): void;
13
+ info(message: string, data?: unknown): void;
14
+ warn(message: string, data?: unknown): void;
15
+ error(message: string, data?: unknown): void;
16
+ time(label: string): () => number;
17
+ timeEnd(label: string, startTime: number): void;
18
+ }
19
+ export declare function createLogger(scope: string): ScopedLogger;
20
+ export declare function getRequestId(): number;
21
+ export { formatDuration };
22
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../lib/logger.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAgB3D,eAAO,MAAM,eAAe,SAAoD,CAAC;AACjF,eAAO,MAAM,aAAa,SAA4D,CAAC;AACvF,eAAO,MAAM,SAAS,UAAoD,CAAC;AAkB3E,iBAAS,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAM1C;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,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