@bitkyc08/opencodex 2.84.0 → 2.86.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/README.md +0 -4
- package/bin/ocx.mjs +61 -3
- package/gui/dist/assets/App-BjlttVLy.js +58 -0
- package/gui/dist/assets/{Tray-C9TGtwad.js → Tray-DyR9yBee.js} +1 -1
- package/gui/dist/assets/index-BMssP4k3.js +94 -0
- package/gui/dist/assets/quota-summary-D8M1bc_R.js +1 -0
- package/gui/dist/index.html +1 -1
- package/package.json +1 -2
- package/src/adapters/anthropic/beta-allowlist.ts +87 -8
- package/src/adapters/anthropic/client-identity.ts +1 -1
- package/src/adapters/anthropic/passthrough.ts +33 -4
- package/src/adapters/azure.ts +19 -1
- package/src/adapters/client-fingerprint.ts +24 -0
- package/src/adapters/coding-agent/turn.ts +22 -9
- package/src/adapters/cursor/arg-codec.ts +17 -5
- package/src/adapters/cursor/catalog.ts +8 -0
- package/src/adapters/cursor/effort-map.ts +3 -0
- package/src/adapters/cursor/freeform-args.ts +75 -0
- package/src/adapters/cursor/protobuf-events.ts +36 -23
- package/src/adapters/google-antigravity-wire.ts +22 -1
- package/src/adapters/google.ts +2 -2
- package/src/adapters/openai-chat/response-events.ts +59 -1
- package/src/adapters/openai-chat.ts +8 -5
- package/src/adapters/qoder/adapter.ts +40 -1
- package/src/advisor/consult.ts +220 -0
- package/src/advisor/context.ts +226 -0
- package/src/advisor/disclosure.ts +20 -0
- package/src/advisor/runtime.ts +305 -0
- package/src/advisor/settings.ts +135 -0
- package/src/advisor/state.ts +369 -0
- package/src/advisor/synthetic-tool.ts +33 -0
- package/src/bridge/errors.ts +5 -0
- package/src/chat/inbound.ts +30 -6
- package/src/chat/outbound.ts +5 -0
- package/src/claude/desktop-3p-library.ts +43 -3
- package/src/claude/desktop-3p.ts +22 -8
- package/src/claude/desktop-picker-profile.ts +11 -4
- package/src/claude/desktop-profile.ts +10 -1
- package/src/claude/desktop-remote-store-io.ts +5 -3
- package/src/claude/inbound.ts +121 -50
- package/src/claude/intercept/local-ca.ts +8 -1
- package/src/claude/model-default-settings.ts +154 -0
- package/src/claude/model-info.ts +7 -7
- package/src/claude/outbound.ts +13 -6
- package/src/cli/advisor.ts +151 -0
- package/src/cli/auxiliary-listener-preflight.ts +37 -0
- package/src/cli/capabilities-agents-routing.ts +18 -0
- package/src/cli/capabilities-base.ts +1 -1
- package/src/cli/chatgpt-command.ts +35 -14
- package/src/cli/claude.ts +46 -6
- package/src/cli/dispatch.ts +5 -1
- package/src/cli/doctor.ts +9 -0
- package/src/cli/ensure-desktop-cold-start.ts +329 -0
- package/src/cli/export-command.ts +1 -1
- package/src/cli/help.ts +2 -1
- package/src/cli/index.ts +13 -4
- package/src/cli/integration-plan-dto.ts +2 -0
- package/src/cli/registry.ts +15 -3
- package/src/cli/restart-scope.ts +3 -1
- package/src/clients/config-export/contracts.ts +1 -0
- package/src/clients/config-export/model-metadata.ts +3 -2
- package/src/clients/config-export/qoder.ts +93 -0
- package/src/clients/config-export.ts +17 -4
- package/src/codex/auth-api/pool-mode-gate.ts +5 -2
- package/src/codex/auth-context.ts +79 -5
- package/src/codex/autostart-health.ts +4 -0
- package/src/codex/catalog/build-entries.ts +11 -2
- package/src/codex/catalog/configured-tiers.ts +50 -0
- package/src/codex/catalog/effort.ts +4 -1
- package/src/codex/catalog/model-hints.ts +21 -3
- package/src/codex/catalog/native-ultrafast.ts +106 -0
- package/src/codex/catalog/parsing.ts +5 -0
- package/src/codex/catalog/provider-models.ts +4 -0
- package/src/codex/catalog/retained-sync.ts +2 -0
- package/src/codex/catalog/routed-gather.ts +22 -4
- package/src/codex/catalog/vendor-context.ts +82 -0
- package/src/codex/config-write-lock.ts +40 -2
- package/src/codex/convergence.ts +2 -0
- package/src/codex/desktop-app/types.ts +2 -0
- package/src/codex/desktop-app/windows.ts +29 -16
- package/src/codex/desktop-app-restart.ts +4 -2
- package/src/codex/desktop-compatibility/certificate-service.ts +99 -0
- package/src/codex/desktop-compatibility/certificate-store.ts +193 -0
- package/src/codex/desktop-compatibility/connection-store.ts +87 -0
- package/src/codex/desktop-compatibility/installed-build.ts +55 -0
- package/src/codex/desktop-compatibility/json-body.ts +29 -0
- package/src/codex/desktop-compatibility/native-identity.ts +62 -0
- package/src/codex/desktop-compatibility/relay-listener.ts +93 -0
- package/src/codex/desktop-compatibility/routing-binding.ts +10 -0
- package/src/codex/desktop-compatibility/routing-preflight.ts +69 -0
- package/src/codex/desktop-compatibility/runtime-ownership.ts +28 -0
- package/src/codex/desktop-compatibility/runtime.ts +173 -0
- package/src/codex/desktop-compatibility/service.ts +30 -0
- package/src/codex/desktop-compatibility/startup-settings.ts +50 -0
- package/src/codex/desktop-compatibility/usage-activation.ts +86 -0
- package/src/codex/desktop-compatibility/usage-controlled-fetch.ts +59 -0
- package/src/codex/desktop-compatibility/usage-controller.ts +107 -0
- package/src/codex/desktop-compatibility/usage-policy.ts +59 -0
- package/src/codex/desktop-compatibility/usage-refresh.ts +33 -0
- package/src/codex/desktop-compatibility/usage-sse-controller.ts +86 -0
- package/src/codex/desktop-compatibility/windows-activation-source.ts +44 -0
- package/src/codex/desktop-compatibility/windows-certificate-trust.ts +81 -0
- package/src/codex/desktop-compatibility/windows-key-protection.ts +59 -0
- package/src/codex/desktop-compatibility/windows-package-command.ts +86 -0
- package/src/codex/desktop-compatibility/windows-package-launch.ts +28 -0
- package/src/codex/history-provider.ts +1 -1
- package/src/codex/inject/config-write-section.ts +4 -1
- package/src/codex/inject/remove.ts +18 -6
- package/src/codex/journal.ts +16 -1
- package/src/codex/main-account.ts +99 -15
- package/src/codex/native-main-refresh-mode.ts +217 -0
- package/src/codex/routing/health-store.ts +1 -1
- package/src/codex/routing/pool-recovery.ts +79 -0
- package/src/codex/shim-diagnostics.ts +6 -0
- package/src/codex/shim-overlay.ts +7 -2
- package/src/config/diagnostics.ts +2 -1
- package/src/config/live-reconcile.ts +13 -0
- package/src/config/load-degrade.ts +6 -1
- package/src/config/paths.ts +10 -3
- package/src/config/schema/config-schema.ts +17 -0
- package/src/config/schema/desktop-compatibility.ts +9 -0
- package/src/config/schema/leaf-validators.ts +1 -0
- package/src/generated/compatibility-version.json +451 -163
- package/src/generated/model-metadata.ts +1 -1
- package/src/integrations/catalog-refresh.ts +1 -1
- package/src/integrations/config-io.ts +20 -2
- package/src/integrations/journal.ts +15 -1
- package/src/integrations/mutation-plan.ts +1 -0
- package/src/integrations/registry.ts +7 -0
- package/src/integrations/store.ts +3 -0
- package/src/integrations/writer.ts +10 -1
- package/src/lib/advisor-activation.ts +16 -0
- package/src/lib/background-work.ts +65 -0
- package/src/lib/bounded-file-read.ts +58 -0
- package/src/lib/bun-path-runtime.d.mts +10 -1
- package/src/lib/bun-path-runtime.mjs +62 -3
- package/src/lib/desktop-proxy-route.ts +30 -0
- package/src/lib/desktop-upstream-tunnel.ts +107 -0
- package/src/lib/errors.ts +7 -0
- package/src/lib/local-internal-call-capability.ts +55 -0
- package/src/lib/package-tree-integrity.ts +2 -2
- package/src/lib/socks5-fetch.ts +48 -71
- package/src/lib/socks5-handshake.ts +112 -0
- package/src/lib/translator-budget.ts +7 -1
- package/src/oauth/generic-account-failover.ts +29 -5
- package/src/oauth/index.ts +4 -2
- package/src/oauth/kiro-device-login.ts +2 -1
- package/src/oauth/kiro.ts +7 -1
- package/src/protocols/codecs/chat-ir.ts +467 -0
- package/src/protocols/codecs/chat.ts +10 -1
- package/src/protocols/codecs/messages-ir.ts +500 -0
- package/src/protocols/features.ts +10 -2
- package/src/protocols/path.ts +11 -1
- package/src/protocols/plan-snapshot.ts +39 -16
- package/src/protocols/plan.ts +9 -1
- package/src/protocols/settings.ts +8 -0
- package/src/providers/antigravity-account-roster.ts +102 -0
- package/src/providers/antigravity-models.ts +85 -7
- package/src/providers/model-rename-fields.ts +2 -0
- package/src/providers/model-rename-migration.ts +5 -3
- package/src/providers/registry/entries-core.ts +7 -6
- package/src/providers/registry/entries-extended.ts +19 -0
- package/src/responses/parser.ts +30 -19
- package/src/responses/state.ts +32 -29
- package/src/routing/history/build-file.ts +92 -0
- package/src/routing/history/indexer.ts +248 -216
- package/src/routing/history/ingest.ts +238 -0
- package/src/routing/history/rebuild-job.ts +111 -0
- package/src/routing/history/rebuild-protocol.ts +15 -0
- package/src/routing/history/rebuild-worker.ts +34 -0
- package/src/server/admission-model-scope.ts +4 -1
- package/src/server/antigravity-direct-eligibility.ts +208 -0
- package/src/server/auth-cors.ts +4 -0
- package/src/server/chat-completions.ts +75 -9
- package/src/server/claude-messages.ts +110 -20
- package/src/server/index/desktop-compatibility-startup.ts +56 -0
- package/src/server/index/serve-options.ts +2 -2
- package/src/server/index/startup-warnings.ts +9 -0
- package/src/server/index/websocket-handler.ts +9 -0
- package/src/server/index.ts +13 -10
- package/src/server/inference/client-encoder-delivery.ts +6 -5
- package/src/server/login-shell-path.ts +146 -0
- package/src/server/management/advisor-routes.ts +191 -0
- package/src/server/management/agent-settings-routes.ts +22 -4
- package/src/server/management/companion-routes.ts +4 -0
- package/src/server/management/config-routes.ts +2 -2
- package/src/server/management/context.ts +4 -0
- package/src/server/management/desktop-compatibility-routes.ts +46 -0
- package/src/server/management/desktop-compatibility-runtime-routes.ts +46 -0
- package/src/server/management/desktop-compatibility-settings-routes.ts +27 -0
- package/src/server/management/model-routes.ts +2 -2
- package/src/server/management/protocol-settings-patch.ts +1 -0
- package/src/server/management/route-registry.ts +11 -0
- package/src/server/management/sibling-guard.ts +1 -0
- package/src/server/management-api.ts +6 -0
- package/src/server/messages-antigravity-direct.ts +195 -0
- package/src/server/messages-native.ts +5 -1
- package/src/server/request-log.ts +7 -0
- package/src/server/responses/adapter-continuation.ts +35 -18
- package/src/server/responses/adapter-delivery.ts +24 -2
- package/src/server/responses/adapter-dispatch.ts +29 -2
- package/src/server/responses/advisor-plan-slot.ts +27 -0
- package/src/server/responses/advisor-slot.ts +336 -0
- package/src/server/responses/code-mode-collab-surface.ts +116 -8
- package/src/server/responses/core-combo-failure.ts +10 -1
- package/src/server/responses/core-combo.ts +21 -0
- package/src/server/responses/core-lifetime.ts +2 -0
- package/src/server/responses/core-normalize.ts +11 -0
- package/src/server/responses/core-options.ts +46 -0
- package/src/server/responses/core-replay.ts +7 -4
- package/src/server/responses/core.ts +1 -1
- package/src/server/responses/passthrough-delivery.ts +16 -10
- package/src/server/responses/passthrough-dispatch.ts +14 -3
- package/src/server/responses/request-prepare.ts +68 -5
- package/src/server/responses/request-transport.ts +16 -0
- package/src/server/responses/run-turn-execution.ts +70 -8
- package/src/server/responses/sidecar-execution.ts +78 -3
- package/src/server/responses/terminal-guard.ts +2 -1
- package/src/server/responses-undeclared-tool-guard.ts +30 -9
- package/src/server/startup-action-control.ts +16 -2
- package/src/server/startup-health-cache.ts +1 -0
- package/src/service/desktop-startup.ts +14 -0
- package/src/service/health-sentinel-main.ts +23 -4
- package/src/service/health-sentinel-probe.ts +24 -7
- package/src/service/logging.ts +72 -0
- package/src/tray/windows-tray.ps1 +43 -24
- package/src/types/config.ts +63 -6
- package/src/types/provider.ts +7 -0
- package/src/types/request.ts +15 -0
- package/src/types/tools.ts +2 -0
- package/src/update/async-check.ts +1 -1
- package/src/update/badge.ts +2 -2
- package/src/update/index.ts +88 -15
- package/src/update/job-supervised-restart.ts +107 -0
- package/src/update/job.ts +32 -32
- package/src/update/notify.ts +1 -1
- package/src/update/refresh-scheduler.ts +2 -2
- package/src/update/supervised-recovery.d.mts +27 -0
- package/src/update/supervised-recovery.mjs +157 -0
- package/src/usage/cache-diagnostic.ts +2 -0
- package/src/usage/expected-prices.ts +12 -0
- package/src/web-search/gemini-executor.ts +2 -2
- package/assets/sponsors/packycode.png +0 -0
- package/gui/dist/assets/App-CZtqiGcw.js +0 -56
- package/gui/dist/assets/index-CTm4l-HQ.js +0 -94
- package/gui/dist/assets/quota-summary-BbEeRfPY.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,w as t,y as n}from"./index-BMssP4k3.js";var r=e(),i=e=>({viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,...e}),a=e=>(0,r.jsxs)(`svg`,{...i(e),children:[(0,r.jsx)(`rect`,{x:`3`,y:`3`,width:`7`,height:`7`,rx:`1.5`}),(0,r.jsx)(`rect`,{x:`14`,y:`3`,width:`7`,height:`7`,rx:`1.5`}),(0,r.jsx)(`rect`,{x:`3`,y:`14`,width:`7`,height:`7`,rx:`1.5`}),(0,r.jsx)(`rect`,{x:`14`,y:`14`,width:`7`,height:`7`,rx:`1.5`})]}),o=e=>(0,r.jsxs)(`svg`,{...i(e),children:[(0,r.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`7`,rx:`2`}),(0,r.jsx)(`rect`,{x:`3`,y:`13`,width:`18`,height:`7`,rx:`2`}),(0,r.jsx)(`path`,{d:`M7 7.5h.01M7 16.5h.01`})]}),s=e=>(0,r.jsxs)(`svg`,{...i(e),children:[(0,r.jsx)(`path`,{d:`M12 2 4 6v6l8 4 8-4V6l-8-4Z`}),(0,r.jsx)(`path`,{d:`m4 6 8 4 8-4M12 10v8`})]}),c=e=>(0,r.jsxs)(`svg`,{...i(e),children:[(0,r.jsx)(`rect`,{x:`4`,y:`8`,width:`16`,height:`11`,rx:`3`}),(0,r.jsx)(`path`,{d:`M12 8V4M8 2h8`}),(0,r.jsx)(`circle`,{cx:`9`,cy:`13`,r:`1`}),(0,r.jsx)(`circle`,{cx:`15`,cy:`13`,r:`1`})]}),l=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01`})}),u=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`M4 6h16M4 12h16M4 18h16`})}),d=e=>(0,r.jsxs)(`svg`,{...i(e),children:[(0,r.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`16`,rx:`2`}),(0,r.jsx)(`path`,{d:`M9 4v16`})]}),f=e=>(0,r.jsxs)(`svg`,{...i(e),children:[(0,r.jsx)(`path`,{d:`m4 17 6-5-6-5`}),(0,r.jsx)(`path`,{d:`M12 19h8`})]}),p=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`M22 12h-4l-3 9L9 3l-3 9H2`})}),m=e=>(0,r.jsxs)(`svg`,{...i(e),children:[(0,r.jsx)(`path`,{d:`M22 12H2`}),(0,r.jsx)(`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11Z`}),(0,r.jsx)(`path`,{d:`M6 16h.01M10 16h.01`})]}),h=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`m20 6-11 11-5-5`})}),g=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`M18 6 6 18M6 6l12 12`})}),ee=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`M12 5v14M5 12h14`})}),_=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`M5 12h14`})}),te=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`M21 12a9 9 0 0 1-9 9 9.8 9.8 0 0 1-6.7-2.7L3 16M3 21v-5h5M3 12a9 9 0 0 1 9-9 9.8 9.8 0 0 1 6.7 2.7L21 8M21 3v5h-5`})}),ne=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`M8 5v14M16 5v14`})}),re=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`m7 4 13 8-13 8Z`})}),ie=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`M3 6h18M8 6V4h8v2M19 6l-1 14H6L5 6`})}),ae=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`m3 3 18 18M10.6 10.6a2 2 0 0 0 2.8 2.8M9.9 4.2A10.8 10.8 0 0 1 12 4c5 0 9 4 10 8a12.7 12.7 0 0 1-2 4.1M6.6 6.6A12.4 12.4 0 0 0 2 12c1 4 5 8 10 8 1.5 0 2.9-.4 4.1-1`})}),oe=e=>(0,r.jsxs)(`svg`,{...i(e),children:[(0,r.jsx)(`path`,{d:`M12 20h9`}),(0,r.jsx)(`path`,{d:`M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z`})]}),se=e=>(0,r.jsxs)(`svg`,{...i(e),children:[(0,r.jsx)(`path`,{d:`M10.3 3.7 1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.7a2 2 0 0 0-3.4 0Z`}),(0,r.jsx)(`path`,{d:`M12 9v4M12 17h.01`})]}),ce=e=>(0,r.jsxs)(`svg`,{...i(e),children:[(0,r.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,r.jsx)(`path`,{d:`M12 16v-4M12 8h.01`})]}),le=e=>(0,r.jsxs)(`svg`,{...i(e),children:[(0,r.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7`}),(0,r.jsx)(`path`,{d:`m21 21-4.3-4.3`})]}),ue=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`M12 19V5M5 12l7-7 7 7`})}),de=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`M12 5v14M19 12l-7 7-7-7`})}),fe=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3`})}),pe=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`m9 18 6-6-6-6`})}),me=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`M9 19c-5 1.5-5-2.5-7-3m14 6v-3.9a3.4 3.4 0 0 0-.9-2.6c3-.3 6.2-1.5 6.2-6.7A5.2 5.2 0 0 0 20 4.8 4.9 4.9 0 0 0 19.9 1S18.7.6 16 2.5a13.4 13.4 0 0 0-7 0C6.3.6 5.1 1 5.1 1A4.9 4.9 0 0 0 5 4.8a5.2 5.2 0 0 0-1.4 3.7c0 5.1 3.1 6.4 6.1 6.7a3.4 3.4 0 0 0-.9 2.5V22`})}),he=e=>(0,r.jsxs)(`svg`,{...i(e),children:[(0,r.jsx)(`path`,{d:`M18.4 5.6a9 9 0 1 1-12.8 0`}),(0,r.jsx)(`path`,{d:`M12 2v10`})]}),ge=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`M15 3h6v6M10 14 21 3M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`})}),_e=e=>(0,r.jsxs)(`svg`,{...i(e),children:[(0,r.jsx)(`circle`,{cx:`7.5`,cy:`15.5`,r:`4.5`}),(0,r.jsx)(`path`,{d:`m10.7 12.3 9.6-9.6M16 7l3 3M14 9l2 2`})]}),ve=e=>(0,r.jsx)(`svg`,{viewBox:`0 0 32 32`,fill:`none`,stroke:`currentColor`,strokeWidth:2.484,strokeLinecap:`round`,...e,children:(0,r.jsx)(`path`,{d:`M22.356 19.797H17.17M9.662 12.29l1.979 3.576a.511.511 0 0 1-.005.504l-1.974 3.409M30.758 16c0 8.15-6.607 14.758-14.758 14.758-8.15 0-14.758-6.607-14.758-14.758C1.242 7.85 7.85 1.242 16 1.242c8.15 0 14.758 6.608 14.758 14.758Z`})}),ye=e=>(0,r.jsxs)(`svg`,{...i(e),children:[(0,r.jsx)(`rect`,{x:`4`,y:`11`,width:`16`,height:`10`,rx:`2`}),(0,r.jsx)(`path`,{d:`M8 11V7a4 4 0 0 1 8 0v4`})]}),be=e=>(0,r.jsxs)(`svg`,{...i(e),children:[(0,r.jsx)(`path`,{d:`M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z`}),(0,r.jsx)(`path`,{d:`M13 5v2`}),(0,r.jsx)(`path`,{d:`M13 17v2`}),(0,r.jsx)(`path`,{d:`M13 11v2`})]}),xe=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2M15 7h2a5 5 0 0 1 0 10h-2M8 12h8`})}),Se=e=>(0,r.jsxs)(`svg`,{...i(e),children:[(0,r.jsx)(`circle`,{cx:`12`,cy:`12`,r:`4`}),(0,r.jsx)(`path`,{d:`M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4`})]}),Ce=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`M21 12.8A9 9 0 1 1 11.2 3 7 7 0 0 0 21 12.8Z`})}),we=e=>(0,r.jsxs)(`svg`,{...i(e),children:[(0,r.jsx)(`rect`,{x:`2`,y:`3`,width:`20`,height:`14`,rx:`2`}),(0,r.jsx)(`path`,{d:`M8 21h8M12 17v4`})]}),Te=e=>(0,r.jsxs)(`svg`,{...i(e),children:[(0,r.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,r.jsx)(`path`,{d:`M3 12h18M12 3a14 14 0 0 1 0 18M12 3a14 14 0 0 0 0 18`})]}),Ee=e=>(0,r.jsxs)(`svg`,{...i(e),children:[(0,r.jsx)(`path`,{d:`m18 14 4 4-4 4`}),(0,r.jsx)(`path`,{d:`m18 2 4 4-4 4`}),(0,r.jsx)(`path`,{d:`M2 18h1.973a4 4 0 0 0 3.3-1.7l5.454-8.6a4 4 0 0 1 3.3-1.7H22`}),(0,r.jsx)(`path`,{d:`M2 6h1.972a4 4 0 0 1 3.6 2.2`}),(0,r.jsx)(`path`,{d:`M22 18h-6.041a4 4 0 0 1-3.3-1.8l-.359-.45`})]}),De=e=>(0,r.jsxs)(`svg`,{...i(e),children:[(0,r.jsx)(`circle`,{cx:`9`,cy:`6`,r:`1`,fill:`currentColor`,stroke:`none`}),(0,r.jsx)(`circle`,{cx:`15`,cy:`6`,r:`1`,fill:`currentColor`,stroke:`none`}),(0,r.jsx)(`circle`,{cx:`9`,cy:`12`,r:`1`,fill:`currentColor`,stroke:`none`}),(0,r.jsx)(`circle`,{cx:`15`,cy:`12`,r:`1`,fill:`currentColor`,stroke:`none`}),(0,r.jsx)(`circle`,{cx:`9`,cy:`18`,r:`1`,fill:`currentColor`,stroke:`none`}),(0,r.jsx)(`circle`,{cx:`15`,cy:`18`,r:`1`,fill:`currentColor`,stroke:`none`})]}),v=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`m12 2 3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z`})}),Oe=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`M4 5h16l-6 7v5l-4 2v-7L4 5z`})}),y={anthropic:`claude-color.svg`,anthropic2:`claude-green.svg`,"anthropic-apikey":`claude-color.svg`,"claude-cli":`claude-color.svg`,"azure-openai":`openai.svg`,chatgpt:`openai.svg`,"cloudflare-ai-gateway":`cloudflare-ai-gateway-color.svg`,"cloudflare-workers-ai":`cloudflare-ai-gateway-color.svg`,cline:`cline-color.svg`,"cline-pass":`cline-color.svg`,"command-code":`commandcode-color.svg`,commandcode:`commandcode-color.svg`,cursor:`cursor-color.svg`,deepseek:`deepseek-color.svg`,devin:`devin.svg`,firepass:`firepass-color.svg`,fireworks:`fireworks-color.svg`,github:`github-copilot-color.svg`,"github-copilot":`copilot-color.svg`,"gitlab-duo":`gitlab-duo-color.svg`,google:`gemini-color.svg`,"google-antigravity":`antigravity-color.svg`,"google-vertex":`gemini-color.svg`,groq:`groq-color.svg`,huggingface:`huggingface-color.svg`,kimi:`kimi-color.svg`,"kimi-code":`kimi-color.svg`,"kimi-responses":`kimi-color.svg`,kiro:`kiro-color.svg`,"lm-studio":`lm-studio-color.svg`,"meta-model":`meta.svg`,"meta-muse":`meta.svg`,mistral:`mistral-color.svg`,minimax:`minimax.svg`,"minimax-cn":`minimax.svg`,moonshot:`moonshot-color.svg`,nvidia:`nvidia-color.svg`,ollama:`ollama-color.svg`,"ollama-cloud":`ollama-color.svg`,openai:`openai.svg`,"openai-apikey":`openai.svg`,"opencode-free":`opencode.svg`,"opencode-go":`opencode.svg`,"opencode-zen":`opencode.svg`,openrouter:`openrouter-color.svg`,opengateway:`opengateway.svg`,opper:`opper.svg`,qianfan:`qianfan-color.svg`,qoder:`qoder.svg`,"qoder-cn":`qoder.svg`,alibaba:`alibaba-color.svg`,"alibaba-token-plan":`alibaba-color.svg`,"alibaba-token-plan-intl":`alibaba-color.svg`,baseten:`baseten.svg`,bizrouter:`bizrouter.svg`,cerebras:`cerebras.svg`,crusoe:`crusoe.svg`,deepinfra:`deepinfra.svg`,digitalocean:`digitalocean.svg`,featherless:`featherless.svg`,hyperbolic:`hyperbolic.svg`,kilo:`kilo.svg`,nanogpt:`nanogpt.svg`,nebius:`nebius.svg`,neuralwatt:`neuralwatt.svg`,nous:`nous.svg`,novita:`novita.svg`,orcarouter:`orcarouter.svg`,"orcarouter-oauth":`orcarouter.svg`,packycode:`packycode.svg`,tokenlab:`tokenlab.svg`,parallel:`parallel.svg`,sambanova:`sambanova.svg`,scaleway:`scaleway.svg`,stepfun:`stepfun-color.svg`,siliconflow:`siliconflow.svg`,synthetic:`synthetic.svg`,together:`together.svg`,umans:`umans.svg`,venice:`venice.svg`,vultr:`vultr.svg`,litellm:`litellm.svg`,zenmux:`zenmux.svg`,zai:`zai.svg`,"zhipu-bigmodel":`zai.svg`,"zhipu-bigmodel-coding":`zai.svg`,"qwen-cloud":`qwen-portal-color.svg`,"vercel-ai-gateway":`vercel-ai-gateway-color.svg`,vllm:`vllm-color.svg`,xai:`grok.svg`,"mimo-free":`xiaomi-color.svg`,mimo:`xiaomi-color.svg`,xiaomi:`xiaomi-color.svg`,"xiaomi-mimo":`xiaomi-color.svg`},b={anthropic:`Anthropic Claude`,"anthropic-apikey":`Anthropic Claude`,chatgpt:`ChatGPT`,openai:`OpenAI (Codex login)`,"openai-apikey":`OpenAI API`,"azure-openai":`Azure OpenAI`,"cloudflare-ai-gateway":`Cloudflare AI Gateway`,"cloudflare-workers-ai":`Cloudflare Workers AI`,cline:`Cline`,"cline-pass":`ClinePass`,nvidia:`NVIDIA NIM`,ollama:`Ollama`,"ollama-cloud":`Ollama Cloud`,xai:`xAI Grok`,"mimo-free":`MiMo Free`,xiaomi:`Xiaomi`,cursor:`Cursor`,deepseek:`DeepSeek`,zed:`Zed`,devin:`Devin`,github:`GitHub`,"github-copilot":`GitHub Copilot`,"gitlab-duo":`GitLab Duo`,openrouter:`OpenRouter`,opengateway:`OpenGateway`,opper:`Opper`,"opencode-go":`OpenCode Go`,"opencode-free":`OpenCode Free`,"opencode-zen":`OpenCode Zen`,orcarouter:`OrcaRouter - API`,"orcarouter-oauth":`OrcaRouter - Auth`,packycode:`PackyCode`,tokenlab:`TokenLab`,mistral:`Mistral`,groq:`Groq`,"meta-model":`Meta Model API`,"meta-muse":`Muse Code`,alibaba:`Alibaba Coding Plan`,"alibaba-token-plan":`Alibaba Token Plan`,"alibaba-token-plan-intl":`Alibaba Token Plan (Intl)`,kimi:`Kimi`,"kimi-code":`Kimi`,"kimi-responses":`Kimi`,moonshot:`Moonshot`,google:`Google`,"google-vertex":`Google Vertex`,"lm-studio":`LM Studio`,huggingface:`Hugging Face`,"qwen-cloud":`Qwen Cloud`,siliconflow:`SiliconFlow`,stepfun:`StepFun`,"tencent-coding-plan":`Tencent Cloud Coding Plan`,codebuddy:`CodeBuddy`,"codebuddy-cn":`CodeBuddy CN`,qoder:`Qoder`,"qoder-cn":`Qoder CN`,"vercel-ai-gateway":`Vercel AI Gateway`,vllm:`vLLM`,litellm:`LiteLLM`},x={anthropic2:`provider.name.anthropic2`,"command-code":`provider.name.commandCodeAuth`,commandcode:`provider.name.commandCodeApi`,orcarouter:`provider.name.orcaRouterApi`,"orcarouter-oauth":`provider.name.orcaRouterAuth`,volcengine:`provider.name.volcengine`,"volcengine-coding-plan":`provider.name.volcengineCodingPlan`,"volcengine-agent-plan":`provider.name.volcengineAgentPlan`},ke=new Set([...Object.keys(b),...Object.keys(x)]);function Ae(e){let t=e.toLowerCase();return Object.hasOwn(y,t)?y[t]:void 0}function je(e,t){let n=Ae(e);return n?`/provider-icons/${n}`:void 0}var Me=new Set([`cerebras.svg`,`deepinfra.svg`,`neuralwatt.svg`,`nous.svg`,`novita.svg`,`packycode.svg`,`tokenlab.svg`,`opper.svg`,`opengateway.svg`,`siliconflow.svg`,`synthetic.svg`,`zenmux.svg`,`grok.svg`,`kimi-color.svg`,`ollama-color.svg`,`opencode.svg`,`vercel-ai-gateway-color.svg`]),Ne=new Set([`baseten.svg`,`kilo.svg`,`sambanova.svg`,`venice.svg`,`zai.svg`]),Pe=new Set([`bizrouter.svg`,`featherless.svg`,`hyperbolic.svg`,`nebius.svg`,`parallel.svg`,`umans.svg`]);function Fe(e){if(!e)return`image`;let t=e.split(`/`).pop()??``;return Me.has(t)?`mask`:Ne.has(t)?`plate`:Pe.has(t)?`dark-plate`:`image`}function S(e,t){let n=e.toLowerCase(),r=Object.hasOwn(x,n)?x[n]:void 0;return r?t(r):(Object.hasOwn(b,n)?b[n]:void 0)||(e===n&&/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(e)?e.split(`-`).map(e=>e&&e[0].toUpperCase()+e.slice(1)).join(` `):e)}function Ie(e){return ke.has(e.toLowerCase())}function Le(e){return e===`command-code`?`commandcode-auth`:e===`commandcode`?`commandcode-api`:e}function Re(e,t){let n=e.indexOf(`/`);if(n<=0)return e;let r=e.slice(0,n),i=e.slice(n+1);if(r===`command-code`||r===`commandcode`){let e=i.match(/^([a-z0-9]+)-([a-z0-9]+(?:-[a-z0-9]+)+)$/i);return e&&i.startsWith(`${e[1]}-${e[1]}-`)&&(i=i.slice(e[1].length+1)),`${r===`command-code`?`commandcode-auth`:`commandcode-api`}/${i}`}return e}var ze={ko:[{v:0x2386f26fc10000,s:`경`},{v:0xe8d4a51000,s:`조`},{v:1e8,s:`억`},{v:1e4,s:`만`}],zh:[{v:0x2386f26fc10000,s:`京`},{v:0xe8d4a51000,s:`兆`},{v:1e8,s:`亿`},{v:1e4,s:`万`}],"zh-TW":[{v:0x2386f26fc10000,s:`京`},{v:0xe8d4a51000,s:`兆`},{v:1e8,s:`億`},{v:1e4,s:`萬`}]};function C(e){return e.replace(/\.0+$/,``).replace(/(\.\d*?)0+$/,`$1`)}function Be(e,t){let n=ze[t];if(n){for(let t of n)if(e>=t.v)return`${C((e/t.v).toFixed(1))}${t.s}`;return String(e)}return e<1e4?String(e):e<1e6?`${C((e/1e3).toFixed(1))}K`:e<1e9?`${C((e/1e6).toFixed(1))}M`:e<0xe8d4a51000?`${C((e/1e9).toFixed(1))}B`:`${C((e/0xe8d4a51000).toFixed(1))}T`}var Ve=new Set([`claude-cli`]),He=`anthropic-apikey`;function w(e){return Ve.has((e.adapter??``).trim())}var T=`https://chatgpt.com/backend-api/codex`,Ue=`openai`;function E(e){try{let t=new URL(e.trim());if(t.username||t.password||t.search||t.hash)return;let n=t.pathname.replace(/\/+$/,``);return`${t.origin}${n}`}catch{return}}var We=new URL(T).protocol;function D(e,...t){return`${We}//${e}/${t.join(`/`)}`}var Ge={"cline-pass":{adapter:`openai-chat`,baseUrl:D(`api.cline.bot`,`api`,`v1`)},"mimo-free":{adapter:`mimo-free`,baseUrl:D(`api.xiaomimimo.com`,`api`,`free-ai`,`openai`,`chat`)}};function Ke(e,t){let n=Ge[e];return!n||t.adapter!==n.adapter||E(t.baseUrl)!==E(n.baseUrl)}function O(e){try{let t=new URL(e).hostname.replace(/^\[|\]$/g,``).toLowerCase();return t===`localhost`||t===`127.0.0.1`||t===`::1`}catch{return!1}}function k(e){return e.keyOptional===!0||w(e)||e.authMode===`oauth`||e.authMode===`forward`||e.authMode===`local`||O(e.baseUrl)||e.hasApiKey===!0}function A(e){return e.adapter===`openai-responses`&&e.authMode===`forward`&&E(e.baseUrl)===T}function j(e,t){return e===Ue&&A(t)}function M(e){return w(e)?!1:e.freeTier===!0||e.keyOptional===!0||e.authMode===`local`||O(e.baseUrl)}function N(e,t){return j(e,t)?`accounts`:M(t)?`free`:`paid`}function qe(e,t){let n=[...e],r=(e,t)=>e.name.localeCompare(t.name,void 0,{sensitivity:`base`}),i=e=>e.tier??N(e.name,e);switch(t){case`az`:return n.sort(r);case`za`:return n.sort((e,t)=>r(t,e));case`free-paid`:return n.sort((e,t)=>(i(e)===`free`?0:1)-(i(t)===`free`?0:1)||r(e,t));case`paid-free`:return n.sort((e,t)=>(i(e)===`free`)-+(i(t)===`free`)||r(e,t));case`accounts-first`:return n.sort((e,t)=>{let n=e=>{let t=i(e);return t===`accounts`?0:t===`free`?1:2};return n(e)-n(t)||r(e,t)});default:return n}}function Je(e){let t=[],n=[],r=[];for(let[i,a]of Object.entries(e)){if(a.disabled){r.push({name:i,...a});continue}k(a)?t.push({name:i,...a,tier:N(i,a)}):n.push({name:i,...a})}return{ready:t,needsSetup:n,disabled:r}}function Ye(e,t){let n=new Set(Object.entries(t).filter(([,e])=>e).map(([e])=>e));if(n.size===0)return e;let r=e=>e.map(e=>n.has(e.name)?{...e,activeNeedsReauth:!0}:e);return{ready:r(e.ready),needsSetup:r(e.needsSetup),disabled:e.disabled}}function P(e){return e.disabled?`disabled`:`activeNeedsReauth`in e&&e.activeNeedsReauth?`needs-setup`:k(e)?`ready`:`needs-setup`}function Xe(e){let t=e.openai,n=e.chatgpt;if(!t||!n||!j(`openai`,t)||!A(n))return e;let r={...e};return delete r.chatgpt,r}function F(e){return e.authMode===`local`||O(e.baseUrl)}var Ze=[`ollama`,`vllm`,`lm-studio`,`lmstudio`,`litellm`,`localai`];function Qe(e){let t=(e.authMode??``).toLowerCase();if(t===`oauth`||t===`forward`)return`login`;if(F(e))return`local`;let n=`${e.name??``} ${e.adapter} ${e.baseUrl}`.toLowerCase();return Ze.some(e=>n.includes(e))?`selfHosted`:`cloud`}function I(e,t){if(!e||typeof e!=`object`||Array.isArray(e))return null;let n=e;if(typeof n.updatedAt!=`number`||!Number.isFinite(n.updatedAt))return null;let r=n.observed===!0;return!r&&t-n.updatedAt>=18e5||!(`quota`in n)||n.label!==void 0&&typeof n.label!=`string`||n.source!==void 0&&typeof n.source!=`string`?null:{...typeof n.label==`string`?{label:n.label}:{},...typeof n.source==`string`?{source:n.source}:{},updatedAt:n.updatedAt,quota:n.quota,...r?{observed:!0}:{},...n.aggregation===void 0?{}:{aggregation:n.aggregation}}}function $e(e,t=Date.now()){if(!e||typeof e!=`object`||Array.isArray(e))return null;let n={};for(let[r,i]of Object.entries(e)){let e=I(i,t);r.trim()&&e&&(n[r]=e)}return n}function et(e,t=Date.now()){if(!Array.isArray(e))return{};let n={};for(let r of e){if(!r||typeof r!=`object`||Array.isArray(r))continue;let e=r.provider,i=I(r,t);typeof e==`string`&&e.trim()&&i&&(n[e]=i)}return n}function tt(e){return e?.observed===!0&&typeof e.updatedAt==`number`?e.updatedAt:void 0}var L=e=>typeof e==`number`&&Number.isFinite(e)?e:void 0,nt=e=>{let t=L(e);if(t===void 0)return;let n=t>1e10?t:t*1e3;return Number.isFinite(new Date(n).getTime())?t:void 0};function R(e,t){if(!e||typeof e!=`object`||Array.isArray(e))return null;let n=e,r=Array.isArray(n.customWindows)?n.customWindows.flatMap(e=>{if(!e||typeof e!=`object`)return[];let t=e;return typeof t.label!=`string`||L(t.percent)===void 0?[]:[{label:t.label,percent:t.percent,...L(t.resetAt)===void 0?{}:{resetAt:t.resetAt}}]}):[],i=n.creditsUsd&&typeof n.creditsUsd==`object`&&!Array.isArray(n.creditsUsd)?n.creditsUsd:null,a=L(i?.used),o=L(i?.limit),s=L(i?.remaining),c=L(i?.percent),l=nt(i?.expiresAt),u=a!==void 0&&o!==void 0&&s!==void 0&&c!==void 0?{used:a,limit:o,remaining:s,percent:c,...l===void 0?{}:{expiresAt:l},...typeof i?.unlimited==`boolean`?{unlimited:i.unlimited}:{}}:void 0,d={...L(n.fiveHourPercent)===void 0?{}:{fiveHourPercent:n.fiveHourPercent},...L(n.fiveHourResetAt)===void 0?{}:{fiveHourResetAt:n.fiveHourResetAt},...L(n.weeklyPercent)===void 0?{}:{weeklyPercent:n.weeklyPercent},...L(n.weeklyResetAt)===void 0?{}:{weeklyResetAt:n.weeklyResetAt},...L(n.monthlyPercent)===void 0?{}:{monthlyPercent:n.monthlyPercent},...L(n.monthlyResetAt)===void 0?{}:{monthlyResetAt:n.monthlyResetAt},...r.length>0?{customWindows:r}:{},...u?{creditsUsd:u}:{},updatedAt:L(n.updatedAt)??t??Date.now()};return d.fiveHourPercent!==void 0||d.weeklyPercent!==void 0||d.monthlyPercent!==void 0||(d.customWindows?.length??0)>0||d.creditsUsd!==void 0?d:null}function z(e){return R(e?.quota,e?.updatedAt)}function rt(e){if(!e)return;if(e.aggregation===void 0)return e;let t=V(e)?.currentAccount?.quota??null;return{...e,aggregation:void 0,quota:t,updatedAt:t?.updatedAt}}function B(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e,n=L(t.usedPercent);if(n!==void 0)return{usedPercent:n,...typeof t.incomplete==`boolean`?{incomplete:t.incomplete}:{},...L(t.excludedAccounts)===void 0?{}:{excludedAccounts:t.excludedAccounts},...L(t.nextRecoveryAt)===void 0?{}:{nextRecoveryAt:t.nextRecoveryAt},...L(t.nextRecoveryPercent)===void 0?{}:{nextRecoveryPercent:t.nextRecoveryPercent}}}function V(e){let t=e?.aggregation;if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t;if(n.kind!==`capacity-weighted-v1`||n.scope!==`routable-known`)return null;let r=L(n.excludedAccounts),i=L(n.unknownPlanAccounts);if(r===void 0||i===void 0||typeof n.incomplete!=`boolean`)return null;let a=n.currentAccount&&typeof n.currentAccount==`object`&&!Array.isArray(n.currentAccount)?n.currentAccount:null,o=Array.isArray(n.customWindows)?n.customWindows.flatMap(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return[];let t=e,n=B(t);return typeof t.label==`string`&&n?[{label:t.label,...n}]:[]}):[],s=B(n.fiveHour),c=B(n.weekly),l=B(n.monthly),u=!!s||!!c||!!l||o.length>0;return{presentation:n.presentation===`aggregate`||n.presentation===`effective-account-fallback`||n.presentation===`coverage-only`?n.presentation:u?`aggregate`:`coverage-only`,incomplete:n.incomplete,excludedAccounts:r,unknownPlanAccounts:i,partialWindowAccounts:L(n.partialWindowAccounts)??0,...s?{fiveHour:s}:{},...c?{weekly:c}:{},...l?{monthly:l}:{},...o.length>0?{customWindows:o}:{},...a?{currentAccount:{...typeof a.plan==`string`||a.plan===null?{plan:a.plan}:{},quota:R(a.quota)}}:{}}}function it(e){if(!e?.trim())return``;let[t,n]=e.split(`:`,2);return n?`${t} · ${n.replace(/-/g,` `)}`:e}function at(e,t){let n=P(e);return n===`disabled`?t(`prov.disabledBadge`):n===`ready`?t(`pws.status.ready`):`activeNeedsReauth`in e&&e.activeNeedsReauth?t(`pws.status.needsAttention`):t(`pws.status.needsSetup`)}function ot(e,t){if(w(e))return t(`modal.badge.subscriptionCli`);switch(e.authMode){case`oauth`:return t(`modal.badge.oauth`);case`forward`:return t(`pws.auth.chatgptPassthrough`);case`local`:return t(`modal.badge.local`);case`key`:return t(`modal.badge.apiKey`);default:return e.authMode??(e.keyOptional?t(`pws.auth.noKey`):t(`modal.badge.apiKey`))}}function st(e){let t=P(e);return t===`disabled`?`providers-workspace-rail-status providers-workspace-rail-status--inactive`:t===`ready`?`providers-workspace-rail-status providers-workspace-rail-status--active`:`providers-workspace-rail-status providers-workspace-rail-status--warning`}function H({name:e,adapter:n,baseUrl:i,cls:a}){let o=t(),s=je(e,{adapter:n,baseUrl:i}),c=Fe(s),l=c===`plate`?`${a} provider-icon--plate`:c===`dark-plate`?`${a} provider-icon--plate-dark`:a;return(0,r.jsx)(`span`,{className:l,children:s&&c===`mask`?(0,r.jsx)(`span`,{className:`provider-icon-mask`,style:{maskImage:`url(${s})`,WebkitMaskImage:`url(${s})`},"aria-hidden":`true`}):s?(0,r.jsx)(`img`,{src:s,alt:``,"aria-hidden":`true`}):(0,r.jsx)(ct,{name:e,label:S(e,o)})})}function ct({name:e,label:t}){let n=[...e].reduce((e,t)=>e+t.charCodeAt(0),0)%360,i=(t.trim()[0]??e[0]??`?`).toUpperCase();return(0,r.jsx)(`span`,{className:`provider-icon-fallback`,style:{background:`hsl(${n} 55% 90%)`,color:`hsl(${n} 65% 32%)`},"aria-hidden":`true`,children:i})}function lt({item:e,selected:n,tabbable:i,modelCount:a,isDefault:o,showConfigId:s,onClick:c,onFocus:l}){let u=t(),d=M(e),f=F(e),p=at(e,u),m=S(e.name,u),h=s?`${m} (${e.name})`:m,g=`${o?u(`pws.rail.suffixDefault`):``}${f?u(`pws.rail.suffixLocal`):d?u(`pws.rail.suffixFree`):``}`,ee=a!==void 0&&a>0?a===1?u(`pws.modelCountOne`):u(`pws.modelCount`,{count:a}):``,_=[s?e.name:``,ee].filter(Boolean).join(` · `);return(0,r.jsxs)(`button`,{type:`button`,className:`providers-workspace-rail-row${n?` providers-workspace-rail-row--selected`:``}`,onClick:c,role:`option`,"aria-selected":n,tabIndex:i?0:-1,"aria-label":u(`pws.rail.selectAria`,{name:h,status:p,suffix:g}),title:h,onFocus:l,children:[(0,r.jsx)(H,{name:e.name,adapter:e.adapter,baseUrl:e.baseUrl,cls:`providers-workspace-rail-icon`}),(0,r.jsxs)(`span`,{className:`providers-workspace-rail-copy`,children:[(0,r.jsxs)(`span`,{className:`providers-workspace-rail-primary`,children:[(0,r.jsx)(`span`,{className:`providers-workspace-rail-name-label`,title:m,children:m}),f?(0,r.jsx)(`span`,{className:`pwi-rail-badge pwi-rail-badge--local`,title:u(`pws.localTitle`),children:u(`modal.badge.local`)}):d?(0,r.jsx)(`span`,{className:`pwi-rail-badge pwi-rail-badge--free`,title:u(`pws.freeTitle`),children:u(`modal.badge.free`)}):null]}),(0,r.jsx)(`span`,{className:`providers-workspace-rail-secondary`,title:_||void 0,children:_||`\xA0`})]}),(0,r.jsxs)(`span`,{className:`providers-workspace-rail-trail`,children:[o&&(0,r.jsx)(`span`,{className:`pwi-default-star`,title:u(`prov.defaultBadge`),"aria-label":u(`prov.defaultBadge`),children:(0,r.jsx)(v,{width:17,height:17,"aria-hidden":`true`})}),(0,r.jsx)(`span`,{className:st(e),title:p,"aria-hidden":`true`})]})]})}var ut=1e10;function dt(e){return e<ut?e*1e3:e}function ft(e,t){let n=e=>typeof e==`number`&&Number.isFinite(e);if(!n(e.shortPercent)||e.shortPercent<100)return!1;let r=e.shortResetAt;if(!n(r)||r<=0){let r=e.shortObservedAt;if(!n(r))return!1;let i=t-r;return i>=0&&i<=3e5}return dt(r)>t}function pt(e){return{fiveHourAvailable:e?.shortWindowSeconds===18e3&&typeof e.shortResetAt==`number`,weeklyAvailable:typeof e?.weeklyResetAt==`number`}}function U(e){let t=e?.trim().toLowerCase();return t===`go`||t===`free`}function W(e,t){if(!e)return null;let n=e.shortPercent===void 0&&e.shortResetAt===void 0?e:{...e,fiveHourPercent:e.fiveHourPercent??e.shortPercent,fiveHourResetAt:e.fiveHourResetAt??e.shortResetAt};return U(t)?{...n.monthlyPercent===void 0?{}:{monthlyPercent:n.monthlyPercent},...n.monthlyResetAt===void 0?{}:{monthlyResetAt:n.monthlyResetAt},...n.creditsUsd===void 0?{}:{creditsUsd:n.creditsUsd},...n.resetCredits===void 0?{}:{resetCredits:n.resetCredits},updatedAt:n.updatedAt}:n}function mt(e,t,n=Date.now()){if(!e)return null;let r=e=>typeof e==`number`&&Number.isFinite(e),i=r(e.fiveHourPercent)?e.fiveHourPercent:r(e.shortPercent)?e.shortPercent:void 0,a=(U(t)?[e.monthlyPercent]:[e.weeklyPercent,e.monthlyPercent]).filter(r);if(a.length===0)return ft({...r(i)?{shortPercent:i}:{},...r(e.fiveHourResetAt??e.shortResetAt)?{shortResetAt:e.fiveHourResetAt??e.shortResetAt}:{},...r(e.shortObservedAt)?{shortObservedAt:e.shortObservedAt}:{}},n)?100:null;let o=r(i)?[...a,i]:a;return o.length?Math.max(...o):null}function ht(e){let t=new URLSearchParams({hours:String(e.chartHours),bucketMinutes:String(e.bucketMinutes),metric:e.tokenMetric,aggregation:e.aggregation,grouping:e.chartGrouping});e.models?.length&&t.set(`models`,e.models.join(`,`));for(let n of e.hiddenProviders)t.append(`hiddenProvider`,n);return t}function G(e){return Array.isArray(e)&&e.length<=100&&e.every(e=>typeof e==`string`)?JSON.stringify([...new Set(e)].sort()):void 0}function gt(e,t){let n=new Set(t.hiddenProviders),r=e.availableModels.filter(e=>!n.has(e.slice(0,e.indexOf(`/`))));if(t.models?.length===0)return{...e,series:[],availableModels:r};let i=t.models===null?null:new Set(t.models),a=i!==null||n.size>0,o=e.appliedFilters,s=!!o&&G(o.hiddenProviders)===G(t.hiddenProviders)&&(t.models===null?o.models===null:G(o.models)===G(t.models)),c=e.series.filter(e=>e.id===`other`&&e.provider===``?!a||s:!n.has(e.provider)&&(i===null||i.has(`${e.provider}/${e.model}`)||i.has(e.model)));return{...e,series:c,availableModels:r,truncated:e.truncated||(a||o!==void 0)&&!s}}var _t={6:15,24:60,72:180,168:360};function vt(e){return _t[e]}function K(e){if(e<1e3)return String(Math.round(e));let t=[[0xe8d4a51000,`T`],[1e9,`B`],[1e6,`M`],[1e3,`K`]];for(let n=0;n<t.length;n+=1){let[r,i]=t[n];if(e>=r){let a=Math.round(e/r);if(a>=1e3&&n>0){let[r,i]=t[n-1];return`${Math.round(e/r)}${i}`}return`${a}${i}`}}return String(Math.round(e))}function yt(e,t){let n=new Map;for(let r of e){let e=r.includes(`/`)?r.slice(0,r.indexOf(`/`)):r,i=n.get(e)??{provider:e,models:[],total:0},a=t.get(r)??0;i.models.push({id:r,total:a}),i.total+=a,n.set(e,i)}return Array.from(n.values()).map(e=>({...e,models:e.models.toSorted((e,t)=>t.total-e.total||e.id.localeCompare(t.id))})).toSorted((e,t)=>t.total-e.total||e.provider.localeCompare(t.provider))}function bt(e,t,n,r){let i=new Set(t),a=new Set((e??t).filter(e=>i.has(e)));for(let e of n)r?a.add(e):a.delete(e);return t.length>0&&t.every(e=>a.has(e))?null:t.filter(e=>a.has(e))}function xt(e,t=[]){let n={...e};if(typeof n.menuBarTemplate==`string`&&n.menuBarTemplate.trim()===``&&(n.menuBarTemplate=null),n.models!==void 0&&t.length>0){let e=n.models??[],r=new Set(e);e.length===t.length&&t.every(e=>r.has(e))&&(n.models=null)}return n}function St(e,t,n,r,i=8){let a=Math.max(0,t-i*2),o=Math.max(0,n-i*2),s=Math.max(r,1),c=Math.max(e.length-1,1);return e.map((e,t)=>`${i+a*t/c},${i+o*(1-Math.max(0,e)/s)}`).join(` `)}function Ct(e,t,n,r,i=8){let a=e[0]?.points.length??0;if(a===0)return[];let o=Math.max(0,t-i*2),s=Math.max(0,n-i*2),c=Math.max(r,1),l=Math.min(3,o/Math.max(a*8,1)),u=Math.max(0,o/a-l),d=[];for(let t=0;t<a;t+=1){let n=0;for(let r=0;r<e.length;r+=1){let f=s*Math.max(0,e[r]?.points[t]??0)/c;f>0&&d.push({x:i+o/a*t+l/2,y:i+s-n-f,width:u,height:f,seriesIndex:r,bucketIndex:t}),n+=f}}return d}var q=[`#0A84FF`,`#FF9F0A`,`#30D158`,`#BF5AF2`,`#FF453A`,`#64D2FF`],wt=640,Tt=160,J=28;function Et(e,t){return Math.max(...t===`stackedBar`?Array.from({length:e.buckets},(t,n)=>e.series.reduce((e,t)=>e+(t.points[n]??0),0)):e.series.flatMap(e=>e.points),0)}function Dt(e,t){let n=new Intl.DateTimeFormat(t,{month:`short`,day:`numeric`}),r=Math.max(1,Math.floor((e.buckets-1)/3));return[0,1,2,3].map(t=>{let i=Math.min(e.buckets-1,t*r);return n.format(new Date((e.start+i*e.bucketSeconds)*1e3))})}function Ot({timeline:e,chartStyle:t,hours:n,loading:i,error:a,onRetry:o,locale:s,t:c}){if(i)return(0,r.jsx)(`div`,{className:`usage-companion-chart-skeleton`,"aria-busy":`true`,"aria-label":c(`usage.companion.loading`)});if(a)return(0,r.jsxs)(`div`,{className:`usage-companion-chart-state`,role:`alert`,children:[(0,r.jsx)(`span`,{children:c(`usage.companion.timelineUnavailable`)}),(0,r.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:o,children:c(`common.retry`)})]});if(!e||e.series.length===0)return(0,r.jsx)(`div`,{className:`usage-companion-chart-state`,children:c(`usage.companion.empty`,{hours:e?.buckets?Math.round(e.buckets*e.bucketSeconds/3600):n})});let l=Et(e,t),u=Dt(e,s),d=J,f=u.map((e,t)=>(0,r.jsx)(`text`,{x:J+584*t/3,y:156,textAnchor:t===0?`start`:t===3?`end`:`middle`,className:`usage-companion-axis-label`,children:e},`${e}-${t}`)),p=t===`line`?e.series.map((e,t)=>(0,r.jsx)(`polyline`,{points:St(e.points,584,104,l,0),transform:`translate(${J},${J})`,fill:`none`,stroke:q[t%q.length],strokeWidth:`2`,strokeLinejoin:`round`,strokeLinecap:`round`},e.id)):Ct(e.series,584,104,l,0).map(e=>(0,r.jsx)(`rect`,{x:J+e.x,y:J+e.y,width:e.width,height:e.height,fill:q[e.seriesIndex%q.length],rx:`1`},`${e.bucketIndex}-${e.seriesIndex}`));return(0,r.jsxs)(`div`,{className:`usage-companion-chart`,children:[(0,r.jsxs)(`svg`,{viewBox:`0 0 ${wt} ${Tt}`,role:`img`,"aria-label":c(`usage.companion.chartLabel`),children:[(0,r.jsx)(`line`,{x1:J,y1:d,x2:J,y2:132,className:`usage-companion-axis`}),(0,r.jsx)(`line`,{x1:J,y1:132,x2:612,y2:132,className:`usage-companion-axis`}),(0,r.jsx)(`text`,{x:24,y:32,textAnchor:`end`,className:`usage-companion-axis-label`,children:K(l)}),p,f]}),(0,r.jsx)(`div`,{className:`usage-companion-legend`,children:e.series.map((e,t)=>(0,r.jsxs)(`span`,{className:`usage-companion-legend-item`,children:[(0,r.jsx)(`span`,{className:`usage-companion-swatch`,style:{background:q[t%q.length]},"aria-hidden":`true`}),(0,r.jsx)(`span`,{children:e.id})]},e.id))}),e.truncated&&(0,r.jsx)(`p`,{className:`muted text-caption`,children:c(`usage.companion.olderRecordsSkipped`)})]})}var Y=e=>typeof e==`number`&&Number.isFinite(e)&&e>=0,X=e=>typeof e==`object`&&e&&!Array.isArray(e)?e:{};function kt(e){return Object.entries(X(X(e).providers)).flatMap(([e,t])=>{let n=X(t);return n.disabled===!0?[]:e===`openai`?[{name:e,path:`/api/codex-auth/accounts`,switchKind:`codex`}]:n.authMode===`oauth`?[{name:e,path:`/api/oauth/accounts?${new URLSearchParams({provider:e,quota:`1`})}`,switchKind:`oauth`}]:n.hasApiKey===!0&&n.authMode!==`forward`?[{name:e,path:`/api/providers/keys?${new URLSearchParams({name:e,quota:`1`})}`,switchKind:`apiKey`}]:[{name:e,path:null,switchKind:null}]})}function At(e,t,n){return t===`codex`?{path:`/api/codex-auth/active`,body:{accountId:n}}:t===`oauth`?{path:`/api/oauth/accounts/active`,body:{provider:e,accountId:n}}:{path:`/api/providers/keys/active`,body:{name:e,id:n}}}function jt(e,t){return t?{switchState:`active`}:X(e.mainAccountHardLock).state===`blocked`?{switchState:`blocked`,blockedReason:`mainHardLock`}:e.paused===!0?{switchState:`blocked`,blockedReason:`paused`}:X(e.health).reason===`validation_pending`?{switchState:`blocked`,blockedReason:`validationPending`}:{switchState:`available`}}function Mt(e,t){let n=[`go`,`free`].includes((t??``).trim().toLowerCase()),r=e.fiveHourPercent??e.shortPercent;return(n?[e.monthlyPercent,r]:[e.weeklyPercent,e.monthlyPercent,r]).some(e=>typeof e==`number`&&Number.isFinite(e)&&e>=100)}function Nt(e){let t=X(e),n=t.accounts??t.keys;if(!Array.isArray(n))throw Error(`Invalid account roster`);return n.map(e=>{let n=X(e);if(typeof n.id!=`string`)throw Error(`Invalid account identifier`);let r=typeof n.email==`string`?Pt(n.email):void 0,i=[n.alias,n.label,r,n.logLabel,n.id].find(e=>typeof e==`string`&&e.length),a=n.quotaUnavailable===!0||n.quotaMode===`unsupported`||!n.quota?null:X(n.quota),o=typeof n.plan==`string`?n.plan:void 0,s=t.activeAccountId??t.activeId??t.activeCodexAccountId,c=typeof s==`string`?s===n.id:n.active===!0;return{id:n.id,label:i,email:r,plan:o,unavailable:n.quotaUnavailable===!0,active:c,...jt(n,c),exhausted:a!==null&&Mt(X(n.quota),o),status:typeof X(n.health).status==`string`?X(n.health).status:void 0,quotaFailure:typeof n.quotaFailure==`string`?n.quotaFailure:void 0,quota:W(a,o)}})}function Z(e){if(!Y(e)||e===0)return null;let t=e<0xe8d4a51000?e*1e3:e;return Number.isFinite(new Date(t).getTime())?t:null}function Pt(e){let[t,n]=e.split(`@`);if(!n)return`•••`;let r=n.includes(`.`)?n.slice(n.lastIndexOf(`.`)):``;return`${t?.slice(0,1)||`•`}•••@${n.slice(0,1)}•••${r}`}function Ft(e,t,n=Date.now()){let r=Z(e);if(r===null||r<=n)return{text:`—`};let i=Math.ceil((r-n)/6e4),a=(e,n)=>new Intl.NumberFormat(t,{style:`unit`,unit:n,unitDisplay:`narrow`}).format(e);return{text:i<60?a(i,`minute`):i<1440?`${a(Math.floor(i/60),`hour`)} ${a(i%60,`minute`)}`:i<10080?`${a(Math.floor(i/1440),`day`)} ${a(Math.floor(i%1440/60),`hour`)}`:new Intl.DateTimeFormat(t,{month:`short`,day:`numeric`}).format(r),exact:new Date(r).toLocaleString(t)}}function It(e){if(!e)return[];let t=[{id:`quota.fiveHourLimit`,key:`quota.fiveHourLimit`,percent:e.fiveHourPercent??e.shortPercent,reset:e.fiveHourResetAt??e.shortResetAt},{id:`quota.weeklyLimit`,key:`quota.weeklyLimit`,percent:e.weeklyPercent,reset:e.weeklyResetAt},{id:`quota.monthlyLimit`,key:`quota.monthlyLimit`,percent:e.monthlyPercent,reset:e.monthlyResetAt},...Array.isArray(e.customWindows)?e.customWindows.filter(e=>e&&typeof e.label==`string`).map(e=>({id:e.label,label:e.label,percent:e.percent,reset:e.resetAt})):[]].filter(e=>Y(e.percent)||Z(e.reset)!==null),n=new Map;return t.map(e=>{let t=n.get(e.id)??0;return n.set(e.id,t+1),t===0?e:{...e,id:`${e.id}#${t}`}})}function Lt(e,t){let n=new Set(t.hiddenProviders),r=t.models===null?null:new Set(t.models),i=e.models.filter(e=>!n.has(e.provider)&&(r===null||r.has(`${e.provider}/${e.model}`)||r.has(e.model)));if(t.models===null&&t.hiddenProviders.length===0)return{...e,models:i};if(t.models?.length!==0&&e.models.some(e=>!e.provider||!e.model||e.provider===`other`&&e.model===`other`))return{...e,models:i.filter(e=>e.provider!==`other`||e.model!==`other`),summary:{},usageIncomplete:!0};let a={};for(let e of[`requests`,`totalTokens`,`inputTokens`,`outputTokens`,`cachedInputTokens`,`cacheReadInputTokens`,`estimatedCostUsd`,`measuredRequests`,`pricedRequests`])i.length&&i.every(t=>Y(t[e]))&&(a[e]=i.reduce((t,n)=>t+n[e],0));return{...e,models:i,summary:a}}function Rt(e){let t={...e};if((e.requests??0)>0&&(e.measuredRequests===0||e.coverageRatio===0))for(let e of[`totalTokens`,`inputTokens`,`outputTokens`,`cachedInputTokens`,`cacheReadInputTokens`])delete t[e];return(e.requests??0)>0&&e.pricedRequests===0&&delete t.estimatedCostUsd,t}async function zt(e,t){let r=n(2e4),i=()=>r.controller.abort();t.aborted&&i(),t.addEventListener(`abort`,i,{once:!0});try{let t=await fetch(e,{signal:r.signal,cache:`no-store`});if(!t.ok)throw Error(String(t.status));let n=await t.json();if(r.signal.aborted)throw Error(`Tray request cancelled`);return n}finally{r.clear(),t.removeEventListener(`abort`,i)}}function Bt(e){let t=X(e);if(t.error||!t.summary||typeof t.summary!=`object`||Array.isArray(t.summary)||!Array.isArray(t.models))throw Error(`Invalid usage`);return t}var Q=e=>typeof e==`number`&&Number.isFinite(e);function $(e){return Q(e)?e>=90?`critical`:e>=70?`warn`:`normal`:`normal`}function Vt(e){return Q(e)?`${Math.floor(e)}%`:`-`}var Ht=[`quota.weeklyLimit`,`quota.monthlyLimit`,`quota.fiveHourLimit`];function Ut(e){let t=It(e).map(e=>{let t=Q(e.percent)?e.percent:void 0,n=Z(e.reset);return{id:e.id,...`key`in e&&e.key?{labelKey:e.key}:{},...`label`in e&&typeof e.label==`string`?{label:e.label}:{},...t===void 0?{}:{percent:t},...n===null?{}:{resetAt:n},severity:$(t)}}),n=e.creditsUsd;if(n&&n.unlimited!==!0&&Q(n.percent)){let e=Z(n.expiresAt);t.push({id:`quotaSummary.credits`,labelKey:`quotaSummary.credits`,percent:n.percent,...e===null?{}:{resetAt:e},severity:$(n.percent)})}return t}function Wt(e){let t=e.filter(e=>e.percent!==void 0),n=new Map(t.map(e=>[e.id,e]));for(let e of Ht){let t=n.get(e);if(t)return t}return t[0]}function Gt(e,t){let n=[];for(let[r,i]of Object.entries(e)){let e=z(i);if(!e)continue;let a=Ut(e),o=Wt(a);o&&n.push({provider:r,label:i.label?.trim()||t(r),headline:o,windows:a,...Q(i.updatedAt)?{updatedAt:i.updatedAt}:{},observed:i.observed===!0,severity:o.severity})}return n}export{p as $,rt as A,ee as At,Xe as B,ie as Bt,W as C,_ as Ct,ot as D,ne as Dt,lt as E,d as Et,F,Ee as Ft,qe as G,M as H,Qe as I,v as It,Be as J,He as K,Ye as L,Se as Lt,$e as M,te as Mt,et as N,le as Nt,z as O,oe as Ot,tt as P,o as Pt,Le as Q,P as R,f as Rt,mt as S,u as St,H as T,Ce as Tt,Ke as U,j as V,g as Vt,N as W,S as X,Re as Y,Ie as Z,gt as _,ce as _t,zt as a,h as at,yt as b,l as bt,Rt as c,fe as ct,kt as d,Oe as dt,se as et,It as f,me as ft,xt as g,m as gt,vt as h,De as ht,At as i,s as it,it as j,he as jt,V as k,re as kt,Nt as l,ge as lt,Ot as m,a as mt,Vt as n,ue as nt,Lt as o,pe as ot,Ft as p,Te as pt,w as q,$ as r,c as rt,Y as s,ve as st,Gt as t,de as tt,Bt as u,ae as ut,ht as v,_e as vt,pt as w,we as wt,bt as x,ye as xt,K as y,xe as yt,Je as z,be as zt};
|
package/gui/dist/index.html
CHANGED
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
document.documentElement.lang = langMap[locale];
|
|
37
37
|
})();
|
|
38
38
|
</script>
|
|
39
|
-
<script type="module" crossorigin src="/assets/index-
|
|
39
|
+
<script type="module" crossorigin src="/assets/index-BMssP4k3.js"></script>
|
|
40
40
|
<link rel="stylesheet" crossorigin href="/assets/index-BB6uK6tU.css">
|
|
41
41
|
</head>
|
|
42
42
|
<body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bitkyc08/opencodex",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.86.0",
|
|
4
4
|
"description": "Universal provider proxy for OpenAI Codex & Claude Code — use any LLM with Codex CLI/App/SDK and Claude Code",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./bin/package-main.mjs",
|
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
"assets/claude-code-models.gif",
|
|
25
25
|
"assets/codex-app-picker.png",
|
|
26
26
|
"assets/sponsors/orcarouter.png",
|
|
27
|
-
"assets/sponsors/packycode.png",
|
|
28
27
|
"assets/sponsors/tokenlab-light.png",
|
|
29
28
|
"assets/sponsors/tokenlab-dark.png",
|
|
30
29
|
"README.md",
|
|
@@ -6,7 +6,10 @@
|
|
|
6
6
|
* list for the destination's provider class; a match is re-emitted in this file's own spelling,
|
|
7
7
|
* so no caller byte ever reaches the wire, and everything else is dropped. The caller learns
|
|
8
8
|
* nothing about which value was dropped, and the trace records only that something was
|
|
9
|
-
* (`anthropic-beta-dropped`)
|
|
9
|
+
* (`anthropic-beta-dropped`). The proxy log names a dropped value only when it is on this file's
|
|
10
|
+
* closed list of published beta names ({@link KNOWN_UNFORWARDED_BETAS}); anything else is counted,
|
|
11
|
+
* never echoed, so a caller-chosen value (which may carry an account or tenant name) cannot reach
|
|
12
|
+
* the log, while drift in the known set stays visible by name.
|
|
10
13
|
*
|
|
11
14
|
* Proxy-owned betas (the OAuth pair, the fast-mode beta) are not listed here: the lane sets them
|
|
12
15
|
* itself from the provider's own configuration, exactly as the adapter does.
|
|
@@ -36,6 +39,37 @@ const FIRST_PARTY_BETAS: readonly string[] = [
|
|
|
36
39
|
*/
|
|
37
40
|
const COMPATIBLE_BETAS: readonly string[] = [];
|
|
38
41
|
const INLINE_TOOLS_BETA = "inline-tools-2026-09-15";
|
|
42
|
+
/** Pairs with the top-level `context_management` body field; the builder forwards that field
|
|
43
|
+
* only when this beta survives the allowlist, so header and body never disagree. */
|
|
44
|
+
export const CONTEXT_MANAGEMENT_BETA = "context-management-2025-06-27";
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Published betas this lane recognizes but does not forward. Only these, and the allowlisted
|
|
48
|
+
* values above, are ever named in the log; the list grants nothing on the wire.
|
|
49
|
+
*/
|
|
50
|
+
const KNOWN_UNFORWARDED_BETAS: readonly string[] = [
|
|
51
|
+
"claude-code-20250219",
|
|
52
|
+
"oauth-2025-04-20",
|
|
53
|
+
"fast-mode-2026-02-01",
|
|
54
|
+
"thinking-token-count-2026-05-13",
|
|
55
|
+
"mid-conversation-tool-changes-2026-07-01",
|
|
56
|
+
"advanced-tool-use-2025-11-20",
|
|
57
|
+
"effort-2025-11-24",
|
|
58
|
+
"extended-cache-ttl-2025-04-11",
|
|
59
|
+
"context-1m-2025-08-07",
|
|
60
|
+
"tool-search-tool-2025-10-19",
|
|
61
|
+
"files-api-2025-04-14",
|
|
62
|
+
"token-efficient-tools-2025-02-19",
|
|
63
|
+
"fine-grained-tool-streaming-2025-05-14",
|
|
64
|
+
"code-execution-2025-08-25",
|
|
65
|
+
"mcp-client-2025-04-04",
|
|
66
|
+
"web-fetch-2025-09-10",
|
|
67
|
+
"computer-use-2025-01-24",
|
|
68
|
+
"output-128k-2025-02-19",
|
|
69
|
+
"structured-outputs-2025-11-13",
|
|
70
|
+
"skills-2025-10-02",
|
|
71
|
+
"model-context-window-exceeded-2025-08-26",
|
|
72
|
+
];
|
|
39
73
|
|
|
40
74
|
/** An observed Claude client already requested these native body schemas. Advisor may
|
|
41
75
|
* perform its explicitly requested model sub-inference; no feature or body is injected. */
|
|
@@ -48,6 +82,7 @@ const NATIVE_CLIENT_BETAS: readonly string[] = [
|
|
|
48
82
|
"thinking-display-updates-2026-08-18",
|
|
49
83
|
"prompt-caching-scope-2026-01-05",
|
|
50
84
|
"mid-conversation-system-2026-04-07",
|
|
85
|
+
CONTEXT_MANAGEMENT_BETA,
|
|
51
86
|
];
|
|
52
87
|
const NATIVE_CLIENT_ALLOWLIST = new Map(NATIVE_CLIENT_BETAS.map(beta => [beta.toLowerCase(), beta]));
|
|
53
88
|
|
|
@@ -62,10 +97,23 @@ const MAX_CALLER_BETA_HEADER_CHARS = 2048;
|
|
|
62
97
|
export interface AllowlistedAnthropicBetas {
|
|
63
98
|
/** Allowlisted values in this file's spelling, first-seen order, no duplicates. */
|
|
64
99
|
betas: string[];
|
|
65
|
-
/** Whether any non-empty caller value was left out.
|
|
100
|
+
/** Whether any non-empty caller value was left out. */
|
|
66
101
|
dropped: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Log-safe names of the dropped values: a value is named only when it is on this file's closed
|
|
104
|
+
* list of known beta names; every other dropped value is summarized by
|
|
105
|
+
* `droppedUnrecognized`. Bounded, deduplicated, never part of the wire or the trace.
|
|
106
|
+
*/
|
|
107
|
+
droppedNames: string[];
|
|
108
|
+
/** Dropped values left unnamed (not a known beta, past the name cap, or an oversized header). */
|
|
109
|
+
droppedUnrecognized: number;
|
|
67
110
|
}
|
|
68
111
|
|
|
112
|
+
const LOGGABLE_BETA_NAMES: ReadonlySet<string> = new Set([
|
|
113
|
+
...KNOWN_UNFORWARDED_BETAS, ...NATIVE_CLIENT_BETAS, ...FIRST_PARTY_BETAS,
|
|
114
|
+
].map(beta => beta.toLowerCase()));
|
|
115
|
+
const MAX_DROPPED_NAMES = 16;
|
|
116
|
+
|
|
69
117
|
/**
|
|
70
118
|
* Filter the caller's comma-separated `anthropic-beta` header for one provider class. An absent
|
|
71
119
|
* or blank header yields nothing and drops nothing.
|
|
@@ -75,20 +123,51 @@ export function allowlistAnthropicBetas(
|
|
|
75
123
|
providerClass: AnthropicProviderClass,
|
|
76
124
|
features: { inlineTools?: boolean; observedNativeClient?: boolean } = {},
|
|
77
125
|
): AllowlistedAnthropicBetas {
|
|
78
|
-
if (typeof callerHeader !== "string" || callerHeader.trim() === "")
|
|
79
|
-
|
|
126
|
+
if (typeof callerHeader !== "string" || callerHeader.trim() === "") {
|
|
127
|
+
return { betas: [], dropped: false, droppedNames: [], droppedUnrecognized: 0 };
|
|
128
|
+
}
|
|
129
|
+
if (callerHeader.length > MAX_CALLER_BETA_HEADER_CHARS) {
|
|
130
|
+
return { betas: [], dropped: true, droppedNames: [], droppedUnrecognized: 1 };
|
|
131
|
+
}
|
|
80
132
|
const allowed = providerClass === "first-party" && features.observedNativeClient ? NATIVE_CLIENT_ALLOWLIST : ALLOWLISTS[providerClass];
|
|
81
133
|
const betas: string[] = [];
|
|
82
|
-
|
|
134
|
+
const droppedNames: string[] = [];
|
|
135
|
+
let droppedUnrecognized = 0;
|
|
83
136
|
for (const part of callerHeader.split(",")) {
|
|
84
137
|
const token = part.trim().toLowerCase();
|
|
85
138
|
if (!token) continue;
|
|
86
139
|
const canonical = allowed.get(token) ?? (providerClass === "first-party" && features.inlineTools
|
|
87
140
|
&& token === INLINE_TOOLS_BETA ? INLINE_TOOLS_BETA : undefined);
|
|
88
|
-
if (canonical
|
|
89
|
-
|
|
141
|
+
if (canonical !== undefined) {
|
|
142
|
+
if (!betas.includes(canonical)) betas.push(canonical);
|
|
143
|
+
} else if (LOGGABLE_BETA_NAMES.has(token) && droppedNames.length < MAX_DROPPED_NAMES) {
|
|
144
|
+
if (!droppedNames.includes(token)) droppedNames.push(token);
|
|
145
|
+
} else {
|
|
146
|
+
droppedUnrecognized++;
|
|
147
|
+
}
|
|
90
148
|
}
|
|
91
|
-
return { betas, dropped };
|
|
149
|
+
return { betas, dropped: droppedNames.length > 0 || droppedUnrecognized > 0, droppedNames, droppedUnrecognized };
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const loggedDropSets = new Set<string>();
|
|
153
|
+
const MAX_LOGGED_DROP_SETS = 64;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* One proxy log line per distinct dropped set per process: `anthropic-beta-dropped=<names>`.
|
|
157
|
+
* Only the log-safe names from {@link allowlistAnthropicBetas} are written; other values are
|
|
158
|
+
* reported as a count. Repeated requests with the same set stay quiet.
|
|
159
|
+
*/
|
|
160
|
+
export function logDroppedAnthropicBetas(
|
|
161
|
+
result: Pick<AllowlistedAnthropicBetas, "droppedNames" | "droppedUnrecognized">,
|
|
162
|
+
warn: (line: string) => void = console.warn,
|
|
163
|
+
): void {
|
|
164
|
+
if (result.droppedNames.length === 0 && result.droppedUnrecognized === 0) return;
|
|
165
|
+
const names = [...result.droppedNames].sort().join(",");
|
|
166
|
+
const key = `${names}|${result.droppedUnrecognized > 0 ? "u" : ""}`;
|
|
167
|
+
if (loggedDropSets.has(key) || loggedDropSets.size >= MAX_LOGGED_DROP_SETS) return;
|
|
168
|
+
loggedDropSets.add(key);
|
|
169
|
+
const unrecognized = result.droppedUnrecognized > 0 ? ` (+${result.droppedUnrecognized} unnamed)` : "";
|
|
170
|
+
warn(`[anthropic] anthropic-beta-dropped=${names || "-"}${unrecognized}`);
|
|
92
171
|
}
|
|
93
172
|
|
|
94
173
|
/** The allowlist for one class, for documentation and tests. */
|
|
@@ -21,7 +21,7 @@ function valid(name: typeof NAMES[number], value: string): boolean {
|
|
|
21
21
|
if (!value || Buffer.byteLength(value) > MAX_VALUE_BYTES || /[^\x20-\x7e]/.test(value)) return false;
|
|
22
22
|
if (name === "User-Agent") {
|
|
23
23
|
const entrypoint = interceptEntrypoint(value);
|
|
24
|
-
return entrypoint === "cli" || entrypoint === "sdk-cli" || entrypoint === "sdk"
|
|
24
|
+
return entrypoint === "cli" || entrypoint === "sdk-cli" || entrypoint === "sdk" || entrypoint === "sdk-ts"
|
|
25
25
|
|| (DESKTOP_ENTRYPOINTS as readonly string[]).includes(entrypoint ?? "");
|
|
26
26
|
}
|
|
27
27
|
if (name === "X-App") return value === "cli";
|
|
@@ -30,12 +30,14 @@ import {
|
|
|
30
30
|
import { applyAnthropicClientIdentity, hasObservedAnthropicClientIdentity, type AnthropicClientIdentity } from "./client-identity";
|
|
31
31
|
import { bindAnthropicAccountMetadata } from "./account-metadata";
|
|
32
32
|
import { shouldPreserveNativeClientPreamble } from "./native-client-preamble";
|
|
33
|
-
import { allowlistAnthropicBetas } from "./beta-allowlist";
|
|
33
|
+
import { allowlistAnthropicBetas, CONTEXT_MANAGEMENT_BETA } from "./beta-allowlist";
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* Top-level Messages fields the native lane forwards. Everything else is dropped: an unknown or
|
|
37
37
|
* beta-gated field would otherwise reach the provider unchecked. None of the dropped fields has
|
|
38
38
|
* a name in the protocol feature vocabulary, so no feature effect is recorded for them.
|
|
39
|
+
* `context_management` is the one beta-gated field the builder adds back, and only together
|
|
40
|
+
* with its forwarded beta (see {@link CONTEXT_MANAGEMENT_BETA}).
|
|
39
41
|
*/
|
|
40
42
|
export const ANTHROPIC_MESSAGES_PASSTHROUGH_FIELDS = [
|
|
41
43
|
"model",
|
|
@@ -64,8 +66,12 @@ export interface AnthropicMessagesPassthroughRequest {
|
|
|
64
66
|
body: string;
|
|
65
67
|
/** The same body before serialization, for callers that count or inspect what is sent. */
|
|
66
68
|
wireBody: Record<string, unknown>;
|
|
67
|
-
/** Caller `anthropic-beta` values were left out.
|
|
69
|
+
/** Caller `anthropic-beta` values were left out. The trace never records which ones. */
|
|
68
70
|
droppedBetas: boolean;
|
|
71
|
+
/** Log-safe names of the dropped values (known beta names only); see beta-allowlist.ts. */
|
|
72
|
+
droppedBetaNames: string[];
|
|
73
|
+
/** Dropped values that are not known beta names, counted only. */
|
|
74
|
+
droppedUnrecognizedBetas: number;
|
|
69
75
|
/** Thinking signatures or `redacted_thinking` blocks were removed for this destination. */
|
|
70
76
|
strippedOpaqueState: boolean;
|
|
71
77
|
/**
|
|
@@ -239,6 +245,23 @@ export function anthropicOAuthWireBody(body: Rec, clientIdentity?: AnthropicClie
|
|
|
239
245
|
return { body: out, toolNames };
|
|
240
246
|
}
|
|
241
247
|
|
|
248
|
+
/**
|
|
249
|
+
* `context_management` for the wire. Under OAuth, declared client tools travel with the OAuth
|
|
250
|
+
* prefix, so an edit's `exclude_tools` must name the same wire spelling or the tools it means to
|
|
251
|
+
* protect stop matching and their context can be cleared. Copy-on-write; anything else is opaque.
|
|
252
|
+
*/
|
|
253
|
+
export function contextManagementForWire(value: unknown, oauthToolNames?: ReadonlyMap<string, string>): unknown {
|
|
254
|
+
if (!oauthToolNames || oauthToolNames.size === 0 || !isRec(value) || !Array.isArray(value.edits)) return value;
|
|
255
|
+
const callerToWire = new Map([...oauthToolNames].map(([wire, caller]) => [caller, wire]));
|
|
256
|
+
const edits = mapPreservingIdentity(value.edits as unknown[], edit => {
|
|
257
|
+
if (!isRec(edit) || !Array.isArray(edit.exclude_tools)) return edit;
|
|
258
|
+
const excludeTools = mapPreservingIdentity(edit.exclude_tools as unknown[],
|
|
259
|
+
name => typeof name === "string" ? callerToWire.get(name) ?? name : name);
|
|
260
|
+
return excludeTools === edit.exclude_tools ? edit : { ...edit, exclude_tools: excludeTools };
|
|
261
|
+
});
|
|
262
|
+
return edits === value.edits ? value : { ...value, edits };
|
|
263
|
+
}
|
|
264
|
+
|
|
242
265
|
/**
|
|
243
266
|
* What the native lane sends for this provider, without a credential: the allowlisted body,
|
|
244
267
|
* opaque state kept only for first-party Anthropic, and the OAuth request shape for an OAuth
|
|
@@ -306,12 +329,18 @@ export function buildAnthropicMessagesPassthroughRequest(
|
|
|
306
329
|
const betas = allowlistAnthropicBetas(options.callerAnthropicBeta, domain?.firstPartyAnthropic ? "first-party" : "compatible",
|
|
307
330
|
{ inlineTools: hasInlineToolChanges(wireBody), observedNativeClient: hasObservedAnthropicClientIdentity(options.clientIdentity) });
|
|
308
331
|
mergeAnthropicBetaHeader(headers, betas.betas);
|
|
332
|
+
// Header and body travel as a pair: the field goes out only when its beta does.
|
|
333
|
+
const sentBody = betas.betas.includes(CONTEXT_MANAGEMENT_BETA) && body.context_management !== undefined
|
|
334
|
+
? { ...wireBody, context_management: contextManagementForWire(body.context_management, oauthToolNames) }
|
|
335
|
+
: wireBody;
|
|
309
336
|
return {
|
|
310
337
|
url,
|
|
311
338
|
headers,
|
|
312
|
-
body: JSON.stringify(
|
|
313
|
-
wireBody,
|
|
339
|
+
body: JSON.stringify(sentBody),
|
|
340
|
+
wireBody: sentBody,
|
|
314
341
|
droppedBetas: betas.dropped,
|
|
342
|
+
droppedBetaNames: betas.droppedNames,
|
|
343
|
+
droppedUnrecognizedBetas: betas.droppedUnrecognized,
|
|
315
344
|
strippedOpaqueState,
|
|
316
345
|
...(oauthToolNames ? { oauthToolNames } : {}),
|
|
317
346
|
};
|
package/src/adapters/azure.ts
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import type { IncomingMeta, ProviderAdapter } from "./base";
|
|
2
2
|
import type { OcxParsedRequest, OcxProviderConfig } from "../types";
|
|
3
3
|
import { createResponsesPassthroughAdapter } from "./openai-responses";
|
|
4
|
+
import { isPlainObject } from "./openai-responses/internal";
|
|
5
|
+
|
|
6
|
+
/** Shared by wire construction and pre-dispatch spend admission. */
|
|
7
|
+
export function effectiveAzureOutputBudget(provider: OcxProviderConfig, budget: unknown): unknown {
|
|
8
|
+
const floor = provider.minMaxOutputTokens;
|
|
9
|
+
return (provider.adapter === "azure" || provider.adapter === "azure-openai")
|
|
10
|
+
&& typeof floor === "number" && Number.isInteger(floor) && floor > 0
|
|
11
|
+
&& typeof budget === "number" && Number.isInteger(budget) && budget > 0 && budget < floor
|
|
12
|
+
? floor : budget;
|
|
13
|
+
}
|
|
4
14
|
|
|
5
15
|
export function createAzureAdapter(provider: OcxProviderConfig): ProviderAdapter & { passthrough: true } {
|
|
6
16
|
const inner = createResponsesPassthroughAdapter({
|
|
@@ -20,7 +30,15 @@ export function createAzureAdapter(provider: OcxProviderConfig): ProviderAdapter
|
|
|
20
30
|
throw new Error("azure-openai requires a non-empty apiKey");
|
|
21
31
|
}
|
|
22
32
|
|
|
23
|
-
|
|
33
|
+
// An operator may opt into a floor for deployments that reject tiny validation
|
|
34
|
+
// budgets. Copy only the envelope; keep caller-owned input and normal serialization.
|
|
35
|
+
const raw = parsed._rawBody;
|
|
36
|
+
const budget = isPlainObject(raw) ? raw.max_output_tokens : undefined;
|
|
37
|
+
const effectiveBudget = effectiveAzureOutputBudget(provider, budget);
|
|
38
|
+
const effective = effectiveBudget !== budget && isPlainObject(raw)
|
|
39
|
+
? { ...parsed, _rawBody: { ...raw, max_output_tokens: effectiveBudget } }
|
|
40
|
+
: parsed;
|
|
41
|
+
const request = await inner.buildRequest(effective, incoming);
|
|
24
42
|
const unresolvedPlaceholder = request.url.match(/\{[^}]*\}/)?.[0] ?? request.url.match(/[{}]/)?.[0];
|
|
25
43
|
if (unresolvedPlaceholder) {
|
|
26
44
|
throw new Error(`azure-openai baseUrl contains unresolved ${unresolvedPlaceholder} — set your real resource URL`);
|
|
@@ -55,6 +55,8 @@ const ANTIGRAVITY_IDE_PLATFORM = "windows/amd64";
|
|
|
55
55
|
* Must be the IDE client family (`antigravity/ide/...`): Cloud Code Assist backend gates
|
|
56
56
|
* newer agent models (e.g. `gemini-3.7-flash`) by User-Agent and answers 404 NOT_FOUND to
|
|
57
57
|
* CLI-shaped UAs even with a valid OAuth token. Only `antigravity/ide/<ver>` unlocks them.
|
|
58
|
+
* The one exception is Gemini 4 Argon, which CCA serves ONLY to the CLI family; see
|
|
59
|
+
* `antigravityCliUserAgent`.
|
|
58
60
|
* A `GOOGLE_ANTIGRAVITY_USER_AGENT` override (set by the caller) takes precedence upstream.
|
|
59
61
|
*/
|
|
60
62
|
export function antigravityUserAgent(version = ANTIGRAVITY_IDE_VERSION, authMethod = "oauth"): string {
|
|
@@ -63,3 +65,25 @@ export function antigravityUserAgent(version = ANTIGRAVITY_IDE_VERSION, authMeth
|
|
|
63
65
|
const [osType, arch] = ANTIGRAVITY_IDE_PLATFORM.split("/");
|
|
64
66
|
return `antigravity/ide/${version} (os_type=${osType}; arch=${arch}; ${ANTIGRAVITY_IDE_CLIENT_NAME}; auth_method=${authMethod})`;
|
|
65
67
|
}
|
|
68
|
+
|
|
69
|
+
// ── Antigravity CLI ──
|
|
70
|
+
/** Antigravity CLI version whose User-Agent CCA was verified to serve Gemini 4 Argon to. */
|
|
71
|
+
export const ANTIGRAVITY_CLI_VERSION = "1.3.4";
|
|
72
|
+
const ANTIGRAVITY_CLI_PLATFORM = "darwin/arm64";
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Antigravity CLI User-Agent:
|
|
76
|
+
* `antigravity/cli/${version} (os_type=${osType}; arch=${arch}; aidev_client; auth_method=oauth)`.
|
|
77
|
+
*
|
|
78
|
+
* Verified 2026-10-14 against live CCA: `gemini-4-argon-{low,medium,high}` answer only to this
|
|
79
|
+
* family and return 404 "Requested entity was not found" to the IDE UA above, while
|
|
80
|
+
* `gemini-3.7-flash-tiered` and `gemini-3.1-pro-low` 404 under this one. So it is used ONLY for
|
|
81
|
+
* Argon requests and for model discovery, never as a general replacement for the IDE UA.
|
|
82
|
+
*
|
|
83
|
+
* `GOOGLE_ANTIGRAVITY_USER_AGENT` deliberately does not apply here: that override names the IDE
|
|
84
|
+
* header, and letting it replace this one would re-lock Argon for anyone who set it.
|
|
85
|
+
*/
|
|
86
|
+
export function antigravityCliUserAgent(version = ANTIGRAVITY_CLI_VERSION, authMethod = "oauth"): string {
|
|
87
|
+
const [osType, arch] = ANTIGRAVITY_CLI_PLATFORM.split("/");
|
|
88
|
+
return `antigravity/cli/${version} (os_type=${osType}; arch=${arch}; ${ANTIGRAVITY_IDE_CLIENT_NAME}; auth_method=${authMethod})`;
|
|
89
|
+
}
|
|
@@ -105,6 +105,14 @@ export function redactSecrets(text: string, tokenEnv: string | undefined, creden
|
|
|
105
105
|
.replace(/\b(sk-[A-Za-z0-9_-]{6,})\b/g, "[redacted]");
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
+
export type CodingAgentFailure = {
|
|
109
|
+
profile: CodingAgentProviderProfile;
|
|
110
|
+
error: Extract<AdapterEvent, { type: "error" }>;
|
|
111
|
+
} & (
|
|
112
|
+
| { source: "result"; frame: Record<string, unknown> }
|
|
113
|
+
| { source: "process-exit"; exitCode: number; stderr: string }
|
|
114
|
+
);
|
|
115
|
+
|
|
108
116
|
/** Inputs for one headless CLI turn: region profiles, request context, and family-specific arg/env builders. */
|
|
109
117
|
export interface CodingAgentTurnInput {
|
|
110
118
|
/** Region profiles for this family; the turn fails closed if the base URL matches none. */
|
|
@@ -123,6 +131,8 @@ export interface CodingAgentTurnInput {
|
|
|
123
131
|
* The MCP handler never executes the client tool.
|
|
124
132
|
*/
|
|
125
133
|
toolBridge?: CodingAgentToolBridgeInput;
|
|
134
|
+
/** Vendor semantics and recovery permission stay with the adapter. */
|
|
135
|
+
classifyFailure?: (failure: CodingAgentFailure) => Extract<AdapterEvent, { type: "error" }>;
|
|
126
136
|
deps: CodingAgentDeps;
|
|
127
137
|
}
|
|
128
138
|
|
|
@@ -495,7 +505,11 @@ export async function runCodingAgentTurn(input: CodingAgentTurnInput): Promise<v
|
|
|
495
505
|
break;
|
|
496
506
|
}
|
|
497
507
|
}
|
|
498
|
-
const mappedEvents = mapStreamMessageToEvents(message, state)
|
|
508
|
+
const mappedEvents = mapStreamMessageToEvents(message, state).map(event => {
|
|
509
|
+
if (message.type !== "result" || event.type !== "error") return event;
|
|
510
|
+
if (input.classifyFailure) return input.classifyFailure({ source: "result", frame: message, error: event, profile });
|
|
511
|
+
return event;
|
|
512
|
+
});
|
|
499
513
|
if (state.toolCallLimitExceeded) {
|
|
500
514
|
emitOnce({
|
|
501
515
|
type: "error",
|
|
@@ -726,14 +740,13 @@ export async function runCodingAgentTurn(input: CodingAgentTurnInput): Promise<v
|
|
|
726
740
|
const exitMsg = stderr
|
|
727
741
|
? `${profile.label} CLI exited with code ${child.exitCode}: ${stderr}`
|
|
728
742
|
: `${profile.label} CLI exited with non-zero exit code ${child.exitCode}`;
|
|
729
|
-
|
|
730
|
-
type: "error",
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
});
|
|
743
|
+
const error: Extract<AdapterEvent, { type: "error" }> = {
|
|
744
|
+
type: "error", message: exitMsg, status: 502, errorType: "upstream_error",
|
|
745
|
+
code: "process_exit_error", retryable: false,
|
|
746
|
+
};
|
|
747
|
+
emitOnce(input.classifyFailure
|
|
748
|
+
? input.classifyFailure({ source: "process-exit", exitCode: child.exitCode, stderr, error, profile })
|
|
749
|
+
: error);
|
|
737
750
|
} else if (toolBridge && deferredResultDone !== undefined && !sawSelectedToolTurnStop()) {
|
|
738
751
|
emitOnce({
|
|
739
752
|
type: "error",
|
|
@@ -18,21 +18,33 @@ function sameBytes(a: Uint8Array, b: Uint8Array): boolean {
|
|
|
18
18
|
return true;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
/**
|
|
22
|
+
* `preserveStrings` is for freeform tool bodies (#7049). A freeform `input` is text whatever it
|
|
23
|
+
* looks like, so a body that happens to be valid JSON (`{}`, `42`, `null`) must not be
|
|
24
|
+
* re-parsed into a non-string. A protobuf string Value is taken as-is; raw UTF-8 bytes are still
|
|
25
|
+
* unquoted when they are one JSON string literal, and otherwise kept as the raw text.
|
|
26
|
+
*/
|
|
27
|
+
export function decodeCursorArgValue(value: Uint8Array, options: { preserveStrings?: boolean } = {}): unknown {
|
|
22
28
|
try {
|
|
23
29
|
const parsed = fromBinary(ValueSchema, value);
|
|
24
30
|
if (!sameBytes(toBinary(ValueSchema, parsed), value)) throw new Error("not canonical protobuf Value bytes");
|
|
25
31
|
const jsonValue = toJson(ValueSchema, parsed);
|
|
26
|
-
|
|
32
|
+
if (typeof jsonValue !== "string") return jsonValue;
|
|
33
|
+
return options.preserveStrings ? jsonValue : parseJsonText(jsonValue);
|
|
27
34
|
} catch {
|
|
28
|
-
|
|
35
|
+
const text = textDecoder.decode(value);
|
|
36
|
+
const parsed = parseJsonText(text);
|
|
37
|
+
return options.preserveStrings && typeof parsed !== "string" ? text : parsed;
|
|
29
38
|
}
|
|
30
39
|
}
|
|
31
40
|
|
|
32
|
-
export function decodeCursorArgsMap(
|
|
41
|
+
export function decodeCursorArgsMap(
|
|
42
|
+
args: { [key: string]: Uint8Array } | undefined,
|
|
43
|
+
options: { preserveStrings?: boolean } = {},
|
|
44
|
+
): Record<string, unknown> {
|
|
33
45
|
const out: Record<string, unknown> = {};
|
|
34
46
|
for (const [key, value] of Object.entries(args ?? {})) {
|
|
35
|
-
out[key] = decodeCursorArgValue(value);
|
|
47
|
+
out[key] = decodeCursorArgValue(value, options);
|
|
36
48
|
}
|
|
37
49
|
return out;
|
|
38
50
|
}
|
|
@@ -244,6 +244,14 @@ export const CURSOR_CAPABILITIES: Record<string, CursorCapability> = {
|
|
|
244
244
|
defaultVariant: "regular",
|
|
245
245
|
variants: { regular: { levels: ["low", "medium", "high"] } },
|
|
246
246
|
},
|
|
247
|
+
// 261014 preemptive, like gemini-3.8-flash: Cursor's models page lists Gemini 4 Argon, but the
|
|
248
|
+
// live GetUsableModels id is unverified. Inert until the live roster lists this id.
|
|
249
|
+
"gemini-4-argon": {
|
|
250
|
+
displayName: "Gemini 4 Argon",
|
|
251
|
+
window: CONTEXT_GEMINI,
|
|
252
|
+
defaultVariant: "regular",
|
|
253
|
+
variants: { regular: { levels: ["low", "medium", "high"] } },
|
|
254
|
+
},
|
|
247
255
|
// Seeded from the live GetUsableModels roster attached to #4820, which advertises six
|
|
248
256
|
// muse-spark-1.3 effort variants. The ladder stops at xhigh on purpose: see the matching
|
|
249
257
|
// effort-map entry for why Cursor advertising `-max` is not evidence that it runs.
|
|
@@ -56,6 +56,9 @@ const CURSOR_MODEL_EFFORT_TIERS: Record<string, readonly string[]> = {
|
|
|
56
56
|
// glm-5.3 was. Google documents low/medium/high with no `minimal` for this generation,
|
|
57
57
|
// unlike 3.6. The seed is inert until Cursor's live roster lists the id.
|
|
58
58
|
"gemini-3.8-flash": ["low", "medium", "high"],
|
|
59
|
+
// 261014 preemptive: Gemini 4 Argon, low/medium/high with no `minimal` (a documented 400).
|
|
60
|
+
// Inert until Cursor's live roster lists the id.
|
|
61
|
+
"gemini-4-argon": ["low", "medium", "high"],
|
|
59
62
|
// Explicit-thinking variants (260825 live roster). Tiers are the rungs the wire actually
|
|
60
63
|
// lists for each family, which is not always the same set the non-thinking id carries:
|
|
61
64
|
// 4.6-opus thinks only at high/max, 4.5-opus only at high, 4.6-sonnet only at medium.
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { freeformFallbackKeys } from "../../responses/apply-patch-envelope";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Pre-emission gate for Cursor calls to request-declared freeform tools (#7049).
|
|
5
|
+
*
|
|
6
|
+
* Cursor carries a freeform body as a JSON object, and the canonical shape is `{input:string}`.
|
|
7
|
+
* Claude models routed through Cursor also name the body after its content — `{"code": "..."}`
|
|
8
|
+
* for the code-mode `exec` cell — and the shared Responses repair downstream already unwraps
|
|
9
|
+
* exactly that (`unwrapFreeformToolInput`: no `input` key, ONE string-valued fallback key).
|
|
10
|
+
* This gate used to accept only `input`, so it turned a payload the bridge knows how to read
|
|
11
|
+
* into a fatal adapter error before any host execution. It now applies the same single faithful
|
|
12
|
+
* reading and re-emits it canonically; anything ambiguous or non-string still fails closed.
|
|
13
|
+
*
|
|
14
|
+
* A canonical wrapper is returned byte-identical. Only the repaired shape is re-serialized.
|
|
15
|
+
*/
|
|
16
|
+
export type CursorFreeformArgs =
|
|
17
|
+
| { ok: true; args: string }
|
|
18
|
+
| { ok: false; reason: string };
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The only key names a diagnostic may print. They are constants written here, so the error can
|
|
22
|
+
* never carry request-derived text: a model can put body text or an identifier in key position,
|
|
23
|
+
* and the message is persisted to request logs. Every other key is counted, not named.
|
|
24
|
+
*/
|
|
25
|
+
const NAMEABLE_KEYS: ReadonlySet<string> = new Set([
|
|
26
|
+
"input",
|
|
27
|
+
"code", "script", "js", "javascript", "command", "cmd", "content", "patch",
|
|
28
|
+
"source", "program", "body", "text", "args", "arguments",
|
|
29
|
+
]);
|
|
30
|
+
const MAX_LISTED_KEYS = 8;
|
|
31
|
+
|
|
32
|
+
function valueKind(value: unknown): string {
|
|
33
|
+
if (value === null) return "null";
|
|
34
|
+
if (Array.isArray(value)) return "array";
|
|
35
|
+
return typeof value;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Shape-only description of a rejected wrapper: allowlisted key names with their value kinds,
|
|
40
|
+
* then a count of every other key. Never values, never an unlisted key name.
|
|
41
|
+
*/
|
|
42
|
+
function describeKeys(record: Record<string, unknown>): string {
|
|
43
|
+
const keys = Object.keys(record);
|
|
44
|
+
if (keys.length === 0) return "received an empty object";
|
|
45
|
+
const listed = keys.filter(key => NAMEABLE_KEYS.has(key))
|
|
46
|
+
.slice(0, MAX_LISTED_KEYS)
|
|
47
|
+
.map(key => `${key}:${valueKind(record[key])}`);
|
|
48
|
+
const hidden = keys.length - listed.length;
|
|
49
|
+
if (hidden > 0) listed.push(`+${hidden} other`);
|
|
50
|
+
return `received keys [${listed.join(", ")}]`;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function canonicalCursorFreeformArgs(args: string, toolName: string): CursorFreeformArgs {
|
|
54
|
+
if (args.length === 0) return { ok: false, reason: "received no arguments" };
|
|
55
|
+
let parsed: unknown;
|
|
56
|
+
try {
|
|
57
|
+
parsed = JSON.parse(args);
|
|
58
|
+
} catch {
|
|
59
|
+
return { ok: false, reason: "received arguments that are not JSON" };
|
|
60
|
+
}
|
|
61
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
62
|
+
return { ok: false, reason: `received a JSON ${valueKind(parsed)}` };
|
|
63
|
+
}
|
|
64
|
+
const record = parsed as Record<string, unknown>;
|
|
65
|
+
if (Object.prototype.hasOwnProperty.call(record, "input")) {
|
|
66
|
+
return typeof record.input === "string"
|
|
67
|
+
? { ok: true, args }
|
|
68
|
+
: { ok: false, reason: `input was ${valueKind(record.input)}` };
|
|
69
|
+
}
|
|
70
|
+
const candidates = freeformFallbackKeys(toolName).filter(key => typeof record[key] === "string");
|
|
71
|
+
if (candidates.length === 1) {
|
|
72
|
+
return { ok: true, args: JSON.stringify({ input: record[candidates[0]] as string }) };
|
|
73
|
+
}
|
|
74
|
+
return { ok: false, reason: describeKeys(record) };
|
|
75
|
+
}
|