mixdog 1.2.1 → 1.2.3
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/README.md +18 -0
- package/package.json +2 -1
- package/scripts/gate-local.mjs +19 -3
- package/scripts/model-catalog-audit.mjs +1 -15
- package/scripts/provider-pingpong-live.mjs +509 -0
- package/src/agents/advisor/AGENT.md +1 -1
- package/src/agents/advisor/agent.json +1 -1
- package/src/agents/reviewer/AGENT.md +3 -3
- package/src/agents/reviewer/agent.json +1 -1
- package/src/defaults/shipped-history.json +6 -0
- package/src/defaults/skills/setup/SKILL.md +6 -1
- package/src/defaults/skills/setup/references/actions.md +44 -22
- package/src/defaults/skills/setup/references/surfaces.md +10 -8
- package/src/headless-exec.mjs +15 -8
- package/src/lib/keychain-cjs.cjs +7 -4
- package/src/output-styles/common.md +11 -10
- package/src/repl/slash-commands.mjs +16 -1
- package/src/rules/agent/AGENT.md +5 -5
- package/src/rules/lead/LEAD.md +5 -5
- package/src/runtime/agent/orchestrator/agent-runtime/agent-progress-watchdog.mjs +29 -4
- package/src/runtime/agent/orchestrator/agent-runtime/cache-strategy.mjs +10 -0
- package/src/runtime/agent/orchestrator/agent-trace-io.mjs +92 -61
- package/src/runtime/agent/orchestrator/cache-mtime.mjs +10 -1
- package/src/runtime/agent/orchestrator/config-providers-merge.mjs +7 -0
- package/src/runtime/agent/orchestrator/config.mjs +5 -0
- package/src/runtime/agent/orchestrator/context/collect.mjs +1 -0
- package/src/runtime/agent/orchestrator/context/deferred-tools.mjs +26 -7
- package/src/runtime/agent/orchestrator/context/skill-catalog.mjs +112 -7
- package/src/runtime/agent/orchestrator/mcp/client-config.mjs +36 -7
- package/src/runtime/agent/orchestrator/mcp/client-handshake.mjs +49 -10
- package/src/runtime/agent/orchestrator/mcp/client-transport.mjs +40 -3
- package/src/runtime/agent/orchestrator/mcp/client.mjs +230 -96
- package/src/runtime/agent/orchestrator/mcp/oauth-callback.mjs +103 -0
- package/src/runtime/agent/orchestrator/mcp/oauth-credentials.mjs +150 -0
- package/src/runtime/agent/orchestrator/mcp/oauth-login.mjs +111 -0
- package/src/runtime/agent/orchestrator/mcp/oauth-probe.mjs +87 -0
- package/src/runtime/agent/orchestrator/mcp/oauth-provider.mjs +95 -0
- package/src/runtime/agent/orchestrator/mcp/oauth-request.mjs +122 -0
- package/src/runtime/agent/orchestrator/mcp/oauth-shared.mjs +9 -0
- package/src/runtime/agent/orchestrator/mcp/oauth.mjs +229 -0
- package/src/runtime/agent/orchestrator/providers/account-pool.mjs +188 -29
- package/src/runtime/agent/orchestrator/providers/anthropic-api-recovery.mjs +2 -1
- package/src/runtime/agent/orchestrator/providers/anthropic-api-request.mjs +48 -20
- package/src/runtime/agent/orchestrator/providers/anthropic-api-transport.mjs +94 -31
- package/src/runtime/agent/orchestrator/providers/anthropic-error-contract.mjs +98 -0
- package/src/runtime/agent/orchestrator/providers/anthropic-fast-mode.mjs +39 -18
- package/src/runtime/agent/orchestrator/providers/anthropic-max-tokens-recovery.mjs +55 -0
- package/src/runtime/agent/orchestrator/providers/anthropic-max-tokens.mjs +48 -37
- package/src/runtime/agent/orchestrator/providers/anthropic-messages.mjs +10 -7
- package/src/runtime/agent/orchestrator/providers/anthropic-midstream-recovery.mjs +18 -4
- package/src/runtime/agent/orchestrator/providers/anthropic-model-resolve.mjs +13 -1
- package/src/runtime/agent/orchestrator/providers/anthropic-oauth-client-version.mjs +1 -1
- package/src/runtime/agent/orchestrator/providers/anthropic-oauth-midstream.mjs +10 -1
- package/src/runtime/agent/orchestrator/providers/anthropic-oauth-recovery.mjs +23 -9
- package/src/runtime/agent/orchestrator/providers/anthropic-oauth-request/initial-status.mjs +46 -20
- package/src/runtime/agent/orchestrator/providers/anthropic-oauth-request.mjs +14 -9
- package/src/runtime/agent/orchestrator/providers/anthropic-oauth.mjs +102 -45
- package/src/runtime/agent/orchestrator/providers/anthropic-overload-fallback.mjs +69 -0
- package/src/runtime/agent/orchestrator/providers/anthropic-server-fallback.mjs +4 -0
- package/src/runtime/agent/orchestrator/providers/anthropic-sse-turn/turn-blocks.mjs +20 -1
- package/src/runtime/agent/orchestrator/providers/anthropic-sse-turn/turn-events/content-block-delta.mjs +15 -2
- package/src/runtime/agent/orchestrator/providers/anthropic-sse-turn/turn-events/content-block-start.mjs +11 -4
- package/src/runtime/agent/orchestrator/providers/anthropic-sse-turn/turn-events/message-events.mjs +3 -0
- package/src/runtime/agent/orchestrator/providers/anthropic-sse-turn/turn-events.mjs +12 -5
- package/src/runtime/agent/orchestrator/providers/anthropic-sse-turn/turn-outcome.mjs +1 -0
- package/src/runtime/agent/orchestrator/providers/anthropic-sse-turn/turn-state.mjs +14 -0
- package/src/runtime/agent/orchestrator/providers/anthropic-sse.mjs +10 -1
- package/src/runtime/agent/orchestrator/providers/anthropic-turn-result.mjs +9 -0
- package/src/runtime/agent/orchestrator/providers/anthropic.mjs +40 -7
- package/src/runtime/agent/orchestrator/providers/antigravity-oauth-catalog.mjs +30 -9
- package/src/runtime/agent/orchestrator/providers/antigravity-oauth.mjs +7 -0
- package/src/runtime/agent/orchestrator/providers/antigravity-request.mjs +88 -21
- package/src/runtime/agent/orchestrator/providers/antigravity-response.mjs +30 -10
- package/src/runtime/agent/orchestrator/providers/antigravity-retry-policy.mjs +106 -0
- package/src/runtime/agent/orchestrator/providers/antigravity-stream.mjs +10 -61
- package/src/runtime/agent/orchestrator/providers/antigravity-transport.mjs +94 -15
- package/src/runtime/agent/orchestrator/providers/codex-client-meta.mjs +1 -1
- package/src/runtime/agent/orchestrator/providers/command-code-oauth.mjs +117 -72
- package/src/runtime/agent/orchestrator/providers/compat-request-policy.mjs +78 -2
- package/src/runtime/agent/orchestrator/providers/cursor-auth.mjs +75 -10
- package/src/runtime/agent/orchestrator/providers/cursor-client-version.mjs +1 -1
- package/src/runtime/agent/orchestrator/providers/cursor-wire-guards.mjs +97 -2
- package/src/runtime/agent/orchestrator/providers/cursor-wire-stream-bridge.mjs +103 -23
- package/src/runtime/agent/orchestrator/providers/cursor-wire-stream-messages.mjs +43 -2
- package/src/runtime/agent/orchestrator/providers/cursor-wire-transport.mjs +103 -33
- package/src/runtime/agent/orchestrator/providers/cursor-wire.mjs +32 -6
- package/src/runtime/agent/orchestrator/providers/cursor.mjs +27 -3
- package/src/runtime/agent/orchestrator/providers/custom-provider-config.mjs +64 -1
- package/src/runtime/agent/orchestrator/providers/custom-provider.mjs +70 -6
- package/src/runtime/agent/orchestrator/providers/custom-reasoning.mjs +34 -7
- package/src/runtime/agent/orchestrator/providers/custom-tool-wire.mjs +32 -6
- package/src/runtime/agent/orchestrator/providers/deepseek.mjs +67 -0
- package/src/runtime/agent/orchestrator/providers/effort-configuration.mjs +80 -18
- package/src/runtime/agent/orchestrator/providers/gemini-cache-policy.mjs +11 -4
- package/src/runtime/agent/orchestrator/providers/gemini-cache.mjs +46 -8
- package/src/runtime/agent/orchestrator/providers/gemini-error-contract.mjs +273 -0
- package/src/runtime/agent/orchestrator/providers/gemini-family.mjs +9 -0
- package/src/runtime/agent/orchestrator/providers/gemini-history-signatures.mjs +9 -4
- package/src/runtime/agent/orchestrator/providers/gemini-request-body.mjs +41 -5
- package/src/runtime/agent/orchestrator/providers/gemini-response.mjs +3 -1
- package/src/runtime/agent/orchestrator/providers/gemini-retry-policy.mjs +180 -0
- package/src/runtime/agent/orchestrator/providers/gemini-schema.mjs +369 -112
- package/src/runtime/agent/orchestrator/providers/gemini-sdk-request.mjs +3 -1
- package/src/runtime/agent/orchestrator/providers/gemini-stream.mjs +140 -35
- package/src/runtime/agent/orchestrator/providers/gemini-thinking.mjs +70 -24
- package/src/runtime/agent/orchestrator/providers/gemini.mjs +80 -29
- package/src/runtime/agent/orchestrator/providers/grok-client-version.mjs +1 -1
- package/src/runtime/agent/orchestrator/providers/grok-oauth-tokens.mjs +3 -0
- package/src/runtime/agent/orchestrator/providers/grok-oauth.mjs +69 -19
- package/src/runtime/agent/orchestrator/providers/lib/action-input-contract.mjs +60 -0
- package/src/runtime/agent/orchestrator/providers/lib/anthropic-native-blocks.mjs +1 -0
- package/src/runtime/agent/orchestrator/providers/lib/anthropic-request-utils.mjs +246 -42
- package/src/runtime/agent/orchestrator/providers/lib/anthropic-server-tool-usage.mjs +18 -0
- package/src/runtime/agent/orchestrator/providers/lib/anthropic-system-blocks.mjs +27 -6
- package/src/runtime/agent/orchestrator/providers/lib/claude-bridge-schema.mjs +388 -0
- package/src/runtime/agent/orchestrator/providers/lib/inclusive-usage.mjs +54 -0
- package/src/runtime/agent/orchestrator/providers/lib/origin-bound-fetch.mjs +16 -0
- package/src/runtime/agent/orchestrator/providers/lib/responses-terminal-fields.mjs +11 -0
- package/src/runtime/agent/orchestrator/providers/lib/usage-primitives.mjs +8 -0
- package/src/runtime/agent/orchestrator/providers/lib/wire-pairing.mjs +48 -22
- package/src/runtime/agent/orchestrator/providers/media-normalization.mjs +119 -18
- package/src/runtime/agent/orchestrator/providers/mimo-oauth-profile.mjs +13 -15
- package/src/runtime/agent/orchestrator/providers/mimo-oauth.mjs +3 -0
- package/src/runtime/agent/orchestrator/providers/model-list-sanitize.mjs +2 -1
- package/src/runtime/agent/orchestrator/providers/model-proxy-channel.d.mts +1 -1
- package/src/runtime/agent/orchestrator/providers/model-proxy-channel.mjs +1 -0
- package/src/runtime/agent/orchestrator/providers/model-proxy-provider.mjs +33 -1
- package/src/runtime/agent/orchestrator/providers/muse-code-oauth.mjs +4 -9
- package/src/runtime/agent/orchestrator/providers/oauth-credential-probes.mjs +2 -0
- package/src/runtime/agent/orchestrator/providers/openai-codex-metadata.mjs +2 -0
- package/src/runtime/agent/orchestrator/providers/openai-compat-chat-send.mjs +123 -61
- package/src/runtime/agent/orchestrator/providers/openai-compat-chat-stream/chunk-events.mjs +35 -14
- package/src/runtime/agent/orchestrator/providers/openai-compat-chat-stream/stream-result.mjs +27 -2
- package/src/runtime/agent/orchestrator/providers/openai-compat-chat-stream/stream-state.mjs +37 -7
- package/src/runtime/agent/orchestrator/providers/openai-compat-chat-stream/tool-call-acc.mjs +2 -9
- package/src/runtime/agent/orchestrator/providers/openai-compat-chat-stream.mjs +1 -0
- package/src/runtime/agent/orchestrator/providers/openai-compat-error-contract.mjs +50 -0
- package/src/runtime/agent/orchestrator/providers/openai-compat-models.mjs +47 -2
- package/src/runtime/agent/orchestrator/providers/openai-compat-options.mjs +47 -25
- package/src/runtime/agent/orchestrator/providers/openai-compat-presets.mjs +5 -1
- package/src/runtime/agent/orchestrator/providers/openai-compat-reasoning-field.mjs +151 -0
- package/src/runtime/agent/orchestrator/providers/openai-compat-response-normalization.mjs +64 -23
- package/src/runtime/agent/orchestrator/providers/openai-compat-responses-events.mjs +79 -33
- package/src/runtime/agent/orchestrator/providers/openai-compat-responses-head-parity.json +2901 -0
- package/src/runtime/agent/orchestrator/providers/openai-compat-responses-parity.fixtures.mjs +172 -0
- package/src/runtime/agent/orchestrator/providers/openai-compat-responses-state.mjs +3 -2
- package/src/runtime/agent/orchestrator/providers/openai-compat-responses.mjs +144 -15
- package/src/runtime/agent/orchestrator/providers/openai-compat-retry-profile.mjs +193 -0
- package/src/runtime/agent/orchestrator/providers/openai-compat-stream-common.mjs +66 -2
- package/src/runtime/agent/orchestrator/providers/openai-compat-stream.mjs +9 -2
- package/src/runtime/agent/orchestrator/providers/openai-compat-trace.mjs +2 -0
- package/src/runtime/agent/orchestrator/providers/openai-compat-wire.mjs +109 -26
- package/src/runtime/agent/orchestrator/providers/openai-compat-xai-send.mjs +27 -6
- package/src/runtime/agent/orchestrator/providers/openai-compat-xai.mjs +34 -20
- package/src/runtime/agent/orchestrator/providers/openai-compat.mjs +23 -4
- package/src/runtime/agent/orchestrator/providers/openai-direct-request.mjs +37 -28
- package/src/runtime/agent/orchestrator/providers/openai-error-contract.mjs +274 -0
- package/src/runtime/agent/orchestrator/providers/openai-http-sse-request.mjs +72 -32
- package/src/runtime/agent/orchestrator/providers/openai-http-sse-response-state/response-events/output-items.mjs +23 -10
- package/src/runtime/agent/orchestrator/providers/openai-http-sse-response-state/response-events/terminal-frames.mjs +43 -15
- package/src/runtime/agent/orchestrator/providers/openai-http-sse-response-state/response-events.mjs +10 -0
- package/src/runtime/agent/orchestrator/providers/openai-http-sse-response-state/response-items.mjs +18 -7
- package/src/runtime/agent/orchestrator/providers/openai-http-sse-response-state/response-outcome.mjs +5 -2
- package/src/runtime/agent/orchestrator/providers/openai-http-sse-response-state/response-stamps.mjs +2 -2
- package/src/runtime/agent/orchestrator/providers/openai-http-sse-response-state/response-state.mjs +7 -3
- package/src/runtime/agent/orchestrator/providers/openai-http-sse-response-state/text-relay.mjs +9 -1
- package/src/runtime/agent/orchestrator/providers/openai-http-sse-response-state.mjs +2 -2
- package/src/runtime/agent/orchestrator/providers/openai-http-sse-watchdogs.mjs +1 -3
- package/src/runtime/agent/orchestrator/providers/openai-model-capabilities.mjs +80 -0
- package/src/runtime/agent/orchestrator/providers/openai-oauth-dispatch.mjs +37 -4
- package/src/runtime/agent/orchestrator/providers/openai-oauth-http-sse.mjs +12 -1
- package/src/runtime/agent/orchestrator/providers/openai-oauth-tokens.mjs +22 -2
- package/src/runtime/agent/orchestrator/providers/openai-oauth.mjs +12 -1
- package/src/runtime/agent/orchestrator/providers/openai-responses-input.mjs +76 -33
- package/src/runtime/agent/orchestrator/providers/openai-responses-payload-parity.fixture.json +323 -0
- package/src/runtime/agent/orchestrator/providers/openai-responses-payload.mjs +44 -16
- package/src/runtime/agent/orchestrator/providers/openai-retry-policy.mjs +9 -0
- package/src/runtime/agent/orchestrator/providers/openai-ws-delta.mjs +7 -16
- package/src/runtime/agent/orchestrator/providers/openai-ws-handshake.mjs +16 -8
- package/src/runtime/agent/orchestrator/providers/openai-ws-response-state/refusals.mjs +60 -0
- package/src/runtime/agent/orchestrator/providers/openai-ws-response-state/tool-calls.mjs +51 -35
- package/src/runtime/agent/orchestrator/providers/openai-ws-response-state.mjs +30 -0
- package/src/runtime/agent/orchestrator/providers/openai-ws-send-attempts/attempt-context.mjs +1 -2
- package/src/runtime/agent/orchestrator/providers/openai-ws-send-attempts/policy.mjs +25 -14
- package/src/runtime/agent/orchestrator/providers/openai-ws-stream/event-switch.mjs +12 -0
- package/src/runtime/agent/orchestrator/providers/openai-ws-stream/terminal-frames.mjs +25 -6
- package/src/runtime/agent/orchestrator/providers/openai-ws-terminal.mjs +18 -11
- package/src/runtime/agent/orchestrator/providers/openai-ws.mjs +41 -22
- package/src/runtime/agent/orchestrator/providers/opencode-go-gemini.mjs +170 -0
- package/src/runtime/agent/orchestrator/providers/opencode-go.mjs +75 -70
- package/src/runtime/agent/orchestrator/providers/openrouter.mjs +75 -0
- package/src/runtime/agent/orchestrator/providers/provider-error-kind.mjs +720 -0
- package/src/runtime/agent/orchestrator/providers/registry.mjs +4 -1
- package/src/runtime/agent/orchestrator/providers/retry-backoff.mjs +46 -7
- package/src/runtime/agent/orchestrator/providers/retry-classification.mjs +123 -219
- package/src/runtime/agent/orchestrator/providers/retry-classifier.mjs +2 -0
- package/src/runtime/agent/orchestrator/providers/retry-executor.mjs +148 -45
- package/src/runtime/agent/orchestrator/providers/retry-midstream.mjs +81 -16
- package/src/runtime/agent/orchestrator/providers/transport-scope.d.mts +6 -0
- package/src/runtime/agent/orchestrator/providers/transport-scope.mjs +28 -0
- package/src/runtime/agent/orchestrator/providers/wire-gateway.mjs +157 -0
- package/src/runtime/agent/orchestrator/providers/wire-route.mjs +512 -0
- package/src/runtime/agent/orchestrator/providers/xai-tool-search-head-parity.json +1131 -0
- package/src/runtime/agent/orchestrator/providers/xai-tool-search.fixtures.mjs +183 -0
- package/src/runtime/agent/orchestrator/runtime-core/ask-user-tool-defs.mjs +100 -0
- package/src/runtime/agent/orchestrator/runtime-core/config-helpers.mjs +3 -0
- package/src/runtime/agent/orchestrator/runtime-core/deferred-tool-availability.mjs +21 -0
- package/src/runtime/agent/orchestrator/runtime-core/effort.mjs +15 -0
- package/src/runtime/agent/orchestrator/runtime-core/goal-reminder.mjs +0 -18
- package/src/runtime/agent/orchestrator/runtime-core/model-capabilities.mjs +57 -28
- package/src/runtime/agent/orchestrator/runtime-core/orchestration.mjs +19 -16
- package/src/runtime/agent/orchestrator/runtime-core/plugin-mcp.mjs +1 -97
- package/src/runtime/agent/orchestrator/runtime-core/provider-request-snapshot.mjs +7 -3
- package/src/runtime/agent/orchestrator/runtime-core/session-title.mjs +21 -1
- package/src/runtime/agent/orchestrator/runtime-core/skill-tool-loading.mjs +14 -3
- package/src/runtime/agent/orchestrator/runtime-core/tool-bridge.mjs +526 -0
- package/src/runtime/agent/orchestrator/runtime-core/tool-catalog-data.mjs +3 -0
- package/src/runtime/agent/orchestrator/runtime-core/tool-catalog-schema.mjs +10 -7
- package/src/runtime/agent/orchestrator/runtime-core/tool-catalog.mjs +176 -71
- package/src/runtime/agent/orchestrator/runtime-core/tool-defs.mjs +62 -10
- package/src/runtime/agent/orchestrator/runtime-core/tool-exposure.mjs +96 -0
- package/src/runtime/agent/orchestrator/session/catalog-db/schema.mjs +5 -1
- package/src/runtime/agent/orchestrator/session/compact/constants.mjs +3 -2
- package/src/runtime/agent/orchestrator/session/compact/messages.mjs +14 -93
- package/src/runtime/agent/orchestrator/session/compact/summary-anchor.mjs +5 -0
- package/src/runtime/agent/orchestrator/session/compact/user-message-kind.mjs +120 -0
- package/src/runtime/agent/orchestrator/session/context-tool-schema.mjs +17 -2
- package/src/runtime/agent/orchestrator/session/context-utils.mjs +8 -4
- package/src/runtime/agent/orchestrator/session/eager-dispatch/admission.mjs +2 -1
- package/src/runtime/agent/orchestrator/session/eager-dispatch.mjs +6 -1
- package/src/runtime/agent/orchestrator/session/loop/compact-policy.mjs +91 -1
- package/src/runtime/agent/orchestrator/session/loop/completion-guards.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/loop/context-overflow.mjs +56 -0
- package/src/runtime/agent/orchestrator/session/loop/deferred-call-through.mjs +18 -8
- package/src/runtime/agent/orchestrator/session/loop/loop-state.mjs +1 -0
- package/src/runtime/agent/orchestrator/session/loop/pre-dispatch-deny.mjs +21 -10
- package/src/runtime/agent/orchestrator/session/loop/provider-tool-exclusions.mjs +132 -0
- package/src/runtime/agent/orchestrator/session/loop/request-boundary.mjs +30 -0
- package/src/runtime/agent/orchestrator/session/loop/send-phase.mjs +67 -20
- package/src/runtime/agent/orchestrator/session/loop/step-auto-effort.mjs +104 -19
- package/src/runtime/agent/orchestrator/session/loop/tool-call-resolution.mjs +95 -0
- package/src/runtime/agent/orchestrator/session/loop/tool-exec/before-hook.mjs +30 -3
- package/src/runtime/agent/orchestrator/session/loop/tool-exec/dispatch.mjs +15 -4
- package/src/runtime/agent/orchestrator/session/loop/tool-exec.mjs +15 -1
- package/src/runtime/agent/orchestrator/session/loop/tool-exposure-migration.mjs +150 -0
- package/src/runtime/agent/orchestrator/session/loop/tool-phase.mjs +7 -2
- package/src/runtime/agent/orchestrator/session/manager/ask-queue.mjs +30 -2
- package/src/runtime/agent/orchestrator/session/manager/ask-session.mjs +11 -2
- package/src/runtime/agent/orchestrator/session/manager/ask-turn-auto-effort.mjs +2 -1
- package/src/runtime/agent/orchestrator/session/manager/ask-turn-commit.mjs +34 -12
- package/src/runtime/agent/orchestrator/session/manager/ask-turn-execute.mjs +57 -21
- package/src/runtime/agent/orchestrator/session/manager/ask-turn-loop-options.mjs +57 -25
- package/src/runtime/agent/orchestrator/session/manager/ask-turn-prepare.mjs +6 -0
- package/src/runtime/agent/orchestrator/session/manager/ask-turn-settle.mjs +4 -0
- package/src/runtime/agent/orchestrator/session/manager/compaction-runner.mjs +8 -0
- package/src/runtime/agent/orchestrator/session/manager/pending-message-entry.mjs +5 -10
- package/src/runtime/agent/orchestrator/session/manager/prompt-utils.mjs +208 -14
- package/src/runtime/agent/orchestrator/session/manager/session-close.mjs +16 -4
- package/src/runtime/agent/orchestrator/session/manager/session-crud.mjs +25 -3
- package/src/runtime/agent/orchestrator/session/manager/session-fallback-title.mjs +82 -0
- package/src/runtime/agent/orchestrator/session/manager/session-lifecycle.mjs +19 -2
- package/src/runtime/agent/orchestrator/session/manager/session-record.mjs +3 -0
- package/src/runtime/agent/orchestrator/session/manager/tool-resolution.mjs +4 -1
- package/src/runtime/agent/orchestrator/session/manager/turn-interruption.mjs +18 -7
- package/src/runtime/agent/orchestrator/session/manager.mjs +2 -1
- package/src/runtime/agent/orchestrator/session/pre-send-compact.mjs +6 -0
- package/src/runtime/agent/orchestrator/session/send-with-recovery.mjs +168 -29
- package/src/runtime/agent/orchestrator/session/side-question-store.mjs +96 -0
- package/src/runtime/agent/orchestrator/session/side-question.mjs +192 -0
- package/src/runtime/agent/orchestrator/session/store/lifecycle-barriers.mjs +17 -3
- package/src/runtime/agent/orchestrator/session/store/live-state.mjs +23 -0
- package/src/runtime/agent/orchestrator/session/store/paths-heartbeat.mjs +58 -2
- package/src/runtime/agent/orchestrator/session/store/save-worker.mjs +6 -3
- package/src/runtime/agent/orchestrator/session/store/session-delete.mjs +41 -28
- package/src/runtime/agent/orchestrator/session/store/session-observers.mjs +4 -2
- package/src/runtime/agent/orchestrator/session/store/sweep/sweep-finish.mjs +12 -1
- package/src/runtime/agent/orchestrator/session/store/write-admission.mjs +3 -1
- package/src/runtime/agent/orchestrator/session/store/write-guards.mjs +16 -0
- package/src/runtime/agent/orchestrator/session/store-agent-worker-rows.mjs +22 -10
- package/src/runtime/agent/orchestrator/session/store-summary-archived-agent.mjs +34 -15
- package/src/runtime/agent/orchestrator/session/store-summary-catalog.mjs +6 -0
- package/src/runtime/agent/orchestrator/session/store-summary-fields.mjs +13 -0
- package/src/runtime/agent/orchestrator/session/store-summary-index.mjs +13 -1
- package/src/runtime/agent/orchestrator/session/store-summary-reader.mjs +10 -2
- package/src/runtime/agent/orchestrator/session/store.mjs +19 -3
- package/src/runtime/agent/orchestrator/session/tool-batch/execute-call.mjs +1 -0
- package/src/runtime/agent/orchestrator/session/tool-batch/finalize.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/tool-batch/record-outcome.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/tool-batch/state.mjs +7 -1
- package/src/runtime/agent/orchestrator/session/tool-result-offload.mjs +4 -0
- package/src/runtime/agent/orchestrator/session/tool-schema-rejection.mjs +77 -0
- package/src/runtime/agent/orchestrator/session/transcript-restore/restore.mjs +20 -1
- package/src/runtime/agent/orchestrator/tools/bash-policy-scan.mjs +8 -2
- package/src/runtime/agent/orchestrator/tools/builtin/arg-guard.mjs +2 -2
- package/src/runtime/agent/orchestrator/tools/builtin/bash-tool/command-preflight.mjs +3 -3
- package/src/runtime/agent/orchestrator/tools/builtin/bash-tool/deadline-plan.mjs +12 -15
- package/src/runtime/agent/orchestrator/tools/builtin/bash-tool.mjs +4 -1
- package/src/runtime/agent/orchestrator/tools/builtin/builtin-tools.mjs +5 -5
- package/src/runtime/agent/orchestrator/tools/builtin/external-tool-adapters.mjs +14 -10
- package/src/runtime/agent/orchestrator/tools/builtin/lib/shell-job-records.mjs +49 -34
- package/src/runtime/agent/orchestrator/tools/builtin/runtime-capabilities.mjs +23 -1
- package/src/runtime/agent/orchestrator/tools/code-graph/dispatch/root-resolution.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/code-graph/search.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/patch/ui-diff.mjs +73 -39
- package/src/runtime/agent/orchestrator/tools/progress-message.mjs +18 -1
- package/src/runtime/agent/orchestrator/tools/shell-command.mjs +7 -4
- package/src/runtime/agent/orchestrator/tools/shell-exec-policy.mjs +88 -12
- package/src/runtime/agent/orchestrator/tools/shell-policy.mjs +2 -0
- package/src/runtime/computer-bridge/action-schema.mjs +44 -21
- package/src/runtime/github/tool.mjs +92 -2
- package/src/runtime/memory/index.mjs +1 -0
- package/src/runtime/memory/lib/http-router/ingest-routes.mjs +22 -1
- package/src/runtime/memory/lib/ingest/transcript-offsets.mjs +2 -0
- package/src/runtime/memory/lib/pg/adapter.mjs +98 -1
- package/src/runtime/memory/lib/pg/process.mjs +65 -50
- package/src/runtime/memory/lib/pg/run-child.mjs +49 -0
- package/src/runtime/memory/lib/pg/supervisor.mjs +124 -16
- package/src/runtime/memory/lib/runtime-fetcher.mjs +12 -13
- package/src/runtime/memory/lib/transcript-ingest.mjs +14 -0
- package/src/runtime/office/README.md +2 -2
- package/src/runtime/office/authoring/html-document-author.mjs +2 -0
- package/src/runtime/office/authoring/pptx-contact-sheet.mjs +2 -0
- package/src/runtime/office/authoring/pptx-html-measure.mjs +2 -0
- package/src/runtime/office/authoring/pptx-html-runner.mjs +2 -0
- package/src/runtime/office/authoring/xlsx-html-runner.mjs +2 -0
- package/src/runtime/office/core/office-actions-read.mjs +3 -0
- package/src/runtime/office/core/office-render-preview.mjs +2 -0
- package/src/runtime/office/core/office-session-dispatch.mjs +7 -0
- package/src/runtime/office/core/office-sessionless-actions.mjs +8 -0
- package/src/runtime/office/core/office-sessions.mjs +5 -0
- package/src/runtime/office/core/office-transactions.mjs +3 -0
- package/src/runtime/office/core/office-write-ledger.mjs +98 -0
- package/src/runtime/office/design/library/templates/mixdog-executive.mixdog-edit.pptx +0 -0
- package/src/runtime/office/index.mjs +30 -0
- package/src/runtime/office/pdf/pdf-edit-document.mjs +2 -0
- package/src/runtime/office/pdf/pdf-render.mjs +23 -7
- package/src/runtime/office/pdf/pdf-security.mjs +2 -0
- package/src/runtime/office/portable/portable-opc.mjs +4 -1
- package/src/runtime/office/quality/visual-diff.mjs +2 -0
- package/src/runtime/office/shared/values.mjs +0 -5
- package/src/runtime/shared/background-tasks.mjs +92 -14
- package/src/runtime/shared/bounded-file-read.mjs +13 -0
- package/src/runtime/shared/bounded-line-diff.mjs +182 -0
- package/src/runtime/shared/buffered-appender.mjs +18 -0
- package/src/runtime/shared/config.mjs +78 -18
- package/src/runtime/shared/err-text.mjs +31 -0
- package/src/runtime/shared/error-presentation.mjs +159 -19
- package/src/runtime/shared/file-permissions.d.mts +6 -1
- package/src/runtime/shared/file-permissions.mjs +54 -6
- package/src/runtime/shared/llm/anthropic-betas.mjs +4 -3
- package/src/runtime/shared/llm/anthropic-effort.mjs +129 -134
- package/src/runtime/shared/llm/anthropic-thinking-contract.mjs +50 -14
- package/src/runtime/shared/llm/model-catalog.mjs +53 -40
- package/src/runtime/shared/llm/openai-daybreak.mjs +4 -16
- package/src/runtime/shared/llm/provider-catalog-registry.mjs +11 -0
- package/src/runtime/shared/llm/provider-model-identities.mjs +13 -4
- package/src/runtime/shared/llm/usage-accounting.mjs +5 -2
- package/src/runtime/shared/llm/usage-ledger-rollup.mjs +3 -0
- package/src/runtime/shared/llm/usage-rollup.mjs +0 -1
- package/src/runtime/shared/loopback-listener.mjs +9 -0
- package/src/runtime/shared/model-display.mjs +13 -0
- package/src/runtime/shared/provider-api-key.mjs +2 -0
- package/src/runtime/shared/quota-resume-store.mjs +11 -0
- package/src/runtime/shared/review-diff.mjs +52 -0
- package/src/runtime/shared/session-baseline-store.mjs +960 -0
- package/src/runtime/shared/session-sidebar-host.d.mts +4 -0
- package/src/runtime/shared/session-sidebar-host.mjs +38 -0
- package/src/runtime/shared/slow-span.mjs +114 -0
- package/src/runtime/shared/statusline/statusline-format.mjs +4 -4
- package/src/runtime/shared/statusline/statusline-segments.mjs +28 -4
- package/src/runtime/shared/task-notification-envelope.mjs +2 -2
- package/src/runtime/shared/tool-card-model/card-header.mjs +6 -1
- package/src/runtime/shared/tool-card-model/generic-detail.mjs +39 -5
- package/src/runtime/shared/tool-card-model.mjs +5 -2
- package/src/runtime/shared/tool-output-limit.mjs +4 -0
- package/src/runtime/shared/tool-primitives.mjs +13 -0
- package/src/runtime/shared/tool-result-summary.mjs +8 -1
- package/src/runtime/shared/tool-surface.mjs +18 -3
- package/src/runtime/shared/tool-work-units.mjs +40 -4
- package/src/runtime/shared/transcript-writer/purge.mjs +74 -0
- package/src/runtime/shared/transcript-writer.mjs +10 -2
- package/src/runtime/shared/turn-changes.mjs +670 -274
- package/src/runtime/shared/turn-review-reply.mjs +8 -39
- package/src/runtime/shared/turn-snapshot-store.mjs +94 -2
- package/src/runtime/shared/turn-snapshot.mjs +986 -690
- package/src/runtime/shared/turn-worktree-snapshot.mjs +279 -262
- package/src/runtime/shared/user-data-guard.mjs +262 -49
- package/src/runtime/shared/worktrees/carry.mjs +531 -0
- package/src/runtime/shared/worktrees/contract.mjs +34 -24
- package/src/runtime/shared/worktrees/file-recovery.mjs +68 -0
- package/src/runtime/shared/worktrees/git-head.mjs +205 -0
- package/src/runtime/shared/worktrees/git.mjs +8 -3
- package/src/runtime/shared/worktrees/maintenance.mjs +1 -1
- package/src/runtime/shared/worktrees/manager.mjs +156 -8
- package/src/runtime/shared/worktrees/merge.mjs +31 -21
- package/src/runtime/shared/worktrees/paths.d.mts +6 -0
- package/src/runtime/shared/worktrees/test-support.mjs +19 -4
- package/src/runtime/terminal-bridge/client.mjs +44 -11
- package/src/runtime/terminal-bridge/tool-defs.mjs +13 -6
- package/src/runtime/tidy/apply.mjs +47 -2
- package/src/runtime/tidy/run-engines.mjs +11 -5
- package/src/session-runtime/agent-tool-routing.mjs +19 -13
- package/src/session-runtime/boot/apis.mjs +19 -5
- package/src/session-runtime/boot/facade.mjs +1 -0
- package/src/session-runtime/boot/infrastructure.mjs +12 -1
- package/src/session-runtime/boot/session.mjs +0 -1
- package/src/session-runtime/boot/tools.mjs +4 -1
- package/src/session-runtime/cwd-plugins/cwd-apply.mjs +12 -5
- package/src/session-runtime/internal-tool-executor/ask-user-tool.mjs +65 -0
- package/src/session-runtime/internal-tool-executor/bridge-tools.mjs +3 -1
- package/src/session-runtime/internal-tool-executor/knowledge-tools.mjs +11 -4
- package/src/session-runtime/internal-tool-executor/workspace-tools.mjs +115 -18
- package/src/session-runtime/internal-tool-executor.mjs +6 -2
- package/src/session-runtime/lifecycle/cold-heir.mjs +188 -0
- package/src/session-runtime/lifecycle/inheritance.mjs +71 -27
- package/src/session-runtime/lifecycle/session-catalog.mjs +14 -3
- package/src/session-runtime/lifecycle/session-switch/resume.mjs +6 -0
- package/src/session-runtime/lifecycle/session-switch/session-delete.mjs +29 -6
- package/src/session-runtime/lifecycle/teardown.mjs +73 -8
- package/src/session-runtime/lifecycle-api.mjs +1 -0
- package/src/session-runtime/mcp-glue/connect.mjs +46 -14
- package/src/session-runtime/mcp-glue/server-catalog.mjs +20 -3
- package/src/session-runtime/mcp-glue.mjs +3 -0
- package/src/session-runtime/mcp-oauth-login.mjs +174 -0
- package/src/session-runtime/model-route/model-switch-target.mjs +34 -0
- package/src/session-runtime/model-route/set-route.mjs +85 -17
- package/src/session-runtime/model-route/web-search-route.mjs +1 -1
- package/src/session-runtime/native-web-search/routes.mjs +22 -3
- package/src/session-runtime/native-web-search-usage.mjs +51 -0
- package/src/session-runtime/native-web-search.mjs +10 -1
- package/src/session-runtime/new-session-config.mjs +4 -2
- package/src/session-runtime/provider-auth/login.mjs +4 -0
- package/src/session-runtime/provider-models/model-meta.mjs +12 -3
- package/src/session-runtime/quick-model-rows/web-search-rows.mjs +13 -8
- package/src/session-runtime/quick-web-search-models.mjs +13 -38
- package/src/session-runtime/resource-extension-sync.mjs +4 -0
- package/src/session-runtime/resource-mcp-api.mjs +98 -2
- package/src/session-runtime/resource-scope-decorate.mjs +10 -3
- package/src/session-runtime/runtime-review-api.mjs +21 -2
- package/src/session-runtime/services/agent-tool/index-write-queue.mjs +81 -20
- package/src/session-runtime/services/agent-tool/job-task-reconcile.mjs +13 -1
- package/src/session-runtime/services/agent-tool/job-views/agent-list.mjs +7 -2
- package/src/session-runtime/services/agent-tool/lead-worker-index/forgotten-leads.mjs +29 -0
- package/src/session-runtime/services/agent-tool/lead-worker-index/index-file.mjs +1 -1
- package/src/session-runtime/services/agent-tool/lead-worker-index.mjs +73 -7
- package/src/session-runtime/services/agent-tool/send-flow.mjs +22 -4
- package/src/session-runtime/services/agent-tool/spawn-flow/job-start.mjs +2 -0
- package/src/session-runtime/services/agent-tool/spawn-flow/spawn-run.mjs +22 -5
- package/src/session-runtime/services/agent-tool/tag-registry.mjs +15 -1
- package/src/session-runtime/services/agent-tool/worker-index/row-liveness.mjs +8 -1
- package/src/session-runtime/services/agent-tool/worker-index/row-shape.mjs +2 -2
- package/src/session-runtime/services/agent-tool/worker-index/row-store.mjs +10 -1
- package/src/session-runtime/services/agent-tool/worker-index.mjs +46 -7
- package/src/session-runtime/services/agent-tool/worker-rows.mjs +17 -0
- package/src/session-runtime/services/agent-tool.mjs +3 -0
- package/src/session-runtime/services/channel-admin.mjs +19 -3
- package/src/session-runtime/services/memory-runtime-proxy/calls.mjs +4 -0
- package/src/session-runtime/services/memory-runtime-proxy.mjs +1 -0
- package/src/session-runtime/services/provider-admin.mjs +81 -15
- package/src/session-runtime/session-transcript-purge.mjs +32 -0
- package/src/session-runtime/session-turn-api.mjs +14 -5
- package/src/session-runtime/settings-builtin-tools-api.mjs +9 -0
- package/src/session-runtime/settings-compaction-api.mjs +1 -0
- package/src/session-runtime/setup-tool/executor.mjs +36 -6
- package/src/session-runtime/setup-tool/extended-actions.mjs +86 -6
- package/src/session-runtime/setup-tool/settings-contract.mjs +13 -3
- package/src/session-runtime/setup-tool/tool-defs.mjs +13 -4
- package/src/session-runtime/skills-api.mjs +3 -5
- package/src/session-runtime/tool-surface.mjs +5 -1
- package/src/session-runtime/turn/compaction-gate.mjs +25 -0
- package/src/session-runtime/turn/session-ops.mjs +7 -5
- package/src/session-runtime/turn/side-question-ops.mjs +22 -0
- package/src/session-runtime/turn/turn-run/ask-callbacks.mjs +5 -1
- package/src/session-runtime/turn/turn-run/turn-prepare.mjs +8 -3
- package/src/session-runtime/turn/turn-run/turn-settle.mjs +10 -0
- package/src/session-runtime/turn/turn-run/turn-timing.mjs +4 -3
- package/src/session-runtime/turn/turn-run.mjs +25 -9
- package/src/session-runtime/usage-stats-api.mjs +43 -11
- package/src/session-runtime/workspace/project-branches.mjs +7 -5
- package/src/session-runtime/workspace/transition-steps.mjs +129 -31
- package/src/session-runtime/workspace/transitions.mjs +190 -15
- package/src/standalone/daemon-agent-control.mjs +9 -1
- package/src/standalone/daemon-drain-policy.mjs +8 -0
- package/src/standalone/daemon-local-session-bridge.mjs +14 -1
- package/src/standalone/daemon-owner.mjs +17 -4
- package/src/standalone/daemon-pg-stop.mjs +51 -0
- package/src/standalone/daemon-stop-budget.d.mts +2 -0
- package/src/standalone/daemon-stop-budget.mjs +18 -0
- package/src/standalone/daemon-stored-session-views.mjs +2 -0
- package/src/standalone/daemon-telemetry.mjs +74 -0
- package/src/standalone/daemon.mjs +64 -8
- package/src/standalone/desktop-service-registry.mjs +5 -0
- package/src/standalone/local-session-runtime.mjs +70 -19
- package/src/standalone/session-client.mjs +42 -0
- package/src/standalone/session-protocol.mjs +14 -0
- package/src/standalone/session-proxy/projection.mjs +41 -4
- package/src/standalone/session-runtime-inline-host/boot-loaders.mjs +15 -1
- package/src/standalone/session-runtime-inline-host.mjs +1 -0
- package/src/standalone/session-service/agent-tree/agent-cancel.mjs +33 -2
- package/src/standalone/session-service/agent-tree/agent-turns.mjs +26 -10
- package/src/standalone/session-service/agent-tree.mjs +12 -0
- package/src/standalone/session-service/quota-resume.mjs +8 -0
- package/src/standalone/session-service/retention/busy.mjs +15 -1
- package/src/standalone/session-service/session-calls/session-action.mjs +18 -3
- package/src/standalone/session-service-api.mjs +11 -1
- package/src/standalone/session-service.mjs +1 -0
- package/src/standalone/session-state-patch.d.mts +2 -1
- package/src/standalone/session-state-patch.mjs +41 -1
- package/src/tui/App.jsx +25 -0
- package/src/tui/app/app-view/floating-panel.jsx +26 -1
- package/src/tui/app/app-view.jsx +1 -0
- package/src/tui/app/btw-controller.mjs +118 -0
- package/src/tui/app/create-app-pickers.mjs +6 -0
- package/src/tui/app/extension-pickers/mcp-login.mjs +107 -0
- package/src/tui/app/extension-pickers/mcp-servers-picker.mjs +2 -1
- package/src/tui/app/extension-pickers.mjs +2 -1
- package/src/tui/app/model-options.mjs +11 -16
- package/src/tui/app/shell-layout/row-budgets.mjs +11 -1
- package/src/tui/app/shell-layout/surfaces.mjs +3 -1
- package/src/tui/app/slash-commands.mjs +20 -5
- package/src/tui/app/slash-dispatch/panel-commands.mjs +16 -1
- package/src/tui/app/slash-dispatch/session-commands.mjs +19 -6
- package/src/tui/app/use-global-key-input/approval-shortcut.mjs +12 -0
- package/src/tui/app/use-global-key-input.mjs +5 -12
- package/src/tui/app/use-prompt-handlers.mjs +11 -0
- package/src/tui/components/BtwPanel.jsx +53 -0
- package/src/tui/components/QuestionPanel.jsx +275 -0
- package/src/tui/components/StatusLine.jsx +2 -0
- package/src/tui/components/question-panel-model.mjs +156 -0
- package/src/tui/components/status-line/local-line.mjs +5 -2
- package/src/tui/components/status-line/use-statusline-text.mjs +7 -1
- package/src/tui/dist/index.mjs +3221 -1500
- package/src/tui/session/context-state.mjs +4 -2
- package/src/tui/session/quota-resume.mjs +46 -14
- package/src/tui/session/session-api/commands.mjs +43 -24
- package/src/tui/session/session-api/controls.mjs +2 -2
- package/src/tui/session/session-api/extensions.mjs +22 -0
- package/src/tui/session/session-api/integrations.mjs +16 -2
- package/src/tui/session/session-api/lifecycle/dispose.mjs +1 -0
- package/src/tui/session/session-api/lifecycle.mjs +7 -2
- package/src/tui/session/session-api/routes.mjs +71 -7
- package/src/tui/session/session-api/settings.mjs +11 -14
- package/src/tui/session/session-api.mjs +1 -0
- package/src/tui/session/session-flow/drain.mjs +7 -1
- package/src/tui/session/session-flow/failed-turn-rewind.mjs +10 -4
- package/src/tui/session/tool-approval.mjs +10 -7
- package/src/tui/session/transcript-spill.mjs +14 -7
- package/src/tui/session/turn-stream.mjs +174 -31
- package/src/tui/session/turn.mjs +46 -16
- package/src/tui/statusline-ansi-bridge.mjs +1 -1
- package/src/ui/statusline-agents.mjs +15 -4
- package/src/ui/statusline.mjs +7 -3
- package/src/ui/streaming-markdown-heal.mjs +34 -3
- package/src/vendor/statusline/src/gateway/claude-current.mjs +14 -4
- package/src/workflows/default/WORKFLOW.md +3 -1
- package/src/runtime/memory/lib/memory-session-merge.mjs +0 -32
- package/src/runtime/shared/llm/usage-session-history.mjs +0 -266
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* antigravity-stream.mjs — what one Antigravity SSE turn accumulates while it
|
|
3
3
|
* streams: the live text mirror a retirement notice is recognised from, the
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* carry (emittedToolCall / unsafeToRetry / partial calls + partial replay).
|
|
4
|
+
* leak guard that recovers calls the model wrote as text (held back, like the
|
|
5
|
+
* native calls, until the turn finishes cleanly), and the first terminal
|
|
6
|
+
* finishReason. Nothing is dispatched while streaming.
|
|
8
7
|
*
|
|
9
8
|
* The transport (antigravity-transport.mjs) owns the socket and the retry
|
|
10
9
|
* policy; the projection (antigravity-response.mjs) reads this record after
|
|
11
10
|
* the turn settles.
|
|
12
11
|
*/
|
|
13
|
-
import { createProviderReplay } from './lib/provider-replay.mjs';
|
|
14
12
|
import { createGeminiTextLeakGuard, consumeGeminiRestStreamResponse } from './gemini-stream.mjs';
|
|
15
|
-
import { parseToolCalls, emitGeminiToolCalls } from './gemini-schema.mjs';
|
|
16
13
|
import { normalizeAntigravityUsage } from './antigravity-response.mjs';
|
|
17
14
|
|
|
18
15
|
// A retired wire id answers with one plain-text notice and no finishReason.
|
|
@@ -46,10 +43,6 @@ export function createAntigravityStreamCollector({ tools, useModel, onToolCall,
|
|
|
46
43
|
// Streamed text is kept so a retirement notice can be told apart from
|
|
47
44
|
// a truncated stream when the gateway omits the finishReason.
|
|
48
45
|
let streamedText = '';
|
|
49
|
-
let streamedParts = [];
|
|
50
|
-
let streamedNativeToolCalls = [];
|
|
51
|
-
const seenNativeToolIds = new Set();
|
|
52
|
-
const emittedToolIds = new Set();
|
|
53
46
|
|
|
54
47
|
const relayText = onTextDelta
|
|
55
48
|
? (text) => {
|
|
@@ -57,15 +50,9 @@ export function createAntigravityStreamCollector({ tools, useModel, onToolCall,
|
|
|
57
50
|
onTextDelta(text);
|
|
58
51
|
}
|
|
59
52
|
: null;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
// native calls and calls recovered from its text.
|
|
64
|
-
if (terminalFailure || emittedToolIds.has(call.id)) return;
|
|
65
|
-
emittedToolIds.add(call.id);
|
|
66
|
-
onToolCall(call);
|
|
67
|
-
}
|
|
68
|
-
: null;
|
|
53
|
+
// Tool calls (native and text-recovered) are never dispatched while the
|
|
54
|
+
// stream runs: the turn's terminal verdict decides, and
|
|
55
|
+
// finalizeAntigravityTurn releases them only after a clean finish.
|
|
69
56
|
const onChunk = (chunk) => {
|
|
70
57
|
const candidate = chunk?.candidates?.[0];
|
|
71
58
|
const finishReason =
|
|
@@ -74,37 +61,20 @@ export function createAntigravityStreamCollector({ tools, useModel, onToolCall,
|
|
|
74
61
|
if (finishReason && String(finishReason).replace(/^FINISH_REASON_/, '') !== 'STOP') {
|
|
75
62
|
terminalFailure ||= finishReason;
|
|
76
63
|
}
|
|
77
|
-
if (!onToolCall) return;
|
|
78
|
-
const parts = candidate?.content?.parts ?? [];
|
|
79
|
-
streamedParts.push(...parts);
|
|
80
|
-
if (terminalFailure || !parts.some((part) => part?.functionCall)) return;
|
|
81
|
-
// Parse against the turn's parts so anonymous call IDs keep the
|
|
82
|
-
// same ordinal as final parsing, even across separate SSE chunks.
|
|
83
|
-
const fresh = (parseToolCalls(streamedParts) || []).filter((call) => {
|
|
84
|
-
if (seenNativeToolIds.has(call.id)) return false;
|
|
85
|
-
seenNativeToolIds.add(call.id);
|
|
86
|
-
return true;
|
|
87
|
-
});
|
|
88
|
-
const calls = textLeakGuard?.enabled ? textLeakGuard.filterNativeToolCalls(fresh) : fresh;
|
|
89
|
-
if (calls?.length) streamedNativeToolCalls.push(...calls);
|
|
90
|
-
emitGeminiToolCalls(calls, dispatchToolCall);
|
|
91
64
|
};
|
|
92
65
|
|
|
93
66
|
// Each attempt starts from an empty record: a replayed request must not
|
|
94
|
-
// inherit the dead attempt's text
|
|
67
|
+
// inherit the dead attempt's text or failure.
|
|
95
68
|
const beginAttempt = () => {
|
|
96
69
|
textLeakGuard = createGeminiTextLeakGuard({
|
|
97
70
|
knownToolNames: tools?.map((t) => t.name).filter(Boolean) ?? [],
|
|
98
71
|
onTextDelta: relayText,
|
|
99
|
-
onToolCall
|
|
72
|
+
onToolCall,
|
|
100
73
|
onStreamDelta,
|
|
74
|
+
deferToolCalls: true,
|
|
101
75
|
});
|
|
102
76
|
streamedText = '';
|
|
103
77
|
terminalFailure = null;
|
|
104
|
-
streamedParts = [];
|
|
105
|
-
streamedNativeToolCalls = [];
|
|
106
|
-
seenNativeToolIds.clear();
|
|
107
|
-
emittedToolIds.clear();
|
|
108
78
|
};
|
|
109
79
|
const releaseGuard = () => {
|
|
110
80
|
textLeakGuard = null;
|
|
@@ -125,22 +95,7 @@ export function createAntigravityStreamCollector({ tools, useModel, onToolCall,
|
|
|
125
95
|
unwrapChunk: (chunk) => (chunk && typeof chunk === 'object' && chunk.response ? chunk.response : chunk),
|
|
126
96
|
});
|
|
127
97
|
} catch (streamErr) {
|
|
128
|
-
|
|
129
|
-
// Native calls now run before EOF. Preserve
|
|
130
|
-
// their history and prohibit resampling after
|
|
131
|
-
// a tool callback.
|
|
132
|
-
if (emittedToolIds.size) {
|
|
133
|
-
error.emittedToolCall = true;
|
|
134
|
-
error.unsafeToRetry = true;
|
|
135
|
-
const leaked = textLeakGuard.getLeakedToolCalls();
|
|
136
|
-
error.partialToolCalls = [...streamedNativeToolCalls, ...leaked];
|
|
137
|
-
const replay = createProviderReplay('antigravity', leaked.length ? [] : streamedParts);
|
|
138
|
-
if (replay) {
|
|
139
|
-
replay.requestContext = { model: useModel };
|
|
140
|
-
error.partialProviderReplay = replay;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
throw error;
|
|
98
|
+
throw retiredModelError(streamErr, streamedText, useModel) || streamErr;
|
|
144
99
|
}
|
|
145
100
|
};
|
|
146
101
|
|
|
@@ -155,11 +110,5 @@ export function createAntigravityStreamCollector({ tools, useModel, onToolCall,
|
|
|
155
110
|
get terminalFailure() {
|
|
156
111
|
return terminalFailure;
|
|
157
112
|
},
|
|
158
|
-
get streamedNativeToolCalls() {
|
|
159
|
-
return streamedNativeToolCalls;
|
|
160
|
-
},
|
|
161
|
-
get emittedToolCount() {
|
|
162
|
-
return emittedToolIds.size;
|
|
163
|
-
},
|
|
164
113
|
};
|
|
165
114
|
}
|
|
@@ -6,13 +6,45 @@
|
|
|
6
6
|
* account-verification URL Google hides in the error details), and the
|
|
7
7
|
* per-attempt hand-off of the live stream to the turn collector.
|
|
8
8
|
*/
|
|
9
|
-
import { emitProviderRetryStage, withRetry } from './retry-classifier.mjs';
|
|
9
|
+
import { emitProviderRetryStage, markProviderRecoveryExhausted, sleepWithAbort, withRetry } from './retry-classifier.mjs';
|
|
10
|
+
import {
|
|
11
|
+
ANTIGRAVITY_RETRY,
|
|
12
|
+
antigravity429WaitMs,
|
|
13
|
+
isAntigravityCapacityError,
|
|
14
|
+
} from './antigravity-retry-policy.mjs';
|
|
10
15
|
import { createTimeoutSignal } from '../stall-policy.mjs';
|
|
11
16
|
import { getLlmDispatcher } from '../../../shared/llm/http-agent.mjs';
|
|
12
17
|
import { GEMINI_FIRST_BYTE_TIMEOUT_MS } from './gemini-stream.mjs';
|
|
13
18
|
import { _scrubTokens } from './antigravity-oauth-tokens.mjs';
|
|
19
|
+
import { applyGeminiErrorContract } from './gemini-error-contract.mjs';
|
|
20
|
+
import { DETERMINISTIC_KINDS, providerErrorKind } from './provider-error-kind.mjs';
|
|
14
21
|
|
|
15
|
-
|
|
22
|
+
// Rate-limit reason: 503/529 are capacity by status; a
|
|
23
|
+
// typed ErrorInfo reason decides next; wording is the last resort for a 429.
|
|
24
|
+
const CAPACITY_MESSAGE_RE = /capacity|overloaded|resource exhausted|server (?:is )?(?:currently )?busy/i;
|
|
25
|
+
const RATE_LIMIT_MESSAGE_RE = /per minute|rate limit|too many requests/i;
|
|
26
|
+
const TYPED_REASONS = new Set(['quota_exhausted', 'rate_limit_exceeded', 'model_capacity_exhausted']);
|
|
27
|
+
|
|
28
|
+
function applyAntigravityRateLimitReason(err, status, message) {
|
|
29
|
+
if (status === 503 || status === 529) {
|
|
30
|
+
// A typed refusal of this request (bad argument, policy, auth, quota) is
|
|
31
|
+
// not an overload whatever the status says.
|
|
32
|
+
if (DETERMINISTIC_KINDS.has(providerErrorKind(err).kind)) return;
|
|
33
|
+
err.code = 'model_capacity_exhausted';
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (status !== 429 || TYPED_REASONS.has(err.code)) return;
|
|
37
|
+
if (CAPACITY_MESSAGE_RE.test(message)) err.code = 'model_capacity_exhausted';
|
|
38
|
+
else if (RATE_LIMIT_MESSAGE_RE.test(message)) err.code = 'rate_limit_exceeded';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const CAPACITY_STATUSES = new Set([429, 503, 529]);
|
|
42
|
+
|
|
43
|
+
function isCapacityFailure(err) {
|
|
44
|
+
return CAPACITY_STATUSES.has(Number(err?.status)) && isAntigravityCapacityError(err);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function antigravityError(res, text, endpoint) {
|
|
16
48
|
let payload = null;
|
|
17
49
|
try {
|
|
18
50
|
payload = text ? JSON.parse(text) : null;
|
|
@@ -30,23 +62,36 @@ function antigravityError(res, text, endpoint) {
|
|
|
30
62
|
err.error = detail;
|
|
31
63
|
err.data = payload;
|
|
32
64
|
if (detail.status) err.geminiStatus = detail.status;
|
|
65
|
+
const details = detail.details ?? detail.errorDetails;
|
|
66
|
+
applyGeminiErrorContract(err, { details, googleStatus: detail.status, message });
|
|
33
67
|
}
|
|
68
|
+
// Capacity is overload of the shared model pool, not this account's quota.
|
|
69
|
+
applyAntigravityRateLimitReason(err, res.status, message);
|
|
34
70
|
// Account verification is terminal and actionable: surface the URL Google
|
|
35
71
|
// returns instead of a raw API body the user cannot act on.
|
|
36
72
|
// Google puts the link in the error details, not the message text.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
73
|
+
// Order: google.rpc.Help.links, metadata.validation_url, metadata.validation_link.
|
|
74
|
+
const detailEntries = Array.isArray(detail?.details) ? detail.details : [];
|
|
75
|
+
const helpUrl = detailEntries
|
|
76
|
+
.flatMap((entry) => (Array.isArray(entry?.links) ? entry.links : []))
|
|
77
|
+
.map((link) => link?.url)
|
|
78
|
+
.find((url) => typeof url === 'string' && url.length > 0);
|
|
79
|
+
const metadataUrl = (key) =>
|
|
80
|
+
detailEntries.find((entry) => entry?.reason === 'VALIDATION_REQUIRED' && typeof entry.metadata?.[key] === 'string' && entry.metadata[key])
|
|
81
|
+
?.metadata[key];
|
|
42
82
|
const validationUrl =
|
|
43
|
-
|
|
83
|
+
helpUrl ||
|
|
84
|
+
metadataUrl('validation_url') ||
|
|
85
|
+
metadataUrl('validation_link') ||
|
|
44
86
|
/https:\/\/\S*(?:accounts|console)\.google\.com\/\S+/.exec(message || '')?.[0] ||
|
|
45
87
|
'';
|
|
46
88
|
if (res.status === 403 && /VALIDATION_REQUIRED/i.test(text || '')) {
|
|
47
89
|
err.message = `Antigravity requires account verification${validationUrl ? `: open ${validationUrl} , complete the check, then retry` : ''}`;
|
|
48
90
|
err.validationUrl = validationUrl || undefined;
|
|
49
91
|
err.unsafeToRetry = true;
|
|
92
|
+
// This account needs verification; another account may still serve.
|
|
93
|
+
err.code ||= 'validation_required';
|
|
94
|
+
err.accountBlocked = true;
|
|
50
95
|
}
|
|
51
96
|
return err;
|
|
52
97
|
}
|
|
@@ -62,8 +107,17 @@ function antigravityError(res, text, endpoint) {
|
|
|
62
107
|
* @param {{ beginAttempt: Function, consume: Function }} deps.collector
|
|
63
108
|
* @returns {() => Promise<object>} one retried request that resolves the final payload
|
|
64
109
|
*/
|
|
65
|
-
export function createAntigravityRequest({ fetchFn, endpoint, headers, body, opts, signal, collector }) {
|
|
66
|
-
|
|
110
|
+
export function createAntigravityRequest({ fetchFn, endpoint, headers, body, opts, signal, collector, sleepFn }) {
|
|
111
|
+
const log = (attempt, lastErr, delayMs) => {
|
|
112
|
+
emitProviderRetryStage(opts.onStageChange, {
|
|
113
|
+
attempt: attempt + 1,
|
|
114
|
+
maxAttempts: ANTIGRAVITY_RETRY.maxAttempts,
|
|
115
|
+
lastErr,
|
|
116
|
+
delayMs,
|
|
117
|
+
});
|
|
118
|
+
process.stderr.write(`[antigravity] retry ${attempt + 1} after ${lastErr?.message || 'transient error'}\n`);
|
|
119
|
+
};
|
|
120
|
+
const attemptOnce = () =>
|
|
67
121
|
withRetry(
|
|
68
122
|
async ({ signal: attemptSignal }) => {
|
|
69
123
|
try {
|
|
@@ -94,17 +148,42 @@ export function createAntigravityRequest({ fetchFn, endpoint, headers, body, opt
|
|
|
94
148
|
}
|
|
95
149
|
if (!res.ok) {
|
|
96
150
|
const text = await res.text().catch(() => '');
|
|
97
|
-
|
|
151
|
+
const failure = antigravityError(res, text, endpoint);
|
|
152
|
+
// Capacity is paced by the local schedule below; the generic loop
|
|
153
|
+
// would sleep whatever wait the server names.
|
|
154
|
+
if (isCapacityFailure(failure)) markProviderRecoveryExhausted(failure, { owner: 'antigravity-capacity' });
|
|
155
|
+
throw failure;
|
|
98
156
|
}
|
|
99
157
|
collector.beginAttempt();
|
|
100
158
|
return collector.consume(res, attemptSignal);
|
|
101
159
|
},
|
|
102
160
|
{
|
|
161
|
+
...ANTIGRAVITY_RETRY,
|
|
162
|
+
finalOnExhaust: true,
|
|
103
163
|
signal,
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
process.stderr.write(`[antigravity] retry ${attempt + 1} after ${retryErr?.message || 'transient error'}\n`);
|
|
107
|
-
},
|
|
164
|
+
sleepFn,
|
|
165
|
+
onRetry: ({ attempt, lastErr: retryErr, delayMs }) => log(attempt, retryErr, delayMs),
|
|
108
166
|
}
|
|
109
167
|
);
|
|
168
|
+
// A 429 comes back from withRetry untouched (retry429:false) and is paced by
|
|
169
|
+
// the retry schedule: capacity backs off on this host, an RPM hit
|
|
170
|
+
// gets one quick retry, a spent quota surfaces.
|
|
171
|
+
return async () => {
|
|
172
|
+
const state = { capacityRetries: 0, quickRetried: false };
|
|
173
|
+
for (let tried = 1; ; tried++) {
|
|
174
|
+
try {
|
|
175
|
+
return await attemptOnce();
|
|
176
|
+
} catch (err) {
|
|
177
|
+
const waitMs = antigravity429WaitMs(err, state);
|
|
178
|
+
if (waitMs == null) {
|
|
179
|
+
if (isCapacityFailure(err)) {
|
|
180
|
+
markProviderRecoveryExhausted(err, { owner: 'antigravity-capacity', attempts: tried });
|
|
181
|
+
}
|
|
182
|
+
throw err;
|
|
183
|
+
}
|
|
184
|
+
log(tried, err, waitMs);
|
|
185
|
+
await sleepWithAbort(waitMs, signal, sleepFn, 'Antigravity retry wait aborted');
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
};
|
|
110
189
|
}
|
|
@@ -20,7 +20,7 @@ import { createNpmVersionSource, maxSemver } from './npm-cli-version.mjs';
|
|
|
20
20
|
// version (gpt-6.1-sol requires >= 0.159.0, measured 2026-10-09), so the
|
|
21
21
|
// release workflow raises this to the published CLI version on every release
|
|
22
22
|
// (scripts/sync-client-version-floors.mjs).
|
|
23
|
-
export const CODEX_CLIENT_VERSION_FLOOR = '0.
|
|
23
|
+
export const CODEX_CLIENT_VERSION_FLOOR = '0.163.0';
|
|
24
24
|
export const CODEX_CLI_NPM_PACKAGE = '@openai/codex';
|
|
25
25
|
const live = createNpmVersionSource(CODEX_CLI_NPM_PACKAGE, { persistKey: 'codex-cli' });
|
|
26
26
|
|
|
@@ -2,22 +2,25 @@
|
|
|
2
2
|
* Command Code provider (commandcode.ai Provider API).
|
|
3
3
|
*
|
|
4
4
|
* Credentials are a Studio-issued API key (command-code-oauth-tokens.mjs).
|
|
5
|
-
* Each model is served on
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* Command Code API host. The key never expires and
|
|
9
|
-
* 401 means the user must sign in again.
|
|
5
|
+
* Each model is served on a wire its /models row declares (wire-route.mjs
|
|
6
|
+
* picks among them): Chat Completions and Responses through the
|
|
7
|
+
* OpenAI-compatible engine, Messages through the Anthropic engine. Both
|
|
8
|
+
* clients are pinned to the Command Code API host. The key never expires and
|
|
9
|
+
* has no refresh grant: a 401 means the user must sign in again.
|
|
10
10
|
*/
|
|
11
11
|
import { noteErrorUsage } from './lib/note-error-usage.mjs';
|
|
12
12
|
import { fileMtimeMs, normalizeExpiresAtMs, scrubOAuthSecrets } from './lib/oauth-token-utils.mjs';
|
|
13
|
+
import { originBoundFetch } from './lib/origin-bound-fetch.mjs';
|
|
14
|
+
import { withInclusiveUsage } from './lib/inclusive-usage.mjs';
|
|
13
15
|
import { OpenAICompatProvider, preloadOpenAICompatRuntime } from './openai-compat.mjs';
|
|
16
|
+
import { COMPAT_RETRY_POLICY } from './openai-compat-retry-profile.mjs';
|
|
14
17
|
import { listCompatModels } from './openai-compat-models.mjs';
|
|
15
18
|
import { AnthropicProvider } from './anthropic.mjs';
|
|
16
|
-
import { toInclusiveOpenCodeGoUsage as toInclusiveUsage } from './opencode-go.mjs';
|
|
17
19
|
import { sanitizeToolPairs } from '../session/context-utils.mjs';
|
|
18
20
|
import { preparePdfTextForProvider } from './media-normalization.mjs';
|
|
19
|
-
import { currentUsageContext } from '../../../shared/llm/usage-context.mjs';
|
|
20
21
|
import { makeModelCache } from './model-cache.mjs';
|
|
22
|
+
import { resolveWireRoute, sendOnRoute } from './wire-route.mjs';
|
|
23
|
+
import { gatewayMessagesOpts } from './wire-gateway.mjs';
|
|
21
24
|
import {
|
|
22
25
|
API_ORIGIN,
|
|
23
26
|
CREDITS_URL,
|
|
@@ -37,8 +40,11 @@ export {
|
|
|
37
40
|
export { beginOAuthLogin, loginOAuth } from './command-code-oauth-login.mjs';
|
|
38
41
|
|
|
39
42
|
export const DEFAULT_MODEL = 'deepseek/deepseek-v4-flash';
|
|
40
|
-
const
|
|
41
|
-
|
|
43
|
+
const ENDPOINT_WIRES = Object.freeze({
|
|
44
|
+
'/chat/completions': 'chat',
|
|
45
|
+
'/messages': 'messages',
|
|
46
|
+
'/responses': 'responses',
|
|
47
|
+
});
|
|
42
48
|
// The Anthropic SDK appends /v1/messages itself.
|
|
43
49
|
const MESSAGES_BASE_URL = `${API_ORIGIN}/provider`;
|
|
44
50
|
const FIVE_HOURS_MS = 5 * 60 * 60 * 1000;
|
|
@@ -55,35 +61,42 @@ const commandCodeModelCache = makeModelCache({
|
|
|
55
61
|
});
|
|
56
62
|
|
|
57
63
|
/**
|
|
58
|
-
* The
|
|
59
|
-
*
|
|
60
|
-
|
|
64
|
+
* The wires a /models row declares (`supported_endpoints`), or null when it
|
|
65
|
+
* declares none — such a row is served on Chat Completions by convention.
|
|
66
|
+
*/
|
|
67
|
+
export function modelEndpoints(item) {
|
|
68
|
+
const declared = item?.supported_endpoints;
|
|
69
|
+
if (!Array.isArray(declared)) return null;
|
|
70
|
+
const wires = [];
|
|
71
|
+
for (const endpoint of declared) {
|
|
72
|
+
const path = String(endpoint).replace(/^\/?(?:provider\/)?(?:v1\/)?/, '/');
|
|
73
|
+
const wire = Object.hasOwn(ENDPOINT_WIRES, path) ? ENDPOINT_WIRES[path] : null;
|
|
74
|
+
if (wire && !wires.includes(wire)) wires.push(wire);
|
|
75
|
+
}
|
|
76
|
+
return wires;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// The route for a model with these declared endpoints (null: undeclared, Chat).
|
|
80
|
+
// `undefined`: nothing describes the model, so no wire is ruled out.
|
|
81
|
+
function commandCodeRoute(model, endpoints, ctx = {}) {
|
|
82
|
+
return resolveWireRoute(PROVIDER_ID, model, { ...ctx, endpoints: endpoints === undefined ? null : (endpoints ?? ['chat']) });
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* The wire a /models row is served on (wire-route.mjs over its declared
|
|
87
|
+
* endpoints): Responses for GPT / Muse / Grok when advertised, otherwise Chat
|
|
88
|
+
* when declared or undeclared, Messages when it is the only one, Responses
|
|
89
|
+
* for a Responses-only row; null when it declares none of them.
|
|
61
90
|
*/
|
|
62
91
|
export function modelWire(item) {
|
|
63
92
|
if (typeof item?.id !== 'string' || !item.id) return null;
|
|
64
|
-
|
|
65
|
-
if (!Array.isArray(endpoints)) return 'chat';
|
|
66
|
-
const declared = endpoints.map((endpoint) => String(endpoint).replace(/^\/?(?:provider\/)?(?:v1\/)?/, '/'));
|
|
67
|
-
if (declared.includes(CHAT_ENDPOINT)) return 'chat';
|
|
68
|
-
if (declared.includes(MESSAGES_ENDPOINT)) return 'messages';
|
|
69
|
-
return null;
|
|
93
|
+
return commandCodeRoute(item.id, modelEndpoints(item))?.wire || null;
|
|
70
94
|
}
|
|
71
95
|
|
|
72
|
-
// Every request either engine makes goes through this fetch:
|
|
73
|
-
//
|
|
74
|
-
// and redirects are never followed (any 3xx is an error).
|
|
96
|
+
// Every request either engine makes goes through this fetch: only the Command
|
|
97
|
+
// Code API origin, never a redirect.
|
|
75
98
|
function apiOnlyFetch(fetchImpl) {
|
|
76
|
-
return
|
|
77
|
-
const url = new URL(String(input?.url ?? input));
|
|
78
|
-
if (url.origin !== API_ORIGIN) {
|
|
79
|
-
throw new Error(`[command-code-oauth] refusing to send the API key to ${url.host}`);
|
|
80
|
-
}
|
|
81
|
-
const res = await (fetchImpl || globalThis.fetch)(input, { ...init, redirect: 'manual' });
|
|
82
|
-
if (res.status >= 300 && res.status < 400) {
|
|
83
|
-
throw new Error(`[command-code-oauth] refusing to follow a redirect from ${url.host}`);
|
|
84
|
-
}
|
|
85
|
-
return res;
|
|
86
|
-
};
|
|
99
|
+
return originBoundFetch(API_ORIGIN, fetchImpl, PROVIDER_ID);
|
|
87
100
|
}
|
|
88
101
|
|
|
89
102
|
// Anthropic engine bound to this credential: only the Command Code key is
|
|
@@ -97,15 +110,11 @@ class CommandCodeMessagesEngine extends AnthropicProvider {
|
|
|
97
110
|
client.fetch = apiOnlyFetch(this.config.fetchImpl);
|
|
98
111
|
return client;
|
|
99
112
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
if (err && typeof err === 'object') {
|
|
104
|
-
if (err.usage) err.usage = toInclusiveUsage(err.usage);
|
|
105
|
-
if (err.partialUsage) err.partialUsage = toInclusiveUsage(err.partialUsage);
|
|
113
|
+
// The roster's output ceiling reaches the shared request builder.
|
|
114
|
+
_sendOnce(messages, model, tools, opts) {
|
|
115
|
+
return super._sendOnce(messages, model, tools, gatewayMessagesOpts(this.config, model, messages, opts));
|
|
106
116
|
}
|
|
107
|
-
|
|
108
|
-
};
|
|
117
|
+
}
|
|
109
118
|
|
|
110
119
|
function rosterRow(item) {
|
|
111
120
|
const contextWindow = Number(item.context_window ?? item.max_context_window ?? item.context_length ?? 0);
|
|
@@ -117,6 +126,11 @@ function rosterRow(item) {
|
|
|
117
126
|
...(name ? { name: name.trim() } : {}),
|
|
118
127
|
...(contextWindow > 0 ? { contextWindow } : {}),
|
|
119
128
|
...(outputTokens > 0 ? { outputTokens } : {}),
|
|
129
|
+
// The full declared endpoint set: the cached route metadata a later
|
|
130
|
+
// send falls back on when the live roster cannot be read.
|
|
131
|
+
...(Array.isArray(item.supported_endpoints)
|
|
132
|
+
? { supportedEndpoints: item.supported_endpoints.map((endpoint) => String(endpoint)) }
|
|
133
|
+
: {}),
|
|
120
134
|
};
|
|
121
135
|
}
|
|
122
136
|
|
|
@@ -146,11 +160,16 @@ function scrubErrorSecrets(err, apiKey) {
|
|
|
146
160
|
}
|
|
147
161
|
|
|
148
162
|
// Redact where the transport first surfaces errors (request open and stream
|
|
149
|
-
// iteration)
|
|
163
|
+
// iteration) on the Chat and Responses endpoints, so the shared retry
|
|
164
|
+
// reporter never logs the key.
|
|
150
165
|
function redactClientErrors(client, apiKey) {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
166
|
+
redactCreateErrors(client?.chat?.completions, apiKey);
|
|
167
|
+
redactCreateErrors(client?.responses, apiKey);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function redactCreateErrors(endpoint, apiKey) {
|
|
171
|
+
if (!endpoint || !apiKey || endpoint.create?.commandCodeRedacting === apiKey) return;
|
|
172
|
+
const create = endpoint.create.bind(endpoint);
|
|
154
173
|
const wrapped = async (...args) => {
|
|
155
174
|
try {
|
|
156
175
|
const stream = await create(...args);
|
|
@@ -176,7 +195,7 @@ function redactClientErrors(client, apiKey) {
|
|
|
176
195
|
}
|
|
177
196
|
};
|
|
178
197
|
wrapped.commandCodeRedacting = apiKey;
|
|
179
|
-
|
|
198
|
+
endpoint.create = wrapped;
|
|
180
199
|
}
|
|
181
200
|
|
|
182
201
|
// Same for the Anthropic client's streaming request (read through
|
|
@@ -242,6 +261,8 @@ export class CommandCodeOAuthProvider {
|
|
|
242
261
|
// OpenAI-compatible usage: prompt_tokens includes cached. See registry.mjs.
|
|
243
262
|
static inputExcludesCache = false;
|
|
244
263
|
name = PROVIDER_ID;
|
|
264
|
+
// The retry profile's limits are final: no loop-level recovery cycles on top.
|
|
265
|
+
retryPolicy = COMPAT_RETRY_POLICY;
|
|
245
266
|
config;
|
|
246
267
|
tokens = null;
|
|
247
268
|
_inner = null;
|
|
@@ -250,8 +271,9 @@ export class CommandCodeOAuthProvider {
|
|
|
250
271
|
_defaultModelKey = null;
|
|
251
272
|
_messages = null;
|
|
252
273
|
_messagesKey = null;
|
|
253
|
-
// Model id →
|
|
254
|
-
|
|
274
|
+
// Model id → declared endpoint wires (null: undeclared) from the roster
|
|
275
|
+
// fetched with `_wiresKey`.
|
|
276
|
+
_endpoints = new Map();
|
|
255
277
|
_wiresKey = null;
|
|
256
278
|
|
|
257
279
|
constructor(config) {
|
|
@@ -312,6 +334,8 @@ export class CommandCodeOAuthProvider {
|
|
|
312
334
|
apiKey,
|
|
313
335
|
baseURL: MESSAGES_BASE_URL,
|
|
314
336
|
disableBetaHeaders: true,
|
|
337
|
+
modelMaxOutputTokens: (model) =>
|
|
338
|
+
commandCodeModelCache.loadSync({ allowStale: true })?.find((row) => row?.id === model)?.outputTokens,
|
|
315
339
|
// x-api-key from the SDK plus the bearer form of the same key.
|
|
316
340
|
extraHeaders: { Authorization: `Bearer ${apiKey}` },
|
|
317
341
|
});
|
|
@@ -321,8 +345,9 @@ export class CommandCodeOAuthProvider {
|
|
|
321
345
|
return engine;
|
|
322
346
|
}
|
|
323
347
|
|
|
324
|
-
// Servable rows from /models
|
|
325
|
-
//
|
|
348
|
+
// Servable rows from /models (any declared Chat, Messages or Responses
|
|
349
|
+
// endpoint, or none declared); only the latest fetch with the still-active
|
|
350
|
+
// key publishes the roster and the per-model endpoint map.
|
|
326
351
|
async _fetchRoster(apiKey, signal = null) {
|
|
327
352
|
const publish = commandCodeModelCache.beginSave(() => loadTokens()?.apiKey === apiKey);
|
|
328
353
|
const body = await requestCommandCodeJson(`${PROVIDER_BASE_URL}/models`, apiKey, {
|
|
@@ -335,16 +360,30 @@ export class CommandCodeOAuthProvider {
|
|
|
335
360
|
const items = list.filter((item) => modelWire(item));
|
|
336
361
|
publish(items.map(rosterRow));
|
|
337
362
|
if (this.tokens?.apiKey === apiKey) {
|
|
338
|
-
|
|
363
|
+
// Rows accumulate for one key: a later roster that misses a model
|
|
364
|
+
// leaves the endpoints it was last listed with.
|
|
365
|
+
const known = this._wiresKey === apiKey ? this._endpoints : new Map();
|
|
366
|
+
for (const item of items) known.set(item.id, modelEndpoints(item));
|
|
367
|
+
this._endpoints = known;
|
|
339
368
|
this._wiresKey = apiKey;
|
|
340
369
|
}
|
|
341
370
|
return items;
|
|
342
371
|
}
|
|
343
372
|
|
|
344
|
-
//
|
|
345
|
-
//
|
|
346
|
-
//
|
|
347
|
-
|
|
373
|
+
// A model's declared endpoints: what this credential's rosters listed,
|
|
374
|
+
// then the persisted roster (a roster miss or a roster that cannot be read
|
|
375
|
+
// right now must not move a known Messages-only model to Chat). null is a
|
|
376
|
+
// row declaring none (Chat); undefined is a model nothing describes.
|
|
377
|
+
_endpointsFor(apiKey, model) {
|
|
378
|
+
if (this._wiresKey === apiKey && this._endpoints.has(model)) return this._endpoints.get(model);
|
|
379
|
+
const cached = commandCodeModelCache.loadSync({ allowStale: true })?.find((row) => row?.id === model);
|
|
380
|
+
return cached ? modelEndpoints({ supported_endpoints: cached.supportedEndpoints }) : undefined;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
// This credential's route for a model (the roster is fetched once when
|
|
384
|
+
// missing; a roster that cannot be read falls back on the persisted rows);
|
|
385
|
+
// a rejected key is surfaced.
|
|
386
|
+
async _routeFor(inner, model, ctx = {}) {
|
|
348
387
|
if (this._wiresKey !== inner.apiKey) {
|
|
349
388
|
try {
|
|
350
389
|
await listCompatModels(inner, { throwOnError: true });
|
|
@@ -352,7 +391,16 @@ export class CommandCodeOAuthProvider {
|
|
|
352
391
|
if (isUnauthorized(err)) throw err;
|
|
353
392
|
}
|
|
354
393
|
}
|
|
355
|
-
|
|
394
|
+
const endpoints = this._endpointsFor(inner.apiKey, model);
|
|
395
|
+
return commandCodeRoute(model, endpoints, {
|
|
396
|
+
...ctx,
|
|
397
|
+
override: this.config?.modelWires?.[model] ?? null,
|
|
398
|
+
known: endpoints !== undefined,
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
resolveWireRoute(model, ctx = {}) {
|
|
403
|
+
return this._routeFor(this._ensureInner(), model, ctx);
|
|
356
404
|
}
|
|
357
405
|
|
|
358
406
|
// A rejected key needs a fresh sign-in; the gateway's own detail stays attached.
|
|
@@ -379,17 +427,21 @@ export class CommandCodeOAuthProvider {
|
|
|
379
427
|
throw this._shapeError(err, this.tokens?.apiKey);
|
|
380
428
|
}
|
|
381
429
|
const apiKey = this._innerKey;
|
|
382
|
-
// The model's
|
|
383
|
-
//
|
|
384
|
-
const { compatWireApi: _wire, responsesTransport: _transport, ...
|
|
430
|
+
// The model's route (the session's pinned one, else its declared
|
|
431
|
+
// endpoints) picks the wire; a caller's compat wire flag cannot move it.
|
|
432
|
+
const { compatWireApi: _wire, responsesTransport: _transport, ...callerOpts } = sendOpts || {};
|
|
385
433
|
try {
|
|
386
434
|
const useModel = model || (await this._pickDefaultModel(inner));
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
435
|
+
// One clear "unsupported" refusal moves the send to the next wire once.
|
|
436
|
+
return await sendOnRoute(this, useModel, tools, callerOpts, messages, (wire, history, opts) => {
|
|
437
|
+
if (wire === 'messages') return this._sendMessages(apiKey, history, useModel, tools, opts);
|
|
438
|
+
// _doSend directly: the compat wrapper's 401 handler reloads a static
|
|
439
|
+
// config key, which does not apply to this credential.
|
|
440
|
+
if (wire === 'responses') {
|
|
441
|
+
return inner._doSend(history, useModel, tools, { ...opts, compatWireApi: 'responses' });
|
|
442
|
+
}
|
|
443
|
+
return inner._doSend(history, useModel, tools, opts);
|
|
444
|
+
});
|
|
393
445
|
} catch (err) {
|
|
394
446
|
throw this._shapeError(err, apiKey);
|
|
395
447
|
}
|
|
@@ -402,14 +454,7 @@ export class CommandCodeOAuthProvider {
|
|
|
402
454
|
async _sendMessages(apiKey, messages, model, tools, opts) {
|
|
403
455
|
const engine = this._ensureMessages(apiKey);
|
|
404
456
|
const prepared = await preparePdfTextForProvider(sanitizeToolPairs(messages), engine);
|
|
405
|
-
|
|
406
|
-
if (identity) identity.normalizeAbandonedUsage = toInclusiveUsage;
|
|
407
|
-
try {
|
|
408
|
-
const result = await engine._doSend(prepared, model, tools, opts);
|
|
409
|
-
return result?.usage ? { ...result, usage: toInclusiveUsage(result.usage) } : result;
|
|
410
|
-
} catch (err) {
|
|
411
|
-
throw normalizeUsageError(err);
|
|
412
|
-
}
|
|
457
|
+
return withInclusiveUsage(() => engine._doSend(prepared, model, tools, opts));
|
|
413
458
|
}
|
|
414
459
|
|
|
415
460
|
async listModels() {
|