@bitkyc08/opencodex 2.98.0 → 2.99.0-preview.20261108
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/bin/ocx.mjs +6 -19
- package/gui/dist/assets/{App-6TFtZsUF.css → App-C1hGwaN1.css} +1 -1
- package/gui/dist/assets/App-CWz0areF.js +59 -0
- package/gui/dist/assets/Tray-BosDoskm.js +1 -0
- package/gui/dist/assets/{brand-mark-A03mw_9y.js → brand-mark-DpiBmFGI.js} +1 -1
- package/gui/dist/assets/{index-BjTIN4to.js → index-CAxjGWkm.js} +13 -13
- package/gui/dist/assets/index-bnUWypyz.css +2 -0
- package/gui/dist/assets/{segment-thumb-features-Bf6vpwf8.js → segment-thumb-features-JcszQ18T.js} +1 -1
- package/gui/dist/classic/assets/App-BOEsFmiN.js +58 -0
- package/gui/dist/classic/assets/Tray-5v86r9Az.js +1 -0
- package/gui/dist/classic/assets/{index-DFAFnven.js → index-ClZ_zZ77.js} +13 -13
- package/gui/dist/classic/assets/{quota-summary-C-4HP4_5.js → quota-summary-xwvDtvu7.js} +1 -1
- package/gui/dist/classic/index.html +1 -1
- package/gui/dist/index.html +2 -2
- package/package.json +1 -1
- package/src/adapters/coding-agent/protocol.ts +8 -3
- package/src/adapters/coding-agent/turn.ts +6 -2
- package/src/adapters/command-code.ts +8 -5
- package/src/adapters/devin.ts +11 -1
- package/src/adapters/kiro/stream.ts +5 -4
- package/src/adapters/openai-chat/destination-policy.ts +25 -0
- package/src/adapters/openai-chat/native-content.ts +32 -0
- package/src/adapters/openai-chat/passthrough.ts +14 -1
- package/src/adapters/openai-chat/reasoning-wire.ts +42 -1
- package/src/adapters/openai-chat.ts +2 -2
- package/src/adapters/qoder/adapter.ts +9 -0
- package/src/bridge/response-json.ts +13 -1
- package/src/bridge/sse.ts +112 -22
- package/src/cli/account-affinity-reset.ts +42 -0
- package/src/cli/account.ts +5 -0
- package/src/cli/capabilities-accounts.ts +8 -0
- package/src/cli/capabilities-agents-routing.ts +5 -4
- package/src/cli/message-command.ts +1 -1
- package/src/cli/message-mcp-command.ts +8 -5
- package/src/client/orphan-token-recovery.ts +1 -1
- package/src/codex/autostart-health.ts +4 -2
- package/src/generated/compatibility-version.json +128 -76
- package/src/lib/desktop-cli-handoff.mjs +5 -8
- package/src/lib/failure-detail.ts +5 -2
- package/src/lib/launcher-signal-forwarding.d.mts +8 -0
- package/src/lib/launcher-signal-forwarding.mjs +36 -0
- package/src/lib/privacy.ts +6 -0
- package/src/lib/request-execution-budget.ts +188 -33
- package/src/lib/upstream-validation-detail.ts +47 -0
- package/src/lib/workflow-budget.ts +35 -16
- package/src/messaging/mcp-queue-rpc.ts +7 -3
- package/src/messaging/mcp-queue-server.ts +6 -0
- package/src/messaging/mcp-reply-cursor.ts +34 -0
- package/src/messaging/mcp-reply-tools.ts +93 -0
- package/src/oauth/anthropic-routing.ts +46 -3
- package/src/oauth/anthropic-session-affinity-store.ts +23 -10
- package/src/protocols/codecs/ollama.ts +22 -12
- package/src/providers/registry/entries-extended.ts +14 -0
- package/src/remote/hub-usage.ts +7 -0
- package/src/responses/parser.ts +27 -0
- package/src/responses/reasoning-envelope.ts +4 -0
- package/src/responses/schema.ts +1 -0
- package/src/server/chat-completions.ts +3 -0
- package/src/server/chat-native-sse.ts +14 -10
- package/src/server/chat-native.ts +24 -11
- package/src/server/index/websocket-handler.ts +12 -1
- package/src/server/management/oauth-account-routes.ts +65 -13
- package/src/server/management/route-registry.ts +1 -0
- package/src/server/messages-native.ts +21 -5
- package/src/server/request-log-attempt-recovery.ts +17 -0
- package/src/server/request-log-failure-detail.ts +18 -1
- package/src/server/request-log.ts +5 -18
- package/src/server/responses/account-auto-pause-recovery.ts +29 -1
- package/src/server/responses/adapter-continuation.ts +12 -5
- package/src/server/responses/adapter-dispatch.ts +50 -51
- package/src/server/responses/antigravity-model-denial-recovery.ts +4 -2
- package/src/server/responses/codex-ws-exchange.ts +13 -4
- package/src/server/responses/combo-required-tool-contract.ts +22 -3
- package/src/server/responses/core-codex-account.ts +92 -86
- package/src/server/responses/core-combo-failure.ts +7 -0
- package/src/server/responses/core-combo.ts +11 -4
- package/src/server/responses/core-lifetime.ts +3 -0
- package/src/server/responses/deferred-send-reporter.ts +18 -1
- package/src/server/responses/fetch-helpers.ts +9 -3
- package/src/server/responses/native-continuation-refusal.ts +8 -0
- package/src/server/responses/native-continuation-send.ts +34 -0
- package/src/server/responses/passthrough-delivery.ts +6 -2
- package/src/server/responses/passthrough-dispatch.ts +48 -33
- package/src/server/responses/passthrough-execution.ts +1 -0
- package/src/server/responses/policy-fallback.ts +32 -5
- package/src/server/responses/policy-request-scope.ts +26 -0
- package/src/server/responses/request-prepare.ts +11 -2
- package/src/server/responses/request-send-budget.ts +96 -14
- package/src/server/responses/request-spend-target.ts +19 -0
- package/src/server/responses/request-spend.ts +80 -28
- package/src/server/responses/request-transport.ts +106 -53
- package/src/server/responses/run-turn-execution.ts +3 -0
- package/src/server/responses/sidecar-execution.ts +2 -1
- package/src/server/responses/ws-upstream.ts +2 -1
- package/src/server/workflow-refusal.ts +38 -4
- package/src/server/ws-bridge.ts +10 -3
- package/src/service/desktop-startup.ts +76 -13
- package/src/types/request.ts +2 -1
- package/src/usage/app-breakdown.ts +23 -0
- package/src/usage/summary.ts +34 -1
- package/src/web-search/anthropic-executor.ts +25 -9
- package/src/web-search/loop.ts +3 -1
- package/src/web-search/passthrough-bridge.ts +3 -0
- package/src/web-search/run-turn-loop.ts +3 -1
- package/gui/dist/assets/App-FQ0OtiMJ.js +0 -59
- package/gui/dist/assets/Tray-D2d5wqLq.js +0 -1
- package/gui/dist/assets/index-5REODpG3.css +0 -2
- package/gui/dist/classic/assets/App-C9Eg3nUo.js +0 -58
- package/gui/dist/classic/assets/Tray-B8P8cokE.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{O as e,S as t,n}from"./index-DFAFnven.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`})}),ee=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`M18 6 6 18M6 6l12 12`})}),te=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`M12 5v14M5 12h14`})}),g=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`M5 12h14`})}),ne=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`})}),re=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`})]}),ie=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`M8 5v14M16 5v14`})}),ae=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`m7 4 13 8-13 8Z`})}),oe=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`M3 6h18M8 6V4h8v2M19 6l-1 14H6L5 6`})}),se=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`})}),ce=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`})]}),le=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`})]}),ue=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`})]}),de=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`})]}),fe=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`M12 19V5M5 12l7-7 7 7`})}),pe=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`M12 5v14M19 12l-7 7-7-7`})}),me=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`})}),he=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`m9 18 6-6-6-6`})}),ge=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`})}),_e=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`})]}),ve=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`})}),ye=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`})]}),be=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`})}),xe=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`})]}),Se=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`})]}),Ce=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`})}),we=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`})]}),Te=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`})}),Ee=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`})]}),De=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`})]}),Oe=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`})]}),ke=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`})]}),_=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`})}),Ae=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`M4 5h16l-6 7v5l-4 2v-7L4 5z`})}),v={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`},y={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`},b={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`},je=new Set([...Object.keys(y),...Object.keys(b)]);function Me(e){let t=e.toLowerCase();return Object.hasOwn(v,t)?v[t]:void 0}function Ne(e,t){let n=Me(e);return n?`/provider-icons/${n}`:void 0}var Pe=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`]),Fe=new Set([`baseten.svg`,`kilo.svg`,`sambanova.svg`,`venice.svg`,`zai.svg`]),Ie=new Set([`bizrouter.svg`,`featherless.svg`,`hyperbolic.svg`,`nebius.svg`,`parallel.svg`,`umans.svg`]);function Le(e){if(!e)return`image`;let t=e.split(`/`).pop()??``;return Pe.has(t)?`mask`:Fe.has(t)?`plate`:Ie.has(t)?`dark-plate`:`image`}function x(e,t){let n=e.toLowerCase(),r=Object.hasOwn(b,n)?b[n]:void 0;return r?t(r):(Object.hasOwn(y,n)?y[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 Re(e){return je.has(e.toLowerCase())}function ze(e){return e===`command-code`?`commandcode-auth`:e===`commandcode`?`commandcode-api`:e}function Be(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 Ve={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 S(e){return e.replace(/\.0+$/,``).replace(/(\.\d*?)0+$/,`$1`)}function He(e,t){let n=Ve[t];if(n){for(let t of n)if(e>=t.v)return`${S((e/t.v).toFixed(1))}${t.s}`;return String(e)}return e<1e4?String(e):e<1e6?`${S((e/1e3).toFixed(1))}K`:e<1e9?`${S((e/1e6).toFixed(1))}M`:e<0xe8d4a51000?`${S((e/1e9).toFixed(1))}B`:`${S((e/0xe8d4a51000).toFixed(1))}T`}var Ue=new Set([`claude-cli`]),We=`anthropic-apikey`;function C(e){return Ue.has((e.adapter??``).trim())}var Ge=`https://chatgpt.com/backend-api/codex`,Ke=`openai`;function w(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 qe=new URL(Ge).protocol;function Je(e,...t){return`${qe}//${e}/${t.join(`/`)}`}var Ye={"cline-pass":{adapter:`openai-chat`,baseUrl:Je(`api.cline.bot`,`api`,`v1`)},"mimo-free":{adapter:`mimo-free`,baseUrl:Je(`api.xiaomimimo.com`,`api`,`free-ai`,`openai`,`chat`)}};function Xe(e,t){let n=Ye[e];return!n||t.adapter!==n.adapter||w(t.baseUrl)!==w(n.baseUrl)}function T(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 E(e){return e.keyOptional===!0||C(e)||e.authMode===`oauth`||e.authMode===`forward`||e.authMode===`local`||T(e.baseUrl)||e.hasApiKey===!0}function D(e){return e.adapter===`openai-responses`&&e.authMode===`forward`&&w(e.baseUrl)===Ge}function O(e,t){return e===Ke&&D(t)}function k(e){return C(e)?!1:e.freeTier===!0||e.keyOptional===!0||e.authMode===`local`||T(e.baseUrl)}function A(e,t){return O(e,t)?`accounts`:k(t)?`free`:`paid`}function Ze(e,t){let n=[...e],r=(e,t)=>e.name.localeCompare(t.name,void 0,{sensitivity:`base`}),i=e=>e.tier??A(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 Qe(e){let t=[],n=[],r=[];for(let[i,a]of Object.entries(e))a.disabled?r.push({name:i,...a}):E(a)?t.push({name:i,...a,tier:A(i,a)}):n.push({name:i,...a});return{ready:t,needsSetup:n,disabled:r}}function $e(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 j(e){return e.disabled?`disabled`:`activeNeedsReauth`in e&&e.activeNeedsReauth?`needs-setup`:E(e)?`ready`:`needs-setup`}function et(e){let t=e.openai,n=e.chatgpt;if(!t||!n||!O(`openai`,t)||!D(n))return e;let r={...e};return delete r.chatgpt,r}function M(e){return e.authMode===`local`||T(e.baseUrl)}var tt=[`ollama`,`vllm`,`lm-studio`,`lmstudio`,`litellm`,`localai`];function nt(e){let t=(e.authMode??``).toLowerCase();if(t===`oauth`||t===`forward`)return`login`;if(M(e))return`local`;let n=`${e.name??``} ${e.adapter} ${e.baseUrl}`.toLowerCase();return tt.some(e=>n.includes(e))?`selfHosted`:`cloud`}var N=[`plan_base`,`plan_bonus`,`addon`,`benefit`,`other`];function P(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}function F(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 I(e){let t=P(e),n=F(t.total),r=F(t.used),i=F(t.remaining),a=F(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 rt(e){let t=P(e),n=I(e);if(!n||!Array.isArray(t.groups)||t.groups.length>N.length)return;let r=[],i=new Set;for(let e of t.groups){let t=P(e),n=I(t),a=N.find(e=>e===t.kind);if(!n||!a||i.has(a))return;i.add(a),r.push({kind:a,...n})}let a=P(t.expiring),o=F(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 L(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 it(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=L(i,t);r.trim()&&e&&(n[r]=e)}return n}function at(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=L(r,t);typeof e==`string`&&e.trim()&&i&&(n[e]=i)}return n}function ot(e){return e?.observed===!0&&typeof e.updatedAt==`number`?e.updatedAt:void 0}var R=e=>typeof e==`number`&&Number.isFinite(e)?e:void 0,st=e=>{let t=R(e);if(t===void 0)return;let n=t>1e10?t:t*1e3;return Number.isFinite(new Date(n).getTime())?t:void 0};function z(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`||R(t.percent)===void 0?[]:[{label:t.label,percent:t.percent,...R(t.resetAt)===void 0?{}:{resetAt:t.resetAt},...typeof t.modelId==`string`&&t.modelId.length<=128?{modelId:t.modelId}:{}}]}):[],i=n.creditsUsd&&typeof n.creditsUsd==`object`&&!Array.isArray(n.creditsUsd)?n.creditsUsd:null,a=R(i?.used),o=R(i?.limit),s=R(i?.remaining),c=R(i?.percent),l=st(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=rt(n.workbuddyCredits),f={...d?{workbuddyCredits:d}:{},...R(n.fiveHourPercent)===void 0?{}:{fiveHourPercent:n.fiveHourPercent},...R(n.fiveHourResetAt)===void 0?{}:{fiveHourResetAt:n.fiveHourResetAt},...R(n.weeklyPercent)===void 0?{}:{weeklyPercent:n.weeklyPercent},...R(n.weeklyResetAt)===void 0?{}:{weeklyResetAt:n.weeklyResetAt},...R(n.monthlyPercent)===void 0?{}:{monthlyPercent:n.monthlyPercent},...R(n.monthlyResetAt)===void 0?{}:{monthlyResetAt:n.monthlyResetAt},...r.length>0?{customWindows:r}:{},...u?{creditsUsd:u}:{},updatedAt:R(n.updatedAt)??t??Date.now()};return f.fiveHourPercent!==void 0||f.weeklyPercent!==void 0||f.monthlyPercent!==void 0||(f.customWindows?.length??0)>0||f.creditsUsd!==void 0||f.workbuddyCredits!==void 0?f:null}function B(e){return z(e?.quota,e?.updatedAt)}function ct(e){if(!e)return;if(e.aggregation===void 0)return e;let t=H(e)?.currentAccount?.quota??null;return{...e,aggregation:void 0,quota:t,updatedAt:t?.updatedAt}}function V(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e,n=R(t.usedPercent);if(n!==void 0)return{usedPercent:n,...typeof t.incomplete==`boolean`?{incomplete:t.incomplete}:{},...R(t.excludedAccounts)===void 0?{}:{excludedAccounts:t.excludedAccounts},...R(t.nextRecoveryAt)===void 0?{}:{nextRecoveryAt:t.nextRecoveryAt},...R(t.nextRecoveryPercent)===void 0?{}:{nextRecoveryPercent:t.nextRecoveryPercent}}}function H(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=R(n.excludedAccounts),i=R(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=V(t);return typeof t.label==`string`&&n?[{label:t.label,...n}]:[]}):[],s=V(n.fiveHour),c=V(n.weekly),l=V(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:R(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:z(a.quota)}}:{}}}function lt(e){if(!e?.trim())return``;let[t,n]=e.split(`:`,2);return n?`${t} · ${n.replace(/-/g,` `)}`:e}function ut(e,t){let n=j(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 dt(e,t){if(C(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 ft(e){let t=j(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 U({name:t,adapter:n,baseUrl:i,cls:a}){let o=e(),s=Ne(t,{adapter:n,baseUrl:i}),c=Le(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)(pt,{name:t,label:x(t,o)})})}function pt({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 mt({item:t,selected:n,tabbable:i,modelCount:a,isDefault:o,showConfigId:s,onClick:c,onFocus:l}){let u=e(),d=k(t),f=M(t),p=ut(t,u),m=x(t.name,u),h=s?`${m} (${t.name})`:m,ee=`${o?u(`pws.rail.suffixDefault`):``}${f?u(`pws.rail.suffixLocal`):d?u(`pws.rail.suffixFree`):``}`,te=a!==void 0&&a>0?a===1?u(`pws.modelCountOne`):u(`pws.modelCount`,{count:a}):``,g=[s?t.name:``,te].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:ee}),title:h,onFocus:l,children:[(0,r.jsx)(U,{name:t.name,adapter:t.adapter,baseUrl:t.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:g||void 0,children:g||`\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)(_,{width:17,height:17,"aria-hidden":`true`})}),(0,r.jsx)(`span`,{className:ft(t),title:p,"aria-hidden":`true`})]})]})}var ht=1e10;function W(e){return e<ht?e*1e3:e}function gt(e,t){return typeof e==`number`&&Number.isFinite(e)&&e>0&&W(e)<=t}function _t(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 W(r)>t}function vt(e){return{fiveHourAvailable:e?.shortWindowSeconds===18e3&&typeof e.shortResetAt==`number`,weeklyAvailable:typeof e?.weeklyResetAt==`number`}}function G(e){let t=e?.trim().toLowerCase();return t===`go`||t===`free`}function yt(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 G(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 bt(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=(G(t)?[e.monthlyPercent]:[e.weeklyPercent,e.monthlyPercent]).filter(r);if(a.length===0)return _t({...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)&&!gt(e.fiveHourResetAt??e.shortResetAt,n)?[...a,i]:a;return o.length?Math.max(...o):null}function xt(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 K(e){return Array.isArray(e)&&e.length<=100&&e.every(e=>typeof e==`string`)?JSON.stringify([...new Set(e)].sort()):void 0}function St(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&&K(o.hiddenProviders)===K(t.hiddenProviders)&&(t.models===null?o.models===null:K(o.models)===K(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 Ct={6:15,24:60,72:180,168:360};function wt(e){return Ct[e]}function Tt(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 Et(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 Dt(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 Ot(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 kt(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 At(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`],jt=640,Mt=160,J=28;function Nt(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 Pt(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 Ft({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=Nt(e,t),u=Pt(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:kt(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)):At(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 ${jt} ${Mt}`,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:Tt(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 It(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 Lt(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 Rt(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 zt(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 Bt(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`?Vt(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,...Rt(n,c),exhausted:a!==null&&zt(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:yt(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 Vt(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 Ht(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 Ut(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,modelId:e.modelId,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 Wt(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 Gt(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 Kt(e,n){let r=t(2e4),i=()=>r.controller.abort();n.aborted&&i(),n.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(),n.removeEventListener(`abort`,i)}}function qt(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 Jt(e){return Q(e)?`${Math.floor(e)}%`:`-`}var Yt=[`quota.weeklyLimit`,`quota.monthlyLimit`,`quota.fiveHourLimit`];function Xt(e){let t=Ut(e).map(e=>{let t=Q(e.percent)?e.percent:void 0,n=Z(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}:{},...t===void 0?{}:{percent:t},...n===null?{}:{resetAt:n},severity:r===void 0?$(t):`normal`}}),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)})}let r=new Set;return t.map(e=>{let t=e.id,n=1;for(;r.has(t);)t=`${e.id}#${n++}`;return r.add(t),t===e.id?e:{...e,id:t}})}function Zt(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 Yt){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]}function Qt(e,t){let n=[];for(let[r,i]of Object.entries(e)){let e=B(i);if(!e)continue;let a=Xt(e),o=Zt(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 $,ct as A,ae as At,et as B,Se as Bt,yt as C,u as Ct,dt as D,d as Dt,mt as E,Te as Et,M as F,o as Ft,Ze as G,k as H,ee as Ht,nt as I,Oe as It,He as J,We as K,$e as L,_ as Lt,it as M,_e as Mt,at as N,ne as Nt,B as O,ie as Ot,ot as P,de as Pt,ze as Q,j as R,we as Rt,bt as S,xe as St,U as T,Ee as Tt,Xe as U,O as V,oe as Vt,A as W,x as X,Be as Y,Re as Z,St as _,re as _t,Kt as a,h as at,Et as b,Ce as bt,Gt as c,me as ct,It as d,Ae as dt,le as et,Ut as f,ge as ft,Ot as g,m as gt,wt as h,ke as ht,Lt as i,s as it,lt as j,te as jt,H as k,ce as kt,Bt as l,ve as lt,Ft as m,a as mt,Jt as n,fe as nt,Wt as o,he as ot,Ht as p,De as pt,C as q,$ as r,c as rt,Y as s,be as st,Qt as t,pe as tt,qt as u,se as ut,xt as v,ue as vt,vt as w,g as wt,Dt as x,l as xt,Tt as y,ye as yt,Qe as z,f as zt};
|
|
1
|
+
import{O as e,S as t,n}from"./index-ClZ_zZ77.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`})}),ee=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`M18 6 6 18M6 6l12 12`})}),te=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`M12 5v14M5 12h14`})}),g=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`M5 12h14`})}),ne=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`})}),re=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`})]}),ie=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`M8 5v14M16 5v14`})}),ae=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`m7 4 13 8-13 8Z`})}),oe=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`M3 6h18M8 6V4h8v2M19 6l-1 14H6L5 6`})}),se=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`})}),ce=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`})]}),le=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`})]}),ue=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`})]}),de=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`})]}),fe=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`M12 19V5M5 12l7-7 7 7`})}),pe=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`M12 5v14M19 12l-7 7-7-7`})}),me=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`})}),he=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`m9 18 6-6-6-6`})}),ge=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`})}),_e=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`})]}),ve=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`})}),ye=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`})]}),be=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`})}),xe=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`})]}),Se=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`})]}),Ce=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`})}),we=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`})]}),Te=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`})}),Ee=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`})]}),De=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`})]}),Oe=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`})]}),ke=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`})]}),_=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`})}),Ae=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`M4 5h16l-6 7v5l-4 2v-7L4 5z`})}),v={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`},y={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`},b={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`},je=new Set([...Object.keys(y),...Object.keys(b)]);function Me(e){let t=e.toLowerCase();return Object.hasOwn(v,t)?v[t]:void 0}function Ne(e,t){let n=Me(e);return n?`/provider-icons/${n}`:void 0}var Pe=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`]),Fe=new Set([`baseten.svg`,`kilo.svg`,`sambanova.svg`,`venice.svg`,`zai.svg`]),Ie=new Set([`bizrouter.svg`,`featherless.svg`,`hyperbolic.svg`,`nebius.svg`,`parallel.svg`,`umans.svg`]);function Le(e){if(!e)return`image`;let t=e.split(`/`).pop()??``;return Pe.has(t)?`mask`:Fe.has(t)?`plate`:Ie.has(t)?`dark-plate`:`image`}function x(e,t){let n=e.toLowerCase(),r=Object.hasOwn(b,n)?b[n]:void 0;return r?t(r):(Object.hasOwn(y,n)?y[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 Re(e){return je.has(e.toLowerCase())}function ze(e){return e===`command-code`?`commandcode-auth`:e===`commandcode`?`commandcode-api`:e}function Be(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 Ve={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 S(e){return e.replace(/\.0+$/,``).replace(/(\.\d*?)0+$/,`$1`)}function He(e,t){let n=Ve[t];if(n){for(let t of n)if(e>=t.v)return`${S((e/t.v).toFixed(1))}${t.s}`;return String(e)}return e<1e4?String(e):e<1e6?`${S((e/1e3).toFixed(1))}K`:e<1e9?`${S((e/1e6).toFixed(1))}M`:e<0xe8d4a51000?`${S((e/1e9).toFixed(1))}B`:`${S((e/0xe8d4a51000).toFixed(1))}T`}var Ue=new Set([`claude-cli`]),We=`anthropic-apikey`;function C(e){return Ue.has((e.adapter??``).trim())}var Ge=`https://chatgpt.com/backend-api/codex`,Ke=`openai`;function w(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 qe=new URL(Ge).protocol;function Je(e,...t){return`${qe}//${e}/${t.join(`/`)}`}var Ye={"cline-pass":{adapter:`openai-chat`,baseUrl:Je(`api.cline.bot`,`api`,`v1`)},"mimo-free":{adapter:`mimo-free`,baseUrl:Je(`api.xiaomimimo.com`,`api`,`free-ai`,`openai`,`chat`)}};function Xe(e,t){let n=Ye[e];return!n||t.adapter!==n.adapter||w(t.baseUrl)!==w(n.baseUrl)}function T(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 E(e){return e.keyOptional===!0||C(e)||e.authMode===`oauth`||e.authMode===`forward`||e.authMode===`local`||T(e.baseUrl)||e.hasApiKey===!0}function D(e){return e.adapter===`openai-responses`&&e.authMode===`forward`&&w(e.baseUrl)===Ge}function O(e,t){return e===Ke&&D(t)}function k(e){return C(e)?!1:e.freeTier===!0||e.keyOptional===!0||e.authMode===`local`||T(e.baseUrl)}function A(e,t){return O(e,t)?`accounts`:k(t)?`free`:`paid`}function Ze(e,t){let n=[...e],r=(e,t)=>e.name.localeCompare(t.name,void 0,{sensitivity:`base`}),i=e=>e.tier??A(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 Qe(e){let t=[],n=[],r=[];for(let[i,a]of Object.entries(e))a.disabled?r.push({name:i,...a}):E(a)?t.push({name:i,...a,tier:A(i,a)}):n.push({name:i,...a});return{ready:t,needsSetup:n,disabled:r}}function $e(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 j(e){return e.disabled?`disabled`:`activeNeedsReauth`in e&&e.activeNeedsReauth?`needs-setup`:E(e)?`ready`:`needs-setup`}function et(e){let t=e.openai,n=e.chatgpt;if(!t||!n||!O(`openai`,t)||!D(n))return e;let r={...e};return delete r.chatgpt,r}function M(e){return e.authMode===`local`||T(e.baseUrl)}var tt=[`ollama`,`vllm`,`lm-studio`,`lmstudio`,`litellm`,`localai`];function nt(e){let t=(e.authMode??``).toLowerCase();if(t===`oauth`||t===`forward`)return`login`;if(M(e))return`local`;let n=`${e.name??``} ${e.adapter} ${e.baseUrl}`.toLowerCase();return tt.some(e=>n.includes(e))?`selfHosted`:`cloud`}var N=[`plan_base`,`plan_bonus`,`addon`,`benefit`,`other`];function P(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}function F(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 I(e){let t=P(e),n=F(t.total),r=F(t.used),i=F(t.remaining),a=F(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 rt(e){let t=P(e),n=I(e);if(!n||!Array.isArray(t.groups)||t.groups.length>N.length)return;let r=[],i=new Set;for(let e of t.groups){let t=P(e),n=I(t),a=N.find(e=>e===t.kind);if(!n||!a||i.has(a))return;i.add(a),r.push({kind:a,...n})}let a=P(t.expiring),o=F(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 L(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 it(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=L(i,t);r.trim()&&e&&(n[r]=e)}return n}function at(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=L(r,t);typeof e==`string`&&e.trim()&&i&&(n[e]=i)}return n}function ot(e){return e?.observed===!0&&typeof e.updatedAt==`number`?e.updatedAt:void 0}var R=e=>typeof e==`number`&&Number.isFinite(e)?e:void 0,st=e=>{let t=R(e);if(t===void 0)return;let n=t>1e10?t:t*1e3;return Number.isFinite(new Date(n).getTime())?t:void 0};function z(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`||R(t.percent)===void 0?[]:[{label:t.label,percent:t.percent,...R(t.resetAt)===void 0?{}:{resetAt:t.resetAt},...typeof t.modelId==`string`&&t.modelId.length<=128?{modelId:t.modelId}:{}}]}):[],i=n.creditsUsd&&typeof n.creditsUsd==`object`&&!Array.isArray(n.creditsUsd)?n.creditsUsd:null,a=R(i?.used),o=R(i?.limit),s=R(i?.remaining),c=R(i?.percent),l=st(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=rt(n.workbuddyCredits),f={...d?{workbuddyCredits:d}:{},...R(n.fiveHourPercent)===void 0?{}:{fiveHourPercent:n.fiveHourPercent},...R(n.fiveHourResetAt)===void 0?{}:{fiveHourResetAt:n.fiveHourResetAt},...R(n.weeklyPercent)===void 0?{}:{weeklyPercent:n.weeklyPercent},...R(n.weeklyResetAt)===void 0?{}:{weeklyResetAt:n.weeklyResetAt},...R(n.monthlyPercent)===void 0?{}:{monthlyPercent:n.monthlyPercent},...R(n.monthlyResetAt)===void 0?{}:{monthlyResetAt:n.monthlyResetAt},...r.length>0?{customWindows:r}:{},...u?{creditsUsd:u}:{},updatedAt:R(n.updatedAt)??t??Date.now()};return f.fiveHourPercent!==void 0||f.weeklyPercent!==void 0||f.monthlyPercent!==void 0||(f.customWindows?.length??0)>0||f.creditsUsd!==void 0||f.workbuddyCredits!==void 0?f:null}function B(e){return z(e?.quota,e?.updatedAt)}function ct(e){if(!e)return;if(e.aggregation===void 0)return e;let t=H(e)?.currentAccount?.quota??null;return{...e,aggregation:void 0,quota:t,updatedAt:t?.updatedAt}}function V(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e,n=R(t.usedPercent);if(n!==void 0)return{usedPercent:n,...typeof t.incomplete==`boolean`?{incomplete:t.incomplete}:{},...R(t.excludedAccounts)===void 0?{}:{excludedAccounts:t.excludedAccounts},...R(t.nextRecoveryAt)===void 0?{}:{nextRecoveryAt:t.nextRecoveryAt},...R(t.nextRecoveryPercent)===void 0?{}:{nextRecoveryPercent:t.nextRecoveryPercent}}}function H(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=R(n.excludedAccounts),i=R(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=V(t);return typeof t.label==`string`&&n?[{label:t.label,...n}]:[]}):[],s=V(n.fiveHour),c=V(n.weekly),l=V(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:R(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:z(a.quota)}}:{}}}function lt(e){if(!e?.trim())return``;let[t,n]=e.split(`:`,2);return n?`${t} · ${n.replace(/-/g,` `)}`:e}function ut(e,t){let n=j(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 dt(e,t){if(C(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 ft(e){let t=j(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 U({name:t,adapter:n,baseUrl:i,cls:a}){let o=e(),s=Ne(t,{adapter:n,baseUrl:i}),c=Le(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)(pt,{name:t,label:x(t,o)})})}function pt({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 mt({item:t,selected:n,tabbable:i,modelCount:a,isDefault:o,showConfigId:s,onClick:c,onFocus:l}){let u=e(),d=k(t),f=M(t),p=ut(t,u),m=x(t.name,u),h=s?`${m} (${t.name})`:m,ee=`${o?u(`pws.rail.suffixDefault`):``}${f?u(`pws.rail.suffixLocal`):d?u(`pws.rail.suffixFree`):``}`,te=a!==void 0&&a>0?a===1?u(`pws.modelCountOne`):u(`pws.modelCount`,{count:a}):``,g=[s?t.name:``,te].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:ee}),title:h,onFocus:l,children:[(0,r.jsx)(U,{name:t.name,adapter:t.adapter,baseUrl:t.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:g||void 0,children:g||`\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)(_,{width:17,height:17,"aria-hidden":`true`})}),(0,r.jsx)(`span`,{className:ft(t),title:p,"aria-hidden":`true`})]})]})}var ht=1e10;function W(e){return e<ht?e*1e3:e}function gt(e,t){return typeof e==`number`&&Number.isFinite(e)&&e>0&&W(e)<=t}function _t(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 W(r)>t}function vt(e){return{fiveHourAvailable:e?.shortWindowSeconds===18e3&&typeof e.shortResetAt==`number`,weeklyAvailable:typeof e?.weeklyResetAt==`number`}}function G(e){let t=e?.trim().toLowerCase();return t===`go`||t===`free`}function yt(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 G(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 bt(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=(G(t)?[e.monthlyPercent]:[e.weeklyPercent,e.monthlyPercent]).filter(r);if(a.length===0)return _t({...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)&&!gt(e.fiveHourResetAt??e.shortResetAt,n)?[...a,i]:a;return o.length?Math.max(...o):null}function xt(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 K(e){return Array.isArray(e)&&e.length<=100&&e.every(e=>typeof e==`string`)?JSON.stringify([...new Set(e)].sort()):void 0}function St(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&&K(o.hiddenProviders)===K(t.hiddenProviders)&&(t.models===null?o.models===null:K(o.models)===K(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 Ct={6:15,24:60,72:180,168:360};function wt(e){return Ct[e]}function Tt(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 Et(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 Dt(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 Ot(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 kt(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 At(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`],jt=640,Mt=160,J=28;function Nt(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 Pt(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 Ft({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=Nt(e,t),u=Pt(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:kt(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)):At(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 ${jt} ${Mt}`,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:Tt(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 It(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 Lt(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 Rt(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 zt(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 Bt(e,t,n){let r=X(e),i=r.accounts??r.keys;if(!Array.isArray(i))throw Error(`Invalid account roster`);return i.map((e,i)=>{let a=X(e);if(typeof a.id!=`string`)throw Error(`Invalid account identifier`);let o=t===`oauth`?void 0:typeof a.email==`string`?Vt(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:X(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,...Rt(a,d),exhausted:c!==null&&zt(X(a.quota),l),status:typeof X(a.health).status==`string`?X(a.health).status:void 0,quotaFailure:typeof a.quotaFailure==`string`?a.quotaFailure:void 0,quota:yt(c,l)}})}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 Vt(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 Ht(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 Ut(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,modelId:e.modelId,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 Wt(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 Gt(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 Kt(e,n){let r=t(2e4),i=()=>r.controller.abort();n.aborted&&i(),n.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(),n.removeEventListener(`abort`,i)}}function qt(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 Jt(e){return Q(e)?`${Math.floor(e)}%`:`-`}var Yt=[`quota.weeklyLimit`,`quota.monthlyLimit`,`quota.fiveHourLimit`];function Xt(e){let t=Ut(e).map(e=>{let t=Q(e.percent)?e.percent:void 0,n=Z(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}:{},...t===void 0?{}:{percent:t},...n===null?{}:{resetAt:n},severity:r===void 0?$(t):`normal`}}),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)})}let r=new Set;return t.map(e=>{let t=e.id,n=1;for(;r.has(t);)t=`${e.id}#${n++}`;return r.add(t),t===e.id?e:{...e,id:t}})}function Zt(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 Yt){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]}function Qt(e,t){let n=[];for(let[r,i]of Object.entries(e)){let e=B(i);if(!e)continue;let a=Xt(e),o=Zt(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 $,ct as A,ae as At,et as B,Se as Bt,yt as C,u as Ct,dt as D,d as Dt,mt as E,Te as Et,M as F,o as Ft,Ze as G,k as H,ee as Ht,nt as I,Oe as It,He as J,We as K,$e as L,_ as Lt,it as M,_e as Mt,at as N,ne as Nt,B as O,ie as Ot,ot as P,de as Pt,ze as Q,j as R,we as Rt,bt as S,xe as St,U as T,Ee as Tt,Xe as U,O as V,oe as Vt,A as W,x as X,Be as Y,Re as Z,St as _,re as _t,Kt as a,h as at,Et as b,Ce as bt,Gt as c,me as ct,It as d,Ae as dt,le as et,Ut as f,ge as ft,Ot as g,m as gt,wt as h,ke as ht,Lt as i,s as it,lt as j,te as jt,H as k,ce as kt,Bt as l,ve as lt,Ft as m,a as mt,Jt as n,fe as nt,Wt as o,he as ot,Ht as p,De as pt,C as q,$ as r,c as rt,Y as s,be as st,Qt as t,pe as tt,qt as u,se as ut,xt as v,ue as vt,vt as w,g as wt,Dt as x,l as xt,Tt as y,ye as yt,Qe as z,f 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-ClZ_zZ77.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-CAxjGWkm.js"></script>
|
|
53
|
+
<link rel="stylesheet" crossorigin href="/assets/index-bnUWypyz.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.
|
|
3
|
+
"version": "2.99.0-preview.20261108",
|
|
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",
|
|
@@ -258,7 +258,7 @@ export interface StreamParseState {
|
|
|
258
258
|
translatorBudget?: TranslatorBudget;
|
|
259
259
|
/** A capture bridge may impose a tighter ceiling on distinct calls and retained blocks. */
|
|
260
260
|
maxToolBlockStarts?: number;
|
|
261
|
-
/** Qoder's
|
|
261
|
+
/** Qoder's accepted CLI names to selected wire identities; validates partial starts and alias deduplication. */
|
|
262
262
|
toolBridgeNames?: ReadonlyMap<string, string>;
|
|
263
263
|
/** Set before an over-limit block can be allocated or emitted. */
|
|
264
264
|
toolCallLimitExceeded?: boolean;
|
|
@@ -464,7 +464,10 @@ function resolveToolBlockKey(state: StreamParseState, event: StreamMessage): num
|
|
|
464
464
|
function isEmittedToolCallRepeat(state: StreamParseState, id: string, name: string, argumentsJson: string): boolean {
|
|
465
465
|
const previous = state.emittedToolCalls?.get(id);
|
|
466
466
|
if (!previous) return false;
|
|
467
|
-
|
|
467
|
+
const selectedName = state.toolBridgeNames?.get(name);
|
|
468
|
+
const sameName = previous.name === name
|
|
469
|
+
|| (selectedName !== undefined && selectedName === state.toolBridgeNames?.get(previous.name));
|
|
470
|
+
if (!sameName || previous.argumentsJson !== argumentsJson) {
|
|
468
471
|
throw new CodingAgentProtocolError("Coding-agent CLI reused a completed tool call ID with conflicting name or input.");
|
|
469
472
|
}
|
|
470
473
|
return true;
|
|
@@ -594,7 +597,9 @@ function mapRawStreamEvent(event: StreamMessage, state: StreamParseState): Adapt
|
|
|
594
597
|
throw new CodingAgentProtocolError("Coding-agent CLI started a tool block with an invalid or undeclared name.");
|
|
595
598
|
}
|
|
596
599
|
const previous = state.emittedToolCalls?.get(id);
|
|
597
|
-
|
|
600
|
+
const selectedName = state.toolBridgeNames?.get(name);
|
|
601
|
+
if (previous && previous.name !== name
|
|
602
|
+
&& (selectedName === undefined || selectedName !== state.toolBridgeNames?.get(previous.name))) {
|
|
598
603
|
throw new CodingAgentProtocolError("Coding-agent CLI reused a completed tool call ID with conflicting name or input.");
|
|
599
604
|
}
|
|
600
605
|
const distinctIds = state.completeAssistantToolUse ? (state.partialToolCallIds ??= new Set<string>()) : undefined;
|
|
@@ -153,7 +153,7 @@ export interface CodingAgentToolBridgeInput {
|
|
|
153
153
|
tools: ReadonlyArray<{ name: string; description: string; inputSchema: Record<string, unknown> }>;
|
|
154
154
|
/** CLI-emitted tool name (`mcp__<server>__<tool>`) to the request's wire tool name. */
|
|
155
155
|
emittedNameMap: Map<string, string>;
|
|
156
|
-
/**
|
|
156
|
+
/** A CLI may emit an exact selected wire name instead of its MCP transport name.
|
|
157
157
|
* These aliases are output-only: they never enter the CLI's --allowedTools list. */
|
|
158
158
|
acceptWireToolNames?: boolean;
|
|
159
159
|
/** Tool_use blocks accepted in one assistant message. */
|
|
@@ -481,7 +481,11 @@ export async function runCodingAgentTurn(input: CodingAgentTurnInput): Promise<v
|
|
|
481
481
|
strictToolBlockCapture: Boolean(toolBridge),
|
|
482
482
|
partialToolCallIds: toolBridge ? new Set<string>() : undefined,
|
|
483
483
|
completeAssistantToolUse: toolBridge?.completeAssistantToolUse,
|
|
484
|
-
toolBridgeNames: toolBridge?.completeAssistantToolUse
|
|
484
|
+
toolBridgeNames: toolBridge?.completeAssistantToolUse
|
|
485
|
+
? profile.family === "qoder" && wireToolNames
|
|
486
|
+
? new Map([...toolBridge.emittedNameMap, ...Array.from(wireToolNames, name => [name, name] as const)])
|
|
487
|
+
: toolBridge.emittedNameMap
|
|
488
|
+
: undefined,
|
|
485
489
|
};
|
|
486
490
|
const toolTurnCompletionSignal = toolBridge?.toolTurnCompletionSignal ?? "message_stop";
|
|
487
491
|
const sawSelectedToolTurnStop = (): boolean => toolTurnCompletionSignal === "assistant_tool_use_stop"
|
|
@@ -437,17 +437,20 @@ async function*ndjson(response: Response, budget: TranslatorBudget): AsyncGenera
|
|
|
437
437
|
try {
|
|
438
438
|
for (;;) {
|
|
439
439
|
const { value, done } = await reader.read();
|
|
440
|
-
const
|
|
441
|
-
|
|
440
|
+
const decoded = decoder.decode(value, { stream: !done });
|
|
441
|
+
// TextDecoder emits complete code points, so fragment UTF-8 sizes are additive.
|
|
442
|
+
const nextBytes = bufferBytes + encoder.encode(decoded).byteLength;
|
|
442
443
|
resizeBuffer(nextBytes);
|
|
443
|
-
buffer
|
|
444
|
-
|
|
444
|
+
buffer += decoded;
|
|
445
|
+
// The retained suffix has no newline; only new text can complete a record.
|
|
446
|
+
const hasNewline = decoded.includes("\n");
|
|
447
|
+
let newline = hasNewline ? buffer.indexOf("\n") : -1;
|
|
445
448
|
while (newline >= 0) {
|
|
446
449
|
const line = buffer.slice(0, newline).trim(); buffer = buffer.slice(newline + 1);
|
|
447
450
|
if (line) yield* decodeEventLine(line);
|
|
448
451
|
newline = buffer.indexOf("\n");
|
|
449
452
|
}
|
|
450
|
-
resizeBuffer(encoder.encode(buffer).byteLength);
|
|
453
|
+
if (hasNewline) resizeBuffer(encoder.encode(buffer).byteLength);
|
|
451
454
|
if (done) break;
|
|
452
455
|
}
|
|
453
456
|
const final = buffer.trim();
|
package/src/adapters/devin.ts
CHANGED
|
@@ -692,6 +692,11 @@ export function mapDevinToolCallStartForTests(
|
|
|
692
692
|
return mapDevinToolCallStart(id, name, buildDevinReturnedToolNameMap(tools));
|
|
693
693
|
}
|
|
694
694
|
|
|
695
|
+
/**
|
|
696
|
+
* Create the native Devin adapter with bounded per-instance cascade-ID state.
|
|
697
|
+
* The configured provider ID selects the stored tenant slot; runTurn translates
|
|
698
|
+
* native chat events and marks turn signatures for downstream output ownership.
|
|
699
|
+
*/
|
|
695
700
|
export function createDevinAdapter(
|
|
696
701
|
provider: OcxProviderConfig,
|
|
697
702
|
context: { providerId?: string } = {},
|
|
@@ -730,6 +735,11 @@ export function createDevinAdapter(
|
|
|
730
735
|
};
|
|
731
736
|
},
|
|
732
737
|
|
|
738
|
+
/**
|
|
739
|
+
* Execute one native chat turn through admitted sends and emit adapter events.
|
|
740
|
+
* Keeps signed continuation and optional unsigned retries request-scoped; late
|
|
741
|
+
* provider attestations are marked afterOutput for downstream replay ownership.
|
|
742
|
+
*/
|
|
733
743
|
async runTurn(parsed: OcxParsedRequest, incoming: IncomingMeta, emit: (event: AdapterEvent) => void) {
|
|
734
744
|
if (incoming.abortSignal?.aborted) {
|
|
735
745
|
emit({ type: "error", message: DEVIN_CLIENT_CLOSED_MESSAGE, status: 499, retryable: false });
|
|
@@ -937,7 +947,7 @@ export function createDevinAdapter(
|
|
|
937
947
|
if (event.kind === "reasoning_signature") {
|
|
938
948
|
// Carried back out so the next turn can replay it in the prompt's
|
|
939
949
|
// signature field; an unsigned replay is what the service ignores.
|
|
940
|
-
emit({ type: "thinking_signature", signature: encodeDevinSignature(event.signature, event.signatureType) });
|
|
950
|
+
emit({ type: "thinking_signature", signature: encodeDevinSignature(event.signature, event.signatureType), afterOutput: true });
|
|
941
951
|
continue;
|
|
942
952
|
}
|
|
943
953
|
if (event.kind === "tool_call_start") {
|
|
@@ -385,7 +385,7 @@ async function* parseKiroAttemptEvents(
|
|
|
385
385
|
};
|
|
386
386
|
}
|
|
387
387
|
|
|
388
|
-
let open: { id: string; name: string; chunks: string[]; completion: boolean } | null = null;
|
|
388
|
+
let open: { id: string; name: string; chunks: string[]; inputBytes: number; completion: boolean } | null = null;
|
|
389
389
|
let openCallId: string | undefined;
|
|
390
390
|
const closeOpenCall = () => {
|
|
391
391
|
if (!openCallId) return;
|
|
@@ -571,8 +571,8 @@ async function* parseKiroAttemptEvents(
|
|
|
571
571
|
const beginTool = (
|
|
572
572
|
id: string,
|
|
573
573
|
name: string,
|
|
574
|
-
): { tool?: { id: string; name: string; chunks: string[]; completion: boolean }; terminal?: AdapterEvent } => {
|
|
575
|
-
const next = { id, name, chunks: [], completion: false };
|
|
574
|
+
): { tool?: { id: string; name: string; chunks: string[]; inputBytes: number; completion: boolean }; terminal?: AdapterEvent } => {
|
|
575
|
+
const next = { id, name, chunks: [], inputBytes: 0, completion: false };
|
|
576
576
|
const terminal = classifyTool(next);
|
|
577
577
|
return terminal ? { terminal } : { tool: next };
|
|
578
578
|
};
|
|
@@ -831,12 +831,13 @@ async function* parseKiroAttemptEvents(
|
|
|
831
831
|
}
|
|
832
832
|
}
|
|
833
833
|
if (open && ev.input !== undefined) {
|
|
834
|
-
const previousCallBytes = open.
|
|
834
|
+
const previousCallBytes = open.inputBytes;
|
|
835
835
|
const nextCallBytes = previousCallBytes + Buffer.byteLength(ev.input);
|
|
836
836
|
const callReservation = budget.reserveTransient(nextCallBytes, { kind: "tool_args", callId: open.id });
|
|
837
837
|
open.chunks.push(ev.input);
|
|
838
838
|
callReservation.commitRetained();
|
|
839
839
|
budget.releaseRetained(previousCallBytes, { kind: "tool_args", callId: open.id });
|
|
840
|
+
open.inputBytes = nextCallBytes;
|
|
840
841
|
const nextOutputCharsBytes = appendedUtf8Bytes(outputChars, outputCharsBytes, ev.input);
|
|
841
842
|
const toolOutputReservation = budget.reserveTransient(nextOutputCharsBytes, { kind: "retained_collectors" });
|
|
842
843
|
outputChars += ev.input;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { isCanonicalMistralChat } from "../../providers/mistral-transport";
|
|
2
|
+
import { configuredReasoningEfforts, resolveEffortAtOrBelow } from "../../reasoning-effort";
|
|
3
|
+
import type { OcxProviderConfig } from "../../types";
|
|
4
|
+
|
|
5
|
+
const MISTRAL_CHAT_POLICY = {
|
|
6
|
+
rename: { max_completion_tokens: "max_tokens" },
|
|
7
|
+
omit: ["user", "store", "thinking", "include_reasoning", "reasoning", "top_k"],
|
|
8
|
+
} as const;
|
|
9
|
+
|
|
10
|
+
/** Final wire projection shared by native and translated Chat; caller objects are not mutated. */
|
|
11
|
+
export function applyChatDestinationPolicy(body: Record<string, unknown>, provider: OcxProviderConfig): void {
|
|
12
|
+
if (!isCanonicalMistralChat(provider)) return;
|
|
13
|
+
for (const [source, target] of Object.entries(MISTRAL_CHAT_POLICY.rename)) {
|
|
14
|
+
if ((body[target] === undefined || body[target] === null) && body[source] !== undefined) body[target] = body[source];
|
|
15
|
+
delete body[source];
|
|
16
|
+
}
|
|
17
|
+
for (const field of MISTRAL_CHAT_POLICY.omit) delete body[field];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Native Chat normally preserves effort spelling; Mistral requires its declared model ladder. */
|
|
21
|
+
export function mistralNativeChatEffort(provider: OcxProviderConfig, modelId: string, effort: string): string | undefined {
|
|
22
|
+
if (!isCanonicalMistralChat(provider) || effort === "none") return effort;
|
|
23
|
+
const supported = configuredReasoningEfforts(provider, modelId);
|
|
24
|
+
return supported === undefined ? effort : resolveEffortAtOrBelow(effort, supported);
|
|
25
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { isCanonicalMistralChat } from "../../providers/mistral-transport";
|
|
2
|
+
import type { OcxProviderConfig } from "../../types";
|
|
3
|
+
import { chatContentEvents } from "./response-events";
|
|
4
|
+
|
|
5
|
+
type RecordValue = Record<string, unknown>;
|
|
6
|
+
const isRecord = (value: unknown): value is RecordValue => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
7
|
+
type Destination = Pick<OcxProviderConfig, "adapter" | "authMode" | "baseUrl">;
|
|
8
|
+
|
|
9
|
+
/** Normalize both Chat deltas and completion messages with the translated adapter's typed parser. */
|
|
10
|
+
export function normalizeNativeChatContent(value: RecordValue, provider?: Destination): RecordValue {
|
|
11
|
+
if (!provider || !isCanonicalMistralChat(provider) || !Array.isArray(value.choices)) return value;
|
|
12
|
+
let invalid = false;
|
|
13
|
+
const choices = value.choices.map(choice => {
|
|
14
|
+
if (!isRecord(choice)) return choice;
|
|
15
|
+
const out = { ...choice };
|
|
16
|
+
for (const field of ["delta", "message"] as const) {
|
|
17
|
+
const message = choice[field];
|
|
18
|
+
if (!isRecord(message) || !Array.isArray(message.content)) continue;
|
|
19
|
+
const events = chatContentEvents(message.content, provider.baseUrl);
|
|
20
|
+
if (events.some(event => event.type === "error")) { invalid = true; continue; }
|
|
21
|
+
const text = events.filter(event => event.type === "text_delta").map(event => event.text).join("");
|
|
22
|
+
const reasoning = events.filter(event => event.type === "reasoning_raw_delta").map(event => event.text).join("");
|
|
23
|
+
out[field] = { ...message, content: text,
|
|
24
|
+
...(reasoning ? { reasoning_content: (typeof message.reasoning_content === "string" ? message.reasoning_content : "") + reasoning } : {}),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
return out;
|
|
28
|
+
});
|
|
29
|
+
return invalid
|
|
30
|
+
? { error: { status: 502, type: "upstream_error", message: "unsupported Mistral content block" } }
|
|
31
|
+
: { ...value, choices };
|
|
32
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { applyChatDestinationPolicy, mistralNativeChatEffort } from "./destination-policy";
|
|
1
2
|
import { protectGlmSummaryBudget } from "./summary-budget";
|
|
2
3
|
import { openAIChatTransport, stripBracketedModelSuffix } from "./wire";
|
|
3
4
|
import type { AdapterRequest } from "../base";
|
|
@@ -16,7 +17,8 @@ import { modelInList, type OcxProviderConfig } from "../../types";
|
|
|
16
17
|
import { mapReasoningEffort, modelRecordValue } from "../../reasoning-effort";
|
|
17
18
|
import { resolveReasoningCapabilities } from "../../providers/reasoning-capabilities";
|
|
18
19
|
import { chatParallelToolCallsWireValue } from "./parallel-tool-calls";
|
|
19
|
-
import { applyExplicitChatReasoningWirePolicy, declaresIndependentChatReasoningControls
|
|
20
|
+
import { applyExplicitChatReasoningWirePolicy, declaresIndependentChatReasoningControls,
|
|
21
|
+
nativeChatUltraWireEffort } from "./reasoning-wire";
|
|
20
22
|
import { declaresThinkingToggleWire, reasoningControlsAreUnsupported } from "../reasoning-controls";
|
|
21
23
|
import { planNativeChatReasoningReplay } from "./reasoning-replay";
|
|
22
24
|
import type { OcxReasoningReplayScopeRef } from "../../types";
|
|
@@ -101,6 +103,16 @@ export function buildOpenAIChatPassthroughRequest(
|
|
|
101
103
|
if (reasoningDisabled) {
|
|
102
104
|
delete body.reasoning_effort;
|
|
103
105
|
}
|
|
106
|
+
if (body.reasoning_effort === "ultra") {
|
|
107
|
+
const folded = nativeChatUltraWireEffort(provider, modelId);
|
|
108
|
+
if (folded === undefined) delete body.reasoning_effort;
|
|
109
|
+
else body.reasoning_effort = folded;
|
|
110
|
+
}
|
|
111
|
+
if (typeof body.reasoning_effort === "string") {
|
|
112
|
+
const effort = mistralNativeChatEffort(provider, modelId, body.reasoning_effort);
|
|
113
|
+
if (effort === undefined) delete body.reasoning_effort;
|
|
114
|
+
else body.reasoning_effort = effort;
|
|
115
|
+
}
|
|
104
116
|
const hasTools = Array.isArray(rawBody.tools) && rawBody.tools.length > 0;
|
|
105
117
|
const requestedEffort = typeof body.reasoning_effort === "string" ? body.reasoning_effort : undefined;
|
|
106
118
|
const explicitThinkingEnabled = rawBody.reasoning !== null && typeof rawBody.reasoning === "object"
|
|
@@ -190,6 +202,7 @@ export function buildOpenAIChatPassthroughRequest(
|
|
|
190
202
|
body.stream_options = rawBody.stream_options;
|
|
191
203
|
}
|
|
192
204
|
|
|
205
|
+
applyChatDestinationPolicy(body, provider);
|
|
193
206
|
const transformedBody = () => applyGithubCopilotContextTier(body, provider, modelId, providerName);
|
|
194
207
|
// The binding constraint is the final size base + net, so a shrinking replay may legitimately
|
|
195
208
|
// measure a base above the cap; only a base above max - net makes the result unserializable.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { resolveThinkingEnabled } from "../../clients/reasoning-controls";
|
|
2
2
|
import { declaredModelCapabilities, resolveReasoningCapabilities } from "../../providers/reasoning-capabilities";
|
|
3
3
|
import { registryEntryForProviderDestination } from "../../providers/registry";
|
|
4
|
+
import { configuredReasoningEfforts, isDeclaredReasoningEffort, isReasoningEffortOmitted, mapReasoningEffort, reasoningEffortMapFor, resolveEffortAtOrBelow } from "../../reasoning-effort";
|
|
4
5
|
import { modelInList, type OcxProviderConfig } from "../../types";
|
|
5
6
|
import type { AdapterRequest } from "../base";
|
|
6
7
|
import { declaresThinkingToggleWire, reasoningControlsAreUnsupported } from "../reasoning-controls";
|
|
@@ -29,6 +30,29 @@ export function declaresIndependentChatReasoningControls(provider: OcxProviderCo
|
|
|
29
30
|
.some(axis => typeof (explicit?.[axis] ?? registry?.[axis]) === "boolean");
|
|
30
31
|
}
|
|
31
32
|
|
|
33
|
+
/**
|
|
34
|
+
* Wire value for a native Chat caller's `ultra`. It is a Codex picker level, not an upstream
|
|
35
|
+
* Chat value: codex-rs folds it to `max` before every provider request and the translated path
|
|
36
|
+
* does the same in `mapReasoningEffort`, but OpenCode and Kilo send it verbatim, and Mistral
|
|
37
|
+
* answers it with HTTP 422 (#8254). The fold lands on `max`, clamped at or below it to the
|
|
38
|
+
* model's declared ladder (Mistral Large 4 tops out at `high`). A declared ladder that lists
|
|
39
|
+
* `ultra` itself is the provider's own claim and keeps it. Like a pin or cap rewrite, the folded
|
|
40
|
+
* value goes through the provider's wire alias map; `undefined` means omit the field.
|
|
41
|
+
* A thinking-toggle wire is the exception: its map holds thinking discriminators, which
|
|
42
|
+
* `applyExplicitChatReasoningWirePolicy` resolves itself, so it receives the plain strength.
|
|
43
|
+
*/
|
|
44
|
+
export function nativeChatUltraWireEffort(provider: OcxProviderConfig, modelId: string): string | undefined {
|
|
45
|
+
const ladder = configuredReasoningEfforts(provider, modelId);
|
|
46
|
+
if (ladder?.includes("ultra")) return "ultra";
|
|
47
|
+
if (declaresThinkingToggleWire(provider, modelId)) {
|
|
48
|
+
// Keep the original alias for the independent policy to omit effort and select thinking.
|
|
49
|
+
if (declaresIndependentChatReasoningEffort(provider, modelId)
|
|
50
|
+
&& isReasoningEffortOmitted(reasoningEffortMapFor(provider, modelId)?.max)) return "max";
|
|
51
|
+
return ladder ? resolveEffortAtOrBelow("max", ladder) ?? "max" : "max";
|
|
52
|
+
}
|
|
53
|
+
return mapReasoningEffort(provider, modelId, "ultra");
|
|
54
|
+
}
|
|
55
|
+
|
|
32
56
|
/**
|
|
33
57
|
* Apply provider-declared reasoning wire policy after the effective provider is resolved.
|
|
34
58
|
* Unset declarations are a no-op so native Chat keeps forwarding the caller's raw field.
|
|
@@ -81,8 +105,20 @@ export function applyExplicitChatReasoningWirePolicy(options: {
|
|
|
81
105
|
if (capabilities.supportsThinkingToggle === false) delete body.thinking;
|
|
82
106
|
return { handled: true };
|
|
83
107
|
}
|
|
108
|
+
const omitIndependentEffort = toggleWire && declaresIndependentChatReasoningEffort(provider, modelId)
|
|
109
|
+
&& requestedStrength !== undefined
|
|
110
|
+
&& isReasoningEffortOmitted(reasoningEffortMapFor(provider, modelId)?.[requestedStrength]);
|
|
111
|
+
// A native caller's ultra stays on the wire when the provider explicitly advertises it.
|
|
112
|
+
// In that case the max alias belongs to a different value, even though the shared mapper folds ultra.
|
|
113
|
+
if (omitIndependentEffort && !(requestedEffort === "ultra" && body.reasoning_effort === "ultra")) {
|
|
114
|
+
delete body.reasoning_effort;
|
|
115
|
+
}
|
|
84
116
|
const resolvedThinkingEnabled = toggleWire && !toggleDisabled
|
|
85
|
-
? resolveThinkingEnabled(provider, modelId, {
|
|
117
|
+
? resolveThinkingEnabled(provider, modelId, {
|
|
118
|
+
thinkingEnabled: thinkingEnabled ?? (omitIndependentEffort && requestedStrength !== undefined && isDeclaredReasoningEffort(requestedStrength)
|
|
119
|
+
? requestedStrength !== "none" : undefined),
|
|
120
|
+
reasoning: requestedEffort,
|
|
121
|
+
})
|
|
86
122
|
: undefined;
|
|
87
123
|
if (toggleDisabled) {
|
|
88
124
|
delete body.thinking;
|
|
@@ -147,6 +183,11 @@ export function applyExplicitChatReasoningWirePolicy(options: {
|
|
|
147
183
|
|
|
148
184
|
const nativeOpenAI = isNativeOpenAIChatTarget(provider);
|
|
149
185
|
if (requestedEffort === "none") {
|
|
186
|
+
if (omitIndependentEffort) {
|
|
187
|
+
delete body.reasoning_effort;
|
|
188
|
+
delete body.reasoning;
|
|
189
|
+
return { handled: true };
|
|
190
|
+
}
|
|
150
191
|
if (nativeOpenAI) {
|
|
151
192
|
delete body.reasoning;
|
|
152
193
|
body.reasoning_effort = "none";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { applyChatDestinationPolicy } from "./openai-chat/destination-policy";
|
|
1
2
|
import { withRequiredChatToolResult } from "./openai-chat/required-tool-result";
|
|
2
3
|
import { hasShrinkableOpenAIChatImages, normalizeOpenAIChatImages } from "./openai-chat-images";
|
|
3
4
|
import { protectGlmSummaryBudget, resolveMaxTokens } from "./openai-chat/summary-budget";
|
|
@@ -96,7 +97,6 @@ export function createOpenAIChatAdapter(provider: OcxProviderConfig): ProviderAd
|
|
|
96
97
|
name: "openai-chat",
|
|
97
98
|
|
|
98
99
|
formatErrorBody: formatOpenAIChatErrorBody,
|
|
99
|
-
|
|
100
100
|
buildRequest(parsed: OcxParsedRequest, incoming?: IncomingMeta) {
|
|
101
101
|
lastRequestedModelId = parsed.modelId;
|
|
102
102
|
const completedToolBlocks = incoming?.completedToolBlocks === true;
|
|
@@ -236,7 +236,7 @@ export function createOpenAIChatAdapter(provider: OcxProviderConfig): ProviderAd
|
|
|
236
236
|
if (parallelToolCalls !== undefined) body.parallel_tool_calls = parallelToolCalls;
|
|
237
237
|
}
|
|
238
238
|
if (parsed.stream) body.stream_options = { include_usage: true };
|
|
239
|
-
|
|
239
|
+
applyChatDestinationPolicy(body, provider);
|
|
240
240
|
const bodyJson = JSON.stringify(applyGithubCopilotContextTier(body, provider, parsed.modelId, incoming?.providerName));
|
|
241
241
|
const tierLog = createAdapterTierMetadata(
|
|
242
242
|
parsed.options.tierObservation,
|
|
@@ -266,6 +266,7 @@ export function guardQoderScaffolding(emit: (event: AdapterEvent) => void): (eve
|
|
|
266
266
|
};
|
|
267
267
|
}
|
|
268
268
|
|
|
269
|
+
/** Build the regional Qoder adapter with a request-scoped capture-only tool catalog. */
|
|
269
270
|
export function createQoderAdapter(provider: OcxProviderConfig, deps: QoderAdapterDeps = {}): ProviderAdapter {
|
|
270
271
|
return {
|
|
271
272
|
name: "qoder",
|
|
@@ -287,6 +288,12 @@ export function createQoderAdapter(provider: OcxProviderConfig, deps: QoderAdapt
|
|
|
287
288
|
let catalog: ReturnType<typeof buildCodingAgentToolCatalog>;
|
|
288
289
|
try {
|
|
289
290
|
catalog = buildCodingAgentToolCatalog(parsed, QODER_MCP_SERVER_NAME);
|
|
291
|
+
for (const wireName of catalog.emittedNameMap.values()) {
|
|
292
|
+
const restored = catalog.emittedNameMap.get(wireName);
|
|
293
|
+
if (restored !== undefined && restored !== wireName) {
|
|
294
|
+
throw new CodingAgentToolCatalogError("ambiguous selected tool identity");
|
|
295
|
+
}
|
|
296
|
+
}
|
|
290
297
|
} catch (error) {
|
|
291
298
|
if (!(error instanceof CodingAgentToolCatalogError)) throw error;
|
|
292
299
|
emit({
|
|
@@ -305,6 +312,8 @@ export function createQoderAdapter(provider: OcxProviderConfig, deps: QoderAdapt
|
|
|
305
312
|
serverModulePath: QODER_MCP_SERVER_PATH,
|
|
306
313
|
tools: catalog.tools,
|
|
307
314
|
emittedNameMap: catalog.emittedNameMap,
|
|
315
|
+
// Qoder can mix exact client wire names with MCP names in one reply.
|
|
316
|
+
acceptWireToolNames: true,
|
|
308
317
|
maxTurnToolCalls: MAX_TOOL_BLOCK_STARTS,
|
|
309
318
|
projectHistoryToolNames: true,
|
|
310
319
|
completeAssistantToolUse: true,
|