@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,108 @@
|
|
|
1
|
+
import { readdirSync } from "node:fs";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { isPendingTeardownAbandoned, isValidPendingTeardownReceipt, type OutstandingTeardown, type PendingTeardownReceipt } from "../config/pending-teardown";
|
|
5
|
+
import { isAnyTeardownObligationFileName, pendingTeardownNonceFromFileName } from "../config/pending-teardown-names.mjs";
|
|
6
|
+
import { getConfigDir } from "../config/paths";
|
|
7
|
+
import { isLikelyOcxProcess, type ClientStopOwner, type RuntimePortState } from "../config/process-state";
|
|
8
|
+
import { readBoundedRegularFileSync } from "../lib/bounded-file-read";
|
|
9
|
+
import { isProcessAlive } from "../lib/process-control";
|
|
10
|
+
import { readSyncRuntime } from "./sync-runtime";
|
|
11
|
+
import { observeClientStopOwner, readClientStopProcessStart, type ClientStopOwnerStatus } from "./stop-teardown-owner";
|
|
12
|
+
|
|
13
|
+
export type LinkStopRuntime = Required<Pick<RuntimePortState, "pid" | "port" | "attestationSecret">>;
|
|
14
|
+
export type NativeTeardownDecision = "restore" | "defer" | "refuse";
|
|
15
|
+
const host = (value: string) => value.trim().toLowerCase().replace(/^\[(.*)\]$/, "$1");
|
|
16
|
+
|
|
17
|
+
type TeardownSnapshot = { state: "valid"; path: string; bytes: Buffer; receipt: PendingTeardownReceipt };
|
|
18
|
+
export type LinkInheritedTeardown = OutstandingTeardown & { bytes?: Buffer };
|
|
19
|
+
|
|
20
|
+
type NativeTeardownEvidence =
|
|
21
|
+
| TeardownSnapshot
|
|
22
|
+
| { state: "invalid"; nonce: string; detail: string }
|
|
23
|
+
| { state: "quarantined" }
|
|
24
|
+
| { state: "unscannable"; detail: string };
|
|
25
|
+
|
|
26
|
+
/** The signal and parent preflight use the same bounded, no-follow disk evidence. */
|
|
27
|
+
export function readLinkNativeTeardownEvidence(): NativeTeardownEvidence[] {
|
|
28
|
+
let names: string[];
|
|
29
|
+
try { names = readdirSync(getConfigDir()).filter(isAnyTeardownObligationFileName); }
|
|
30
|
+
catch (error) { return (error as NodeJS.ErrnoException).code === "ENOENT" ? [] : [{ state: "unscannable", detail: "the opencodex home could not be listed" }]; }
|
|
31
|
+
return names.map(name => {
|
|
32
|
+
const nonce = pendingTeardownNonceFromFileName(name);
|
|
33
|
+
if (!nonce) return { state: "quarantined" };
|
|
34
|
+
try {
|
|
35
|
+
const path = join(getConfigDir(), name);
|
|
36
|
+
const bytes = readBoundedRegularFileSync(path, 4 * 1024);
|
|
37
|
+
const receipt: unknown = JSON.parse(bytes.toString("utf8"));
|
|
38
|
+
return isValidPendingTeardownReceipt(receipt, nonce) ? { state: "valid", path, bytes, receipt } : { state: "invalid", nonce, detail: "malformed receipt" };
|
|
39
|
+
} catch { return { state: "invalid", nonce, detail: "receipt is not bounded regular JSON" }; }
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Bind the original JSON bytes, which include each receipt's filename nonce. */
|
|
44
|
+
export function inheritedTeardownDigest(snapshots: readonly Buffer[]): string | undefined {
|
|
45
|
+
if (snapshots.length === 0) return;
|
|
46
|
+
const hash = createHash("sha256");
|
|
47
|
+
for (const bytes of [...snapshots].sort(Buffer.compare)) {
|
|
48
|
+
hash.update(bytes).update("\0");
|
|
49
|
+
}
|
|
50
|
+
return hash.digest("hex");
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Preserve the parent's recovery ownership rules and use one snapshot before/after stop. */
|
|
54
|
+
export function readLinkInheritedTeardowns(): LinkInheritedTeardown[] {
|
|
55
|
+
// Multiple valid receipts can name the same stop incarnation. Their nonce is
|
|
56
|
+
// validated against the filename above and does not change what the OS can prove.
|
|
57
|
+
const owners = new Map<string, ClientStopOwnerStatus>();
|
|
58
|
+
return readLinkNativeTeardownEvidence().flatMap<LinkInheritedTeardown>(read => {
|
|
59
|
+
if (read.state === "quarantined") return [];
|
|
60
|
+
if (read.state === "valid" && read.receipt.ownerStartTime) {
|
|
61
|
+
const { ownerPid: pid, ownerStartTime: startTime, nonce } = read.receipt;
|
|
62
|
+
const key = `${pid}:${startTime}`;
|
|
63
|
+
let status = owners.get(key);
|
|
64
|
+
if (status === undefined) {
|
|
65
|
+
status = pid === process.pid && readClientStopProcessStart(pid) === startTime
|
|
66
|
+
? "active" : observeClientStopOwner({ pid, startTime, nonce });
|
|
67
|
+
owners.set(key, status);
|
|
68
|
+
}
|
|
69
|
+
if (status === "active") return [];
|
|
70
|
+
if (status === "unverified") return [{ state: "unscannable", detail: "the pending-teardown receipt's stop owner could not be verified" }];
|
|
71
|
+
return [read];
|
|
72
|
+
}
|
|
73
|
+
return isPendingTeardownAbandoned(read, pid => isProcessAlive(pid) && isLikelyOcxProcess(pid)) ? [read] : [];
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Before a receipt is issued, the bound owner already excludes concurrent recycle. */
|
|
78
|
+
function activeClientStopOwner(runtime: RuntimePortState): ClientStopOwner | undefined {
|
|
79
|
+
const owner = runtime.clientStopOwner;
|
|
80
|
+
if (runtime.clientStopping && runtime.clientStopRequested && owner && observeClientStopOwner(owner) === "active") return owner;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Receipts alone never release a socket still named by native loopback routing. */
|
|
84
|
+
export function linkNativeTeardownDecision(expected?: LinkStopRuntime): NativeTeardownDecision {
|
|
85
|
+
const evidence = readLinkNativeTeardownEvidence();
|
|
86
|
+
if (evidence.length === 0) return "restore";
|
|
87
|
+
try {
|
|
88
|
+
const runtime = readSyncRuntime();
|
|
89
|
+
if (!expected || expected.pid !== process.pid || !runtime || runtime.pid !== expected.pid
|
|
90
|
+
|| runtime.port !== expected.port || runtime.attestationSecret !== expected.attestationSecret
|
|
91
|
+
|| host(runtime.hostname ?? "127.0.0.1") !== "127.0.0.1"
|
|
92
|
+
|| runtime.clientStopping !== true || runtime.clientStopRequested !== true) return "refuse";
|
|
93
|
+
// A malformed/guessed inherited obligation blocks the parent's restore too.
|
|
94
|
+
if (evidence.some(read => read.state === "invalid" || read.state === "unscannable"
|
|
95
|
+
|| read.state === "valid" && read.receipt.endpointSource !== "exact")) return "refuse";
|
|
96
|
+
const sameEndpoint = (read: TeardownSnapshot) =>
|
|
97
|
+
read.receipt.endpoint.port === expected.port && host(read.receipt.endpoint.hostname) === "127.0.0.1";
|
|
98
|
+
const owner = activeClientStopOwner(runtime);
|
|
99
|
+
const claim = owner && evidence.find(read => read.state === "valid" && sameEndpoint(read)
|
|
100
|
+
&& read.receipt.nonce === owner.nonce && read.receipt.ownerPid === owner.pid
|
|
101
|
+
&& read.receipt.ownerStartTime === owner.startTime);
|
|
102
|
+
const foreign = evidence.flatMap(read => read.state === "valid" && !sameEndpoint(read) ? [read.bytes] : []);
|
|
103
|
+
if (claim?.state === "valid" && inheritedTeardownDigest(foreign) === claim.receipt.inheritedTeardownDigest
|
|
104
|
+
&& readBoundedRegularFileSync(claim.path, 4 * 1024).equals(claim.bytes)
|
|
105
|
+
&& Bun.deepEquals(readSyncRuntime(), runtime, true)) return "defer";
|
|
106
|
+
} catch { /* unreadable or replaced runtime evidence is not an active parent */ }
|
|
107
|
+
return "refuse";
|
|
108
|
+
}
|
|
@@ -6,14 +6,15 @@ import { journalOwner, JOURNAL_PATH } from "../codex/journal";
|
|
|
6
6
|
import { CODEX_CONFIG_PATH } from "../codex/paths";
|
|
7
7
|
import { siblingOfLivePort, siblingSkipMessage } from "../codex/sibling-start";
|
|
8
8
|
import type { OcxClientConnectionConfig } from "../types";
|
|
9
|
-
import { pendingTeardownOutstanding } from "../config/pending-teardown";
|
|
10
9
|
import { stripGrokConfig } from "../grok/inject";
|
|
11
10
|
import { isDesktopSupervised } from "../lib/system-restart-contract";
|
|
12
11
|
import { serviceEnvironmentOwnedHere } from "../service/guards";
|
|
13
12
|
import { stopRestoreWriteGuard } from "./restore-ownership";
|
|
14
13
|
import { isLinkConnection } from "./state";
|
|
14
|
+
import { linkNativeTeardownDecision, type LinkStopRuntime } from "./stop-native-handoff";
|
|
15
15
|
|
|
16
|
-
export type LinkRoutingRestoreResult = { success: boolean; restored: boolean; message: string };
|
|
16
|
+
export type LinkRoutingRestoreResult = { success: boolean; restored: boolean; message: string; retainListener?: true };
|
|
17
|
+
type LinkRoutingRestoreOptions = { syncFenced: boolean; runtime?: LinkStopRuntime };
|
|
17
18
|
|
|
18
19
|
const resumeGuidance = "After starting the Child again, run `ocx sync --restart-codex` to restore its Home routing.";
|
|
19
20
|
const refusal = (reason: string): LinkRoutingRestoreResult => ({
|
|
@@ -21,19 +22,52 @@ const refusal = (reason: string): LinkRoutingRestoreResult => ({
|
|
|
21
22
|
message: `Link Child Codex routing restore refused: ${reason}. No further writes; inspect remaining recovery evidence.`,
|
|
22
23
|
});
|
|
23
24
|
|
|
25
|
+
function preserveSupervisedRouting(): boolean {
|
|
26
|
+
return process.env.OCX_SERVICE === "1" || isDesktopSupervised();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Await file writers before releasing the socket, retaining it when safe cleanup is refused. */
|
|
30
|
+
export async function restoreLinkClientRoutingBeforeExit(
|
|
31
|
+
expected: OcxClientConnectionConfig, options: LinkRoutingRestoreOptions,
|
|
32
|
+
): Promise<LinkRoutingRestoreResult> {
|
|
33
|
+
expected = structuredClone(expected);
|
|
34
|
+
options = { ...options, ...(options.runtime ? { runtime: { ...options.runtime } } : {}) };
|
|
35
|
+
const retainOnRefusal = (result: LinkRoutingRestoreResult): LinkRoutingRestoreResult => result.success ? result : {
|
|
36
|
+
...result, retainListener: true,
|
|
37
|
+
message: `${result.message} The listener remains bound; repair the reported evidence, then retry ocx stop.`,
|
|
38
|
+
};
|
|
39
|
+
// A parent receipt defers native Codex/Grok only. It never proves that a live owner
|
|
40
|
+
// will remove Link file routes before this socket closes, even when the receipt is valid.
|
|
41
|
+
if (siblingOfLivePort() !== null || !isLinkConnection(expected) || preserveSupervisedRouting()) {
|
|
42
|
+
return retainOnRefusal(restoreLinkClientRouting(expected, options));
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
const { restoreLinkFileRouting } = await import("./stop-file-routing");
|
|
46
|
+
if (!options.syncFenced) throw new Error("the runtime sync fence could not be verified");
|
|
47
|
+
await restoreLinkFileRouting(expected, { beforeWrite: () => {
|
|
48
|
+
if (preserveSupervisedRouting() || siblingOfLivePort() !== null) throw new Error("restart or teardown ownership changed");
|
|
49
|
+
} });
|
|
50
|
+
} catch (error) {
|
|
51
|
+
return { success: false, restored: false, retainListener: true,
|
|
52
|
+
message: `Link Child file routing restore refused: ${error instanceof Error ? error.message : "restoration failed"}. The listener remains bound; repair the client configuration or ownership evidence, then retry ocx stop.` };
|
|
53
|
+
}
|
|
54
|
+
return retainOnRefusal(restoreLinkClientRouting(expected, options));
|
|
55
|
+
}
|
|
56
|
+
|
|
24
57
|
/** Unsupervised signal cleanup; explicit parent stop and restart retain their own restoration. */
|
|
25
|
-
export function restoreLinkClientRouting(expected: OcxClientConnectionConfig, options:
|
|
58
|
+
export function restoreLinkClientRouting(expected: OcxClientConnectionConfig, options: LinkRoutingRestoreOptions): LinkRoutingRestoreResult {
|
|
26
59
|
if (siblingOfLivePort() !== null) return { success: true, restored: false, message: siblingSkipMessage() };
|
|
27
60
|
if (!isLinkConnection(expected)) {
|
|
28
61
|
return { success: true, restored: false, message: "Hub connection-owned integrations preserved." };
|
|
29
62
|
}
|
|
30
|
-
|
|
31
|
-
|| pendingTeardownOutstanding();
|
|
32
|
-
if (preserve()) return { success: true, restored: false, message: "Supervised restart or pending teardown owns the client integrations." };
|
|
63
|
+
if (preserveSupervisedRouting()) return { success: true, restored: false, message: "Supervised restart owns native Codex and managed Grok restoration." };
|
|
33
64
|
if (options?.syncFenced !== true) return refusal("the runtime sync fence could not be verified");
|
|
65
|
+
const nativeTeardown = linkNativeTeardownDecision(options.runtime);
|
|
66
|
+
if (nativeTeardown === "defer") return { success: true, restored: false, message: "The active parent stop owns native Codex and managed Grok restoration." };
|
|
67
|
+
if (nativeTeardown === "refuse") return refusal("pending native teardown has no verified active parent stop");
|
|
34
68
|
const guard = stopRestoreWriteGuard(expected);
|
|
35
69
|
const withWriteGuard = <T>(write: () => T): T => guard.run(() => {
|
|
36
|
-
if (
|
|
70
|
+
if (preserveSupervisedRouting() || linkNativeTeardownDecision(options.runtime) !== "restore") throw new Error("restart or teardown ownership changed");
|
|
37
71
|
const owner = journalOwner({ readOnly: true });
|
|
38
72
|
if (existsSync(JOURNAL_PATH) && (owner?.kind !== "client" || owner.apiKeyId !== expected.apiKeyId)) {
|
|
39
73
|
throw new Error("the Codex journal belongs to another owner or is unverified");
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
2
|
+
import { readlinkSync, statSync } from "node:fs";
|
|
3
|
+
import { isAbsolute, join, resolve } from "node:path";
|
|
4
|
+
import { NODE_LAUNCH_PROOF_PREFIX } from "../cli/launcher-context";
|
|
5
|
+
import { parseStopApproval } from "../cli/stop-approval";
|
|
6
|
+
import { tokenizeCommandLine } from "../codex/app-server-processes";
|
|
7
|
+
import { readProcessCommandLine, type ClientStopOwner } from "../config/process-state";
|
|
8
|
+
import { readBoundedRegularFileSync } from "../lib/bounded-file-read";
|
|
9
|
+
import { resolveTrustedWindowsPowerShellExe } from "../lib/windows-elevation";
|
|
10
|
+
import { windowsProcessNative, windowsProcessPlatform, windowsProcessPlatformSimulated } from "../service/windows-process-native";
|
|
11
|
+
import { readDarwinStopArgv, readDarwinStopCwd, readDarwinStopEnvironment, readDarwinStopStart } from "./stop-darwin-process";
|
|
12
|
+
|
|
13
|
+
const basename = (value: string) => value.toLowerCase().replace(/\\/g, "/").split("/").pop() ?? "";
|
|
14
|
+
|
|
15
|
+
/** Recognize the invocation that sets the native Child's explicit-stop fence, not any ocx. */
|
|
16
|
+
export function isClientStopCommandLine(commandLine: string): boolean {
|
|
17
|
+
if (commandLine.length > 64 * 1024) return false;
|
|
18
|
+
return isClientStopArgv(tokenizeCommandLine(commandLine));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function isClientStopArgv(argv: readonly string[]): boolean {
|
|
22
|
+
const command = ocxCommandIndex(argv);
|
|
23
|
+
return command !== undefined && argv[command] === "stop" && parseStopApproval(argv.slice(command + 1)).ok;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function isLegacyWindowsStartCommandLine(commandLine: string): boolean {
|
|
27
|
+
if (commandLine.length > 64 * 1024) return false;
|
|
28
|
+
const argv = tokenizeCommandLine(commandLine);
|
|
29
|
+
const command = ocxCommandIndex(argv);
|
|
30
|
+
return command !== undefined && argv[command] === "start";
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function ocxCommandIndex(argv: readonly string[]): number | undefined {
|
|
34
|
+
let next = 1;
|
|
35
|
+
if (/^bun(?:\.exe)?$/.test(basename(argv[0] ?? ""))) {
|
|
36
|
+
if (argv[next] === "run") next++;
|
|
37
|
+
const script = argv[next++]?.replace(/\\/g, "/");
|
|
38
|
+
if (!script || !/(?:^|\/)src\/cli(?:\/index)?\.ts$/i.test(script)) return;
|
|
39
|
+
} else if (!/^(?:ocx|opencodex)(?:\.exe)?$/.test(basename(argv[0] ?? ""))) return;
|
|
40
|
+
// npm inserts this one token before the command. Its spelling is not proof of
|
|
41
|
+
// launcher trust; the current runtime fence and same-user live owner are separate.
|
|
42
|
+
if (argv[next]?.startsWith(NODE_LAUNCH_PROOF_PREFIX)) {
|
|
43
|
+
if (!/^[A-Za-z0-9_-]{43}$/.test(argv[next]!.slice(NODE_LAUNCH_PROOF_PREFIX.length))) return;
|
|
44
|
+
next++;
|
|
45
|
+
}
|
|
46
|
+
return next;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Creation identity and same-user ownership, sampled freshly for each destructive boundary. */
|
|
50
|
+
export function readClientStopProcessStart(pid: number): string | undefined {
|
|
51
|
+
if (!Number.isInteger(pid) || pid <= 0 || pid > 0x7fffffff) return;
|
|
52
|
+
try {
|
|
53
|
+
const platform = windowsProcessPlatform();
|
|
54
|
+
if (platform === "darwin") return readDarwinStopStart(pid);
|
|
55
|
+
if (platform === "linux") {
|
|
56
|
+
const dir = `/proc/${pid}`;
|
|
57
|
+
if (statSync(dir).uid !== process.geteuid?.()) return;
|
|
58
|
+
const stat = readBoundedRegularFileSync(`${dir}/stat`, 4096).toString();
|
|
59
|
+
const end = stat.lastIndexOf(") ");
|
|
60
|
+
const ticks = end < 0 ? undefined : stat.slice(end + 2).trim().split(/\s+/)[19];
|
|
61
|
+
const boot = readBoundedRegularFileSync("/proc/sys/kernel/random/boot_id", 64).toString().trim();
|
|
62
|
+
if (ticks && /^\d+$/.test(ticks) && /^[a-f0-9-]{36}$/.test(boot)) return `linux:${boot}:${ticks}`;
|
|
63
|
+
}
|
|
64
|
+
if (platform === "win32") {
|
|
65
|
+
const native = windowsProcessNative();
|
|
66
|
+
if (native) {
|
|
67
|
+
const identity = native.sameUserIdentity(pid);
|
|
68
|
+
return identity ? `win32:${identity.ticks}` : undefined;
|
|
69
|
+
}
|
|
70
|
+
if (windowsProcessPlatformSimulated()) return;
|
|
71
|
+
// The fallback also binds the SID to this incarnation by refreshing CreationDate.
|
|
72
|
+
const script = `$ErrorActionPreference='Stop'; $p=Get-CimInstance Win32_Process -Filter "ProcessId=${pid}"; $owner=Invoke-CimMethod -InputObject $p -MethodName GetOwnerSid; if ($owner.ReturnValue -eq 0 -and $owner.Sid -eq [System.Security.Principal.WindowsIdentity]::GetCurrent().User.Value -and $p.CreationDate) { $after=Get-CimInstance -InputObject $p; if ($after.CreationDate -eq $p.CreationDate) { $p.CreationDate.ToUniversalTime().Ticks } }`;
|
|
73
|
+
const ticks = execFileSync(resolveTrustedWindowsPowerShellExe(), ["-NoProfile", "-NoLogo", "-NonInteractive", "-Command", script], {
|
|
74
|
+
encoding: "utf8", stdio: ["ignore", "pipe", "ignore"], timeout: 3000, maxBuffer: 1024, windowsHide: true,
|
|
75
|
+
}).trim();
|
|
76
|
+
if (/^\d{1,20}$/.test(ticks)) return `win32:${ticks}`;
|
|
77
|
+
}
|
|
78
|
+
} catch { /* unreadable ownership cannot authorize a native restoration handoff */ }
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Read only the home settings needed to bind a legacy record to its invoking process. */
|
|
82
|
+
export function readLegacyStopProcessHome(pid: number): string | undefined {
|
|
83
|
+
try {
|
|
84
|
+
const environment = process.platform === "linux" ? readBoundedRegularFileSync(`/proc/${pid}/environ`, 1024 * 1024)
|
|
85
|
+
: process.platform === "darwin" ? readDarwinStopEnvironment(pid) : undefined;
|
|
86
|
+
if (!environment?.length || environment[environment.length - 1] !== 0) return;
|
|
87
|
+
const setting = (name: string) => {
|
|
88
|
+
const prefix = Buffer.from(`${name}=`);
|
|
89
|
+
for (let offset = 0; offset < environment.length;) {
|
|
90
|
+
const end = environment.indexOf(0, offset);
|
|
91
|
+
if (end < 0) break;
|
|
92
|
+
if (offset + prefix.length <= end && environment.subarray(offset, offset + prefix.length).equals(prefix)) {
|
|
93
|
+
return new TextDecoder("utf-8", { fatal: true }).decode(environment.subarray(offset + prefix.length, end)).trim();
|
|
94
|
+
}
|
|
95
|
+
offset = end + 1;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
const override = setting("OPENCODEX_HOME");
|
|
99
|
+
if (override && isAbsolute(override)) return resolve(override);
|
|
100
|
+
if (override && override !== "~" && !override.startsWith("~/") && !override.startsWith("~\\")) {
|
|
101
|
+
const cwd = process.platform === "linux"
|
|
102
|
+
? new TextDecoder("utf-8", { fatal: true }).decode(readlinkSync(`/proc/${pid}/cwd`, { encoding: "buffer" }))
|
|
103
|
+
: readDarwinStopCwd(pid);
|
|
104
|
+
// procfs appends this marker when the working directory has been removed.
|
|
105
|
+
if (cwd && isAbsolute(cwd) && !(process.platform === "linux" && cwd.endsWith(" (deleted)"))) return resolve(cwd, override);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const home = setting("HOME");
|
|
109
|
+
if (!home || !isAbsolute(home)) return;
|
|
110
|
+
if (!override) return join(home, ".opencodex");
|
|
111
|
+
return override === "~" ? resolve(home) : join(home, override.slice(2));
|
|
112
|
+
} catch { /* An unreadable home cannot bind a legacy record. */ }
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export type ClientStopOwnerStatus = "active" | "confirmed-stale" | "unverified";
|
|
116
|
+
|
|
117
|
+
const creationIdentity: Partial<Record<NodeJS.Platform, RegExp>> = {
|
|
118
|
+
darwin: /^darwin:([1-9]\d{0,19}):(?:0|[1-9]\d{0,5})$/,
|
|
119
|
+
linux: /^linux:[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}:(0|[1-9]\d{0,19})$/,
|
|
120
|
+
win32: /^win32:([1-9]\d{0,18})$/,
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
function validCreationIdentity(value: unknown): boolean {
|
|
124
|
+
if (typeof value !== "string" || value.length > 80) return false;
|
|
125
|
+
const platform = windowsProcessPlatform();
|
|
126
|
+
const ticks = creationIdentity[platform]?.exec(value)?.[1];
|
|
127
|
+
return ticks !== undefined && BigInt(ticks) <= (platform === "win32" ? 3155378975999999999n : 0xffffffffffffffffn);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** Bind argv to the creation identity so a recycled PID cannot inherit the fence. */
|
|
131
|
+
export function observeClientStopOwner({ pid, startTime, nonce }: ClientStopOwner): ClientStopOwnerStatus {
|
|
132
|
+
if (!Number.isInteger(pid) || pid <= 0 || pid > 0x7fffffff
|
|
133
|
+
|| !validCreationIdentity(startTime)
|
|
134
|
+
|| typeof nonce !== "string" || !/^[a-f0-9]{32}$/.test(nonce)) return "unverified";
|
|
135
|
+
try { process.kill(pid, 0); }
|
|
136
|
+
catch (error) { return (error as NodeJS.ErrnoException).code === "ESRCH" ? "confirmed-stale" : "unverified"; }
|
|
137
|
+
const native = windowsProcessPlatform() === "win32" ? windowsProcessNative() : null;
|
|
138
|
+
if (native) {
|
|
139
|
+
try {
|
|
140
|
+
const identity = native.sameUserIdentity(pid, true);
|
|
141
|
+
if (!identity) return "unverified";
|
|
142
|
+
if (`win32:${identity.ticks}` !== startTime) return "confirmed-stale";
|
|
143
|
+
return pid !== process.pid && identity.commandLine && isClientStopCommandLine(identity.commandLine) ? "active" : "unverified";
|
|
144
|
+
} catch { return "unverified"; }
|
|
145
|
+
}
|
|
146
|
+
// Without a process handle for argv, bracket the read with verified creation identities.
|
|
147
|
+
const before = readClientStopProcessStart(pid);
|
|
148
|
+
if (before === undefined) return "unverified";
|
|
149
|
+
if (before !== startTime) return "confirmed-stale";
|
|
150
|
+
if (pid === process.pid) return "unverified";
|
|
151
|
+
try {
|
|
152
|
+
let stop: boolean;
|
|
153
|
+
if (process.platform === "linux") {
|
|
154
|
+
// /proc exposes argv, not a quoted command line. Preserve NUL boundaries:
|
|
155
|
+
// install paths and approval values can legitimately contain spaces.
|
|
156
|
+
const raw = new TextDecoder("utf8", { fatal: true }).decode(readBoundedRegularFileSync(`/proc/${pid}/cmdline`, 64 * 1024));
|
|
157
|
+
if (raw.length <= 1 || !raw.endsWith("\0")) return "unverified";
|
|
158
|
+
stop = isClientStopArgv(raw.slice(0, -1).split("\0"));
|
|
159
|
+
} else if (process.platform === "darwin") {
|
|
160
|
+
const argv = readDarwinStopArgv(pid);
|
|
161
|
+
if (!argv?.length) return "unverified";
|
|
162
|
+
stop = isClientStopArgv(argv);
|
|
163
|
+
} else {
|
|
164
|
+
const commandLine = readProcessCommandLine(pid);
|
|
165
|
+
if (!commandLine?.trim() || commandLine.length > 64 * 1024) return "unverified";
|
|
166
|
+
stop = isClientStopCommandLine(commandLine);
|
|
167
|
+
}
|
|
168
|
+
const after = readClientStopProcessStart(pid);
|
|
169
|
+
if (after === undefined) return "unverified";
|
|
170
|
+
if (after !== startTime) return "confirmed-stale";
|
|
171
|
+
return stop ? "active" : "unverified";
|
|
172
|
+
} catch { return "unverified"; }
|
|
173
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** Cross-process admission for Link sync while its local runtime shuts down. */
|
|
2
2
|
import { lstatSync } from "node:fs";
|
|
3
3
|
import { ConfigMutationLockError, withConfigMutationLockSync } from "../config";
|
|
4
|
-
import { getRuntimePortPath, isValidRuntimePortState, writeRuntimePort, type RuntimePortState } from "../config/process-state";
|
|
4
|
+
import { getRuntimePortPath, isValidRuntimePortState, writeRuntimePort, type ClientStopOwner, type RuntimePortState } from "../config/process-state";
|
|
5
5
|
import { readBoundedRegularFileSync } from "../lib/bounded-file-read";
|
|
6
6
|
|
|
7
7
|
export class ClientSyncRuntimeError extends Error {
|
|
@@ -10,7 +10,7 @@ export class ClientSyncRuntimeError extends Error {
|
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
function readSyncRuntime(): RuntimePortState | null {
|
|
13
|
+
export function readSyncRuntime(): RuntimePortState | null {
|
|
14
14
|
const path = getRuntimePortPath();
|
|
15
15
|
try { lstatSync(path); }
|
|
16
16
|
catch (error) {
|
|
@@ -43,14 +43,33 @@ export function assertRouteIntentPort(port: number): void {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
/** The same C transaction excludes every sync commit; never mark a replacement runtime. */
|
|
46
|
-
export function markClientRuntimeStopping(
|
|
46
|
+
export function markClientRuntimeStopping(
|
|
47
|
+
expected: Required<Pick<RuntimePortState, "pid" | "port" | "attestationSecret">>, stopOwner?: ClientStopOwner,
|
|
48
|
+
): void {
|
|
47
49
|
withConfigMutationLockSync(() => {
|
|
48
50
|
const current = readSyncRuntime();
|
|
49
51
|
if (!current || current.pid !== expected.pid || current.port !== expected.port
|
|
50
52
|
|| current.attestationSecret !== expected.attestationSecret) {
|
|
51
53
|
throw new ClientSyncRuntimeError("client_runtime_changed");
|
|
52
54
|
}
|
|
53
|
-
if (!current.clientStopping
|
|
55
|
+
if (!current.clientStopping || (stopOwner && !Bun.deepEquals(current.clientStopOwner, stopOwner, true))) {
|
|
56
|
+
writeRuntimePort({ ...current, clientStopping: true, ...(stopOwner ? { clientStopRequested: true, clientStopOwner: stopOwner } : {}) });
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** Finish only this parent's exact-runtime stop; sync stays fenced until its process exits. */
|
|
62
|
+
export function finishClientRuntimeStop(
|
|
63
|
+
expected: Required<Pick<RuntimePortState, "pid" | "port" | "attestationSecret">>, stopOwner: ClientStopOwner,
|
|
64
|
+
): void {
|
|
65
|
+
withConfigMutationLockSync(() => {
|
|
66
|
+
const current = readSyncRuntime();
|
|
67
|
+
if (current?.pid === expected.pid && current.port === expected.port
|
|
68
|
+
&& current.attestationSecret === expected.attestationSecret && current.clientStopRequested === true
|
|
69
|
+
&& Bun.deepEquals(current.clientStopOwner, stopOwner, true)) {
|
|
70
|
+
const { clientStopOwner: _finished, ...retained } = current;
|
|
71
|
+
writeRuntimePort({ ...retained, clientStopRequested: false });
|
|
72
|
+
}
|
|
54
73
|
});
|
|
55
74
|
}
|
|
56
75
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { captureRouteStaticPolicy, previewRouteModel } from "../../router";
|
|
2
|
+
import { nativeChatDeclineReason } from "../../server/chat-native-eligibility";
|
|
3
|
+
import type { OcxConfig } from "../../types";
|
|
4
|
+
import type { OpencodeCatalogModel } from "./contracts";
|
|
5
|
+
|
|
6
|
+
/** Prefer Chat only when it preserves the wire of a direct, native-eligible route. */
|
|
7
|
+
export function opencodeModelUsesChat(model: OpencodeCatalogModel, config: OcxConfig): boolean {
|
|
8
|
+
if (model.native || !model.provider || !model.id || !model.namespaced.startsWith(`${model.provider}/`)) return false;
|
|
9
|
+
try {
|
|
10
|
+
const route = previewRouteModel(config, model.namespaced);
|
|
11
|
+
if (route.routeKind !== "explicit-provider" || route.routeReason !== "explicit-provider-namespace"
|
|
12
|
+
|| route.providerName !== model.provider || route.modelId !== model.id
|
|
13
|
+
|| route.staticPolicy.model.adapter !== "openai-chat") return false;
|
|
14
|
+
// A registry default may depend on the incoming protocol. Matching Chat must not change
|
|
15
|
+
// an otherwise Responses upstream into a Chat upstream just to enable passthrough.
|
|
16
|
+
const chat = captureRouteStaticPolicy(route.providerName, route.modelId, route.provider,
|
|
17
|
+
route.staticPolicy.effectiveAlias, "chat");
|
|
18
|
+
return chat.model.adapter === "openai-chat"
|
|
19
|
+
&& nativeChatDeclineReason({ ...route, provider: { ...route.provider, adapter: chat.model.adapter } }, {}) === undefined;
|
|
20
|
+
} catch {
|
|
21
|
+
// A stale catalog or a route that cannot currently resolve gives no native wire guarantee.
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -66,6 +66,7 @@ import type { ExportModel, OpencodeLaunchEnv, OpencodeCatalogModel, ExportContex
|
|
|
66
66
|
import { OPENCODE_API_KEY_ENV_REF, OPENCODE_PROVIDER_BLOCK_DEFAULT_CONFIG, OPENCODE_CONFIG_SCHEMA, OPENCODE_PROVIDER_ID, PI_API_DIALECT, LOOPBACK_API_KEY_PLACEHOLDER, HERMES_API_KEY_ENV_REF, OPENCLAW_API_KEY_ENV_REF, OPENCODE_API_KEY_ENV, HERMES_API_KEY_ENV, OPENCLAW_API_KEY_ENV, KILO_API_KEY_ENV } from "./config-export/constants";
|
|
67
67
|
import { exportModelLabel, authoritativeContextWindow, outputBudgetFor, inputBudgetFor, normalizeExportModels, inputModalitiesForClient, opencodeModelCapabilities, proxyAdmissionHeaders, singleFragment } from "./config-export/model-metadata";
|
|
68
68
|
import { exportReasoningEfforts, exportDefaultReasoningEffort, legacyReasoningMetadata, type LegacyEffortVariant } from "./config-export/reasoning-metadata";
|
|
69
|
+
import { opencodeModelUsesChat } from "./config-export/opencode-wire";
|
|
69
70
|
import { buildOmpClientConfig, summarizeOmp, buildOmpContribution } from "./config-export/omp";
|
|
70
71
|
import { buildDshClientConfig, summarizeDsh, buildDshContribution, DSH_DESKTOP_PROFILE } from "./config-export/dsh";
|
|
71
72
|
import { buildMcodeClientConfig, summarizeMcode, buildMcodeContribution } from "./config-export/mcode";
|
|
@@ -98,6 +99,7 @@ export { buildT3CodeClientConfig, t3codeConfigPath, t3codeHomeDir, type T3CodeGe
|
|
|
98
99
|
|
|
99
100
|
export interface OpencodeModelEntry {
|
|
100
101
|
name: string;
|
|
102
|
+
provider?: { npm: typeof OPENCODE_CHAT_NPM };
|
|
101
103
|
limit?: { context: number; input?: number; output: number };
|
|
102
104
|
/**
|
|
103
105
|
* opencode's own capability fields, derived from the catalog row's declared input
|
|
@@ -126,6 +128,7 @@ export interface OpencodeModelVariant {
|
|
|
126
128
|
|
|
127
129
|
export interface OpencodeV2ModelEntry {
|
|
128
130
|
name: string;
|
|
131
|
+
package?: typeof OPENCODE_CHAT_PACKAGE;
|
|
129
132
|
limit?: { context: number; input?: number; output: number };
|
|
130
133
|
capabilities?: { tools: boolean; input?: string[]; output?: string[] };
|
|
131
134
|
compatibility?: { reasoningField: "reasoning_content" };
|
|
@@ -164,7 +167,8 @@ export interface OpencodeProviderBlock {
|
|
|
164
167
|
export interface OpencodeV2ProviderBlock {
|
|
165
168
|
package: string;
|
|
166
169
|
name: string;
|
|
167
|
-
settings: OpencodeProviderConnection
|
|
170
|
+
settings: Omit<OpencodeProviderConnection, "headers">;
|
|
171
|
+
headers?: Record<string, string>;
|
|
168
172
|
models: Record<string, OpencodeV2ModelEntry>;
|
|
169
173
|
}
|
|
170
174
|
|
|
@@ -186,17 +190,10 @@ export interface OpencodeGeneratedConfig {
|
|
|
186
190
|
providers: Record<string, OpencodeV2ProviderBlock>;
|
|
187
191
|
}
|
|
188
192
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
const OPENCODE_PROVIDER_NPM = "@ai-sdk/openai-compatible";
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Canonical V2 runtime spelling. Current clients alias the old @opencode-ai scope,
|
|
197
|
-
* but exported documents use the documented package rather than depending on that alias.
|
|
198
|
-
*/
|
|
199
|
-
const OPENCODE_V2_PROVIDER_PACKAGE = "@opencode/ai/providers/openai-compatible";
|
|
193
|
+
const OPENCODE_CHAT_NPM = "@ai-sdk/openai-compatible";
|
|
194
|
+
const OPENCODE_CHAT_PACKAGE = "@opencode/ai/providers/openai-compatible";
|
|
195
|
+
const OPENCODE_RESPONSES_NPM = "@ai-sdk/openai";
|
|
196
|
+
const OPENCODE_RESPONSES_PACKAGE = "@opencode/ai/providers/openai-compatible-responses";
|
|
200
197
|
|
|
201
198
|
/** Display name for the provider block, identical in both generations. */
|
|
202
199
|
const OPENCODE_PROVIDER_NAME = "OpenCodex";
|
|
@@ -737,7 +734,7 @@ export function raycastConfigPath(env: OpencodeLaunchEnv = process.env, home: st
|
|
|
737
734
|
return join(raycastAiDir(env, home), "providers.yaml");
|
|
738
735
|
}
|
|
739
736
|
|
|
740
|
-
/**
|
|
737
|
+
/** Same endpoint and credentials, with the admission header serialized by generation. */
|
|
741
738
|
function opencodeProviderConnection(baseURL: string, config: OcxConfig): OpencodeProviderConnection {
|
|
742
739
|
const options: OpencodeProviderConnection = { baseURL };
|
|
743
740
|
// Opt-in opencode-side timeout overrides. Omitted by default so opencode keeps its native
|
|
@@ -755,6 +752,8 @@ function opencodeProviderConnection(baseURL: string, config: OcxConfig): Opencod
|
|
|
755
752
|
// stays free for Codex Direct upstream credentials when applicable.
|
|
756
753
|
if (shouldInjectApiAuthHeader(config)) {
|
|
757
754
|
options.headers = { "x-opencodex-api-key": OPENCODE_API_KEY_ENV_REF };
|
|
755
|
+
// The OpenAI SDK requires a key even when the proxy's admission uses its own header.
|
|
756
|
+
options.apiKey = LOOPBACK_API_KEY_PLACEHOLDER;
|
|
758
757
|
return options;
|
|
759
758
|
}
|
|
760
759
|
options.apiKey = OPENCODE_API_KEY_ENV_REF;
|
|
@@ -791,7 +790,13 @@ export function opencodeProviderBlocks(
|
|
|
791
790
|
const v2Models: Record<string, OpencodeV2ModelEntry> = {};
|
|
792
791
|
for (const model of expandFastExportModels(catalogModels)) {
|
|
793
792
|
const key = model.namespaced;
|
|
794
|
-
const
|
|
793
|
+
const usesChat = opencodeModelUsesChat(model, config);
|
|
794
|
+
const { interleaved, ...reasoning } = legacyReasoningMetadata(model);
|
|
795
|
+
const entry: OpencodeModelEntry = {
|
|
796
|
+
name: exportModelLabel(model),
|
|
797
|
+
...reasoning,
|
|
798
|
+
...(usesChat ? { provider: { npm: OPENCODE_CHAT_NPM }, ...(interleaved ? { interleaved } : {}) } : {}),
|
|
799
|
+
};
|
|
795
800
|
const context = authoritativeContextWindow(model.contextWindow);
|
|
796
801
|
if (context !== undefined) {
|
|
797
802
|
entry.limit = { context, output: outputBudgetFor(context, model) };
|
|
@@ -819,22 +824,26 @@ export function opencodeProviderBlocks(
|
|
|
819
824
|
name: entry.name,
|
|
820
825
|
...(entry.limit ? { limit: { ...entry.limit } } : {}),
|
|
821
826
|
...(v2Capabilities ? { capabilities: v2Capabilities } : {}),
|
|
822
|
-
...(
|
|
827
|
+
...(usesChat ? { package: OPENCODE_CHAT_PACKAGE } : {}),
|
|
828
|
+
...(usesChat && interleaved ? { compatibility: { reasoningField: interleaved.field } } : {}),
|
|
823
829
|
...(defaultEffort !== undefined ? { settings: { reasoningEffort: defaultEffort } } : {}),
|
|
824
830
|
variants: opencodeEffortVariants(model),
|
|
825
831
|
};
|
|
826
832
|
}
|
|
833
|
+
const connection = opencodeProviderConnection(baseURL, config);
|
|
834
|
+
const { headers, ...settings } = connection;
|
|
827
835
|
return {
|
|
828
836
|
v1: {
|
|
829
|
-
npm:
|
|
837
|
+
npm: OPENCODE_RESPONSES_NPM,
|
|
830
838
|
name: OPENCODE_PROVIDER_NAME,
|
|
831
|
-
options:
|
|
839
|
+
options: connection,
|
|
832
840
|
models: v1Models,
|
|
833
841
|
},
|
|
834
842
|
v2: {
|
|
835
|
-
package:
|
|
843
|
+
package: OPENCODE_RESPONSES_PACKAGE,
|
|
836
844
|
name: OPENCODE_PROVIDER_NAME,
|
|
837
|
-
settings
|
|
845
|
+
settings,
|
|
846
|
+
...(headers ? { headers } : {}),
|
|
838
847
|
models: v2Models,
|
|
839
848
|
},
|
|
840
849
|
};
|