@iislee/opencodex 2.11.0 → 2.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS_INSTALL.md +109 -0
- package/README.md +114 -19
- package/bin/ocx.mjs +164 -36
- package/bin/package-main.mjs +1 -1
- package/gui/dist/assets/index-BF38heuV.js +104 -0
- package/gui/dist/assets/index-DMiI18Kv.css +1 -0
- package/gui/dist/index.html +2 -2
- package/gui/dist/provider-icons/alibaba-color.svg +1 -1
- package/gui/dist/provider-icons/antigravity-color.svg +1 -1
- package/gui/dist/provider-icons/claude-color.svg +1 -1
- package/gui/dist/provider-icons/cline-color.svg +16 -0
- package/gui/dist/provider-icons/cloudflare-ai-gateway-color.svg +1 -1
- package/gui/dist/provider-icons/commandcode-color.svg +1 -0
- package/gui/dist/provider-icons/copilot-color.svg +1 -1
- package/gui/dist/provider-icons/cursor-color.svg +1 -1
- package/gui/dist/provider-icons/deepseek-color.svg +1 -1
- package/gui/dist/provider-icons/firepass-color.svg +1 -1
- package/gui/dist/provider-icons/fireworks-color.svg +1 -1
- package/gui/dist/provider-icons/gemini-color.svg +1 -1
- package/gui/dist/provider-icons/github-copilot-color.svg +1 -1
- package/gui/dist/provider-icons/gitlab-duo-color.svg +1 -1
- package/gui/dist/provider-icons/grok.svg +1 -1
- package/gui/dist/provider-icons/groq-color.svg +1 -1
- package/gui/dist/provider-icons/huggingface-color.svg +1 -1
- package/gui/dist/provider-icons/kimi-color.svg +1 -1
- package/gui/dist/provider-icons/kiro-color.svg +2 -2
- package/gui/dist/provider-icons/lm-studio-color.svg +1 -1
- package/gui/dist/provider-icons/mistral-color.svg +1 -1
- package/gui/dist/provider-icons/moonshot-color.svg +1 -1
- package/gui/dist/provider-icons/nvidia-color.svg +1 -1
- package/gui/dist/provider-icons/ollama-color.svg +1 -1
- package/gui/dist/provider-icons/openai.svg +1 -1
- package/gui/dist/provider-icons/opencode.svg +2 -1
- package/gui/dist/provider-icons/openrouter-color.svg +1 -1
- package/gui/dist/provider-icons/pi.svg +2 -2
- package/gui/dist/provider-icons/qianfan-color.svg +1 -1
- package/gui/dist/provider-icons/qwen-portal-color.svg +1 -1
- package/gui/dist/provider-icons/vercel-ai-gateway-color.svg +1 -1
- package/gui/dist/provider-icons/vllm-color.svg +1 -1
- package/gui/dist/provider-icons/xiaomi-color.svg +1 -1
- package/package.json +19 -10
- package/src/adapters/anthropic-output-schema.ts +137 -0
- package/src/adapters/anthropic.ts +376 -52
- package/src/adapters/base.ts +54 -7
- package/src/adapters/client-fingerprint.ts +18 -12
- package/src/adapters/cline-pass-deepseek-v4-tool-replay.ts +69 -0
- package/src/adapters/command-code.ts +601 -0
- package/src/adapters/cursor/checkpoint-store.ts +303 -0
- package/src/adapters/cursor/cursor-errors.ts +129 -6
- package/src/adapters/cursor/discovery.ts +61 -4
- package/src/adapters/cursor/effort-map.ts +27 -3
- package/src/adapters/cursor/framing.ts +39 -0
- package/src/adapters/cursor/h2-pool.ts +123 -0
- package/src/adapters/cursor/http1-bidi.ts +361 -0
- package/src/adapters/cursor/images.ts +704 -0
- package/src/adapters/cursor/live-models.ts +174 -58
- package/src/adapters/cursor/live-transport.ts +609 -170
- package/src/adapters/cursor/native-exec-common.ts +23 -2
- package/src/adapters/cursor/native-exec-fs.ts +10 -7
- package/src/adapters/cursor/native-exec-network.ts +1 -1
- package/src/adapters/cursor/native-exec-shell.ts +0 -1
- package/src/adapters/cursor/native-exec.ts +101 -14
- package/src/adapters/cursor/protobuf-events.ts +829 -11
- package/src/adapters/cursor/protobuf-request.ts +383 -65
- package/src/adapters/cursor/request-builder.ts +237 -31
- package/src/adapters/cursor/tool-definitions.ts +242 -12
- package/src/adapters/cursor/tool-result-normalize.ts +92 -0
- package/src/adapters/cursor/transport.ts +22 -0
- package/src/adapters/cursor/types.ts +28 -1
- package/src/adapters/cursor.ts +133 -7
- package/src/adapters/google-antigravity-replay.ts +558 -34
- package/src/adapters/google-antigravity-wire.ts +43 -10
- package/src/adapters/google-http.ts +38 -10
- package/src/adapters/google-tool-schema.ts +80 -15
- package/src/adapters/google-truncation.ts +11 -0
- package/src/adapters/google.ts +618 -74
- package/src/adapters/identity.ts +39 -6
- package/src/adapters/kiro-errors.ts +11 -0
- package/src/adapters/kiro-events.ts +19 -1
- package/src/adapters/kiro-thinking.ts +18 -2
- package/src/adapters/kiro-tools.ts +10 -1
- package/src/adapters/kiro.ts +92 -54
- package/src/adapters/mimo-free.ts +17 -0
- package/src/adapters/openai-chat-url.ts +11 -0
- package/src/adapters/openai-chat.ts +1311 -336
- package/src/adapters/openai-responses-url.ts +16 -0
- package/src/adapters/openai-responses.ts +830 -56
- package/src/adapters/registry.ts +175 -0
- package/src/adapters/responses-tool-schema.ts +67 -0
- package/src/adapters/tool-call-id.ts +119 -0
- package/src/adapters/tool-catalog-nudge.ts +104 -21
- package/src/adapters/xai-web-search.ts +185 -0
- package/src/bridge.ts +428 -61
- package/src/chat/inbound.ts +43 -19
- package/src/chat/outbound.ts +82 -26
- package/src/claude/agents-inject.ts +32 -9
- package/src/claude/context-windows.ts +21 -5
- package/src/claude/desktop-3p.ts +243 -9
- package/src/claude/gateway-cache.ts +41 -4
- package/src/claude/inbound.ts +72 -3
- package/src/claude/model-info.ts +38 -15
- package/src/claude/outbound.ts +70 -16
- package/src/cli/account-api.ts +35 -1
- package/src/cli/account-auth.ts +33 -6
- package/src/cli/account-catalog-refresh.ts +14 -0
- package/src/cli/account-extended.ts +389 -2
- package/src/cli/account-main.ts +317 -0
- package/src/cli/account.ts +30 -6
- package/src/cli/agent.ts +45 -1
- package/src/cli/claude-agent-startup-sync.ts +73 -0
- package/src/cli/claude-desktop.ts +29 -4
- package/src/cli/claude.ts +103 -34
- package/src/cli/codex-log-guard-doctor.ts +103 -0
- package/src/cli/codex-shim-autorestore.ts +2 -0
- package/src/cli/codex-shim-readiness.ts +76 -0
- package/src/cli/combo.ts +8 -0
- package/src/cli/config-command.ts +74 -10
- package/src/cli/dispatch.ts +593 -0
- package/src/cli/doctor.ts +315 -43
- package/src/cli/ensure-desired-integrations.ts +152 -0
- package/src/cli/export-command.ts +46 -20
- package/src/cli/help.ts +20 -271
- package/src/cli/index.ts +378 -519
- package/src/cli/init.ts +4 -17
- package/src/cli/integrations.ts +120 -2
- package/src/cli/lab.ts +607 -0
- package/src/cli/launcher-context.ts +77 -0
- package/src/cli/minimax.ts +497 -0
- package/src/cli/models-runtime.ts +35 -2
- package/src/cli/models.ts +100 -14
- package/src/cli/observe.ts +92 -3
- package/src/cli/opencode.ts +4 -2
- package/src/cli/provider-runtime.ts +18 -1
- package/src/cli/provider.ts +24 -3
- package/src/cli/ready.ts +301 -0
- package/src/cli/registry.ts +437 -0
- package/src/cli/root.ts +86 -0
- package/src/cli/route-policy.ts +92 -0
- package/src/cli/runtime-api.ts +6 -3
- package/src/cli/star-prompt.ts +71 -15
- package/src/cli/status.ts +10 -3
- package/src/cli/system-restart-client.ts +146 -0
- package/src/cli/tray-proxy.ts +153 -6
- package/src/cli/v2.ts +105 -10
- package/src/cli.ts +1 -1
- package/src/clients/config-export.ts +1358 -21
- package/src/codex/account-label.ts +14 -1
- package/src/codex/account-lifecycle.ts +130 -13
- package/src/codex/account-namespaces.ts +49 -3
- package/src/codex/account-priority.ts +83 -0
- package/src/codex/account-store.ts +29 -2
- package/src/codex/account-usability.ts +25 -2
- package/src/codex/admission.ts +256 -0
- package/src/codex/affinity-debug.ts +162 -0
- package/src/codex/app-server-processes.ts +493 -106
- package/src/codex/app-server-restart-service.ts +232 -0
- package/src/codex/auth-api.ts +849 -242
- package/src/codex/auth-collision.ts +5 -3
- package/src/codex/auth-context.ts +345 -32
- package/src/codex/autostart-health.ts +8 -1
- package/src/codex/catalog/account-models.ts +67 -0
- package/src/codex/catalog/aggregation.ts +68 -10
- package/src/codex/catalog/bundled.ts +331 -33
- package/src/codex/catalog/effort.ts +121 -30
- package/src/codex/catalog/filesystem-evidence.ts +302 -0
- package/src/codex/catalog/kinds.ts +2 -0
- package/src/codex/catalog/metadata.ts +529 -45
- package/src/codex/catalog/native-models.ts +72 -0
- package/src/codex/catalog/parsing.ts +224 -30
- package/src/codex/catalog/provider-fetch.ts +1460 -134
- package/src/codex/catalog/sync.ts +1449 -186
- package/src/codex/catalog-admission.ts +199 -0
- package/src/codex/catalog-refresh-status.ts +105 -0
- package/src/codex/catalog-write-serialization.ts +242 -0
- package/src/codex/catalog.ts +6 -3
- package/src/codex/codex-write-lock.ts +384 -0
- package/src/codex/convergence-types.ts +614 -0
- package/src/codex/convergence.ts +651 -0
- package/src/codex/coordinator-doctor.ts +332 -0
- package/src/codex/custom-model-catalog-migration.ts +176 -0
- package/src/codex/desired-state.ts +230 -0
- package/src/codex/features.ts +636 -39
- package/src/codex/generation.ts +202 -0
- package/src/codex/history-job.ts +407 -0
- package/src/codex/history-lock.ts +242 -0
- package/src/codex/history-migration-guardian.ts +26 -20
- package/src/codex/history-provider.ts +231 -28
- package/src/codex/history-transition.ts +105 -0
- package/src/codex/history-worker.ts +220 -0
- package/src/codex/inject-coordination.ts +290 -0
- package/src/codex/inject.ts +1073 -152
- package/src/codex/injected-marker.ts +37 -3
- package/src/codex/integration-record.ts +266 -0
- package/src/codex/internal/catalog-writer.ts +203 -0
- package/src/codex/internal/history-writer.ts +80 -0
- package/src/codex/journal.ts +66 -4
- package/src/codex/log-guard/inspect.ts +506 -0
- package/src/codex/log-guard/lock.ts +150 -0
- package/src/codex/log-guard/maintenance.ts +403 -0
- package/src/codex/log-guard/path-safety.ts +88 -0
- package/src/codex/log-guard/policy.ts +44 -0
- package/src/codex/log-guard/processes.ts +205 -0
- package/src/codex/log-guard/protection.ts +489 -0
- package/src/codex/log-guard/sqlite-errors.ts +9 -0
- package/src/codex/main-account-cache.ts +24 -0
- package/src/codex/main-account.ts +29 -1
- package/src/codex/management-convergence.ts +167 -0
- package/src/codex/model-cache.ts +56 -10
- package/src/codex/model-entitlements.ts +353 -0
- package/src/codex/native-main-admission.ts +47 -0
- package/src/codex/native-main-auth-temp.ts +187 -0
- package/src/codex/native-main-claim.ts +178 -0
- package/src/codex/native-main-lock-file.ts +162 -0
- package/src/codex/native-main-owner.ts +329 -0
- package/src/codex/native-profile-api.ts +247 -0
- package/src/codex/native-profile-manager.ts +1531 -0
- package/src/codex/native-profile-processes.ts +121 -0
- package/src/codex/native-profile-recovery.ts +99 -0
- package/src/codex/native-profile-stage-store.ts +387 -0
- package/src/codex/native-profile-startup.ts +492 -0
- package/src/codex/native-profile-store.ts +855 -0
- package/src/codex/native-profile-types.ts +120 -0
- package/src/codex/native-residue.ts +682 -0
- package/src/codex/paths.ts +80 -1
- package/src/codex/plan-from-token.ts +140 -0
- package/src/codex/plan.ts +40 -0
- package/src/codex/plugins-doctor.ts +1 -1
- package/src/codex/pool-rotation.ts +74 -4
- package/src/codex/project-config-warnings.ts +20 -6
- package/src/codex/prompt-journal.ts +352 -0
- package/src/codex/prompt-layers.ts +967 -0
- package/src/codex/prompt-lock.ts +143 -0
- package/src/codex/quota-rejection.ts +298 -0
- package/src/codex/quota.ts +175 -13
- package/src/codex/refresh.ts +11 -2
- package/src/codex/reset-credit-recovery.ts +1044 -0
- package/src/codex/routing.ts +505 -94
- package/src/codex/runtime.ts +159 -38
- package/src/codex/shim.ts +1009 -28
- package/src/codex/subagent-model-fallback.ts +350 -35
- package/src/codex/sync.ts +191 -2
- package/src/codex/transition-state.ts +612 -0
- package/src/codex/upstream-host-health.ts +368 -0
- package/src/codex/user-identity.ts +557 -0
- package/src/codex/warmup.ts +187 -81
- package/src/codex/write-coordination.ts +114 -0
- package/src/combos/failover.ts +20 -0
- package/src/combos/index.ts +4 -0
- package/src/combos/request.ts +32 -0
- package/src/combos/types.ts +81 -9
- package/src/config/provider-name.ts +24 -0
- package/src/config.ts +1762 -140
- package/src/generated/compatibility-version.json +3164 -0
- package/src/generated/{jawcode-model-metadata.ts → model-metadata.ts} +19 -17
- package/src/grok/inject.ts +16 -5
- package/src/grok/inspect.ts +45 -0
- package/src/grok/sync.ts +2 -2
- package/src/images/loop.ts +152 -29
- package/src/images/plan.ts +23 -13
- package/src/integrations/config-io.ts +269 -0
- package/src/integrations/journal.ts +315 -0
- package/src/integrations/merge.ts +135 -0
- package/src/integrations/mutation-flight.ts +71 -0
- package/src/integrations/native/ownership-preflight.ts +202 -0
- package/src/integrations/omp-yaml-source.ts +358 -0
- package/src/integrations/owned-refresh.ts +74 -0
- package/src/integrations/ownership.ts +111 -0
- package/src/integrations/registry.ts +159 -0
- package/src/integrations/serialize.ts +314 -0
- package/src/integrations/state.ts +361 -0
- package/src/integrations/store.ts +103 -0
- package/src/integrations/writer-lock.ts +98 -0
- package/src/integrations/writer.ts +691 -0
- package/src/lab/artifacts/sanitize.ts +586 -0
- package/src/lab/artifacts/secure-fs.ts +475 -0
- package/src/lab/artifacts/store.ts +310 -0
- package/src/lab/automation/budgets.ts +78 -0
- package/src/lab/automation/config-persistence.ts +256 -0
- package/src/lab/automation/constants.ts +39 -0
- package/src/lab/automation/cooldown.ts +103 -0
- package/src/lab/automation/dispatch.ts +211 -0
- package/src/lab/automation/index.ts +13 -0
- package/src/lab/automation/orchestrator.ts +499 -0
- package/src/lab/automation/persistence.ts +512 -0
- package/src/lab/automation/planner.ts +371 -0
- package/src/lab/automation/policy.ts +136 -0
- package/src/lab/automation/queue.ts +191 -0
- package/src/lab/automation/recovery.ts +24 -0
- package/src/lab/automation/route-context.ts +21 -0
- package/src/lab/automation/run-key.ts +44 -0
- package/src/lab/automation/runs-query.ts +34 -0
- package/src/lab/automation/types.ts +160 -0
- package/src/lab/conformance/assertion.ts +325 -0
- package/src/lab/conformance/digest.ts +22 -0
- package/src/lab/conformance/executor.ts +741 -0
- package/src/lab/conformance/fixture-provider.ts +27 -0
- package/src/lab/conformance/fixtures/live-v1-cases.json +175 -0
- package/src/lab/conformance/fixtures/protocol-v1-cases.json +461 -0
- package/src/lab/conformance/harness-budget.ts +47 -0
- package/src/lab/conformance/index.ts +5 -0
- package/src/lab/conformance/jcs.ts +64 -0
- package/src/lab/conformance/json-pointer.ts +39 -0
- package/src/lab/conformance/manifest.ts +180 -0
- package/src/lab/conformance/mcp-stub.ts +179 -0
- package/src/lab/conformance/negative-controls.ts +164 -0
- package/src/lab/conformance/observation.ts +355 -0
- package/src/lab/conformance/runner.ts +68 -0
- package/src/lab/conformance/sse-normalize.ts +59 -0
- package/src/lab/conformance/suite-manifest.ts +78 -0
- package/src/lab/conformance/types.ts +214 -0
- package/src/lab/constants.ts +126 -0
- package/src/lab/digest.ts +64 -0
- package/src/lab/events/errors.ts +9 -0
- package/src/lab/events/limits.ts +117 -0
- package/src/lab/events/types.ts +229 -0
- package/src/lab/events/validate.ts +781 -0
- package/src/lab/fabric/constants.ts +40 -0
- package/src/lab/fabric/executor.ts +492 -0
- package/src/lab/fabric/index.ts +80 -0
- package/src/lab/fabric/manifest.ts +222 -0
- package/src/lab/fabric/observe.ts +489 -0
- package/src/lab/fabric/patch.ts +79 -0
- package/src/lab/fabric/producer-child.ts +139 -0
- package/src/lab/fabric/producer-isolate.ts +276 -0
- package/src/lab/fabric/producer-protocol.ts +61 -0
- package/src/lab/fabric/scratch.ts +439 -0
- package/src/lab/fabric/subject.ts +106 -0
- package/src/lab/fabric/types.ts +134 -0
- package/src/lab/fabric/verifier.ts +98 -0
- package/src/lab/index.ts +54 -0
- package/src/lab/ledger/artifact-refs.ts +127 -0
- package/src/lab/ledger/invalidation.ts +136 -0
- package/src/lab/ledger/purge.ts +310 -0
- package/src/lab/ledger/store.ts +532 -0
- package/src/lab/live/credential-lease.ts +53 -0
- package/src/lab/live/destination.ts +155 -0
- package/src/lab/live/executor.ts +336 -0
- package/src/lab/live/inert-tools.ts +56 -0
- package/src/lab/live/manifest.ts +85 -0
- package/src/lab/live/mcp-loopback.ts +57 -0
- package/src/lab/live/runner.ts +19 -0
- package/src/lab/live/sandbox.ts +61 -0
- package/src/lab/live/suite-manifest.ts +41 -0
- package/src/lab/live/transport.ts +118 -0
- package/src/lab/live/types.ts +197 -0
- package/src/lab/observe/from-conformance.ts +301 -0
- package/src/lab/observe/from-live.ts +117 -0
- package/src/lab/paths.ts +153 -0
- package/src/lab/projection/rebuild.ts +495 -0
- package/src/lab/projection/schema.ts +135 -0
- package/src/lab/projection/verdicts.ts +474 -0
- package/src/lab/projection/verification.ts +412 -0
- package/src/lab/public/bundle.ts +217 -0
- package/src/lab/public/community-authority.ts +175 -0
- package/src/lab/public/community-files.ts +29 -0
- package/src/lab/public/community.ts +479 -0
- package/src/lab/public/file-safety.ts +155 -0
- package/src/lab/public/ids.ts +26 -0
- package/src/lab/public/index.ts +16 -0
- package/src/lab/public/mutation-lock.ts +424 -0
- package/src/lab/public/operator.ts +353 -0
- package/src/lab/public/origin-purge.ts +79 -0
- package/src/lab/public/origin.ts +203 -0
- package/src/lab/public/privacy.ts +143 -0
- package/src/lab/public/private-file.ts +261 -0
- package/src/lab/public/project.ts +124 -0
- package/src/lab/public/purge-test-fault.ts +21 -0
- package/src/lab/public/purge.ts +223 -0
- package/src/lab/public/registry.ts +44 -0
- package/src/lab/public/revocation.ts +252 -0
- package/src/lab/public/signature.ts +243 -0
- package/src/lab/public/storage.ts +105 -0
- package/src/lab/public/strict-json.ts +206 -0
- package/src/lab/public/time.ts +26 -0
- package/src/lab/public/types.ts +172 -0
- package/src/lab/public/validate.ts +391 -0
- package/src/lab/query/catalog.ts +101 -0
- package/src/lab/query/connection.ts +107 -0
- package/src/lab/query/constants.ts +4 -0
- package/src/lab/query/cursor.ts +132 -0
- package/src/lab/query/dto-map.ts +277 -0
- package/src/lab/query/errors.ts +22 -0
- package/src/lab/query/freshness.ts +53 -0
- package/src/lab/query/index.ts +45 -0
- package/src/lab/query/latest-observation.ts +59 -0
- package/src/lab/query/passive-production.ts +159 -0
- package/src/lab/query/queries.ts +444 -0
- package/src/lab/query/types.ts +266 -0
- package/src/lab/subject/behavior-fingerprint.ts +77 -0
- package/src/lab/subject/installation-salt.ts +112 -0
- package/src/lab/subject/protocol-subject.ts +80 -0
- package/src/lab/subject/route-subject.ts +74 -0
- package/src/lib/app-owned-memory-stores.ts +22 -0
- package/src/lib/bounded-body.ts +153 -9
- package/src/lib/bun-runtime.ts +125 -12
- package/src/lib/bun-stream-caps.ts +13 -9
- package/src/lib/codex-restart-contract.ts +120 -0
- package/src/lib/config-ownership.ts +6 -2
- package/src/lib/destination-policy.ts +65 -1
- package/src/lib/errors.ts +44 -2
- package/src/lib/fabric-task-execution-authority.ts +7 -0
- package/src/lib/fabric-task-host.ts +29 -0
- package/src/lib/lab-activation.ts +223 -0
- package/src/lib/lab-live-execution-authority.ts +13 -0
- package/src/lib/lab-live-host.ts +30 -0
- package/src/lib/lab-live-pinned-sender.ts +56 -0
- package/src/lib/lab-live-route-production.ts +130 -0
- package/src/lib/lab-passive-linker-registration.ts +26 -0
- package/src/lib/local-management-attestation.ts +51 -0
- package/src/lib/local-management-capability.ts +100 -0
- package/src/lib/local-provider-reload-contract.ts +100 -0
- package/src/lib/optional-shutdown-hooks.ts +57 -0
- package/src/lib/pinned-http.ts +145 -26
- package/src/lib/process-control.ts +4 -1
- package/src/lib/provider-outbound.ts +49 -9
- package/src/lib/redact.ts +419 -3
- package/src/lib/self-launch-argv.ts +15 -0
- package/src/lib/server-resource-ownership.ts +71 -0
- package/src/lib/shadow-call.ts +35 -4
- package/src/lib/sse-decoder.ts +41 -0
- package/src/lib/state-store-registrations.ts +10 -2
- package/src/lib/system-restart-contract.ts +73 -0
- package/src/lib/token-estimate.ts +19 -2
- package/src/lib/tool-argument-integers.ts +202 -0
- package/src/lib/translator-budget.ts +44 -0
- package/src/lib/upstream-http-version.ts +57 -0
- package/src/lib/upstream-reachability.ts +95 -0
- package/src/lib/upstream-retry.ts +156 -3
- package/src/lib/windows-atomic-replace.ts +155 -0
- package/src/lib/windows-elevation.ts +70 -2
- package/src/lib/windows-secret-acl.ts +409 -69
- package/src/lib/windows-service-wrappers.ts +72 -0
- package/src/lib/windows-text.ts +106 -0
- package/src/lib/windows-user-principal.ts +341 -0
- package/src/lib/winsw.ts +33 -5
- package/src/oauth/account-import/google-antigravity-adapter.ts +74 -0
- package/src/oauth/account-import/index.ts +15 -0
- package/src/oauth/account-import/parser.ts +83 -0
- package/src/oauth/account-import/registry.ts +18 -0
- package/src/oauth/account-import/service.ts +75 -0
- package/src/oauth/account-import/types.ts +91 -0
- package/src/oauth/anthropic.ts +12 -1
- package/src/oauth/callback-server.ts +8 -2
- package/src/oauth/chatgpt.ts +12 -1
- package/src/oauth/command-code.ts +239 -0
- package/src/oauth/cursor.ts +46 -5
- package/src/oauth/google-antigravity.ts +35 -3
- package/src/oauth/health.ts +20 -12
- package/src/oauth/index.ts +398 -66
- package/src/oauth/key-providers.ts +16 -0
- package/src/oauth/kimi.ts +16 -2
- package/src/oauth/kiro.ts +50 -6
- package/src/oauth/local-token-detect.ts +11 -2
- package/src/oauth/log.ts +3 -1
- package/src/oauth/login-cli.ts +88 -28
- package/src/oauth/nous.ts +798 -0
- package/src/oauth/store.ts +119 -21
- package/src/oauth/token-guardian.ts +9 -3
- package/src/pi/models.ts +2 -2
- package/src/providers/alibaba-region-migration.ts +1 -1
- package/src/providers/antigravity-models.ts +521 -31
- package/src/providers/base-url-choices.ts +10 -0
- package/src/providers/codex-capacity.ts +292 -0
- package/src/providers/command-code-efforts.ts +144 -0
- package/src/providers/context-cap.ts +22 -5
- package/src/providers/cursor-pool.ts +72 -0
- package/src/providers/derive.ts +253 -6
- package/src/providers/fastwire.ts +501 -0
- package/src/providers/free-directory.ts +10 -7
- package/src/providers/google-vertex-location.ts +14 -0
- package/src/providers/key-failover.ts +71 -3
- package/src/providers/label.ts +1 -1
- package/src/providers/model-discovery-limits.ts +16 -0
- package/src/providers/model-discovery.ts +115 -22
- package/src/providers/model-rename-migration.ts +255 -0
- package/src/providers/model-rename-startup.ts +28 -0
- package/src/providers/openai-sidecar.ts +72 -4
- package/src/providers/openai-tier-startup.ts +31 -2
- package/src/providers/openai-tiers.ts +119 -4
- package/src/providers/openai-virtual-models.ts +1 -0
- package/src/providers/opencode-zen-rate-limit.ts +102 -0
- package/src/providers/provider-id-rewrite.ts +29 -0
- package/src/providers/quota.ts +1319 -38
- package/src/providers/registry.ts +1429 -111
- package/src/providers/request-pacing.ts +310 -0
- package/src/providers/service-tier.ts +277 -0
- package/src/providers/slug-codec.ts +42 -6
- package/src/providers/static-model-discovery.ts +86 -0
- package/src/providers/xai-responses-opt-in.ts +15 -0
- package/src/providers/xai-transport.ts +11 -4
- package/src/reasoning-effort.ts +49 -1
- package/src/responses/compaction.ts +26 -1
- package/src/responses/custom-tool-compat.ts +266 -0
- package/src/responses/hosted-tool-policy.ts +9 -0
- package/src/responses/namespace-tool-compat.ts +355 -0
- package/src/responses/parser.ts +220 -38
- package/src/responses/provider-continuation.ts +98 -0
- package/src/responses/provider-opaque-metadata.ts +73 -0
- package/src/responses/reasoning-envelope.ts +9 -1
- package/src/responses/reasoning-replay-cache.ts +426 -0
- package/src/responses/schema.ts +7 -1
- package/src/responses/spill-store.ts +75 -10
- package/src/responses/state.ts +565 -27
- package/src/responses/thought-signature-replay.ts +347 -0
- package/src/responses/tool-search-compat.ts +301 -0
- package/src/responses/truncated-stop-reason.ts +60 -0
- package/src/router.ts +366 -30
- package/src/routing/analytics.ts +378 -0
- package/src/routing/capability.ts +244 -0
- package/src/routing/compatibility/assemble.ts +73 -0
- package/src/routing/compatibility/behavior.ts +278 -0
- package/src/routing/compatibility/catalog.ts +99 -0
- package/src/routing/compatibility/endpoint.ts +52 -0
- package/src/routing/compatibility/lab-evidence-provider.ts +130 -0
- package/src/routing/compatibility/policy.ts +181 -0
- package/src/routing/compatibility/provider-slot.ts +56 -0
- package/src/routing/compatibility/reader.ts +110 -0
- package/src/routing/compatibility/subject.ts +191 -0
- package/src/routing/compatibility/types.ts +64 -0
- package/src/routing/compatibility/version.ts +104 -0
- package/src/routing/cost.ts +77 -0
- package/src/routing/evaluator.ts +495 -0
- package/src/routing/health.ts +412 -0
- package/src/routing/history/cursor.ts +43 -0
- package/src/routing/history/indexer.ts +605 -0
- package/src/routing/history/schema.ts +72 -0
- package/src/routing/profile-namespace.ts +15 -0
- package/src/routing/profile.ts +547 -0
- package/src/routing/quota.ts +145 -0
- package/src/routing/request-evidence.ts +45 -0
- package/src/routing/trace.ts +776 -0
- package/src/server/adapter-resolve.ts +2 -29
- package/src/server/auth-cors.ts +267 -46
- package/src/server/background-lifecycle.ts +182 -0
- package/src/server/chat-completions.ts +130 -56
- package/src/server/chat-native-sse.ts +331 -0
- package/src/server/chat-native.ts +426 -0
- package/src/server/claude-messages.ts +159 -43
- package/src/server/direct-local-http.ts +347 -0
- package/src/server/effort-policy.ts +18 -0
- package/src/server/github-copilot-responses-repair.ts +338 -0
- package/src/server/gui-static.ts +39 -10
- package/src/server/images.ts +94 -12
- package/src/server/index.ts +865 -181
- package/src/server/lifecycle.ts +284 -13
- package/src/server/live.ts +136 -17
- package/src/server/local-management-read-client.ts +90 -0
- package/src/server/local-provider-reload-client.ts +137 -0
- package/src/server/management/agent-settings-routes.ts +398 -103
- package/src/server/management/api-key-usage.ts +31 -5
- package/src/server/management/body.ts +6 -0
- package/src/server/management/combo-routes.ts +62 -24
- package/src/server/management/config-routes.ts +464 -51
- package/src/server/management/context.ts +80 -2
- package/src/server/management/integration-routes.ts +498 -0
- package/src/server/management/lab-automation-routes.ts +206 -0
- package/src/server/management/lab-routes.ts +563 -0
- package/src/server/management/logs-usage-routes.ts +101 -32
- package/src/server/management/model-routes.ts +189 -131
- package/src/server/management/model-rows.ts +163 -0
- package/src/server/management/native-integration-routes.ts +769 -0
- package/src/server/management/oauth-account-routes.ts +80 -4
- package/src/server/management/provider-capability-config.ts +48 -0
- package/src/server/management/provider-routes.ts +764 -157
- package/src/server/management/request-history-routes.ts +191 -0
- package/src/server/management/routing-analytics-routes.ts +74 -0
- package/src/server/management/routing-profile-routes.ts +380 -0
- package/src/server/management/shared.ts +27 -11
- package/src/server/management/sidebar-routes.ts +47 -31
- package/src/server/management/storage-log-guard-routes.ts +186 -0
- package/src/server/management/sync-response.ts +69 -0
- package/src/server/management/system-restart.ts +288 -32
- package/src/server/management/system-routes.ts +77 -0
- package/src/server/management/usage-summary-cache.ts +9 -1
- package/src/server/management/vision-sidecar-options.ts +167 -0
- package/src/server/management/web-search-sidecar-options.ts +120 -0
- package/src/server/management-api.ts +115 -14
- package/src/server/management-auth.ts +220 -5
- package/src/server/passive-route-linker.ts +66 -0
- package/src/server/ports.ts +41 -1
- package/src/server/proxy-liveness.ts +132 -5
- package/src/server/readiness.ts +99 -0
- package/src/server/relay-eager.ts +82 -42
- package/src/server/relay.ts +236 -76
- package/src/server/request-decompress.ts +113 -6
- package/src/server/request-log.ts +235 -22
- package/src/server/responses/agent-task-recovery-cache.ts +143 -0
- package/src/server/responses/agent-task-recovery.ts +465 -0
- package/src/server/responses/collaboration.ts +204 -35
- package/src/server/responses/compact.ts +442 -55
- package/src/server/responses/core.ts +2872 -331
- package/src/server/responses/empty-completion-guard.ts +276 -0
- package/src/server/responses/encrypted-payload.ts +62 -39
- package/src/server/responses/fetch-helpers.ts +79 -4
- package/src/server/responses/input-admission.ts +185 -0
- package/src/server/responses/pacing-overload.ts +13 -0
- package/src/server/responses/policy-fallback.ts +178 -0
- package/src/server/responses/responses-field-backfill.ts +251 -0
- package/src/server/responses/terminal-guard.ts +26 -5
- package/src/server/responses/upstream-error.ts +5 -0
- package/src/server/responses/ws-upstream.ts +308 -0
- package/src/server/responses-custom-tool-repair.ts +282 -0
- package/src/server/responses-item-id-repair.ts +54 -6
- package/src/server/responses-json-events.ts +90 -0
- package/src/server/responses-model-rewrite.ts +29 -0
- package/src/server/responses-reasoning-summary-rewrite.ts +178 -0
- package/src/server/responses-snapshot-repair.ts +621 -0
- package/src/server/responses-terminal-repair.ts +342 -0
- package/src/server/responses-tool-search-repair.ts +267 -0
- package/src/server/responses-undeclared-tool-guard.ts +153 -0
- package/src/server/responses.ts +18 -2
- package/src/server/search.ts +78 -13
- package/src/server/sse-frame-buffer.ts +292 -0
- package/src/server/sse-payload-rewrite.ts +110 -22
- package/src/server/startup-action-control.ts +8 -1
- package/src/server/startup-health-cache.ts +19 -1
- package/src/server/system-env.ts +80 -9
- package/src/server/ws-bridge.ts +39 -38
- package/src/service-manager-probe.ts +892 -0
- package/src/service.ts +1111 -90
- package/src/sidecar/auth.ts +92 -0
- package/src/sidecar/candidates.ts +83 -0
- package/src/storage/cleanup.ts +2 -2
- package/src/storage/scanner.ts +1 -1
- package/src/storage/worker-lifecycle.ts +14 -14
- package/src/tray/windows-tray.ps1 +83 -9
- package/src/tray/windows.ts +43 -16
- package/src/types/accounts.ts +37 -0
- package/src/types/config.ts +845 -0
- package/src/types/provider.ts +545 -0
- package/src/types/request.ts +384 -0
- package/src/types/tools.ts +131 -0
- package/src/types/wire.ts +80 -0
- package/src/types.ts +104 -1236
- package/src/update/index.ts +32 -19
- package/src/update/job.ts +442 -67
- package/src/update/notify.ts +12 -6
- package/src/update/npm-cache-preflight.d.mts +47 -0
- package/src/update/npm-cache-preflight.mjs +201 -0
- package/src/update/transactional-install.d.mts +22 -0
- package/src/update/transactional-install.mjs +259 -0
- package/src/usage/cost.ts +0 -0
- package/src/usage/expected-prices.ts +268 -16
- package/src/usage/log.ts +606 -41
- package/src/usage/summary.ts +177 -9
- package/src/usage/user-cost-overlay-reconciler.ts +313 -0
- package/src/usage/user-cost-overlays.ts +314 -0
- package/src/vision/anthropic-describe.ts +10 -6
- package/src/vision/backends.ts +97 -0
- package/src/vision/describe.ts +9 -3
- package/src/vision/eligibility.ts +250 -0
- package/src/vision/index.ts +238 -24
- package/src/vision/reasoning.ts +55 -0
- package/src/vision/routed-describe.ts +175 -0
- package/src/vision/timeout-bounds.ts +9 -0
- package/src/web-search/anthropic-executor.ts +13 -7
- package/src/web-search/backends.ts +108 -0
- package/src/web-search/exa-executor.ts +88 -0
- package/src/web-search/executor.ts +11 -3
- package/src/web-search/gemini-executor.ts +141 -0
- package/src/web-search/index.ts +150 -15
- package/src/web-search/loop.ts +279 -50
- package/src/web-search/parse.ts +125 -30
- package/src/web-search/sources.ts +60 -0
- package/src/web-search/xai-executor.ts +219 -0
- package/gui/dist/assets/index-DTpMHS4F.js +0 -67
- package/gui/dist/assets/index-ZNVDE3C7.css +0 -1
- package/gui/dist/provider-icons/antigravity.svg +0 -1
- package/gui/dist/provider-icons/claude.svg +0 -1
- package/gui/dist/provider-icons/copilot.svg +0 -1
- package/gui/dist/provider-icons/cursor.svg +0 -2
- package/gui/dist/provider-icons/gemini.svg +0 -1
- package/gui/dist/provider-icons/grok-color.svg +0 -1
- package/gui/dist/provider-icons/kiro.svg +0 -14
- package/src/cli/internal-dispatch.ts +0 -20
package/src/types.ts
CHANGED
|
@@ -1,1237 +1,105 @@
|
|
|
1
|
-
|
|
1
|
+
// AUTO-SPLIT barrel: src/types.ts re-exports every historical name; bodies live in src/types/*.
|
|
2
|
+
// Values (runtime): tools + wire. Types (erased): request + config + provider + accounts.
|
|
3
|
+
|
|
4
|
+
export type { OcxTool, OcxToolChoice } from "./types/tools";
|
|
5
|
+
export {
|
|
6
|
+
namespacedToolName,
|
|
7
|
+
toolChoiceAliases,
|
|
8
|
+
toolChoiceCandidates,
|
|
9
|
+
toolAllowedByChoice,
|
|
10
|
+
resolveToolChoiceWireName,
|
|
11
|
+
modelInList,
|
|
12
|
+
isAllowedToolChoice,
|
|
13
|
+
toolChoiceToolPredicate,
|
|
14
|
+
} from "./types/tools";
|
|
15
|
+
|
|
16
|
+
export type { UpstreamHttpVersion, ReasoningSummaryDelivery, CodexAccountMode } from "./types/wire";
|
|
17
|
+
export {
|
|
18
|
+
UPSTREAM_HTTP_VERSION_VALUES,
|
|
19
|
+
REASONING_SUMMARY_DELIVERY_VALUES,
|
|
20
|
+
OPENAI_PROVIDER_TIER_VERSION,
|
|
21
|
+
MODEL_ADAPTER_OVERRIDE_ALLOWED,
|
|
22
|
+
captureWireAdapterHardPins,
|
|
23
|
+
isWirePinnedModel,
|
|
24
|
+
pinnedWireAdapter,
|
|
25
|
+
} from "./types/wire";
|
|
26
|
+
|
|
27
|
+
export type {
|
|
28
|
+
OcxReasoningReplayIdentity,
|
|
29
|
+
OcxReasoningReplayScopeRef,
|
|
30
|
+
OcxParsedRequest,
|
|
31
|
+
OcxContext,
|
|
32
|
+
OcxMessage,
|
|
33
|
+
OcxUserMessage,
|
|
34
|
+
OcxAssistantMessage,
|
|
35
|
+
OcxDeveloperMessage,
|
|
36
|
+
OcxToolResultMessage,
|
|
37
|
+
OcxTextContent,
|
|
38
|
+
OcxImageContent,
|
|
39
|
+
OcxContentPart,
|
|
40
|
+
OcxThinkingContent,
|
|
41
|
+
OcxToolCall,
|
|
42
|
+
OcxProviderOpaqueToolCallMetadata,
|
|
43
|
+
OcxAssistantContentPart,
|
|
44
|
+
OcxRequestOptions,
|
|
45
|
+
OcxMessagePhase,
|
|
46
|
+
OcxProviderContinuationOwner,
|
|
47
|
+
OcxProviderContinuationState,
|
|
48
|
+
AdapterEvent,
|
|
49
|
+
OcxUrlCitation,
|
|
50
|
+
OcxUsage,
|
|
51
|
+
} from "./types/request";
|
|
52
|
+
|
|
53
|
+
export type {
|
|
54
|
+
OcxClaudeCodeConfig,
|
|
55
|
+
OcxClaudeDesktopFamily,
|
|
56
|
+
OcxClaudeDesktopAssignment,
|
|
57
|
+
OcxClaudeDesktopProfile,
|
|
58
|
+
StorageCleanupPolicy,
|
|
59
|
+
OcxCustomModel,
|
|
60
|
+
OcxApiKeyEntry,
|
|
61
|
+
OcxClientIntegrationsConfig,
|
|
62
|
+
OcxConfig,
|
|
63
|
+
OcxAccountPoolRotationStrategy,
|
|
64
|
+
OcxComboStrategy,
|
|
65
|
+
OcxComboDefaultEffort,
|
|
66
|
+
OcxComboTarget,
|
|
67
|
+
OcxComboConfig,
|
|
68
|
+
OcxRoutingUnknownEvidenceMode,
|
|
69
|
+
OcxRoutingProfileCandidate,
|
|
70
|
+
OcxRoutingProfileRequirements,
|
|
71
|
+
OcxRoutingProfileOptimize,
|
|
72
|
+
OcxRoutingUnknownCostCapMode,
|
|
73
|
+
OcxRoutingProfileLimits,
|
|
74
|
+
OcxRoutingProfileUnknownEvidence,
|
|
75
|
+
OcxRoutingProfileCompatibilitySuite,
|
|
76
|
+
OcxRoutingProfileCompatibility,
|
|
77
|
+
OcxRoutingProfileConfig,
|
|
78
|
+
OcxTokenGuardianConfig,
|
|
79
|
+
OcxImagesConfig,
|
|
80
|
+
OcxSearchConfig,
|
|
81
|
+
OcxVisionSidecarConfig,
|
|
82
|
+
OcxWebSearchSidecarConfig,
|
|
83
|
+
} from "./types/config";
|
|
84
|
+
|
|
85
|
+
export type {
|
|
86
|
+
RefreshPolicy,
|
|
87
|
+
OpenRouterProviderRouting,
|
|
88
|
+
ResponsesItemIdRepairConfig,
|
|
89
|
+
RateLimitRetryPolicy,
|
|
90
|
+
ProviderCostOverlay,
|
|
91
|
+
RequestPacingRule,
|
|
92
|
+
ProviderRequestPacingConfig,
|
|
93
|
+
FastWire,
|
|
94
|
+
AttemptTierOutcome,
|
|
95
|
+
TierObservationContext,
|
|
96
|
+
TierDecision,
|
|
97
|
+
OcxProviderConfig,
|
|
98
|
+
} from "./types/provider";
|
|
99
|
+
|
|
100
|
+
export type {
|
|
101
|
+
CodexAccount,
|
|
102
|
+
CodexAccountCredentials,
|
|
103
|
+
CodexAccountCredentialRecord,
|
|
104
|
+
} from "./types/accounts";
|
|
2
105
|
|
|
3
|
-
export interface OcxParsedRequest {
|
|
4
|
-
modelId: string;
|
|
5
|
-
previousResponseId?: string;
|
|
6
|
-
context: OcxContext;
|
|
7
|
-
stream: boolean;
|
|
8
|
-
options: OcxRequestOptions;
|
|
9
|
-
_rawBody?: unknown;
|
|
10
|
-
/** Number of leading raw input items restored from local previous_response_id state. */
|
|
11
|
-
_replayPrefixLen?: number;
|
|
12
|
-
/** True when the proxy expanded a previous_response_id request into a full input replay. */
|
|
13
|
-
_previousResponseInputExpanded?: boolean;
|
|
14
|
-
/** Provider-private stable Cursor conversation id resolved from the Responses previous_response_id chain. */
|
|
15
|
-
_cursorConversationId?: string;
|
|
16
|
-
/** Stable upstream client thread identity, used only to derive provider-scoped continuation ids. */
|
|
17
|
-
_clientThreadId?: string;
|
|
18
|
-
/**
|
|
19
|
-
* Optional authenticated tenant/operator namespace for Cursor thread→conversation derivation.
|
|
20
|
-
* When absent (single-operator local proxy), derivation stays local-scoped.
|
|
21
|
-
*/
|
|
22
|
-
_cursorIdentityScope?: string;
|
|
23
|
-
/**
|
|
24
|
-
* True for helper/shadow/compaction turns that must not append into the main Cursor conversation
|
|
25
|
-
* derived from the parent thread id.
|
|
26
|
-
*/
|
|
27
|
-
_cursorIsolateConversation?: boolean;
|
|
28
|
-
/** Account-scoped, non-secret Kiro request metadata selected with the OAuth access token. */
|
|
29
|
-
_kiroAuthContext?: Pick<KiroOAuthMetadata, "profileArn" | "apiRegion" | "ssoRegion">;
|
|
30
|
-
/** Provider-private continuation metadata resolved from the Responses previous_response_id chain. */
|
|
31
|
-
_providerContinuation?: OcxProviderContinuationState;
|
|
32
|
-
/**
|
|
33
|
-
* The hosted `{type:"web_search", ...}` tool config, stashed when Codex enables web search. Routed
|
|
34
|
-
* (non-OpenAI) providers can't run it server-side, so the proxy re-exposes it as a function tool and
|
|
35
|
-
* executes searches via the gpt-5.4-mini sidecar (see src/web-search). Absent when not requested.
|
|
36
|
-
*/
|
|
37
|
-
_webSearch?: Record<string, unknown>;
|
|
38
|
-
/** Hosted image_generation tool config stashed for the image bridge sidecar (see src/images). */
|
|
39
|
-
_imageGeneration?: { toolNames: Set<string>; originalTool?: Record<string, unknown> };
|
|
40
|
-
/**
|
|
41
|
-
* True when Codex requested structured output (`text.format` = json_schema/json_object). The
|
|
42
|
-
* web-search tool_result is then rendered as compact JSON instead of markdown prose, so its
|
|
43
|
-
* answer/"Sources:" text can't bleed into and corrupt the model's schema-constrained output.
|
|
44
|
-
*/
|
|
45
|
-
_structuredOutput?: boolean;
|
|
46
|
-
/**
|
|
47
|
-
* True when the input carried `{type:"compaction_trigger"}` — Codex remote compaction v2 asking
|
|
48
|
-
* this turn to produce a `{type:"compaction"}` output item. Routed adapters can't natively;
|
|
49
|
-
* the server runs the model as a summarizer and the bridge emits a synthetic compaction item
|
|
50
|
-
* (see src/responses/compaction.ts).
|
|
51
|
-
*/
|
|
52
|
-
_compactionRequest?: boolean;
|
|
53
|
-
/**
|
|
54
|
-
* True when the current request newly introduced a stored compaction summary/marker. Historical
|
|
55
|
-
* markers restored by previous_response_id expansion were already acknowledged and do not reset
|
|
56
|
-
* provider-private continuation caches again on every later turn.
|
|
57
|
-
*/
|
|
58
|
-
_contextCompactionBoundary?: boolean;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export interface OcxContext {
|
|
62
|
-
systemPrompt?: string[];
|
|
63
|
-
messages: OcxMessage[];
|
|
64
|
-
tools?: OcxTool[];
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export type OcxMessage =
|
|
68
|
-
| OcxUserMessage
|
|
69
|
-
| OcxAssistantMessage
|
|
70
|
-
| OcxDeveloperMessage
|
|
71
|
-
| OcxToolResultMessage;
|
|
72
|
-
|
|
73
|
-
export interface OcxUserMessage {
|
|
74
|
-
role: "user";
|
|
75
|
-
content: string | OcxContentPart[];
|
|
76
|
-
timestamp: number;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export interface OcxAssistantMessage {
|
|
80
|
-
role: "assistant";
|
|
81
|
-
content: OcxAssistantContentPart[];
|
|
82
|
-
/** Responses message phase, preserved when replaying translated provider output. */
|
|
83
|
-
phase?: OcxMessagePhase;
|
|
84
|
-
model?: string;
|
|
85
|
-
timestamp: number;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export interface OcxDeveloperMessage {
|
|
89
|
-
role: "developer";
|
|
90
|
-
content: string | OcxContentPart[];
|
|
91
|
-
timestamp: number;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export interface OcxToolResultMessage {
|
|
95
|
-
role: "toolResult";
|
|
96
|
-
toolCallId: string;
|
|
97
|
-
toolName: string;
|
|
98
|
-
/** MCP namespace from the originating tool call, if any. */
|
|
99
|
-
toolNamespace?: string;
|
|
100
|
-
/** Text, or content parts when a tool (e.g. Codex view_image) returns an image in its output. */
|
|
101
|
-
content: string | OcxContentPart[];
|
|
102
|
-
/** True when the Responses result contained opaque encrypted output Kiro cannot translate. */
|
|
103
|
-
containsEncryptedContent?: boolean;
|
|
104
|
-
isError: boolean;
|
|
105
|
-
timestamp: number;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export interface OcxTextContent {
|
|
109
|
-
type: "text";
|
|
110
|
-
text: string;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export interface OcxImageContent {
|
|
114
|
-
type: "image";
|
|
115
|
-
/** A `data:` URL (base64) or a remote https URL — passed through from Codex verbatim, NEVER inlined as text. */
|
|
116
|
-
imageUrl: string;
|
|
117
|
-
/** Fidelity hint from Codex: "low" | "high" | "auto". */
|
|
118
|
-
detail?: string;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/** A user/developer message content part: text or an image (vision). */
|
|
122
|
-
export type OcxContentPart = OcxTextContent | OcxImageContent;
|
|
123
|
-
|
|
124
|
-
export interface OcxThinkingContent {
|
|
125
|
-
type: "thinking";
|
|
126
|
-
thinking: string;
|
|
127
|
-
signature?: string;
|
|
128
|
-
itemId?: string;
|
|
129
|
-
/** Raw Anthropic redacted_thinking block payloads to replay verbatim (order preserved). */
|
|
130
|
-
redacted?: string[];
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
export interface OcxToolCall {
|
|
134
|
-
type: "toolCall";
|
|
135
|
-
id: string;
|
|
136
|
-
name: string;
|
|
137
|
-
arguments: Record<string, unknown>;
|
|
138
|
-
customWireName?: string;
|
|
139
|
-
thoughtSignature?: string;
|
|
140
|
-
/** MCP namespace (e.g. "mcp__context7") when this call targets a namespaced tool. */
|
|
141
|
-
namespace?: string;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
export type OcxAssistantContentPart = OcxTextContent | OcxThinkingContent | OcxToolCall;
|
|
145
|
-
|
|
146
|
-
export interface OcxTool {
|
|
147
|
-
name: string;
|
|
148
|
-
description: string;
|
|
149
|
-
parameters: Record<string, unknown>;
|
|
150
|
-
strict?: boolean;
|
|
151
|
-
/** MCP namespace (e.g. "mcp__context7") for tools flattened out of a Responses "namespace" tool. */
|
|
152
|
-
namespace?: string;
|
|
153
|
-
/** Freeform/custom tool (e.g. apply_patch): the model's call must be relayed as a custom_tool_call. */
|
|
154
|
-
freeform?: boolean;
|
|
155
|
-
/** Client-executed tool discovery (tool_search): the model's call must be relayed as a tool_search_call. */
|
|
156
|
-
toolSearch?: boolean;
|
|
157
|
-
/** Tool definition restored from a prior tool_search output; transports may prioritize it when catalogs are bounded. */
|
|
158
|
-
loadedFromToolSearch?: boolean;
|
|
159
|
-
/** Synthetic web_search tool: the model's call is executed by the gpt-5.4-mini sidecar, not relayed to Codex. */
|
|
160
|
-
webSearch?: boolean;
|
|
161
|
-
/** Synthetic image_gen tool: the model's call is executed by the xAI image bridge sidecar, not relayed to Codex. */
|
|
162
|
-
imageGeneration?: boolean;
|
|
163
|
-
/** Synthetic video_gen tool: executed by the xAI video bridge sidecar. */
|
|
164
|
-
videoGeneration?: boolean;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* Wire name a chat model sees for a tool. Namespaced (MCP) tools are flattened to
|
|
169
|
-
* "<namespace>__<name>" so they survive the chat-completions function-tool format;
|
|
170
|
-
* the proxy maps this back to {namespace, name} on the return trip (Codex routes MCP
|
|
171
|
-
* calls by an explicit `namespace` field, not by parsing the name).
|
|
172
|
-
*/
|
|
173
|
-
export function namespacedToolName(namespace: string | undefined, name: string): string {
|
|
174
|
-
return namespace ? `${namespace}__${name}` : name;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
export function toolChoiceAliases(tool: Pick<OcxTool, "namespace" | "name">): string[] {
|
|
178
|
-
const wireName = namespacedToolName(tool.namespace, tool.name);
|
|
179
|
-
return tool.namespace ? [wireName, `${tool.namespace}.${tool.name}`] : [wireName];
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
export function toolAllowedByChoice(tool: Pick<OcxTool, "namespace" | "name">, allowedTools: ReadonlySet<string>): boolean {
|
|
183
|
-
return toolChoiceAliases(tool).some(name => allowedTools.has(name));
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
export function resolveToolChoiceWireName(tools: readonly Pick<OcxTool, "namespace" | "name">[] | undefined, name: string): string {
|
|
187
|
-
const match = tools?.find(tool => toolChoiceAliases(tool).includes(name));
|
|
188
|
-
return match ? namespacedToolName(match.namespace, match.name) : name;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Whether `modelId` is in a per-provider classification list (e.g. `noVisionModels`). Matches the full
|
|
193
|
-
* id, OR — for Ollama-style ids — the family before the ":size" tag, so a `gpt-oss` entry covers
|
|
194
|
-
* `gpt-oss:120b`/`gpt-oss:20b`. Colon-less ids (e.g. `grok-build-0.1`) still match exactly only.
|
|
195
|
-
*/
|
|
196
|
-
export function modelInList(list: string[] | undefined, modelId: string): boolean {
|
|
197
|
-
if (!list || list.length === 0) return false;
|
|
198
|
-
if (list.includes(modelId)) return true;
|
|
199
|
-
const colon = modelId.indexOf(":");
|
|
200
|
-
return colon > 0 && list.includes(modelId.slice(0, colon));
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
export type OcxToolChoice =
|
|
204
|
-
| "auto"
|
|
205
|
-
| "none"
|
|
206
|
-
| "required"
|
|
207
|
-
| { name: string }
|
|
208
|
-
| { allowedTools: string[]; mode: "auto" | "required" };
|
|
209
|
-
|
|
210
|
-
export function isAllowedToolChoice(value: OcxToolChoice | undefined): value is { allowedTools: string[]; mode: "auto" | "required" } {
|
|
211
|
-
return typeof value === "object" && value !== null && "allowedTools" in value;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
export interface OcxRequestOptions {
|
|
215
|
-
maxOutputTokens?: number;
|
|
216
|
-
temperature?: number;
|
|
217
|
-
topP?: number;
|
|
218
|
-
stopSequences?: string[];
|
|
219
|
-
toolChoice?: OcxToolChoice;
|
|
220
|
-
parallelToolCalls?: boolean;
|
|
221
|
-
reasoning?: string;
|
|
222
|
-
hideThinkingSummary?: boolean;
|
|
223
|
-
serviceTier?: string;
|
|
224
|
-
presencePenalty?: number;
|
|
225
|
-
frequencyPenalty?: number;
|
|
226
|
-
/** Responses prompt-cache affinity key. Passthrough preserves it via _rawBody; routed adapters do not consume it unless their upstream wire supports it. */
|
|
227
|
-
promptCacheKey?: string;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
export type OcxMessagePhase = "commentary" | "final_answer";
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* Provider-private state that must follow a locally expanded `previous_response_id` chain.
|
|
234
|
-
* Kept out of public Responses output and persisted only in the bounded local continuation cache.
|
|
235
|
-
*/
|
|
236
|
-
export interface OcxProviderContinuationState {
|
|
237
|
-
cursor?: {
|
|
238
|
-
conversationId?: string;
|
|
239
|
-
checkpointUsable?: boolean;
|
|
240
|
-
};
|
|
241
|
-
kiro?: {
|
|
242
|
-
conversationId?: string;
|
|
243
|
-
};
|
|
244
|
-
[provider: string]: Record<string, unknown> | undefined;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
export type AdapterEvent =
|
|
248
|
-
| { type: "heartbeat" }
|
|
249
|
-
| { type: "text_delta"; text: string; phase?: OcxMessagePhase }
|
|
250
|
-
| { type: "thinking_delta"; thinking: string }
|
|
251
|
-
// Anthropic extended-thinking round-trip: signature_delta for the current thinking block, and
|
|
252
|
-
// opaque redacted_thinking blocks. Both must be replayed verbatim or tool-use turns 400.
|
|
253
|
-
| { type: "thinking_signature"; signature: string }
|
|
254
|
-
| { type: "redacted_thinking"; data: string }
|
|
255
|
-
| { type: "reasoning_raw_delta"; text: string }
|
|
256
|
-
| { type: "tool_call_start"; id: string; name: string }
|
|
257
|
-
| { type: "tool_call_delta"; arguments: string }
|
|
258
|
-
| { type: "tool_call_end" }
|
|
259
|
-
/** Internal boundary between a guarded first pass and its one-shot continuation. */
|
|
260
|
-
| { type: "assistant_boundary" }
|
|
261
|
-
// Native web-search activity surfaced by the web-search sidecar so Codex renders a "Searched the
|
|
262
|
-
// web" cell. Emitted as a lifecycle PAIR at real wall-clock moments by src/web-search/loop.ts
|
|
263
|
-
// (routed adapters never emit these): `begin` right before the sidecar runs so Codex shows the
|
|
264
|
-
// "Searching the web" spinner, then `end` once it resolves. The bridge maps begin → an
|
|
265
|
-
// output_item.added(in_progress) and end → the matching output_item.done(completed|failed) under
|
|
266
|
-
// the SAME output index, so the activity animates instead of flashing completed instantly.
|
|
267
|
-
| { type: "web_search_call_begin"; id: string }
|
|
268
|
-
| { type: "web_search_call_end"; id: string; queries: string[]; status?: "completed" | "failed"; sources?: OcxUrlCitation[] }
|
|
269
|
-
| {
|
|
270
|
-
type: "done";
|
|
271
|
-
usage?: OcxUsage;
|
|
272
|
-
stopReason?: string;
|
|
273
|
-
endTurn?: boolean;
|
|
274
|
-
providerState?: OcxProviderContinuationState;
|
|
275
|
-
}
|
|
276
|
-
| {
|
|
277
|
-
type: "incomplete";
|
|
278
|
-
reason: string;
|
|
279
|
-
message?: string;
|
|
280
|
-
usage?: OcxUsage;
|
|
281
|
-
retryable?: boolean;
|
|
282
|
-
endTurn?: boolean;
|
|
283
|
-
providerState?: OcxProviderContinuationState;
|
|
284
|
-
}
|
|
285
|
-
// `usage` carries best-effort partial consumption when a turn dies before a clean done
|
|
286
|
-
// (e.g. cursor upstream 502 mid-stream), so failed requests can log real token counts.
|
|
287
|
-
| {
|
|
288
|
-
type: "error";
|
|
289
|
-
message: string;
|
|
290
|
-
usage?: OcxUsage;
|
|
291
|
-
/** Authoritative upstream/proxy status when known; avoids message-based classification. */
|
|
292
|
-
status?: number;
|
|
293
|
-
/** Responses error type and code when the adapter has a structured provider failure. */
|
|
294
|
-
errorType?: string;
|
|
295
|
-
code?: string;
|
|
296
|
-
retryable?: boolean;
|
|
297
|
-
};
|
|
298
|
-
|
|
299
|
-
/**
|
|
300
|
-
* A web source backing a search answer. Surfaced on the search-end event and rendered by the bridge
|
|
301
|
-
* as a `url_citation` annotation on the following assistant message (the desktop app's Sources chip
|
|
302
|
-
* reads these; the TUI ignores annotations, so this is additive).
|
|
303
|
-
*/
|
|
304
|
-
export interface OcxUrlCitation {
|
|
305
|
-
url: string;
|
|
306
|
-
title?: string;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
/**
|
|
310
|
-
* Canonical usage convention (devlog/260711_claude_inbound/070):
|
|
311
|
-
* - `inputTokens` is the TOTAL prompt size, INCLUDING cache reads and cache writes
|
|
312
|
-
* (OpenAI Responses convention). Anthropic parse sites normalize into this shape.
|
|
313
|
-
* - `cachedInputTokens` is cache READ tokens only (a subset of `inputTokens`).
|
|
314
|
-
* - `cacheReadInputTokens`/`cacheCreationInputTokens` carry the read/write split when
|
|
315
|
-
* the provider reports both; reads mirror `cachedInputTokens`.
|
|
316
|
-
* - `totalTokens` = inputTokens + outputTokens. Never re-add cache detail on top.
|
|
317
|
-
*/
|
|
318
|
-
export interface OcxUsage {
|
|
319
|
-
inputTokens: number;
|
|
320
|
-
outputTokens: number;
|
|
321
|
-
/**
|
|
322
|
-
* Absolute active-context size after the response. Stateful providers can expose this separately
|
|
323
|
-
* from their per-attempt usage. Responses serialization derives the input side from
|
|
324
|
-
* `contextTotalTokens - outputTokens` so output is never added to an absolute checkpoint twice.
|
|
325
|
-
*/
|
|
326
|
-
contextTotalTokens?: number;
|
|
327
|
-
totalTokens?: number;
|
|
328
|
-
cachedInputTokens?: number;
|
|
329
|
-
cacheReadInputTokens?: number;
|
|
330
|
-
cacheCreationInputTokens?: number;
|
|
331
|
-
reasoningOutputTokens?: number;
|
|
332
|
-
estimated?: boolean;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
/**
|
|
336
|
-
* Claude Code inbound settings (devlog/260711_claude_inbound). Consumed by the
|
|
337
|
-
* /v1/messages surface, the `ocx claude` launcher, and the GUI Claude page.
|
|
338
|
-
*/
|
|
339
|
-
export interface OcxClaudeCodeConfig {
|
|
340
|
-
/** Kill switch for the /v1/messages inbound (GUI "Claude ON" toggle). Default: enabled. */
|
|
341
|
-
enabled?: boolean;
|
|
342
|
-
/**
|
|
343
|
-
* Verbatim passthrough of unmapped claude/anthropic models to api.anthropic.com with the
|
|
344
|
-
* caller's own sk-ant-* credential (Claude Code subscription OAuth). Default: enabled.
|
|
345
|
-
*/
|
|
346
|
-
nativePassthrough?: boolean;
|
|
347
|
-
/** Upstream for the native passthrough (tests/enterprise gateways). Default: https://api.anthropic.com */
|
|
348
|
-
anthropicBaseUrl?: string;
|
|
349
|
-
/**
|
|
350
|
-
* Native passthrough body inactivity budget in SECONDS — raw upstream-byte silence
|
|
351
|
-
* while a read is pending, NOT total duration (slow-but-alive streams never trip it;
|
|
352
|
-
* devlog 260716_passthrough_followups/010). Default 90. Min 1. Exactly 0 disables;
|
|
353
|
-
* negative/non-finite values fall back to the default.
|
|
354
|
-
*/
|
|
355
|
-
bodyStallSec?: number;
|
|
356
|
-
/**
|
|
357
|
-
* Native passthrough cumulative body byte cap (streamed SSE and buffered non-stream
|
|
358
|
-
* alike) — an OOM/occupancy guard, not a correctness limit. Default 67108864 (64 MiB).
|
|
359
|
-
* Exactly 0 disables; negative/non-finite values fall back to the default.
|
|
360
|
-
*/
|
|
361
|
-
bodyMaxBytes?: number;
|
|
362
|
-
/** Default model slot injected as ANTHROPIC_MODEL by `ocx claude`. */
|
|
363
|
-
model?: string;
|
|
364
|
-
/** Haiku/small-fast slot injected as ANTHROPIC_DEFAULT_HAIKU_MODEL (+ legacy SMALL_FAST). */
|
|
365
|
-
smallFastModel?: string;
|
|
366
|
-
/** Inbound model id remaps: exact id first, then date-stripped (`-\d{8}$`). */
|
|
367
|
-
modelMap?: Record<string, string>;
|
|
368
|
-
/**
|
|
369
|
-
* Inject ANTHROPIC_BASE_URL etc. into the macOS user domain via `launchctl setenv`
|
|
370
|
-
* so plain `claude` commands route through the proxy without `ocx claude`. Reverted
|
|
371
|
-
* on stop/shutdown. Default: false (opt-in). macOS only.
|
|
372
|
-
*/
|
|
373
|
-
systemEnv?: boolean;
|
|
374
|
-
/**
|
|
375
|
-
* Auth mode for Claude Code inbound requests — a THREE-state intent.
|
|
376
|
-
*
|
|
377
|
-
* "proxy": inject the dummy ANTHROPIC_AUTH_TOKEN so Claude Code routes through the
|
|
378
|
-
* proxy without a real Anthropic key. "subscription": never inject it. UNSET means
|
|
379
|
-
* AUTO: the mode is resolved from detected Claude auth on every launch and every
|
|
380
|
-
* status read (src/claude/auth-mode.ts), so registering a Claude login switches the
|
|
381
|
-
* behaviour with no migration and no stored state.
|
|
382
|
-
*
|
|
383
|
-
* An explicit value always wins over detection and is never rewritten by the auto
|
|
384
|
-
* logic — that is what makes a manual choice stick (devlog 260726_claude_auth_auto).
|
|
385
|
-
*/
|
|
386
|
-
authMode?: "proxy" | "subscription";
|
|
387
|
-
/**
|
|
388
|
-
* ISO timestamp of the one-time authMode migration. Before auto existed, choosing
|
|
389
|
-
* "Subscription" DELETED the key, so a pre-upgrade config cannot distinguish an
|
|
390
|
-
* explicit subscription choice from "never chose". Its ABSENCE identifies a
|
|
391
|
-
* pre-upgrade block; the migration writes it once and never re-runs, so a user who
|
|
392
|
-
* later picks Auto (which deletes authMode) is not silently converted back.
|
|
393
|
-
*/
|
|
394
|
-
authModeMigratedAt?: string;
|
|
395
|
-
/**
|
|
396
|
-
* Context-window override for Claude Code/Desktop clients (devlog 136 B6):
|
|
397
|
-
* injected as CLAUDE_CODE_MAX_CONTEXT_TOKENS + DISABLE_COMPACT=1 (the official
|
|
398
|
-
* env pair — recognized claude-shaped ids need both). WARNING: DISABLE_COMPACT
|
|
399
|
-
* turns off auto-compaction. Unset = client defaults.
|
|
400
|
-
*/
|
|
401
|
-
maxContextTokens?: number;
|
|
402
|
-
/**
|
|
403
|
-
* Opt-in CLAUDE_CODE_ALWAYS_ENABLE_EFFORT=1 injection. Default OFF: opus-shaped
|
|
404
|
-
* aliases already carry output_config.effort on the wire (devlog 136 실측), and
|
|
405
|
-
* forcing effort on every request can leak reasoning params to non-reasoning routes.
|
|
406
|
-
*/
|
|
407
|
-
alwaysEnableEffort?: boolean;
|
|
408
|
-
/**
|
|
409
|
-
* Subagent tier slots (devlog 260712 B2): injected as ANTHROPIC_DEFAULT_*_MODEL so
|
|
410
|
-
* Claude Code's Agent-tool aliases (opus/sonnet/haiku/fable + parent-inherit) route
|
|
411
|
-
* to proxy models. haiku falls back to smallFastModel (one effective value feeds
|
|
412
|
-
* both ANTHROPIC_DEFAULT_HAIKU_MODEL and legacy ANTHROPIC_SMALL_FAST_MODEL).
|
|
413
|
-
*/
|
|
414
|
-
tierModels?: { opus?: string; sonnet?: string; haiku?: string; fable?: string };
|
|
415
|
-
/**
|
|
416
|
-
* Auto-context (devlog 260712 020): when not false, routed/native models whose
|
|
417
|
-
* authoritative window is > 200k AND >= the compact window get the [1m] marker
|
|
418
|
-
* (Claude Code then accounts 1M) and CLAUDE_CODE_AUTO_COMPACT_WINDOW is injected
|
|
419
|
-
* so compaction fires at the real budget. 2.1.207 semantics (binary-verified):
|
|
420
|
-
* effective compact window = min(believed window, env) — one global env behaves
|
|
421
|
-
* like a per-model floor. Default: enabled. Inert while maxContextTokens is set
|
|
422
|
-
* (the legacy DISABLE_COMPACT pair takes rule-1 precedence in the CLI).
|
|
423
|
-
*/
|
|
424
|
-
autoContext?: boolean;
|
|
425
|
-
/** Compact-window tokens for auto-context. Default 350_000. */
|
|
426
|
-
autoCompactWindow?: number;
|
|
427
|
-
/**
|
|
428
|
-
* Bundled-skill content elision for ROUTED (non-Anthropic) models (devlog 260712
|
|
429
|
-
* 060): Skill-tool results whose skill name matches an entry here are replaced
|
|
430
|
-
* with a short stub in the anthropic->responses translation. Third-party models
|
|
431
|
-
* are not trained on these Anthropic doc bundles, and claude-api alone injects
|
|
432
|
-
* ~136k tokens (GitHub anthropics/claude-code#74473). Native Anthropic
|
|
433
|
-
* passthrough never goes through the translation, so Claude models keep the
|
|
434
|
-
* full content. Default: ["claude-api"]. Empty array = explicitly off.
|
|
435
|
-
*/
|
|
436
|
-
blockedSkills?: string[];
|
|
437
|
-
/**
|
|
438
|
-
* Sync the featured subagent roster (config.subagentModels + main model) into
|
|
439
|
-
* ~/.claude/agents/ocx-*.md custom agent definitions at launch (devlog 260712
|
|
440
|
-
* 070) so any routed model is dispatchable as a subagent_type — the Agent
|
|
441
|
-
* tool's model argument is a hard 4-alias enum, but definition frontmatter is
|
|
442
|
-
* free. Only ocx-*.md files are owned/pruned. Default: enabled.
|
|
443
|
-
*/
|
|
444
|
-
injectAgents?: boolean;
|
|
445
|
-
/**
|
|
446
|
-
* Optional Claude Code effort pinned in every generated ocx-* subagent
|
|
447
|
-
* definition. Unset inherits the parent session effort.
|
|
448
|
-
*/
|
|
449
|
-
subagentEffort?: "low" | "medium" | "high" | "xhigh" | "max";
|
|
450
|
-
/** Claude-originated web-search override. Unset fields inherit the global sidecar settings. */
|
|
451
|
-
webSearchSidecar?: { backend?: "openai" | "anthropic"; model?: string };
|
|
452
|
-
/** Claude-originated vision override. Unset fields inherit the global sidecar settings. */
|
|
453
|
-
visionSidecar?: { backend?: "openai" | "anthropic"; model?: string };
|
|
454
|
-
/** Persisted Claude Desktop four-family routing profile. */
|
|
455
|
-
desktopProfile?: OcxClaudeDesktopProfile;
|
|
456
|
-
/** Auto-reconcile Desktop 3P config when provider catalog changes. Default: enabled. */
|
|
457
|
-
desktopAutoApply?: boolean;
|
|
458
|
-
/**
|
|
459
|
-
* When false, omit `native/*` rows from Claude Desktop show/export/apply. Default: enabled.
|
|
460
|
-
* Routing-sidecar alias decoding is unchanged — only the Desktop model list writer.
|
|
461
|
-
*/
|
|
462
|
-
desktopNativeModels?: boolean;
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
export type OcxClaudeDesktopFamily = "opus" | "fable" | "sonnet" | "haiku";
|
|
466
|
-
|
|
467
|
-
export interface OcxClaudeDesktopAssignment {
|
|
468
|
-
family: OcxClaudeDesktopFamily;
|
|
469
|
-
alias: string;
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
export interface OcxClaudeDesktopProfile {
|
|
473
|
-
version: 1;
|
|
474
|
-
assignments: Record<string, OcxClaudeDesktopAssignment>;
|
|
475
|
-
defaults: Record<OcxClaudeDesktopFamily, string | null>;
|
|
476
|
-
/** SHA-256 fingerprint of the last successfully applied 3P config content. */
|
|
477
|
-
appliedFingerprint?: string;
|
|
478
|
-
/** ISO timestamp of the last successful apply. */
|
|
479
|
-
appliedAt?: string;
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
/**
|
|
483
|
-
* Opt-in archived-session auto-cleanup policy (issue #42 Phase 3).
|
|
484
|
-
* Persisted under `OcxConfig.storageCleanupPolicy`. Default `enabled: false`.
|
|
485
|
-
*/
|
|
486
|
-
export interface StorageCleanupPolicy {
|
|
487
|
-
/** When false/unset, the engine never mutates. Default false. */
|
|
488
|
-
enabled: boolean;
|
|
489
|
-
/** Run when archived session bytes exceed this threshold. */
|
|
490
|
-
trigger: { archivedBytesOver: number };
|
|
491
|
-
/** Either shrink archives toward a byte floor, or remove the oldest N%. */
|
|
492
|
-
target: { reduceToBytes?: number } | { removeOldestPercent?: number };
|
|
493
|
-
schedule: "startup" | "daily" | "weekly" | "manual";
|
|
494
|
-
/** Default quarantine. Permanent only when explicitly set. */
|
|
495
|
-
mode: "quarantine" | "permanent";
|
|
496
|
-
lastRun?: { at: number; freedBytes: number; removed: number };
|
|
497
|
-
/** Epoch ms when the next scheduled evaluation is due. */
|
|
498
|
-
nextRun?: number;
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
/** 사용자가 대시보드에서 직접 추가한 커스텀 모델 정의. */
|
|
502
|
-
export interface OcxCustomModel {
|
|
503
|
-
/** 고유 ID (crypto.randomUUID()) */
|
|
504
|
-
id: string;
|
|
505
|
-
/** 프로바이더 키 (기존 providers[name]) */
|
|
506
|
-
provider: string;
|
|
507
|
-
/** 모델 슬러그 (프로바이더 접두사 없는 bare id) */
|
|
508
|
-
modelId: string;
|
|
509
|
-
/** 인간 가독 표시명 (선택, 슬래시 불가) */
|
|
510
|
-
displayName?: string;
|
|
511
|
-
/** 컨텍스트 윈도우 (토큰) */
|
|
512
|
-
contextWindow?: number;
|
|
513
|
-
/** 입력 모달리티 (선택, 기본 ["text"]) */
|
|
514
|
-
inputModalities?: string[];
|
|
515
|
-
/** 추가 시각 (ISO 8601) */
|
|
516
|
-
addedAt?: string;
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
/**
|
|
520
|
-
* A generated `ocx_` data-plane key. `key` is the secret itself and never leaves
|
|
521
|
-
* the server except in the one-time POST /api/keys response; every other surface
|
|
522
|
-
* sees only the masked prefix.
|
|
523
|
-
*/
|
|
524
|
-
export interface OcxApiKeyEntry {
|
|
525
|
-
id: string;
|
|
526
|
-
name: string;
|
|
527
|
-
key: string;
|
|
528
|
-
createdAt: string;
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
export interface OcxConfig {
|
|
532
|
-
port: number;
|
|
533
|
-
/** Maximum usage-log bytes read for one management snapshot. */
|
|
534
|
-
managementUsageMaxReadBytes?: number;
|
|
535
|
-
providers: Record<string, OcxProviderConfig>;
|
|
536
|
-
defaultProvider: string;
|
|
537
|
-
/** OpenAI provider-contract migration marker (v2 = single `openai` provider with account mode). */
|
|
538
|
-
openaiProviderTierVersion?: 1 | 2;
|
|
539
|
-
/** One-time migration marker for Antigravity's static catalog default. */
|
|
540
|
-
googleAntigravityStaticCatalogVersion?: 1;
|
|
541
|
-
/** Claude Code inbound + launcher settings. */
|
|
542
|
-
claudeCode?: OcxClaudeCodeConfig;
|
|
543
|
-
/**
|
|
544
|
-
* Up to 5 routed model ids ("<provider>/<model>") to feature FIRST in the injected Codex catalog.
|
|
545
|
-
* Codex's spawn_agent only advertises the first 5 routed models, so this picks which 5 appear.
|
|
546
|
-
*/
|
|
547
|
-
subagentModels?: string[];
|
|
548
|
-
/**
|
|
549
|
-
* Priority-ordered fallback models for spawned sub-agents. When the requested
|
|
550
|
-
* model is quota-exhausted or recently failed, opencodex rewrites the child
|
|
551
|
-
* turn to the next available entry before routing.
|
|
552
|
-
*/
|
|
553
|
-
subagentModelFallback?: string[];
|
|
554
|
-
/**
|
|
555
|
-
* TTL (ms) for cached sub-agent model availability probes. Default 60_000.
|
|
556
|
-
*/
|
|
557
|
-
subagentModelFallbackPollMs?: number;
|
|
558
|
-
injectionModel?: string;
|
|
559
|
-
/**
|
|
560
|
-
* Opt in to synchronizing the selected injection model into Codex's native
|
|
561
|
-
* sub-agent defaults. Only meaningful while `injectionModel` is set.
|
|
562
|
-
*/
|
|
563
|
-
syncCodexSubagentDefaults?: boolean;
|
|
564
|
-
/**
|
|
565
|
-
* Optional reasoning effort the delegation prompt tells the agent to pass in spawn_agent calls
|
|
566
|
-
* (`reasoning_effort` argument). Only meaningful while `injectionModel` is set; validated against
|
|
567
|
-
* the Codex ladder (src/reasoning-effort.ts CODEX_REASONING_LEVELS) at the API boundary.
|
|
568
|
-
*/
|
|
569
|
-
injectionEffort?: string;
|
|
570
|
-
/**
|
|
571
|
-
* Explicit sideband websocket base for realtime/live joins, mirroring upstream's
|
|
572
|
-
* `experimental_realtime_ws_base_url`. The value is a ROOT (or a recognized
|
|
573
|
-
* `/realtime`, `/realtime/calls/<id>`, `/live/<id>` endpoint form, which is
|
|
574
|
-
* stripped back to the root); `/v1` is appended during normalization. Intended
|
|
575
|
-
* for local development against a fake realtime server — plaintext `http`/`ws`
|
|
576
|
-
* is accepted only for loopback hosts, and URL userinfo is rejected; both
|
|
577
|
-
* failures close to the canonical `https://api.openai.com/v1`. Configured by
|
|
578
|
-
* editing this file; there is deliberately no management-API or GUI surface.
|
|
579
|
-
*/
|
|
580
|
-
experimentalRealtimeWsBaseUrl?: string;
|
|
581
|
-
/**
|
|
582
|
-
* Model ids the user has EXCLUDED from the Grok Build managed block. Absent or empty
|
|
583
|
-
* means "everything visible", which is the historical behaviour — so an existing
|
|
584
|
-
* config keeps the fence it already had.
|
|
585
|
-
*
|
|
586
|
-
* Exclusion list rather than an inclusion list on purpose: a newly added provider
|
|
587
|
-
* model should appear in Grok by default, exactly as it does today. An inclusion list
|
|
588
|
-
* would silently hide every future model behind a switch nobody knew to flip.
|
|
589
|
-
*/
|
|
590
|
-
grokExcludedModels?: string[];
|
|
591
|
-
/**
|
|
592
|
-
* When true, OpenAI-routed requests include `service_tier: "priority"` (fast inference).
|
|
593
|
-
* When false, service_tier is stripped so requests use default speed.
|
|
594
|
-
* Undefined = passthrough (don't modify what the client sends).
|
|
595
|
-
*/
|
|
596
|
-
fastMode?: boolean;
|
|
597
|
-
/**
|
|
598
|
-
* Windows/macOS SSE passthrough stream shape (#314 mitigation).
|
|
599
|
-
* On Windows, "auto" (default) selects eager relay only on a runtime proven
|
|
600
|
-
* to carry the Bun#32111 fix. On macOS, "auto" always stays on legacy tee and
|
|
601
|
-
* eager relay is explicit-only. "eager-relay" opts into the new relay (and
|
|
602
|
-
* accepts #32111 crash risk on Bun 1.3.14); "legacy-tee" pins the tee path.
|
|
603
|
-
* Persisted in config.json so service users can select the stream shape.
|
|
604
|
-
* See src/lib/bun-stream-caps.ts.
|
|
605
|
-
*/
|
|
606
|
-
streamMode?: "auto" | "legacy-tee" | "eager-relay";
|
|
607
|
-
/**
|
|
608
|
-
* Custom override for the injected multi-agent guidance body (the text inside the
|
|
609
|
-
* <multi_agent_mode> tags). When set, it replaces the built-in prompt on whichever
|
|
610
|
-
* collab surface would have fired; firing gates are unchanged. Placeholders:
|
|
611
|
-
* `{{model}}` -> injectionModel, `{{effort}}` -> injectionEffort, `{{roster}}` ->
|
|
612
|
-
* the resolved sub-agent roster block ("" when nothing resolves), `{{fallback}}` ->
|
|
613
|
-
* the configured subagent model fallback guidance block ("" when unset).
|
|
614
|
-
*/
|
|
615
|
-
injectionPrompt?: string;
|
|
616
|
-
/**
|
|
617
|
-
* Proxy-authored multi-agent developer guidance. Undefined/true = enabled for
|
|
618
|
-
* backward compatibility; false suppresses both v1 and v2 guidance injection.
|
|
619
|
-
*/
|
|
620
|
-
multiAgentGuidanceEnabled?: boolean;
|
|
621
|
-
/**
|
|
622
|
-
* Global hard ceiling for the reasoning effort of EVERY proxied turn (main agent AND
|
|
623
|
-
* sub-agents). Ladder value "low".."max"; incoming efforts ranking above it are rewritten
|
|
624
|
-
* in both request shapes before any adapter or clamp. Unset = no cap. codex-rs converts
|
|
625
|
-
* ultra -> max client-side, so e.g. a "high" cap sends ultra/max-tier turns as high.
|
|
626
|
-
*/
|
|
627
|
-
effortCap?: string;
|
|
628
|
-
/**
|
|
629
|
-
* Hard ceiling applied ONLY to sub-agent turns — requests carrying codex-rs's spawned-child
|
|
630
|
-
* markers (`x-openai-subagent` header, or `subagent_kind` inside `x-codex-turn-metadata`).
|
|
631
|
-
* Lets the main agent keep its tier while delegated children are capped. When both caps are
|
|
632
|
-
* set, the lower one wins for sub-agents. See src/server/effort-policy.ts.
|
|
633
|
-
*/
|
|
634
|
-
subagentEffortCap?: string;
|
|
635
|
-
/**
|
|
636
|
-
* Models hidden from Codex. Routed ids are namespaced ("<provider>/<model>") and are excluded
|
|
637
|
-
* from the catalog + /v1/models entirely. BARE ids (no "/") are native GPT passthrough slugs:
|
|
638
|
-
* their catalog entries flip to visibility "hide" (entry preserved, picker-hidden) and they
|
|
639
|
-
* are omitted from the bare /v1/models list.
|
|
640
|
-
*/
|
|
641
|
-
disabledModels?: string[];
|
|
642
|
-
/** 사용자가 대시보드에서 직접 추가한 커스텀 모델 목록. */
|
|
643
|
-
customModels?: OcxCustomModel[];
|
|
644
|
-
/**
|
|
645
|
-
* Shadow call intercept: redirect Codex's hard-coded helper calls (title generation,
|
|
646
|
-
* commit messages, skill orchestration) to a user-chosen model. Default intercepted
|
|
647
|
-
* source models: gpt-5.4-mini (older clients) and gpt-5.6-luna (Codex 0.145.0+).
|
|
648
|
-
* Opt-in; disabled by default. When enabled, effort is forced to low.
|
|
649
|
-
*/
|
|
650
|
-
shadowCallIntercept?: {
|
|
651
|
-
/** When true, requests for known shadow/helper source models are rewritten to the configured model. */
|
|
652
|
-
enabled?: boolean;
|
|
653
|
-
/** Replacement model id (e.g. "gpt-5.5"). */
|
|
654
|
-
model?: string;
|
|
655
|
-
/** Optional override of intercepted source-model prefixes (default: gpt-5.4-mini, gpt-5.6-luna). */
|
|
656
|
-
sourceModels?: string[];
|
|
657
|
-
};
|
|
658
|
-
/**
|
|
659
|
-
* 3-state multi-agent surface override:
|
|
660
|
-
* - "v1": force ALL models to v1 surface (override upstream pins)
|
|
661
|
-
* - "default" | undefined: respect upstream model pins (sol/terra=v2, luna=v1, rest=codex flag)
|
|
662
|
-
* - "v2": force ALL models to v2 surface (override upstream pins)
|
|
663
|
-
*/
|
|
664
|
-
multiAgentMode?: "v1" | "default" | "v2";
|
|
665
|
-
/** Provider-level Codex-visible context caps. Values only lower known model context windows. */
|
|
666
|
-
providerContextCaps?: Record<string, number>;
|
|
667
|
-
/** Global Codex-visible context cap value (tokens). Falls back to DEFAULT_PROVIDER_CONTEXT_CAP. */
|
|
668
|
-
contextCapValue?: number;
|
|
669
|
-
/** Bind hostname. Default "127.0.0.1" (loopback only). Set "0.0.0.0" to expose on all interfaces. */
|
|
670
|
-
hostname?: string;
|
|
671
|
-
/**
|
|
672
|
-
* Outbound HTTP(S) proxy URL for provider requests (e.g. "http://user:pass@proxy:8080", or
|
|
673
|
-
* "${HTTPS_PROXY}"-style env reference). Mirrored into HTTP_PROXY/HTTPS_PROXY at startup when
|
|
674
|
-
* those are unset — Bun's fetch honors them for all outbound calls; localhost is excluded.
|
|
675
|
-
*/
|
|
676
|
-
proxy?: string;
|
|
677
|
-
/**
|
|
678
|
-
* Upstream stall timeout (seconds). After this many seconds of no upstream data, emits
|
|
679
|
-
* response.incomplete. Default 300. Min 1.
|
|
680
|
-
*/
|
|
681
|
-
stallTimeoutSec?: number;
|
|
682
|
-
/** Connect timeout (ms) for upstream fetch — covers DNS, TCP, TLS, and response header. Default 200000. */
|
|
683
|
-
connectTimeoutMs?: number;
|
|
684
|
-
/** Graceful shutdown drain timeout (ms). Active turns are aborted after this deadline. Default 5000. */
|
|
685
|
-
shutdownTimeoutMs?: number;
|
|
686
|
-
/** Advertise supports_websockets so Codex opens the WS endpoint. Default false; set true to opt in. */
|
|
687
|
-
websockets?: boolean;
|
|
688
|
-
/**
|
|
689
|
-
* Opt-in auto-cleanup policy for archived Codex sessions (issue #42 Phase 3).
|
|
690
|
-
* Default OFF (`enabled` false / unset). Never enabled implicitly.
|
|
691
|
-
* See `src/storage/policy.ts`.
|
|
692
|
-
*/
|
|
693
|
-
storageCleanupPolicy?: StorageCleanupPolicy;
|
|
694
|
-
/** Generated API keys for external access to the proxy's /v1/responses endpoint. */
|
|
695
|
-
apiKeys?: OcxApiKeyEntry[];
|
|
696
|
-
/** Auto-start/sync the proxy from the Codex shim before launching Codex. Default true. */
|
|
697
|
-
codexAutoStart?: boolean;
|
|
698
|
-
/** Restore an installed shim after a stable external Codex update replaces it. Default true. */
|
|
699
|
-
codexShimAutoRestore?: boolean;
|
|
700
|
-
/**
|
|
701
|
-
* Compatibility mode: temporarily rewrite Codex resume-history metadata while the proxy is active
|
|
702
|
-
* so Codex App can show old OpenAI chats and opencodex-created exec chats under its default
|
|
703
|
-
* interactive-source/provider filters. Default true; originals are backed up and restored by
|
|
704
|
-
* `ocx stop` / `ocx restore`. Set false to opt out of history remapping.
|
|
705
|
-
*/
|
|
706
|
-
syncResumeHistory?: boolean;
|
|
707
|
-
/** Freshness window (ms) for the per-provider live `/models` cache. Defaults to 5 min. */
|
|
708
|
-
modelCacheTtlMs?: number;
|
|
709
|
-
/** Evictable retained app-state budget in MiB. Default 256; valid 64..4096. */
|
|
710
|
-
appOwnedMemoryBudgetMb?: number;
|
|
711
|
-
/** Anthropic prompt-cache retention: "short" = 5-min ephemeral (default), "long" = 1-hour extended, "none" = disabled. */
|
|
712
|
-
cacheRetention?: "none" | "short" | "long";
|
|
713
|
-
/** Web-search sidecar: route web_search for non-OpenAI models through a gpt-mini via ChatGPT passthrough. */
|
|
714
|
-
webSearchSidecar?: OcxWebSearchSidecarConfig;
|
|
715
|
-
/** Vision sidecar: describe images via a gpt vision model so text-only models can "see" them. */
|
|
716
|
-
visionSidecar?: OcxVisionSidecarConfig;
|
|
717
|
-
/** /v1/images relay for codex's built-in image_gen tool. */
|
|
718
|
-
images?: OcxImagesConfig;
|
|
719
|
-
/** /v1/alpha/search relay for codex's built-in web search client. */
|
|
720
|
-
search?: OcxSearchConfig;
|
|
721
|
-
/** Codex multi-account pool. */
|
|
722
|
-
codexAccounts?: CodexAccount[];
|
|
723
|
-
/** Account ids administratively excluded from future pool selection until resumed. */
|
|
724
|
-
pausedCodexAccountIds?: string[];
|
|
725
|
-
/**
|
|
726
|
-
* Public model-selector namespaces bound to one Codex account. Values are stored account ids;
|
|
727
|
-
* `"@main"` selects the Codex Desktop/main auth.json account. Account display aliases
|
|
728
|
-
* are intentionally separate from these selectors.
|
|
729
|
-
*/
|
|
730
|
-
codexAccountNamespaces?: Record<string, string>;
|
|
731
|
-
/** Active pool account id for next session. undefined = main (passthrough as-is). */
|
|
732
|
-
activeCodexAccountId?: string;
|
|
733
|
-
/** Auto-switch threshold (0-100). Default 80. 0 = disabled. */
|
|
734
|
-
autoSwitchThreshold?: number;
|
|
735
|
-
/** New-session account rotation strategy for the Codex pool. Default quota (today's behaviour). */
|
|
736
|
-
accountPoolStrategy?: OcxAccountPoolRotationStrategy;
|
|
737
|
-
/** Successful new-session binds retained on one round-robin selection. Default 1; range 1..100. */
|
|
738
|
-
accountPoolStickyLimit?: number;
|
|
739
|
-
/** Consecutive non-2xx upstream responses before switching future new threads. Default 3. 0 = disabled. */
|
|
740
|
-
upstreamFailoverThreshold?: number;
|
|
741
|
-
/**
|
|
742
|
-
* Opt-in Anthropic OAuth account pool (#294). Default OFF.
|
|
743
|
-
* Failover on 429 + sticky affinity; new sessions may pick lowest known 5h usage.
|
|
744
|
-
* Experimental — see docs and GUI warning before enabling.
|
|
745
|
-
*/
|
|
746
|
-
anthropicAccountPool?: {
|
|
747
|
-
enabled?: boolean;
|
|
748
|
-
/** Usage % threshold for new-session auto-pick. Default 80. 0 = disabled (affinity/active only). */
|
|
749
|
-
autoSwitchThreshold?: number;
|
|
750
|
-
/** New-session rotation strategy. Default quota (today's behaviour). */
|
|
751
|
-
strategy?: OcxAccountPoolRotationStrategy;
|
|
752
|
-
/** Successful new-session binds retained on one round-robin selection. Default 1; range 1..100. */
|
|
753
|
-
stickyLimit?: number;
|
|
754
|
-
};
|
|
755
|
-
/** Virtual `combo/<id>` models spanning concrete provider/model targets (issue #133). */
|
|
756
|
-
combos?: Record<string, OcxComboConfig>;
|
|
757
|
-
/** Background proactive token refresh ("Token Guardian"). Off by default; see OcxTokenGuardianConfig. */
|
|
758
|
-
tokenGuardian?: OcxTokenGuardianConfig;
|
|
759
|
-
/** Additional origins allowed for CORS (e.g. ["https://clisu-oracle.tail19a2d7.ts.net"]). Loopback origins are always allowed. */
|
|
760
|
-
corsAllowOrigins?: string[];
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
export type OcxAccountPoolRotationStrategy = "quota" | "round-robin" | "fill-first";
|
|
764
|
-
|
|
765
|
-
export type OcxComboStrategy = "failover" | "round-robin";
|
|
766
|
-
export type OcxComboDefaultEffort = "low" | "medium" | "high" | "xhigh" | "max" | "ultra";
|
|
767
|
-
|
|
768
|
-
export interface OcxComboTarget {
|
|
769
|
-
provider: string;
|
|
770
|
-
model: string;
|
|
771
|
-
/** Relative SWRR batch weight. Default 1; valid range 1..10000. */
|
|
772
|
-
weight?: number;
|
|
773
|
-
}
|
|
774
|
-
|
|
775
|
-
export interface OcxComboConfig {
|
|
776
|
-
targets: OcxComboTarget[];
|
|
777
|
-
/** Ordered failover (default) or deterministic smooth weighted round-robin. */
|
|
778
|
-
strategy?: OcxComboStrategy;
|
|
779
|
-
/** Successful requests retained on one RR selection batch. Default 1; range 1..100. */
|
|
780
|
-
stickyLimit?: number;
|
|
781
|
-
/** Used when the client omits reasoning.effort. null/omitted leaves the target default unchanged. */
|
|
782
|
-
defaultEffort?: OcxComboDefaultEffort | null;
|
|
783
|
-
/**
|
|
784
|
-
* Optional public model name replacing the default `combo/<id>` slug. Bare names
|
|
785
|
-
* without "/" are allowed (e.g. "deepseek-v4-flash") so the combo can answer to a
|
|
786
|
-
* mandated model id; exact-match requests route here before any provider resolution.
|
|
787
|
-
*/
|
|
788
|
-
alias?: string;
|
|
789
|
-
}
|
|
790
|
-
|
|
791
|
-
/**
|
|
792
|
-
* Per-provider proactive-refresh policy. The guardian only ever touches a provider whose EFFECTIVE
|
|
793
|
-
* policy is "proactive"; "lazy-only" keeps today's on-demand refresh, "disabled" forbids the
|
|
794
|
-
* guardian entirely (used for providers whose ToS actively enforces against non-official-client
|
|
795
|
-
* token traffic, e.g. Anthropic subscription OAuth). See devlog 260703_oauth-multi-account-refresh-and-tos.
|
|
796
|
-
*/
|
|
797
|
-
export type RefreshPolicy = "proactive" | "lazy-only" | "disabled";
|
|
798
|
-
|
|
799
|
-
export interface OcxTokenGuardianConfig {
|
|
800
|
-
/** Global kill-switch. Default false — the guardian does nothing unless explicitly enabled. */
|
|
801
|
-
enabled?: boolean;
|
|
802
|
-
/** Seconds between refresh sweeps. Default 21600 (6h). Min 60. */
|
|
803
|
-
tickSeconds?: number;
|
|
804
|
-
/** Random 0..jitterSeconds added before each sweep to de-synchronize. Default 300. */
|
|
805
|
-
jitterSeconds?: number;
|
|
806
|
-
/** Max concurrent refreshes per sweep. Default 3. Min 1. */
|
|
807
|
-
concurrency?: number;
|
|
808
|
-
/** Extra lead (seconds) beyond one tick when deciding a token is "expiring soon". Default 900. */
|
|
809
|
-
leadSeconds?: number;
|
|
810
|
-
/** First backoff (seconds) after a permanent refresh failure. Default 300. */
|
|
811
|
-
failureBackoffBaseSeconds?: number;
|
|
812
|
-
/** Backoff ceiling (seconds). Default 3600. */
|
|
813
|
-
failureBackoffMaxSeconds?: number;
|
|
814
|
-
/** Optional Codex pool session warmup sweep. Default false to avoid background synthetic traffic. */
|
|
815
|
-
codexWarmupEnabled?: boolean;
|
|
816
|
-
/** Max age before a Codex pool account is revalidated via `/codex/responses`. Default 691200 (8d). */
|
|
817
|
-
codexWarmupMaxAgeSeconds?: number;
|
|
818
|
-
/** Model used for optional Codex pool warmup. Default gpt-5.4-mini. */
|
|
819
|
-
codexWarmupModel?: string;
|
|
820
|
-
}
|
|
821
|
-
|
|
822
|
-
export interface OcxImagesConfig {
|
|
823
|
-
/** Optional custom API-key provider for /v1/images relays. Built-in OpenAI tiers remain automatic. */
|
|
824
|
-
provider?: string;
|
|
825
|
-
/** Upstream timeout (ms) for one image generation/edit call (bridge xAI + /v1/images relay). Default 60000 for the bridge; relay may use a higher default (300000). */
|
|
826
|
-
timeoutMs?: number;
|
|
827
|
-
/** Master switch for the image bridge. Default false — set true to enable paid xAI Grok Imagine generation. */
|
|
828
|
-
bridgeEnabled?: boolean;
|
|
829
|
-
/** xAI image model id. Default "grok-imagine-image-quality" (see DEFAULT_MODEL in images/plan.ts). */
|
|
830
|
-
bridgeModel?: string;
|
|
831
|
-
/** Max image-generation loop iterations before forced-final. Default 3; clamped to [0, 10]. */
|
|
832
|
-
maxRounds?: number;
|
|
833
|
-
/** Max files retained under artifacts/. Oldest deleted when exceeded. Default 200. */
|
|
834
|
-
artifactsKeepCount?: number;
|
|
835
|
-
/** Master switch for the video bridge. Default false — must be explicitly opted in. */
|
|
836
|
-
videoBridgeEnabled?: boolean;
|
|
837
|
-
/** Model for xAI video generation. Default "grok-imagine-video". */
|
|
838
|
-
videoBridgeModel?: string;
|
|
839
|
-
/** Max video-gen rounds before forced-final. Default 2 (video is slower than image). */
|
|
840
|
-
videoMaxRounds?: number;
|
|
841
|
-
/** Per-video generation timeout (ms) including polling. Default 300000 (5 min). */
|
|
842
|
-
videoTimeoutMs?: number;
|
|
843
|
-
}
|
|
844
|
-
|
|
845
|
-
export interface OcxSearchConfig {
|
|
846
|
-
/**
|
|
847
|
-
* Total upstream deadline (ms) for one /v1/alpha/search relay. Default 200000. The endpoint
|
|
848
|
-
* is non-streaming JSON (headers arrive only when the search completes), so this is a whole-
|
|
849
|
-
* request budget — deliberately NOT connectTimeoutMs, which is a header-arrival budget.
|
|
850
|
-
*/
|
|
851
|
-
timeoutMs?: number;
|
|
852
|
-
}
|
|
853
|
-
|
|
854
|
-
export interface OcxVisionSidecarConfig {
|
|
855
|
-
/** Master switch. Default: enabled when the selected backend has a usable credential. */
|
|
856
|
-
enabled?: boolean;
|
|
857
|
-
/** Description backend. Unset prefers a usable stored Anthropic OAuth credential, else OpenAI. */
|
|
858
|
-
backend?: "openai" | "anthropic";
|
|
859
|
-
/** Vision model that describes images. */
|
|
860
|
-
model?: string;
|
|
861
|
-
/** Max description cache misses admitted in one main-model turn. Zero disables description calls. */
|
|
862
|
-
maxDescriptionsPerTurn?: number;
|
|
863
|
-
/** Sidecar fetch timeout (ms). */
|
|
864
|
-
timeoutMs?: number;
|
|
865
|
-
}
|
|
866
|
-
|
|
867
|
-
export interface OcxWebSearchSidecarConfig {
|
|
868
|
-
/** Master switch. Default: enabled when a forward (ChatGPT) provider exists and the caller is logged in. */
|
|
869
|
-
enabled?: boolean;
|
|
870
|
-
/**
|
|
871
|
-
* Which backend actually runs the server-side search. "openai" replays the hosted web_search via
|
|
872
|
-
* the ChatGPT forward provider (gpt-mini sidecar); "anthropic" runs web_search_20250305 on a Claude
|
|
873
|
-
* model authenticated by the STORED anthropic OAuth credential. Unset resolves to "anthropic" when a
|
|
874
|
-
* usable anthropic OAuth credential exists, else "openai".
|
|
875
|
-
*/
|
|
876
|
-
backend?: "openai" | "anthropic";
|
|
877
|
-
/** Sidecar model that runs the real server-side web_search (must be a native ChatGPT model). */
|
|
878
|
-
model?: string;
|
|
879
|
-
/** Reasoning effort for the sidecar — "minimal" (non-thinking) keeps it fast/cheap. */
|
|
880
|
-
reasoning?: string;
|
|
881
|
-
/** Max searches executed per main-model turn (loop guard). */
|
|
882
|
-
maxSearchesPerTurn?: number;
|
|
883
|
-
/** Sidecar fetch timeout (ms). */
|
|
884
|
-
timeoutMs?: number;
|
|
885
|
-
/**
|
|
886
|
-
* Config-file-only deadline (ms) for continuous routed-model response-body raw-byte inactivity
|
|
887
|
-
* during a web-search turn. Default 200000. Must be an integer from 1 through 2147483647.
|
|
888
|
-
*/
|
|
889
|
-
routedModelStallTimeoutMs?: number;
|
|
890
|
-
}
|
|
891
|
-
|
|
892
|
-
export interface OpenRouterProviderRouting {
|
|
893
|
-
/** OpenRouter provider slugs to try first, in priority order. */
|
|
894
|
-
order?: string[];
|
|
895
|
-
/** Restrict routing to these OpenRouter provider slugs. */
|
|
896
|
-
only?: string[];
|
|
897
|
-
/** Whether OpenRouter may use providers outside `order`. Defaults to OpenRouter's policy. */
|
|
898
|
-
allowFallbacks?: boolean;
|
|
899
|
-
}
|
|
900
|
-
|
|
901
|
-
export interface ResponsesItemIdRepairConfig {
|
|
902
|
-
/** Exact `message` item ids that the proxy should rewrite to request-local canonical ids. */
|
|
903
|
-
message?: string[];
|
|
904
|
-
/** Exact `reasoning` item ids that the proxy should rewrite to request-local canonical ids. */
|
|
905
|
-
reasoning?: string[];
|
|
906
|
-
/** Backfill missing `output_item.done` / terminal snapshot ids from the matching output_index. */
|
|
907
|
-
repairMissingTerminalIds?: boolean;
|
|
908
|
-
}
|
|
909
|
-
|
|
910
|
-
export interface OcxProviderConfig {
|
|
911
|
-
adapter: string;
|
|
912
|
-
/** Cursor MCP compatibility bounds; positive integers when configured. */
|
|
913
|
-
mcpMaxTools?: number;
|
|
914
|
-
mcpMaxSchemaBytes?: number;
|
|
915
|
-
mcpMaxResultBytes?: number;
|
|
916
|
-
/**
|
|
917
|
-
* Per-model wire override, keyed by the upstream native model id (after namespace
|
|
918
|
-
* and combo resolution). A single gateway can front models that speak different
|
|
919
|
-
* wires — Grok needs the Responses API for hosted web_search while a sibling model
|
|
920
|
-
* is fine on chat completions (#404).
|
|
921
|
-
*
|
|
922
|
-
* Only OpenAI-shaped wires may be selected; see MODEL_ADAPTER_OVERRIDE_ALLOWED.
|
|
923
|
-
* Absent or empty means the provider-wide `adapter` applies to everything, exactly
|
|
924
|
-
* as before.
|
|
925
|
-
*/
|
|
926
|
-
modelAdapters?: Record<string, string>;
|
|
927
|
-
baseUrl: string;
|
|
928
|
-
/**
|
|
929
|
-
* Optional relative resource path for key-auth openai-responses requests. Must start with `/`
|
|
930
|
-
* and must not include a URL scheme, query string, or fragment. When omitted, the adapter keeps
|
|
931
|
-
* the legacy `/v1/responses` construction.
|
|
932
|
-
*/
|
|
933
|
-
responsesPath?: string;
|
|
934
|
-
/**
|
|
935
|
-
* Responses upstream that stores nothing server-side (DeepSeek documents "the API
|
|
936
|
-
* is stateless"). Stateful request parameters are dropped, `store` is pinned false,
|
|
937
|
-
* and orphaned tool results left by a replay miss are repaired rather than
|
|
938
|
-
* forwarded to an upstream that cannot resolve their pair.
|
|
939
|
-
*/
|
|
940
|
-
statelessResponses?: boolean;
|
|
941
|
-
/**
|
|
942
|
-
* Explicit opt-in for non-registry private-network destinations such as localhost, RFC1918,
|
|
943
|
-
* link-local, or unique-local upstreams. Metadata endpoints remain blocked.
|
|
944
|
-
*/
|
|
945
|
-
allowPrivateNetwork?: boolean;
|
|
946
|
-
/** Keep provider settings on disk but exclude it from routing and model/catalog listings. */
|
|
947
|
-
disabled?: boolean;
|
|
948
|
-
/**
|
|
949
|
-
* Codex account-selection mode. Valid ONLY on the canonical built-in `openai` forward provider.
|
|
950
|
-
* "pool" (default) rotates main + added Codex accounts through the affinity/quota/cooldown/
|
|
951
|
-
* failover engine; "direct" pins the caller's main Codex login and never touches pool state.
|
|
952
|
-
*/
|
|
953
|
-
codexAccountMode?: CodexAccountMode;
|
|
954
|
-
apiKey?: string;
|
|
955
|
-
/**
|
|
956
|
-
* Key-auth header style for Anthropic-compatible providers.
|
|
957
|
-
* Defaults to the native Anthropic `x-api-key`; gateways may require
|
|
958
|
-
* `Authorization: Bearer <key>` instead.
|
|
959
|
-
*/
|
|
960
|
-
apiKeyTransport?: "x-api-key" | "bearer";
|
|
961
|
-
/**
|
|
962
|
-
* Multi-key pool (API-key twin of OAuth multiauth). `apiKey` always mirrors the ACTIVE
|
|
963
|
-
* entry so routing stays single-key; managed via /api/providers/keys. A legacy bare
|
|
964
|
-
* `apiKey` seeds a one-entry pool on first management touch.
|
|
965
|
-
*/
|
|
966
|
-
apiKeyPool?: Array<{ id: string; key: string; label?: string; addedAt?: number }>;
|
|
967
|
-
defaultModel?: string;
|
|
968
|
-
models?: string[];
|
|
969
|
-
/**
|
|
970
|
-
* Fetch the provider's live `/models` endpoint. Defaults to true.
|
|
971
|
-
* Set false when `models` is an intentional allowlist or a provider's live catalog is too large
|
|
972
|
-
* or too flaky for startup/catalog sync.
|
|
973
|
-
*/
|
|
974
|
-
liveModels?: boolean;
|
|
975
|
-
/**
|
|
976
|
-
* Per-provider catalog allowlist. When non-empty, ONLY these model ids are emitted to Codex's
|
|
977
|
-
* catalog and `/v1/models` — live discovery still runs, this just narrows what ships (so a proxy
|
|
978
|
-
* exposing thousands of models, or an aggregator like OpenRouter, doesn't bloat the catalog).
|
|
979
|
-
* Empty/undefined = expose all. The admin `/api/models` list is unaffected (it always shows the
|
|
980
|
-
* full set so the user can pick). See devlog issue_052_provider-model-allowlist.
|
|
981
|
-
*/
|
|
982
|
-
selectedModels?: string[];
|
|
983
|
-
/** Provider-wide Codex-visible context-window cap for routed catalog entries. */
|
|
984
|
-
contextWindow?: number;
|
|
985
|
-
/** Model-specific Codex-visible context-window caps. Values cap live metadata, never raise it. */
|
|
986
|
-
modelContextWindows?: Record<string, number>;
|
|
987
|
-
/** Model-specific Codex catalog input modalities, e.g. ["text"] or ["text", "image"]. */
|
|
988
|
-
modelInputModalities?: Record<string, string[]>;
|
|
989
|
-
/** Model-specific max input token limits. Values cap auto_compact_token_limit. */
|
|
990
|
-
modelMaxInputTokens?: Record<string, number>;
|
|
991
|
-
/**
|
|
992
|
-
* Provider-wide fallback for chat-completions `max_tokens` when the caller omits
|
|
993
|
-
* Responses `max_output_tokens`. Adapters still let an explicit request win.
|
|
994
|
-
*/
|
|
995
|
-
defaultMaxOutputTokens?: number;
|
|
996
|
-
/** Model-specific fallback output token budgets. Exact/model-pattern entries beat the provider default. */
|
|
997
|
-
modelMaxOutputTokens?: Record<string, number>;
|
|
998
|
-
headers?: Record<string, string>;
|
|
999
|
-
/** Default provider-routing preferences for models sent through the canonical OpenRouter API. */
|
|
1000
|
-
openRouterRouting?: OpenRouterProviderRouting;
|
|
1001
|
-
/** Exact model-id overrides for `openRouterRouting`. Each matching entry replaces the default. */
|
|
1002
|
-
modelOpenRouterRouting?: Record<string, OpenRouterProviderRouting>;
|
|
1003
|
-
/**
|
|
1004
|
-
* "key" (default): authenticate upstream with `apiKey`.
|
|
1005
|
-
* "forward": relay the caller's incoming auth headers verbatim (OAuth passthrough; gpt only).
|
|
1006
|
-
* "oauth": resolve a stored OAuth access token (auto-refreshed) and use it as the Bearer key.
|
|
1007
|
-
* Only the openai-responses adapter implements "forward"; openai-chat uses its own key/token.
|
|
1008
|
-
* "local": local runtime (Ollama etc.) — no remote key required. Valid only for
|
|
1009
|
-
* providers whose registry entry declares authKind "local" (management API enforces).
|
|
1010
|
-
*/
|
|
1011
|
-
authMode?: "key" | "forward" | "oauth" | "local";
|
|
1012
|
-
/** Allow an explicitly key/oauth provider to run without a credential (for keyless local proxies). */
|
|
1013
|
-
keyOptional?: boolean;
|
|
1014
|
-
/**
|
|
1015
|
-
* Free-tier pricing flag for UI/catalog (Free badge, Free filter). Not the same as
|
|
1016
|
-
* `keyOptional` — free tiers may still require an API key (e.g. NVIDIA NIM free credits).
|
|
1017
|
-
*/
|
|
1018
|
-
freeTier?: boolean;
|
|
1019
|
-
/** Optional human note shown in the providers UI (not used for routing). */
|
|
1020
|
-
note?: string;
|
|
1021
|
-
/** Strip one trailing bracketed suffix from model ids before sending them upstream. */
|
|
1022
|
-
modelSuffixBracketStrip?: boolean;
|
|
1023
|
-
/**
|
|
1024
|
-
* Override the guardian's proactive-refresh policy for this provider. When unset, the provider's
|
|
1025
|
-
* built-in risk-tiered default applies (see OAUTH_PROVIDERS in src/oauth/index.ts). Set "proactive"
|
|
1026
|
-
* to opt this provider into background refresh; "disabled"/"lazy-only" to forbid/limit it.
|
|
1027
|
-
*/
|
|
1028
|
-
refreshPolicy?: RefreshPolicy;
|
|
1029
|
-
/**
|
|
1030
|
-
* Provider-wide Codex-visible reasoning tiers for routed models. Use only Codex-supported labels
|
|
1031
|
-
* here (`low`, `medium`, `high`, `xhigh`, `max`); translate provider aliases with
|
|
1032
|
-
* `reasoningEffortMap` / `modelReasoningEffortMap` below.
|
|
1033
|
-
*/
|
|
1034
|
-
reasoningEfforts?: string[];
|
|
1035
|
-
/** Model-specific Codex-visible reasoning tiers. An empty array means “do not expose effort”. */
|
|
1036
|
-
modelReasoningEfforts?: Record<string, string[]>;
|
|
1037
|
-
/** Model-specific default Codex reasoning tier; must also be present in the visible tier list. */
|
|
1038
|
-
modelDefaultReasoningEfforts?: Record<string, string>;
|
|
1039
|
-
/**
|
|
1040
|
-
* Model-specific Codex reasoning-summary capability. Set false when an OpenAI-compatible
|
|
1041
|
-
* Responses backend rejects Codex summary-delivery fields for that model.
|
|
1042
|
-
*/
|
|
1043
|
-
modelSupportsReasoningSummaries?: Record<string, boolean>;
|
|
1044
|
-
/**
|
|
1045
|
-
* Per-model wire value for Responses `stream_options.reasoning_summary_delivery`.
|
|
1046
|
-
* Presence also advertises reasoning-summary support for that routed model.
|
|
1047
|
-
*/
|
|
1048
|
-
modelReasoningSummaryDelivery?: Record<string, ReasoningSummaryDelivery>;
|
|
1049
|
-
/** Provider-wide mapping from Codex effort labels to upstream `reasoning_effort` values. */
|
|
1050
|
-
reasoningEffortMap?: Record<string, string>;
|
|
1051
|
-
/** Model-specific mapping from Codex effort labels to upstream `reasoning_effort` values. */
|
|
1052
|
-
modelReasoningEffortMap?: Record<string, Record<string, string>>;
|
|
1053
|
-
/**
|
|
1054
|
-
* Model ids that do NOT support a reasoning/thinking parameter. The openai-chat adapter drops
|
|
1055
|
-
* reasoning_effort for these even when Codex selects a reasoning level (e.g. xAI grok-build-0.1).
|
|
1056
|
-
*/
|
|
1057
|
-
noReasoningModels?: string[];
|
|
1058
|
-
/** Model ids that reject caller-specified temperature. */
|
|
1059
|
-
noTemperatureModels?: string[];
|
|
1060
|
-
/** Model ids that reject caller-specified top_p. */
|
|
1061
|
-
noTopPModels?: string[];
|
|
1062
|
-
/** Model ids that reject caller-specified presence/frequency penalty values. */
|
|
1063
|
-
noPenaltyModels?: string[];
|
|
1064
|
-
/**
|
|
1065
|
-
* Allow multiple tool calls per completion. DEFAULT-ON for openai-chat providers (the
|
|
1066
|
-
* buffered stream parser assembles interleaved/fragmented multi-call turns safely);
|
|
1067
|
-
* set `false` to force `parallel_tool_calls:false` upstream and drop the catalog's
|
|
1068
|
-
* `supports_parallel_tool_calls` bit for that provider. Non-chat adapters advertise
|
|
1069
|
-
* only on explicit `true`. See devlog/_plan/260709_parallel_tool_calls.
|
|
1070
|
-
*/
|
|
1071
|
-
parallelToolCalls?: boolean;
|
|
1072
|
-
/**
|
|
1073
|
-
* Opt-in: forward `prompt_cache_key` to the upstream `/chat/completions` body.
|
|
1074
|
-
* OpenAI-specific extension; strict backends (Groq, Cerebras, etc.) reject unknown
|
|
1075
|
-
* fields. Default off; only enable for providers that document this parameter.
|
|
1076
|
-
*/
|
|
1077
|
-
promptCacheKey?: boolean;
|
|
1078
|
-
/**
|
|
1079
|
-
* Provider-local passthrough SSE repair for broken openai-responses gateways that reuse exact
|
|
1080
|
-
* placeholder message/reasoning ids or omit the terminal id after a stable added event.
|
|
1081
|
-
* Disabled by default; function_call ids and call_id pairing are never rewritten.
|
|
1082
|
-
*/
|
|
1083
|
-
responsesItemIdRepair?: ResponsesItemIdRepairConfig;
|
|
1084
|
-
/** Model ids whose tool_choice only accepts `auto` or `none`; forced/named choices are downgraded. */
|
|
1085
|
-
autoToolChoiceOnlyModels?: string[];
|
|
1086
|
-
/** Model ids that expect prior assistant `reasoning_content` to be preserved in chat history. */
|
|
1087
|
-
preserveReasoningContentModels?: string[];
|
|
1088
|
-
/**
|
|
1089
|
-
* Model ids whose OpenAI-compatible chat endpoint accepts `reasoning_split: true` and returns
|
|
1090
|
-
* thinking separately in `reasoning_content` / `reasoning_details` instead of visible content.
|
|
1091
|
-
*/
|
|
1092
|
-
reasoningSplitModels?: string[];
|
|
1093
|
-
/**
|
|
1094
|
-
* Model ids whose reasoning is a vendor `thinking: {type}` toggle on the
|
|
1095
|
-
* chat-completions wire (MiMo v2.x, GLM 5/5.1 style), NOT an OpenAI `reasoning_effort` ladder.
|
|
1096
|
-
* The openai-chat adapter translates the mapped effort into the thinking toggle for these.
|
|
1097
|
-
*/
|
|
1098
|
-
thinkingToggleModels?: string[];
|
|
1099
|
-
/**
|
|
1100
|
-
* Model ids whose reasoning is a `thinking_budget` integer on the chat-completions wire
|
|
1101
|
-
* (Qwen3.x style), NOT an OpenAI `reasoning_effort` ladder. The openai-chat adapter maps the
|
|
1102
|
-
* Codex effort to a budget fraction.
|
|
1103
|
-
*/
|
|
1104
|
-
thinkingBudgetModels?: string[];
|
|
1105
|
-
/** Anthropic-compatible gateways that need custom tool names escaped on the wire. */
|
|
1106
|
-
escapeBuiltinToolNames?: boolean;
|
|
1107
|
-
/**
|
|
1108
|
-
* Model ids that do NOT accept image inputs. The proxy gives them "eyes" via the vision sidecar:
|
|
1109
|
-
* attached images are described by a gpt vision model and replaced with text before the call.
|
|
1110
|
-
*/
|
|
1111
|
-
noVisionModels?: string[];
|
|
1112
|
-
/**
|
|
1113
|
-
* Google adapter mode. "ai-studio" (default) = Generative Language API + x-goog-api-key.
|
|
1114
|
-
* "vertex" = Vertex AI project/location endpoints with GCP ADC (or x-goog-api-key).
|
|
1115
|
-
* "cloud-code-assist" = Google Antigravity (Cloud Code Assist) OAuth + CCA envelope.
|
|
1116
|
-
*/
|
|
1117
|
-
googleMode?: "ai-studio" | "vertex" | "cloud-code-assist";
|
|
1118
|
-
/** Vertex AI GCP project id (or GOOGLE_CLOUD_PROJECT / GCLOUD_PROJECT env). */
|
|
1119
|
-
project?: string;
|
|
1120
|
-
/** Vertex AI location, e.g. "us-central1" or "global" (or GOOGLE_CLOUD_LOCATION env). */
|
|
1121
|
-
location?: string;
|
|
1122
|
-
/**
|
|
1123
|
-
* Cursor adapter only: MCP servers opencodex starts/connects and exposes to the Cursor agent
|
|
1124
|
-
* as callable tools. Each entry is spawned (stdio `command`) or connected (`url`) lazily per
|
|
1125
|
-
* stream; their tools are advertised to the Cursor server and executed against the live server.
|
|
1126
|
-
*/
|
|
1127
|
-
mcpServers?: Record<string, import("./adapters/cursor/mcp-config").CursorMcpServerConfig>;
|
|
1128
|
-
/**
|
|
1129
|
-
* Cursor adapter only: opt-in external executor for computer-use / record-screen. opencodex is
|
|
1130
|
-
* headless and cannot control a screen itself; provide commands here only when running on a host
|
|
1131
|
-
* that can. With no executor, these tools honestly report "not supported".
|
|
1132
|
-
*/
|
|
1133
|
-
desktopExecutor?: import("./adapters/cursor/native-exec-desktop").DesktopExecutorConfig;
|
|
1134
|
-
/**
|
|
1135
|
-
* Cursor adapter only: unsafe opt-in escape hatch for Cursor server-driven built-in local
|
|
1136
|
-
* read/write/delete/ls/grep/shell/fetch execution. Prefer `nativeLocalExec: "on"` for new
|
|
1137
|
-
* configs; this legacy boolean remains a server-local explicit opt-in for existing operators.
|
|
1138
|
-
* Defaults to false so remote Cursor messages cannot bypass Codex approval/sandbox semantics.
|
|
1139
|
-
* Explicit MCP and desktop executors remain controlled by their own opt-in config.
|
|
1140
|
-
*/
|
|
1141
|
-
unsafeAllowNativeLocalExec?: boolean;
|
|
1142
|
-
/**
|
|
1143
|
-
* Cursor adapter only: native local exec policy mode (exec-policy.ts).
|
|
1144
|
-
* "off" (default) rejects server-driven local exec; "on" always allows it for this
|
|
1145
|
-
* provider and should be used only for a trusted local experiment on a host where every
|
|
1146
|
-
* data-plane caller is trusted. "codex-sandbox" is accepted for backwards compatibility
|
|
1147
|
-
* but is fail-closed like "off": Responses instructions/system/developer text is
|
|
1148
|
-
* caller-controlled prose, and opencodex has no trustworthy per-request attestation that it
|
|
1149
|
-
* reflects a real Codex sandbox state. The default loopback bind admits ANY local process
|
|
1150
|
-
* without auth (including other local users on multi-user machines), and
|
|
1151
|
-
* isAllowedRequestOrigin blocks non-loopback browser origins by default but not
|
|
1152
|
-
* loopback-origin or origin-less callers.
|
|
1153
|
-
*/
|
|
1154
|
-
nativeLocalExec?: "off" | "codex-sandbox" | "on";
|
|
1155
|
-
}
|
|
1156
|
-
|
|
1157
|
-
export const REASONING_SUMMARY_DELIVERY_VALUES = [
|
|
1158
|
-
"sequential",
|
|
1159
|
-
"sequential_cutoff",
|
|
1160
|
-
"concurrent",
|
|
1161
|
-
"concurrent_cutoff",
|
|
1162
|
-
] as const;
|
|
1163
|
-
|
|
1164
|
-
export type ReasoningSummaryDelivery = typeof REASONING_SUMMARY_DELIVERY_VALUES[number];
|
|
1165
|
-
|
|
1166
|
-
/** Trusted runtime ownership for Codex-account credentials. Never persisted per provider. */
|
|
1167
|
-
export type CodexAccountMode = "direct" | "pool";
|
|
1168
|
-
|
|
1169
|
-
export const OPENAI_PROVIDER_TIER_VERSION = 2 as const;
|
|
1170
|
-
|
|
1171
|
-
/**
|
|
1172
|
-
* Wires that a per-model `modelAdapters` override may select.
|
|
1173
|
-
*
|
|
1174
|
-
* Deliberately narrow: provider-specific adapters (cursor, kiro, google, ...) carry
|
|
1175
|
-
* their own credential and base-URL semantics, so exposing them here would widen the
|
|
1176
|
-
* auth boundary rather than pick a wire. Widening this set needs a per-adapter
|
|
1177
|
-
* credential threat model first (#404).
|
|
1178
|
-
*/
|
|
1179
|
-
export const MODEL_ADAPTER_OVERRIDE_ALLOWED: ReadonlySet<string> = new Set([
|
|
1180
|
-
"openai-chat",
|
|
1181
|
-
"openai-responses",
|
|
1182
|
-
]);
|
|
1183
|
-
|
|
1184
|
-
/**
|
|
1185
|
-
* Providers whose listed model ids must be driven over the Anthropic wire even when
|
|
1186
|
-
* the provider's configured adapter says otherwise — the upstream only speaks
|
|
1187
|
-
* Anthropic for these models.
|
|
1188
|
-
*/
|
|
1189
|
-
const ANTHROPIC_WIRE_MODELS: Record<string, ReadonlySet<string>> = {
|
|
1190
|
-
"opencode-go": new Set(["minimax-m2.5", "minimax-m2.7", "minimax-m3"]),
|
|
1191
|
-
};
|
|
1192
|
-
|
|
1193
|
-
/**
|
|
1194
|
-
* True when the upstream speaks exactly one wire for this model, so a configured
|
|
1195
|
-
* override must not apply.
|
|
1196
|
-
*
|
|
1197
|
-
* Deliberately independent of the provider's current adapter: the wire resolver runs
|
|
1198
|
-
* more than once per request, and a check phrased as "pin differs from the current
|
|
1199
|
-
* adapter" would pass on the first pass and then let the override win on the second.
|
|
1200
|
-
*/
|
|
1201
|
-
export function isWirePinnedModel(providerName: string, modelId: string): boolean {
|
|
1202
|
-
return ANTHROPIC_WIRE_MODELS[providerName]?.has(modelId) ?? false;
|
|
1203
|
-
}
|
|
1204
|
-
|
|
1205
|
-
/** The wire a pinned model must use, or undefined when the model is not pinned. */
|
|
1206
|
-
export function pinnedWireAdapter(providerName: string, modelId: string): string | undefined {
|
|
1207
|
-
return isWirePinnedModel(providerName, modelId) ? "anthropic" : undefined;
|
|
1208
|
-
}
|
|
1209
|
-
|
|
1210
|
-
export interface CodexAccount {
|
|
1211
|
-
id: string;
|
|
1212
|
-
email: string;
|
|
1213
|
-
/** User-owned display label; never participates in routing or identity checks. */
|
|
1214
|
-
alias?: string;
|
|
1215
|
-
plan?: string;
|
|
1216
|
-
chatgptAccountId?: string;
|
|
1217
|
-
logLabel?: string;
|
|
1218
|
-
isMain: boolean;
|
|
1219
|
-
}
|
|
1220
|
-
|
|
1221
|
-
export interface CodexAccountCredentials {
|
|
1222
|
-
accessToken: string;
|
|
1223
|
-
refreshToken: string;
|
|
1224
|
-
expiresAt: number;
|
|
1225
|
-
chatgptAccountId: string;
|
|
1226
|
-
}
|
|
1227
|
-
|
|
1228
|
-
export interface CodexAccountCredentialRecord {
|
|
1229
|
-
credential?: CodexAccountCredentials;
|
|
1230
|
-
generation: number;
|
|
1231
|
-
refreshGrantFingerprint?: string;
|
|
1232
|
-
deletedAt?: number;
|
|
1233
|
-
replacedAt?: number;
|
|
1234
|
-
lastCodexValidatedAt?: number;
|
|
1235
|
-
lastCodexValidationStatus?: "ok" | "failed";
|
|
1236
|
-
lastCodexValidationError?: string;
|
|
1237
|
-
}
|