@bitkyc08/opencodex 2.100.5 → 2.100.6-preview.20261119.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/README.md +1 -1
- package/bin/ocx.mjs +2 -0
- package/gui/dist/assets/App-BI8LQ7Qk.css +1 -0
- package/gui/dist/assets/App-D5qUBOoF.js +60 -0
- package/gui/dist/assets/Tray-DMwQSAli.js +1 -0
- package/gui/dist/assets/brand-mark-ycThul7d.js +1 -0
- package/gui/dist/assets/index-Bp_GaFFu.js +138 -0
- package/gui/dist/assets/index-BtwVlpeQ.css +2 -0
- package/gui/dist/assets/{segment-thumb-features-Bquysdn5.js → segment-thumb-features-BLUW2Fb1.js} +1 -1
- package/gui/dist/classic/assets/App-CoiVLRW3.css +1 -0
- package/gui/dist/classic/assets/App-D39mkP2w.js +59 -0
- package/gui/dist/classic/assets/Tray-nUmdL7K9.js +1 -0
- package/gui/dist/classic/assets/index-BJ4uxZk0.js +138 -0
- package/gui/dist/classic/assets/usage-companion-chart-DFoYm2RY.js +1 -0
- package/gui/dist/classic/index.html +1 -1
- package/gui/dist/index.html +2 -2
- package/native/ocx-child/Cargo.lock +62 -0
- package/native/ocx-child/Cargo.toml +1 -0
- package/native/ocx-child/src/journal.rs +32 -10
- package/native/ocx-child/src/state.rs +2 -1
- package/native/ocx-child/src/toml_surgeon.rs +183 -72
- package/package.json +2 -2
- package/src/adapters/agy-acp/acp.ts +202 -0
- package/src/adapters/agy-acp/adapter.ts +554 -0
- package/src/adapters/agy-acp/binary.ts +79 -0
- package/src/adapters/agy-acp/options.ts +163 -0
- package/src/adapters/agy-acp/output-redaction.ts +270 -0
- package/src/adapters/agy-acp/policy.ts +105 -0
- package/src/adapters/agy-acp/process.ts +218 -0
- package/src/adapters/anthropic/account-metadata.ts +4 -1
- package/src/adapters/anthropic/advisor-tool.ts +43 -9
- package/src/adapters/anthropic/client-identity.ts +2 -0
- package/src/adapters/anthropic.ts +102 -14
- package/src/adapters/antigravity-refusal.ts +5 -1
- package/src/adapters/base.ts +25 -2
- package/src/adapters/claude-cli/adapter.ts +1 -0
- package/src/adapters/claude-cli/usage-admission.ts +12 -9
- package/src/adapters/codebuddy/adapter.ts +1 -0
- package/src/adapters/command-code.ts +2 -2
- package/src/adapters/cursor/http1-bidi.ts +7 -2
- package/src/adapters/cursor/live-transport.ts +2 -0
- package/src/adapters/cursor/request-builder.ts +4 -4
- package/src/adapters/cursor/tool-naming.ts +5 -5
- package/src/adapters/cursor/transport-retry.ts +14 -8
- package/src/adapters/cursor/transport.ts +2 -0
- package/src/adapters/cursor.ts +8 -2
- package/src/adapters/google-error-details.ts +105 -0
- package/src/adapters/google-errors.ts +183 -31
- package/src/adapters/google-http.ts +66 -22
- package/src/adapters/google-truncation.ts +48 -3
- package/src/adapters/google-vertex-endpoint.ts +12 -1
- package/src/adapters/google.ts +54 -26
- package/src/adapters/kiro/adapter.ts +39 -38
- package/src/adapters/kiro/stream.ts +59 -9
- package/src/adapters/kiro-retry.ts +5 -3
- package/src/adapters/m365-copilot/LICENSE +21 -0
- package/src/adapters/m365-copilot/fenced.ts +745 -0
- package/src/adapters/m365-copilot/images.ts +89 -0
- package/src/adapters/m365-copilot/tools.ts +284 -0
- package/src/adapters/m365-copilot/transport.ts +232 -0
- package/src/adapters/m365-copilot.ts +143 -0
- package/src/adapters/openai-chat/tool-schema.ts +2 -2
- package/src/adapters/openai-responses/passthrough.ts +1 -0
- package/src/adapters/openai-responses/reasoning.ts +23 -3
- package/src/adapters/physical-send.ts +11 -4
- package/src/adapters/qoder/adapter.ts +17 -3
- package/src/adapters/registry.ts +15 -1
- package/src/adapters/zed.ts +2 -1
- package/src/advisor/consult.ts +1 -0
- package/src/bridge/response-json.ts +6 -2
- package/src/bridge/sse.ts +21 -9
- package/src/chat/inbound.ts +11 -8
- package/src/chat/outbound.ts +28 -7
- package/src/claude/context-windows.ts +32 -8
- package/src/claude/desktop-3p.ts +18 -14
- package/src/claude/desktop-picker-platform.ts +1 -1
- package/src/claude/desktop-picker.ts +3 -3
- package/src/claude/inbound-content-options.ts +11 -1
- package/src/claude/intercept/picker-ca-cleanup.ts +17 -5
- package/src/claude/intercept/picker-ca.ts +162 -27
- package/src/claude/intercept/picker-trust-linux.ts +411 -0
- package/src/claude/intercept/picker-trust.ts +35 -3
- package/src/claude/intercept/runtime.ts +2 -2
- package/src/claude/subagent-force-status.ts +24 -5
- package/src/claude/subscription-reserve.ts +87 -0
- package/src/cli/account-api.ts +3 -0
- package/src/cli/account-auth.ts +65 -11
- package/src/cli/account-extended.ts +1 -1
- package/src/cli/account-next-actions.ts +4 -1
- package/src/cli/account-policy-dto.ts +1 -1
- package/src/cli/account-policy.ts +6 -3
- package/src/cli/account-probe.ts +66 -0
- package/src/cli/account.ts +8 -2
- package/src/cli/capabilities-accounts.ts +8 -1
- package/src/cli/capabilities-agents-routing.ts +2 -2
- package/src/cli/capabilities-base.ts +4 -4
- package/src/cli/capabilities-integrations.ts +44 -4
- package/src/cli/capabilities-provider-models.ts +6 -0
- package/src/cli/claude-context-settings.ts +60 -0
- package/src/cli/claude-desktop.ts +2 -2
- package/src/cli/claude.ts +15 -7
- package/src/cli/client-start-fence.ts +64 -1
- package/src/cli/combo-result.ts +1 -0
- package/src/cli/combo-stats.ts +1 -1
- package/src/cli/combo.ts +19 -2
- package/src/cli/config-command.ts +21 -8
- package/src/cli/connect.ts +16 -0
- package/src/cli/cross-home-owner.ts +65 -18
- package/src/cli/dispatch.ts +4 -0
- package/src/cli/gateway-client-command.ts +128 -0
- package/src/cli/index.ts +98 -97
- package/src/cli/init.ts +20 -4
- package/src/cli/integrations.ts +23 -3
- package/src/cli/launcher-context.ts +12 -1
- package/src/cli/link.ts +24 -5
- package/src/cli/models-runtime-subcommands.ts +1 -0
- package/src/cli/models-runtime.ts +32 -0
- package/src/cli/start-owner-fence.ts +5 -2
- package/src/cli/status.ts +3 -3
- package/src/cli/stop-client-process.ts +51 -0
- package/src/cli/stop-restore.ts +383 -36
- package/src/cli/sync-command.ts +2 -2
- package/src/cli/uninstall-client-state.ts +7 -0
- package/src/client/connect.ts +72 -13
- package/src/client/hub-client.ts +38 -0
- package/src/client/hub-relay.ts +61 -36
- package/src/client/hub-session.ts +106 -0
- package/src/client/lifecycle-lock.ts +6 -1
- package/src/client/link-relay.ts +2 -1
- package/src/client/machine-listener.ts +60 -1
- package/src/client/runtime-restart.ts +1 -0
- package/src/client/runtime.ts +104 -34
- package/src/client/state.ts +11 -0
- package/src/client/stop-darwin-process.ts +73 -0
- package/src/client/stop-file-routing.ts +49 -0
- package/src/client/stop-native-handoff.ts +108 -0
- package/src/client/stop-routing.ts +41 -7
- package/src/client/stop-teardown-owner.ts +173 -0
- package/src/client/sync-runtime.ts +23 -4
- package/src/clients/config-export/opencode-wire.ts +24 -0
- package/src/clients/config-export.ts +28 -19
- package/src/codex/auth-api/login-flow.ts +68 -33
- package/src/codex/auth-api/main-account-probe.ts +3 -3
- package/src/codex/auth-api/pool-quota-probe.ts +8 -7
- package/src/codex/auth-api/routes.ts +1 -1
- package/src/codex/catalog/aggregation.ts +22 -10
- package/src/codex/catalog/gather-capture.ts +11 -2
- package/src/codex/catalog/m365-copilot-models.ts +52 -0
- package/src/codex/catalog/provider-models.ts +126 -53
- package/src/codex/catalog/routed-gather.ts +26 -12
- package/src/codex/catalog-admission.ts +4 -6
- package/src/codex/catalog-auto-refresh.ts +4 -2
- package/src/codex/catalog-self-heal.ts +4 -2
- package/src/codex/control-plane-models.ts +6 -0
- package/src/codex/convergence.ts +10 -0
- package/src/codex/desktop-app/picker-freshness.ts +3 -14
- package/src/codex/desktop-app/types.ts +6 -0
- package/src/codex/desktop-app/windows-command-payload.ts +9 -0
- package/src/codex/desktop-app/windows.ts +20 -12
- package/src/codex/desktop-compatibility/installed-build.ts +61 -58
- package/src/codex/desktop-compatibility/runtime-ownership.ts +11 -5
- package/src/codex/desktop-compatibility/runtime.ts +51 -14
- package/src/codex/desktop-compatibility/windows-activation-source.ts +28 -13
- package/src/codex/desktop-compatibility/windows-package-command.ts +73 -33
- package/src/codex/desktop-compatibility/windows-package-launch.ts +41 -9
- package/src/codex/desktop-compatibility/windows-package-proof.ts +104 -0
- package/src/codex/inject/config-toml.ts +67 -73
- package/src/codex/inject/plan.ts +11 -10
- package/src/codex/inject/remove.ts +4 -1
- package/src/codex/inject.ts +1 -0
- package/src/codex/journal-config-restore.ts +31 -4
- package/src/codex/journal.ts +16 -4
- package/src/codex/model-cache.ts +98 -27
- package/src/codex/native-residue.ts +14 -13
- package/src/codex/paths.ts +65 -28
- package/src/codex/quota-observation-freshness.ts +4 -0
- package/src/codex/quota.ts +71 -8
- package/src/codex/routing/selection.ts +32 -8
- package/src/combos/capability-policy.ts +31 -0
- package/src/combos/failover.ts +82 -74
- package/src/combos/identifiers.ts +2 -2
- package/src/combos/index.ts +3 -0
- package/src/combos/jev-model-backend.ts +12 -4
- package/src/combos/jev-session-pin-config.ts +22 -9
- package/src/combos/jev.ts +15 -4
- package/src/combos/request-capability.ts +214 -0
- package/src/combos/request.ts +22 -15
- package/src/combos/resolve.ts +5 -2
- package/src/combos/suggestion-channel.ts +89 -0
- package/src/combos/types.ts +14 -1
- package/src/config/account-auto-pause-revisions.ts +33 -10
- package/src/config/atomic-write.ts +1 -1
- package/src/config/codex-ws-incremental-setting.ts +34 -0
- package/src/config/diagnostics.ts +47 -8
- package/src/config/live-topology.ts +4 -2
- package/src/config/load-degrade.ts +96 -2
- package/src/config/mutation-lock.ts +7 -3
- package/src/config/paths.ts +3 -0
- package/src/config/pending-teardown.ts +19 -3
- package/src/config/process-state.ts +30 -12
- package/src/config/provider-validation.ts +10 -0
- package/src/config/salvage.ts +2 -2
- package/src/config/schema/account-auto-pause.ts +15 -1
- package/src/config/schema/agy-acp-references.ts +257 -0
- package/src/config/schema/config-schema.ts +32 -0
- package/src/config/schema/leaf-validators.ts +42 -0
- package/src/config/schema/subscription-reserve.ts +33 -0
- package/src/config/windows-process-command-line.ts +27 -9
- package/src/config.ts +6 -0
- package/src/generated/compatibility-version.json +806 -402
- package/src/images/loop.ts +79 -39
- package/src/integrations/catalog-refresh.ts +19 -1
- package/src/integrations/gateway-clients/agy.ts +340 -0
- package/src/integrations/gateway-clients/antigravity.ts +224 -0
- package/src/integrations/gateway-clients/index.ts +89 -0
- package/src/integrations/gateway-clients/io.ts +278 -0
- package/src/integrations/gateway-clients/types.ts +80 -0
- package/src/integrations/route-intent-disconnect.ts +37 -21
- package/src/lib/app-owned-memory-stores.ts +9 -0
- package/src/lib/cloud-code-appeal-link.ts +30 -0
- package/src/lib/errors.ts +32 -0
- package/src/lib/executor-physical-send-receipt.ts +42 -0
- package/src/lib/failure-detail.ts +1 -0
- package/src/lib/gcp-adc.ts +5 -0
- package/src/lib/http-date.ts +91 -0
- package/src/lib/lab-passive-linker-registration.ts +2 -1
- package/src/lib/local-chat-completion.ts +13 -3
- package/src/lib/local-internal-call-capability.ts +1 -3
- package/src/lib/messages-error-body.ts +2 -1
- package/src/lib/outbound-credential-registry.ts +40 -4
- package/src/lib/pinned-http.ts +7 -2
- package/src/lib/process-control.ts +1 -0
- package/src/lib/provider-egress.ts +16 -0
- package/src/lib/provider-outbound.ts +3 -0
- package/src/lib/redact-folding.ts +12 -3
- package/src/lib/redact.ts +37 -19
- package/src/lib/request-execution-budget.ts +241 -32
- package/src/lib/request-peer-scope.ts +64 -0
- package/src/lib/response-send-readings.ts +41 -0
- package/src/lib/state-store-registrations.ts +5 -0
- package/src/lib/tool-envelope-echo-filter.ts +33 -5
- package/src/lib/upstream-condition.ts +10 -3
- package/src/lib/upstream-retry.ts +95 -20
- package/src/lib/windows-secret-acl.ts +24 -7
- package/src/link/child-activity.ts +60 -4
- package/src/link/codex-settings.ts +2 -1
- package/src/link/relay-auth.ts +1 -0
- package/src/link/route-rounds.ts +32 -9
- package/src/link/status-projection.ts +42 -5
- package/src/link/supervisor.ts +96 -11
- package/src/link/tunnel-history.ts +5 -0
- package/src/oauth/account-auto-pause-policy.ts +72 -19
- package/src/oauth/account-auto-pause.ts +40 -16
- package/src/oauth/anthropic-account-refusal.ts +7 -0
- package/src/oauth/anthropic-continuity.ts +70 -9
- package/src/oauth/anthropic-identity.ts +75 -11
- package/src/oauth/anthropic-login-slot.ts +258 -0
- package/src/oauth/anthropic-routing.ts +24 -9
- package/src/oauth/anthropic-send-ownership.ts +4 -3
- package/src/oauth/anthropic.ts +30 -11
- package/src/oauth/health.ts +7 -2
- package/src/oauth/index.ts +50 -48
- package/src/oauth/key-providers.ts +2 -0
- package/src/oauth/login-cli.ts +11 -0
- package/src/oauth/login-flow-state.ts +10 -4
- package/src/oauth/m365-copilot-browser.ts +222 -0
- package/src/oauth/m365-copilot-web-session.ts +25 -0
- package/src/oauth/m365-copilot.ts +57 -0
- package/src/oauth/model-discovery-auth.ts +5 -0
- package/src/oauth/plan.ts +44 -0
- package/src/oauth/pool-kernel.ts +22 -8
- package/src/oauth/pool-settings-capability.ts +14 -3
- package/src/oauth/reauth-precheck.ts +27 -0
- package/src/oauth/store-anthropic-instance.ts +3 -1
- package/src/oauth/store.ts +121 -23
- package/src/oauth/types.ts +27 -2
- package/src/protocols/codecs/chat-ir.ts +7 -4
- package/src/protocols/codecs/gemini-interactions.ts +770 -0
- package/src/protocols/codecs/gemini.ts +470 -0
- package/src/protocols/contract.ts +2 -0
- package/src/protocols/encoders/adapter-events.ts +5 -3
- package/src/protocols/encoders/chat.ts +23 -7
- package/src/protocols/settings.ts +3 -0
- package/src/providers/account-quota-disk.ts +26 -8
- package/src/providers/api-key-pause.ts +2 -2
- package/src/providers/api-key-response-ownership.ts +14 -4
- package/src/providers/claude-cli-usage-state.ts +1 -0
- package/src/providers/claude-cli-usage.ts +24 -7
- package/src/providers/default-aliases.ts +11 -5
- package/src/providers/derive.ts +5 -1
- package/src/providers/fastwire.ts +6 -5
- package/src/providers/free-directory.ts +2 -2
- package/src/providers/google-vertex-location.ts +2 -1
- package/src/providers/google-vertex-model-discovery.ts +22 -0
- package/src/providers/key-failover.ts +18 -23
- package/src/providers/m365-copilot-discovery-fetch.ts +17 -0
- package/src/providers/m365-copilot-discovery.ts +68 -0
- package/src/providers/m365-copilot-models.ts +32 -0
- package/src/providers/model-rename-fields.ts +6 -0
- package/src/providers/new-model-policy-runtime.ts +27 -6
- package/src/providers/openai-forward-destination.ts +19 -0
- package/src/providers/openai-tiers-destination.ts +3 -19
- package/src/providers/quota/account-cache.ts +183 -27
- package/src/providers/quota/anthropic-account-quota.ts +21 -17
- package/src/providers/quota/anthropic-cooldown-recovery.ts +57 -27
- package/src/providers/quota/anthropic-decision-windows.ts +7 -3
- package/src/providers/quota/anthropic-usage-windows.ts +34 -4
- package/src/providers/quota/antigravity-account-probe.ts +165 -0
- package/src/providers/quota/antigravity.ts +71 -3
- package/src/providers/quota/vendor-probes-oauth.ts +52 -28
- package/src/providers/quota-decision-publication.ts +1 -1
- package/src/providers/quota-decision-snapshot.ts +4 -1
- package/src/providers/quota-types.ts +2 -0
- package/src/providers/quota.ts +8 -7
- package/src/providers/registry/agy-acp-models.ts +3 -0
- package/src/providers/registry/entries-core.ts +9 -0
- package/src/providers/registry/entries-extended.ts +60 -0
- package/src/providers/registry/model-seeds.ts +51 -0
- package/src/providers/request-pacing.ts +37 -7
- package/src/providers/service-tier.ts +2 -0
- package/src/providers/xai-privacy-mode.ts +52 -0
- package/src/remote/hub-management-relay.ts +74 -0
- package/src/responses/id-limits.ts +2 -0
- package/src/responses/input-media.ts +15 -3
- package/src/responses/parser-tools.ts +74 -11
- package/src/responses/parser.ts +16 -14
- package/src/responses/provider-opaque-metadata.ts +10 -0
- package/src/responses/reasoning-envelope.ts +3 -0
- package/src/responses/schema.ts +2 -3
- package/src/responses/spill-store.ts +5 -3
- package/src/responses/state/connection-scope.ts +232 -0
- package/src/responses/state/entry-types.ts +47 -0
- package/src/responses/state/snapshot-codec.ts +75 -14
- package/src/responses/state/snapshot-select.ts +2 -0
- package/src/responses/state/spill-codec.ts +59 -0
- package/src/responses/state/spill-queue.ts +11 -2
- package/src/responses/state.ts +178 -159
- package/src/router.ts +2 -6
- package/src/routing/compatibility/behavior.ts +6 -2
- package/src/routing/compatibility/subject.ts +17 -12
- package/src/routing/machine-weighted-routing.ts +58 -0
- package/src/server/advisor-admission-scope.ts +15 -7
- package/src/server/auth-cors.ts +27 -0
- package/src/server/chat-completions.ts +37 -17
- package/src/server/chat-native-eligibility.ts +21 -0
- package/src/server/chat-native.ts +15 -6
- package/src/server/claude-messages.ts +54 -6
- package/src/server/credential-recovery-attempt.ts +32 -0
- package/src/server/effort-policy.ts +6 -3
- package/src/server/gemini-inbound.ts +267 -0
- package/src/server/gemini-interactions-inbound.ts +229 -0
- package/src/server/gemini-interactions-store.ts +129 -0
- package/src/server/gemini-native-catalog.ts +64 -0
- package/src/server/gemini-native-log.ts +33 -0
- package/src/server/gemini-native-paths.ts +88 -0
- package/src/server/gemini-native-wire.ts +201 -0
- package/src/server/gemini-native.ts +218 -0
- package/src/server/grok-upstream-envelope-echo.ts +8 -2
- package/src/server/hub-relay-auth.ts +87 -0
- package/src/server/hub-usage-windows.ts +135 -0
- package/src/server/hub-usage.ts +16 -3
- package/src/server/inbound-body-admission.ts +2 -1
- package/src/server/index/anthropic-model-listing.ts +75 -0
- package/src/server/index/gemini-routes.ts +147 -0
- package/src/server/index/link-management.ts +3 -22
- package/src/server/index/link-relay-sessions.ts +71 -13
- package/src/server/index/link-websocket.ts +2 -0
- package/src/server/index/passive-management-read.ts +55 -0
- package/src/server/index/serve-options.ts +93 -107
- package/src/server/index/websocket-handler.ts +15 -2
- package/src/server/index.ts +10 -0
- package/src/server/inference/client-encoder-delivery.ts +2 -1
- package/src/server/inference/context.ts +33 -6
- package/src/server/management/agent-settings-routes.ts +33 -16
- package/src/server/management/claude-code-settings-patch.ts +6 -0
- package/src/server/management/combo-routes.ts +21 -1
- package/src/server/management/combo-suggestion-routes.ts +212 -0
- package/src/server/management/config-routes.ts +12 -4
- package/src/server/management/context.ts +2 -0
- package/src/server/management/gateway-client-routes.ts +62 -0
- package/src/server/management/integration-routes.ts +5 -0
- package/src/server/management/link-routes.ts +5 -1
- package/src/server/management/m365-copilot-provider-probe.ts +23 -0
- package/src/server/management/model-routes.ts +32 -2
- package/src/server/management/model-rows.ts +36 -3
- package/src/server/management/oauth-account-routes.ts +68 -15
- package/src/server/management/protocol-settings-patch.ts +1 -0
- package/src/server/management/provider-omitted-fields.ts +25 -0
- package/src/server/management/provider-overwrite-carry.ts +33 -8
- package/src/server/management/provider-routes.ts +10 -16
- package/src/server/management/request-history-routes.ts +2 -2
- package/src/server/management/route-registry.ts +10 -0
- package/src/server/management/shared.ts +118 -30
- package/src/server/management/sibling-guard.ts +2 -1
- package/src/server/management/system-routes.ts +6 -0
- package/src/server/management-auth.ts +8 -1
- package/src/server/messages-native-scope.ts +19 -0
- package/src/server/messages-native.ts +156 -59
- package/src/server/messages-shared.ts +6 -0
- package/src/server/models-capabilities.ts +24 -0
- package/src/server/native-chat-bridge.ts +259 -0
- package/src/server/ollama-inbound.ts +36 -184
- package/src/server/passive-route-linker.ts +3 -1
- package/src/server/port-reclaim.ts +48 -4
- package/src/server/proxy-liveness.ts +79 -22
- package/src/server/relay.ts +16 -9
- package/src/server/request-log-account-rotation.ts +2 -1
- package/src/server/request-log-attempt-recovery.ts +24 -2
- package/src/server/request-log-attempt-usage.ts +5 -4
- package/src/server/request-log-committed-terminal.ts +87 -0
- package/src/server/request-log-failure-attribution.ts +3 -3
- package/src/server/request-log-failure-detail.ts +34 -0
- package/src/server/request-log-key-failure.ts +27 -0
- package/src/server/request-log-terminal-status.ts +25 -12
- package/src/server/request-log.ts +59 -63
- package/src/server/responses/adapter-continuation.ts +77 -44
- package/src/server/responses/adapter-delivery.ts +47 -22
- package/src/server/responses/adapter-dispatch.ts +150 -149
- package/src/server/responses/advisor-retention.ts +12 -4
- package/src/server/responses/advisor-slot.ts +97 -2
- package/src/server/responses/agent-task-recovery.ts +44 -11
- package/src/server/responses/agy-acp-preflight.ts +41 -0
- package/src/server/responses/anthropic-image-context.ts +44 -0
- package/src/server/responses/antigravity-validation-refusal.ts +25 -1
- package/src/server/responses/buffered-sse-json.ts +18 -1
- package/src/server/responses/codex-ws-correlation.ts +5 -2
- package/src/server/responses/codex-ws-exchange.ts +91 -8
- package/src/server/responses/codex-ws-incremental.ts +136 -0
- package/src/server/responses/codex-ws-pool.ts +22 -8
- package/src/server/responses/codex-ws-request.ts +5 -0
- package/src/server/responses/codex-ws-send-accounting.ts +8 -0
- package/src/server/responses/codex-ws-session.ts +14 -0
- package/src/server/responses/codex-ws-wire.ts +44 -22
- package/src/server/responses/combo-admission-snapshot.ts +93 -0
- package/src/server/responses/combo-required-tool-stream.ts +16 -4
- package/src/server/responses/combo-selection-keepalive.ts +5 -0
- package/src/server/responses/combo-stream-preflight.ts +182 -73
- package/src/server/responses/compact-response-body.ts +27 -0
- package/src/server/responses/compact.ts +174 -121
- package/src/server/responses/compaction-recovery.ts +7 -0
- package/src/server/responses/core-codex-account.ts +88 -62
- package/src/server/responses/core-combo-failure.ts +15 -0
- package/src/server/responses/core-combo-native.ts +12 -1
- package/src/server/responses/core-combo.ts +340 -94
- package/src/server/responses/core-normalize.ts +19 -12
- package/src/server/responses/core-opaque-recovery.ts +15 -4
- package/src/server/responses/core-options.ts +50 -5
- package/src/server/responses/core-pipeline.ts +11 -0
- package/src/server/responses/core.ts +7 -1
- package/src/server/responses/empty-completion-guard.ts +21 -7
- package/src/server/responses/estimated-usage.ts +2 -1
- package/src/server/responses/fetch-helpers.ts +95 -19
- package/src/server/responses/history-slim.ts +204 -0
- package/src/server/responses/hosted-advisor-spend.ts +49 -0
- package/src/server/responses/image-context-recovery.ts +199 -0
- package/src/server/responses/input-admission.ts +36 -11
- package/src/server/responses/jev-model-invoke.ts +23 -16
- package/src/server/responses/non-replayable-error.ts +12 -2
- package/src/server/responses/passthrough-build-error.ts +5 -3
- package/src/server/responses/passthrough-delivery.ts +74 -33
- package/src/server/responses/passthrough-dispatch.ts +170 -197
- package/src/server/responses/policy-fallback.ts +7 -2
- package/src/server/responses/policy-request-scope.ts +36 -2
- package/src/server/responses/replay-owner.ts +20 -0
- package/src/server/responses/request-prepare.ts +97 -16
- package/src/server/responses/request-send-budget.ts +97 -25
- package/src/server/responses/request-sidecar-auth.ts +138 -65
- package/src/server/responses/request-spend-target.ts +13 -1
- package/src/server/responses/request-spend.ts +228 -47
- package/src/server/responses/request-transport.ts +395 -70
- package/src/server/responses/run-turn-execution.ts +40 -9
- package/src/server/responses/sidecar-execution.ts +214 -67
- package/src/server/responses/sidecar-send-budget.ts +9 -9
- package/src/server/responses/terminal-guard.ts +35 -9
- package/src/server/responses/ws-upstream.ts +27 -6
- package/src/server/responses-phase-inference.ts +32 -9
- package/src/server/responses-terminal-repair.ts +14 -35
- package/src/server/system-env.ts +8 -5
- package/src/server/ws-bridge.ts +23 -17
- package/src/service/health-sentinel-linux.ts +16 -7
- package/src/service/systemd.ts +11 -2
- package/src/service/windows-checked-stop-live.ts +60 -55
- package/src/service/windows-checked-stop.ts +29 -11
- package/src/service/windows-guarded-manager.ts +14 -26
- package/src/service/windows-process-evidence.ts +82 -74
- package/src/service/windows-process-native.ts +69 -20
- package/src/service/windows-service-stop.ts +14 -12
- package/src/service/windows-stop-binding.ts +14 -5
- package/src/service/windows-stop-confirm.ts +1 -1
- package/src/service/windows-task-instance-stop.ts +98 -0
- package/src/service/windows-taskxml.ts +30 -7
- package/src/sidecar/anthropic-binding.ts +1 -1
- package/src/stall-timeout.ts +30 -0
- package/src/telemetry/aggregate.ts +6 -3
- package/src/types/account-auto-pause.ts +19 -1
- package/src/types/accounts.ts +21 -0
- package/src/types/anthropic-account-pool.ts +1 -1
- package/src/types/combo-capability-policy.ts +19 -0
- package/src/types/config.ts +22 -2
- package/src/types/provider.ts +42 -8
- package/src/types/request.ts +15 -0
- package/src/types/tools.ts +22 -5
- package/src/types/wire.ts +1 -0
- package/src/types.ts +4 -0
- package/src/update/check-types.ts +2 -0
- package/src/update/job.ts +8 -3
- package/src/update/managed-release.ts +6 -0
- package/src/update/orchestrated-entry.ts +13 -4
- package/src/update/refresh-scheduler.ts +17 -7
- package/src/usage/attempt-delivery.ts +6 -0
- package/src/usage/cache-provenance.ts +71 -0
- package/src/usage/cost.ts +216 -27
- package/src/usage/credit-billing.ts +88 -0
- package/src/usage/jev-stats.ts +13 -9
- package/src/usage/log.ts +5 -33
- package/src/usage/summary.ts +8 -43
- package/src/usage/user-cost-overlays.ts +13 -1
- package/src/vision/index.ts +8 -3
- package/src/vision/plan.ts +28 -14
- package/src/vision/routed-describe.ts +24 -36
- package/src/web-search/header-deadline.ts +14 -3
- package/src/web-search/index.ts +6 -4
- package/src/web-search/loop.ts +240 -78
- package/src/web-search/progress-stream.ts +29 -2
- package/src/web-search/run-turn-loop.ts +5 -1
- package/gui/dist/assets/App-BGP8I0V4.css +0 -1
- package/gui/dist/assets/App-BRExzhwL.js +0 -60
- package/gui/dist/assets/Tray-DHCWAn8V.js +0 -1
- package/gui/dist/assets/brand-mark-C70PuQ3j.js +0 -1
- package/gui/dist/assets/index-DJxM-imn.css +0 -2
- package/gui/dist/assets/index-Dy1jIGty.js +0 -138
- package/gui/dist/classic/assets/App-B4j-Txmb.css +0 -1
- package/gui/dist/classic/assets/App-CaC-E6Vl.js +0 -59
- package/gui/dist/classic/assets/Tray-BG253fiL.js +0 -1
- package/gui/dist/classic/assets/index-CR_AThOp.js +0 -138
- package/gui/dist/classic/assets/quota-summary-B7KQPpEC.js +0 -1
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process and workspace lifetime for one `agy acp` turn.
|
|
3
|
+
*
|
|
4
|
+
* Each turn gets a fresh directory outside the OpenCodex home. It has mode 0700 on POSIX and a
|
|
5
|
+
* private NTFS ACL on Windows, with its own temp directory. The CLI's request-review permission
|
|
6
|
+
* engine scopes file access to this workspace, which serves as both the spawn and session cwd.
|
|
7
|
+
* POSIX signals the child's group and waits for leader exit and group disappearance. Windows
|
|
8
|
+
* requires a successful System32 taskkill /T /F while the leader is alive and leader closure.
|
|
9
|
+
*/
|
|
10
|
+
import { execFile, spawn, type ChildProcess } from "node:child_process";
|
|
11
|
+
import { chmod, mkdir, mkdtemp, realpath, rm } from "node:fs/promises";
|
|
12
|
+
import { tmpdir } from "node:os";
|
|
13
|
+
import { isAbsolute, join, relative, sep } from "node:path";
|
|
14
|
+
import { forgetEphemeralSecretDir, hardenSecretDirAsync, windowsSecretAclApplies } from "../../lib/windows-secret-acl";
|
|
15
|
+
|
|
16
|
+
export interface TurnWorkspace { dir: string; tmp: string; remove(): Promise<void> }
|
|
17
|
+
|
|
18
|
+
export class AgyAcpCleanupError extends Error {}
|
|
19
|
+
|
|
20
|
+
export class AgyAcpWorkspaceCleanupError extends AgyAcpCleanupError {
|
|
21
|
+
constructor() {
|
|
22
|
+
super("Antigravity ACP could not remove its private workspace.");
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function isInside(child: string, parent: string): boolean {
|
|
27
|
+
const rel = relative(parent, child);
|
|
28
|
+
return rel !== ".." && !rel.startsWith(`..${sep}`) && !isAbsolute(rel);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** A fresh private workspace outside `home`; throws when the temp root resolves inside it. */
|
|
32
|
+
export async function createTurnWorkspace(home: string, tempRoot = tmpdir()): Promise<TurnWorkspace> {
|
|
33
|
+
const root = await realpath(tempRoot);
|
|
34
|
+
let homeReal = home;
|
|
35
|
+
try { homeReal = await realpath(home); } catch { /* a missing home cannot contain the workspace */ }
|
|
36
|
+
if (isInside(root, homeReal)) throw new Error("agy acp workspace would be inside the OpenCodex home");
|
|
37
|
+
const created = await mkdtemp(join(root, "ocx-agy-acp-"));
|
|
38
|
+
let aclDir: string | undefined;
|
|
39
|
+
const remove = async (): Promise<void> => {
|
|
40
|
+
try { await rm(created, { recursive: true, force: true, maxRetries: 2 }); } catch {
|
|
41
|
+
const error = new AgyAcpWorkspaceCleanupError();
|
|
42
|
+
console.warn(error.message);
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
if (aclDir) forgetEphemeralSecretDir(aclDir);
|
|
46
|
+
};
|
|
47
|
+
try {
|
|
48
|
+
const dir = await realpath(created);
|
|
49
|
+
if (isInside(dir, homeReal)) throw new Error("agy acp workspace would be inside the OpenCodex home");
|
|
50
|
+
if (windowsSecretAclApplies()) {
|
|
51
|
+
aclDir = dir;
|
|
52
|
+
const acl = await hardenSecretDirAsync(dir, { required: true });
|
|
53
|
+
if (!acl.ok) throw new Error("agy acp could not harden the workspace ACL");
|
|
54
|
+
} else {
|
|
55
|
+
await chmod(dir, 0o700);
|
|
56
|
+
}
|
|
57
|
+
const tmp = join(dir, ".tmp");
|
|
58
|
+
await mkdir(tmp, { mode: 0o700 });
|
|
59
|
+
return { dir, tmp, remove };
|
|
60
|
+
} catch (error) {
|
|
61
|
+
// Rollback reports its own fixed warning. The caller still receives the original setup error.
|
|
62
|
+
await remove().catch(() => {});
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export type AgyAcpChild = Pick<ChildProcess, "stdin" | "stdout" | "stderr" | "pid" | "exitCode" | "signalCode" | "kill" | "on" | "once">;
|
|
68
|
+
export type AgyAcpSpawn = (binary: string, args: string[], options: { cwd: string; env: Record<string, string> }) => AgyAcpChild;
|
|
69
|
+
|
|
70
|
+
const NO_PROCESS_SPAWN_ERRORS = new Set(["ENOENT", "EACCES", "EPERM", "ENOEXEC", "EMFILE", "ENFILE", "EAGAIN", "ENOMEM"]);
|
|
71
|
+
|
|
72
|
+
/** A failed spawn with no assigned PID has no owned process to reap. */
|
|
73
|
+
export function agySpawnCreatedNoProcess(child: AgyAcpChild, error: NodeJS.ErrnoException): boolean {
|
|
74
|
+
return child.pid === undefined && error.code !== undefined && NO_PROCESS_SPAWN_ERRORS.has(error.code);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export const defaultAgyAcpSpawn: AgyAcpSpawn = (binary, args, options) => spawn(binary, args, {
|
|
78
|
+
...options,
|
|
79
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
80
|
+
windowsHide: true,
|
|
81
|
+
shell: false,
|
|
82
|
+
detached: process.platform !== "win32",
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
export interface ReapOptions {
|
|
86
|
+
graceMs: number;
|
|
87
|
+
reapTimeoutMs: number;
|
|
88
|
+
platform?: NodeJS.Platform;
|
|
89
|
+
signalGroup?: (pid: number, signal: NodeJS.Signals | 0) => void;
|
|
90
|
+
killWindowsTree?: (pid: number, completed: (ok: boolean) => void) => void;
|
|
91
|
+
warnTreeFailure?: () => void;
|
|
92
|
+
setTimeout?: typeof setTimeout;
|
|
93
|
+
clearTimeout?: typeof clearTimeout;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function defaultKillWindowsTree(pid: number, completed: (ok: boolean) => void): void {
|
|
97
|
+
const taskkill = `${process.env.SystemRoot ?? "C:\\Windows"}\\System32\\taskkill.exe`;
|
|
98
|
+
execFile(taskkill, ["/PID", String(pid), "/T", "/F"], { windowsHide: true, timeout: 5_000 }, error => completed(!error));
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const GROUP_POLL_MS = 25;
|
|
102
|
+
|
|
103
|
+
export class AgyAcpTreeCleanupError extends AgyAcpCleanupError {
|
|
104
|
+
constructor(readonly platform = process.platform) {
|
|
105
|
+
super(platform === "win32"
|
|
106
|
+
? "Antigravity ACP could not confirm Windows process tree cleanup."
|
|
107
|
+
: "Antigravity ACP could not confirm POSIX process tree cleanup.");
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** Reject unless the owned process tree is confirmed gone within the deadline. */
|
|
112
|
+
export function reapProcessTree(child: AgyAcpChild, options: ReapOptions): Promise<void> {
|
|
113
|
+
const set = options.setTimeout ?? setTimeout;
|
|
114
|
+
const clear = options.clearTimeout ?? clearTimeout;
|
|
115
|
+
const platform = options.platform ?? process.platform;
|
|
116
|
+
const pid = child.pid;
|
|
117
|
+
const signalGroup = options.signalGroup ?? ((target: number, signal: NodeJS.Signals | 0) => process.kill(-target, signal));
|
|
118
|
+
const signalLeader = (sig: NodeJS.Signals): void => {
|
|
119
|
+
if (child.exitCode !== null || child.signalCode !== null) return;
|
|
120
|
+
try { child.kill(sig); } catch { /* best effort only */ }
|
|
121
|
+
};
|
|
122
|
+
const unconfirmed = (): AgyAcpTreeCleanupError => {
|
|
123
|
+
const error = new AgyAcpTreeCleanupError(platform);
|
|
124
|
+
if (options.warnTreeFailure) options.warnTreeFailure();
|
|
125
|
+
else console.warn(error.message);
|
|
126
|
+
return error;
|
|
127
|
+
};
|
|
128
|
+
const leaderGone = child.exitCode !== null || child.signalCode !== null;
|
|
129
|
+
if (pid === undefined) return Promise.reject(unconfirmed());
|
|
130
|
+
|
|
131
|
+
if (platform === "win32") {
|
|
132
|
+
if (leaderGone) return Promise.reject(unconfirmed());
|
|
133
|
+
return new Promise<void>((resolve, reject) => {
|
|
134
|
+
let treeKilled = false;
|
|
135
|
+
let leaderClosed = false;
|
|
136
|
+
let settled = false;
|
|
137
|
+
const finish = (confirmed: boolean): void => {
|
|
138
|
+
if (settled) return;
|
|
139
|
+
settled = true;
|
|
140
|
+
clear(deadline);
|
|
141
|
+
if (confirmed) {
|
|
142
|
+
resolve();
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
const error = unconfirmed();
|
|
146
|
+
if (!leaderClosed) signalLeader("SIGKILL");
|
|
147
|
+
reject(error);
|
|
148
|
+
};
|
|
149
|
+
const deadline = set(() => finish(false), options.reapTimeoutMs);
|
|
150
|
+
child.once("close", () => {
|
|
151
|
+
leaderClosed = true;
|
|
152
|
+
if (treeKilled) finish(true);
|
|
153
|
+
});
|
|
154
|
+
try {
|
|
155
|
+
(options.killWindowsTree ?? defaultKillWindowsTree)(pid, ok => {
|
|
156
|
+
if (!ok) return finish(false);
|
|
157
|
+
treeKilled = true;
|
|
158
|
+
if (leaderClosed) finish(true);
|
|
159
|
+
});
|
|
160
|
+
} catch {
|
|
161
|
+
finish(false);
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const noSuchGroup = (error: unknown): boolean => (error as NodeJS.ErrnoException | undefined)?.code === "ESRCH";
|
|
167
|
+
return new Promise<void>((resolve, reject) => {
|
|
168
|
+
let leaderExited = leaderGone;
|
|
169
|
+
let groupSignalled = false;
|
|
170
|
+
let settled = false;
|
|
171
|
+
let pollTimer: ReturnType<typeof setTimeout> | undefined;
|
|
172
|
+
const finish = (confirmed: boolean): void => {
|
|
173
|
+
if (settled) return;
|
|
174
|
+
settled = true;
|
|
175
|
+
clear(grace);
|
|
176
|
+
clear(deadline);
|
|
177
|
+
if (pollTimer !== undefined) clear(pollTimer);
|
|
178
|
+
if (confirmed) {
|
|
179
|
+
resolve();
|
|
180
|
+
} else {
|
|
181
|
+
if (!leaderExited) signalLeader("SIGKILL");
|
|
182
|
+
reject(unconfirmed());
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
const pollGroup = (): void => {
|
|
187
|
+
try { signalGroup(pid, 0); } catch (error) { return finish(noSuchGroup(error)); }
|
|
188
|
+
pollTimer = set(pollGroup, GROUP_POLL_MS);
|
|
189
|
+
};
|
|
190
|
+
const killGroup = (): void => {
|
|
191
|
+
if (settled) return;
|
|
192
|
+
if (!groupSignalled) {
|
|
193
|
+
try { signalGroup(pid, "SIGKILL"); } catch (error) {
|
|
194
|
+
if (!noSuchGroup(error)) return finish(false);
|
|
195
|
+
}
|
|
196
|
+
groupSignalled = true;
|
|
197
|
+
}
|
|
198
|
+
if (leaderExited) pollGroup();
|
|
199
|
+
};
|
|
200
|
+
const onExit = (): void => {
|
|
201
|
+
if (leaderExited) return;
|
|
202
|
+
leaderExited = true;
|
|
203
|
+
clear(grace);
|
|
204
|
+
killGroup();
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
const grace = set(killGroup, options.graceMs);
|
|
208
|
+
const deadline = set(() => finish(false), options.reapTimeoutMs);
|
|
209
|
+
if (leaderExited) {
|
|
210
|
+
clear(grace);
|
|
211
|
+
killGroup();
|
|
212
|
+
} else {
|
|
213
|
+
child.once("exit", onExit);
|
|
214
|
+
child.once("close", onExit);
|
|
215
|
+
try { signalGroup(pid, "SIGTERM"); } catch { signalLeader("SIGTERM"); }
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
}
|
|
@@ -5,7 +5,10 @@ const MAX_USER_ID_BYTES = 4096;
|
|
|
5
5
|
type Rec = Record<string, unknown>;
|
|
6
6
|
const isRec = (value: unknown): value is Rec => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
7
7
|
|
|
8
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* Deterministic per-account 64-hex device_id so pooled accounts never share one client device_id.
|
|
10
|
+
* Organization slots of one Claude account share it: they are one person on one device.
|
|
11
|
+
*/
|
|
9
12
|
export function deriveAnthropicAccountDeviceId(accountUuid: string): string {
|
|
10
13
|
return createHash("sha256").update(`ocx-claude-code-device-v1:${accountUuid.trim().toLowerCase()}`, "utf8").digest("hex");
|
|
11
14
|
}
|
|
@@ -10,12 +10,28 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import { credentialDomainFor } from "../../protocols/opaque-state";
|
|
12
12
|
import type { OcxProviderConfig } from "../../types";
|
|
13
|
+
import type { AdapterRequest } from "../base";
|
|
13
14
|
|
|
14
15
|
type Rec = Record<string, unknown>;
|
|
15
16
|
|
|
16
17
|
export const ADVISOR_TOOL_BETA = "advisor-tool-2026-03-01";
|
|
17
18
|
export const ADVISOR_SERVER_TOOL_NAME = "advisor";
|
|
18
19
|
|
|
20
|
+
/** The serializer's admitted auth, before operator or plugin header rewrites. */
|
|
21
|
+
export const hostedAdvisorCredentials = new WeakMap<AdapterRequest, {
|
|
22
|
+
readonly header: "authorization" | "x-api-key";
|
|
23
|
+
readonly value: string;
|
|
24
|
+
}>();
|
|
25
|
+
|
|
26
|
+
/** Keep unrelated betas when a rewriter restores the withheld hosted Advisor beta. */
|
|
27
|
+
export function stripHostedAdvisorBeta(headers: Headers): void {
|
|
28
|
+
const betas = headers.get("anthropic-beta")?.split(",").map(beta => beta.trim());
|
|
29
|
+
if (!betas?.includes(ADVISOR_TOOL_BETA)) return;
|
|
30
|
+
const kept = betas.filter(beta => beta && beta !== ADVISOR_TOOL_BETA);
|
|
31
|
+
if (kept.length) headers.set("anthropic-beta", kept.join(","));
|
|
32
|
+
else headers.delete("anthropic-beta");
|
|
33
|
+
}
|
|
34
|
+
|
|
19
35
|
function isPlainRecord(value: unknown): value is Rec {
|
|
20
36
|
if (value === null || typeof value !== "object" || Array.isArray(value)) return false;
|
|
21
37
|
const prototype = Object.getPrototypeOf(value);
|
|
@@ -100,21 +116,39 @@ function runHasOtherServerTool(run: readonly Rec[]): boolean {
|
|
|
100
116
|
return run.some(block => block.type === "server_tool_use" && block.name !== ADVISOR_SERVER_TOOL_NAME);
|
|
101
117
|
}
|
|
102
118
|
|
|
103
|
-
|
|
104
|
-
* Withhold the caller's Advisor for a turn the proxy Advisor joins: its declaration and every
|
|
105
|
-
* replayed run that contains an Advisor call. The synthetic `advisor` owns the name for the whole
|
|
106
|
-
* turn, so a later leg that drops the synthetic tool (consultations exhausted) must not bring the
|
|
107
|
-
* history or the beta back and change the prompt mid-turn. Returns whether a declaration was withheld.
|
|
108
|
-
*/
|
|
109
|
-
export function withholdAdvisorServerTools(parsed: {
|
|
119
|
+
type AdvisorServerToolState = {
|
|
110
120
|
_anthropicServerTools?: readonly Rec[];
|
|
111
121
|
_anthropicServerReplay?: ReadonlyMap<string, readonly Rec[]>;
|
|
112
|
-
}
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
/** A declaration or completed replay can enable the hosted Advisor on this turn. */
|
|
125
|
+
export function hasAdvisorServerTools(parsed: AdvisorServerToolState): boolean {
|
|
126
|
+
if (hasAdvisorDeclaration(parsed._anthropicServerTools)) return true;
|
|
127
|
+
for (const run of parsed._anthropicServerReplay?.values() ?? []) {
|
|
128
|
+
if (runHasAdvisor(run)) return true;
|
|
129
|
+
}
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Withhold the caller's hosted Advisor: its declaration and its call/result blocks in validated
|
|
135
|
+
* replay runs. Keep other completed exchanges at their original anchor. Later legs must not
|
|
136
|
+
* restore Advisor history or beta, whether a ceiling withheld it or the proxy owns its name.
|
|
137
|
+
* Returns whether a declaration was withheld.
|
|
138
|
+
*/
|
|
139
|
+
export function withholdAdvisorServerTools(parsed: AdvisorServerToolState): boolean {
|
|
113
140
|
const declared = hasAdvisorDeclaration(parsed._anthropicServerTools);
|
|
114
141
|
if (declared) parsed._anthropicServerTools = parsed._anthropicServerTools!.filter(tool => !isAdvisorServerToolType(tool.type));
|
|
115
142
|
const replay = parsed._anthropicServerReplay;
|
|
116
143
|
if (replay && [...replay.values()].some(runHasAdvisor)) {
|
|
117
|
-
const kept = new Map
|
|
144
|
+
const kept = new Map<string, readonly Rec[]>();
|
|
145
|
+
for (const [anchor, run] of replay) {
|
|
146
|
+
// Validation pairs every call/result by ID, including interleaved exchanges. Removing
|
|
147
|
+
// both Advisor block types preserves the remaining complete pairs and their order.
|
|
148
|
+
const remaining = runHasAdvisor(run) ? run.filter(block => block.type !== "advisor_tool_result"
|
|
149
|
+
&& !(block.type === "server_tool_use" && block.name === ADVISOR_SERVER_TOOL_NAME)) : run;
|
|
150
|
+
if (remaining.length > 0) kept.set(anchor, remaining);
|
|
151
|
+
}
|
|
118
152
|
if (kept.size > 0) parsed._anthropicServerReplay = kept;
|
|
119
153
|
else delete parsed._anthropicServerReplay;
|
|
120
154
|
}
|
|
@@ -24,6 +24,8 @@ function valid(name: typeof NAMES[number], value: string): boolean {
|
|
|
24
24
|
if (name === "User-Agent") {
|
|
25
25
|
const entrypoint = interceptEntrypoint(value);
|
|
26
26
|
return entrypoint === "cli" || entrypoint === "sdk-cli" || entrypoint === "sdk" || entrypoint === "sdk-ts"
|
|
27
|
+
// First-party project children use a wire label independent of the host routing surface.
|
|
28
|
+
|| entrypoint === "local_projects"
|
|
27
29
|
|| (DESKTOP_ENTRYPOINTS as readonly string[]).includes(entrypoint ?? "");
|
|
28
30
|
}
|
|
29
31
|
if (name === "X-App") return CLAUDE_CODE_APPS.has(value);
|
|
@@ -22,6 +22,7 @@ import type {
|
|
|
22
22
|
} from "../types";
|
|
23
23
|
import { isAllowedToolChoice, namespacedToolName, resolveToolChoiceWireName } from "../types";
|
|
24
24
|
import { ANTHROPIC_OAUTH_BETA, CLAUDE_CODE_SYSTEM_INSTRUCTION, applyClaudeToolPrefix, stripClaudeToolPrefix } from "../oauth/anthropic";
|
|
25
|
+
import { sameProviderContinuationOwner } from "../responses/provider-continuation";
|
|
25
26
|
import { parseDataUrl } from "./image";
|
|
26
27
|
import { enforceAnthropicImageLimits } from "./anthropic-image-guard";
|
|
27
28
|
import { normalizeAnthropicImages } from "./anthropic-image-normalize";
|
|
@@ -41,7 +42,7 @@ import { resolveReasoningCapabilities } from "../providers/reasoning-capabilitie
|
|
|
41
42
|
import { declaresThinkingToggleWire, reasoningControlsAreUnsupported } from "./reasoning-controls";
|
|
42
43
|
import { applyAgentRouterLanguageFraming, isAgentRouterEndpoint } from "./agentrouter";
|
|
43
44
|
import { anthropicCacheWrite1hTokens, resolveAnthropicCacheRetention, type AnthropicCacheRetention } from "./anthropic/cache-retention";
|
|
44
|
-
import { advisorServerExchange, advisorServerToolDestination, planAnthropicServerTools } from "./anthropic/advisor-tool";
|
|
45
|
+
import { advisorServerExchange, advisorServerToolDestination, hostedAdvisorCredentials, planAnthropicServerTools } from "./anthropic/advisor-tool";
|
|
45
46
|
import { applyAnthropicPerMessageEffort } from "./anthropic/per-message-effort";
|
|
46
47
|
import { claudeFamilyVersion, rejectsCombinedSampling, rejectsForcedToolChoice, rejectsSamplingParameters, supportsExplicitThinkingDisable, usesAdaptiveThinking, usesBetweenToolsFloor } from "./anthropic-model-contract";
|
|
47
48
|
|
|
@@ -121,9 +122,47 @@ function applyCacheControlToLastText(blocks: Array<Record<string, unknown>>, cc:
|
|
|
121
122
|
applyCacheControlToLast(blocks, cc);
|
|
122
123
|
}
|
|
123
124
|
|
|
125
|
+
/** Mark the first text block, the head of a relocated caller system prefix. */
|
|
126
|
+
function applyCacheControlToLeadText(blocks: Array<Record<string, unknown>>, cc: CacheControl): void {
|
|
127
|
+
for (let i = 0; i < blocks.length; i++) {
|
|
128
|
+
if (blocks[i].type === "text") {
|
|
129
|
+
blocks[i] = { ...blocks[i], cache_control: cc };
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Prepend caller instructions without inserting text into a tool-result turn. Assistant-leading
|
|
137
|
+
* histories get a separate initial user turn, leaving existing call/result pairs adjacent.
|
|
138
|
+
*/
|
|
139
|
+
function prependTextToFirstUserMessage(messages: unknown[], texts: string[]): void {
|
|
140
|
+
const blocks = texts.map(text => ({ type: "text", text }));
|
|
141
|
+
const first = messages[0] as Record<string, unknown> | undefined;
|
|
142
|
+
if (!first || first.role !== "user") {
|
|
143
|
+
messages.unshift({ role: "user", content: blocks });
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
if (typeof first.content === "string") {
|
|
147
|
+
first.content = [...blocks, { type: "text", text: first.content }];
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
if (Array.isArray(first.content)) {
|
|
151
|
+
first.content = [...blocks, ...(first.content as unknown[])];
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
messages.unshift({ role: "user", content: blocks });
|
|
155
|
+
}
|
|
156
|
+
|
|
124
157
|
type PromptCachingOptions = {
|
|
125
158
|
maxExplicitBreakpoints?: number;
|
|
126
159
|
skipLastUser?: boolean;
|
|
160
|
+
/**
|
|
161
|
+
* The caller's system prompt travels as the head of the first user turn (OAuth). Cache that
|
|
162
|
+
* prefix instead of the single identity block in the top-level system array, so independent
|
|
163
|
+
* requests that share the caller prompt can reuse it.
|
|
164
|
+
*/
|
|
165
|
+
relocatedSystemPrefix?: boolean;
|
|
127
166
|
/** The last system block is the caller's uncached per-turn tail; mark the block before it. */
|
|
128
167
|
uncachedSystemTail?: boolean;
|
|
129
168
|
};
|
|
@@ -159,9 +198,17 @@ function applyPromptCaching(
|
|
|
159
198
|
}
|
|
160
199
|
if (used >= explicitLimit) return;
|
|
161
200
|
|
|
162
|
-
// 2. system
|
|
201
|
+
// 2. system, or the caller prefix relocated to the first user turn
|
|
163
202
|
const system = body.system as Array<Record<string, unknown>> | undefined;
|
|
164
|
-
|
|
203
|
+
const relocated = options.relocatedSystemPrefix === true ? messages?.[0] : undefined;
|
|
204
|
+
if (relocated !== undefined && relocated.role === "user") {
|
|
205
|
+
if (typeof relocated.content === "string") {
|
|
206
|
+
relocated.content = [{ type: "text", text: relocated.content, cache_control: cc }];
|
|
207
|
+
} else if (Array.isArray(relocated.content) && relocated.content.length > 0) {
|
|
208
|
+
applyCacheControlToLeadText(relocated.content as Array<Record<string, unknown>>, cc);
|
|
209
|
+
}
|
|
210
|
+
used++;
|
|
211
|
+
} else if (system && system.length > 0) {
|
|
165
212
|
const i = system.length - (options.uncachedSystemTail && system.length > 1 ? 2 : 1);
|
|
166
213
|
system[i] = { ...system[i], cache_control: cc };
|
|
167
214
|
used++;
|
|
@@ -566,11 +613,17 @@ export function anthropicBaseRequestHeaders(stream: boolean | undefined): Record
|
|
|
566
613
|
};
|
|
567
614
|
}
|
|
568
615
|
|
|
616
|
+
/** The configured credential used by the non-OAuth Messages serializer. */
|
|
617
|
+
export function anthropicApiKeyForRequest(provider: OcxProviderConfig): string | undefined {
|
|
618
|
+
return provider.authMode !== "oauth" && typeof provider.apiKey === "string" ? provider.apiKey : undefined;
|
|
619
|
+
}
|
|
620
|
+
|
|
569
621
|
/** Key-auth credential placement: `x-api-key`, or a bearer when the provider asks for one. */
|
|
570
622
|
export function applyAnthropicKeyAuth(headers: Record<string, string>, provider: OcxProviderConfig): void {
|
|
571
|
-
|
|
572
|
-
if (
|
|
573
|
-
|
|
623
|
+
const apiKey = anthropicApiKeyForRequest(provider);
|
|
624
|
+
if (apiKey === undefined) return;
|
|
625
|
+
if (anthropicKeyUsesBearer(provider)) headers["Authorization"] = `Bearer ${apiKey}`;
|
|
626
|
+
else headers["x-api-key"] = apiKey;
|
|
574
627
|
}
|
|
575
628
|
|
|
576
629
|
export function resolveTranslatedAnthropicSessionKey(parsed: OcxParsedRequest, incoming?: IncomingMeta): string | undefined {
|
|
@@ -764,7 +817,8 @@ function messagesToAnthropicFormat(
|
|
|
764
817
|
parsed: OcxParsedRequest,
|
|
765
818
|
toolNames: { toWire: (name: string) => string },
|
|
766
819
|
serverReplay?: ReadonlyMap<string, readonly Record<string, unknown>[]>,
|
|
767
|
-
|
|
820
|
+
relocateCallerSystem = false,
|
|
821
|
+
): { system: string[]; callerSystem: string[]; messages: unknown[] } {
|
|
768
822
|
// The client's server-tool exchanges go back ahead of the block they preceded. Their anchors are
|
|
769
823
|
// unique in the caller's history (replayedAnthropicServerBlocks drops repeated ones); each is used once.
|
|
770
824
|
const pendingReplay = new Map(serverReplay);
|
|
@@ -791,7 +845,17 @@ function messagesToAnthropicFormat(
|
|
|
791
845
|
undefined,
|
|
792
846
|
tool => toolNames.toWire(namespacedToolName(tool.namespace, tool.name)),
|
|
793
847
|
);
|
|
794
|
-
const
|
|
848
|
+
const { systemPrompt = [], proxySystemPrompt = [] } = parsed.context;
|
|
849
|
+
const promptParts = relocateCallerSystem && proxySystemPrompt.length > 0
|
|
850
|
+
? systemPrompt.flatMap((text, blockIndex) => {
|
|
851
|
+
const owned = proxySystemPrompt.find(part => part.blockIndex === blockIndex);
|
|
852
|
+
if (!owned) return [text];
|
|
853
|
+
const caller = text.slice(0, -owned.suffix.length);
|
|
854
|
+
return caller ? [caller] : [];
|
|
855
|
+
})
|
|
856
|
+
: systemPrompt;
|
|
857
|
+
const toolGuidance = toolCatalogNudge ? [toolCatalogNudge] : [];
|
|
858
|
+
const systemParts = relocateCallerSystem ? promptParts : [...promptParts, ...toolGuidance];
|
|
795
859
|
// End a block at the caller's cached prefix so its breakpoint skips the per-turn tail.
|
|
796
860
|
const prefix = parsed._anthropicSystemCachePrefix
|
|
797
861
|
? identifyRoutedModel(parsed._anthropicSystemCachePrefix, parsed.modelId) : undefined;
|
|
@@ -799,7 +863,12 @@ function messagesToAnthropicFormat(
|
|
|
799
863
|
const texts = prefix && head?.startsWith(`${prefix}\n\n`)
|
|
800
864
|
? [prefix, [head.slice(prefix.length + 2), ...systemParts.slice(1)].join("\n\n")]
|
|
801
865
|
: [systemParts.join("\n\n")];
|
|
802
|
-
const
|
|
866
|
+
const normalized = texts.map(text => identifyRoutedModel(text, parsed.modelId)).filter(Boolean);
|
|
867
|
+
const callerSystem = relocateCallerSystem ? normalized : [];
|
|
868
|
+
const system = relocateCallerSystem
|
|
869
|
+
? [...proxySystemPrompt.map(({ suffix }) => suffix.trimStart()), ...toolGuidance]
|
|
870
|
+
.map(text => identifyRoutedModel(text, parsed.modelId)).filter(Boolean)
|
|
871
|
+
: normalized;
|
|
803
872
|
const messages: unknown[] = [];
|
|
804
873
|
|
|
805
874
|
for (let i = 0; i < parsed.context.messages.length; i++) {
|
|
@@ -938,7 +1007,7 @@ function messagesToAnthropicFormat(
|
|
|
938
1007
|
messages.push({ role: "user", content: "(continue)" });
|
|
939
1008
|
}
|
|
940
1009
|
|
|
941
|
-
return { system, messages };
|
|
1010
|
+
return { system, callerSystem, messages };
|
|
942
1011
|
}
|
|
943
1012
|
|
|
944
1013
|
function toolsToAnthropicFormat(parsed: OcxParsedRequest, toolNames: { toWire: (name: string) => string }): unknown[] | undefined {
|
|
@@ -982,6 +1051,10 @@ export function createAnthropicAdapter(provider: OcxProviderConfig, cacheRetenti
|
|
|
982
1051
|
formatErrorBody: formatAnthropicErrorBody,
|
|
983
1052
|
|
|
984
1053
|
async buildRequest(parsed: OcxParsedRequest, incoming?: IncomingMeta) {
|
|
1054
|
+
if (parsed._anthropicImageOwner && (!parsed._providerContinuationOwner
|
|
1055
|
+
|| !sameProviderContinuationOwner(parsed._anthropicImageOwner, parsed._providerContinuationOwner))) {
|
|
1056
|
+
throw new Error("Anthropic image context no longer belongs to the selected account.");
|
|
1057
|
+
}
|
|
985
1058
|
if (typeof provider.apiKey !== "string" || provider.apiKey.trim() === "") {
|
|
986
1059
|
if (isOAuth) {
|
|
987
1060
|
throw new Error("anthropic oauth token missing — run ocx login anthropic");
|
|
@@ -993,8 +1066,8 @@ export function createAnthropicAdapter(provider: OcxProviderConfig, cacheRetenti
|
|
|
993
1066
|
// Advisor also reaches a gateway that opted in with forwardAdvisorTool (advisor-tool.ts).
|
|
994
1067
|
const serverToolPlan = planAnthropicServerTools(provider, parsed._anthropicServerTools, parsed._anthropicServerReplay,
|
|
995
1068
|
new Set(parsed.context.tools?.map(tool => tool.name)), usesNativeAnthropicEndpoint(provider));
|
|
996
|
-
const { system, messages } = messagesToAnthropicFormat(parsed, toolNames,
|
|
997
|
-
serverToolPlan.replay);
|
|
1069
|
+
const { system, callerSystem, messages } = messagesToAnthropicFormat(parsed, toolNames,
|
|
1070
|
+
serverToolPlan.replay, isOAuth && provider.anthropicOAuthUserInstructions === true && !parsed._proxyOwnedSystemPrompt);
|
|
998
1071
|
// Before image normalization, so the framing block is present for every downstream pass.
|
|
999
1072
|
if (isAgentRouterEndpoint(provider.baseUrl)) applyAgentRouterLanguageFraming(messages);
|
|
1000
1073
|
// Primary image layer: resize/re-encode to fit Anthropic limits without dropping
|
|
@@ -1026,12 +1099,20 @@ export function createAnthropicAdapter(provider: OcxProviderConfig, cacheRetenti
|
|
|
1026
1099
|
stream: parsed.stream,
|
|
1027
1100
|
max_tokens: parsed.options.maxOutputTokens ?? omittedMaxTokens,
|
|
1028
1101
|
};
|
|
1102
|
+
let relocatedCallerSystem = false;
|
|
1029
1103
|
if (isOAuth) {
|
|
1030
1104
|
// Claude OAuth (Pro/Max) requires the first system block to be the Claude Code identity.
|
|
1105
|
+
// A captured OpenCode request was rejected with caller instructions in top-level
|
|
1106
|
+
// system, but accepted with those instructions in user content. Proxy guidance keeps
|
|
1107
|
+
// system-role priority even when caller instructions move.
|
|
1031
1108
|
body.system = [
|
|
1032
1109
|
{ type: "text", text: CLAUDE_CODE_SYSTEM_INSTRUCTION },
|
|
1033
1110
|
...system.map(text => ({ type: "text", text })),
|
|
1034
1111
|
];
|
|
1112
|
+
if (callerSystem.length > 0) {
|
|
1113
|
+
prependTextToFirstUserMessage(messages, callerSystem);
|
|
1114
|
+
relocatedCallerSystem = true;
|
|
1115
|
+
}
|
|
1035
1116
|
} else if (system.length > 0) {
|
|
1036
1117
|
body.system = system.map(text => ({ type: "text", text }));
|
|
1037
1118
|
}
|
|
@@ -1157,7 +1238,7 @@ export function createAnthropicAdapter(provider: OcxProviderConfig, cacheRetenti
|
|
|
1157
1238
|
delete body.top_p;
|
|
1158
1239
|
}
|
|
1159
1240
|
|
|
1160
|
-
if (nativeOpus55 && !reasoningControlsUnsupported && thinkingEnabled !== false) {
|
|
1241
|
+
if (nativeOpus55 && !reasoningControlsUnsupported && thinkingEnabled !== false && !parsed._anthropicImageSummary) {
|
|
1161
1242
|
// An explicit per-request summary (concise/detailed) still forces summarized (#7881).
|
|
1162
1243
|
body.thinking = summaryRequested || thinkingDisplayPolicy === "summarized"
|
|
1163
1244
|
? { type: "adaptive", display: "summarized" }
|
|
@@ -1198,7 +1279,7 @@ export function createAnthropicAdapter(provider: OcxProviderConfig, cacheRetenti
|
|
|
1198
1279
|
else if (tc === "none") body.tool_choice = { type: "none" };
|
|
1199
1280
|
else if (tc === "required") body.tool_choice = { type: "any" };
|
|
1200
1281
|
else if (isAllowedToolChoice(tc)) body.tool_choice = { type: tc.mode === "required" ? "any" : "auto" };
|
|
1201
|
-
else if (typeof tc === "object" && "name" in tc) body.tool_choice = { type: "tool", name: toolNames.toWire(resolveToolChoiceWireName(parsed.context.tools, tc.name)) };
|
|
1282
|
+
else if (typeof tc === "object" && "name" in tc) body.tool_choice = { type: "tool", name: toolNames.toWire(resolveToolChoiceWireName(parsed.context.tools, tc.name, tc)) };
|
|
1202
1283
|
} else if (tools && parsed.options.parallelToolCalls === false) {
|
|
1203
1284
|
// The caller asked for one tool call at a time but sent no explicit choice.
|
|
1204
1285
|
// Anthropic carries that intent INSIDE tool_choice, so the implicit default
|
|
@@ -1243,6 +1324,11 @@ export function createAnthropicAdapter(provider: OcxProviderConfig, cacheRetenti
|
|
|
1243
1324
|
const headers = anthropicBaseRequestHeaders(parsed.stream);
|
|
1244
1325
|
if (isOAuth) applyAnthropicOAuthAuth(headers, provider.apiKey, resolveTranslatedAnthropicSessionKey(parsed, incoming));
|
|
1245
1326
|
else applyAnthropicKeyAuth(headers, provider);
|
|
1327
|
+
const advisorCredential = serverToolPlan.betas.length > 0
|
|
1328
|
+
? headers.Authorization !== undefined
|
|
1329
|
+
? { header: "authorization" as const, value: headers.Authorization }
|
|
1330
|
+
: { header: "x-api-key" as const, value: headers["x-api-key"]! }
|
|
1331
|
+
: undefined;
|
|
1246
1332
|
if (provider.headers) Object.assign(headers, provider.headers);
|
|
1247
1333
|
mergeAnthropicBetaHeader(headers, [...(fastSpeed?.betas ?? []), ...(progressUpdates ? ["thinking-display-updates-2026-08-18"] : []), ...serverToolPlan.betas]);
|
|
1248
1334
|
|
|
@@ -1255,6 +1341,7 @@ export function createAnthropicAdapter(provider: OcxProviderConfig, cacheRetenti
|
|
|
1255
1341
|
applyPromptCaching(body, cc, {
|
|
1256
1342
|
maxExplicitBreakpoints: explicitLimit,
|
|
1257
1343
|
skipLastUser: !!automaticPromptCaching,
|
|
1344
|
+
relocatedSystemPrefix: relocatedCallerSystem,
|
|
1258
1345
|
uncachedSystemTail: system.length > 1,
|
|
1259
1346
|
});
|
|
1260
1347
|
enforceCacheControlLimit(body, explicitLimit);
|
|
@@ -1277,6 +1364,7 @@ export function createAnthropicAdapter(provider: OcxProviderConfig, cacheRetenti
|
|
|
1277
1364
|
),
|
|
1278
1365
|
};
|
|
1279
1366
|
captureAnthropicRejectionPayloads(request, body, incoming?.translatorBudget);
|
|
1367
|
+
if (advisorCredential) hostedAdvisorCredentials.set(request, advisorCredential);
|
|
1280
1368
|
return request;
|
|
1281
1369
|
},
|
|
1282
1370
|
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { BOUNDED_BODY_MAX_BYTES } from "../lib/bounded-body";
|
|
3
3
|
import { registerProviderResponseProvenance } from "../providers/request-pacing";
|
|
4
4
|
import { parseUpstreamJsonPayload } from "./upstream-http-error";
|
|
5
|
+
import { ANTIGRAVITY_TOS_VIOLATION_PREFIX } from "./google-errors";
|
|
5
6
|
|
|
6
7
|
/** Trusted only at the original Google body boundary; never serialized or inferred from display text. */
|
|
7
8
|
const modelNotFoundResponses = new WeakMap<Response, true>();
|
|
@@ -30,7 +31,7 @@ export function markAntigravityModelNotFound(response: Response, requestBody: st
|
|
|
30
31
|
modelNotFoundResponses.set(response, true);
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
export type AntigravityRefusalKind = "verify_account" | "other";
|
|
34
|
+
export type AntigravityRefusalKind = "verify_account" | "tos_violation" | "other";
|
|
34
35
|
export interface AntigravityRefusal { kind: AntigravityRefusalKind }
|
|
35
36
|
|
|
36
37
|
const VERIFY_ACCOUNT_WORDS = [
|
|
@@ -51,6 +52,9 @@ export function classifyAntigravityRefusal(status: number, bodyText: string): An
|
|
|
51
52
|
if (status !== 403) return { kind: "other" };
|
|
52
53
|
if (Buffer.byteLength(bodyText, "utf8") > BOUNDED_BODY_MAX_BYTES)
|
|
53
54
|
return { kind: "other" };
|
|
55
|
+
// The suspension marker exists only when the Google adapter saw a typed TOS_VIOLATION body
|
|
56
|
+
// (google-errors.ts); it leads the normalized text, so upstream prose cannot produce it.
|
|
57
|
+
if (bodyText.startsWith(`${ANTIGRAVITY_TOS_VIOLATION_PREFIX}: `)) return { kind: "tos_violation" };
|
|
54
58
|
const lower = bodyText.toLowerCase();
|
|
55
59
|
if (VERIFY_ACCOUNT_WORDS.some(word => lower.includes(word))) return { kind: "verify_account" };
|
|
56
60
|
return { kind: "other" };
|
package/src/adapters/base.ts
CHANGED
|
@@ -8,6 +8,10 @@ import type { ProviderRequestSlot } from "../providers/request-pacing";
|
|
|
8
8
|
/** Metadata about the caller's incoming request, for auth-forwarding adapters. */
|
|
9
9
|
export interface IncomingMeta {
|
|
10
10
|
headers: Headers;
|
|
11
|
+
/** Client ingress transport, carried from the Responses bridge. */
|
|
12
|
+
inboundTransport?: "websocket";
|
|
13
|
+
/** Internal ACP refusal signal from the original HTTP turn. */
|
|
14
|
+
agyAcpUnattendedHttpTurn?: boolean;
|
|
11
15
|
/** Canonical routed provider identity for provider-specific wire fields. */
|
|
12
16
|
providerName?: string;
|
|
13
17
|
/** Trusted caller has durable structural replay ownership for earlier completed tools. */
|
|
@@ -20,14 +24,29 @@ export interface IncomingMeta {
|
|
|
20
24
|
dispatchPacingHeld?: boolean;
|
|
21
25
|
/** Combo children must surface a pre-output refusal so the selector can try the next target. */
|
|
22
26
|
comboAttempt?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Subagent fallback selected this route (request-prepare records the decision). A typed fact, never
|
|
29
|
+
* inferred from headers or models; the Antigravity ACP provider refuses such turns (plan 080).
|
|
30
|
+
*/
|
|
31
|
+
subagentFallback?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* A combo's internal decision call (JEV) dispatched this turn. Combo machinery, not a person; it is
|
|
34
|
+
* not a combo member, so it has its own fact. The Antigravity ACP provider refuses it (plan 080).
|
|
35
|
+
*/
|
|
36
|
+
internalDecisionCall?: boolean;
|
|
23
37
|
/**
|
|
24
38
|
* Provider-scoped fetch prepared by the Responses router. Stateful transports that emit more
|
|
25
39
|
* than one physical HTTP request per logical turn must reuse it so every request participates in
|
|
26
40
|
* the same pacing queue and custom provider fetch seam.
|
|
41
|
+
* Native sockets require explicit socket-route authority; HTTP transparency is insufficient.
|
|
27
42
|
*/
|
|
28
43
|
providerFetch?: typeof globalThis.fetch;
|
|
29
44
|
/** Synchronous selection fence for adapter-owned sends; call after async setup, before dispatch. */
|
|
30
45
|
beforePhysicalSend?: () => void;
|
|
46
|
+
/** Recheck credential authority without recording a physical dispatch. */
|
|
47
|
+
beforeCredentialSend?: () => void;
|
|
48
|
+
/** Router-owned receipt at the guarded provider executor's physical dispatch boundary. */
|
|
49
|
+
onGuardedDispatch?: () => void;
|
|
31
50
|
/**
|
|
32
51
|
* Image-normalization ladder bias for upstream-413 tightened retries: every image
|
|
33
52
|
* starts one tier lower (devlog/260714_image_normalization_pipeline/030). Consumed by
|
|
@@ -66,8 +85,9 @@ export interface ProviderAdapter {
|
|
|
66
85
|
name: string;
|
|
67
86
|
|
|
68
87
|
/**
|
|
69
|
-
* This adapter reports every physical inference send through
|
|
70
|
-
*
|
|
88
|
+
* This adapter reports every physical inference send, including its first, through
|
|
89
|
+
* `IncomingMeta.onPhysicalSend`. A `fetchResponse` adapter using its own executor can also
|
|
90
|
+
* opt in by calling `AdapterFetchContext.onPhysicalSend` after its final dispatch guards.
|
|
71
91
|
*
|
|
72
92
|
* The caller normally logs the first send before handing control over, which is correct for a
|
|
73
93
|
* transport whose sends it can see. An adapter that admits its own sends through the shared
|
|
@@ -77,6 +97,9 @@ export interface ProviderAdapter {
|
|
|
77
97
|
*/
|
|
78
98
|
reportsPhysicalSends?: boolean;
|
|
79
99
|
|
|
100
|
+
/** Upper bound on physical sends for one hosted-tool model iteration. */
|
|
101
|
+
hostedIterationSendLimit?: number;
|
|
102
|
+
|
|
80
103
|
/**
|
|
81
104
|
* Convert an already-read provider HTTP error into client-safe text. This hook must be pure and
|
|
82
105
|
* return fully redacted output: callers may pass untrusted provider headers and payload text.
|
|
@@ -184,6 +184,7 @@ export function withClaudeLoginHint(emit: (event: AdapterEvent) => void): (event
|
|
|
184
184
|
export function createClaudeCliAdapter(provider: OcxProviderConfig, deps: ClaudeCliAdapterDeps = {}): ProviderAdapter {
|
|
185
185
|
return {
|
|
186
186
|
name: "claude-cli",
|
|
187
|
+
reportsPhysicalSends: true,
|
|
187
188
|
|
|
188
189
|
buildRequest(): AdapterRequest {
|
|
189
190
|
return { url: provider.baseUrl, method: "POST", headers: {}, body: "" };
|