@bitkyc08/opencodex 2.100.0 → 2.100.2
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/gui/dist/assets/App-BpJOzw4F.js +59 -0
- package/gui/dist/assets/Tray-BcaI-VCr.js +1 -0
- package/gui/dist/assets/brand-mark-DU-0Vdkr.js +1 -0
- package/gui/dist/assets/index-Bbor_y80.js +94 -0
- package/gui/dist/assets/index-DJEkIDAi.css +2 -0
- package/gui/dist/assets/{segment-thumb-features-CcxZBnxv.js → segment-thumb-features-e9A_FogJ.js} +1 -1
- package/gui/dist/classic/assets/{App-aYgIQMxI.js → App-BrIlUiLc.js} +18 -18
- package/gui/dist/classic/assets/{Tray-D8jfUXpQ.js → Tray-DT146AhS.js} +1 -1
- package/gui/dist/classic/assets/index-DyJHagvT.js +94 -0
- package/gui/dist/classic/assets/quota-summary-CakPe9Ni.js +1 -0
- package/gui/dist/classic/index.html +1 -1
- package/gui/dist/index.html +2 -2
- package/package.json +2 -2
- package/src/adapters/anthropic-image-normalize.ts +1 -1
- package/src/adapters/client-fingerprint.ts +6 -4
- package/src/adapters/cursor/native-exec.ts +3 -2
- package/src/adapters/cursor/tool-guidance.ts +3 -3
- package/src/adapters/cursor/tool-wording.ts +10 -1
- package/src/adapters/devin/cloud-direct/tool-schema.ts +20 -2
- package/src/adapters/google-antigravity-wire.ts +13 -6
- package/src/adapters/google-truncation.ts +4 -2
- package/src/adapters/google.ts +8 -2
- package/src/adapters/openai-chat/mistral-image-limit.ts +28 -15
- package/src/adapters/openai-chat/tool-schema.ts +9 -0
- package/src/adapters/openai-chat-images.ts +100 -0
- package/src/adapters/openai-chat.ts +6 -9
- package/src/adapters/openai-responses/tool-schema.ts +18 -4
- package/src/adapters/run-turn-queue.ts +139 -5
- package/src/adapters/upstream-http-error.ts +4 -2
- package/src/bridge/sse.ts +8 -1
- package/src/claude/chat-tool-dispatch.ts +233 -0
- package/src/claude/inbound-tool-loading.ts +42 -17
- package/src/cli/account-api.ts +6 -0
- package/src/cli/account-extended.ts +60 -6
- package/src/cli/account-key-quota.ts +22 -2
- package/src/cli/account.ts +1 -1
- package/src/cli/capabilities-access-remote.ts +10 -0
- package/src/cli/capabilities-agents-routing.ts +2 -2
- package/src/cli/capabilities-base.ts +2 -2
- package/src/cli/claude.ts +19 -14
- package/src/cli/config-command.ts +24 -1
- package/src/cli/connect.ts +36 -3
- package/src/cli/gui-pair-client.ts +23 -2
- package/src/cli/help.ts +1 -1
- package/src/cli/hub.ts +18 -1
- package/src/cli/link-child-ops.ts +136 -0
- package/src/cli/link-status-child.ts +94 -0
- package/src/cli/link.ts +22 -9
- package/src/cli/registry.ts +3 -2
- package/src/cli/sync-command.ts +3 -1
- package/src/cli/sync-fanout.ts +8 -81
- package/src/client/link-readiness.ts +16 -6
- package/src/client/link-tunnel-status.ts +76 -0
- package/src/clients/config-export.ts +14 -1
- package/src/codex/account-resume-health.ts +41 -0
- package/src/codex/auth-api/login-flow.ts +6 -0
- package/src/codex/auth-api/routes.ts +35 -2
- package/src/codex/catalog/gather-capture.ts +2 -0
- package/src/codex/catalog/provider-models.ts +13 -8
- package/src/codex/convergence-types.ts +2 -0
- package/src/codex/quota.ts +111 -6
- package/src/combos/cooldown-store.ts +208 -0
- package/src/combos/failover.ts +432 -35
- package/src/config/salvage.ts +1 -0
- package/src/config/schema/config-schema.ts +6 -3
- package/src/config/schema/leaf-validators.ts +34 -12
- package/src/generated/compatibility-version.json +227 -135
- package/src/lib/catalog-etag.ts +10 -0
- package/src/lib/client-error-body.ts +15 -0
- package/src/lib/config-ownership.ts +9 -2
- package/src/lib/context-overflow-verdict.ts +266 -9
- package/src/lib/failure-detail.ts +72 -3
- package/src/lib/hard-refusal.ts +259 -0
- package/src/link/child-activity.ts +57 -0
- package/src/link/child-catalog-freshness.ts +149 -0
- package/src/link/child-gated-ocx.ts +117 -0
- package/src/link/child-observations.ts +205 -0
- package/src/link/child-observe.ts +121 -0
- package/src/link/child-ops-engine.ts +162 -0
- package/src/link/child-update-contract.ts +165 -0
- package/src/link/paths.ts +5 -0
- package/src/link/remote-windows.ts +42 -6
- package/src/link/ssh-argv.ts +126 -32
- package/src/link/status-projection.ts +73 -0
- package/src/link/sync-fanout-classify.ts +98 -0
- package/src/link/tunnel-state.ts +10 -4
- package/src/messaging/mcp-queue-rpc.ts +2 -1
- package/src/messaging/mcp-queue-server.ts +5 -0
- package/src/messaging/mcp-reply-tools.ts +24 -9
- package/src/messaging/mcp-reply-wait.ts +70 -0
- package/src/oauth/account-resume-health.ts +60 -0
- package/src/oauth/anthropic-model-quota.ts +12 -0
- package/src/oauth/anthropic-routing.ts +11 -4
- package/src/oauth/index.ts +1 -0
- package/src/oauth/kiro-iam-identity-center.ts +4 -1
- package/src/oauth/store.ts +44 -1
- package/src/providers/api-key-pause-state.ts +23 -0
- package/src/providers/api-key-pause.ts +68 -10
- package/src/providers/api-key-selection-capture.ts +3 -1
- package/src/providers/api-key-selection.ts +3 -2
- package/src/providers/api-keys.ts +18 -5
- package/src/providers/claude-cli-identity.ts +9 -3
- package/src/providers/claude-cli-usage-state.ts +11 -6
- package/src/providers/claude-cli-usage.ts +27 -8
- package/src/providers/codex-capacity.ts +11 -2
- package/src/providers/key-failover.ts +13 -6
- package/src/providers/model-discovery-config.ts +31 -0
- package/src/providers/model-discovery-diagnostic.ts +34 -3
- package/src/providers/model-discovery.ts +43 -7
- package/src/providers/model-rename-fields.ts +2 -0
- package/src/providers/openai-sidecar.ts +15 -2
- package/src/providers/provider-id-rewrite.ts +3 -0
- package/src/providers/quota/account-cache.ts +52 -34
- package/src/providers/quota/anthropic-family-headers.ts +8 -1
- package/src/providers/quota/anthropic-usage-windows.ts +66 -9
- package/src/providers/quota/report-cache.ts +53 -5
- package/src/providers/quota/vendor-probes-key.ts +73 -0
- package/src/providers/quota/vendor-probes-oauth.ts +57 -3
- package/src/providers/quota-key-accounts.ts +12 -5
- package/src/providers/quota-mistral-budget.ts +18 -0
- package/src/providers/quota-types.ts +32 -0
- package/src/providers/quota.ts +22 -22
- package/src/providers/reasoning-metadata.ts +1051 -12
- package/src/providers/registry/entries-extended.ts +3 -1
- package/src/providers/registry/model-ids.ts +1 -0
- package/src/providers/registry/types.ts +6 -0
- package/src/quota/reset-observer.ts +4 -2
- package/src/quota/reset-seen-store.ts +9 -0
- package/src/quota/window-mapping.ts +1 -0
- package/src/quota-pool/assemble.ts +4 -1
- package/src/responses/hosted-tool-policy.ts +56 -12
- package/src/responses/retained-compaction.ts +31 -5
- package/src/router.ts +2 -0
- package/src/server/auth-cors.ts +11 -8
- package/src/server/catalog-download.ts +3 -5
- package/src/server/chat-native.ts +11 -2
- package/src/server/claude-messages.ts +2 -1
- package/src/server/images.ts +41 -13
- package/src/server/index/link-listener.ts +16 -2
- package/src/server/index/link-relay-sessions.ts +43 -2
- package/src/server/index/optional-listeners.ts +18 -0
- package/src/server/management/config-routes.ts +7 -1
- package/src/server/management/context.ts +1 -1
- package/src/server/management/link-child-ops-routes.ts +116 -0
- package/src/server/management/link-route-state.ts +10 -0
- package/src/server/management/link-routes.ts +10 -0
- package/src/server/management/oauth-account-routes.ts +33 -4
- package/src/server/management/provider-overwrite-carry.ts +28 -3
- package/src/server/management/provider-routes.ts +16 -11
- package/src/server/management/route-registry.ts +3 -0
- package/src/server/messages-native.ts +5 -0
- package/src/server/request-log-failure-detail.ts +59 -1
- package/src/server/responses/adapter-dispatch.ts +35 -44
- package/src/server/responses/combo-stream-preflight.ts +146 -29
- package/src/server/responses/compact.ts +27 -4
- package/src/server/responses/context-overflow.ts +58 -2
- package/src/server/responses/core-combo-failure.ts +29 -4
- package/src/server/responses/core-combo-native.ts +3 -1
- package/src/server/responses/core-combo.ts +30 -3
- package/src/server/responses/core-errors.ts +3 -1
- package/src/server/responses/core-opaque-recovery.ts +45 -2
- package/src/server/responses/core-options.ts +12 -0
- package/src/server/responses/passthrough-dispatch.ts +30 -38
- package/src/server/responses/request-transport.ts +43 -14
- package/src/server/responses/reset-replay.ts +58 -2
- package/src/server/responses/run-turn-execution.ts +56 -30
- package/src/types/claude-tool-loading.ts +48 -0
- package/src/types/config.ts +5 -35
- package/src/types/provider.ts +21 -0
- package/src/types.ts +1 -0
- package/src/web-search/parse.ts +44 -4
- package/gui/dist/assets/App-CitvEefy.js +0 -59
- package/gui/dist/assets/Tray-CeKVWQyB.js +0 -1
- package/gui/dist/assets/brand-mark-M92UnxX2.js +0 -1
- package/gui/dist/assets/index-BP47do6-.js +0 -94
- package/gui/dist/assets/index-DmDooSAG.css +0 -2
- package/gui/dist/classic/assets/index-CfGqHooN.js +0 -94
- package/gui/dist/classic/assets/quota-summary-R-ih7OlS.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{E as e,M as t,n}from"./index-DyJHagvT.js";var r=n(),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`})}),_=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`M12 5v14M5 12h14`})}),v=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`M5 12h14`})}),ee=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`})}),te=e=>(0,r.jsxs)(`svg`,{...i(e),children:[(0,r.jsx)(`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`}),(0,r.jsx)(`path`,{d:`M3 3v5h5M12 7v5l4 2`})]}),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`})]}),y=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`})}),b={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`,"dsh-account":`deepseek-color.svg`,"workbuddy-ai":`workbuddy-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`},x={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`,"dsh-account":`DeepSeek Account (DSH)`,"workbuddy-ai":`WorkBuddy AI`,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`},S={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(x),...Object.keys(S)]);function Ae(e){let t=e.toLowerCase();return Object.hasOwn(b,t)?b[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 C(e,t){let n=e.toLowerCase(),r=Object.hasOwn(S,n)?S[n]:void 0;return r?t(r):(Object.hasOwn(x,n)?x[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 w(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`${w((e/t.v).toFixed(1))}${t.s}`;return String(e)}return e<1e4?String(e):e<1e6?`${w((e/1e3).toFixed(1))}K`:e<1e9?`${w((e/1e6).toFixed(1))}M`:e<0xe8d4a51000?`${w((e/1e9).toFixed(1))}B`:`${w((e/0xe8d4a51000).toFixed(1))}T`}var Ve=new Set([`claude-cli`]),He=`anthropic-apikey`;function T(e){return Ve.has((e.adapter??``).trim())}var E=`https://chatgpt.com/backend-api/codex`,Ue=`openai`;function D(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(E).protocol;function O(e,...t){return`${We}//${e}/${t.join(`/`)}`}var Ge={"cline-pass":{adapter:`openai-chat`,baseUrl:O(`api.cline.bot`,`api`,`v1`)},"mimo-free":{adapter:`mimo-free`,baseUrl:O(`api.xiaomimimo.com`,`api`,`free-ai`,`openai`,`chat`)}};function Ke(e,t){let n=Ge[e];return!n||t.adapter!==n.adapter||D(t.baseUrl)!==D(n.baseUrl)}function k(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 A(e){return e.keyOptional===!0||T(e)||e.authMode===`oauth`||e.authMode===`forward`||e.authMode===`local`||k(e.baseUrl)||e.hasApiKey===!0}function qe(e){return`name`in e&&e.name===`google-vertex`&&(e.googleMode===void 0||e.googleMode===`vertex`)||e.adapter===`google`&&e.googleMode===`vertex`}function j(e){return e.disabled||e.authMode!==void 0&&e.authMode!==`key`||!qe(e)?!1:e.vertexCredentialKind?e.vertexCredentialKind!==`api-key`:!e.hasApiKey}function M(e){return e.adapter===`openai-responses`&&e.authMode===`forward`&&D(e.baseUrl)===E}function N(e,t){return e===Ue&&M(t)}function P(e){return T(e)?!1:e.freeTier===!0||e.keyOptional===!0||e.authMode===`local`||k(e.baseUrl)}function F(e,t){return N(e,t)?`accounts`:P(t)?`free`:`paid`}function Je(e,t){let n=[...e],r=(e,t)=>e.name.localeCompare(t.name,void 0,{sensitivity:`base`}),i=e=>e.tier??F(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 Ye(e){let t=[],n=[],r=[],i=[];for(let[a,o]of Object.entries(e))o.disabled?i.push({name:a,...o}):j({name:a,...o})?r.push({name:a,...o}):A(o)?t.push({name:a,...o,tier:F(a,o)}):n.push({name:a,...o});return{ready:t,needsSetup:n,unverified:r,disabled:i}}function Xe(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),unverified:r(e.unverified),disabled:e.disabled}}function I(e){return e.disabled?`disabled`:`activeNeedsReauth`in e&&e.activeNeedsReauth?`needs-setup`:j(e)?`unverified`:A(e)?`ready`:`needs-setup`}function Ze(e){let t=e.openai,n=e.chatgpt;if(!t||!n||!N(`openai`,t)||!M(n))return e;let r={...e};return delete r.chatgpt,r}function L(e){return e.authMode===`local`||k(e.baseUrl)}var Qe=[`ollama`,`vllm`,`lm-studio`,`lmstudio`,`litellm`,`localai`];function $e(e){let t=(e.authMode??``).toLowerCase();if(t===`oauth`||t===`forward`)return`login`;if(L(e))return`local`;let n=`${e.name??``} ${e.adapter} ${e.baseUrl}`.toLowerCase();return Qe.some(e=>n.includes(e))?`selfHosted`:`cloud`}var R=[`plan_base`,`plan_bonus`,`addon`,`benefit`,`other`];function z(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}function B(e){if(typeof e!=`number`&&!(typeof e==`string`&&/^\d+(?:\.\d+)?$/.test(e)))return;let t=Number(e);return Number.isFinite(t)&&t>=0&&t<=2**53-1?t:void 0}function V(e){let t=z(e),n=B(t.total),r=B(t.used),i=B(t.remaining),a=B(t.frozen);if(n!==void 0&&r!==void 0&&i!==void 0&&a!==void 0)return{total:n,used:r,remaining:i,frozen:a}}function et(e){let t=z(e),n=V(e);if(!n||!Array.isArray(t.groups)||t.groups.length>R.length)return;let r=[],i=new Set;for(let e of t.groups){let t=z(e),n=V(t),a=R.find(e=>e===t.kind);if(!n||!a||i.has(a))return;i.add(a),r.push({kind:a,...n})}let a=z(t.expiring),o=B(a.amount),s=typeof a.at==`number`&&a.at>0&&Number.isFinite(new Date(a.at).getTime())?a.at:void 0;return{...n,groups:r,...o!==void 0&&o>0&&s!==void 0?{expiring:{amount:o,at:s}}:{}}}function H(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 tt(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=H(i,t);r.trim()&&e&&(n[r]=e)}return n}function nt(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=H(r,t);typeof e==`string`&&e.trim()&&i&&(n[e]=i)}return n}function rt(e){return e?.observed===!0&&typeof e.updatedAt==`number`?e.updatedAt:void 0}var U=e=>typeof e==`number`&&Number.isFinite(e)?e:void 0,it=e=>{let t=U(e);if(t===void 0)return;let n=t>1e10?t:t*1e3;return Number.isFinite(new Date(n).getTime())?t:void 0},at=e=>{let t=U(e);return t!==void 0&&t>0&&t<=100?t:void 0};function ot(e){return Array.isArray(e)?e.flatMap(e=>{if(!e||typeof e!=`object`)return[];let t=e;return typeof t.label!=`string`||U(t.percent)===void 0?[]:[{label:t.label,...typeof t.displayLabel==`string`&&t.displayLabel.trim()?{displayLabel:t.displayLabel}:{},percent:t.percent,...U(t.resetAt)===void 0?{}:{resetAt:t.resetAt},...typeof t.modelId==`string`&&t.modelId.length<=128?{modelId:t.modelId}:{},...at(t.weeklyAllowancePercent)===void 0?{}:{weeklyAllowancePercent:at(t.weeklyAllowancePercent)}}]}):[]}function st(e,t){if(!e||typeof e!=`object`||Array.isArray(e))return null;let n=e,r=ot(n.customWindows),i=new Set(r.map(e=>e.label)),a=ot(n.displayWindows).filter(e=>!i.has(e.label)),o=Array.isArray(n.unknownBudgetWindows)?n.unknownBudgetWindows.flatMap(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return[];let t=e;if(typeof t.label!=`string`)return[];let n=it(t.resetAt);return[{label:t.label,...n===void 0?{}:{resetAt:n}}]}):[],s=n.creditsUsd&&typeof n.creditsUsd==`object`&&!Array.isArray(n.creditsUsd)?n.creditsUsd:null,c=U(s?.used),l=U(s?.limit),u=U(s?.remaining),d=U(s?.percent),f=it(s?.expiresAt),p=c!==void 0&&l!==void 0&&u!==void 0&&d!==void 0?{used:c,limit:l,remaining:u,percent:d,...f===void 0?{}:{expiresAt:f},...typeof s?.unlimited==`boolean`?{unlimited:s.unlimited}:{}}:void 0,m=et(n.workbuddyCredits),h={...m?{workbuddyCredits:m}:{},...U(n.fiveHourPercent)===void 0?{}:{fiveHourPercent:n.fiveHourPercent},...U(n.fiveHourResetAt)===void 0?{}:{fiveHourResetAt:n.fiveHourResetAt},...U(n.weeklyPercent)===void 0?{}:{weeklyPercent:n.weeklyPercent},...U(n.weeklyResetAt)===void 0?{}:{weeklyResetAt:n.weeklyResetAt},...U(n.monthlyPercent)===void 0?{}:{monthlyPercent:n.monthlyPercent},...U(n.monthlyResetAt)===void 0?{}:{monthlyResetAt:n.monthlyResetAt},...r.length>0?{customWindows:r}:{},...a.length>0?{displayWindows:a}:{},...o.length>0?{unknownBudgetWindows:o}:{},...p?{creditsUsd:p}:{},updatedAt:U(n.updatedAt)??t??Date.now()};return h.fiveHourPercent!==void 0||h.weeklyPercent!==void 0||h.monthlyPercent!==void 0||(h.customWindows?.length??0)>0||(h.displayWindows?.length??0)>0||(h.unknownBudgetWindows?.length??0)>0||h.creditsUsd!==void 0||h.workbuddyCredits!==void 0?h:null}function ct(e){return st(e?.quota,e?.updatedAt)}function lt(e){if(!e)return;if(e.aggregation===void 0)return e;let t=ut(e)?.currentAccount?.quota??null;return{...e,aggregation:void 0,quota:t,updatedAt:t?.updatedAt}}function W(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e,n=U(t.usedPercent);if(n!==void 0)return{usedPercent:n,...typeof t.incomplete==`boolean`?{incomplete:t.incomplete}:{},...U(t.excludedAccounts)===void 0?{}:{excludedAccounts:t.excludedAccounts},...U(t.nextRecoveryAt)===void 0?{}:{nextRecoveryAt:t.nextRecoveryAt},...U(t.nextRecoveryPercent)===void 0?{}:{nextRecoveryPercent:t.nextRecoveryPercent}}}function ut(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=U(n.excludedAccounts),i=U(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=W(t);return typeof t.label==`string`&&n?[{label:t.label,...n}]:[]}):[],s=W(n.fiveHour),c=W(n.weekly),l=W(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:U(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:st(a.quota)}}:{}}}function dt(e){if(!e?.trim())return``;let[t,n]=e.split(`:`,2);return n?`${t} · ${n.replace(/-/g,` `)}`:e}function ft(e,t){let n=I(e);return n===`disabled`?t(`prov.disabledBadge`):n===`ready`?t(`pws.status.ready`):j(e)?t(`pws.vertexUnverified`):`activeNeedsReauth`in e&&e.activeNeedsReauth?t(`pws.status.needsAttention`):t(`pws.status.needsSetup`)}function pt(e,t){if(j(e))return t(`pws.vertexHostAuth`);if(T(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 mt(e){let t=I(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 ht({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)(gt,{name:e,label:C(e,o)})})}function gt({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 _t({item:e,selected:n,tabbable:i,modelCount:a,isDefault:o,showConfigId:s,onClick:c,onFocus:l}){let u=t(),d=P(e),f=L(e),p=ft(e,u),m=C(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`):``}`,_=a!==void 0&&a>0?a===1?u(`pws.modelCountOne`):u(`pws.modelCount`,{count:a}):``,v=[s?e.name:``,_].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)(ht,{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:v||void 0,children:v||`\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)(y,{width:17,height:17,"aria-hidden":`true`})}),(0,r.jsx)(`span`,{className:mt(e),title:p,"aria-hidden":`true`})]})]})}var vt=1e10;function yt(e){return e<vt?e*1e3:e}function bt(e,t){return typeof e==`number`&&Number.isFinite(e)&&e>0&&yt(e)<=t}function xt(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 yt(r)>t}function St(e){return{fiveHourAvailable:e?.shortWindowSeconds===18e3&&typeof e.shortResetAt==`number`,weeklyAvailable:typeof e?.weeklyResetAt==`number`}}function Ct(e){let t=e?.trim().toLowerCase();return t===`go`||t===`free`}function wt(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 Ct(t)?{...n.monthlyPercent===void 0?{}:{monthlyPercent:n.monthlyPercent},...n.monthlyResetAt===void 0?{}:{monthlyResetAt:n.monthlyResetAt},...n.workbuddyCredits===void 0?{}:{workbuddyCredits:n.workbuddyCredits},...n.creditsUsd===void 0?{}:{creditsUsd:n.creditsUsd},...n.resetCredits===void 0?{}:{resetCredits:n.resetCredits},updatedAt:n.updatedAt}:n}function Tt(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=(Ct(t)?[e.monthlyPercent]:[e.weeklyPercent,e.monthlyPercent]).filter(r);if(a.length===0)return xt({...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)&&!bt(e.fiveHourResetAt??e.shortResetAt,n)?[...a,i]:a;return o.length?Math.max(...o):null}function Et(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 Dt(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 Ot={6:15,24:60,72:180,168:360};function kt(e){return Ot[e]}function At(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 jt(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 Mt(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 Nt(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 Pt(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 Ft(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 K=[`#0A84FF`,`#FF9F0A`,`#30D158`,`#BF5AF2`,`#FF453A`,`#64D2FF`],It=640,Lt=160,q=28;function Rt(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 zt(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 Bt({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=Rt(e,t),u=zt(e,s),d=q,f=u.map((e,t)=>(0,r.jsx)(`text`,{x:q+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:Pt(e.points,584,104,l,0),transform:`translate(${q},${q})`,fill:`none`,stroke:K[t%K.length],strokeWidth:`2`,strokeLinejoin:`round`,strokeLinecap:`round`},e.id)):Ft(e.series,584,104,l,0).map(e=>(0,r.jsx)(`rect`,{x:q+e.x,y:q+e.y,width:e.width,height:e.height,fill:K[e.seriesIndex%K.length],rx:`1`},`${e.bucketIndex}-${e.seriesIndex}`));return(0,r.jsxs)(`div`,{className:`usage-companion-chart`,children:[(0,r.jsxs)(`svg`,{viewBox:`0 0 ${It} ${Lt}`,role:`img`,"aria-label":c(`usage.companion.chartLabel`),children:[(0,r.jsx)(`line`,{x1:q,y1:d,x2:q,y2:132,className:`usage-companion-axis`}),(0,r.jsx)(`line`,{x1:q,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:At(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:K[t%K.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 J=e=>typeof e==`number`&&Number.isFinite(e)&&e>=0,Y=e=>typeof e==`object`&&e&&!Array.isArray(e)?e:{};function Vt(e){return Object.entries(Y(Y(e).providers)).flatMap(([e,t])=>{let n=Y(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 Ht(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 Ut(e,t){return t?{switchState:`active`}:Y(e.mainAccountHardLock).state===`blocked`?{switchState:`blocked`,blockedReason:`mainHardLock`}:e.paused===!0?{switchState:`blocked`,blockedReason:`paused`}:Y(e.health).reason===`validation_pending`?{switchState:`blocked`,blockedReason:`validationPending`}:{switchState:`available`}}function Wt(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 Gt(e,t,n){let r=Y(e),i=r.accounts??r.keys;if(!Array.isArray(i))throw Error(`Invalid account roster`);return i.map((e,i)=>{let a=Y(e);if(typeof a.id!=`string`)throw Error(`Invalid account identifier`);let o=t===`oauth`?void 0:typeof a.email==`string`?Kt(a.email):void 0,s=(t===`oauth`?[a.alias,a.maskedLabel].find(e=>typeof e==`string`&&e.trim()):[a.alias,a.label,o,a.logLabel,a.id].find(e=>typeof e==`string`&&e.trim()))?.trim()||(t===`oauth`?n?.(i+1):void 0);if(!s)throw Error(`Missing account label`);let c=a.quotaUnavailable===!0||a.quotaMode===`unsupported`||!a.quota?null:Y(a.quota),l=typeof a.plan==`string`?a.plan:void 0,u=r.activeAccountId??r.activeId??r.activeCodexAccountId,d=typeof u==`string`?u===a.id:a.active===!0;return{id:a.id,label:s,email:o,plan:l,unavailable:a.quotaUnavailable===!0,active:d,...Ut(a,d),exhausted:c!==null&&Wt(Y(a.quota),l),status:typeof Y(a.health).status==`string`?Y(a.health).status:void 0,quotaFailure:typeof a.quotaFailure==`string`?a.quotaFailure:void 0,quota:wt(c,l)}})}function X(e){if(!J(e)||e===0)return null;let t=e<0xe8d4a51000?e*1e3:e;return Number.isFinite(new Date(t).getTime())?t:null}function Kt(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 qt(e,t,n=Date.now()){let r=X(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 Jt(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,...typeof e.displayLabel==`string`&&e.displayLabel.trim()?{displayLabel:e.displayLabel}:{},modelId:e.modelId,percent:e.percent,reset:e.resetAt})):[],...Array.isArray(e.unknownBudgetWindows)?e.unknownBudgetWindows.filter(e=>e&&typeof e.label==`string`).map(e=>({id:e.label,label:e.label,percent:void 0,reset:e.resetAt,unknownBudget:!0})):[]].filter(e=>J(e.percent)||X(e.reset)!==null||`unknownBudget`in e&&e.unknownBudget===!0),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 Yt(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=>J(t[e]))&&(a[e]=i.reduce((t,n)=>t+n[e],0));return{...e,models:i,summary:a}}function Xt(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(t,n){let r=e(2e4),i=()=>r.controller.abort();n.aborted&&i(),n.addEventListener(`abort`,i,{once:!0});try{let e=await fetch(t,{signal:r.signal,cache:`no-store`});if(!e.ok)throw Error(String(e.status));let n=await e.json();if(r.signal.aborted)throw Error(`Tray request cancelled`);return n}finally{r.clear(),n.removeEventListener(`abort`,i)}}function Qt(e){let t=Y(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 Z=e=>typeof e==`number`&&Number.isFinite(e);function Q(e){return Z(e)?e>=90?`critical`:e>=70?`warn`:`normal`:`normal`}function $t(e){return Z(e)?`${Math.floor(e)}%`:`-`}function $(e){let[t,n=`0`]=e.toString().split(`e`),[r,i=``]=t.split(`.`),a=BigInt(`${r}${i}`),o=i.length-Number(n);return o>=0?[a,10n**BigInt(o)]:[a*10n**BigInt(-o),1n]}function en(e,t){let[n,r]=$(e),[i,a]=$(Math.min(t,e)),o=n*a,s=(o-i*r)*100n;return Number((2n*s+o)/(2n*o))}var tn=[`quota.weeklyLimit`,`quota.monthlyLimit`,`quota.fiveHourLimit`];function nn(e){let t=Jt(e).map(e=>{let t=Z(e.percent)?e.percent:void 0,n=X(e.reset),r=`modelId`in e?e.modelId:void 0;return{id:e.id,...r===void 0?{}:{modelId:r},...`key`in e&&e.key?{labelKey:e.key}:{},...`label`in e&&typeof e.label==`string`?{label:e.label}:{},...`displayLabel`in e&&typeof e.displayLabel==`string`&&e.displayLabel.trim()?{displayLabel:e.displayLabel}:{},...t===void 0?{}:{percent:t},...`unknownBudget`in e&&e.unknownBudget===!0?{unknownBudget:!0}:{},...n===null?{}:{resetAt:n},severity:r===void 0?Q(t):`normal`}}),n=e.creditsUsd;if(n&&n.unlimited!==!0&&Z(n.percent)){let e=X(n.expiresAt);t.push({id:`quotaSummary.credits`,labelKey:`quotaSummary.credits`,percent:n.percent,...e===null?{}:{resetAt:e},severity:Q(n.percent)})}let r=e.workbuddyCredits;if(r&&r.total>0&&r.remaining/r.total<=1+2**-52*1024){let e=en(r.total,r.remaining);t.push({id:`quotaSummary.creditsUnavailable`,labelKey:`quotaSummary.creditsUnavailable`,percent:e,severity:`normal`})}let i=new Set;return t.map(e=>{let t=e.id,n=1;for(;i.has(t);)t=`${e.id}#${n++}`;return i.add(t),t===e.id?e:{...e,id:t}})}function rn(e){let t=e.filter(e=>e.modelId===void 0&&e.percent!==void 0),n=new Map;for(let e of t)e.labelKey!==void 0&&!n.has(e.labelKey)&&n.set(e.labelKey,e);let r;for(let e of tn){let t=n.get(e);if(t){r=t;break}}r||=t.find(e=>e.labelKey!==`quotaSummary.credits`);let i=n.get(`quotaSummary.credits`);return i&&i.severity===`critical`&&r?.severity!==`critical`?i:r??t[0]??e.find(e=>e.unknownBudget)}function an(e,t){let n=[];for(let[r,i]of Object.entries(e)){let e=ct(i);if(!e)continue;let a=nn(e),o=rn(a);o&&n.push({provider:r,label:i.label?.trim()||t(r),headline:o,windows:a,...Z(i.updatedAt)?{updatedAt:i.updatedAt}:{},observed:i.observed===!0,severity:o.severity})}return n}export{Le as $,lt as A,oe as At,Ze as B,f as Bt,wt as C,ye as Ct,pt as D,Ce as Dt,_t as E,we as Et,L as F,le as Ft,Je as G,P as H,ie as Ht,$e as I,o as It,T as J,j as K,Xe as L,Ee as Lt,tt as M,_ as Mt,nt as N,he as Nt,ct as O,d as Ot,rt as P,ee as Pt,Ie as Q,I as R,y as Rt,Tt as S,l as St,ht as T,v as Tt,Ke as U,g as Ut,N as V,be as Vt,F as W,Re as X,Be as Y,C as Z,Dt as _,m as _t,Zt as a,s as at,jt as b,_e as bt,Xt as c,ve as ct,Vt as d,ae as dt,p as et,Jt as f,Oe as ft,Nt as g,De as gt,kt as h,a as ht,Ht as i,c as it,dt as j,re as jt,ut as k,ne as kt,Gt as l,fe as lt,Bt as m,Te as mt,$t as n,de as nt,Yt as o,h as ot,qt as p,me as pt,He as q,Q as r,ue as rt,J as s,pe as st,an as t,se as tt,Qt as u,ge as ut,Et as v,te as vt,St as w,u as wt,Mt as x,xe as xt,At as y,ce as yt,Ye as z,Se as zt};
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
document.documentElement.lang = langMap[locale];
|
|
39
39
|
})();
|
|
40
40
|
</script>
|
|
41
|
-
<script type="module" crossorigin src="/classic/assets/index-
|
|
41
|
+
<script type="module" crossorigin src="/classic/assets/index-DyJHagvT.js"></script>
|
|
42
42
|
<link rel="stylesheet" crossorigin href="/classic/assets/index-CHWwDo9L.css">
|
|
43
43
|
</head>
|
|
44
44
|
<body>
|
package/gui/dist/index.html
CHANGED
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
}
|
|
50
50
|
})();
|
|
51
51
|
</script>
|
|
52
|
-
<script type="module" crossorigin src="/assets/index-
|
|
53
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
52
|
+
<script type="module" crossorigin src="/assets/index-Bbor_y80.js"></script>
|
|
53
|
+
<link rel="stylesheet" crossorigin href="/assets/index-DJEkIDAi.css">
|
|
54
54
|
</head>
|
|
55
55
|
<body>
|
|
56
56
|
<div id="root"></div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bitkyc08/opencodex",
|
|
3
|
-
"version": "2.100.
|
|
3
|
+
"version": "2.100.2",
|
|
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",
|
|
@@ -136,5 +136,5 @@
|
|
|
136
136
|
"url": "https://github.com/lidge-jun/opencodex/issues"
|
|
137
137
|
},
|
|
138
138
|
"license": "MIT",
|
|
139
|
-
"gitHead": "
|
|
139
|
+
"gitHead": "61147ec681bc8374d350e0eae08b71c117c6df30"
|
|
140
140
|
}
|
|
@@ -37,7 +37,7 @@ const IMAGE_DECODE_PROCESS_CONCURRENCY = IMAGE_NORMALIZE_CONCURRENCY;
|
|
|
37
37
|
let activeImageDecodes = 0;
|
|
38
38
|
const imageDecodeWaiters: Array<() => void> = [];
|
|
39
39
|
|
|
40
|
-
async function enterImageDecode(signal?: AbortSignal): Promise<() => void> {
|
|
40
|
+
export async function enterImageDecode(signal?: AbortSignal): Promise<() => void> {
|
|
41
41
|
if (signal?.aborted) throw signal.reason ?? new DOMException("Aborted", "AbortError");
|
|
42
42
|
let transferred = false;
|
|
43
43
|
if (activeImageDecodes >= IMAGE_DECODE_PROCESS_CONCURRENCY) {
|
|
@@ -42,7 +42,7 @@ export function stainlessArchName(arch: string = process.arch): string {
|
|
|
42
42
|
return arch ? `other:${arch}` : "unknown";
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
// ── Claude Code CLI (matches Claude Code 2.1.
|
|
45
|
+
// ── Claude Code CLI (matches Claude Code 2.1.321 / @anthropic-ai/sdk 0.128.0) ──
|
|
46
46
|
export const CLAUDE_CODE_HEADERS: Record<string, string> = {
|
|
47
47
|
"X-App": "cli",
|
|
48
48
|
"anthropic-dangerous-direct-browser-access": "true",
|
|
@@ -88,7 +88,8 @@ const ANTIGRAVITY_IDE_PLATFORM = "windows/amd64";
|
|
|
88
88
|
* Must be the IDE client family (`antigravity/ide/...`): Cloud Code Assist backend gates
|
|
89
89
|
* newer agent models (e.g. `gemini-3.7-flash`) by User-Agent and answers 404 NOT_FOUND to
|
|
90
90
|
* CLI-shaped UAs even with a valid OAuth token. Only `antigravity/ide/<ver>` unlocks them.
|
|
91
|
-
* The
|
|
91
|
+
* The exception is the Gemini 4 generation (Argon, Carbon), which CCA serves ONLY to the CLI
|
|
92
|
+
* family; see
|
|
92
93
|
* `antigravityCliUserAgent`.
|
|
93
94
|
* A `GOOGLE_ANTIGRAVITY_USER_AGENT` override (set by the caller) takes precedence upstream.
|
|
94
95
|
*/
|
|
@@ -109,9 +110,10 @@ const ANTIGRAVITY_CLI_PLATFORM = "darwin/arm64";
|
|
|
109
110
|
* `antigravity/cli/${version} (os_type=${osType}; arch=${arch}; aidev_client; auth_method=oauth)`.
|
|
110
111
|
*
|
|
111
112
|
* Verified 2026-10-14 against live CCA: `gemini-4-argon-{low,medium,high}` answer only to this
|
|
112
|
-
* family and return 404 "Requested entity was not found" to the IDE UA above
|
|
113
|
+
* family and return 404 "Requested entity was not found" to the IDE UA above (2026-11-11:
|
|
114
|
+
* `gemini-4-carbon-*` behaves the same), while
|
|
113
115
|
* `gemini-3.7-flash-tiered` and `gemini-3.1-pro-low` 404 under this one. So it is used ONLY for
|
|
114
|
-
*
|
|
116
|
+
* Gemini 4 requests, model discovery and the quota summary (whose Argon group is likewise CLI-only),
|
|
115
117
|
* never as a general replacement for the IDE UA.
|
|
116
118
|
*
|
|
117
119
|
* `GOOGLE_ANTIGRAVITY_USER_AGENT` deliberately does not apply here: that override names the IDE
|
|
@@ -57,7 +57,7 @@ import { OCX_RESPONSES_TOOL_PROVIDER } from "./tool-definitions";
|
|
|
57
57
|
import { CODEX_UNIFIED_EXEC_TOOL, cursorRequestHasExecutionPath, cursorRequestHasShellAlias, cursorRequestUsesCodeMode, cursorToolWireName } from "./tool-naming";
|
|
58
58
|
import { CODE_MODE_RESULT_ECHO_SENTENCE } from "../exec-tool-result-normalize";
|
|
59
59
|
import type { OcxTool } from "../../types";
|
|
60
|
-
import { cursorPlainNativeExecFallback, cursorPlainNativeExecRedirectHint, cursorUsesPlainToolWording } from "./tool-wording";
|
|
60
|
+
import { CURSOR_DEFERRED_TOOL_FALLBACK, cursorPlainNativeExecFallback, cursorPlainNativeExecRedirectHint, cursorUsesPlainToolWording } from "./tool-wording";
|
|
61
61
|
|
|
62
62
|
export type CursorNativeExecDeps = CursorNativeNetworkDeps & CursorNativeToolDeps;
|
|
63
63
|
|
|
@@ -135,7 +135,8 @@ export function cursorNativeExecRedirectHint(
|
|
|
135
135
|
function cursorCodeModeExecRedirectHint(): string {
|
|
136
136
|
return (
|
|
137
137
|
`Re-issue this operation NOW through the \`${CODEX_UNIFIED_EXEC_TOOL}\` tool: this turn uses Codex code mode, so \`${CODEX_UNIFIED_EXEC_TOOL}\` takes a JavaScript body and shell, file, search, and fetch are nested helpers called INSIDE that body as \`await tools.<name>(...)\`, for example \`text(await tools.exec_command({cmd: "ls"}))\`. `
|
|
138
|
-
+ "Cursor-native Read/Glob/Grep/LS/Shell/Write/Fetch are not part of this request's catalog; do not retry them, and do not call `shell_command` or `exec_command` at the top level here — code mode exposes no bare shell bridge, only the nested helpers. Every other tool this turn lists
|
|
138
|
+
+ "Cursor-native Read/Glob/Grep/LS/Shell/Write/Fetch are not part of this request's catalog; do not retry them, and do not call `shell_command` or `exec_command` at the top level here — code mode exposes no bare shell bridge, only the nested helpers. Every other tool this turn lists is called directly, outside `exec`, as usual. "
|
|
139
|
+
+ CURSOR_DEFERRED_TOOL_FALLBACK + " "
|
|
139
140
|
+ CODE_MODE_RESULT_ECHO_SENTENCE + " "
|
|
140
141
|
+ `Do NOT narrate this redirect, do NOT comment on tool availability, and do NOT re-announce the task — just make the \`${CODEX_UNIFIED_EXEC_TOOL}\` call.`
|
|
141
142
|
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { OcxRequestOptions, OcxTool } from "../../types";
|
|
2
|
-
import { CURSOR_TOOL_CALL_CONTINUATION, cursorUsesPlainToolWording } from "./tool-wording";
|
|
2
|
+
import { CURSOR_DEFERRED_TOOL_FALLBACK, CURSOR_TOOL_CALL_CONTINUATION, cursorUsesPlainToolWording } from "./tool-wording";
|
|
3
3
|
import { CODE_MODE_HOST_CONTRACT_SENTENCE, CODE_MODE_RESULT_ECHO_SENTENCE } from "../exec-tool-result-normalize";
|
|
4
4
|
import { CODEX_SHELL_BRIDGE_TOOL_NAMES, CODEX_TOOL_SEARCH_TOOL, CODEX_UNIFIED_EXEC_TOOL, clientSemanticToolNameFromCursorWire, cursorRequestAdvertisesApplyPatch, cursorRequestHasExecutionPath, cursorRequestHasShellAlias, cursorRequestUsesCodeMode, cursorToolAllowedByChoice, cursorToolWireName, isBareCodexShellBridgeTool, isClaudeClientBareToolName, isCodexShellBridgeToolName, isCursorExecutionPathTool, isCursorStructuredEditToolName } from "./tool-naming";
|
|
5
5
|
|
|
@@ -199,14 +199,14 @@ export function buildCursorToolGuidanceSystemNote(
|
|
|
199
199
|
// Code mode: shell/edit/MCP live inside freeform `exec` as nested helpers. Without this the
|
|
200
200
|
// model probes for a top-level shell tool that is not there.
|
|
201
201
|
codeMode
|
|
202
|
-
? `\`${CODEX_UNIFIED_EXEC_TOOL}\` is Codex code mode: its body is JavaScript evaluated in a V8 isolate, not a shell command and not Node. Shell, file edits, and MCP are nested helpers called INSIDE that body as \`await tools.<name>(...)\`, for example \`text(await tools.exec_command({cmd: \"ls\"}))\`. Read the tool description and the isolate global \`ALL_TOOLS\` (not \`tools.ALL_TOOLS\`) for helpers this turn provides; absence from the top-level catalog or from \`exec\`'s description is not absence. Those nested helpers are not themselves top-level tools, so do not call \`exec_command\` or \`shell_command\` at the top level here${codeModeOtherTopLevelNames.length > 0 ? `; every other tool this turn lists, including ${quotedNames(codeModeOtherTopLevelNames)},
|
|
202
|
+
? `\`${CODEX_UNIFIED_EXEC_TOOL}\` is Codex code mode: its body is JavaScript evaluated in a V8 isolate, not a shell command and not Node. Shell, file edits, and MCP are nested helpers called INSIDE that body as \`await tools.<name>(...)\`, for example \`text(await tools.exec_command({cmd: \"ls\"}))\`. Read the tool description and the isolate global \`ALL_TOOLS\` (not \`tools.ALL_TOOLS\`) for helpers this turn provides; absence from the top-level catalog or from \`exec\`'s description is not absence. Those nested helpers are not themselves top-level tools, so do not call \`exec_command\` or \`shell_command\` at the top level here${codeModeOtherTopLevelNames.length > 0 ? `; every other tool this turn lists, including ${quotedNames(codeModeOtherTopLevelNames)}, is called directly, outside \`${CODEX_UNIFIED_EXEC_TOOL}\`, as usual` : ""}. ${CURSOR_DEFERRED_TOOL_FALLBACK} Nested \`tools.apply_patch(input)\` is host-executed: the string must begin exactly with \`*** Begin Patch\` and end with \`*** End Patch\`, each marker line being three asterisks, one space, the two words, then end of line with no further asterisks. OpenCodex does not rewrite JavaScript inside exec, so extra asterisks on a marker line are rejected by Codex before the file is touched.`
|
|
203
203
|
: undefined,
|
|
204
204
|
codeMode
|
|
205
205
|
? CODE_MODE_RESULT_ECHO_SENTENCE + " There is no `require`, no `module`, and no filesystem or network globals; reach the host only through the nested helpers. " + CODE_MODE_HOST_CONTRACT_SENTENCE
|
|
206
206
|
: undefined,
|
|
207
207
|
codeMode
|
|
208
208
|
? plainToolWording
|
|
209
|
-
? "Cursor-native Shell, Read, Grep, List, and Write are not available in this request. The exec code cell and its nested helpers provide the execution path; separately listed tools
|
|
209
|
+
? "Cursor-native Shell, Read, Grep, List, and Write are not available in this request. The exec code cell and its nested helpers provide the execution path; separately listed tools are called directly, outside the exec cell."
|
|
210
210
|
: "NEVER attempt Cursor-native Shell, Read, Grep, List, Write, or any tool absent from the catalog — they are not executed in this environment and every probe wastes a turn. The exec code cell (with its nested helpers) is the ONLY execution surface; go to it directly on the FIRST attempt and do not narrate switching surfaces."
|
|
211
211
|
: undefined,
|
|
212
212
|
hasBareExec
|
|
@@ -9,6 +9,14 @@ export function cursorUsesPlainToolWording(modelId?: string): boolean {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export const CURSOR_TOOL_CALL_CONTINUATION = "Continue the task with that tool call.";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Cursor can defer the Codex client tools behind its own GetDynamicTools/CallDynamicTool pair, so a
|
|
15
|
+
* code-mode turn may list `exec` without the model seeing it at the top level (#8132). Name the
|
|
16
|
+
* deferred call path instead of asserting top-level reach.
|
|
17
|
+
*/
|
|
18
|
+
export const CURSOR_DEFERRED_TOOL_FALLBACK = "If a tool this turn lists, including `exec`, is missing from your top-level tool list, Cursor has deferred it: "
|
|
19
|
+
+ `call \`CallDynamicTool\` with namespace \`${OCX_RESPONSES_TOOL_PROVIDER}\`, \`toolName\` set to that tool's name, and the tool's own arguments under \`arguments\`.`;
|
|
12
20
|
const CURSOR_NO_CLIENT_TOOLS = "Cursor-native filesystem, shell, and fetch tools are not available through this execution channel. No client tools are available in this request. Answer without tools using the information already provided, or report that the requested operation cannot be completed without tools.";
|
|
13
21
|
|
|
14
22
|
/** Factual catalog wording; legacy model wording is owned by native-exec.ts unchanged. */
|
|
@@ -29,7 +37,8 @@ export function cursorPlainNativeExecRedirectHint(
|
|
|
29
37
|
+ "Cursor-native Read/Glob/Grep/LS/Shell/Write/Fetch are not available in this request. ";
|
|
30
38
|
if (!cursorRequestHasShellAlias(clientTools) && cursorRequestUsesCodeMode(clientTools)) {
|
|
31
39
|
return catalog + "`exec` takes a JavaScript body evaluated in a V8 isolate, not a shell command. Shell, file, search, and fetch are nested helpers called inside it as `await tools.<name>(...)`, for example `text(await tools.exec_command({cmd: \"ls\"}))`. "
|
|
32
|
-
+ "`shell_command` and `exec_command` are nested helpers, not top-level tools here. Every other listed tool
|
|
40
|
+
+ "`shell_command` and `exec_command` are nested helpers, not top-level tools here. Every other listed tool is called directly, outside `exec`. "
|
|
41
|
+
+ CURSOR_DEFERRED_TOOL_FALLBACK + " "
|
|
33
42
|
+ CODE_MODE_RESULT_ECHO_SENTENCE + " " + CURSOR_TOOL_CALL_CONTINUATION;
|
|
34
43
|
}
|
|
35
44
|
const operation = cursorRequestHasExecutionPath(clientTools)
|
|
@@ -9,12 +9,28 @@
|
|
|
9
9
|
* accept type arrays, so only the Gemini family is rewritten, and only that one
|
|
10
10
|
* keyword: the full Google subset sanitizer would strip keywords this backend
|
|
11
11
|
* accepts.
|
|
12
|
+
*
|
|
13
|
+
* Claude models behind the same wire answer `invalid_argument` for a root
|
|
14
|
+
* `oneOf` (#8302), as Anthropic rejects a root composition in any
|
|
15
|
+
* `input_schema`. Claude uids get the same root flattening as Claude Chat
|
|
16
|
+
* gateways; a schema without a root composition is passed through unchanged.
|
|
12
17
|
*/
|
|
18
|
+
import { flattenClaudeRootToolParameters } from '../../openai-chat/tool-schema.js';
|
|
13
19
|
|
|
14
20
|
export function isDevinGeminiModelUid(modelUid: string): boolean {
|
|
15
21
|
return /^gemini-/i.test(modelUid) || /^MODEL_GOOGLE_GEMINI_/i.test(modelUid);
|
|
16
22
|
}
|
|
17
23
|
|
|
24
|
+
export function isDevinClaudeModelUid(modelUid: string): boolean {
|
|
25
|
+
return /^claude-/i.test(modelUid) || /^MODEL_CLAUDE_/i.test(modelUid);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const ROOT_COMPOSITION_KEYS = ['oneOf', 'anyOf', 'allOf'] as const;
|
|
29
|
+
|
|
30
|
+
function hasRootComposition(parameters: unknown): boolean {
|
|
31
|
+
return isSchema(parameters) && ROOT_COMPOSITION_KEYS.some((key) => Array.isArray(parameters[key]));
|
|
32
|
+
}
|
|
33
|
+
|
|
18
34
|
/** Keys whose values are instance data, not subschemas. */
|
|
19
35
|
const DATA_KEYS = new Set(['enum', 'const', 'default', 'examples', 'example']);
|
|
20
36
|
/** Keys whose values map arbitrary names (which may be "enum" or "default") to subschemas. */
|
|
@@ -79,7 +95,9 @@ function rewrite(node: unknown): unknown {
|
|
|
79
95
|
return splitTypeArray(out, types);
|
|
80
96
|
}
|
|
81
97
|
|
|
82
|
-
/** Rewrite type arrays for Gemini uids
|
|
98
|
+
/** Rewrite type arrays for Gemini uids and root compositions for Claude uids; others are unchanged. */
|
|
83
99
|
export function normalizeDevinToolParameters(modelUid: string, parameters: unknown): unknown {
|
|
84
|
-
|
|
100
|
+
if (isDevinGeminiModelUid(modelUid)) return rewrite(parameters);
|
|
101
|
+
if (isDevinClaudeModelUid(modelUid) && hasRootComposition(parameters)) return flattenClaudeRootToolParameters(parameters);
|
|
102
|
+
return parameters;
|
|
85
103
|
}
|
|
@@ -12,20 +12,27 @@ import { antigravityCliUserAgent, antigravityUserAgent } from "./client-fingerpr
|
|
|
12
12
|
export const ANTIGRAVITY_REQUEST_UA = antigravityUserAgent();
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
* Antigravity CLI User-Agent. CCA serves Gemini 4 Argon only to the
|
|
16
|
-
* 404s other agent models (`gemini-3.7-flash-tiered`,
|
|
17
|
-
* choice is per wire model: see
|
|
15
|
+
* Antigravity CLI User-Agent. CCA serves the Gemini 4 codename models (Argon, Carbon) only to the
|
|
16
|
+
* CLI client family, and it 404s other agent models (`gemini-3.7-flash-tiered`,
|
|
17
|
+
* `gemini-3.1-pro-low`) under it, so the choice is per wire model: see
|
|
18
|
+
* `antigravityUserAgentForWireModel`.
|
|
18
19
|
*/
|
|
19
20
|
export const ANTIGRAVITY_CLI_REQUEST_UA = antigravityCliUserAgent();
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
|
-
* Model discovery (`:fetchAvailableModels`) uses the CLI UA so
|
|
23
|
+
* Model discovery (`:fetchAvailableModels`) uses the CLI UA so the Gemini 4 wire ids are listed;
|
|
23
24
|
* under the IDE UA they are absent.
|
|
24
25
|
*/
|
|
25
26
|
export const ANTIGRAVITY_DISCOVERY_UA = ANTIGRAVITY_CLI_REQUEST_UA;
|
|
26
27
|
|
|
27
|
-
/**
|
|
28
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Wire ids CCA serves only to the CLI client family: every Gemini 4 codename, bare or with a tier
|
|
30
|
+
* suffix. Argon was verified 2026-10-14. On 2026-11-11 the CLI discovery list was exactly the IDE
|
|
31
|
+
* list plus the Argon and Carbon tiers, and `gemini-4-carbon-medium` 404'd under the IDE UA while
|
|
32
|
+
* answering 200 under the CLI UA. Matching the generation keeps a newly discovered codename
|
|
33
|
+
* callable instead of listing it in the picker and 404ing every request.
|
|
34
|
+
*/
|
|
35
|
+
const ANTIGRAVITY_CLI_ONLY_WIRE_MODEL = /^gemini-4-[a-z][a-z0-9]*(?:-(?:low|medium|high))?$/;
|
|
29
36
|
|
|
30
37
|
/** The User-Agent an Antigravity inference request for `wireModelId` must carry. */
|
|
31
38
|
export function antigravityUserAgentForWireModel(wireModelId: string): string {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { redactSecretString } from "../lib/redact";
|
|
2
|
+
import { withProviderFailureFacts } from "../lib/failure-detail";
|
|
2
3
|
import type { AdapterEvent, OcxUsage } from "../types";
|
|
3
4
|
|
|
4
5
|
/** Gemini/Vertex finishReason values that mean the turn was cut off, not cleanly stopped. */
|
|
@@ -37,10 +38,11 @@ export function vertexTruncationErrorEvent(
|
|
|
37
38
|
toolCallsStarted: number,
|
|
38
39
|
usage?: OcxUsage,
|
|
39
40
|
): Extract<AdapterEvent, { type: "error" }> {
|
|
40
|
-
|
|
41
|
+
// The request log keeps the closed finish reason that ended the turn (#8446); the wire event is unchanged.
|
|
42
|
+
return withProviderFailureFacts({
|
|
41
43
|
type: "error",
|
|
42
44
|
message: vertexTruncationErrorMessage(finishReason),
|
|
43
45
|
...(usage ? { usage } : {}),
|
|
44
46
|
...(finishReason === "MALFORMED_FUNCTION_CALL" && toolCallsStarted === 0 ? { replaySafeBeforeOutput: true } : {}),
|
|
45
|
-
};
|
|
47
|
+
} as const, { finishReason });
|
|
46
48
|
}
|
package/src/adapters/google.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { AdapterFetchContext, AdapterRequest, IncomingMeta, ProviderAdapter
|
|
|
3
3
|
import { debugDroppedFrame, debugProviderDiagnosticLazy } from "../lib/debug";
|
|
4
4
|
import { createToolCallIdAllocator } from "./tool-call-id";
|
|
5
5
|
import { openCodeGoGeminiEndpoint } from "../types/opencode-go";
|
|
6
|
+
import { withProviderFailureFacts } from "../lib/failure-detail";
|
|
6
7
|
import { createImageBudget, materializeInlineImage, MAX_ENCODED_BYTES_PER_IMAGE, artifactHttpUrl } from "../images/artifacts";
|
|
7
8
|
import type {
|
|
8
9
|
AdapterEvent,
|
|
@@ -20,6 +21,7 @@ import { isAllowedToolChoice, namespacedToolName, resolveToolChoiceWireName, too
|
|
|
20
21
|
import type { OcxTool } from "../types";
|
|
21
22
|
import { contentPartsToText, parseDataUrl } from "./image";
|
|
22
23
|
import { bindVertexRequestAuthority, GCP_CREDENTIAL_MARKER_PREFIX, gcpCredentialMarkerAccount, getVertexAccessTokenWithAuthority } from "../lib/gcp-adc";
|
|
24
|
+
import { isProviderApiKeyPaused, ProviderApiKeyPausedError } from "../providers/api-key-pause";
|
|
23
25
|
import { fetchAntigravityWithRetry, fetchVertexWithRetry } from "./google-http";
|
|
24
26
|
import { safeAntigravityHttpErrorMessage, safeVertexHttpErrorMessage } from "./google-errors";
|
|
25
27
|
import { readDisplaySafeErrorPayloadText } from "./upstream-http-error";
|
|
@@ -1238,6 +1240,8 @@ export function createGoogleAdapter(provider: OcxProviderConfig): ProviderAdapte
|
|
|
1238
1240
|
return { url, method: "POST", headers, body: JSON.stringify(envelope) };
|
|
1239
1241
|
}
|
|
1240
1242
|
|
|
1243
|
+
if (isProviderApiKeyPaused(provider)) throw new ProviderApiKeyPausedError();
|
|
1244
|
+
|
|
1241
1245
|
if (provider.googleMode === "vertex") {
|
|
1242
1246
|
if (provider.authMode === "forward") throw new Error("Vertex does not support forward authentication");
|
|
1243
1247
|
const compiled = compileGoogleWireBody(body, toolSchemaProfile, toolSchemaPolicy);
|
|
@@ -1390,12 +1394,14 @@ export function createGoogleAdapter(provider: OcxProviderConfig): ProviderAdapte
|
|
|
1390
1394
|
|
|
1391
1395
|
// Inline provider error inside a 200 stream → terminal error (see openai-chat.ts).
|
|
1392
1396
|
if (chunk.error) {
|
|
1393
|
-
const err = chunk.error as { message?: string } | undefined;
|
|
1397
|
+
const err = chunk.error as { message?: string; status?: unknown } | undefined;
|
|
1394
1398
|
// Clear-on-invalid: a signature rejection means our replayed thoughtSignatures are stale.
|
|
1395
1399
|
// Drop the cache entry and durable store entry for rejected calls so the next turn
|
|
1396
1400
|
// starts clean instead of re-injecting a bad sig.
|
|
1397
1401
|
handleSignatureRejection(err?.message);
|
|
1398
|
-
|
|
1402
|
+
// Only the closed RPC status class and finish reason ride along for the request log (#8446).
|
|
1403
|
+
yield withProviderFailureFacts({ type: "error", message: err?.message ?? "upstream error" } as AdapterEvent,
|
|
1404
|
+
{ type: err?.status, finishReason: lastFinishReason });
|
|
1399
1405
|
return "terminate";
|
|
1400
1406
|
}
|
|
1401
1407
|
|
|
@@ -22,6 +22,14 @@ function isRecord(value: unknown): value is Record<string, unknown> {
|
|
|
22
22
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
/** Checks for a nonempty image URL string in either supported shape, not URL syntax or reachability. */
|
|
26
|
+
function hasUsableImageUrl(part: Record<string, unknown>): boolean {
|
|
27
|
+
if (part.type !== "image_url") return false;
|
|
28
|
+
const imageUrl = part.image_url;
|
|
29
|
+
return (typeof imageUrl === "string" && imageUrl.length > 0)
|
|
30
|
+
|| (isRecord(imageUrl) && typeof imageUrl.url === "string" && imageUrl.url.length > 0);
|
|
31
|
+
}
|
|
32
|
+
|
|
25
33
|
/**
|
|
26
34
|
* Keep the newest images a first-party Mistral request may carry and replace older ones with a
|
|
27
35
|
* text note, across every message (promoted tool-result images included). Normalizes the outbound
|
|
@@ -30,21 +38,26 @@ function isRecord(value: unknown): value is Record<string, unknown> {
|
|
|
30
38
|
export function limitMistralChatImages(messages: unknown, provider: OcxProviderConfig, modelId: string): unknown {
|
|
31
39
|
if (!isMistralChatTarget(provider) || !Array.isArray(messages)) return messages;
|
|
32
40
|
const maxImages = mistralMaxImages(provider, modelId);
|
|
33
|
-
const images: Array<{ message: number; part: number }> = [];
|
|
34
|
-
messages.forEach((message, index) => {
|
|
35
|
-
if (!isRecord(message) || !Array.isArray(message.content)) return;
|
|
36
|
-
message.content.forEach((part, partIndex) => {
|
|
37
|
-
if (isRecord(part) && part.type === "image_url") images.push({ message: index, part: partIndex });
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
const excess = images.length - maxImages;
|
|
41
|
-
if (excess <= 0) return messages;
|
|
42
41
|
const note = { type: "text", text: `[image omitted: Mistral accepts at most ${maxImages} images per request for this model; older images were dropped]` };
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
const missingNote = { type: "text", text: "[image omitted: missing or malformed image URL]" };
|
|
43
|
+
let imagesKept = 0;
|
|
44
|
+
let out: unknown[] | undefined;
|
|
45
|
+
for (let index = messages.length - 1; index >= 0; index--) {
|
|
46
|
+
const message = messages[index];
|
|
47
|
+
if (!isRecord(message) || !Array.isArray(message.content)) continue;
|
|
48
|
+
const content = message.content;
|
|
49
|
+
let nextContent: unknown[] | undefined;
|
|
50
|
+
for (let partIndex = content.length - 1; partIndex >= 0; partIndex--) {
|
|
51
|
+
const part = content[partIndex];
|
|
52
|
+
if (!isRecord(part) || part.type !== "image_url") continue;
|
|
53
|
+
const usable = hasUsableImageUrl(part);
|
|
54
|
+
if (usable && imagesKept++ < maxImages) continue;
|
|
55
|
+
nextContent ??= content.slice();
|
|
56
|
+
nextContent[partIndex] = usable ? note : missingNote;
|
|
57
|
+
}
|
|
58
|
+
if (!nextContent) continue;
|
|
59
|
+
out ??= messages.slice();
|
|
60
|
+
out[index] = { ...message, content: nextContent };
|
|
48
61
|
}
|
|
49
|
-
return out;
|
|
62
|
+
return out ?? messages;
|
|
50
63
|
}
|
|
@@ -162,6 +162,15 @@ function isClaudeModelId(modelId: string | undefined): boolean {
|
|
|
162
162
|
return tail.startsWith("claude-");
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
+
/**
|
|
166
|
+
* The Claude root flattening above, for other wires that front Claude with a translated tool
|
|
167
|
+
* schema (Devin's GetChatMessage). Root oneOf/anyOf/allOf branches merge into one object;
|
|
168
|
+
* nested schemas, property values and literal data are copied as they are.
|
|
169
|
+
*/
|
|
170
|
+
export function flattenClaudeRootToolParameters(parameters: unknown): Record<string, unknown> {
|
|
171
|
+
return ensureZenRootObjectSchema(parameters, false);
|
|
172
|
+
}
|
|
173
|
+
|
|
165
174
|
function isAzureOpenAiChatTarget(provider: OcxProviderConfig): boolean {
|
|
166
175
|
try {
|
|
167
176
|
const host = new URL(provider.baseUrl).hostname.toLowerCase();
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { parseDataUrl } from "./image";
|
|
2
|
+
import { sniffImageDimensions } from "./anthropic-image-guard";
|
|
3
|
+
import { MAX_INPUT_PIXELS } from "./anthropic-image-codec";
|
|
4
|
+
import { enterImageDecode } from "./anthropic-image-normalize";
|
|
2
5
|
import {
|
|
3
6
|
normalizeImageTargets,
|
|
4
7
|
type NormalizeOptions,
|
|
@@ -12,6 +15,18 @@ import {
|
|
|
12
15
|
*/
|
|
13
16
|
export const OPENAI_CHAT_IMAGE_BASE64_BUDGET = 3_670_016; // 3.5MiB
|
|
14
17
|
|
|
18
|
+
/** Longest edge an undersized image may be stretched to while reaching the minimum edge. */
|
|
19
|
+
export const OPENAI_CHAT_UPSCALE_MAX_EDGE = 4096;
|
|
20
|
+
|
|
21
|
+
/** Resizes decoded image bytes to exactly `width` x `height` and returns base64 plus media type. */
|
|
22
|
+
export type UpscaleFn = (input: Buffer, width: number, height: number) => Promise<{ data: string; mediaType: string }>;
|
|
23
|
+
|
|
24
|
+
/** Default upscaler: Bun.Image resize, re-encoded as PNG so small text strips stay sharp. */
|
|
25
|
+
export const bunImageUpscale: UpscaleFn = async (input, width, height) => {
|
|
26
|
+
const out = await new Bun.Image(input).resize(width, height).png().toBuffer();
|
|
27
|
+
return { data: Buffer.from(out).toString("base64"), mediaType: "image/png" };
|
|
28
|
+
};
|
|
29
|
+
|
|
15
30
|
export interface NormalizeOpenAIChatImagesOptions
|
|
16
31
|
extends Pick<NormalizeOptions, "encode" | "tierBias" | "validate"> {
|
|
17
32
|
abortSignal?: AbortSignal;
|
|
@@ -61,6 +76,91 @@ export function hasShrinkableOpenAIChatImages(messages: unknown): boolean {
|
|
|
61
76
|
return found;
|
|
62
77
|
}
|
|
63
78
|
|
|
79
|
+
/**
|
|
80
|
+
* Target size for an image whose short edge is below `minEdge`, or null when it already
|
|
81
|
+
* fits or cannot be handled safely. Aspect ratio is kept; the long edge is clamped to
|
|
82
|
+
* OPENAI_CHAT_UPSCALE_MAX_EDGE, which only distorts extreme strips.
|
|
83
|
+
*/
|
|
84
|
+
export function upscaledImageSize(width: number, height: number, minEdge: number): { width: number; height: number } | null {
|
|
85
|
+
if (!(width > 0 && height > 0) || Math.min(width, height) >= minEdge) return null;
|
|
86
|
+
if (width * height > MAX_INPUT_PIXELS) return null;
|
|
87
|
+
const scale = minEdge / Math.min(width, height);
|
|
88
|
+
const clamp = (edge: number): number => Math.min(OPENAI_CHAT_UPSCALE_MAX_EDGE, Math.max(minEdge, Math.ceil(edge * scale)));
|
|
89
|
+
return { width: clamp(width), height: clamp(height) };
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Whether any inline image has a sniffable short edge below `minEdge`. */
|
|
93
|
+
export function hasUndersizedOpenAIChatImages(messages: unknown, minEdge: number): boolean {
|
|
94
|
+
let found = false;
|
|
95
|
+
forEachImagePart(messages, (_imageUrl, url) => {
|
|
96
|
+
const source = parseDataUrl(url);
|
|
97
|
+
const dims = source ? sniffImageDimensions(source.base64) : null;
|
|
98
|
+
if (dims && upscaledImageSize(dims.width, dims.height, minEdge)) {
|
|
99
|
+
found = true;
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
return found;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Upscale inline images below `minEdge` in already-built Chat Completions messages, in place.
|
|
108
|
+
* Runs after budget normalization, because that step can itself floor a wide screenshot
|
|
109
|
+
* under the minimum. An image that cannot be decoded keeps its original URL.
|
|
110
|
+
*/
|
|
111
|
+
export async function upscaleUndersizedOpenAIChatImages(
|
|
112
|
+
messages: unknown,
|
|
113
|
+
minEdge: number,
|
|
114
|
+
options: { upscale?: UpscaleFn; abortSignal?: AbortSignal } = {},
|
|
115
|
+
): Promise<void> {
|
|
116
|
+
const upscale = options.upscale ?? bunImageUpscale;
|
|
117
|
+
const jobs: Array<{ imageUrl: Record<string, unknown>; base64: string; width: number; height: number }> = [];
|
|
118
|
+
forEachImagePart(messages, (imageUrl, url) => {
|
|
119
|
+
const source = parseDataUrl(url);
|
|
120
|
+
const dims = source ? sniffImageDimensions(source.base64) : null;
|
|
121
|
+
const target = dims ? upscaledImageSize(dims.width, dims.height, minEdge) : null;
|
|
122
|
+
if (source && target) jobs.push({ imageUrl, base64: source.base64, ...target });
|
|
123
|
+
});
|
|
124
|
+
const throwIfAborted = (): void => {
|
|
125
|
+
if (options.abortSignal?.aborted) throw options.abortSignal.reason ?? new DOMException("Aborted", "AbortError");
|
|
126
|
+
};
|
|
127
|
+
for (const job of jobs) {
|
|
128
|
+
throwIfAborted();
|
|
129
|
+
// Decoded bitmaps share the process-wide decode bound with the other image normalizers.
|
|
130
|
+
const release = await enterImageDecode(options.abortSignal);
|
|
131
|
+
try {
|
|
132
|
+
const out = await upscale(Buffer.from(job.base64, "base64"), job.width, job.height);
|
|
133
|
+
job.imageUrl.url = `data:${out.mediaType};base64,${out.data}`;
|
|
134
|
+
} catch {
|
|
135
|
+
// Keep the original image; the upstream reports its own validation error.
|
|
136
|
+
} finally {
|
|
137
|
+
release();
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
// A cancellation during the last resize must not let a request for a cancelled turn through.
|
|
141
|
+
throwIfAborted();
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Image work the openai-chat adapter must finish before it builds the request, or null when
|
|
146
|
+
* there is none. Budget normalization runs first because it can floor a wide screenshot below
|
|
147
|
+
* the upstream minimum. A failure keeps the original images unless the request was cancelled.
|
|
148
|
+
*/
|
|
149
|
+
export function prepareOpenAIChatImages(
|
|
150
|
+
messages: unknown,
|
|
151
|
+
minImageEdge: number | undefined,
|
|
152
|
+
options: NormalizeOpenAIChatImagesOptions = {},
|
|
153
|
+
): Promise<void> | null {
|
|
154
|
+
const shrink = hasShrinkableOpenAIChatImages(messages);
|
|
155
|
+
if (!shrink && (minImageEdge === undefined || !hasUndersizedOpenAIChatImages(messages, minImageEdge))) return null;
|
|
156
|
+
return (async () => {
|
|
157
|
+
if (shrink) await normalizeOpenAIChatImages(messages, options);
|
|
158
|
+
if (minImageEdge !== undefined) await upscaleUndersizedOpenAIChatImages(messages, minImageEdge, { abortSignal: options.abortSignal });
|
|
159
|
+
})().catch(error => {
|
|
160
|
+
if (options.abortSignal?.aborted) throw error;
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
|
|
64
164
|
/**
|
|
65
165
|
* Normalize image_url parts in already-built Chat Completions messages, in place.
|
|
66
166
|
*
|