@bitkyc08/opencodex 2.100.3 → 2.100.5-preview.20261118.1
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/AGENTS_INSTALL.md +23 -1
- package/bin/ocx.mjs +8 -1
- package/gui/dist/assets/{App-Dnb6VMsP.js → App-BiOGtxDS.js} +21 -20
- package/gui/dist/assets/{Tray-BV4ms9U9.js → Tray-BwsMejUO.js} +1 -1
- package/gui/dist/assets/brand-mark-BY1dgACL.js +1 -0
- package/gui/dist/assets/{index-DCdXsMyZ.js → index-CwHSKMdG.js} +46 -13
- package/gui/dist/assets/index-DJxM-imn.css +2 -0
- package/gui/dist/assets/{segment-thumb-features-DXSidY6D.js → segment-thumb-features-Bds9Hb_7.js} +1 -1
- package/gui/dist/classic/assets/{App-DA-scMPq.js → App-CGLOiqQL.js} +20 -19
- package/gui/dist/classic/assets/{Tray-BrHaVRAq.js → Tray-Da4r2O70.js} +1 -1
- package/gui/dist/classic/assets/{index-BqOaGLf5.js → index-CvoKXKL9.js} +46 -13
- package/gui/dist/classic/assets/quota-summary-DvqzfCmr.js +1 -0
- package/gui/dist/classic/index.html +1 -1
- package/gui/dist/index.html +2 -2
- package/native/ocx-child/src/cli.rs +5 -3
- package/native/ocx-child/src/codex_home.rs +1 -0
- package/native/ocx-child/src/link_ws.rs +24 -19
- package/native/ocx-child/src/link_ws_frame.rs +136 -50
- package/package.json +3 -3
- package/src/adapters/anthropic/per-message-effort.ts +296 -0
- package/src/adapters/anthropic-input-schema.ts +270 -0
- package/src/adapters/anthropic.ts +4 -63
- package/src/adapters/claude-cli/adapter.ts +1 -0
- package/src/adapters/command-code-tool-text.ts +9 -1
- package/src/adapters/command-code.ts +18 -2
- package/src/adapters/devin/cloud-direct/chat.ts +95 -14
- package/src/adapters/devin/live-models.ts +11 -1
- package/src/adapters/google-errors.ts +14 -2
- package/src/adapters/kiro/reasoning.ts +3 -0
- package/src/adapters/kiro-tools.ts +14 -9
- package/src/adapters/openai-responses/passthrough.ts +3 -1
- package/src/adapters/openai-responses/request-strips.ts +1 -0
- package/src/adapters/qoder/adapter.ts +9 -1
- package/src/adapters/tool-catalog-nudge.ts +1 -1
- package/src/adapters/zed.ts +4 -2
- package/src/claude/chat-tool-dispatch.ts +4 -1
- package/src/claude/desktop-remote-store.ts +60 -10
- package/src/cli/account-api.ts +4 -0
- package/src/cli/account-auth.ts +30 -2
- package/src/cli/account-extended.ts +33 -2
- package/src/cli/capabilities-access-remote.ts +3 -3
- package/src/cli/capabilities-accounts.ts +3 -3
- package/src/cli/capabilities-base.ts +11 -6
- package/src/cli/capabilities-observe-system.ts +2 -2
- package/src/cli/claude.ts +3 -3
- package/src/cli/disconnect-runtime.ts +16 -6
- package/src/cli/dispatch.ts +7 -1
- package/src/cli/index.ts +2 -2
- package/src/cli/link-apply-restart.ts +4 -2
- package/src/cli/link-routes.ts +4 -1
- package/src/cli/link.ts +5 -4
- package/src/cli/logout-command.ts +23 -4
- package/src/cli/preflight-exemptions.ts +3 -0
- package/src/cli/provider.ts +3 -2
- package/src/cli/registry.ts +5 -2
- package/src/cli/resolve.ts +23 -8
- package/src/cli/restart-failure.ts +11 -1
- package/src/cli/runtime-api.ts +4 -0
- package/src/cli/status.ts +4 -1
- package/src/cli/system-command.ts +1 -1
- package/src/cli/system-restart-client.ts +9 -3
- package/src/cli/system-settings-parity.ts +2 -1
- package/src/client/connect.ts +73 -11
- package/src/client/desktop-refusal.ts +38 -0
- package/src/client/lifecycle-lock.ts +29 -4
- package/src/client/runtime-restart.ts +27 -15
- package/src/client/runtime.ts +4 -2
- package/src/client/state.ts +14 -0
- package/src/clients/config-export.ts +12 -7
- package/src/codex/account-lifecycle.ts +3 -1
- package/src/codex/account-pause.ts +4 -0
- package/src/codex/account-runtime-state.ts +4 -0
- package/src/codex/auth-api/main-account-probe.ts +3 -1
- package/src/codex/auth-api/main-hard-lock-refusal-read.ts +172 -0
- package/src/codex/auth-context.ts +40 -2
- package/src/codex/catalog/build-entries.ts +10 -0
- package/src/codex/catalog/derive-entry.ts +7 -0
- package/src/codex/catalog/metadata.ts +8 -0
- package/src/codex/catalog/native-models.ts +16 -6
- package/src/codex/catalog/pinned-models.ts +1 -0
- package/src/codex/catalog/provider-models.ts +5 -5
- package/src/codex/catalog/reserve-warn.ts +7 -5
- package/src/codex/catalog/reserve.ts +4 -3
- package/src/codex/catalog/retained-sync.ts +2 -0
- package/src/codex/catalog/routed-defaults.ts +35 -0
- package/src/codex/catalog-auto-refresh.ts +13 -2
- package/src/codex/config-drift-heal.ts +40 -12
- package/src/codex/config-write-lock.ts +39 -1
- package/src/codex/convergence.ts +2 -0
- package/src/codex/data/roster-pinned-models.json +346 -1
- package/src/codex/inject/config-write-section.ts +39 -1
- package/src/codex/inject/plan.ts +10 -8
- package/src/codex/inject/remove.ts +21 -19
- package/src/codex/inject/restore.ts +5 -1
- package/src/codex/inject-coordination.ts +58 -7
- package/src/codex/inject.ts +10 -12
- package/src/codex/journal-config-restore.ts +42 -0
- package/src/codex/journal.ts +62 -8
- package/src/codex/loopback-target.ts +22 -8
- package/src/codex/main-account.ts +94 -30
- package/src/codex/native-main-auth-file.ts +14 -0
- package/src/codex/native-main-credentials.ts +276 -0
- package/src/codex/native-main-owner.ts +3 -0
- package/src/codex/native-main-refresh-mode.ts +14 -1
- package/src/codex/quota.ts +63 -14
- package/src/combos/failover.ts +195 -1
- package/src/combos/index.ts +5 -0
- package/src/combos/resolve.ts +115 -19
- package/src/config/diagnostics.ts +3 -0
- package/src/config/live-reconcile.ts +6 -3
- package/src/config/load-degrade.ts +2 -0
- package/src/config/persisted-mutation.ts +2 -2
- package/src/config/persisted-projections.ts +18 -0
- package/src/config/process-state.ts +4 -3
- package/src/config/reserve-capability.ts +96 -0
- package/src/config/schema/config-schema.ts +6 -0
- package/src/config/schema/leaf-validators.ts +2 -0
- package/src/config/schema/routed-catalog-defaults.ts +49 -0
- package/src/config/subagent-models.ts +20 -12
- package/src/config.ts +7 -7
- package/src/desktop-update/acquire.ts +202 -0
- package/src/desktop-update/cli.ts +168 -0
- package/src/desktop-update/drain.ts +40 -0
- package/src/desktop-update/headless.ts +285 -0
- package/src/desktop-update/image.ts +85 -0
- package/src/desktop-update/install.ts +53 -0
- package/src/desktop-update/msi.ts +72 -0
- package/src/desktop-update/release.ts +128 -0
- package/src/desktop-update/runtime.ts +155 -0
- package/src/desktop-update/staging.ts +118 -0
- package/src/desktop-update/trust.ts +45 -0
- package/src/generated/compatibility-version.json +327 -195
- package/src/generated/model-metadata.ts +3 -3
- package/src/images/fulfill-video.ts +3 -3
- package/src/images/loop.ts +6 -2
- package/src/images/plan.ts +147 -11
- package/src/images/types.ts +13 -4
- package/src/images/xai-video-client.ts +72 -10
- package/src/lib/client-error-body.ts +6 -0
- package/src/lib/developer-role-rejection.ts +15 -0
- package/src/lib/gcp-adc.ts +48 -4
- package/src/lib/offline-resend.ts +150 -0
- package/src/lib/paced-stream.ts +3 -3
- package/src/lib/provider-outbound.ts +17 -6
- package/src/lib/request-failure-model.ts +2 -0
- package/src/lib/response-body-inactivity.ts +23 -1
- package/src/lib/upstream-retry.ts +39 -6
- package/src/link/explicit-route.ts +4 -4
- package/src/link/remote-windows.ts +79 -31
- package/src/link/residual-recovery.ts +20 -8
- package/src/messaging/budget.ts +23 -5
- package/src/messaging/remote-ports.ts +22 -10
- package/src/messaging/rpc.ts +4 -4
- package/src/oauth/antigravity-risk.ts +126 -0
- package/src/oauth/credential-siblings.ts +32 -0
- package/src/oauth/generic-account-failover.ts +113 -30
- package/src/oauth/generic-session-affinity.ts +10 -3
- package/src/oauth/index.ts +22 -14
- package/src/oauth/login-cli.ts +35 -1
- package/src/oauth/pool-kernel.ts +3 -3
- package/src/oauth/store.ts +38 -7
- package/src/providers/anthropic-billing-refusal.ts +27 -3
- package/src/providers/anthropic-reset-grants.ts +4 -0
- package/src/providers/claude-cli-usage.ts +2 -0
- package/src/providers/codebuddy-models.ts +11 -0
- package/src/providers/google-vertex-model-discovery.ts +49 -15
- package/src/providers/kiro-models.ts +5 -0
- package/src/providers/model-rename-fields.ts +2 -0
- package/src/providers/quota/workbuddy.ts +6 -2
- package/src/providers/registry/entries-core.ts +9 -3
- package/src/providers/registry/entries-extended.ts +20 -9
- package/src/providers/registry/model-seeds.ts +4 -1
- package/src/providers/stale-context-window-migration.ts +2 -0
- package/src/providers/workbuddy-credit-balance.ts +125 -16
- package/src/responses/citation-markers.ts +26 -23
- package/src/responses/effort-history.ts +732 -0
- package/src/routing/history/integrity.ts +41 -4
- package/src/server/auth-cors.ts +13 -3
- package/src/server/codex-model-list.ts +2 -1
- package/src/server/direct-local-http.ts +26 -3
- package/src/server/index/link-listener.ts +20 -14
- package/src/server/index/serve-options.ts +1 -0
- package/src/server/index.ts +3 -2
- package/src/server/link-turn.ts +17 -5
- package/src/server/management/config-routes.ts +39 -3
- package/src/server/management/link-child-preflight.ts +1 -1
- package/src/server/management/link-enrollment.ts +3 -3
- package/src/server/management/link-route-edit.ts +20 -1
- package/src/server/management/link-route-request.ts +11 -5
- package/src/server/management/oauth-account-routes.ts +43 -13
- package/src/server/management/provider-credential-release.ts +44 -0
- package/src/server/management/provider-overwrite-carry.ts +3 -0
- package/src/server/management/provider-routes.ts +12 -12
- package/src/server/management/static-catalog-probe.ts +33 -0
- package/src/server/management/usage-aggregate-cache.ts +6 -3
- package/src/server/messages-native.ts +16 -2
- package/src/server/proxy-liveness.ts +54 -9
- package/src/server/relay.ts +6 -1
- package/src/server/request-log-conversation.ts +8 -4
- package/src/server/request-log-failure-detail.ts +26 -9
- package/src/server/request-log.ts +5 -1
- package/src/server/reserve-capability-startup.ts +32 -0
- package/src/server/responses/adapter-continuation.ts +59 -25
- package/src/server/responses/adapter-delivery.ts +2 -0
- package/src/server/responses/adapter-dispatch.ts +39 -18
- package/src/server/responses/antigravity-fault-rotation.ts +24 -0
- package/src/server/responses/antigravity-validation-refusal.ts +43 -6
- package/src/server/responses/codex-tool-catalog.ts +47 -10
- package/src/server/responses/combo-selection-keepalive.ts +254 -0
- package/src/server/responses/combo-session-recall.ts +26 -1
- package/src/server/responses/combo-stream-preflight.ts +35 -26
- package/src/server/responses/core-combo-failure.ts +6 -0
- package/src/server/responses/core-combo-native.ts +2 -1
- package/src/server/responses/core-combo.ts +67 -28
- package/src/server/responses/core-errors.ts +9 -6
- package/src/server/responses/core-options.ts +10 -0
- package/src/server/responses/core.ts +21 -0
- package/src/server/responses/estimated-usage.ts +115 -0
- package/src/server/responses/input-admission.ts +41 -3
- package/src/server/responses/jev-model-invoke.ts +7 -2
- package/src/server/responses/passthrough-completion.ts +6 -3
- package/src/server/responses/passthrough-delivery.ts +47 -8
- package/src/server/responses/passthrough-dispatch.ts +3 -0
- package/src/server/responses/request-prepare.ts +9 -5
- package/src/server/responses/request-send-budget.ts +1 -1
- package/src/server/responses/request-transport.ts +10 -2
- package/src/server/responses/sidecar-execution.ts +11 -4
- package/src/service/desktop-supervision.d.mts +2 -0
- package/src/service/desktop-supervision.mjs +5 -0
- package/src/service/windows-checked-stop-live.ts +28 -5
- package/src/stall-timeout.ts +11 -0
- package/src/types/config.ts +15 -92
- package/src/types/provider.ts +13 -0
- package/src/types/request.ts +23 -3
- package/src/types/routed-catalog-defaults.ts +17 -0
- package/src/types/routing-profile.ts +90 -0
- package/src/types.ts +1 -0
- package/src/update/index.ts +1 -1
- package/src/usage/expected-prices.ts +35 -0
- package/src/usage/ledger-scanner.ts +44 -10
- package/src/usage/log.ts +14 -4
- package/src/usage/telemetry-contract.ts +1 -0
- package/src/web-search/loop.ts +20 -2
- package/src/web-search/parse.ts +2 -12
- package/src/web-search/passthrough-bridge.ts +7 -0
- package/src/web-search/sources.ts +13 -0
- package/gui/dist/assets/brand-mark-XOLJbomA.js +0 -1
- package/gui/dist/assets/index-DQtCRNAw.css +0 -2
- package/gui/dist/classic/assets/quota-summary-Dy5_wfTT.js +0 -1
package/src/oauth/login-cli.ts
CHANGED
|
@@ -18,6 +18,13 @@ import { codexAccountNamespaceProviderCollisionError } from "../codex/account-na
|
|
|
18
18
|
import { assertAnthropicInstanceLoginConfig } from "./store-anthropic-instance";
|
|
19
19
|
import { reportOAuthLoginError } from "./login-cli-errors";
|
|
20
20
|
import { terminalSafeText } from "../lib/terminal-safe-text";
|
|
21
|
+
import {
|
|
22
|
+
ANTIGRAVITY_RISK_CLI_FLAG,
|
|
23
|
+
antigravityRiskDecisionMessage,
|
|
24
|
+
requiresAntigravityRiskAcknowledgement,
|
|
25
|
+
resolveAntigravityRiskAcknowledgement,
|
|
26
|
+
} from "./antigravity-risk";
|
|
27
|
+
import { isAgentDriven } from "../cli/agent-driven";
|
|
21
28
|
|
|
22
29
|
/**
|
|
23
30
|
* Seams a test drives in place of a browser, a terminal and a real provider. Production passes
|
|
@@ -34,6 +41,10 @@ export interface LoginCliDeps {
|
|
|
34
41
|
warn?: (message: string) => void;
|
|
35
42
|
/** Ask one question, read one line. Defaults to a readline prompt that owns its own lifetime. */
|
|
36
43
|
ask?: (question: string) => Promise<string>;
|
|
44
|
+
/** Whether a person can answer a prompt. Defaults to stdin and stdout both being terminals. */
|
|
45
|
+
isInteractive?: () => boolean;
|
|
46
|
+
/** Whether a coding agent or CI runner drives this process. Defaults to isAgentDriven(). */
|
|
47
|
+
agentDriven?: () => boolean;
|
|
37
48
|
}
|
|
38
49
|
|
|
39
50
|
/**
|
|
@@ -116,10 +127,12 @@ export function warnIfLiveReloadSkipped(result: LocalProviderReloadResult | null
|
|
|
116
127
|
* that used to be their only pointer to it.
|
|
117
128
|
*/
|
|
118
129
|
export function loginUsageMessage(): string {
|
|
119
|
-
return `Usage: ocx login <provider> [--headless]\n`
|
|
130
|
+
return `Usage: ocx login <provider> [--headless] [${ANTIGRAVITY_RISK_CLI_FLAG}]\n`
|
|
120
131
|
+ ` --headless: no browser and no local port — approve in any browser, then paste the code\n`
|
|
121
132
|
+ ` it shows or confirm the device code printed here\n`
|
|
122
133
|
+ ` (${listCodeLoginProviders().join(", ")})\n`
|
|
134
|
+
+ ` ${ANTIGRAVITY_RISK_CLI_FLAG}: google-antigravity only; accept the account-ban risk without\n`
|
|
135
|
+
+ ` the interactive prompt (the warning is still printed)\n`
|
|
123
136
|
+ ` Codex / ChatGPT: ocx login codex (account pool, needs a running proxy; 'chatgpt' and\n`
|
|
124
137
|
+ ` 'openai' are the same route. An OpenAI platform key is 'openai-apikey'.)\n`
|
|
125
138
|
+ ` OAuth login: ${listOAuthProviders().join(", ")}\n`
|
|
@@ -129,10 +142,16 @@ export function loginUsageMessage(): string {
|
|
|
129
142
|
export interface LoginCliOptions {
|
|
130
143
|
/** `--headless`: no callback server, no browser launch — print the URL and read back the code. */
|
|
131
144
|
codeMode?: boolean;
|
|
145
|
+
/** `--accept-antigravity-risk`: accept the Antigravity warning without a prompt. */
|
|
146
|
+
acceptAntigravityRisk?: boolean;
|
|
132
147
|
}
|
|
133
148
|
|
|
134
149
|
export async function handleLogin(provider?: string, deps: LoginCliDeps = {}, opts: LoginCliOptions = {}): Promise<void> {
|
|
135
150
|
const name = (provider ?? "").trim().toLowerCase();
|
|
151
|
+
if (opts.acceptAntigravityRisk && !requiresAntigravityRiskAcknowledgement(DEPRECATED_OAUTH_PROVIDER_ALIASES[name] ?? name)) {
|
|
152
|
+
console.error(`${ANTIGRAVITY_RISK_CLI_FLAG} only applies to google-antigravity`);
|
|
153
|
+
process.exit(1);
|
|
154
|
+
}
|
|
136
155
|
try {
|
|
137
156
|
// Check raw ownership before tolerant loading can print diagnostics or fall back to defaults.
|
|
138
157
|
if (name === "anthropic2") assertAnthropicInstanceLoginConfig({ providers: {} }, name);
|
|
@@ -210,6 +229,21 @@ async function handleCodeLogin(name: string, deps: LoginCliDeps): Promise<void>
|
|
|
210
229
|
|
|
211
230
|
export async function handleOAuthLogin(name: string, deps: LoginCliDeps = {}, opts: LoginCliOptions = {}): Promise<void> {
|
|
212
231
|
if (name === "anthropic2") assertAnthropicInstanceLoginConfig(loadConfig(), name);
|
|
232
|
+
// Runs in-process, so there is no management API check behind it: this prompt is the gate.
|
|
233
|
+
if (requiresAntigravityRiskAcknowledgement(name)) {
|
|
234
|
+
const decision = await resolveAntigravityRiskAcknowledgement({
|
|
235
|
+
flag: opts.acceptAntigravityRisk === true,
|
|
236
|
+
// readline writes the question to stdout, so both ends must be a terminal.
|
|
237
|
+
interactive: (deps.isInteractive ?? (() => process.stdin.isTTY === true && process.stdout.isTTY === true))(),
|
|
238
|
+
agentDriven: (deps.agentDriven ?? isAgentDriven)(),
|
|
239
|
+
warn: text => console.error(text),
|
|
240
|
+
ask: question => withPrompt(deps.ask, ask => ask(question)),
|
|
241
|
+
});
|
|
242
|
+
if (decision !== "accepted") {
|
|
243
|
+
console.error(antigravityRiskDecisionMessage(decision));
|
|
244
|
+
process.exit(1);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
213
247
|
if (opts.codeMode) return handleCodeLogin(name, deps);
|
|
214
248
|
const login = deps.runLogin ?? runLogin;
|
|
215
249
|
const launch = deps.openUrl ?? openUrl;
|
package/src/oauth/pool-kernel.ts
CHANGED
|
@@ -10,8 +10,8 @@ export const POOL_KEY_ANTHROPIC = "anthropic";
|
|
|
10
10
|
* with the two dedicated kinds, and so `reconcilePoolRotationState` can recognise
|
|
11
11
|
* the entry as sweepable rather than skipping it as unknown.
|
|
12
12
|
*/
|
|
13
|
-
export function genericPoolKey(providerName: string): string {
|
|
14
|
-
return `generic:${providerName}`;
|
|
13
|
+
export function genericPoolKey(providerName: string, family?: string): string {
|
|
14
|
+
return family ? `generic:${providerName}:${family}` : `generic:${providerName}`;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
interface SelectionState {
|
|
@@ -309,7 +309,7 @@ export function reconcilePoolRotationState(context: GenerationContext): number {
|
|
|
309
309
|
: poolKey === POOL_KEY_CODEX || poolKey.startsWith(`${POOL_KEY_CODEX}:`)
|
|
310
310
|
? context.codexAccountIds
|
|
311
311
|
: poolKey.startsWith("generic:")
|
|
312
|
-
? genericIds.get(poolKey.slice("generic:".length)) ?? new Set<string>()
|
|
312
|
+
? genericIds.get(poolKey.slice("generic:".length).split(":")[0]!) ?? new Set<string>()
|
|
313
313
|
: null;
|
|
314
314
|
if (!valid) continue;
|
|
315
315
|
if (valid.size === 0) {
|
package/src/oauth/store.ts
CHANGED
|
@@ -29,6 +29,8 @@ import { normalizeWorkBuddyMetadata } from "../providers/workbuddy";
|
|
|
29
29
|
import { findKiroAccountForLogin, withRetainedKiroUser } from "./kiro-account-identity";
|
|
30
30
|
import { isAnthropicInstanceId, type AnthropicInstanceId } from "../providers/anthropic-instance-id";
|
|
31
31
|
import { assertNoCrossAnthropicRegistration, assertAnthropicCredentialSource, assertAnthropicInstanceLoginConfig } from "./store-anthropic-instance";
|
|
32
|
+
// A sibling row (Kimi (Responses)) addresses its owner's slot in every account-set API below.
|
|
33
|
+
import { oauthCredentialSiblingsOf, oauthCredentialSlot } from "./credential-siblings";
|
|
32
34
|
import { createHash, randomUUID } from "node:crypto";
|
|
33
35
|
import { chmodSync, closeSync, constants as fsConstants, copyFileSync, existsSync, fstatSync, lstatSync, mkdirSync, openSync, readFileSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
34
36
|
import { join } from "node:path";
|
|
@@ -930,7 +932,7 @@ export function mutateStore<T>(fn:(store:AuthStore)=>T|Promise<T>, retainedValue
|
|
|
930
932
|
|
|
931
933
|
/** The ACTIVE account's credential for a provider (what requests should use). */
|
|
932
934
|
export function getCredential(provider: string): OAuthCredentials | null {
|
|
933
|
-
const set = loadAuthStore()[provider];
|
|
935
|
+
const set = loadAuthStore()[oauthCredentialSlot(provider)];
|
|
934
936
|
if (!set) return null;
|
|
935
937
|
return set.accounts.find(a => a.id === set.activeAccountId)?.credential ?? null;
|
|
936
938
|
}
|
|
@@ -965,6 +967,7 @@ export async function saveCredentialWithReceipt(
|
|
|
965
967
|
cred: OAuthCredentials,
|
|
966
968
|
opts: { preserveIdentityless?: boolean; assertBeforePersist?: () => void } = {},
|
|
967
969
|
): Promise<OAuthCredentialWriteReceipt | null> {
|
|
970
|
+
provider = oauthCredentialSlot(provider);
|
|
968
971
|
if (isAnthropicInstanceId(provider)) assertAnthropicCredentialSource(provider, cred);
|
|
969
972
|
const safe = normalizeCredential(cred);
|
|
970
973
|
if (!safe) return null;
|
|
@@ -1124,6 +1127,7 @@ export async function saveCredential(
|
|
|
1124
1127
|
cred: OAuthCredentials,
|
|
1125
1128
|
opts: { preserveIdentityless?: boolean; assertBeforePersist?: () => void } = {},
|
|
1126
1129
|
): Promise<OAuthCredentialWriteReceipt | null> {
|
|
1130
|
+
provider = oauthCredentialSlot(provider);
|
|
1127
1131
|
return await saveCredentialWithReceipt(provider, cred, opts);
|
|
1128
1132
|
}
|
|
1129
1133
|
|
|
@@ -1218,6 +1222,7 @@ export async function upsertCredentialByIdentity(
|
|
|
1218
1222
|
provider: string,
|
|
1219
1223
|
cred: OAuthCredentials,
|
|
1220
1224
|
): Promise<"inserted" | "updated"> {
|
|
1225
|
+
provider = oauthCredentialSlot(provider);
|
|
1221
1226
|
if (isAnthropicInstanceId(provider)) assertAnthropicCredentialSource(provider, cred);
|
|
1222
1227
|
const safe = normalizeCredential(cred);
|
|
1223
1228
|
if (!safe || (!safe.accountId && !safe.email)) {
|
|
@@ -1269,6 +1274,7 @@ export async function upsertCredentialByIdentity(
|
|
|
1269
1274
|
* Deciding inside the mutation is the only place the answer is true when it is returned.
|
|
1270
1275
|
*/
|
|
1271
1276
|
export async function removeCredential(provider: string): Promise<"removed" | "not-found"> {
|
|
1277
|
+
provider = oauthCredentialSlot(provider);
|
|
1272
1278
|
return await mutateStore(store => {
|
|
1273
1279
|
const set = store[provider];
|
|
1274
1280
|
if (!set) return "not-found" as const;
|
|
@@ -1288,11 +1294,11 @@ export async function removeCredential(provider: string): Promise<"removed" | "n
|
|
|
1288
1294
|
// ---------------------------------------------------------------------------
|
|
1289
1295
|
|
|
1290
1296
|
export function getAccountSet(provider: string): ProviderAccountSet | null {
|
|
1291
|
-
return loadAuthStore()[provider] ?? null;
|
|
1297
|
+
return loadAuthStore()[oauthCredentialSlot(provider)] ?? null;
|
|
1292
1298
|
}
|
|
1293
1299
|
|
|
1294
1300
|
export function listAccounts(provider: string): ProviderAccount[] {
|
|
1295
|
-
return loadAuthStore()[provider]?.accounts ?? [];
|
|
1301
|
+
return loadAuthStore()[oauthCredentialSlot(provider)]?.accounts ?? [];
|
|
1296
1302
|
}
|
|
1297
1303
|
|
|
1298
1304
|
export function listLiveOAuthAccountKeys(
|
|
@@ -1300,14 +1306,14 @@ export function listLiveOAuthAccountKeys(
|
|
|
1300
1306
|
): ReadonlySet<string> {
|
|
1301
1307
|
const keys = new Set<string>();
|
|
1302
1308
|
for (const [provider, accountSet] of Object.entries(loadAuthStore())) {
|
|
1303
|
-
if (!providerNames.has(provider)) continue;
|
|
1309
|
+
if (!providerNames.has(provider) && !oauthCredentialSiblingsOf(provider).some(row => providerNames.has(row))) continue;
|
|
1304
1310
|
for (const account of accountSet.accounts) keys.add(`${provider}\0${account.id}`);
|
|
1305
1311
|
}
|
|
1306
1312
|
return keys;
|
|
1307
1313
|
}
|
|
1308
1314
|
|
|
1309
1315
|
export function getAccountCredential(provider: string, accountId: string): OAuthCredentials | null {
|
|
1310
|
-
return loadAuthStore()[provider]?.accounts.find(a => a.id === accountId)?.credential ?? null;
|
|
1316
|
+
return loadAuthStore()[oauthCredentialSlot(provider)]?.accounts.find(a => a.id === accountId)?.credential ?? null;
|
|
1311
1317
|
}
|
|
1312
1318
|
|
|
1313
1319
|
/**
|
|
@@ -1321,6 +1327,7 @@ export function getAccountCredentialWithStatus(
|
|
|
1321
1327
|
provider: string,
|
|
1322
1328
|
accountId: string,
|
|
1323
1329
|
): { credential: OAuthCredentials; needsReauth: boolean; paused: boolean } | null {
|
|
1330
|
+
provider = oauthCredentialSlot(provider);
|
|
1324
1331
|
const account = loadAuthStore()[provider]?.accounts.find(a => a.id === accountId);
|
|
1325
1332
|
if (!account?.credential) return null;
|
|
1326
1333
|
return {
|
|
@@ -1344,6 +1351,7 @@ export async function saveAccountCredential(
|
|
|
1344
1351
|
*/
|
|
1345
1352
|
opts: { assertBeforePersist?: () => void; rotateLoginId?: boolean; clearAutomaticPause?: boolean } = {},
|
|
1346
1353
|
): Promise<boolean> {
|
|
1354
|
+
provider = oauthCredentialSlot(provider);
|
|
1347
1355
|
if (isAnthropicInstanceId(provider)) assertAnthropicCredentialSource(provider, cred);
|
|
1348
1356
|
const safe = normalizeCredential(cred);
|
|
1349
1357
|
if (!safe) return false;
|
|
@@ -1402,6 +1410,7 @@ export async function commitOAuthAccountSelection(
|
|
|
1402
1410
|
requireUsableAccount?: boolean;
|
|
1403
1411
|
} = {},
|
|
1404
1412
|
): Promise<OAuthAccountSelection | null> {
|
|
1413
|
+
provider = oauthCredentialSlot(provider);
|
|
1405
1414
|
// Snapshot caller-owned options before waiting for the serialized writer.
|
|
1406
1415
|
const expected = options.expectedSelection ? { ...options.expectedSelection } : undefined;
|
|
1407
1416
|
const { expectedCredentialGeneration, requireUsableAccount } = options;
|
|
@@ -1433,6 +1442,7 @@ export async function setActiveAccount(provider: string, accountId: string): Pro
|
|
|
1433
1442
|
}
|
|
1434
1443
|
|
|
1435
1444
|
export async function setAccountAlias(provider: string, accountId: string, alias: string | undefined): Promise<boolean> {
|
|
1445
|
+
provider = oauthCredentialSlot(provider);
|
|
1436
1446
|
return await mutateStore(store => {
|
|
1437
1447
|
const account = store[provider]?.accounts.find(a => a.id === accountId);
|
|
1438
1448
|
if (!account) return false;
|
|
@@ -1498,6 +1508,7 @@ export async function setAccountPaused(
|
|
|
1498
1508
|
/** Resume only while the pause and credential are the ones a health check observed (#8398). */
|
|
1499
1509
|
resumeGuard?: { generation: string; pauseRevision: string | undefined },
|
|
1500
1510
|
): Promise<SetAccountPausedResult> {
|
|
1511
|
+
provider = oauthCredentialSlot(provider);
|
|
1501
1512
|
const result = await mutateStore(store => {
|
|
1502
1513
|
const set = store[provider];
|
|
1503
1514
|
const account = set?.accounts.find(candidate => candidate.id === accountId);
|
|
@@ -1558,6 +1569,7 @@ export async function setAccountPaused(
|
|
|
1558
1569
|
|
|
1559
1570
|
/** Remove one account by id; active removal promotes the first usable survivor when available. */
|
|
1560
1571
|
export async function removeAccount(provider: string, accountId: string): Promise<boolean> {
|
|
1572
|
+
provider = oauthCredentialSlot(provider);
|
|
1561
1573
|
const removed = await mutateStore(store => {
|
|
1562
1574
|
const set = store[provider];
|
|
1563
1575
|
if (!set) return false;
|
|
@@ -1589,6 +1601,7 @@ export async function replaceProviderAccountSet(
|
|
|
1589
1601
|
provider: string,
|
|
1590
1602
|
set: ProviderAccountSet | null,
|
|
1591
1603
|
): Promise<void> {
|
|
1604
|
+
provider = oauthCredentialSlot(provider);
|
|
1592
1605
|
await mutateStore(store => {
|
|
1593
1606
|
if (!set || set.accounts.length === 0) {
|
|
1594
1607
|
const cleared = store[provider] !== undefined;
|
|
@@ -1618,6 +1631,23 @@ export async function replaceProviderAccountSet(
|
|
|
1618
1631
|
|
|
1619
1632
|
export type ProviderCredentialRekeyOutcome = "moved" | "absent" | "conflict";
|
|
1620
1633
|
|
|
1634
|
+
/**
|
|
1635
|
+
* Clear `provider`'s login slot unless `retain()` reports that a remaining row still signs in
|
|
1636
|
+
* through it. `retain` runs inside the serialized store write, so a row published while this
|
|
1637
|
+
* release waited is seen before the credential is removed. Returns whether a slot was cleared.
|
|
1638
|
+
*/
|
|
1639
|
+
export async function releaseProviderAccountSetUnlessRetained(
|
|
1640
|
+
provider: string,
|
|
1641
|
+
retain: () => boolean,
|
|
1642
|
+
): Promise<"released" | "retained"> {
|
|
1643
|
+
provider = oauthCredentialSlot(provider);
|
|
1644
|
+
return mutateStore<"released" | "retained">(store => {
|
|
1645
|
+
if (retain()) return "retained";
|
|
1646
|
+
delete store[provider];
|
|
1647
|
+
return "released";
|
|
1648
|
+
}, [provider], { scrubLegacyBackup: outcome => outcome === "released" ? [provider] : [] });
|
|
1649
|
+
}
|
|
1650
|
+
|
|
1621
1651
|
/**
|
|
1622
1652
|
* Move a provider's whole account set to a different provider key.
|
|
1623
1653
|
*
|
|
@@ -1656,6 +1686,7 @@ export async function markAccountNeedsReauth(
|
|
|
1656
1686
|
reason?: "verify_account",
|
|
1657
1687
|
writerGeneration = captureConfigGeneration(),
|
|
1658
1688
|
): Promise<void> {
|
|
1689
|
+
provider = oauthCredentialSlot(provider);
|
|
1659
1690
|
if (writerGeneration < lastReconciledGeneration && !liveOAuthAccountKeys.has(oauthAccountKey(provider, accountId))) return;
|
|
1660
1691
|
await mutateStore(store => {
|
|
1661
1692
|
const account = store[provider]?.accounts.find(a => a.id === accountId);
|
|
@@ -1670,10 +1701,10 @@ export async function markAccountNeedsReauth(
|
|
|
1670
1701
|
}, [provider, accountId]);
|
|
1671
1702
|
}
|
|
1672
1703
|
|
|
1673
|
-
export async function mergeAccountCredential(provider:string,accountId:string,credential:OAuthCredentials,opts:{expectedGeneration?:string;afterPrePersistRead?:()=>void|Promise<void>;assertOwnership?: (store: AuthStore) => void;keepReauthMarkedAfterDispatch?:boolean}={}):Promise<{superseded:false}|{superseded:true;stored:OAuthCredentials}>{const safe=normalizeCredential(credential);if(!safe)throw new Error("Refusing to persist invalid OAuth credential");if(isAnthropicInstanceId(provider))assertAnthropicCredentialSource(provider,safe);return await mutateStore(async store=>{await opts.afterPrePersistRead?.();const account=store[provider]?.accounts.find(x=>x.id===accountId);if(!account)throw new Error(`OAuth account disappeared before persist: ${provider}`);if(opts.expectedGeneration!==undefined&&credentialGeneration(account.credential)!==opts.expectedGeneration)return{superseded:true,stored:account.credential};opts.assertOwnership?.(store);account.credential=safe;delete account.refreshAttentionGeneration;if(account.needsReauthReason!=="verify_account"&&!(opts.keepReauthMarkedAfterDispatch&&account.needsReauth)){delete account.needsReauth;delete account.needsReauthReason;}return{superseded:false};},[provider,accountId,safe,opts.expectedGeneration]);}
|
|
1704
|
+
export async function mergeAccountCredential(provider:string,accountId:string,credential:OAuthCredentials,opts:{expectedGeneration?:string;afterPrePersistRead?:()=>void|Promise<void>;assertOwnership?: (store: AuthStore) => void;keepReauthMarkedAfterDispatch?:boolean}={}):Promise<{superseded:false}|{superseded:true;stored:OAuthCredentials}>{provider=oauthCredentialSlot(provider);const safe=normalizeCredential(credential);if(!safe)throw new Error("Refusing to persist invalid OAuth credential");if(isAnthropicInstanceId(provider))assertAnthropicCredentialSource(provider,safe);return await mutateStore(async store=>{await opts.afterPrePersistRead?.();const account=store[provider]?.accounts.find(x=>x.id===accountId);if(!account)throw new Error(`OAuth account disappeared before persist: ${provider}`);if(opts.expectedGeneration!==undefined&&credentialGeneration(account.credential)!==opts.expectedGeneration)return{superseded:true,stored:account.credential};opts.assertOwnership?.(store);account.credential=safe;delete account.refreshAttentionGeneration;if(account.needsReauthReason!=="verify_account"&&!(opts.keepReauthMarkedAfterDispatch&&account.needsReauth)){delete account.needsReauth;delete account.needsReauthReason;}return{superseded:false};},[provider,accountId,safe,opts.expectedGeneration]);}
|
|
1674
1705
|
// A late refresh failure must not change an operator-paused account's health. Check under
|
|
1675
1706
|
// the mutation lock, not before awaiting it, so a concurrent pause cannot be overwritten.
|
|
1676
|
-
export async function markAccountNeedsReauthIfGeneration(provider:string,accountId:string,generation:string,writerGeneration=captureConfigGeneration(),reason?:"verify_account",isCurrent?:(store:AuthStore)=>boolean):Promise<boolean>{const key=oauthAccountKey(provider,accountId);if(writerGeneration<lastReconciledGeneration&&!liveOAuthAccountKeys.has(key))return false;return await mutateStore(store=>{const account=store[provider]?.accounts.find(x=>x.id===accountId);if(!account?.credential||account.paused||credentialGeneration(account.credential)!==generation)return false;if(writerGeneration<lastReconciledGeneration&&!liveOAuthAccountKeys.has(key))return false;if(isCurrent&&!isCurrent(store))return false;account.needsReauth=true;if(reason==="verify_account")account.needsReauthReason=reason;return true;},[provider,accountId,generation]);}
|
|
1707
|
+
export async function markAccountNeedsReauthIfGeneration(provider:string,accountId:string,generation:string,writerGeneration=captureConfigGeneration(),reason?:"verify_account",isCurrent?:(store:AuthStore)=>boolean):Promise<boolean>{provider=oauthCredentialSlot(provider);const key=oauthAccountKey(provider,accountId);if(writerGeneration<lastReconciledGeneration&&!liveOAuthAccountKeys.has(key))return false;return await mutateStore(store=>{const account=store[provider]?.accounts.find(x=>x.id===accountId);if(!account?.credential||account.paused||credentialGeneration(account.credential)!==generation)return false;if(writerGeneration<lastReconciledGeneration&&!liveOAuthAccountKeys.has(key))return false;if(isCurrent&&!isCurrent(store))return false;account.needsReauth=true;if(reason==="verify_account")account.needsReauthReason=reason;return true;},[provider,accountId,generation]);}
|
|
1677
1708
|
|
|
1678
1709
|
/** Attention is projected only; refresh selection continues to use the stored terminal flag. */
|
|
1679
1710
|
export function accountNeedsReauthForStatus(provider: string, account: ProviderAccount, now = Date.now()): boolean {
|
|
@@ -4,6 +4,9 @@ const MAX_BILLING_REFUSAL_BYTES = 8 * 1024;
|
|
|
4
4
|
const BILLING_REFUSAL_DEADLINE_MS = 250;
|
|
5
5
|
// Keep the whole-message credit-balance pattern used by anthropic-account-refusal.
|
|
6
6
|
const CREDIT_BALANCE_REFUSAL = /^Your credit balance is too low to access the Anthropic API\.(?: Please go to Plans & Billing to upgrade or purchase credits\.)?$/i;
|
|
7
|
+
// Anthropic's OAuth refusal when a turn bills against an empty extra-usage balance. Exact wording
|
|
8
|
+
// only, as above: a validation error that quotes it back must not grant a combo hop.
|
|
9
|
+
const EXTRA_USAGE_REFUSAL = /^(?:You['\u2019]re out of extra usage|Third-party apps now draw from your extra usage, not your plan limits)\.(?: Add more at claude\.ai\/settings\/usage and keep going\.)?$/i;
|
|
7
10
|
const BILLING_ERROR_TYPES = new Set(["invalid_request_error", "billing_error", "permission_error"]);
|
|
8
11
|
const ACCOUNT_REFUSAL_CODES = new Set(["subscription_required", "insufficient_quota", "permission_denied"]);
|
|
9
12
|
|
|
@@ -22,13 +25,17 @@ export function isAnthropicBillingRefusal(status: number, payload: unknown): boo
|
|
|
22
25
|
return CREDIT_BALANCE_REFUSAL.test(error.message.trim());
|
|
23
26
|
}
|
|
24
27
|
|
|
28
|
+
function withoutProviderPrefix(status: number, message: string): string {
|
|
29
|
+
const text = message.trim();
|
|
30
|
+
const prefix = `Provider error ${status}: `;
|
|
31
|
+
return text.startsWith(prefix) ? text.slice(prefix.length) : text;
|
|
32
|
+
}
|
|
33
|
+
|
|
25
34
|
/** Bounded combo evidence after existing HTTP error formatting, before any output. */
|
|
26
35
|
export function isAnthropicBillingFailure(status: number, message: string, code?: string | null): boolean {
|
|
27
36
|
if (status !== 400 && status !== 402 || Buffer.byteLength(message, "utf8") > MAX_BILLING_REFUSAL_BYTES) return false;
|
|
28
37
|
if (code != null && !BILLING_ERROR_TYPES.has(code) && !ACCOUNT_REFUSAL_CODES.has(code)) return false;
|
|
29
|
-
|
|
30
|
-
const prefix = `Provider error ${status}: `;
|
|
31
|
-
if (text.startsWith(prefix)) text = text.slice(prefix.length);
|
|
38
|
+
const text = withoutProviderPrefix(status, message);
|
|
32
39
|
try { return isAnthropicBillingRefusal(status, JSON.parse(text)); } catch { /* Exact prose needs a structured type. */ }
|
|
33
40
|
return typeof code === "string" && BILLING_ERROR_TYPES.has(code)
|
|
34
41
|
&& isAnthropicBillingRefusal(status, { type: "error", error: { type: code, message: text } });
|
|
@@ -53,3 +60,20 @@ export async function readAnthropicBillingRefusal(response: Response, signal?: A
|
|
|
53
60
|
return false;
|
|
54
61
|
}
|
|
55
62
|
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* A 400 extra-usage refusal says this OAuth target cannot serve the turn; a later combo target
|
|
66
|
+
* may. Same evidence bar as billing: an `invalid_request_error` envelope with the exact wording.
|
|
67
|
+
*/
|
|
68
|
+
export function isAnthropicExtraUsageFailure(status: number, message: string, code?: string | null): boolean {
|
|
69
|
+
if (status !== 400 || Buffer.byteLength(message, "utf8") > MAX_BILLING_REFUSAL_BYTES) return false;
|
|
70
|
+
if (code != null && code !== "invalid_request_error") return false;
|
|
71
|
+
const text = withoutProviderPrefix(status, message);
|
|
72
|
+
try {
|
|
73
|
+
const payload: unknown = JSON.parse(text);
|
|
74
|
+
return record(payload) && payload.type === "error" && record(payload.error)
|
|
75
|
+
&& payload.error.type === "invalid_request_error" && payload.error.code == null
|
|
76
|
+
&& typeof payload.error.message === "string" && EXTRA_USAGE_REFUSAL.test(payload.error.message.trim());
|
|
77
|
+
} catch { /* Exact prose needs a structured type. */ }
|
|
78
|
+
return code === "invalid_request_error" && EXTRA_USAGE_REFUSAL.test(text);
|
|
79
|
+
}
|
|
@@ -234,6 +234,8 @@ async function getAccountJson(path: string, options: AnthropicAccountRequestOpti
|
|
|
234
234
|
try {
|
|
235
235
|
response = await fetchImpl(`${options.origin ?? ANTHROPIC_API_ORIGIN}${path}`, {
|
|
236
236
|
method: "GET",
|
|
237
|
+
// A redirect must never carry the bearer to another host.
|
|
238
|
+
redirect: "error",
|
|
237
239
|
headers: accountHeaders(options.accessToken, false),
|
|
238
240
|
signal: readSignal(options.signal, READ_TIMEOUT_MS),
|
|
239
241
|
});
|
|
@@ -296,6 +298,8 @@ export async function claimAnthropicResetGrant(options: AnthropicResetClaimOptio
|
|
|
296
298
|
try {
|
|
297
299
|
response = await fetchImpl(url, {
|
|
298
300
|
method: "POST",
|
|
301
|
+
// A refused 307/308 lands in the unknown-outcome catch below instead of re-posting the claim.
|
|
302
|
+
redirect: "error",
|
|
299
303
|
headers: accountHeaders(options.accessToken, true),
|
|
300
304
|
body: JSON.stringify({
|
|
301
305
|
program: ANTHROPIC_RESET_GRANT_PROGRAM,
|
|
@@ -36,6 +36,8 @@ export interface AnthropicUsageProbe {
|
|
|
36
36
|
|
|
37
37
|
export async function probeAnthropicUsageQuota(accessToken: string): Promise<AnthropicUsageProbe> {
|
|
38
38
|
const response = await fetch("https://api.anthropic.com/api/oauth/usage", {
|
|
39
|
+
// Like the profile probe: a redirect must never carry the bearer to another host.
|
|
40
|
+
redirect: "error",
|
|
39
41
|
headers: {
|
|
40
42
|
Accept: "application/json, text/plain, */*",
|
|
41
43
|
"Content-Type": "application/json",
|
|
@@ -32,6 +32,9 @@ export const CODEBUDDY_GLOBAL_MODELS = [
|
|
|
32
32
|
"gpt-6.1-sol",
|
|
33
33
|
// 261027 preemptive: GPT-6.1 Terra (mirrors CodeBuddy's GPT-6.1 Sol seed; provider listing unverified).
|
|
34
34
|
"gpt-6.1-terra",
|
|
35
|
+
// 261118 preemptive: GPT-6.2 Sol and Astra (mirror CodeBuddy's GPT-6.1 Sol seed; provider listing unverified).
|
|
36
|
+
"gpt-6.2-sol",
|
|
37
|
+
"gpt-6.2-astra",
|
|
35
38
|
"gpt-5.5",
|
|
36
39
|
"gpt-5.4",
|
|
37
40
|
"gpt-5.3-codex",
|
|
@@ -85,6 +88,8 @@ export const CODEBUDDY_GLOBAL_MODEL_CONTEXT_WINDOWS: Record<string, number> = {
|
|
|
85
88
|
"gpt-6-luna": 1_000_000,
|
|
86
89
|
"gpt-6.1-sol": 1_000_000,
|
|
87
90
|
"gpt-6.1-terra": 1_000_000,
|
|
91
|
+
"gpt-6.2-sol": 1_000_000,
|
|
92
|
+
"gpt-6.2-astra": 1_000_000,
|
|
88
93
|
"gpt-5.5": 1_000_000,
|
|
89
94
|
"gpt-5.4": 272_000,
|
|
90
95
|
"gpt-5.3-codex": 272_000,
|
|
@@ -109,6 +114,8 @@ export const CODEBUDDY_GLOBAL_MODEL_MAX_OUTPUT_TOKENS: Record<string, number> =
|
|
|
109
114
|
"gpt-6-luna": 128_000,
|
|
110
115
|
"gpt-6.1-sol": 128_000,
|
|
111
116
|
"gpt-6.1-terra": 128_000,
|
|
117
|
+
"gpt-6.2-sol": 128_000,
|
|
118
|
+
"gpt-6.2-astra": 128_000,
|
|
112
119
|
"gpt-5.5": 72_000,
|
|
113
120
|
"gpt-5.4": 128_000,
|
|
114
121
|
"gpt-5.3-codex": 128_000,
|
|
@@ -129,6 +136,8 @@ export const CODEBUDDY_GLOBAL_MODEL_REASONING_EFFORTS: Record<string, string[]>
|
|
|
129
136
|
"gpt-6-luna": ["low", "medium", "high", "xhigh"],
|
|
130
137
|
"gpt-6.1-sol": ["low", "medium", "high", "xhigh"],
|
|
131
138
|
"gpt-6.1-terra": ["low", "medium", "high", "xhigh"],
|
|
139
|
+
"gpt-6.2-sol": ["low", "medium", "high", "xhigh"],
|
|
140
|
+
"gpt-6.2-astra": ["low", "medium", "high", "xhigh"],
|
|
132
141
|
"glm-5.3": ["low", "high", "max"],
|
|
133
142
|
"glm-5.2": ["high", "xhigh"],
|
|
134
143
|
};
|
|
@@ -141,6 +150,8 @@ export const CODEBUDDY_GLOBAL_MODEL_DEFAULT_REASONING_EFFORTS: Record<string, st
|
|
|
141
150
|
"gpt-6-luna": "high",
|
|
142
151
|
"gpt-6.1-sol": "high",
|
|
143
152
|
"gpt-6.1-terra": "high",
|
|
153
|
+
"gpt-6.2-sol": "high",
|
|
154
|
+
"gpt-6.2-astra": "high",
|
|
144
155
|
"glm-5.3": "high",
|
|
145
156
|
"glm-5.2": "high",
|
|
146
157
|
};
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
} from "../lib/gcp-adc";
|
|
9
9
|
import type { OcxProviderConfig } from "../types";
|
|
10
10
|
import { resolveProviderApiKey } from "./api-key-resolve";
|
|
11
|
+
import { googleVertexLocationConfigError } from "./google-vertex-location";
|
|
11
12
|
import { captureVertexAmbientKey } from "./vertex-environment-authority";
|
|
12
13
|
import { extractGoogleAiStudioModelItems } from "./google-ai-studio-model-discovery";
|
|
13
14
|
import {
|
|
@@ -33,6 +34,22 @@ const VERTEX_GENERATIVE_MODEL_ID = /^(?:gemini|gemma)-/i;
|
|
|
33
34
|
const VERTEX_NON_CHAT_SKU = /(?:^|-)embedding(?:-|$)|-tts(?:-|$)|-transcribe(?:-|$)|(?:^|-)live(?:-|$)/i;
|
|
34
35
|
const VERTEX_TRAILING_API_VERSION = /\/v1(?:beta1?)?$/i;
|
|
35
36
|
|
|
37
|
+
/** The same Google authorities inference constructs; a base URL never grants credential access. */
|
|
38
|
+
function vertexDiscoveryOrigin(value: string): string | undefined {
|
|
39
|
+
try {
|
|
40
|
+
const url = new URL(value);
|
|
41
|
+
if (url.protocol !== "https:" || url.username || url.password || url.port || url.hash) return undefined;
|
|
42
|
+
const host = "aiplatform.googleapis.com";
|
|
43
|
+
if (url.hostname === host) return url.origin;
|
|
44
|
+
const suffix = `-${host}`;
|
|
45
|
+
if (url.hostname.endsWith(suffix)
|
|
46
|
+
&& googleVertexLocationConfigError(url.hostname.slice(0, -suffix.length)) === null) return url.origin;
|
|
47
|
+
} catch {
|
|
48
|
+
// An invalid destination is unavailable discovery, without resolving a credential.
|
|
49
|
+
}
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
|
|
36
53
|
/** Time budget for one Vertex discovery: ADC token resolution, then every follow-up page. */
|
|
37
54
|
export const VERTEX_DISCOVERY_TIMEOUT_MS = 8_000;
|
|
38
55
|
/** Request ceiling for one listing, first page included (pageSize=300, so 1,500 rows). */
|
|
@@ -150,9 +167,10 @@ export function resolveObservedVertexDiscoveryToken(provider: OcxProviderConfig)
|
|
|
150
167
|
|
|
151
168
|
/** The passive gather's credential with its authority bound, for the same send-time checks. */
|
|
152
169
|
export function resolveObservedVertexDiscoveryAuth(provider: OcxProviderConfig): VertexDiscoveryAuth | undefined {
|
|
153
|
-
|
|
170
|
+
const origin = vertexDiscoveryOrigin(provider.baseUrl);
|
|
171
|
+
if (!origin || provider.authMode === "forward" || isVertexApiKeyPoolPaused(provider)) return undefined;
|
|
154
172
|
const selection = selectVertexDiscoveryCredential(provider);
|
|
155
|
-
return selection.kind === "api-key" ? apiKeyDiscoveryAuth(selection) : undefined;
|
|
173
|
+
return selection.kind === "api-key" ? apiKeyDiscoveryAuth(selection, origin) : undefined;
|
|
156
174
|
}
|
|
157
175
|
|
|
158
176
|
/**
|
|
@@ -175,10 +193,10 @@ function sameVertexSelection(left: VertexDiscoveryCredential, right: VertexDisco
|
|
|
175
193
|
* observed when it was read (`captureVertexAmbientKey`, the record inference binds), so an A→B→A
|
|
176
194
|
* change of the variable invalidates it even though the bytes match again.
|
|
177
195
|
*/
|
|
178
|
-
function apiKeyDiscoveryAuth(selection: { key: string | undefined; ambient?: true }): VertexDiscoveryAuth | undefined {
|
|
196
|
+
function apiKeyDiscoveryAuth(selection: { key: string | undefined; ambient?: true }, origin: string): VertexDiscoveryAuth | undefined {
|
|
179
197
|
if (!selection.key) return undefined;
|
|
180
198
|
const auth: VertexDiscoveryAuth = { token: selection.key, kind: "api-key" };
|
|
181
|
-
if (selection.ambient) bindVertexRequestAuthority(auth,
|
|
199
|
+
if (selection.ambient) bindVertexRequestAuthority(auth, origin, selection.key, { ambientKey: captureVertexAmbientKey(selection.key) });
|
|
182
200
|
return auth;
|
|
183
201
|
}
|
|
184
202
|
|
|
@@ -197,20 +215,27 @@ function apiKeyDiscoveryAuth(selection: { key: string | undefined; ambient?: tru
|
|
|
197
215
|
export async function resolveVertexDiscoveryAuth(
|
|
198
216
|
provider: OcxProviderConfig,
|
|
199
217
|
signal: AbortSignal = vertexDiscoveryDeadline(),
|
|
218
|
+
options: { forceExchange?: boolean } = {},
|
|
200
219
|
): Promise<VertexDiscoveryAuth | undefined> {
|
|
201
|
-
|
|
220
|
+
const origin = vertexDiscoveryOrigin(provider.baseUrl);
|
|
221
|
+
if (!origin || provider.authMode === "forward" || isVertexApiKeyPoolPaused(provider)) return undefined;
|
|
202
222
|
const selection = selectVertexDiscoveryCredential(provider);
|
|
203
|
-
if (selection.kind === "api-key") return apiKeyDiscoveryAuth(selection);
|
|
223
|
+
if (selection.kind === "api-key") return apiKeyDiscoveryAuth(selection, origin);
|
|
204
224
|
let authority: Awaited<ReturnType<typeof getVertexAccessTokenWithAuthority>>;
|
|
205
225
|
try {
|
|
206
226
|
const markerAccount = gcpCredentialMarkerAccount(selection.marker);
|
|
207
|
-
authority = await getVertexAccessTokenWithAuthority({
|
|
227
|
+
authority = await getVertexAccessTokenWithAuthority({
|
|
228
|
+
signal,
|
|
229
|
+
...(markerAccount ? { markerAccount } : {}),
|
|
230
|
+
...(options.forceExchange ? { forceExchange: true } : {}),
|
|
231
|
+
});
|
|
208
232
|
} catch {
|
|
209
233
|
return undefined;
|
|
210
234
|
}
|
|
211
|
-
if (
|
|
235
|
+
if (origin !== vertexDiscoveryOrigin(provider.baseUrl)
|
|
236
|
+
|| !sameVertexSelection(selection, selectVertexDiscoveryCredential(provider))) return undefined;
|
|
212
237
|
const auth: VertexDiscoveryAuth = { token: authority.token, kind: "adc", ...(selection.marker ? { marker: selection.marker } : {}) };
|
|
213
|
-
bindVertexRequestAuthority(auth,
|
|
238
|
+
bindVertexRequestAuthority(auth, origin, `Bearer ${authority.token}`, {
|
|
214
239
|
source: authority.source,
|
|
215
240
|
generation: authority.generation,
|
|
216
241
|
...(authority.markerAccount ? { markerAccount: authority.markerAccount } : {}),
|
|
@@ -227,7 +252,8 @@ export async function resolveVertexDiscoveryToken(
|
|
|
227
252
|
}
|
|
228
253
|
|
|
229
254
|
/**
|
|
230
|
-
* Send-time check, run before every discovery request (`beforeSend`): the
|
|
255
|
+
* Send-time check, run before every discovery request (`beforeSend`): the actual URL stays on the
|
|
256
|
+
* approved Google origin, and the row still selects the
|
|
231
257
|
* credential this token came from, an ADC token's source and generation are still current (the
|
|
232
258
|
* check inference runs before dispatch), and the outgoing headers carry it in that scheme's header
|
|
233
259
|
* and not the other one. Any change cancels the send, first page and follow-up pages alike, so a
|
|
@@ -237,11 +263,14 @@ export function vertexDiscoveryAuthIsCurrent(
|
|
|
237
263
|
provider: OcxProviderConfig,
|
|
238
264
|
auth: VertexDiscoveryAuth,
|
|
239
265
|
headers: Record<string, string>,
|
|
266
|
+
url: string,
|
|
240
267
|
): boolean {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
268
|
+
const origin = vertexDiscoveryOrigin(provider.baseUrl);
|
|
269
|
+
if (!origin || vertexDiscoveryOrigin(url) !== origin
|
|
270
|
+
|| provider.authMode === "forward" || isVertexApiKeyPoolPaused(provider)) return false;
|
|
271
|
+
// Recheck ADC source/generation and the ambient-key generation after destination admission,
|
|
272
|
+
// before comparing the current selection, exactly as inference checks them.
|
|
273
|
+
if (!vertexRequestAuthorityIsCurrent(auth, origin)) return false;
|
|
245
274
|
const current = selectVertexDiscoveryCredential(provider);
|
|
246
275
|
const issued: VertexDiscoveryCredential = auth.kind === "api-key"
|
|
247
276
|
? { kind: "api-key", key: auth.token }
|
|
@@ -268,6 +297,11 @@ export function buildVertexModelsDiscoveryRequest(
|
|
|
268
297
|
resolveUrl: (defaultUrl: string) => string,
|
|
269
298
|
): { url: string; headers: Record<string, string> } {
|
|
270
299
|
const base = effectiveProvider.baseUrl.replace(/\/+$/, "").replace(VERTEX_TRAILING_API_VERSION, "");
|
|
300
|
+
// Keep a credential-free request available for catalog capture/fallback, but never attach
|
|
301
|
+
// a Google credential to a destination outside the origin admitted before resolution.
|
|
302
|
+
const url = resolveUrl(`${base}/v1beta1/publishers/google/models?pageSize=300`);
|
|
303
|
+
const origin = vertexDiscoveryOrigin(effectiveProvider.baseUrl);
|
|
304
|
+
if (!origin || vertexDiscoveryOrigin(url) !== origin) return { url, headers };
|
|
271
305
|
if (usesVertexApiKeyForDiscovery(effectiveProvider)) {
|
|
272
306
|
if (apiKey) headers["x-goog-api-key"] = apiKey;
|
|
273
307
|
} else {
|
|
@@ -282,7 +316,7 @@ export function buildVertexModelsDiscoveryRequest(
|
|
|
282
316
|
// Vertex ModelGardenService.ListPublisherModels enforces a maximum pageSize of 300
|
|
283
317
|
// (values > 300 return HTTP 400 INVALID_ARGUMENT); later pages follow nextPageToken.
|
|
284
318
|
return {
|
|
285
|
-
url
|
|
319
|
+
url,
|
|
286
320
|
headers,
|
|
287
321
|
};
|
|
288
322
|
}
|
|
@@ -12,6 +12,9 @@ export const KIRO_MODELS = [
|
|
|
12
12
|
"gpt-6.1-sol",
|
|
13
13
|
// 261027 preemptive: GPT-6.1 Terra (mirrors Kiro's GPT-6.1 Sol seed; provider listing unverified).
|
|
14
14
|
"gpt-6.1-terra",
|
|
15
|
+
// 261118 preemptive: GPT-6.2 Sol and Astra (mirror Kiro's GPT-6.1 Sol seed; provider listing unverified).
|
|
16
|
+
"gpt-6.2-sol",
|
|
17
|
+
"gpt-6.2-astra",
|
|
15
18
|
// Listed on kiro.dev/docs/models (2026-10-24).
|
|
16
19
|
"claude-sonnet-5.5",
|
|
17
20
|
"claude-sonnet-5",
|
|
@@ -47,6 +50,8 @@ export const KIRO_MODEL_CONTEXT_WINDOWS: Record<string, number> = {
|
|
|
47
50
|
"gpt-6-luna": 272_000,
|
|
48
51
|
"gpt-6.1-sol": 272_000,
|
|
49
52
|
"gpt-6.1-terra": 272_000,
|
|
53
|
+
"gpt-6.2-sol": 272_000,
|
|
54
|
+
"gpt-6.2-astra": 272_000,
|
|
50
55
|
"claude-sonnet-5.5": 1_000_000,
|
|
51
56
|
"claude-sonnet-5": 1_000_000,
|
|
52
57
|
"claude-opus-5.5": 1_000_000,
|
|
@@ -155,6 +155,7 @@ export const PROVIDER_MODEL_RENAME_ROLES = {
|
|
|
155
155
|
escapeBuiltinToolNames: "none",
|
|
156
156
|
anthropicEofTolerance: "none",
|
|
157
157
|
forwardAdvisorTool: "none",
|
|
158
|
+
perMessageEffort: "none",
|
|
158
159
|
noVisionModels: "list",
|
|
159
160
|
googleMode: "none",
|
|
160
161
|
googleToolSchemaPolicy: "none",
|
|
@@ -165,6 +166,7 @@ export const PROVIDER_MODEL_RENAME_ROLES = {
|
|
|
165
166
|
unsafeAllowNativeLocalExec: "none",
|
|
166
167
|
nativeLocalExec: "none",
|
|
167
168
|
messagePhaseInference: "none",
|
|
169
|
+
estimateMissingUsage: "none",
|
|
168
170
|
tlsProfile: "none",
|
|
169
171
|
} as const satisfies Record<keyof OcxProviderConfig, ModelRenameRole>;
|
|
170
172
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { OAuthCredentials } from "../../oauth/types";
|
|
2
2
|
import { workBuddyApi, WorkBuddyApiError } from "../../oauth/workbuddy";
|
|
3
3
|
import { workBuddyHeaders } from "../workbuddy";
|
|
4
|
-
import { parseWorkBuddyCredits, remainingWorkBuddyCredits, workBuddyCapacity, workBuddyRecord, type WorkBuddyCreditBalance } from "../workbuddy-credit-balance";
|
|
4
|
+
import { parseWorkBuddyCredits, remainingWorkBuddyCredits, workBuddyCapacity, workBuddyExactCredits, workBuddyRecord, type WorkBuddyCreditBalance } from "../workbuddy-credit-balance";
|
|
5
5
|
import { REQUEST_TIMEOUT_MS } from "../quota-wire";
|
|
6
6
|
import { TERMINAL_QUOTA_FAILURE, type ProviderQuotaProbeResult } from "./report-cache";
|
|
7
7
|
|
|
@@ -56,6 +56,7 @@ async function expiringCredits(summary: Record<string, unknown>, headers: Record
|
|
|
56
56
|
return workBuddyExpiringCredits(lists.flat(), new Set(codes), now);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
/** Display-only credit balance for one account; the enterprise meter fills an empty personal summary. */
|
|
59
60
|
export async function fetchWorkBuddyQuota(provider: string, credential: OAuthCredentials): Promise<ProviderQuotaProbeResult> {
|
|
60
61
|
if (!credential.workbuddy) return null;
|
|
61
62
|
const signal = AbortSignal.timeout(REQUEST_TIMEOUT_MS), now = Date.now();
|
|
@@ -67,7 +68,10 @@ export async function fetchWorkBuddyQuota(provider: string, credential: OAuthCre
|
|
|
67
68
|
const team = await workBuddyApi("/billing/meter/get-enterprise-user-usage", headers, signal, true);
|
|
68
69
|
const total = workBuddyCapacity(team.limitNum), used = workBuddyCapacity(team.credit);
|
|
69
70
|
if (total === undefined || used === undefined) return null;
|
|
70
|
-
|
|
71
|
+
const exact = workBuddyExactCredits(team.limitNum, team.credit);
|
|
72
|
+
credits = exact
|
|
73
|
+
? { total: Number(exact.total), used, remaining: Number(exact.remaining), frozen: 0, groups: [], exact }
|
|
74
|
+
: { total, used, remaining: remainingWorkBuddyCredits(total, used), frozen: 0, groups: [] };
|
|
71
75
|
}
|
|
72
76
|
if (!credits) return null;
|
|
73
77
|
if (credits.remaining > 0) {
|