oc-codex-multi-auth 6.22.0 → 6.24.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.
- package/LICENSE +21 -21
- package/README.md +793 -729
- package/assets/icon.svg +7 -7
- package/assets/opencode-logo-ornate-dark.svg +18 -18
- package/assets/readme-hero.svg +31 -31
- package/config/README.md +197 -177
- package/config/minimal-opencode.json +14 -14
- package/config/opencode-legacy.json +1346 -1496
- package/config/opencode-modern.json +466 -555
- package/dist/index.d.ts +7 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +37 -19
- package/dist/index.js.map +1 -1
- package/dist/lib/accounts/warm-request.d.ts.map +1 -1
- package/dist/lib/accounts/warm-request.js +9 -11
- package/dist/lib/accounts/warm-request.js.map +1 -1
- package/dist/lib/codex-usage.d.ts +35 -0
- package/dist/lib/codex-usage.d.ts.map +1 -1
- package/dist/lib/codex-usage.js +51 -0
- package/dist/lib/codex-usage.js.map +1 -1
- package/dist/lib/config.d.ts +5 -3
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +2 -0
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/constants.d.ts +13 -0
- package/dist/lib/constants.d.ts.map +1 -1
- package/dist/lib/constants.js +13 -0
- package/dist/lib/constants.js.map +1 -1
- package/dist/lib/context-overflow.js +10 -10
- package/dist/lib/desktop-notifications.js +6 -6
- package/dist/lib/oauth-success.js +202 -202
- package/dist/lib/opencode-v2-provider.d.ts +2 -0
- package/dist/lib/opencode-v2-provider.d.ts.map +1 -0
- package/dist/lib/opencode-v2-provider.js +4 -0
- package/dist/lib/opencode-v2-provider.js.map +1 -0
- package/dist/lib/opencode-v2-rpc.d.ts +27 -0
- package/dist/lib/opencode-v2-rpc.d.ts.map +1 -0
- package/dist/lib/opencode-v2-rpc.js +16 -0
- package/dist/lib/opencode-v2-rpc.js.map +1 -0
- package/dist/lib/opencode-v2-status.d.ts +17 -0
- package/dist/lib/opencode-v2-status.d.ts.map +1 -0
- package/dist/lib/opencode-v2-status.js +91 -0
- package/dist/lib/opencode-v2-status.js.map +1 -0
- package/dist/lib/opencode-v2-tui.d.ts +4 -0
- package/dist/lib/opencode-v2-tui.d.ts.map +1 -0
- package/dist/lib/opencode-v2-tui.js +105 -0
- package/dist/lib/opencode-v2-tui.js.map +1 -0
- package/dist/lib/opencode-v2.d.ts +11 -0
- package/dist/lib/opencode-v2.d.ts.map +1 -0
- package/dist/lib/opencode-v2.js +235 -0
- package/dist/lib/opencode-v2.js.map +1 -0
- package/dist/lib/prompts/codex-opencode-bridge.js +67 -67
- package/dist/lib/prompts/codex.d.ts +12 -2
- package/dist/lib/prompts/codex.d.ts.map +1 -1
- package/dist/lib/prompts/codex.js +126 -91
- package/dist/lib/prompts/codex.js.map +1 -1
- package/dist/lib/quota-capacity.d.ts +4 -0
- package/dist/lib/quota-capacity.d.ts.map +1 -0
- package/dist/lib/quota-capacity.js +45 -0
- package/dist/lib/quota-capacity.js.map +1 -0
- package/dist/lib/quota-overview.d.ts +13 -27
- package/dist/lib/quota-overview.d.ts.map +1 -1
- package/dist/lib/quota-overview.js +59 -99
- package/dist/lib/quota-overview.js.map +1 -1
- package/dist/lib/quota-recovery.d.ts +5 -0
- package/dist/lib/quota-recovery.d.ts.map +1 -0
- package/dist/lib/quota-recovery.js +66 -0
- package/dist/lib/quota-recovery.js.map +1 -0
- package/dist/lib/request/fetch-helpers.d.ts +1 -1
- package/dist/lib/request/fetch-helpers.d.ts.map +1 -1
- package/dist/lib/request/fetch-helpers.js +85 -51
- package/dist/lib/request/fetch-helpers.js.map +1 -1
- package/dist/lib/request/helpers/model-map.d.ts +10 -0
- package/dist/lib/request/helpers/model-map.d.ts.map +1 -1
- package/dist/lib/request/helpers/model-map.js +39 -11
- package/dist/lib/request/helpers/model-map.js.map +1 -1
- package/dist/lib/request/helpers/responses-lite.d.ts.map +1 -1
- package/dist/lib/request/helpers/responses-lite.js +4 -1
- package/dist/lib/request/helpers/responses-lite.js.map +1 -1
- package/dist/lib/request/request-transformer.d.ts.map +1 -1
- package/dist/lib/request/request-transformer.js +37 -15
- package/dist/lib/request/request-transformer.js.map +1 -1
- package/dist/lib/schemas.d.ts +9 -1
- package/dist/lib/schemas.d.ts.map +1 -1
- package/dist/lib/schemas.js +3 -2
- package/dist/lib/schemas.js.map +1 -1
- package/dist/lib/storage/state.d.ts +8 -0
- package/dist/lib/storage/state.d.ts.map +1 -1
- package/dist/lib/storage/state.js +47 -20
- package/dist/lib/storage/state.js.map +1 -1
- package/dist/lib/tools/codex-limits.d.ts.map +1 -1
- package/dist/lib/tools/codex-limits.js +49 -3
- package/dist/lib/tools/codex-limits.js.map +1 -1
- package/dist/lib/tui-quota-cache.d.ts +1 -0
- package/dist/lib/tui-quota-cache.d.ts.map +1 -1
- package/dist/lib/tui-quota-cache.js +2 -0
- package/dist/lib/tui-quota-cache.js.map +1 -1
- package/dist/lib/tui-quota-overview.d.ts.map +1 -1
- package/dist/lib/tui-quota-overview.js +4 -0
- package/dist/lib/tui-quota-overview.js.map +1 -1
- package/dist/lib/tui-status-slot.d.ts +3 -0
- package/dist/lib/tui-status-slot.d.ts.map +1 -0
- package/dist/lib/tui-status-slot.js +27 -0
- package/dist/lib/tui-status-slot.js.map +1 -0
- package/dist/lib/tui-status.d.ts +1 -0
- package/dist/lib/tui-status.d.ts.map +1 -1
- package/dist/lib/tui-status.js +1 -0
- package/dist/lib/tui-status.js.map +1 -1
- package/dist/tui.d.ts +10 -3
- package/dist/tui.d.ts.map +1 -1
- package/dist/tui.js +22 -1
- package/dist/tui.js.map +1 -1
- package/package.json +157 -155
- package/scripts/audit-dev-allowlist.js +114 -114
- package/scripts/clean-dist.js +27 -27
- package/scripts/copy-oauth-success.js +47 -47
- package/scripts/install-oc-codex-multi-auth-core.js +2092 -2003
- package/scripts/install-oc-codex-multi-auth.js +37 -37
- package/scripts/test-all-models.sh +260 -260
- package/scripts/validate-model-map.sh +97 -97
package/dist/index.d.ts
CHANGED
|
@@ -41,5 +41,11 @@ import type { Plugin } from "@opencode-ai/plugin";
|
|
|
41
41
|
*/
|
|
42
42
|
export declare const OpenAIOAuthPlugin: Plugin;
|
|
43
43
|
export declare const OpenAIAuthPlugin: Plugin;
|
|
44
|
-
|
|
44
|
+
declare const _default: {
|
|
45
|
+
id: string;
|
|
46
|
+
server: Plugin;
|
|
47
|
+
/** V2 loads the same package through setup instead of the V1 server hook. */
|
|
48
|
+
setup(context: import("@opencode/plugin").Plugin.Context): Promise<() => Promise<void>>;
|
|
49
|
+
};
|
|
50
|
+
export default _default;
|
|
45
51
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAYH,OAAO,KAAK,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAYH,OAAO,KAAK,EAAE,MAAM,EAAsB,MAAM,qBAAqB,CAAC;AAsVtE;;;;;;;;;;;;;;;GAeG;AAEH,eAAO,MAAM,iBAAiB,EAAE,MAA2E,CAAC;AA+qJ5G,eAAO,MAAM,gBAAgB,QAAoB,CAAC;;;;IAKjD,6EAA6E;mBACxD,OAAO,kBAAkB,EAAE,MAAM,CAAC,OAAO;;AAJ/D,wBAQE"}
|
package/dist/index.js
CHANGED
|
@@ -40,7 +40,7 @@ import { applyAccountSelectionFallbacks, persistResolvedAccountSelection, persis
|
|
|
40
40
|
import { coordinateFlaggedPersistedRefresh, coordinatePersistedRefresh, } from "./lib/storage/coordinated-refresh.js";
|
|
41
41
|
import { promptAddAnotherAccount, promptLoginMode } from "./lib/cli.js";
|
|
42
42
|
import { getCodexMode, getRequestTransformMode, getFastSession, getFastSessionStrategy, getFastSessionMaxInputItems, getRetryProfile, getRetryBudgetOverrides, getRateLimitToastDebounceMs, getRetryAllAccountsMaxRetries, getRetryAllAccountsMaxWaitMs, getRetryAllAccountsRateLimited, getFallbackToGpt52OnUnsupportedGpt53, getUnsupportedCodexPolicy, getUnsupportedCodexFallbackChain, getTokenRefreshSkewMs, getSessionRecovery, getAutoResume, getAutoUpdate, getToastDurationMs, getAccountToastsEnabled, getPerProjectAccounts, getEmptyResponseMaxRetries, getEmptyResponseRetryDelayMs, getPidOffsetEnabled, getRotationStrategy, getModelAccountPool, getModelAccountPoolMode, getFetchTimeoutMs, getStreamStallTimeoutMs, getCodexTuiV2, getCodexTuiColorProfile, getCodexTuiGlyphMode, getBeginnerSafeMode, getCodexTuiMaskEmail, getQuotaDisplay, loadPluginConfig, } from "./lib/config.js";
|
|
43
|
-
import { AUTH_LABELS, CODEX_BASE_URL, DUMMY_API_KEY, LOG_STAGES, PLUGIN_NAME, PROVIDER_ID, ACCOUNT_LIMITS, } from "./lib/constants.js";
|
|
43
|
+
import { AUTH_LABELS, CODEX_BASE_URL, DUMMY_API_KEY, LOG_STAGES, PLUGIN_NAME, PROVIDER_ID, ACCOUNT_LIMITS, MAX_QUOTA_FALLBACK_SWITCHES, } from "./lib/constants.js";
|
|
44
44
|
import { initLogger, logRequest, logDebug, logInfo, logWarn, logError, setCorrelationId, clearCorrelationId, } from "./lib/logger.js";
|
|
45
45
|
import { createQuotaMonitor } from "./lib/quota-notifications.js";
|
|
46
46
|
import { checkAndNotify } from "./lib/auto-update-checker.js";
|
|
@@ -179,8 +179,16 @@ function resolveOpenAIBaseURL() {
|
|
|
179
179
|
* }
|
|
180
180
|
* ```
|
|
181
181
|
*/
|
|
182
|
-
export const OpenAIOAuthPlugin = async ({ client }) => {
|
|
183
|
-
|
|
182
|
+
export const OpenAIOAuthPlugin = async ({ client }) => createPluginRuntime({ client });
|
|
183
|
+
/**
|
|
184
|
+
* Shared request/account runtime; V2 has no V1 client or host auth.json.
|
|
185
|
+
*
|
|
186
|
+
* Not exported: V1 hosts call every function this module exports as a plugin,
|
|
187
|
+
* so an exported factory would boot a second runtime beside the real one. The
|
|
188
|
+
* V2 entry receives it through `setup` instead.
|
|
189
|
+
*/
|
|
190
|
+
async function createPluginRuntime({ client, directory = process.cwd() }) {
|
|
191
|
+
initLogger(client ?? {});
|
|
184
192
|
let customBaseURLWarningShown = false;
|
|
185
193
|
let customBaseURLErrorShown = false;
|
|
186
194
|
let cachedAccountManager = null;
|
|
@@ -456,7 +464,7 @@ export const OpenAIOAuthPlugin = async ({ client }) => {
|
|
|
456
464
|
};
|
|
457
465
|
const showToast = async (message, variant = "success", options) => {
|
|
458
466
|
try {
|
|
459
|
-
await client
|
|
467
|
+
await client?.tui.showToast({
|
|
460
468
|
body: {
|
|
461
469
|
message,
|
|
462
470
|
variant,
|
|
@@ -1478,6 +1486,8 @@ export const OpenAIOAuthPlugin = async ({ client }) => {
|
|
|
1478
1486
|
if (event.type === "server.instance.disposed") {
|
|
1479
1487
|
quotaMonitor.dispose();
|
|
1480
1488
|
disposeAccountsWatcher();
|
|
1489
|
+
await cachedAccountManager?.flushPendingSave();
|
|
1490
|
+
cachedAccountManager?.disposeShutdownHandler();
|
|
1481
1491
|
return;
|
|
1482
1492
|
}
|
|
1483
1493
|
// Handle TUI account selection events
|
|
@@ -1585,8 +1595,9 @@ export const OpenAIOAuthPlugin = async ({ client }) => {
|
|
|
1585
1595
|
};
|
|
1586
1596
|
const startupPluginConfig = loadPluginConfig();
|
|
1587
1597
|
const startupPerProjectAccounts = getPerProjectAccounts(startupPluginConfig);
|
|
1588
|
-
setStoragePath(startupPerProjectAccounts ?
|
|
1589
|
-
|
|
1598
|
+
setStoragePath(startupPerProjectAccounts ? directory : null);
|
|
1599
|
+
if (client)
|
|
1600
|
+
await backfillHostOpenAIAuthFromPool();
|
|
1590
1601
|
quotaMonitor.start();
|
|
1591
1602
|
return {
|
|
1592
1603
|
event: eventHandler,
|
|
@@ -1635,7 +1646,7 @@ export const OpenAIOAuthPlugin = async ({ client }) => {
|
|
|
1635
1646
|
let perProjectAccounts = getPerProjectAccounts(pluginConfig);
|
|
1636
1647
|
let storageTransition;
|
|
1637
1648
|
const activeFetches = new Set();
|
|
1638
|
-
setStoragePath(perProjectAccounts ?
|
|
1649
|
+
setStoragePath(perProjectAccounts ? directory : null);
|
|
1639
1650
|
const authFallback = auth.type === "oauth" ? auth : undefined;
|
|
1640
1651
|
// Prefer multi-account auth metadata when available, but still handle
|
|
1641
1652
|
// plain OAuth credentials (for OpenCode versions that inject internal
|
|
@@ -1744,8 +1755,8 @@ export const OpenAIOAuthPlugin = async ({ client }) => {
|
|
|
1744
1755
|
prewarmOpenCodeCodexPrompt();
|
|
1745
1756
|
}
|
|
1746
1757
|
}
|
|
1747
|
-
const recoveryHook = sessionRecoveryEnabled
|
|
1748
|
-
? createSessionRecoveryHook({ client, directory
|
|
1758
|
+
const recoveryHook = sessionRecoveryEnabled && client
|
|
1759
|
+
? createSessionRecoveryHook({ client, directory }, { sessionRecovery: true, autoResume: autoResumeEnabled })
|
|
1749
1760
|
: null;
|
|
1750
1761
|
const pluginOrigin = getPluginOrigin();
|
|
1751
1762
|
if (pluginOrigin && !startupOriginRecorded) {
|
|
@@ -1800,7 +1811,7 @@ export const OpenAIOAuthPlugin = async ({ client }) => {
|
|
|
1800
1811
|
await Promise.all(activeFetches);
|
|
1801
1812
|
// Drain the old pool's pending write before changing the global path.
|
|
1802
1813
|
await cachedAccountManager?.flushPendingSave();
|
|
1803
|
-
setStoragePath(currentPerProjectAccounts ?
|
|
1814
|
+
setStoragePath(currentPerProjectAccounts ? directory : null);
|
|
1804
1815
|
invalidateAccountManagerCache();
|
|
1805
1816
|
perProjectAccounts = currentPerProjectAccounts;
|
|
1806
1817
|
})().finally(() => { storageTransition = undefined; });
|
|
@@ -2148,9 +2159,7 @@ export const OpenAIOAuthPlugin = async ({ client }) => {
|
|
|
2148
2159
|
}
|
|
2149
2160
|
};
|
|
2150
2161
|
// A degraded model must not degrade again without bound, even if a
|
|
2151
|
-
// custom chain is cyclic.
|
|
2152
|
-
// revisiting a model; this caps the total hops per request.
|
|
2153
|
-
const MAX_QUOTA_FALLBACK_SWITCHES = 3;
|
|
2162
|
+
// custom chain is cyclic. See MAX_QUOTA_FALLBACK_SWITCHES.
|
|
2154
2163
|
let quotaFallbackSwitches = 0;
|
|
2155
2164
|
while (true) {
|
|
2156
2165
|
if (cachedAccountManager && cachedAccountManager !== accountManager) {
|
|
@@ -3129,7 +3138,7 @@ export const OpenAIOAuthPlugin = async ({ client }) => {
|
|
|
3129
3138
|
const authPluginConfig = loadPluginConfig();
|
|
3130
3139
|
applyUiRuntimeFromConfig(authPluginConfig);
|
|
3131
3140
|
const authPerProjectAccounts = getPerProjectAccounts(authPluginConfig);
|
|
3132
|
-
setStoragePath(authPerProjectAccounts ?
|
|
3141
|
+
setStoragePath(authPerProjectAccounts ? directory : null);
|
|
3133
3142
|
const accounts = [];
|
|
3134
3143
|
// Programmatic input, not a menu choice: a headless caller or
|
|
3135
3144
|
// script passes it to say "never launch a browser". Ignoring it
|
|
@@ -3888,7 +3897,7 @@ export const OpenAIOAuthPlugin = async ({ client }) => {
|
|
|
3888
3897
|
const manualBrowserPluginConfig = loadPluginConfig();
|
|
3889
3898
|
applyUiRuntimeFromConfig(manualBrowserPluginConfig);
|
|
3890
3899
|
const manualBrowserPerProjectAccounts = getPerProjectAccounts(manualBrowserPluginConfig);
|
|
3891
|
-
setStoragePath(manualBrowserPerProjectAccounts ?
|
|
3900
|
+
setStoragePath(manualBrowserPerProjectAccounts ? directory : null);
|
|
3892
3901
|
const session = await startLoopbackFlow({ openBrowser: false });
|
|
3893
3902
|
if (session.type === "unavailable") {
|
|
3894
3903
|
const message = unavailableMessage(session.lifecycle);
|
|
@@ -3936,7 +3945,7 @@ export const OpenAIOAuthPlugin = async ({ client }) => {
|
|
|
3936
3945
|
const devicePluginConfig = loadPluginConfig();
|
|
3937
3946
|
applyUiRuntimeFromConfig(devicePluginConfig);
|
|
3938
3947
|
const devicePerProjectAccounts = getPerProjectAccounts(devicePluginConfig);
|
|
3939
|
-
setStoragePath(devicePerProjectAccounts ?
|
|
3948
|
+
setStoragePath(devicePerProjectAccounts ? directory : null);
|
|
3940
3949
|
const started = await createDeviceCodeSession();
|
|
3941
3950
|
if (started.type === "failed") {
|
|
3942
3951
|
return {
|
|
@@ -3974,7 +3983,7 @@ export const OpenAIOAuthPlugin = async ({ client }) => {
|
|
|
3974
3983
|
const manualPluginConfig = loadPluginConfig();
|
|
3975
3984
|
applyUiRuntimeFromConfig(manualPluginConfig);
|
|
3976
3985
|
const manualPerProjectAccounts = getPerProjectAccounts(manualPluginConfig);
|
|
3977
|
-
setStoragePath(manualPerProjectAccounts ?
|
|
3986
|
+
setStoragePath(manualPerProjectAccounts ? directory : null);
|
|
3978
3987
|
const { pkce, state, url } = await createAuthorizationFlow();
|
|
3979
3988
|
return buildManualOAuthFlow(pkce, url, state, false);
|
|
3980
3989
|
},
|
|
@@ -3983,7 +3992,16 @@ export const OpenAIOAuthPlugin = async ({ client }) => {
|
|
|
3983
3992
|
},
|
|
3984
3993
|
tool: createToolRegistry(ctx),
|
|
3985
3994
|
};
|
|
3986
|
-
}
|
|
3995
|
+
}
|
|
3996
|
+
;
|
|
3987
3997
|
export const OpenAIAuthPlugin = OpenAIOAuthPlugin;
|
|
3988
|
-
export default
|
|
3998
|
+
export default {
|
|
3999
|
+
id: "oc-codex-multi-auth",
|
|
4000
|
+
server: OpenAIOAuthPlugin,
|
|
4001
|
+
/** V2 loads the same package through setup instead of the V1 server hook. */
|
|
4002
|
+
async setup(context) {
|
|
4003
|
+
const { setupV2 } = await import("./lib/opencode-v2.js");
|
|
4004
|
+
return setupV2(context, createPluginRuntime);
|
|
4005
|
+
},
|
|
4006
|
+
};
|
|
3989
4007
|
//# sourceMappingURL=index.js.map
|