@bitkyc08/opencodex 2.94.0 → 2.96.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/gui/dist/assets/App-B4j-Txmb.css +1 -0
- package/gui/dist/assets/App-bwugJRKn.js +58 -0
- package/gui/dist/assets/{Tray-CZatQdoF.js → Tray-BOPQyDbH.js} +1 -1
- package/gui/dist/assets/index-ebuVUtB7.js +94 -0
- package/gui/dist/assets/quota-summary-6HsrHQAy.js +1 -0
- package/gui/dist/index.html +1 -1
- package/package.json +1 -1
- package/src/adapters/anthropic.ts +10 -3
- package/src/adapters/command-code-project-context.ts +3 -3
- package/src/adapters/kiro/adapter.ts +4 -1
- package/src/adapters/kiro/stream.ts +1 -0
- package/src/adapters/kiro-events.ts +1 -0
- package/src/adapters/ollama-native.ts +10 -6
- package/src/adapters/openai-chat/messages.ts +20 -7
- package/src/adapters/openai-chat/passthrough.ts +4 -2
- package/src/adapters/openai-chat/single-system.ts +24 -0
- package/src/adapters/openai-responses/canonical-forward.ts +50 -13
- package/src/adapters/openai-responses/muse-tool-catalog.ts +87 -0
- package/src/adapters/openai-responses/passthrough.ts +45 -11
- package/src/adapters/openai-responses/prompt-cache.ts +3 -1
- package/src/adapters/openai-responses/request-strips.ts +23 -4
- package/src/adapters/openai-responses/tool-output-recovery.ts +21 -8
- package/src/adapters/openai-responses/tool-schema.ts +20 -8
- package/src/adapters/openai-responses/transport.ts +17 -26
- package/src/adapters/opencode-go-additional-tools.ts +39 -6
- package/src/adapters/qoder/adapter.ts +1 -1
- package/src/adapters/qoder/image-input.ts +5 -2
- package/src/adapters/routed-agent-messages.ts +3 -0
- package/src/adapters/xai-web-search.ts +6 -3
- package/src/adapters/zed-additional-tools.ts +7 -7
- package/src/adapters/zed.ts +1 -6
- package/src/advisor/consult.ts +22 -10
- package/src/advisor/runtime.ts +10 -4
- package/src/bridge/max-output-completion.ts +41 -0
- package/src/bridge/response-json.ts +9 -4
- package/src/bridge/sse.ts +13 -2
- package/src/chatgpt/app-server-shim/bundle-trust-policy.ts +5 -0
- package/src/chatgpt/app-server-shim/launcher.ts +40 -6
- package/src/claude/compatibility.ts +5 -1
- package/src/claude/desktop-3p.ts +27 -6
- package/src/claude/desktop-model-visibility.ts +141 -0
- package/src/claude/desktop-remote-store-io.ts +8 -8
- package/src/claude/inbound-content-options.ts +11 -1
- package/src/claude/intercept/proxy-auth.ts +16 -16
- package/src/cli/account-main.ts +3 -2
- package/src/cli/agent.ts +44 -15
- package/src/cli/capabilities-agents-routing.ts +9 -0
- package/src/cli/capabilities-provider-models.ts +7 -0
- package/src/cli/chatgpt-command.ts +1 -1
- package/src/cli/codex-launcher.ts +20 -8
- package/src/cli/codex-shim-autorestore.ts +19 -1
- package/src/cli/dispatch.ts +6 -6
- package/src/cli/doctor.ts +5 -5
- package/src/cli/ensure-desired-integrations.ts +4 -3
- package/src/cli/index.ts +8 -10
- package/src/cli/init.ts +2 -2
- package/src/cli/internal-command.ts +29 -2
- package/src/cli/message-command.ts +2 -1
- package/src/cli/message-mcp-command.ts +29 -0
- package/src/cli/provider-cc-switch-import.ts +185 -0
- package/src/cli/provider.ts +5 -0
- package/src/cli/registry.ts +2 -1
- package/src/cli/restart-scope.ts +2 -2
- package/src/cli/root.ts +6 -6
- package/src/cli/stop-approval.ts +15 -1
- package/src/cli/v2.ts +69 -19
- package/src/client/machine-api.ts +2 -2
- package/src/clients/config-export.ts +14 -3
- package/src/codex/account-cooldown-response.ts +18 -0
- package/src/codex/account-store.ts +1 -0
- package/src/codex/app-server-restart-service.ts +2 -2
- package/src/codex/auth-api/login-flow.ts +2 -2
- package/src/codex/auth-api/pool-quota-probe.ts +2 -2
- package/src/codex/auth-context-provider.ts +15 -0
- package/src/codex/auth-context.ts +14 -23
- package/src/codex/catalog/bundled.ts +10 -3
- package/src/codex/catalog/metadata.ts +4 -5
- package/src/codex/catalog/native-omission.ts +28 -0
- package/src/codex/catalog/native-template.ts +58 -0
- package/src/codex/catalog/parsing.ts +3 -29
- package/src/codex/catalog/provider-models.ts +2 -1
- package/src/codex/catalog/retained-sync.ts +15 -5
- package/src/codex/catalog/write-audit.ts +18 -18
- package/src/codex/cli-install-provenance.ts +46 -45
- package/src/codex/cli-update-artifacts.ts +8 -6
- package/src/codex/cli-update-job-store-windows.ts +99 -27
- package/src/codex/cli-update-job-worker.ts +3 -11
- package/src/codex/cli-update-recovery.ts +54 -8
- package/src/codex/cli-update-selection-gate.ts +74 -4
- package/src/codex/cli-windows-plan-provenance.ts +37 -19
- package/src/codex/codex-home-owner.ts +9 -8
- package/src/codex/convergence.ts +13 -3
- package/src/codex/coordinator-doctor.ts +14 -8
- package/src/codex/desktop-app/handoff.ts +1 -1
- package/src/codex/desktop-app-restart.ts +11 -1
- package/src/codex/exec-boundary.ts +26 -5
- package/src/codex/forward-transport-headers.ts +33 -33
- package/src/codex/history-provider.ts +11 -10
- package/src/codex/inject/bounded-config-reader.ts +14 -13
- package/src/codex/installation-id.ts +72 -0
- package/src/codex/main-account.ts +6 -6
- package/src/codex/native-main-lock-file.ts +13 -12
- package/src/codex/native-residue.ts +18 -14
- package/src/codex/orca-auth-source.ts +8 -7
- package/src/codex/quota-types.ts +5 -0
- package/src/codex/quota.ts +49 -7
- package/src/codex/role-auto-assign.ts +50 -26
- package/src/codex/role-capability.ts +160 -0
- package/src/codex/role-sizing.ts +24 -6
- package/src/codex/routing/cooldown-math.ts +3 -2
- package/src/codex/runtime.ts +43 -3
- package/src/codex/shim-fingerprint.ts +11 -9
- package/src/codex/shim-inspect.ts +3 -2
- package/src/codex/shim-restore-lock.ts +11 -14
- package/src/codex/shim-state-file.ts +22 -14
- package/src/codex/shim-wrapper-write.ts +7 -6
- package/src/codex/shim.ts +25 -2
- package/src/codex/transition-state.ts +5 -4
- package/src/combos/failover.ts +43 -4
- package/src/config/atomic-write.ts +38 -7
- package/src/config/diagnostics.ts +3 -0
- package/src/config/initialize.ts +6 -6
- package/src/config/load-degrade.ts +2 -0
- package/src/config/process-state.ts +23 -5
- package/src/config/salvage.ts +1 -0
- package/src/config/schema/config-schema.ts +29 -1
- package/src/config/schema/leaf-validators.ts +7 -0
- package/src/config/schema/workflow-budget.ts +43 -0
- package/src/config/tracked-runtime-inspection.ts +188 -0
- package/src/generated/compatibility-version.json +380 -244
- package/src/grok/sync.ts +10 -1
- package/src/integrations/aside-profile-context.ts +1 -1
- package/src/integrations/droid-settings.ts +4 -4
- package/src/integrations/hermes-profiles.ts +3 -3
- package/src/lib/bounded-file-read.ts +3 -9
- package/src/lib/bun-runtime-preflight.ts +9 -8
- package/src/lib/file-identity.ts +15 -0
- package/src/lib/local-chat-completion.ts +8 -6
- package/src/lib/local-destinations.ts +32 -3
- package/src/lib/redact-folding.ts +9 -0
- package/src/lib/spend-pool-alias-validation.ts +6 -6
- package/src/lib/state-store-registrations.ts +2 -0
- package/src/lib/test-home-guard.ts +37 -9
- package/src/lib/windows-secret-acl.ts +49 -31
- package/src/lib/workflow-budget-config.ts +39 -0
- package/src/local-credentials/generation.ts +6 -2
- package/src/local-credentials/inventory.ts +132 -8
- package/src/messaging/mcp-queue-rpc.ts +102 -0
- package/src/messaging/mcp-queue-server.ts +42 -0
- package/src/messaging/mcp-queue-tools.ts +39 -0
- package/src/messaging/remote-forward-failure.ts +35 -0
- package/src/messaging/remote-ports.ts +27 -5
- package/src/messaging/remote-process.ts +30 -4
- package/src/messaging/remote-tunnels.ts +80 -15
- package/src/oauth/anthropic-identity.ts +2 -6
- package/src/oauth/antigravity-discovery-diagnostics.ts +65 -0
- package/src/oauth/google-antigravity.ts +23 -10
- package/src/oauth/index.ts +7 -0
- package/src/oauth/kiro-device-login.ts +87 -30
- package/src/oauth/kiro-iam-identity-center.ts +107 -0
- package/src/oauth/store.ts +9 -7
- package/src/providers/account-quota-disk.ts +18 -4
- package/src/providers/anthropic-subscription.ts +25 -0
- package/src/providers/cc-switch-import-bytes.ts +991 -0
- package/src/providers/cc-switch-import-source.ts +1083 -0
- package/src/providers/cc-switch-import.ts +942 -0
- package/src/providers/claude-cli-usage.ts +15 -67
- package/src/providers/derive.ts +6 -0
- package/src/providers/model-discovery-diagnostic.ts +4 -0
- package/src/providers/model-discovery.ts +4 -4
- package/src/providers/model-rename-fields.ts +2 -0
- package/src/providers/model-rename-migration.ts +41 -6
- package/src/providers/quota/anthropic-decision-windows.ts +5 -19
- package/src/providers/quota/anthropic-usage-windows.ts +55 -0
- package/src/providers/quota/report-cache.ts +17 -4
- package/src/providers/quota.ts +2 -2
- package/src/providers/reasoning-metadata.ts +31 -15
- package/src/providers/registry/entries-core.ts +1 -1
- package/src/providers/registry/entries-extended.ts +1 -1
- package/src/providers/registry/model-ids.ts +1 -0
- package/src/providers/registry/model-seeds.ts +2 -1
- package/src/providers/registry/types.ts +3 -1
- package/src/providers/resolved-model-policy.ts +2 -2
- package/src/providers/routed-config.ts +2 -0
- package/src/providers/stale-model-roster-migration.ts +5 -1
- package/src/providers/xai-transport.ts +4 -4
- package/src/remote-control/workspace-codex-runtime.ts +2 -2
- package/src/remote-control/workspace-executor.ts +14 -13
- package/src/responses/custom-tool-compat.ts +2 -1
- package/src/responses/item-provenance.ts +79 -0
- package/src/responses/namespace-tool-compat.ts +21 -3
- package/src/responses/parser-tools.ts +1 -0
- package/src/responses/schema.ts +5 -2
- package/src/router.ts +21 -2
- package/src/routing/analytics.ts +3 -5
- package/src/routing/fallback-policy.ts +7 -3
- package/src/routing/health.ts +5 -3
- package/src/routing/history/build-file.ts +6 -0
- package/src/routing/history/indexer.ts +158 -31
- package/src/routing/history/ingest.ts +1 -1
- package/src/routing/history/integrity.ts +208 -0
- package/src/routing/history/rebuild-job.ts +20 -6
- package/src/routing/history/rebuild-protocol.ts +2 -1
- package/src/routing/history/rebuild-worker.ts +18 -0
- package/src/routing/history/sqlite-errors.ts +9 -0
- package/src/server/admission-model-scope.ts +21 -4
- package/src/server/advisor-admission-scope.ts +29 -0
- package/src/server/audio-dictation.ts +3 -0
- package/src/server/audio-live.ts +8 -2
- package/src/server/audio-upstream.ts +2 -0
- package/src/server/auth-cors.ts +5 -2
- package/src/server/capture-admission-policy.ts +91 -0
- package/src/server/chat-completions.ts +33 -7
- package/src/server/claude-messages.ts +93 -2
- package/src/server/codex-model-list.ts +2 -1
- package/src/server/configured-credentials.ts +5 -0
- package/src/server/context-history.ts +9 -6
- package/src/server/images.ts +14 -5
- package/src/server/index/live-sideband.ts +16 -2
- package/src/server/index/serve-options.ts +13 -2
- package/src/server/index/websocket-handler.ts +4 -1
- package/src/server/live.ts +30 -5
- package/src/server/management/agent-settings-routes.ts +34 -9
- package/src/server/management/codex-agent-role-routes.ts +1 -0
- package/src/server/management/codex-role-auto-assign.ts +50 -6
- package/src/server/management/config-routes.ts +15 -4
- package/src/server/management/context.ts +3 -0
- package/src/server/management/native-integration-routes.ts +22 -0
- package/src/server/management/oauth-account-routes.ts +20 -4
- package/src/server/management/provider-overwrite-carry.ts +21 -0
- package/src/server/management/provider-routes.ts +3 -1
- package/src/server/management/route-registry.ts +2 -0
- package/src/server/management/shared.ts +17 -1
- package/src/server/management/workflow-budget-routes.ts +70 -3
- package/src/server/messages-native-eligibility.ts +6 -5
- package/src/server/messages-native-scope.ts +6 -1
- package/src/server/messages-shared.ts +57 -17
- package/src/server/persistent-gui-session.ts +4 -4
- package/src/server/request-log.ts +30 -2
- package/src/server/responses/adapter-delivery.ts +4 -0
- package/src/server/responses/adapter-dispatch.ts +5 -0
- package/src/server/responses/advisor-plan-slot.ts +4 -0
- package/src/server/responses/advisor-slot.ts +73 -46
- package/src/server/responses/codex-auth-error.ts +9 -1
- package/src/server/responses/combo-required-tool-contract.ts +39 -0
- package/src/server/responses/compact.ts +41 -20
- package/src/server/responses/core-codex-account.ts +17 -6
- package/src/server/responses/core-combo-failure.ts +2 -0
- package/src/server/responses/core-combo.ts +70 -5
- package/src/server/responses/core-lifetime.ts +4 -0
- package/src/server/responses/core-normalize.ts +7 -1
- package/src/server/responses/core-options.ts +9 -0
- package/src/server/responses/core.ts +2 -0
- package/src/server/responses/jev-model-invoke.ts +4 -2
- package/src/server/responses/passthrough-build-error.ts +36 -0
- package/src/server/responses/passthrough-dispatch.ts +10 -24
- package/src/server/responses/policy-fallback.ts +2 -0
- package/src/server/responses/request-prepare.ts +4 -5
- package/src/server/responses/request-send-budget.ts +2 -1
- package/src/server/responses/request-sidecar-auth.ts +4 -1
- package/src/server/responses/request-transport.ts +2 -3
- package/src/server/responses/run-turn-execution.ts +4 -0
- package/src/server/responses/sidecar-execution.ts +21 -5
- package/src/server/responses-snapshot-repair.ts +18 -4
- package/src/server/responses-undeclared-tool-guard.ts +4 -0
- package/src/server/search.ts +13 -4
- package/src/server/workflow-refusal.ts +2 -1
- package/src/server/ws-bridge.ts +5 -2
- package/src/service/state-lock.ts +12 -11
- package/src/service-manager-probe.ts +53 -8
- package/src/types/admission-policy.ts +13 -0
- package/src/types/config.ts +25 -0
- package/src/types/provider.ts +10 -0
- package/src/types/request.ts +7 -0
- package/src/types.ts +1 -0
- package/src/update/job.ts +20 -0
- package/src/update/worker-launch.ts +71 -1
- package/src/usage/log.ts +25 -4
- package/src/vision/describe.ts +4 -7
- package/src/vision/index.ts +2 -0
- package/src/vision/plan.ts +4 -0
- package/src/vision/routed-describe.ts +38 -23
- package/src/web-search/executor.ts +4 -7
- package/src/web-search/loop.ts +104 -9
- package/src/web-search/parse.ts +10 -2
- package/gui/dist/assets/App-DMps4OLk.css +0 -1
- package/gui/dist/assets/App-DmvwlhQq.js +0 -58
- package/gui/dist/assets/index-3EPO_KbX.js +0 -94
- package/gui/dist/assets/quota-summary-BHvWg9mi.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{D as e,n as t,x as n}from"./index-ebuVUtB7.js";var r=t(),i=e=>({viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,...e}),a=e=>(0,r.jsxs)(`svg`,{...i(e),children:[(0,r.jsx)(`rect`,{x:`3`,y:`3`,width:`7`,height:`7`,rx:`1.5`}),(0,r.jsx)(`rect`,{x:`14`,y:`3`,width:`7`,height:`7`,rx:`1.5`}),(0,r.jsx)(`rect`,{x:`3`,y:`14`,width:`7`,height:`7`,rx:`1.5`}),(0,r.jsx)(`rect`,{x:`14`,y:`14`,width:`7`,height:`7`,rx:`1.5`})]}),o=e=>(0,r.jsxs)(`svg`,{...i(e),children:[(0,r.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`7`,rx:`2`}),(0,r.jsx)(`rect`,{x:`3`,y:`13`,width:`18`,height:`7`,rx:`2`}),(0,r.jsx)(`path`,{d:`M7 7.5h.01M7 16.5h.01`})]}),s=e=>(0,r.jsxs)(`svg`,{...i(e),children:[(0,r.jsx)(`path`,{d:`M12 2 4 6v6l8 4 8-4V6l-8-4Z`}),(0,r.jsx)(`path`,{d:`m4 6 8 4 8-4M12 10v8`})]}),c=e=>(0,r.jsxs)(`svg`,{...i(e),children:[(0,r.jsx)(`rect`,{x:`4`,y:`8`,width:`16`,height:`11`,rx:`3`}),(0,r.jsx)(`path`,{d:`M12 8V4M8 2h8`}),(0,r.jsx)(`circle`,{cx:`9`,cy:`13`,r:`1`}),(0,r.jsx)(`circle`,{cx:`15`,cy:`13`,r:`1`})]}),l=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01`})}),u=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`M4 6h16M4 12h16M4 18h16`})}),d=e=>(0,r.jsxs)(`svg`,{...i(e),children:[(0,r.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`16`,rx:`2`}),(0,r.jsx)(`path`,{d:`M9 4v16`})]}),f=e=>(0,r.jsxs)(`svg`,{...i(e),children:[(0,r.jsx)(`path`,{d:`m4 17 6-5-6-5`}),(0,r.jsx)(`path`,{d:`M12 19h8`})]}),p=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`M22 12h-4l-3 9L9 3l-3 9H2`})}),m=e=>(0,r.jsxs)(`svg`,{...i(e),children:[(0,r.jsx)(`path`,{d:`M22 12H2`}),(0,r.jsx)(`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11Z`}),(0,r.jsx)(`path`,{d:`M6 16h.01M10 16h.01`})]}),h=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`m20 6-11 11-5-5`})}),g=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`M18 6 6 18M6 6l12 12`})}),_=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`M12 5v14M5 12h14`})}),v=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`M5 12h14`})}),ee=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`M21 12a9 9 0 0 1-9 9 9.8 9.8 0 0 1-6.7-2.7L3 16M3 21v-5h5M3 12a9 9 0 0 1 9-9 9.8 9.8 0 0 1 6.7 2.7L21 8M21 3v5h-5`})}),te=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`M8 5v14M16 5v14`})}),ne=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`m7 4 13 8-13 8Z`})}),re=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`M3 6h18M8 6V4h8v2M19 6l-1 14H6L5 6`})}),ie=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`})}),ae=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`})]}),oe=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`})]}),se=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`})]}),ce=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`})]}),le=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`M12 19V5M5 12l7-7 7 7`})}),ue=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`M12 5v14M19 12l-7 7-7-7`})}),de=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`})}),fe=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`m9 18 6-6-6-6`})}),pe=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`})}),me=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`})]}),he=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`})}),ge=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`})]}),_e=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`})}),ve=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`})]}),ye=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`})]}),be=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`})}),xe=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`})]}),Se=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`})}),Ce=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`})]}),we=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`})]}),Te=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`})]}),Ee=e=>(0,r.jsxs)(`svg`,{...i(e),children:[(0,r.jsx)(`circle`,{cx:`9`,cy:`6`,r:`1`,fill:`currentColor`,stroke:`none`}),(0,r.jsx)(`circle`,{cx:`15`,cy:`6`,r:`1`,fill:`currentColor`,stroke:`none`}),(0,r.jsx)(`circle`,{cx:`9`,cy:`12`,r:`1`,fill:`currentColor`,stroke:`none`}),(0,r.jsx)(`circle`,{cx:`15`,cy:`12`,r:`1`,fill:`currentColor`,stroke:`none`}),(0,r.jsx)(`circle`,{cx:`9`,cy:`18`,r:`1`,fill:`currentColor`,stroke:`none`}),(0,r.jsx)(`circle`,{cx:`15`,cy:`18`,r:`1`,fill:`currentColor`,stroke:`none`})]}),y=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`m12 2 3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z`})}),De=e=>(0,r.jsx)(`svg`,{...i(e),children:(0,r.jsx)(`path`,{d:`M4 5h16l-6 7v5l-4 2v-7L4 5z`})}),b={anthropic:`claude-color.svg`,anthropic2:`claude-green.svg`,"anthropic-apikey":`claude-color.svg`,"claude-cli":`claude-color.svg`,"azure-openai":`openai.svg`,chatgpt:`openai.svg`,"cloudflare-ai-gateway":`cloudflare-ai-gateway-color.svg`,"cloudflare-workers-ai":`cloudflare-ai-gateway-color.svg`,cline:`cline-color.svg`,"cline-pass":`cline-color.svg`,"command-code":`commandcode-color.svg`,commandcode:`commandcode-color.svg`,cursor:`cursor-color.svg`,deepseek:`deepseek-color.svg`,"dsh-account":`deepseek-color.svg`,"workbuddy-ai":`workbuddy-color.svg`,devin:`devin.svg`,firepass:`firepass-color.svg`,fireworks:`fireworks-color.svg`,github:`github-copilot-color.svg`,"github-copilot":`copilot-color.svg`,"gitlab-duo":`gitlab-duo-color.svg`,google:`gemini-color.svg`,"google-antigravity":`antigravity-color.svg`,"google-vertex":`gemini-color.svg`,groq:`groq-color.svg`,huggingface:`huggingface-color.svg`,kimi:`kimi-color.svg`,"kimi-code":`kimi-color.svg`,"kimi-responses":`kimi-color.svg`,kiro:`kiro-color.svg`,"lm-studio":`lm-studio-color.svg`,"meta-model":`meta.svg`,"meta-muse":`meta.svg`,mistral:`mistral-color.svg`,minimax:`minimax.svg`,"minimax-cn":`minimax.svg`,moonshot:`moonshot-color.svg`,nvidia:`nvidia-color.svg`,ollama:`ollama-color.svg`,"ollama-cloud":`ollama-color.svg`,openai:`openai.svg`,"openai-apikey":`openai.svg`,"opencode-free":`opencode.svg`,"opencode-go":`opencode.svg`,"opencode-zen":`opencode.svg`,openrouter:`openrouter-color.svg`,opengateway:`opengateway.svg`,opper:`opper.svg`,qianfan:`qianfan-color.svg`,qoder:`qoder.svg`,"qoder-cn":`qoder.svg`,alibaba:`alibaba-color.svg`,"alibaba-token-plan":`alibaba-color.svg`,"alibaba-token-plan-intl":`alibaba-color.svg`,baseten:`baseten.svg`,bizrouter:`bizrouter.svg`,cerebras:`cerebras.svg`,crusoe:`crusoe.svg`,deepinfra:`deepinfra.svg`,digitalocean:`digitalocean.svg`,featherless:`featherless.svg`,hyperbolic:`hyperbolic.svg`,kilo:`kilo.svg`,nanogpt:`nanogpt.svg`,nebius:`nebius.svg`,neuralwatt:`neuralwatt.svg`,nous:`nous.svg`,novita:`novita.svg`,orcarouter:`orcarouter.svg`,"orcarouter-oauth":`orcarouter.svg`,packycode:`packycode.svg`,tokenlab:`tokenlab.svg`,parallel:`parallel.svg`,sambanova:`sambanova.svg`,scaleway:`scaleway.svg`,stepfun:`stepfun-color.svg`,siliconflow:`siliconflow.svg`,synthetic:`synthetic.svg`,together:`together.svg`,umans:`umans.svg`,venice:`venice.svg`,vultr:`vultr.svg`,litellm:`litellm.svg`,zenmux:`zenmux.svg`,zai:`zai.svg`,"zhipu-bigmodel":`zai.svg`,"zhipu-bigmodel-coding":`zai.svg`,"qwen-cloud":`qwen-portal-color.svg`,"vercel-ai-gateway":`vercel-ai-gateway-color.svg`,vllm:`vllm-color.svg`,xai:`grok.svg`,"mimo-free":`xiaomi-color.svg`,mimo:`xiaomi-color.svg`,xiaomi:`xiaomi-color.svg`,"xiaomi-mimo":`xiaomi-color.svg`},x={anthropic:`Anthropic Claude`,"anthropic-apikey":`Anthropic Claude`,chatgpt:`ChatGPT`,openai:`OpenAI (Codex login)`,"openai-apikey":`OpenAI API`,"azure-openai":`Azure OpenAI`,"cloudflare-ai-gateway":`Cloudflare AI Gateway`,"cloudflare-workers-ai":`Cloudflare Workers AI`,cline:`Cline`,"cline-pass":`ClinePass`,nvidia:`NVIDIA NIM`,ollama:`Ollama`,"ollama-cloud":`Ollama Cloud`,xai:`xAI Grok`,"mimo-free":`MiMo Free`,xiaomi:`Xiaomi`,cursor:`Cursor`,deepseek:`DeepSeek`,zed:`Zed`,"dsh-account":`DeepSeek Account (DSH)`,"workbuddy-ai":`WorkBuddy AI`,devin:`Devin`,github:`GitHub`,"github-copilot":`GitHub Copilot`,"gitlab-duo":`GitLab Duo`,openrouter:`OpenRouter`,opengateway:`OpenGateway`,opper:`Opper`,"opencode-go":`OpenCode Go`,"opencode-free":`OpenCode Free`,"opencode-zen":`OpenCode Zen`,orcarouter:`OrcaRouter - API`,"orcarouter-oauth":`OrcaRouter - Auth`,packycode:`PackyCode`,tokenlab:`TokenLab`,mistral:`Mistral`,groq:`Groq`,"meta-model":`Meta Model API`,"meta-muse":`Muse Code`,alibaba:`Alibaba Coding Plan`,"alibaba-token-plan":`Alibaba Token Plan`,"alibaba-token-plan-intl":`Alibaba Token Plan (Intl)`,kimi:`Kimi`,"kimi-code":`Kimi`,"kimi-responses":`Kimi`,moonshot:`Moonshot`,google:`Google`,"google-vertex":`Google Vertex`,"lm-studio":`LM Studio`,huggingface:`Hugging Face`,"qwen-cloud":`Qwen Cloud`,siliconflow:`SiliconFlow`,stepfun:`StepFun`,"tencent-coding-plan":`Tencent Cloud Coding Plan`,codebuddy:`CodeBuddy`,"codebuddy-cn":`CodeBuddy CN`,qoder:`Qoder`,"qoder-cn":`Qoder CN`,"vercel-ai-gateway":`Vercel AI Gateway`,vllm:`vLLM`,litellm:`LiteLLM`},S={anthropic2:`provider.name.anthropic2`,"command-code":`provider.name.commandCodeAuth`,commandcode:`provider.name.commandCodeApi`,orcarouter:`provider.name.orcaRouterApi`,"orcarouter-oauth":`provider.name.orcaRouterAuth`,volcengine:`provider.name.volcengine`,"volcengine-coding-plan":`provider.name.volcengineCodingPlan`,"volcengine-agent-plan":`provider.name.volcengineAgentPlan`},Oe=new Set([...Object.keys(x),...Object.keys(S)]);function ke(e){let t=e.toLowerCase();return Object.hasOwn(b,t)?b[t]:void 0}function Ae(e,t){let n=ke(e);return n?`/provider-icons/${n}`:void 0}var je=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`]),Me=new Set([`baseten.svg`,`kilo.svg`,`sambanova.svg`,`venice.svg`,`zai.svg`]),Ne=new Set([`bizrouter.svg`,`featherless.svg`,`hyperbolic.svg`,`nebius.svg`,`parallel.svg`,`umans.svg`]);function Pe(e){if(!e)return`image`;let t=e.split(`/`).pop()??``;return je.has(t)?`mask`:Me.has(t)?`plate`:Ne.has(t)?`dark-plate`:`image`}function C(e,t){let n=e.toLowerCase(),r=Object.hasOwn(S,n)?S[n]:void 0;return r?t(r):(Object.hasOwn(x,n)?x[n]:void 0)||(e===n&&/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(e)?e.split(`-`).map(e=>e&&e[0].toUpperCase()+e.slice(1)).join(` `):e)}function Fe(e){return Oe.has(e.toLowerCase())}function Ie(e){return e===`command-code`?`commandcode-auth`:e===`commandcode`?`commandcode-api`:e}function Le(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 Re={ko:[{v:0x2386f26fc10000,s:`경`},{v:0xe8d4a51000,s:`조`},{v:1e8,s:`억`},{v:1e4,s:`만`}],zh:[{v:0x2386f26fc10000,s:`京`},{v:0xe8d4a51000,s:`兆`},{v:1e8,s:`亿`},{v:1e4,s:`万`}],"zh-TW":[{v:0x2386f26fc10000,s:`京`},{v:0xe8d4a51000,s:`兆`},{v:1e8,s:`億`},{v:1e4,s:`萬`}]};function w(e){return e.replace(/\.0+$/,``).replace(/(\.\d*?)0+$/,`$1`)}function ze(e,t){let n=Re[t];if(n){for(let t of n)if(e>=t.v)return`${w((e/t.v).toFixed(1))}${t.s}`;return String(e)}return e<1e4?String(e):e<1e6?`${w((e/1e3).toFixed(1))}K`:e<1e9?`${w((e/1e6).toFixed(1))}M`:e<0xe8d4a51000?`${w((e/1e9).toFixed(1))}B`:`${w((e/0xe8d4a51000).toFixed(1))}T`}var Be=new Set([`claude-cli`]),Ve=`anthropic-apikey`;function T(e){return Be.has((e.adapter??``).trim())}var E=`https://chatgpt.com/backend-api/codex`,He=`openai`;function D(e){try{let t=new URL(e.trim());if(t.username||t.password||t.search||t.hash)return;let n=t.pathname.replace(/\/+$/,``);return`${t.origin}${n}`}catch{return}}var Ue=new URL(E).protocol;function O(e,...t){return`${Ue}//${e}/${t.join(`/`)}`}var We={"cline-pass":{adapter:`openai-chat`,baseUrl:O(`api.cline.bot`,`api`,`v1`)},"mimo-free":{adapter:`mimo-free`,baseUrl:O(`api.xiaomimimo.com`,`api`,`free-ai`,`openai`,`chat`)}};function Ge(e,t){let n=We[e];return!n||t.adapter!==n.adapter||D(t.baseUrl)!==D(n.baseUrl)}function k(e){try{let t=new URL(e).hostname.replace(/^\[|\]$/g,``).toLowerCase();return t===`localhost`||t===`127.0.0.1`||t===`::1`}catch{return!1}}function A(e){return e.keyOptional===!0||T(e)||e.authMode===`oauth`||e.authMode===`forward`||e.authMode===`local`||k(e.baseUrl)||e.hasApiKey===!0}function j(e){return e.adapter===`openai-responses`&&e.authMode===`forward`&&D(e.baseUrl)===E}function M(e,t){return e===He&&j(t)}function N(e){return T(e)?!1:e.freeTier===!0||e.keyOptional===!0||e.authMode===`local`||k(e.baseUrl)}function P(e,t){return M(e,t)?`accounts`:N(t)?`free`:`paid`}function Ke(e,t){let n=[...e],r=(e,t)=>e.name.localeCompare(t.name,void 0,{sensitivity:`base`}),i=e=>e.tier??P(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}):A(a)?t.push({name:i,...a,tier:P(i,a)}):n.push({name:i,...a});return{ready:t,needsSetup:n,disabled:r}}function Je(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 F(e){return e.disabled?`disabled`:`activeNeedsReauth`in e&&e.activeNeedsReauth?`needs-setup`:A(e)?`ready`:`needs-setup`}function Ye(e){let t=e.openai,n=e.chatgpt;if(!t||!n||!M(`openai`,t)||!j(n))return e;let r={...e};return delete r.chatgpt,r}function I(e){return e.authMode===`local`||k(e.baseUrl)}var Xe=[`ollama`,`vllm`,`lm-studio`,`lmstudio`,`litellm`,`localai`];function Ze(e){let t=(e.authMode??``).toLowerCase();if(t===`oauth`||t===`forward`)return`login`;if(I(e))return`local`;let n=`${e.name??``} ${e.adapter} ${e.baseUrl}`.toLowerCase();return Xe.some(e=>n.includes(e))?`selfHosted`:`cloud`}var L=[`plan_base`,`plan_bonus`,`addon`,`benefit`,`other`];function R(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}function z(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 B(e){let t=R(e),n=z(t.total),r=z(t.used),i=z(t.remaining),a=z(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 Qe(e){let t=R(e),n=B(e);if(!n||!Array.isArray(t.groups)||t.groups.length>L.length)return;let r=[],i=new Set;for(let e of t.groups){let t=R(e),n=B(t),a=L.find(e=>e===t.kind);if(!n||!a||i.has(a))return;i.add(a),r.push({kind:a,...n})}let a=R(t.expiring),o=z(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 V(e,t){if(!e||typeof e!=`object`||Array.isArray(e))return null;let n=e;if(typeof n.updatedAt!=`number`||!Number.isFinite(n.updatedAt))return null;let r=n.observed===!0;return!r&&t-n.updatedAt>=18e5||!(`quota`in n)||n.label!==void 0&&typeof n.label!=`string`||n.source!==void 0&&typeof n.source!=`string`?null:{...typeof n.label==`string`?{label:n.label}:{},...typeof n.source==`string`?{source:n.source}:{},updatedAt:n.updatedAt,quota:n.quota,...r?{observed:!0}:{},...n.aggregation===void 0?{}:{aggregation:n.aggregation}}}function $e(e,t=Date.now()){if(!e||typeof e!=`object`||Array.isArray(e))return null;let n={};for(let[r,i]of Object.entries(e)){let e=V(i,t);r.trim()&&e&&(n[r]=e)}return n}function et(e,t=Date.now()){if(!Array.isArray(e))return{};let n={};for(let r of e){if(!r||typeof r!=`object`||Array.isArray(r))continue;let e=r.provider,i=V(r,t);typeof e==`string`&&e.trim()&&i&&(n[e]=i)}return n}function tt(e){return e?.observed===!0&&typeof e.updatedAt==`number`?e.updatedAt:void 0}var H=e=>typeof e==`number`&&Number.isFinite(e)?e:void 0,nt=e=>{let t=H(e);if(t===void 0)return;let n=t>1e10?t:t*1e3;return Number.isFinite(new Date(n).getTime())?t:void 0};function rt(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`||H(t.percent)===void 0?[]:[{label:t.label,percent:t.percent,...H(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=H(i?.used),o=H(i?.limit),s=H(i?.remaining),c=H(i?.percent),l=nt(i?.expiresAt),u=a!==void 0&&o!==void 0&&s!==void 0&&c!==void 0?{used:a,limit:o,remaining:s,percent:c,...l===void 0?{}:{expiresAt:l},...typeof i?.unlimited==`boolean`?{unlimited:i.unlimited}:{}}:void 0,d=Qe(n.workbuddyCredits),f={...d?{workbuddyCredits:d}:{},...H(n.fiveHourPercent)===void 0?{}:{fiveHourPercent:n.fiveHourPercent},...H(n.fiveHourResetAt)===void 0?{}:{fiveHourResetAt:n.fiveHourResetAt},...H(n.weeklyPercent)===void 0?{}:{weeklyPercent:n.weeklyPercent},...H(n.weeklyResetAt)===void 0?{}:{weeklyResetAt:n.weeklyResetAt},...H(n.monthlyPercent)===void 0?{}:{monthlyPercent:n.monthlyPercent},...H(n.monthlyResetAt)===void 0?{}:{monthlyResetAt:n.monthlyResetAt},...r.length>0?{customWindows:r}:{},...u?{creditsUsd:u}:{},updatedAt:H(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 it(e){return rt(e?.quota,e?.updatedAt)}function at(e){if(!e)return;if(e.aggregation===void 0)return e;let t=ot(e)?.currentAccount?.quota??null;return{...e,aggregation:void 0,quota:t,updatedAt:t?.updatedAt}}function U(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e,n=H(t.usedPercent);if(n!==void 0)return{usedPercent:n,...typeof t.incomplete==`boolean`?{incomplete:t.incomplete}:{},...H(t.excludedAccounts)===void 0?{}:{excludedAccounts:t.excludedAccounts},...H(t.nextRecoveryAt)===void 0?{}:{nextRecoveryAt:t.nextRecoveryAt},...H(t.nextRecoveryPercent)===void 0?{}:{nextRecoveryPercent:t.nextRecoveryPercent}}}function ot(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=H(n.excludedAccounts),i=H(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=U(t);return typeof t.label==`string`&&n?[{label:t.label,...n}]:[]}):[],s=U(n.fiveHour),c=U(n.weekly),l=U(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:H(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:rt(a.quota)}}:{}}}function st(e){if(!e?.trim())return``;let[t,n]=e.split(`:`,2);return n?`${t} · ${n.replace(/-/g,` `)}`:e}function ct(e,t){let n=F(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 lt(e,t){if(T(e))return t(`modal.badge.subscriptionCli`);switch(e.authMode){case`oauth`:return t(`modal.badge.oauth`);case`forward`:return t(`pws.auth.chatgptPassthrough`);case`local`:return t(`modal.badge.local`);case`key`:return t(`modal.badge.apiKey`);default:return e.authMode??(e.keyOptional?t(`pws.auth.noKey`):t(`modal.badge.apiKey`))}}function ut(e){let t=F(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 dt({name:t,adapter:n,baseUrl:i,cls:a}){let o=e(),s=Ae(t,{adapter:n,baseUrl:i}),c=Pe(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)(ft,{name:t,label:C(t,o)})})}function ft({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 pt({item:t,selected:n,tabbable:i,modelCount:a,isDefault:o,showConfigId:s,onClick:c,onFocus:l}){let u=e(),d=N(t),f=I(t),p=ct(t,u),m=C(t.name,u),h=s?`${m} (${t.name})`:m,g=`${o?u(`pws.rail.suffixDefault`):``}${f?u(`pws.rail.suffixLocal`):d?u(`pws.rail.suffixFree`):``}`,_=a!==void 0&&a>0?a===1?u(`pws.modelCountOne`):u(`pws.modelCount`,{count:a}):``,v=[s?t.name:``,_].filter(Boolean).join(` · `);return(0,r.jsxs)(`button`,{type:`button`,className:`providers-workspace-rail-row${n?` providers-workspace-rail-row--selected`:``}`,onClick:c,role:`option`,"aria-selected":n,tabIndex:i?0:-1,"aria-label":u(`pws.rail.selectAria`,{name:h,status:p,suffix:g}),title:h,onFocus:l,children:[(0,r.jsx)(dt,{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:v||void 0,children:v||`\xA0`})]}),(0,r.jsxs)(`span`,{className:`providers-workspace-rail-trail`,children:[o&&(0,r.jsx)(`span`,{className:`pwi-default-star`,title:u(`prov.defaultBadge`),"aria-label":u(`prov.defaultBadge`),children:(0,r.jsx)(y,{width:17,height:17,"aria-hidden":`true`})}),(0,r.jsx)(`span`,{className:ut(t),title:p,"aria-hidden":`true`})]})]})}var mt=1e10;function ht(e){return e<mt?e*1e3:e}function gt(e,t){return typeof e==`number`&&Number.isFinite(e)&&e>0&&ht(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 ht(r)>t}function vt(e){return{fiveHourAvailable:e?.shortWindowSeconds===18e3&&typeof e.shortResetAt==`number`,weeklyAvailable:typeof e?.weeklyResetAt==`number`}}function yt(e){let t=e?.trim().toLowerCase();return t===`go`||t===`free`}function bt(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 yt(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 xt(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=(yt(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 St(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 W(e){return Array.isArray(e)&&e.length<=100&&e.every(e=>typeof e==`string`)?JSON.stringify([...new Set(e)].sort()):void 0}function Ct(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&&W(o.hiddenProviders)===W(t.hiddenProviders)&&(t.models===null?o.models===null:W(o.models)===W(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 wt={6:15,24:60,72:180,168:360};function Tt(e){return wt[e]}function G(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 K=[`#0A84FF`,`#FF9F0A`,`#30D158`,`#BF5AF2`,`#FF453A`,`#64D2FF`],jt=640,Mt=160,q=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=q,f=u.map((e,t)=>(0,r.jsx)(`text`,{x:q+584*t/3,y:156,textAnchor:t===0?`start`:t===3?`end`:`middle`,className:`usage-companion-axis-label`,children:e},`${e}-${t}`)),p=t===`line`?e.series.map((e,t)=>(0,r.jsx)(`polyline`,{points:kt(e.points,584,104,l,0),transform:`translate(${q},${q})`,fill:`none`,stroke:K[t%K.length],strokeWidth:`2`,strokeLinejoin:`round`,strokeLinecap:`round`},e.id)):At(e.series,584,104,l,0).map(e=>(0,r.jsx)(`rect`,{x:q+e.x,y:q+e.y,width:e.width,height:e.height,fill:K[e.seriesIndex%K.length],rx:`1`},`${e.bucketIndex}-${e.seriesIndex}`));return(0,r.jsxs)(`div`,{className:`usage-companion-chart`,children:[(0,r.jsxs)(`svg`,{viewBox:`0 0 ${jt} ${Mt}`,role:`img`,"aria-label":c(`usage.companion.chartLabel`),children:[(0,r.jsx)(`line`,{x1:q,y1:d,x2:q,y2:132,className:`usage-companion-axis`}),(0,r.jsx)(`line`,{x1:q,y1:132,x2:612,y2:132,className:`usage-companion-axis`}),(0,r.jsx)(`text`,{x:24,y:32,textAnchor:`end`,className:`usage-companion-axis-label`,children:G(l)}),p,f]}),(0,r.jsx)(`div`,{className:`usage-companion-legend`,children:e.series.map((e,t)=>(0,r.jsxs)(`span`,{className:`usage-companion-legend-item`,children:[(0,r.jsx)(`span`,{className:`usage-companion-swatch`,style:{background:K[t%K.length]},"aria-hidden":`true`}),(0,r.jsx)(`span`,{children:e.id})]},e.id))}),e.truncated&&(0,r.jsx)(`p`,{className:`muted text-caption`,children:c(`usage.companion.olderRecordsSkipped`)})]})}var J=e=>typeof e==`number`&&Number.isFinite(e)&&e>=0,Y=e=>typeof e==`object`&&e&&!Array.isArray(e)?e:{};function It(e){return Object.entries(Y(Y(e).providers)).flatMap(([e,t])=>{let n=Y(t);return n.disabled===!0?[]:e===`openai`?[{name:e,path:`/api/codex-auth/accounts`,switchKind:`codex`}]:n.authMode===`oauth`?[{name:e,path:`/api/oauth/accounts?${new URLSearchParams({provider:e,quota:`1`})}`,switchKind:`oauth`}]:n.hasApiKey===!0&&n.authMode!==`forward`?[{name:e,path:`/api/providers/keys?${new URLSearchParams({name:e,quota:`1`})}`,switchKind:`apiKey`}]:[{name:e,path:null,switchKind:null}]})}function 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`}:Y(e.mainAccountHardLock).state===`blocked`?{switchState:`blocked`,blockedReason:`mainHardLock`}:e.paused===!0?{switchState:`blocked`,blockedReason:`paused`}:Y(e.health).reason===`validation_pending`?{switchState:`blocked`,blockedReason:`validationPending`}:{switchState:`available`}}function 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=Y(e),n=t.accounts??t.keys;if(!Array.isArray(n))throw Error(`Invalid account roster`);return n.map(e=>{let n=Y(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:Y(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(Y(n.quota),o),status:typeof Y(n.health).status==`string`?Y(n.health).status:void 0,quotaFailure:typeof n.quotaFailure==`string`?n.quotaFailure:void 0,quota:bt(a,o)}})}function X(e){if(!J(e)||e===0)return null;let t=e<0xe8d4a51000?e*1e3:e;return Number.isFinite(new Date(t).getTime())?t:null}function 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=X(e);if(r===null||r<=n)return{text:`—`};let i=Math.ceil((r-n)/6e4),a=(e,n)=>new Intl.NumberFormat(t,{style:`unit`,unit:n,unitDisplay:`narrow`}).format(e);return{text:i<60?a(i,`minute`):i<1440?`${a(Math.floor(i/60),`hour`)} ${a(i%60,`minute`)}`:i<10080?`${a(Math.floor(i/1440),`day`)} ${a(Math.floor(i%1440/60),`hour`)}`:new Intl.DateTimeFormat(t,{month:`short`,day:`numeric`}).format(r),exact:new Date(r).toLocaleString(t)}}function Z(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=>J(e.percent)||X(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 Ut(e,t){let n=new Set(t.hiddenProviders),r=t.models===null?null:new Set(t.models),i=e.models.filter(e=>!n.has(e.provider)&&(r===null||r.has(`${e.provider}/${e.model}`)||r.has(e.model)));if(t.models===null&&t.hiddenProviders.length===0)return{...e,models:i};if(t.models?.length!==0&&e.models.some(e=>!e.provider||!e.model||e.provider===`other`&&e.model===`other`))return{...e,models:i.filter(e=>e.provider!==`other`||e.model!==`other`),summary:{},usageIncomplete:!0};let a={};for(let e of[`requests`,`totalTokens`,`inputTokens`,`outputTokens`,`cachedInputTokens`,`cacheReadInputTokens`,`estimatedCostUsd`,`measuredRequests`,`pricedRequests`])i.length&&i.every(t=>J(t[e]))&&(a[e]=i.reduce((t,n)=>t+n[e],0));return{...e,models:i,summary:a}}function Wt(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 Gt(e,t){let r=n(2e4),i=()=>r.controller.abort();t.aborted&&i(),t.addEventListener(`abort`,i,{once:!0});try{let t=await fetch(e,{signal:r.signal,cache:`no-store`});if(!t.ok)throw Error(String(t.status));let n=await t.json();if(r.signal.aborted)throw Error(`Tray request cancelled`);return n}finally{r.clear(),t.removeEventListener(`abort`,i)}}function Kt(e){let t=Y(e);if(t.error||!t.summary||typeof t.summary!=`object`||Array.isArray(t.summary)||!Array.isArray(t.models))throw Error(`Invalid usage`);return t}var Q=e=>typeof e==`number`&&Number.isFinite(e);function $(e){return Q(e)?e>=90?`critical`:e>=70?`warn`:`normal`:`normal`}function qt(e){return Q(e)?`${Math.floor(e)}%`:`-`}var Jt=[`quota.weeklyLimit`,`quota.monthlyLimit`,`quota.fiveHourLimit`];function Yt(e){let t=Z(e).map(e=>{let t=Q(e.percent)?e.percent:void 0,n=X(e.reset),r=`modelId`in e?e.modelId:void 0;return{id:e.id,...r===void 0?{}:{modelId:r},...`key`in e&&e.key?{labelKey:e.key}:{},...`label`in e&&typeof e.label==`string`?{label:e.label}:{},...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=X(n.expiresAt);t.push({id:`quotaSummary.credits`,labelKey:`quotaSummary.credits`,percent:n.percent,...e===null?{}:{resetAt:e},severity:$(n.percent)})}return t}function Xt(e){let t=e.filter(e=>e.modelId===void 0&&e.percent!==void 0),n=new Map(t.map(e=>[e.id,e]));for(let e of Jt){let t=n.get(e);if(t)return t}return t[0]}function Zt(e,t){let n=[];for(let[r,i]of Object.entries(e)){let e=it(i);if(!e)continue;let a=Yt(e),o=Xt(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 $,at as A,_ as At,Ye as B,re as Bt,bt as C,v as Ct,lt as D,te as Dt,pt as E,d as Et,I as F,Te as Ft,Ke as G,N as H,Ze as I,y as It,ze as J,Ve as K,Je as L,xe as Lt,$e as M,ee as Mt,et as N,ce as Nt,it as O,ae as Ot,tt as P,o as Pt,Ie as Q,F as R,f as Rt,xt as S,u as St,dt as T,Se as Tt,Ge as U,M as V,g as Vt,P as W,C as X,Le as Y,Fe as Z,Ct as _,se as _t,Gt as a,h as at,Et as b,l as bt,Wt as c,de as ct,It as d,De as dt,oe as et,Z as f,pe as ft,Ot as g,m as gt,Tt as h,Ee as ht,Lt as i,s as it,st as j,me as jt,ot as k,ne as kt,Bt as l,he as lt,Ft as m,a as mt,qt as n,le as nt,Ut as o,fe as ot,Ht as p,we as pt,T as q,$ as r,c as rt,J as s,_e as st,Zt as t,ue as tt,Kt as u,ie as ut,St as v,ge as vt,vt as w,Ce as wt,Dt as x,ve as xt,G as y,be as yt,qe as z,ye as zt};
|
package/gui/dist/index.html
CHANGED
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
document.documentElement.lang = langMap[locale];
|
|
37
37
|
})();
|
|
38
38
|
</script>
|
|
39
|
-
<script type="module" crossorigin src="/assets/index-
|
|
39
|
+
<script type="module" crossorigin src="/assets/index-ebuVUtB7.js"></script>
|
|
40
40
|
<link rel="stylesheet" crossorigin href="/assets/index-CHWwDo9L.css">
|
|
41
41
|
</head>
|
|
42
42
|
<body>
|
package/package.json
CHANGED
|
@@ -1097,7 +1097,10 @@ export function createAnthropicAdapter(provider: OcxProviderConfig, cacheRetenti
|
|
|
1097
1097
|
// request before it can emit its stop sequence (#545). Say "disabled" out loud where the
|
|
1098
1098
|
// model both defaults to thinking and accepts being told not to.
|
|
1099
1099
|
const family = claudeFamilyVersion(parsed.modelId);
|
|
1100
|
-
|
|
1100
|
+
const nativeOpus55 = usesNativeAnthropicEndpoint(provider) && family?.family === "opus" && family.major === 5 && family.minor === 5;
|
|
1101
|
+
const summary = (parsed._rawBody as { reasoning?: { summary?: unknown } } | undefined)?.reasoning?.summary;
|
|
1102
|
+
// Codex sends "auto" by default, so only an explicit concise/detailed request opts out of updates (#7728).
|
|
1103
|
+
const summaryRequested = summary === "concise" || summary === "detailed";
|
|
1101
1104
|
const thinkingToggleWire = declaresThinkingToggleWire(provider, parsed.modelId);
|
|
1102
1105
|
const reasoningControlsUnsupported = reasoningControlsAreUnsupported(provider, parsed.modelId);
|
|
1103
1106
|
const capabilities = resolveReasoningCapabilities(provider, parsed.modelId);
|
|
@@ -1132,7 +1135,7 @@ export function createAnthropicAdapter(provider: OcxProviderConfig, cacheRetenti
|
|
|
1132
1135
|
// default 8192-token request can spend everything on thought and return empty text.
|
|
1133
1136
|
// Opus 4.7+ defaults `display` to "omitted": the stream then carries signature-only
|
|
1134
1137
|
// thinking blocks, so a Chat client sees minutes of heartbeats and no reasoning delta
|
|
1135
|
-
// during a long think (#5824). Opus 5.5
|
|
1138
|
+
// during a long think (#5824). Native Opus 5.5 selects its display below;
|
|
1136
1139
|
// other models request summarized thinking unless the caller hides it.
|
|
1137
1140
|
body.thinking = parsed.options.hideThinkingSummary
|
|
1138
1141
|
? { type: "adaptive" }
|
|
@@ -1181,7 +1184,11 @@ export function createAnthropicAdapter(provider: OcxProviderConfig, cacheRetenti
|
|
|
1181
1184
|
delete body.top_p;
|
|
1182
1185
|
}
|
|
1183
1186
|
|
|
1184
|
-
if (
|
|
1187
|
+
if (nativeOpus55 && !reasoningControlsUnsupported && thinkingEnabled !== false) {
|
|
1188
|
+
body.thinking = { type: "adaptive", display: summaryRequested ? "summarized" : "updates" };
|
|
1189
|
+
}
|
|
1190
|
+
// One discriminator governs the display beta and response classification, including reuse.
|
|
1191
|
+
progressUpdates = (body.thinking as { display?: string } | undefined)?.display === "updates";
|
|
1185
1192
|
|
|
1186
1193
|
if (rejectsSamplingParameters(parsed.modelId)) {
|
|
1187
1194
|
// Opus 4.7+, Sonnet 5+, Haiku 5.5+ and Fable 400 on non-default sampling, with or without
|
|
@@ -189,15 +189,15 @@ function truncateUtf8(text: string, capBytes: number): string {
|
|
|
189
189
|
async function openedFileIsConfined(
|
|
190
190
|
handle: Awaited<ReturnType<typeof open>>, path: string, cwdCanonical: string, deadline: number, scope: ScanScope,
|
|
191
191
|
): Promise<boolean> {
|
|
192
|
-
const opened = await withinDeadline(() => handle.stat(), deadline, scope);
|
|
192
|
+
const opened = await withinDeadline(() => handle.stat({ bigint: true }), deadline, scope);
|
|
193
193
|
if (!opened.isFile()) return false;
|
|
194
|
-
const current = await withinDeadline(() => lstat(path), deadline, scope);
|
|
194
|
+
const current = await withinDeadline(() => lstat(path, { bigint: true }), deadline, scope);
|
|
195
195
|
if (!current.isFile() || opened.dev !== current.dev || opened.ino !== current.ino) return false;
|
|
196
196
|
const resolved = await withinDeadline(() => realpath(path), deadline, scope);
|
|
197
197
|
// The input path was canonical before open. A changed intermediate symlink changes this
|
|
198
198
|
// result even though O_NOFOLLOW protects only the final component on macOS and Linux.
|
|
199
199
|
if (!isContainedCanonicalPath(cwdCanonical, resolved) || resolved !== path) return false;
|
|
200
|
-
const resolvedInfo = await withinDeadline(() => lstat(resolved), deadline, scope);
|
|
200
|
+
const resolvedInfo = await withinDeadline(() => lstat(resolved, { bigint: true }), deadline, scope);
|
|
201
201
|
return resolvedInfo.isFile() && opened.dev === resolvedInfo.dev && opened.ino === resolvedInfo.ino;
|
|
202
202
|
}
|
|
203
203
|
|
|
@@ -297,7 +297,10 @@ export function createKiroAdapter(provider: OcxProviderConfig): ProviderAdapter
|
|
|
297
297
|
toolNameMap = built.nameMap;
|
|
298
298
|
conversationId = built.conversationId;
|
|
299
299
|
completionMode = built.completionMode;
|
|
300
|
-
|
|
300
|
+
// Runtime callbacks belong to the original request, not the retry payload.
|
|
301
|
+
requestSnapshot = structuredClone(Object.fromEntries(
|
|
302
|
+
Object.entries(parsed).filter(([, value]) => typeof value !== "function"),
|
|
303
|
+
)) as OcxParsedRequest;
|
|
301
304
|
firstRequestBodyBytes = Buffer.byteLength(built.request.body);
|
|
302
305
|
requestAbortSignal = incoming?.abortSignal;
|
|
303
306
|
return built.request;
|
|
@@ -187,6 +187,7 @@ function mergeKiroUsage(
|
|
|
187
187
|
...(sumOptional("providerCredits") !== undefined ? { providerCredits: sumOptional("providerCredits") } : {}),
|
|
188
188
|
...(sumOptional("reasoningOutputTokens") !== undefined ? { reasoningOutputTokens: sumOptional("reasoningOutputTokens") } : {}),
|
|
189
189
|
...(first.estimated || second.estimated ? { estimated: true } : {}),
|
|
190
|
+
...(first.upstreamReported && second.upstreamReported ? { upstreamReported: true as const } : {}),
|
|
190
191
|
};
|
|
191
192
|
}
|
|
192
193
|
|
|
@@ -109,6 +109,7 @@ function parseTokenUsage(eventType: string, value: unknown): OcxUsage | undefine
|
|
|
109
109
|
totalTokens,
|
|
110
110
|
...(cacheRead !== undefined ? { cachedInputTokens: cacheRead, cacheReadInputTokens: cacheRead } : {}),
|
|
111
111
|
...(cacheWrite !== undefined ? { cacheCreationInputTokens: cacheWrite } : {}),
|
|
112
|
+
upstreamReported: true,
|
|
112
113
|
};
|
|
113
114
|
}
|
|
114
115
|
|
|
@@ -1051,7 +1051,6 @@ async function* parseOllamaNativeStream(
|
|
|
1051
1051
|
}
|
|
1052
1052
|
const reader = response.body.getReader();
|
|
1053
1053
|
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
1054
|
-
const encoder = new TextEncoder();
|
|
1055
1054
|
const state = streamState(allowParallelToolCalls);
|
|
1056
1055
|
const issuedIds = issuedToolCallIds ?? new Set<string>();
|
|
1057
1056
|
let buffer = "";
|
|
@@ -1060,15 +1059,20 @@ async function* parseOllamaNativeStream(
|
|
|
1060
1059
|
|
|
1061
1060
|
const ingest = function* (text: string): Generator<AdapterEvent> {
|
|
1062
1061
|
if (!text) return;
|
|
1062
|
+
const hasNewline = text.includes("\n");
|
|
1063
1063
|
buffer += text;
|
|
1064
|
-
|
|
1065
|
-
|
|
1064
|
+
// After draining, the carry contains no newline. Only new text can complete a record.
|
|
1065
|
+
const lines = hasNewline ? buffer.split("\n") : [];
|
|
1066
|
+
if (hasNewline) buffer = lines.pop() ?? "";
|
|
1066
1067
|
// The safety bound applies to the genuinely retained residual — the incomplete NDJSON record
|
|
1067
1068
|
// still being assembled — and to each complete record below. It must never depend on the
|
|
1068
1069
|
// transport read size (one read may carry many valid records) nor transiently charge
|
|
1069
1070
|
// old + replacement together. On a ceiling violation the old reservation is left in place so
|
|
1070
1071
|
// the generator's finally releases exactly what is held.
|
|
1071
|
-
|
|
1072
|
+
// TextDecoder emits complete code points; fragment byte counts add without a surrogate fixup.
|
|
1073
|
+
const residualBytes = hasNewline
|
|
1074
|
+
? Buffer.byteLength(buffer, "utf8")
|
|
1075
|
+
: bufferBytes + Buffer.byteLength(text, "utf8");
|
|
1072
1076
|
if (residualBytes > TRANSLATOR_MAX_SSE_EVENT_BYTES) {
|
|
1073
1077
|
throw new TranslatorBudgetExceededError("live_transient", TRANSLATOR_MAX_SSE_EVENT_BYTES);
|
|
1074
1078
|
}
|
|
@@ -1077,7 +1081,7 @@ async function* parseOllamaNativeStream(
|
|
|
1077
1081
|
|
|
1078
1082
|
for (const rawLine of lines) {
|
|
1079
1083
|
const line = rawLine.endsWith("\r") ? rawLine.slice(0, -1) : rawLine;
|
|
1080
|
-
const lineBytes =
|
|
1084
|
+
const lineBytes = Buffer.byteLength(line, "utf8");
|
|
1081
1085
|
if (lineBytes > TRANSLATOR_MAX_SSE_EVENT_BYTES) {
|
|
1082
1086
|
throw new TranslatorBudgetExceededError("live_transient", TRANSLATOR_MAX_SSE_EVENT_BYTES);
|
|
1083
1087
|
}
|
|
@@ -1112,7 +1116,7 @@ async function* parseOllamaNativeStream(
|
|
|
1112
1116
|
yield* ingest(decoder.decode());
|
|
1113
1117
|
if (!state.terminal && buffer.length > 0) {
|
|
1114
1118
|
const rawLine = buffer.endsWith("\r") ? buffer.slice(0, -1) : buffer;
|
|
1115
|
-
const lineBytes =
|
|
1119
|
+
const lineBytes = Buffer.byteLength(rawLine, "utf8");
|
|
1116
1120
|
if (lineBytes > TRANSLATOR_MAX_SSE_EVENT_BYTES) throw new TranslatorBudgetExceededError("live_transient", TRANSLATOR_MAX_SSE_EVENT_BYTES);
|
|
1117
1121
|
try {
|
|
1118
1122
|
// The EOF record keeps its residual charge while it is parsed and consumed — releasing it
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isMistralChatTarget, isNativeOpenAIChatTarget, stripBracketedModelSuffix } from "./wire";
|
|
2
2
|
import { reasoningDetailSegmentForWire } from "./response-events";
|
|
3
3
|
import { translatedChatDeveloperWireRole } from "./developer-role";
|
|
4
|
+
import { singleLeadingSystemMessages } from "./single-system";
|
|
4
5
|
import { isVolcengineArkPaygChatTarget } from "./tool-schema";
|
|
5
6
|
import { contentPartsToText } from "../image";
|
|
6
7
|
import { EMPTY_TOOL_OUTPUT_ANNOTATION, isWhitespaceOnlyTextPartArray } from "../empty-tool-output-annotation";
|
|
@@ -172,7 +173,7 @@ export function messagesToChatFormat(parsed: OcxParsedRequest, provider: OcxProv
|
|
|
172
173
|
// Gateways serve them under namespaced ids (LiteLLM's openai/Qwen3.8-27B, #6674), so any
|
|
173
174
|
// number of leading path segments is accepted; the final segment names the checkpoint.
|
|
174
175
|
// Orca's GGUF marker must precede any colon quant tag; other Orca variants are unchanged.
|
|
175
|
-
const leadingSystemTemplate = !nativeOpenAI && /^(?:[^/]+\/)*(?:flash-next|Qwen3\.8-Flash-Next|Qwen3\.8-27B|qwen3-8-27b(?:-(?:fp8|lora))?|OrcaSAQ-2-Cyber-27B(?=[^:/\s]*GGUF)[^:/\s]*(?::[\w-]+)?)$/i.test(parsed.modelId);
|
|
176
|
+
const leadingSystemTemplate = provider.singleLeadingSystemMessage !== true && !nativeOpenAI && /^(?:[^/]+\/)*(?:flash-next|Qwen3\.8-Flash-Next|Qwen3\.8-27B|qwen3-8-27b(?:-(?:fp8|lora))?|OrcaSAQ-2-Cyber-27B(?=[^:/\s]*GGUF)[^:/\s]*(?::[\w-]+)?)$/i.test(parsed.modelId);
|
|
176
177
|
// Which role a developer message carries, and why the unrecorded state folds, is stated once
|
|
177
178
|
// in ./developer-role.ts and read from there by the native passthrough as well. Either way the
|
|
178
179
|
// message keeps the slot it arrived in — only the role changes, never the position.
|
|
@@ -271,6 +272,15 @@ export function messagesToChatFormat(parsed: OcxParsedRequest, provider: OcxProv
|
|
|
271
272
|
role: msg.role === "developer" && !hasImages && !hasAudio ? developerWireRole : "user",
|
|
272
273
|
content: chatParts,
|
|
273
274
|
};
|
|
275
|
+
if (provider.singleLeadingSystemMessage === true && chatMsg.role !== "user") {
|
|
276
|
+
// Keep document bytes in a user-compatible slot; only their accompanying text is
|
|
277
|
+
// instruction content. Use the same tool barrier so instruction order is retained.
|
|
278
|
+
const instruction = { role: developerWireRole, content: chatParts.filter(p => p.type === "text") };
|
|
279
|
+
if (instruction.content.length > 0) {
|
|
280
|
+
(pendingToolCalls.length > 0 ? deferredBarrierMessages : out).push(instruction);
|
|
281
|
+
}
|
|
282
|
+
chatMsg = { role: "user", content: chatParts.filter(p => p.type !== "text") };
|
|
283
|
+
}
|
|
274
284
|
}
|
|
275
285
|
if (pendingToolCalls.length > 0) deferredBarrierMessages.push(chatMsg);
|
|
276
286
|
else out.push(chatMsg);
|
|
@@ -346,10 +356,10 @@ export function messagesToChatFormat(parsed: OcxParsedRequest, provider: OcxProv
|
|
|
346
356
|
type: "function",
|
|
347
357
|
function: { name: namespacedToolName(tc.namespace, tc.name), arguments: JSON.stringify(tc.arguments) },
|
|
348
358
|
}));
|
|
349
|
-
if (!chatMsg.content) chatMsg.content = emptyAssistantContent(provider);
|
|
359
|
+
if (!chatMsg.content) chatMsg.content = emptyAssistantContent(provider, parsed.modelId);
|
|
350
360
|
}
|
|
351
361
|
if (hasReplayedReasoning && chatMsg.content === undefined && chatMsg.tool_calls === undefined) {
|
|
352
|
-
chatMsg.content = emptyAssistantContent(provider);
|
|
362
|
+
chatMsg.content = emptyAssistantContent(provider, parsed.modelId);
|
|
353
363
|
}
|
|
354
364
|
out.push(chatMsg);
|
|
355
365
|
pendingToolCalls = wireToolCalls.map(({ tc, id }) => ({ id, name: namespacedToolName(tc.namespace, tc.name) }));
|
|
@@ -403,7 +413,7 @@ export function messagesToChatFormat(parsed: OcxParsedRequest, provider: OcxProv
|
|
|
403
413
|
: { reasoning_content: orphanReasoning };
|
|
404
414
|
out.push({
|
|
405
415
|
role: "assistant",
|
|
406
|
-
content: emptyAssistantContent(provider),
|
|
416
|
+
content: emptyAssistantContent(provider, parsed.modelId),
|
|
407
417
|
...orphanReasoningFields,
|
|
408
418
|
tool_calls: [{
|
|
409
419
|
id: toolCallId,
|
|
@@ -429,7 +439,7 @@ export function messagesToChatFormat(parsed: OcxParsedRequest, provider: OcxProv
|
|
|
429
439
|
|
|
430
440
|
flushPendingToolCalls();
|
|
431
441
|
releaseDeferredBarriers();
|
|
432
|
-
return out;
|
|
442
|
+
return singleLeadingSystemMessages(out, provider) as unknown[];
|
|
433
443
|
}
|
|
434
444
|
|
|
435
445
|
export function safeToolName(name: string | undefined): string {
|
|
@@ -438,8 +448,11 @@ export function safeToolName(name: string | undefined): string {
|
|
|
438
448
|
return sanitized;
|
|
439
449
|
}
|
|
440
450
|
|
|
441
|
-
export function emptyAssistantContent(provider: OcxProviderConfig): string | { type: "text"; text: string }[] {
|
|
442
|
-
|
|
451
|
+
export function emptyAssistantContent(provider: OcxProviderConfig, modelId = ""): string | { type: "text"; text: string }[] {
|
|
452
|
+
// Kimi K3.1 Pro rejects Ark's legacy empty-text array during tool continuations.
|
|
453
|
+
const upstreamModelId = provider.modelSuffixBracketStrip ? stripBracketedModelSuffix(modelId) : modelId;
|
|
454
|
+
const kimi31Pro = /^kimi-k3-1-pro(?:-\d{6})?$/.test(upstreamModelId);
|
|
455
|
+
return isVolcengineArkPaygChatTarget(provider) && !kimi31Pro ? [{ type: "text", text: "" }] : "";
|
|
443
456
|
}
|
|
444
457
|
|
|
445
458
|
/** Reconstruct completed text-only thinking; never invent signatures or placeholder reasoning. */
|
|
@@ -3,6 +3,7 @@ import { openAIChatTransport, stripBracketedModelSuffix } from "./wire";
|
|
|
3
3
|
import type { AdapterRequest } from "../base";
|
|
4
4
|
import { frameAgentRouterMessages } from "../agentrouter";
|
|
5
5
|
import { applyExplicitChatDeveloperRole } from "./developer-role";
|
|
6
|
+
import { singleLeadingSystemMessages } from "./single-system";
|
|
6
7
|
import { openRouterProviderPayload, resolveOpenRouterRouting } from "../../providers/openrouter-routing";
|
|
7
8
|
import { resolveVercelGatewayRouting, vercelGatewayProviderPayload } from "../../providers/vercel-gateway-routing";
|
|
8
9
|
import { fastPolicyForModel } from "../../providers/service-tier";
|
|
@@ -77,10 +78,11 @@ export function buildOpenAIChatPassthroughRequest(
|
|
|
77
78
|
// and the conversion changes the role of those messages and nothing else, so the position
|
|
78
79
|
// of every message and every other field survive unchanged. Missing thinking history is
|
|
79
80
|
// repaired below using the same preserve policy as the translated Chat builder.
|
|
80
|
-
|
|
81
|
+
// The explicit single-system policy can then merge instruction slots.
|
|
82
|
+
messages: singleLeadingSystemMessages(applyExplicitChatDeveloperRole(
|
|
81
83
|
frameAgentRouterMessages(provider.baseUrl, rawBody.messages),
|
|
82
84
|
provider,
|
|
83
|
-
),
|
|
85
|
+
), provider),
|
|
84
86
|
stream,
|
|
85
87
|
};
|
|
86
88
|
for (const field of CHAT_PASSTHROUGH_FIELDS) {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { OcxProviderConfig } from "../../types";
|
|
2
|
+
|
|
3
|
+
/** Normalize the outbound copy only; history and non-instruction messages stay intact. */
|
|
4
|
+
export function singleLeadingSystemMessages(messages: unknown, provider: OcxProviderConfig): unknown {
|
|
5
|
+
if (provider.singleLeadingSystemMessage !== true || !Array.isArray(messages)) return messages;
|
|
6
|
+
const instructions: string[] = [];
|
|
7
|
+
const remaining: unknown[] = [];
|
|
8
|
+
for (const message of messages) {
|
|
9
|
+
if (message === null || typeof message !== "object" || Array.isArray(message)
|
|
10
|
+
|| (message.role !== "system" && message.role !== "developer")) {
|
|
11
|
+
remaining.push(message);
|
|
12
|
+
continue;
|
|
13
|
+
}
|
|
14
|
+
const content: unknown = message.content;
|
|
15
|
+
if (typeof content === "string") instructions.push(content);
|
|
16
|
+
else if (Array.isArray(content) && content.every(part => part !== null && typeof part === "object"
|
|
17
|
+
&& part.type === "text" && typeof part.text === "string")) {
|
|
18
|
+
instructions.push(content.map(part => part.text).join(""));
|
|
19
|
+
} else {
|
|
20
|
+
throw new Error("singleLeadingSystemMessage requires text-only system/developer content");
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return instructions.length > 0 ? [{ role: "system", content: instructions.join("\n\n") }, ...remaining] : messages;
|
|
24
|
+
}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
namespacedToolName,
|
|
3
|
+
type AdapterEvent,
|
|
4
|
+
type OcxParsedRequest,
|
|
5
|
+
type OcxProviderConfig,
|
|
6
|
+
type OcxUsage,
|
|
7
|
+
type TierDecision,
|
|
8
|
+
} from "../../types";
|
|
2
9
|
import { stripItemIdsWhenUnstored } from "./request-strips";
|
|
3
10
|
import { isPlainObject } from "./internal";
|
|
4
11
|
import { stripPromptCacheBreakpoints } from "./prompt-cache";
|
|
@@ -15,13 +22,21 @@ import { stripPromptCacheBreakpoints } from "./prompt-cache";
|
|
|
15
22
|
* unexpanded requests: the platform `/v1/responses` supports real server-side storage.
|
|
16
23
|
*/
|
|
17
24
|
export function stripPreviousResponseId(body: unknown, strip: boolean): unknown {
|
|
18
|
-
if (
|
|
25
|
+
if (
|
|
26
|
+
!strip ||
|
|
27
|
+
!isPlainObject(body) ||
|
|
28
|
+
!Object.prototype.hasOwnProperty.call(body, "previous_response_id")
|
|
29
|
+
)
|
|
30
|
+
return body;
|
|
19
31
|
const { previous_response_id: _previousResponseId, ...rest } = body;
|
|
20
32
|
return rest;
|
|
21
33
|
}
|
|
22
34
|
|
|
23
35
|
/** Apply the settled tier only to a fresh outbound object; `_rawBody` remains caller-owned. */
|
|
24
|
-
export function applyTierDecisionToResponsesBody(
|
|
36
|
+
export function applyTierDecisionToResponsesBody(
|
|
37
|
+
body: unknown,
|
|
38
|
+
decision: TierDecision | undefined,
|
|
39
|
+
): unknown {
|
|
25
40
|
if (!decision || decision.kind === "forward-caller" || !isPlainObject(body)) return body;
|
|
26
41
|
const next: Record<string, unknown> = { ...body };
|
|
27
42
|
if (decision.kind === "set") next.service_tier = decision.value;
|
|
@@ -54,8 +69,14 @@ export function applyTierDecisionToResponsesBody(body: unknown, decision: TierDe
|
|
|
54
69
|
*/
|
|
55
70
|
export function stripStatefulResponsesParams(body: unknown): unknown {
|
|
56
71
|
if (!isPlainObject(body)) return body;
|
|
57
|
-
const drop = [
|
|
58
|
-
|
|
72
|
+
const drop = [
|
|
73
|
+
"previous_response_id",
|
|
74
|
+
"conversation",
|
|
75
|
+
"background",
|
|
76
|
+
"metadata",
|
|
77
|
+
"prompt",
|
|
78
|
+
] as const;
|
|
79
|
+
const present = drop.some((key) => Object.prototype.hasOwnProperty.call(body, key));
|
|
59
80
|
if (!present && body.store === false) return body;
|
|
60
81
|
const next: Record<string, unknown> = { ...body };
|
|
61
82
|
for (const key of drop) delete next[key];
|
|
@@ -77,11 +98,19 @@ export function stripStatefulResponsesParams(body: unknown): unknown {
|
|
|
77
98
|
* self-hosted or third-party gateway may honour it — dropping it there silently
|
|
78
99
|
* removes the cap. Only the canonical ChatGPT backend rejects it outright, so only
|
|
79
100
|
* `canonical` callers strip it.
|
|
101
|
+
*
|
|
102
|
+
* `safety_identifier` is the third canonical-only drop: a public OpenAI-platform
|
|
103
|
+
* parameter some BYOK clients (droid's registry-matched models) attach from the
|
|
104
|
+
* model name alone. The official API-key surface accepts it, but the canonical
|
|
105
|
+
* ChatGPT backend rejects it with the same strict-allowlist envelope, so only
|
|
106
|
+
* `canonical` callers strip it.
|
|
80
107
|
*/
|
|
81
108
|
export function stripUnsupportedForwardParams(body: unknown, canonical: boolean): unknown {
|
|
82
109
|
if (!isPlainObject(body)) return body;
|
|
83
|
-
const drop = canonical
|
|
84
|
-
|
|
110
|
+
const drop = canonical
|
|
111
|
+
? (["metadata", "max_output_tokens", "safety_identifier"] as const)
|
|
112
|
+
: (["metadata"] as const);
|
|
113
|
+
if (!drop.some((key) => Object.hasOwn(body, key))) return body;
|
|
85
114
|
const next: Record<string, unknown> = { ...body };
|
|
86
115
|
for (const key of drop) delete next[key];
|
|
87
116
|
return next;
|
|
@@ -104,7 +133,11 @@ const CANONICAL_FORWARD_UNSUPPORTED_SAMPLING = ["temperature", "top_p", "stop",
|
|
|
104
133
|
*/
|
|
105
134
|
export function stripCanonicalForwardSamplingParams(body: unknown): unknown {
|
|
106
135
|
if (!isPlainObject(body)) return body;
|
|
107
|
-
if (
|
|
136
|
+
if (
|
|
137
|
+
!CANONICAL_FORWARD_UNSUPPORTED_SAMPLING.some((key) =>
|
|
138
|
+
Object.prototype.hasOwnProperty.call(body, key),
|
|
139
|
+
)
|
|
140
|
+
) {
|
|
108
141
|
return body;
|
|
109
142
|
}
|
|
110
143
|
const next: Record<string, unknown> = { ...body };
|
|
@@ -130,9 +163,11 @@ function canonicalForwardSystemText(item: Record<string, unknown>): string | nul
|
|
|
130
163
|
|
|
131
164
|
/** Only message items may carry privileged system instructions. */
|
|
132
165
|
function isCanonicalForwardSystemMessage(item: unknown): item is Record<string, unknown> {
|
|
133
|
-
return
|
|
134
|
-
|
|
135
|
-
|
|
166
|
+
return (
|
|
167
|
+
isPlainObject(item) &&
|
|
168
|
+
(item.type === undefined || item.type === "message") &&
|
|
169
|
+
item.role === "system"
|
|
170
|
+
);
|
|
136
171
|
}
|
|
137
172
|
|
|
138
173
|
/**
|
|
@@ -172,7 +207,7 @@ export function normalizeCanonicalForwardPromptEnvelope(body: unknown): unknown
|
|
|
172
207
|
const next: Record<string, unknown> = { ...body };
|
|
173
208
|
if (stripTruncation) delete next.truncation;
|
|
174
209
|
if (sawSystemMessage && canFoldAllSystemMessages) {
|
|
175
|
-
next.input = input.filter(item => !isCanonicalForwardSystemMessage(item));
|
|
210
|
+
next.input = input.filter((item) => !isCanonicalForwardSystemMessage(item));
|
|
176
211
|
const folded = foldedText.join("\n\n");
|
|
177
212
|
if (folded !== "") {
|
|
178
213
|
const existing = typeof body.instructions === "string" ? body.instructions : "";
|
|
@@ -193,7 +228,9 @@ export function normalizeCanonicalForwardContinuationEnvelope(body: unknown): un
|
|
|
193
228
|
let input: unknown[] = body.input;
|
|
194
229
|
let changed = false;
|
|
195
230
|
if (body.store === false) {
|
|
196
|
-
const withoutReferences = input.filter(
|
|
231
|
+
const withoutReferences = input.filter(
|
|
232
|
+
(item) => !isPlainObject(item) || item.type !== "item_reference",
|
|
233
|
+
);
|
|
197
234
|
if (withoutReferences.length !== input.length) {
|
|
198
235
|
input = withoutReferences;
|
|
199
236
|
changed = true;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { isPlainObject } from "./internal";
|
|
2
|
+
import { promoteClientLoadedTools } from "./tool-schema";
|
|
3
|
+
import { rewriteRoutedCustomToolsForUpstream } from "../../responses/custom-tool-compat";
|
|
4
|
+
import { hasItemProvenance, isHistoricalItem } from "../../responses/item-provenance";
|
|
5
|
+
|
|
6
|
+
export class MuseToolCatalogCompatibilityError extends Error {
|
|
7
|
+
constructor() {
|
|
8
|
+
super("Malformed tool catalog for Meta Responses.");
|
|
9
|
+
this.name = "MuseToolCatalogCompatibilityError";
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function isRepresentableName(name: unknown): name is string {
|
|
14
|
+
return typeof name === "string" && name.length > 0
|
|
15
|
+
&& [...name].every(character => character.charCodeAt(0) > 0x1f && character.charCodeAt(0) !== 0x7f);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function normalizeCatalog(tools: unknown, inNamespace = false): Record<string, unknown>[] {
|
|
19
|
+
if (!Array.isArray(tools)) throw new MuseToolCatalogCompatibilityError();
|
|
20
|
+
return tools.flatMap(tool => {
|
|
21
|
+
if (!isPlainObject(tool) || typeof tool.type !== "string") throw new MuseToolCatalogCompatibilityError();
|
|
22
|
+
if (inNamespace && tool.type !== "function" && tool.type !== "custom") throw new MuseToolCatalogCompatibilityError();
|
|
23
|
+
if (tool.type === "function" && isPlainObject(tool.function)) {
|
|
24
|
+
const { function: definition, ...outer } = tool;
|
|
25
|
+
tool = { ...outer, ...definition, type: "function" };
|
|
26
|
+
}
|
|
27
|
+
if (["namespace", "function", "custom"].includes(tool.type)
|
|
28
|
+
&& !isRepresentableName(tool.name)) throw new MuseToolCatalogCompatibilityError();
|
|
29
|
+
if (tool.type !== "namespace") return [tool];
|
|
30
|
+
return [{ ...tool, tools: normalizeCatalog(tool.tools, true) }];
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function flattenBuiltinNamespace(tools: Record<string, unknown>[]): Record<string, unknown>[] {
|
|
35
|
+
const bareNames = new Set(tools.filter(tool => tool.type !== "namespace").map(tool => tool.name));
|
|
36
|
+
return tools.flatMap(tool => {
|
|
37
|
+
if (tool.type !== "namespace" || tool.name !== "functions") return [tool];
|
|
38
|
+
// Match namespace lowering: an explicit bare declaration owns this identity,
|
|
39
|
+
// even when it occurs later or in a different current declaration carrier.
|
|
40
|
+
return (tool.tools as Record<string, unknown>[]).filter(child => !bareNames.has(child.name))
|
|
41
|
+
.map(child => tool.defer_loading === undefined ? child : { defer_loading: tool.defer_loading, ...child });
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Meta rejects Codex's additional_tools input items. Capture the current catalog
|
|
47
|
+
* before history rewrites can shift the replay boundary or consume duplicate names.
|
|
48
|
+
* Historical messages and search results remain replay context, never declarations.
|
|
49
|
+
* The caller gates this projection on the actual Meta destination.
|
|
50
|
+
*/
|
|
51
|
+
export function normalizeMuseToolCatalog(body: unknown, replayPrefixLength = 0, supportsCustomTools?: boolean): unknown {
|
|
52
|
+
if (!isPlainObject(body)) return body;
|
|
53
|
+
// Namespace lowering drops malformed groups; reject them before any partial promotion.
|
|
54
|
+
const topLevelTools = body.tools === undefined ? undefined : normalizeCatalog(body.tools);
|
|
55
|
+
if (!Array.isArray(body.input)) return topLevelTools === undefined ? body : { ...body, tools: flattenBuiltinNamespace(topLevelTools) };
|
|
56
|
+
const start = Number.isFinite(replayPrefixLength)
|
|
57
|
+
? Math.min(body.input.length, Math.max(0, Math.trunc(replayPrefixLength))) : 0;
|
|
58
|
+
// Item provenance owns membership once present: an earlier rewrite (Zed lifting a replayed
|
|
59
|
+
// wrapper) may already have shortened the input below the numeric prefix.
|
|
60
|
+
const originalInput: unknown[] = body.input;
|
|
61
|
+
const tagged = originalInput.some(hasItemProvenance);
|
|
62
|
+
const isCurrent = (item: unknown, index: number) => tagged ? !isHistoricalItem(item) : index >= start;
|
|
63
|
+
const normalizedInput = body.input.map((item, index) => {
|
|
64
|
+
if (!isCurrent(item, index)) return item;
|
|
65
|
+
if (isPlainObject(item) && (item.type === "additional_tools"
|
|
66
|
+
|| (item.type === "tool_search_output" && item.tools !== undefined))) {
|
|
67
|
+
const tools = normalizeCatalog(item.tools);
|
|
68
|
+
return { ...item, tools: item.type === "tool_search_output" ? flattenBuiltinNamespace(tools) : tools };
|
|
69
|
+
}
|
|
70
|
+
return item;
|
|
71
|
+
});
|
|
72
|
+
const currentInput = normalizedInput.filter((_item, index) => isCurrent(originalInput[index], index));
|
|
73
|
+
const declared = [...(topLevelTools ?? [])];
|
|
74
|
+
for (const item of currentInput) {
|
|
75
|
+
if (isPlainObject(item) && item.type === "additional_tools" && Array.isArray(item.tools)) declared.push(...item.tools);
|
|
76
|
+
}
|
|
77
|
+
// All current declarations precede discoveries, regardless of their carrier.
|
|
78
|
+
const current = promoteClientLoadedTools({ ...body, tools: flattenBuiltinNamespace(declared), input: currentInput });
|
|
79
|
+
const tools = isPlainObject(current) && Array.isArray(current.tools) ? current.tools : declared;
|
|
80
|
+
// Replay still needs the old declarations to lower custom calls and their outputs.
|
|
81
|
+
// Retain only that input projection, never the historical declaration/restore sets.
|
|
82
|
+
const replay = rewriteRoutedCustomToolsForUpstream({ ...body, input: normalizedInput }, supportsCustomTools).body;
|
|
83
|
+
const replayInput = isPlainObject(replay) && Array.isArray(replay.input) ? replay.input : normalizedInput;
|
|
84
|
+
const input = replayInput.filter(item => !isPlainObject(item) || item.type !== "additional_tools");
|
|
85
|
+
const hasCatalog = topLevelTools !== undefined || tools.length > 0 || input.length !== body.input.length;
|
|
86
|
+
return { ...body, input, ...(hasCatalog ? { tools } : {}) };
|
|
87
|
+
}
|