switchboard-router 0.9.30 → 0.9.32
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/app/{.next-cli-build/static/chunks/1321-13f34411b35e731e.js → .next/static/chunks/1321-8a3603dbafbb81bb.js} +1 -1
- package/app/.next/static/chunks/979-04a907a12847a634.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/combos/page-99d3be5c7da63d57.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/combos/routing/{page-ef491ec5a2ccecfb.js → page-650dc0927f999aaf.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/[id]/page-68344fb15a77b2c5.js +10 -0
- package/app/.next-cli-build/BUILD_ID +1 -1
- package/app/.next-cli-build/app-path-routes-manifest.json +16 -16
- package/app/.next-cli-build/build-manifest.json +2 -2
- package/app/.next-cli-build/prerender-manifest.json +3 -3
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/agent-library/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/agent-library/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/basic-chat/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/basic-chat/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/routing/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/routing/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/routing/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/mitm/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/mitm/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page.js +2 -2
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/pxpipe/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/pxpipe/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/[id]/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/[id]/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/_global-error/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/_global-error.html +1 -1
- package/app/.next-cli-build/server/app/_global-error.rsc +1 -1
- package/app/.next-cli-build/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/_not-found/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/_not-found.html +1 -1
- package/app/.next-cli-build/server/app/_not-found.rsc +3 -3
- package/app/.next-cli-build/server/app/_not-found.segments/_full.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/api/agent-library/catalog/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/agent-library/doctor/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/agent-library/export/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/agent-library/mcp/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/agent-library/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/agent-library/skills/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/agent-library/sync/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/agent-library/updates/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/auth/login/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/auth/logout/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/auth/status/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/aider-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/aider-settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/all-statuses/route.js +5 -5
- package/app/.next-cli-build/server/app/api/cli-tools/all-statuses/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/alias/route.js +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/alias/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/claude-full-catalog/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/claude-picker-labels/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/claude-settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/cline-settings/route.js +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/cline-settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/codex-settings/route.js +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/codex-settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-registry/route.js +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-registry/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-tools/route.js +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-tools/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/cowork-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/cowork-settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/deepseek-tui-settings/route.js +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/deepseek-tui-settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/droid-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/droid-settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/gemini-cli-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/gemini-cli-settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/grok-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/grok-settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/hermes-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/hermes-settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/jcode-settings/route.js +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/jcode-settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/kilo-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/kilo-settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/openclaw-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/openclaw-settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/opencode-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/opencode-settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/pi-settings/route.js +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/pi-settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/picker-labels/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/combos/[id]/route.js +1 -1
- package/app/.next-cli-build/server/app/api/combos/[id]/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/combos/route.js +1 -1
- package/app/.next-cli-build/server/app/api/combos/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/headroom/extras/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/headroom/proxy/[...path]/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/headroom/restart/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/headroom/start/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/headroom/status/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/headroom/stop/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/health/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/keys/[id]/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/keys/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/locale/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/mcp/[plugin]/message/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/mcp/[plugin]/sse/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/media-providers/tts/deepgram/voices/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/media-providers/tts/elevenlabs/voices/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/media-providers/tts/inworld/voices/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/media-providers/tts/minimax/voices/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/media-providers/tts/voices/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/mgmt/v1/combos/[id]/route.js +1 -1
- package/app/.next-cli-build/server/app/api/mgmt/v1/combos/[id]/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/mgmt/v1/combos/[id]/strategy/route.js +1 -1
- package/app/.next-cli-build/server/app/api/mgmt/v1/combos/[id]/strategy/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/mgmt/v1/combos/route.js +1 -1
- package/app/.next-cli-build/server/app/api/mgmt/v1/combos/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/mgmt/v1/health/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/mgmt/v1/metrics/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/mgmt/v1/providers/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/mgmt/v1/routing/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/mgmt/v1/usage/route.js +1 -1
- package/app/.next-cli-build/server/app/api/mgmt/v1/usage/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/mgmt/v1/version/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/models/alias/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/models/availability/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/models/custom/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/models/disabled/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/models/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/models/test/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/oauth/[provider]/[action]/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/oauth/codex/bulk-import/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/oauth/codex/import-token/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/oauth/cursor/auto-import/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/oauth/cursor/import/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/oauth/gitlab/pat/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/oauth/iflow/cookie/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/oauth/kiro/api-key/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/oauth/kiro/auto-import/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/oauth/kiro/import/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/oauth/kiro/import-cli-proxy/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/oauth/kiro/social-authorize/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/oauth/kiro/social-exchange/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/pricing/defaults/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/pricing/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/provider-nodes/[id]/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/provider-nodes/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/provider-nodes/validate/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/batch/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/cache/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/prepare/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/remove-unavailable/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/verify/cancel/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/verify/start/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/verify/status/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/[id]/models/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/[id]/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/[id]/test/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/[id]/test-models/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/client/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/kilo/free-models/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/suggested-models/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/test-batch/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/validate/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/pxpipe/health/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/pxpipe/install/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/pxpipe/logs/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/pxpipe/restart/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/pxpipe/start/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/pxpipe/stats/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/pxpipe/status/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/pxpipe/stop/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/routing/feedback/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/routing/insights/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/routing/learn/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/routing/stats/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/routing/versions/promote/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/routing/versions/rollback/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/settings/database/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/settings/proxy-test/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/settings/route.js +1 -1
- package/app/.next-cli-build/server/app/api/settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/shutdown/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/skills/[id]/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/tags/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/token-saver/vault-stats/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/translator/console-logs/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/translator/console-logs/stream/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/translator/load/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/translator/save/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/translator/send/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/translator/translate/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/usage/[connectionId]/codex-reset-credits/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/usage/[connectionId]/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/usage/chart/route.js +1 -1
- package/app/.next-cli-build/server/app/api/usage/chart/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/usage/history/route.js +1 -1
- package/app/.next-cli-build/server/app/api/usage/history/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/usage/logs/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/usage/providers/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/usage/request-details/[id]/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/usage/request-details/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/usage/request-logs/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/usage/stats/route.js +1 -1
- package/app/.next-cli-build/server/app/api/usage/stats/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/usage/stream/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/api/chat/route.js +1 -1
- package/app/.next-cli-build/server/app/api/v1/api/chat/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/audio/speech/route.js +1 -1
- package/app/.next-cli-build/server/app/api/v1/audio/speech/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/audio/transcriptions/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/audio/voices/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/chat/completions/route.js +1 -1
- package/app/.next-cli-build/server/app/api/v1/chat/completions/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/embeddings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/images/generations/route.js +2 -2
- package/app/.next-cli-build/server/app/api/v1/images/generations/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/messages/count_tokens/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/messages/route.js +1 -1
- package/app/.next-cli-build/server/app/api/v1/messages/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/models/[kind]/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/models/info/route.js +1 -1
- package/app/.next-cli-build/server/app/api/v1/models/info/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/models/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/responses/compact/route.js +1 -1
- package/app/.next-cli-build/server/app/api/v1/responses/compact/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/responses/route.js +1 -1
- package/app/.next-cli-build/server/app/api/v1/responses/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/search/route.js +1 -1
- package/app/.next-cli-build/server/app/api/v1/search/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/videos/[id]/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/videos/edits/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/videos/extensions/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/videos/generations/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/web/fetch/route.js +1 -1
- package/app/.next-cli-build/server/app/api/v1/web/fetch/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1beta/models/[...path]/route.js +1 -1
- package/app/.next-cli-build/server/app/api/v1beta/models/[...path]/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1beta/models/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/version/route.js +1 -1
- package/app/.next-cli-build/server/app/api/version/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/version/shutdown/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/version/update/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/callback/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/callback/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/callback.html +1 -1
- package/app/.next-cli-build/server/app/callback.rsc +3 -3
- package/app/.next-cli-build/server/app/callback.segments/_full.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/callback.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/callback.segments/callback/__PAGE__.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/dashboard/settings/pricing/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.rsc +3 -3
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_full.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing/__PAGE__.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/favicon.ico/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/index.html +1 -1
- package/app/.next-cli-build/server/app/index.rsc +3 -3
- package/app/.next-cli-build/server/app/index.segments/__PAGE__.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/index.segments/_full.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/index.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/landing/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/landing/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/landing.html +1 -1
- package/app/.next-cli-build/server/app/landing.rsc +3 -3
- package/app/.next-cli-build/server/app/landing.segments/_full.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/landing.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/landing.segments/landing/__PAGE__.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/login/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/login/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/login.html +1 -1
- package/app/.next-cli-build/server/app/login.rsc +4 -4
- package/app/.next-cli-build/server/app/login.segments/_full.segment.rsc +4 -4
- package/app/.next-cli-build/server/app/login.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/login.segments/login/__PAGE__.segment.rsc +4 -4
- package/app/.next-cli-build/server/app/manifest.webmanifest/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app-paths-manifest.json +16 -16
- package/app/.next-cli-build/server/chunks/3423.js +1 -1
- package/app/.next-cli-build/server/chunks/369.js +1 -1
- package/app/.next-cli-build/server/chunks/403.js +1 -1
- package/app/.next-cli-build/server/chunks/519.js +1 -1
- package/app/.next-cli-build/server/chunks/5624.js +1 -0
- package/app/.next-cli-build/server/chunks/5717.js +2 -2
- package/app/.next-cli-build/server/chunks/7454.js +1 -1
- package/app/.next-cli-build/server/chunks/8400.js +9 -9
- package/app/.next-cli-build/server/chunks/845.js +1 -0
- package/app/.next-cli-build/server/chunks/869.js +1 -1
- package/app/.next-cli-build/server/chunks/8998.js +18 -18
- package/app/.next-cli-build/server/chunks/9261.js +3 -3
- package/app/.next-cli-build/server/chunks/9264.js +2 -2
- package/app/.next-cli-build/server/middleware-build-manifest.js +1 -1
- package/app/.next-cli-build/server/middleware.js +1 -1
- package/app/.next-cli-build/server/pages/404.html +1 -1
- package/app/.next-cli-build/server/pages/500.html +1 -1
- package/app/.next-cli-build/server/server-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/server-reference-manifest.json +1 -1
- package/app/{.next/static/chunks/1321-13f34411b35e731e.js → .next-cli-build/static/chunks/1321-8a3603dbafbb81bb.js} +1 -1
- package/app/.next-cli-build/static/chunks/979-04a907a12847a634.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/combos/page-99d3be5c7da63d57.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/combos/routing/{page-ef491ec5a2ccecfb.js → page-650dc0927f999aaf.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/[id]/page-68344fb15a77b2c5.js +10 -0
- package/app/open-sse/identity/tls/bin/darwin/arm64/switchboard-claude-tls +0 -0
- package/app/open-sse/identity/tls/bin/darwin/x64/switchboard-claude-tls +0 -0
- package/app/open-sse/identity/tls/bin/linux/arm64/switchboard-claude-tls +0 -0
- package/app/open-sse/identity/tls/bin/linux/x64/switchboard-claude-tls +0 -0
- package/app/open-sse/identity/tls/bin/win32/arm64/switchboard-claude-tls.exe +0 -0
- package/app/open-sse/identity/tls/bin/win32/x64/switchboard-claude-tls.exe +0 -0
- package/app/package.json +3 -3
- package/package.json +3 -3
- package/app/.next/static/chunks/app/(dashboard)/dashboard/combos/page-aaae06cada500532.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/[id]/page-cb9292ca42b61d7d.js +0 -10
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/combos/page-aaae06cada500532.js +0 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/[id]/page-cb9292ca42b61d7d.js +0 -10
- /package/app/.next/static/{8awSzIlM7UdH1TIvRhWJI → e7Ha89rDlp2qPIlpARdsI}/_buildManifest.js +0 -0
- /package/app/.next/static/{8awSzIlM7UdH1TIvRhWJI → e7Ha89rDlp2qPIlpARdsI}/_ssgManifest.js +0 -0
- /package/app/.next-cli-build/static/{8awSzIlM7UdH1TIvRhWJI → e7Ha89rDlp2qPIlpARdsI}/_buildManifest.js +0 -0
- /package/app/.next-cli-build/static/{8awSzIlM7UdH1TIvRhWJI → e7Ha89rDlp2qPIlpARdsI}/_ssgManifest.js +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[979],{35497:(e,t,r)=>{r.d(t,{x0:()=>P.default,Ex:()=>f.default,$n:()=>n.default,nh:()=>M.default,Zp:()=>u.default,Qv:()=>i.CardSkeleton,CK:()=>m.default,uo:()=>d.ConfirmModal,G9:()=>b.default,wI:()=>$.default,vj:()=>g.default,vE:()=>v.default,pd:()=>a.default,Mh:()=>k.default,uR:()=>h.default,Nf:()=>w.default,aF:()=>d.default,rq:()=>y.default,gw:()=>S.default,LF:()=>s.default,Wx:()=>A.default,gM:()=>c.default,Iz:()=>C.default,l6:()=>o.default,lM:()=>l.default,m_:()=>z.default,jK:()=>p.default});var n=r(92542),a=r(11910),o=r(98),u=r(84588),d=r(81127),i=r(25086);r(56319);var f=r(56061),l=r(98542);r(61929),r(21110),r(92622),r(8823),r(92173);var s=r(90882),y=r(72908),h=r(28815),m=r(45455),w=r(28058),p=r(4809);r(21931),r(80752),r(40197);var c=r(23615);r(44736);var k=r(62899);r(94230);var b=r(30815),v=r(23936),g=r(95088),$=r(73579),P=r(96748),S=r(4823),C=r(28067),z=r(97677),A=r(51825),M=r(29366);r(76361),r(91450)},68875:(e,t,r)=>{r.d(t,{NA:()=>a,WX:()=>c,Z3:()=>g,Z9:()=>i,bC:()=>p,de:()=>o,v2:()=>b,yW:()=>w,zt:()=>v});let n=["peak","offPeak"],a=["always","peak-only","off-peak-only"],o=["mon","tue","wed","thu","fri","sat","sun"],u=new Set(o),d=/^([01]\d|2[0-3]):([0-5]\d)$/,i=[{id:"deepseek-current",label:"DeepSeek (current): peak 01:00–04:00 & 06:00–10:00 UTC, Mon–Fri",config:{timezone:"UTC",defaultState:"offPeak",windows:[{type:"peak",start:"01:00",end:"04:00",days:["mon","tue","wed","thu","fri"]},{type:"peak",start:"06:00",end:"10:00",days:["mon","tue","wed","thu","fri"]}]}},{id:"deepseek-2025-02",label:"DeepSeek (Feb 2025): off-peak 16:30–00:30 UTC daily",config:{timezone:"UTC",defaultState:"peak",windows:[{type:"offPeak",start:"16:30",end:"00:30"}]}}],f=new Map;function l(e){let t=f.get(e);return t||(t=new Intl.DateTimeFormat("en-US",{timeZone:e,hourCycle:"h23",weekday:"short",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),f.set(e,t)),t}function s(e,t){let r={};for(let n of l(t).formatToParts(new Date(e)))"literal"!==n.type&&(r[n.type]=n.value);let n=Number(r.hour),a=Number(r.minute);return{weekday:r.weekday.toLowerCase(),year:Number(r.year),month:Number(r.month),day:Number(r.day),hour:n,minute:a,minutes:60*n+a}}function y(e,t){let r=Date.UTC(e.year,e.month-1,e.day,e.hour,e.minute),n=r;for(let e=0;e<3;e++){let e=s(n,t),a=Date.UTC(e.year,e.month-1,e.day,e.hour,e.minute)-r;if(0===a)break;n-=a}return n}function h(e){let t=d.exec(String(e||""));return t?60*Number(t[1])+Number(t[2]):-1}function m(e){return new Set(Array.isArray(e?.days)&&e.days.length?e.days.filter(e=>u.has(e)):o)}function w(e,t=Date.now()){if(!e||"object"!=typeof e||!Array.isArray(e.windows)||!e.windows.length)return"unscheduled";try{let r="string"==typeof e.timezone&&e.timezone?e.timezone:"UTC",n=s(t,r);for(let t of e.windows)if(t&&"object"==typeof t&&function(e,t,r,n){let a=h(e.start),u=h(e.end);if(a<0||u<0||a===u)return!1;if(a<u)return t.has(r)&&n>=a&&n<u;if(t.has(r)&&n>=a)return!0;let d=(o.indexOf(r)+6)%7,i=o[d];return t.has(i)&&n<u}(t,m(t),n.weekday,n.minutes))return"peak"===t.type?"peak":"offPeak";return"peak"===e.defaultState?"peak":"offPeak"}catch{return"unscheduled"}}function p(e,t=Date.now()){let r=w(e,t);if("unscheduled"===r)return null;let n="string"==typeof e.timezone&&e.timezone?e.timezone:"UTC",a=[],o=s(t,n);for(let t=-1;t<8;t++){let r=s(y({year:o.year,month:o.month,day:o.day,hour:12,minute:0},n)+864e5*t,n),u=s(y({year:o.year,month:o.month,day:o.day,hour:12,minute:0},n)+(t-1)*864e5,n);for(let t of e.windows){if(!t||"object"!=typeof t)continue;let e=h(t.start),o=h(t.end);if(e<0||o<0||e===o)continue;let d=m(t),i={year:r.year,month:r.month,day:r.day,hour:0,minute:0},f=e=>(function(e,t){let r=y(e,t),n=r+36e5,a=s(r,t),o=s(n,t);return a.year===o.year&&a.month===o.month&&a.day===o.day&&a.hour===o.hour&&a.minute===o.minute?[r,n]:[r]})({...i,hour:Math.floor(e/60),minute:e%60},n);d.has(r.weekday)&&(a.push(...f(e)),o>e&&a.push(...f(o))),o<e&&d.has(u.weekday)&&a.push(...f(o))}}for(let n of(a.sort((e,t)=>e-t),a))if(!(n<=t)&&w(e,n)!==r)return n;return null}function c(e){let t="string"==typeof e?e:String(e??""),r=t.indexOf("/");return -1===r?t:t.slice(0,r)}function k(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function b(e,t){if(!k(e))return{error:`Provider "${t}" schedule must be an object.`};let r=("string"==typeof e.timezone?e.timezone.trim():"")||"UTC";if(!function(e){if("string"!=typeof e||!e)return!1;try{return l(e),!0}catch{return f.delete(e),!1}}(r))return{error:`Provider "${t}" schedule timezone "${r}" is not a valid IANA zone.`};let a=r;try{a=l(r).resolvedOptions().timeZone||r}catch{}if(!Array.isArray(e.windows)||0===e.windows.length)return{error:`Provider "${t}" schedule needs at least one time window.`};if(e.windows.length>14)return{error:`Provider "${t}" schedule allows at most 14 windows.`};if(null!=e.defaultState&&!n.includes(e.defaultState))return{error:`Provider "${t}" defaultState must be "peak" or "offPeak".`};let i=[];for(let[r,n]of e.windows.entries()){if(!k(n))return{error:`Provider "${t}" window ${r+1} must be an object.`};if("peak"!==n.type&&"offPeak"!==n.type)return{error:`Provider "${t}" window ${r+1} type must be "peak" or "offPeak".`};if(!d.test(String(n.start||""))||!d.test(String(n.end||"")))return{error:`Provider "${t}" window ${r+1} start/end must be HH:MM (24h).`};if(n.start===n.end)return{error:`Provider "${t}" window ${r+1} start and end must differ.`};let e=o;if(void 0!==n.days){if(!Array.isArray(n.days)||!n.days.length||!n.days.every(e=>u.has(e)))return{error:`Provider "${t}" window ${r+1} days must be a non-empty subset of ${o.join(", ")}.`};e=[...new Set(n.days)].sort((e,t)=>o.indexOf(e)-o.indexOf(t))}i.push({type:n.type,start:n.start,end:n.end,days:e})}return{value:{timezone:a,defaultState:"peak"===e.defaultState?"peak":"offPeak",windows:i}}}function v(e){let t=Math.max(1,Math.round(e/6e4));if(t<60)return`${t} min`;let r=Math.floor(t/60),n=t%60;return n?`${r}h ${n}m`:`${r}h`}function g(e,t){return t?Object.keys(t).filter(t=>"unscheduled"===w(e?.[c(t)])):[]}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3649],{41483:(e,t,a)=>{"use strict";a.d(t,{default:()=>k});var l=a(95155),s=a(12115),r=a(44923),i=a(87256),o=a(39768),n=a(5020),d=a(35497),c=a(11059);a(88105);var m=a(65921),x=a(78559),u=a(47224),p=a(68875);let h={always:"Any time","peak-only":"Peak only","off-peak-only":"Off-peak only"},b=p.NA.map(e=>({value:e,label:h[e]})),f=/^[a-zA-Z0-9_.\-]+$/,g=[{key:"vision",label:"Vision",icon:"visibility",desc:"Images"},{key:"audioInput",label:"Audio",icon:"graphic_eq",desc:"Audio input"}],y={enabled:!0,roundRobin:!1,models:[]},j=Object.keys({vision:{...y},pdf:{...y},audioInput:{...y},videoInput:{...y}});function v(e){return Array.isArray(e)?{enabled:!0,roundRobin:!1,models:e.map(e=>e?.model||e).filter(Boolean)}:e&&"object"==typeof e?{enabled:!1!==e.enabled,roundRobin:!!e.roundRobin,models:Array.isArray(e.models)?e.models.filter(Boolean):[]}:{...y}}function k({initialData:e}){let t=(0,m.i)(e=>e.error),[a,r]=(0,s.useState)(()=>(e?.combos||[]).filter(e=>!e.kind||"llm"===e.kind)),[i,o]=(0,s.useState)(!e),[n,x]=(0,s.useState)(!1),[u,p]=(0,s.useState)(null),[h,b]=(0,s.useState)(e?.connections||[]),[f,g]=(0,s.useState)(e?.settings?.comboStrategies||{}),[y,w]=(0,s.useState)(e?.settings?.providerSchedules||{}),[C,S]=(0,s.useState)(e?.modelCaps||{}),[A,$]=(0,s.useState)(()=>{let t=e?.settings?.capacityAdapter||{},a={};for(let e of j)a[e]=v(t[e]);return a}),[O,E]=(0,s.useState)(null),{copied:P,copy:q}=(0,c.C)(),D=(0,s.useCallback)(async()=>{try{let[e,t,a,l]=await Promise.all([fetch("/api/combos"),fetch("/api/providers"),fetch("/api/settings"),fetch("/api/models")]);if(![e,t,a,l].every(e=>e.ok))throw Error("One or more combo resources failed to load");let s=await e.json(),i=await t.json(),o=await a.json();if(e.ok&&r((s.combos||[]).filter(e=>!e.kind||"llm"===e.kind)),t.ok&&b(i.connections||[]),l.ok){let e=await l.json(),t={};for(let a of e.models||[])a.caps&&(t[a.fullModel]=a.caps);S(t)}g(o.comboStrategies||{}),w(o.providerSchedules||{});let n=o.capacityAdapter||{},d={};for(let e of j)d[e]=v(n[e]);$(d)}catch(e){t("Failed to fetch combo data")}finally{o(!1)}},[t]);(0,s.useEffect)(()=>{e?.combos?o(!1):D()},[e,D]);let[,_]=(0,s.useState)(0),z=Object.keys(y).length>0;(0,s.useEffect)(()=>{if(!z)return;let e=setInterval(()=>_(e=>e+1),3e4);return()=>clearInterval(e)},[z]);let T=async e=>{try{let{strategy:a,capacityAutoSwitch:l,routerModel:s,objective:r,modelAvailability:i,...o}=e,n=await fetch("/api/combos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});if(n.ok){let t=await n.json().catch(()=>({})),d=o.name?.trim()||t?.name;d&&(a||void 0!==l||s||r||i)&&await W(d,N(e)),await D(),x(!1)}else{let e=await n.json();t(e.error||"Failed to create combo")}}catch(e){t("Failed to create combo")}},L=async(e,a)=>{try{let{strategy:l,capacityAutoSwitch:s,routerModel:r,objective:i,modelAvailability:o,...n}=a,d=u?.name,c=await fetch(`/api/combos/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(c.ok){let e=n.name?.trim()||d;if(d&&e&&d!==e&&g(t=>{let a={...t};return d in a&&(e in a||(a[e]=a[d]),delete a[d]),a}),e&&(l||void 0!==s||o)){let t,l=d&&d!==e?(t={...f},d in t&&(e in t||(t[e]=t[d]),delete t[d]),t):f;await W(e,N(a),l)}await D(),p(null)}else{let e=await c.json();t(e.error||"Failed to update combo")}}catch(e){t("Failed to update combo")}},I=async e=>{let l=a.find(t=>t.id===e);E({title:"Delete Combo",message:l?.name?`Delete combo “${l.name}”?`:"Delete this combo?",onConfirm:async()=>{E(null);try{let a=await fetch(`/api/combos/${e}`,{method:"DELETE"});if(a.ok)r(t=>t.filter(t=>t.id!==e)),l?.name&&g(e=>{if(!(l.name in e))return e;let t={...e};return delete t[l.name],t});else{let e=await a.json().catch(()=>({}));t(e.error||`Failed to delete combo (HTTP ${a.status})`)}}catch(e){t("Failed to delete combo")}}})},W=async(e,a,l=null)=>{try{let s={...l||f},r={...s[e]||{},...a};for(let e of Object.keys(r))(""===r[e]||null===r[e]||void 0===r[e])&&delete r[e];let i=r.fallbackStrategy||"fallback";"fallback"!==i||r.judgeModel||r.routerModel||r.objective||r.modelAvailability||void 0!==r.learningEnabled||void 0!==r.freezeLearning||void 0!==r.explorationRate||!1===r.capacityAutoSwitch?(!r.fallbackStrategy&&void 0===a.fallbackStrategy&&s[e]?.fallbackStrategy&&(r.fallbackStrategy=s[e].fallbackStrategy),s[e]=r):delete s[e];let o=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({comboStrategies:s})});if(!o.ok){let e=await o.json().catch(()=>({}));t(e.error||`Failed to update combo strategy (${o.status})`);return}g(s)}catch(e){throw t("Failed to update combo strategy"),e}},B=async e=>{$(e);try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({capacityAdapter:e})})).ok||t("Failed to update capacity adapter")}catch(e){t("Failed to update capacity adapter")}};return i?(0,l.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,l.jsx)(d.Qv,{}),(0,l.jsx)(d.Qv,{})]}):(0,l.jsxs)("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:px-0",children:[(0,l.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,l.jsxs)("div",{className:"min-w-0 max-w-3xl",children:[(0,l.jsx)("h1",{className:"text-[17px] font-semibold text-text-main",children:"Combos"}),(0,l.jsx)("p",{className:"text-sm text-text-muted mt-1",children:"Group models under one name, then pick a strategy per combo:"}),(0,l.jsxs)("ul",{className:"text-sm text-text-muted mt-2 flex flex-col gap-1.5",children:[(0,l.jsxs)("li",{children:[(0,l.jsx)("span",{className:"font-medium text-text-main",children:"Fallback"})," ","— tries models in order (next on failure)"]}),(0,l.jsxs)("li",{children:[(0,l.jsx)("span",{className:"font-medium text-text-main",children:"Round Robin"})," ","— rotates models across requests to spread load"]}),(0,l.jsxs)("li",{children:[(0,l.jsx)("span",{className:"font-medium text-text-main",children:"Fusion"})," ","— queries all models in parallel, then a judge synthesizes one answer. Best quality, but costs the most: every request bills all panel models + the judge (N+1 calls)"]}),(0,l.jsxs)("li",{children:[(0,l.jsx)("span",{className:"font-medium text-text-main",children:"Auto"})," ","— a router model picks one worker from the pool each request (2 calls: router + worker); optional learning from outcomes"]}),(0,l.jsxs)("li",{children:[(0,l.jsx)("span",{className:"font-medium text-text-main",children:"Capacity auto-switch"})," ","— when enabled on a combo, sends image/PDF requests to a model that supports them first (works with Fallback, Round Robin, and Fusion)"]})]})]}),(0,l.jsx)(d.$n,{icon:"add",onClick:()=>x(!0),className:"w-full sm:w-auto whitespace-nowrap shrink-0",children:"Create Combo"})]}),0===a.length?(0,l.jsx)(d.Zp,{children:(0,l.jsxs)("div",{className:"text-center py-12",children:[(0,l.jsx)("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-primary/10 text-primary mb-4",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[32px]",children:"layers"})}),(0,l.jsx)("p",{className:"text-text-main font-medium mb-1",children:"No combos yet"}),(0,l.jsx)("p",{className:"text-sm text-text-muted mb-4 max-w-md mx-auto",children:"Create a named model group, choose Fallback / Round Robin / Fusion / Auto, and point clients at the combo name."}),(0,l.jsx)(d.$n,{icon:"add",onClick:()=>x(!0),className:"w-full sm:w-auto",children:"Create Combo"})]})}):(0,l.jsx)("div",{className:"flex flex-col gap-4",children:a.map(e=>(0,l.jsx)(M,{combo:e,modelCaps:C,activeProviders:h,copied:P,onCopy:q,onEdit:()=>p(e),onDelete:()=>I(e.id),strategy:f[e.name]||{},onSetStrategy:t=>W(e.name,t),providerSchedules:y},e.id))}),(0,l.jsx)(F,{capacityAdapter:A,onChange:B,activeProviders:h,getCaps:e=>C[e]||null}),(0,l.jsx)(R,{isOpen:n,onClose:()=>x(!1),onSave:T,activeProviders:h,modelCaps:C,providerSchedules:y,initialStrategy:{fallbackStrategy:"fallback",capacityAutoSwitch:!0}},"create"),(0,l.jsx)(R,{isOpen:!!u,combo:u,onClose:()=>p(null),onSave:e=>L(u.id,e),activeProviders:h,modelCaps:C,providerSchedules:y,initialStrategy:u?f[u.name]||{fallbackStrategy:"fallback"}:{}},u?.id||"new"),(0,l.jsx)(d.uo,{isOpen:!!O,onClose:()=>E(null),onConfirm:O?.onConfirm,title:O?.title||"Confirm",message:O?.message,variant:"danger"})]})}function N(e){let{strategy:t,capacityAutoSwitch:a,routerModel:l,objective:s,modelAvailability:r}=e||{},i=t||"fallback",o={fallbackStrategy:i,...void 0!==a?{capacityAutoSwitch:a}:{}};return void 0!==r&&(r&&Object.keys(r).length?o.modelAvailability=r:o.modelAvailability=""),"auto"===i?(l&&(o.routerModel=l),s&&(o.objective=s),o.judgeModel=""):("fusion"===i?o.routerModel="":(o.routerModel="",o.judgeModel=""),o.objective="",o.learningEnabled="",o.freezeLearning="",o.explorationRate=""),o}function w(e,t,a){let l=(e||[]).filter(e=>e&&e!==t);return l.length>0&&!l.some(e=>a[e]?.vision)}function C({models:e,routerModel:t}){let a=(e||[]).filter(e=>e&&e!==t);if(a.length<2)return null;let{cheap:s,frontier:r,disabled:i}=function(e){let t=(e||[]).filter(Boolean);if(t.length<=1)return{cheap:t.slice(),frontier:[],disabled:!0};let a=t.map(e=>({m:e,t:function(e){if(!e)return 4;let[t,...a]=e.split("/"),l=a.join("/")||t,s=(0,u.PS)(t,l);if(!s||"number"!=typeof s.input)return 4;let r="number"==typeof s.output?s.output:3*s.input,i=s.input+r;return i<2?0:i<10?1:i<30?2:i<80?3:4}(e)}));if(new Set(a.map(e=>e.t)).size<=1)return{cheap:t.slice(),frontier:[],disabled:!0};let l=a.filter(e=>e.t<=1).map(e=>e.m),s=a.filter(e=>e.t>=2).map(e=>e.m);if(!l.length||!s.length){let e=a.map((e,t)=>({...e,i:t})).sort((e,t)=>e.t-t.t||e.i-t.i),t=Math.ceil(e.length/2);l=e.slice(0,t).map(e=>e.m),s=e.slice(t).map(e=>e.m)}return{cheap:l,frontier:s,disabled:!1}}(a),o=e=>String(e).split("/").pop();return i?(0,l.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[(0,l.jsx)("span",{className:"text-[11px] font-medium text-text-muted",children:"Tiers"}),(0,l.jsx)("span",{className:"text-[10px] text-text-subtle",title:"All workers share one cost tier — tiered routing is off",children:"single tier (tiering off)"})]}):(0,l.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[(0,l.jsx)("span",{className:"text-[11px] font-medium text-text-muted",children:"Tiers"}),s.map(e=>(0,l.jsx)("span",{className:"rounded border border-emerald-500/30 bg-emerald-500/10 px-1.5 py-0.5 font-mono text-[10px] text-emerald-600 dark:text-emerald-400",title:`${e} — cheap tier`,children:o(e)},`c-${e}`)),(0,l.jsx)("span",{className:"material-symbols-outlined text-[12px] text-text-subtle",children:"arrow_forward"}),r.map(e=>(0,l.jsx)("span",{className:"rounded border border-amber-500/30 bg-amber-500/10 px-1.5 py-0.5 font-mono text-[10px] text-amber-600 dark:text-amber-400",title:`${e} — frontier tier`,children:o(e)},`f-${e}`))]})}let S=[{value:"fallback",label:"Fallback — try in order"},{value:"round-robin",label:"Round Robin — rotate load"},{value:"fusion",label:"Fusion — panel + judge (N+1)"},{value:"auto",label:"Auto — router picks 1 worker"}],A={fallback:"Tries models top-to-bottom; on failure uses the next.","round-robin":"Rotates models across requests to spread load.",fusion:"Calls every model, then a judge merges answers (bills N+1).",auto:"Router model chooses one worker each request (bills 2 calls)."},$=[{value:"quality",label:"Quality"},{value:"balanced",label:"Balanced"},{value:"economy",label:"Economy"},{value:"latency",label:"Latency"}];function M({combo:e,modelCaps:t={},activeProviders:a=[],copied:r,onCopy:i,onEdit:o,onDelete:n,strategy:c={},onSetStrategy:m,providerSchedules:x={}}){let[u,h]=(0,s.useState)(!1),[b,f]=(0,s.useState)(!1),[g,y]=(0,s.useState)(!1),[j,v]=(0,s.useState)(!1),[k,N]=(0,s.useState)(""),O=(0,p.Z3)(x,c.modelAvailability),R=c.modelAvailability?Object.keys(c.modelAvailability).filter(e=>!O.includes(e)):[],F=c.fallbackStrategy||"fallback",E=c.judgeModel||"",P="auto"===F,q=c.routerModel||"",D=c.objective||"balanced",_=c.providerStrategy||"off",z=!1!==c.capacityAutoSwitch,T=Array.isArray(c.providerOrder)?c.providerOrder.join(", "):"",L=c.providerLatencyGuardMs??"",[I,W]=(0,s.useState)(T),[B,H]=(0,s.useState)(""===L?"":String(L));(0,s.useEffect)(()=>{W(T)},[T]),(0,s.useEffect)(()=>{H(""===L?"":String(L))},[L]);let J=()=>{let e=I.split(",").map(e=>e.trim()).filter(Boolean),t=Array.isArray(c.providerOrder)?c.providerOrder:[];e.join(",")!==t.join(",")&&m({providerOrder:e})},G=()=>{let e=""===B.trim()?void 0:Number(B)||void 0;e!==c.providerLatencyGuardMs&&m({providerLatencyGuardMs:e})};return(0,l.jsxs)(d.Zp,{padding:"sm",className:"group",children:[(0,l.jsxs)("div",{className:"flex min-w-0 flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,l.jsxs)("div",{className:"flex min-w-0 flex-1 items-start gap-3 sm:items-center",children:[(0,l.jsx)("div",{className:"size-8 rounded-lg bg-primary/10 flex items-center justify-center shrink-0",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-primary text-[18px]",children:"layers"})}),(0,l.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,l.jsx)("code",{className:"block truncate font-mono text-sm font-medium",children:e.name}),(0,l.jsx)("p",{className:"text-[10px] text-text-subtle mt-0.5",children:A[F]||""}),(0,l.jsxs)("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1",children:[0===e.models.length?(0,l.jsx)("span",{className:"text-xs text-text-muted italic",children:"No models"}):e.models.slice(0,3).map((e,a)=>(0,l.jsxs)("code",{className:"inline-flex items-center gap-1 rounded bg-black/5 px-1.5 py-0.5 font-mono text-xs text-text-muted dark:bg-white/5",children:[(0,l.jsx)("span",{children:e}),(0,l.jsx)(d.nh,{caps:t[e]})]},a)),e.models.length>3&&(0,l.jsxs)("span",{className:"text-[10px] text-text-muted",children:["+",e.models.length-3," more"]})]}),(R.length>0||O.length>0)&&(0,l.jsxs)("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[13px] text-text-muted",title:"Peak/off-peak availability rules",children:"schedule"}),R.map(e=>{let t=(0,p.yW)(x[(0,p.WX)(e)]);return(0,l.jsxs)("span",{className:"inline-flex items-center gap-1 rounded bg-black/5 px-1.5 py-0.5 font-mono text-[10px] text-text-muted dark:bg-white/5",title:`${e} — ${c.modelAvailability[e]} (${(0,p.WX)(e)} is currently ${"peak"===t?"peak":"off-peak"})`,children:[e,(0,l.jsx)("span",{className:"font-sans",children:c.modelAvailability[e]})]},e)}),O.length>0&&(0,l.jsxs)("span",{className:"inline-flex items-center gap-1 rounded bg-amber-500/10 px-1.5 py-0.5 text-[10px] text-amber-600 dark:text-amber-400",title:`Dormant (no provider schedule): ${O.join(", ")} — these rules stay inactive until peak hours are configured on the provider page`,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"warning"}),O.length," dormant rule",O.length>1?"s":""]})]}),"fusion"===F&&(0,l.jsxs)("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5",children:[(0,l.jsx)("span",{className:"text-[11px] font-medium text-text-muted",children:"Judge"}),(0,l.jsxs)("button",{onClick:()=>h(!0),className:"inline-flex max-w-full items-center gap-1 rounded border border-dashed border-primary/40 px-1.5 py-0.5 font-mono text-[11px] text-primary hover:border-primary hover:bg-primary/5 transition-colors",title:"Pick the model that fuses panel answers",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"gavel"}),(0,l.jsx)("span",{className:"truncate",children:E||`Auto — ${e.models[0]||"first model"}`})]}),E&&(0,l.jsx)("button",{onClick:()=>m({judgeModel:""}),className:"p-0.5 rounded text-text-muted hover:text-red-500 hover:bg-red-500/10 transition-colors",title:"Reset judge to Auto",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"close"})})]}),P&&(0,l.jsxs)("div",{className:"mt-2 flex min-w-0 flex-col gap-2",children:[(0,l.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[(0,l.jsx)("span",{className:"text-[11px] font-medium text-text-muted",children:"Router"}),(0,l.jsxs)("button",{type:"button",onClick:()=>f(!0),className:"inline-flex max-w-full items-center gap-1 rounded border border-dashed border-primary/40 px-1.5 py-0.5 font-mono text-[11px] text-primary hover:border-primary hover:bg-primary/5 transition-colors",title:"Model that picks the worker each request — required for Auto",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"alt_route"}),(0,l.jsx)("span",{className:"truncate",children:q||"Select a router model (required)"})]})]}),q&&e.models?.includes(q)&&(0,l.jsxs)("p",{className:"text-[10px] text-amber-600 dark:text-amber-400 flex items-center gap-1",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"warning"}),"Router is also in the worker list — it is auto-excluded from the pool."]}),w(e.models,q,t)&&(0,l.jsxs)("p",{className:"text-[10px] text-amber-600 dark:text-amber-400 flex items-center gap-1",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"warning"}),"No vision-capable model — image requests will have images stripped"]}),(0,l.jsx)(C,{models:e.models,routerModel:q}),(0,l.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[(0,l.jsx)("span",{className:"text-[11px] font-medium text-text-muted",children:"Objective"}),(0,l.jsx)("select",{value:D,onChange:e=>m({objective:e.target.value}),className:"rounded border border-border bg-surface-2 px-1.5 py-0.5 text-[11px] text-text-main",children:$.map(e=>(0,l.jsx)("option",{value:e.value,children:e.label},e.value))}),(0,l.jsxs)("label",{className:"inline-flex items-center gap-1 text-[11px] text-text-muted cursor-pointer",children:[(0,l.jsx)("input",{type:"checkbox",className:"rounded border-border",checked:!1!==c.learningEnabled,onChange:e=>m({learningEnabled:e.target.checked})}),"Learn"]}),(0,l.jsxs)("label",{className:"inline-flex items-center gap-1 text-[11px] text-text-muted cursor-pointer",title:"Keep routing on current learning version; block relearn",children:[(0,l.jsx)("input",{type:"checkbox",className:"rounded border-border",checked:!!c.freezeLearning,onChange:e=>m({freezeLearning:e.target.checked})}),"Freeze"]}),(0,l.jsxs)("label",{className:"inline-flex items-center gap-1 text-[11px] text-text-muted cursor-pointer",title:"Occasionally append a 1/2/3 feedback prompt to Auto chat replies (human chat only). Off by default.",children:[(0,l.jsx)("input",{type:"checkbox",className:"rounded border-border",checked:!!c.feedbackAsk,onChange:e=>m({feedbackAsk:e.target.checked})}),"Ask feedback"]}),(0,l.jsxs)("button",{type:"button",disabled:j||!!c.freezeLearning,onClick:async()=>{v(!0),N("");try{let t=await fetch("/api/routing/learn",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({comboName:e.name})}),a=await t.json();N(a.message||(a.ok?"Done":a.error||"Failed"))}catch(e){N(e.message||"Failed")}finally{v(!1)}},className:"inline-flex items-center gap-1 rounded border border-primary/40 bg-primary/10 px-2 py-0.5 text-[11px] font-medium text-primary hover:bg-primary/15 disabled:opacity-50",title:"Run learning optimizer on recent routing events",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"psychology"}),j?"Learning…":"Relearn now"]}),(0,l.jsx)("a",{href:`/dashboard/combos/routing?combo=${encodeURIComponent(e.name)}`,className:"inline-flex items-center gap-1 rounded border border-border px-2 py-0.5 text-[11px] text-text-muted hover:text-primary hover:border-primary/40",children:"Insights"})]}),(0,l.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[(0,l.jsx)("span",{className:"text-[11px] font-medium text-text-muted",children:"Provider"}),(0,l.jsxs)("select",{value:_,onChange:e=>m({providerStrategy:e.target.value}),className:"rounded border border-border bg-surface-2 px-1.5 py-0.5 text-[11px] text-text-main",children:[(0,l.jsx)("option",{value:"off",children:"Off"}),(0,l.jsx)("option",{value:"priority",children:"Priority"}),(0,l.jsx)("option",{value:"round-robin",children:"Round robin"}),(0,l.jsx)("option",{value:"fastest",children:"Fastest"}),(0,l.jsx)("option",{value:"quota-first",children:"Quota first"})]}),"priority"===_&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("input",{type:"text",value:I,onChange:e=>W(e.target.value),onBlur:J,onKeyDown:e=>{"Enter"===e.key&&J()},placeholder:"provider-a, provider-b",className:"w-40 rounded border border-border bg-surface-2 px-1.5 py-0.5 text-[11px] text-text-main"}),(0,l.jsx)("span",{className:"text-[10px] text-text-muted",children:"comma-separated provider names, highest priority first"})]}),(0,l.jsx)("input",{type:"number",min:"1",value:B,onChange:e=>H(e.target.value),onBlur:G,onKeyDown:e=>{"Enter"===e.key&&G()},placeholder:"20000",title:"Demote providers slower than this latency in milliseconds",className:"w-20 rounded border border-border bg-surface-2 px-1.5 py-0.5 text-[11px] text-text-main"})]}),"quota-first"===_&&(0,l.jsx)("p",{className:"text-[10px] text-text-muted",children:"Quota data currently available for Claude & Codex; other providers use availability (not rate-limited, lower recent use)."}),(0,l.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2 text-[11px] text-text-muted",children:[(0,l.jsxs)("label",{className:"inline-flex items-center gap-1",children:["Window",(0,l.jsxs)("select",{value:c.learningWindowDays??14,onChange:e=>m({learningWindowDays:Number(e.target.value)||14}),className:"rounded border border-border bg-surface-2 px-1 py-0.5 text-[11px] text-text-main",children:[(0,l.jsx)("option",{value:7,children:"7d"}),(0,l.jsx)("option",{value:14,children:"14d"}),(0,l.jsx)("option",{value:30,children:"30d"})]})]}),(0,l.jsxs)("label",{className:"inline-flex items-center gap-1",title:"Epsilon-greedy exploration (capped at 20%)",children:["Explore",(0,l.jsx)("select",{value:Math.round((c.explorationRate??.05)*100),onChange:e=>m({explorationRate:Number(e.target.value)/100}),className:"rounded border border-border bg-surface-2 px-1 py-0.5 text-[11px] text-text-main",children:[0,5,10,15,20].map(e=>(0,l.jsxs)("option",{value:e,children:[e,"%"]},e))})]}),(0,l.jsxs)("label",{className:"inline-flex items-center gap-1",title:"0 = manual relearn only",children:["Auto-relearn",(0,l.jsxs)("select",{value:c.autoLearnIntervalHours??0,onChange:e=>m({autoLearnIntervalHours:Number(e.target.value)||0}),className:"rounded border border-border bg-surface-2 px-1 py-0.5 text-[11px] text-text-main",children:[(0,l.jsx)("option",{value:0,children:"off"}),(0,l.jsx)("option",{value:6,children:"6h"}),(0,l.jsx)("option",{value:12,children:"12h"}),(0,l.jsx)("option",{value:24,children:"24h"}),(0,l.jsx)("option",{value:72,children:"72h"})]})]}),(0,l.jsxs)("label",{className:"inline-flex items-center gap-1",title:"Capacity pre-filter before router (vision/PDF)",children:[(0,l.jsx)("input",{type:"checkbox",className:"rounded border-border",checked:!1!==c.capacityAutoSwitch,onChange:e=>m({capacityAutoSwitch:e.target.checked})}),"Heuristic first"]}),(0,l.jsxs)("label",{className:"inline-flex items-center gap-1",title:"Emit X-Auto-Router-* response headers (worker, cluster, score, skipped)",children:[(0,l.jsx)("input",{type:"checkbox",className:"rounded border-border",checked:!1!==c.emitAutoRouterHeaders,onChange:e=>m({emitAutoRouterHeaders:e.target.checked})}),"Route headers"]})]}),k?(0,l.jsx)("p",{className:"text-[11px] font-mono text-text-subtle",children:k}):(0,l.jsx)("p",{className:"text-[10px] text-text-subtle",children:"Worker pool = models list (router model excluded if listed). Every request re-routes. Router model is required — pick a connected account (a cheap, fast model such as Haiku works well)."})]})]})]}),(0,l.jsxs)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center sm:gap-3 sm:shrink-0",children:[(0,l.jsxs)("div",{className:"w-full sm:w-[220px] flex flex-col gap-1.5",children:[(0,l.jsx)(d.l6,{options:S,value:F,onChange:e=>{let t=e.target.value;if("auto"===t&&!q){y(!0),f(!0);return}m({fallbackStrategy:t})},selectClassName:"py-1.5 text-xs"}),!P&&(0,l.jsxs)("label",{className:"inline-flex items-center gap-1.5 text-[10px] text-text-muted cursor-pointer",children:[(0,l.jsx)("input",{type:"checkbox",className:"rounded border-border",checked:z,onChange:e=>m({capacityAutoSwitch:e.target.checked})}),"Capacity auto-switch (vision/PDF first)"]})]}),(0,l.jsxs)("div",{className:"grid grid-cols-3 gap-1 sm:flex",children:[(0,l.jsxs)("button",{onClick:t=>{t.stopPropagation(),i(e.name,`combo-${e.id}`)},className:"flex flex-col items-center rounded px-2 py-1 text-text-muted transition-colors hover:bg-black/5 hover:text-primary dark:hover:bg-white/5",title:"Copy combo name",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:r===`combo-${e.id}`?"check":"content_copy"}),(0,l.jsx)("span",{className:"text-[10px] leading-tight",children:"Copy"})]}),(0,l.jsxs)("button",{onClick:o,className:"flex flex-col items-center rounded px-2 py-1 text-text-muted transition-colors hover:bg-black/5 hover:text-primary dark:hover:bg-white/5",title:"Edit",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"edit"}),(0,l.jsx)("span",{className:"text-[10px] leading-tight",children:"Edit"})]}),(0,l.jsxs)("button",{onClick:n,className:"flex flex-col items-center rounded px-2 py-1 text-red-500 transition-colors hover:bg-red-500/10",title:"Delete",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"delete"}),(0,l.jsx)("span",{className:"text-[10px] leading-tight",children:"Delete"})]})]})]})]}),(0,l.jsx)(d.rq,{isOpen:u,onClose:()=>h(!1),onSelect:e=>{m({judgeModel:e?.value||""}),h(!1)},activeProviders:a,title:"Select Judge Model",addedModelValues:E?[E]:[],closeOnSelect:!0}),(0,l.jsx)(d.rq,{isOpen:b,onClose:()=>{y(!1),f(!1)},onSelect:e=>{let t=e?.value||"";g?(y(!1),t&&m({fallbackStrategy:"auto",routerModel:t})):m({routerModel:t}),f(!1)},activeProviders:a,title:"Select Router Model",addedModelValues:q?[q]:[],closeOnSelect:!0})]})}function O({id:e,index:t,model:a,learned:r=null,isFirst:n,isLast:d,onEdit:c,onMoveUp:m,onMoveDown:x,onRemove:u,availability:h="always",providerStatus:f=null,anySchedules:g=!1,onAvailabilityChange:y=null}){let{attributes:j,listeners:v,setNodeRef:k,transform:N,isDragging:w}=(0,i.gl)({id:e}),C={transform:o.Ks.Transform.toString(N),opacity:w?.4:1,zIndex:w?999:void 0},[S,A]=(0,s.useState)(!1),[$,M]=(0,s.useState)(a),R=()=>{let e=$.trim();e&&e!==a?c(e):M(a),A(!1)};return(0,l.jsxs)("div",{ref:k,style:C,className:`group flex min-w-0 items-center gap-1.5 rounded-md px-2 py-1 bg-black/[0.02] hover:bg-black/[0.04] dark:bg-white/[0.02] dark:hover:bg-white/[0.04] transition-colors ${w?"shadow-md ring-1 ring-primary/30":""}`,children:[(0,l.jsx)("button",{...j,...v,type:"button",className:"cursor-grab touch-none p-0.5 rounded text-text-muted hover:text-primary active:cursor-grabbing shrink-0",title:"Drag to reorder",children:(0,l.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,l.jsx)("circle",{cx:"9",cy:"4",r:"2"}),(0,l.jsx)("circle",{cx:"15",cy:"4",r:"2"}),(0,l.jsx)("circle",{cx:"9",cy:"12",r:"2"}),(0,l.jsx)("circle",{cx:"15",cy:"12",r:"2"}),(0,l.jsx)("circle",{cx:"9",cy:"20",r:"2"}),(0,l.jsx)("circle",{cx:"15",cy:"20",r:"2"})]})}),(0,l.jsx)("span",{className:"text-[10px] font-medium text-text-muted w-3 text-center shrink-0",children:t+1}),S?(0,l.jsx)("input",{autoFocus:!0,value:$,onChange:e=>M(e.target.value),onBlur:R,onKeyDown:e=>{"Enter"===e.key&&R(),"Escape"===e.key&&(M(a),A(!1))},className:"min-w-0 flex-1 rounded border border-primary/40 bg-white px-1.5 py-0.5 font-mono text-xs text-text-main outline-none dark:bg-black/20"}):(0,l.jsx)("div",{role:"button",tabIndex:0,className:"min-w-0 flex-1 cursor-text truncate rounded px-1.5 py-0.5 font-mono text-xs text-text-main hover:bg-black/5 dark:hover:bg-white/5 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/40",onClick:()=>A(!0),onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),A(!0))},title:"Click to edit","aria-label":`Edit model ${a}`,children:a}),(g||"always"!==h)&&y&&(0,l.jsxs)("span",{className:"flex shrink-0 items-center gap-1",title:"Peak/off-peak rule for this member (set hours on the provider page)",children:[f&&(0,l.jsx)("span",{className:`size-1.5 rounded-full ${"peak"===f?"bg-red-500":"bg-green-500"}`,title:`Provider is currently ${"peak"===f?"peak":"off-peak"}`}),(0,l.jsx)("select",{value:h,onChange:e=>y(a,e.target.value),disabled:!f,title:f?`Provider is currently ${"peak"===f?"peak":"off-peak"}`:`Rule is dormant — configure peak hours for "${(0,p.WX)(a)}" on its provider page first`,className:`rounded border border-border bg-background px-1 py-0.5 text-[10px] ${"always"!==h&&!f?"text-amber-600 dark:text-amber-400":""}`,"aria-label":`Availability for ${a}`,children:b.map(e=>(0,l.jsx)("option",{value:e.value,children:e.label},e.value))})]}),r&&r.n>=10&&(0,l.jsxs)("span",{className:"shrink-0 font-mono text-[10px] text-text-subtle",title:"Learned routing stats (all combos, last 14d)",children:["avg ",Math.round(r.avgScore)," \xb7 n=",r.n,r.bestCluster?` \xb7 best: ${r.bestCluster}`:""]}),(0,l.jsxs)("div",{className:"flex shrink-0 items-center gap-0.5",children:[(0,l.jsx)("button",{onClick:m,disabled:n,className:`p-0.5 rounded ${n?"text-text-muted/20 cursor-not-allowed":"text-text-muted hover:text-primary hover:bg-black/5 dark:hover:bg-white/5"}`,title:"Move up",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"arrow_upward"})}),(0,l.jsx)("button",{onClick:x,disabled:d,className:`p-0.5 rounded ${d?"text-text-muted/20 cursor-not-allowed":"text-text-muted hover:text-primary hover:bg-black/5 dark:hover:bg-white/5"}`,title:"Move down",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"arrow_downward"})})]}),(0,l.jsx)("button",{onClick:u,className:"p-0.5 hover:bg-red-500/10 rounded text-text-muted hover:text-red-500 transition-all",title:"Remove",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"close"})})]})}function R({isOpen:e,combo:t,onClose:a,onSave:o,activeProviders:c,modelCaps:m={},kindFilter:u=null,initialStrategy:h={},providerSchedules:b={}}){let[g,y]=(0,s.useState)(t?.name||""),[j,v]=(0,s.useState)(t?.models||[]),[k,N]=(0,s.useState)(h.fallbackStrategy||"fallback"),[C,$]=(0,s.useState)(!1!==h.capacityAutoSwitch),[M,F]=(0,s.useState)(h.modelAvailability||{}),[E,P]=(0,s.useState)(!1),[q,D]=(0,s.useState)(!1),[_,z]=(0,s.useState)(""),[T,L]=(0,s.useState)({}),[I,W]=(0,s.useState)({}),B=(0,r.FR)((0,r.MS)(r.AN,{activationConstraint:{distance:5}}),(0,r.MS)(r.uN,{coordinateGetter:i.JR})),H=j.map((e,t)=>({uid:`item-${t}`,model:e})),J=async()=>{try{let e=await fetch("/api/models/alias");if(e.ok){let t=await e.json();L(t.aliases||{})}}catch(e){(0,x.s)("Error fetching modal data:",e)}try{let e=await fetch("/api/routing/stats");if(!e.ok)throw Error("Failed to fetch learned routing stats");let t=await e.json(),a={};for(let e of t.global||[]){let t=Object.entries(e.clusters||{}),l=t.filter(([,e])=>e.n>=3),s=(l.length?l:t).reduce((e,t)=>{if(!e)return t;let[a,s]=e,[r,i]=t,o=l.length?s.avgScore:s.n,n=l.length?i.avgScore:i.n;return n>o||n===o&&r<a?t:e},null);a[e.worker]={avgScore:e.avgScore,n:e.n,bestCluster:s?s[0]:null}}W(a)}catch{W({})}};(0,s.useEffect)(()=>{e&&(y(t?.name||""),v(t?.models||[]),N(h.fallbackStrategy||"fallback"),$(!1!==h.capacityAutoSwitch),F(h.modelAvailability||{}),P(!1),D(!1),z(""),W({}),J())},[e,t?.id,t?.name]);let G=e=>e.trim()?f.test(e)?(z(""),!0):(z("Only letters, numbers, -, _ and . allowed"),!1):(z("Name is required"),!1),K=(e,t)=>{F(a=>{let l={...a};return"always"===t?delete l[e]:l[e]=t,l})},V=async()=>{if(G(g)){if(0===j.length)return void(0,x.s)("Add at least one model to the combo");if("auto"===k&&j.length<2)return void(0,x.s)("Auto strategy needs at least 2 models in the worker pool (plus a connected router account)");D(!0),await o({name:g.trim(),models:j,strategy:k,capacityAutoSwitch:"auto"===k||C,modelAvailability:M}),D(!1)}},Q=!!t,X=Object.keys(b).length>0;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(d.aF,{isOpen:e,onClose:a,title:Q?"Edit Combo":"Create Combo",children:(0,l.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,l.jsxs)("p",{className:"text-xs text-text-muted leading-relaxed",children:["Clients call this combo by name as the ",(0,l.jsx)("code",{className:"text-primary",children:"model"})," field. Strategy controls how models in the list are used."]}),(0,l.jsxs)("div",{children:[(0,l.jsx)(d.pd,{label:"Combo Name",value:g,onChange:e=>{let t=e.target.value;y(t),t?G(t):z("")},placeholder:"my-combo",error:_}),(0,l.jsx)("p",{className:"text-[10px] text-text-muted mt-0.5",children:"Only letters, numbers, -, _ and . allowed \xb7 use as model id in /v1"})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{className:"text-sm font-medium mb-1.5 block",children:"Strategy"}),(0,l.jsx)(d.l6,{options:S,value:k,onChange:e=>N(e.target.value),selectClassName:"py-2 text-sm"}),(0,l.jsx)("p",{className:"text-[11px] text-text-muted mt-1.5",children:A[k]}),"auto"===k&&(0,l.jsxs)("p",{className:"text-[11px] text-amber-600 dark:text-amber-400 mt-1 flex items-center gap-1",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"info"}),"Auto requires a router model — select one on the combo card after saving."]}),"auto"!==k&&(0,l.jsxs)("label",{className:"mt-2 inline-flex items-center gap-2 text-xs text-text-muted cursor-pointer",children:[(0,l.jsx)("input",{type:"checkbox",className:"rounded border-border",checked:C,onChange:e=>$(e.target.checked)}),"Capacity auto-switch — prefer vision/PDF-capable models when the request needs them"]}),"auto"===k&&(0,l.jsx)("p",{className:"text-[11px] text-text-subtle mt-1.5 font-mono",children:"After create: set Router model on the combo card (must be a connected account). Workers = this model list (router excluded if listed)."}),"fusion"===k&&(0,l.jsx)("p",{className:"text-[11px] text-text-subtle mt-1.5 font-mono",children:"After create: optionally set Judge on the combo card (default = first model)."})]}),(0,l.jsxs)("div",{children:[(0,l.jsxs)("label",{className:"text-sm font-medium mb-1.5 block",children:["Models ","fallback"===k?"(order = priority)":"(pool)"]}),j.length>0&&w(j,null,m)&&(0,l.jsxs)("p",{className:"text-[10px] text-amber-600 dark:text-amber-400 flex items-center gap-1 mb-1",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"warning"}),"No vision-capable model — image requests will have images stripped"]}),0===j.length?(0,l.jsxs)("div",{className:"text-center py-4 border border-dashed border-black/10 dark:border-white/10 rounded-lg bg-black/[0.01] dark:bg-white/[0.01]",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-text-muted text-xl mb-1",children:"layers"}),(0,l.jsx)("p",{className:"text-xs text-text-muted",children:"No models added yet"})]}):(0,l.jsx)(r.Mp,{sensors:B,collisionDetection:r.fp,onDragEnd:e=>{let{active:t,over:a}=e;if(a&&t.id!==a.id){let e=H.findIndex(e=>e.uid===t.id),l=H.findIndex(e=>e.uid===a.id);-1!==e&&-1!==l&&v(t=>(0,i.be)(t,e,l))}},modifiers:[n.FN,n.gj],children:(0,l.jsx)(i.gB,{items:H.map(e=>e.uid),strategy:i._G,children:(0,l.jsx)("div",{className:"flex max-h-[55vh] min-w-0 flex-col gap-1 overflow-y-auto sm:max-h-[350px]",children:H.map(({uid:e,model:t},a)=>{let s;return(0,l.jsx)(O,{id:e,index:a,model:t,learned:I[t]||null,isFirst:0===a,isLast:a===H.length-1,availability:M[t]||"always",anySchedules:X,providerStatus:"unscheduled"===(s=(0,p.yW)(b?.[(0,p.WX)(t)]))?null:s,onAvailabilityChange:K,onEdit:e=>{t!==e&&M[t]&&F(a=>{let l={...a};return l[e]=l[t],delete l[t],l});let l=[...j];l[a]=e,v(l)},onMoveUp:()=>(e=>{if(0===e)return;let t=[...j];[t[e-1],t[e]]=[t[e],t[e-1]],v(t)})(a),onMoveDown:()=>(e=>{if(e===j.length-1)return;let t=[...j];[t[e],t[e+1]]=[t[e+1],t[e]],v(t)})(a),onRemove:()=>(e=>{v(j.filter((t,a)=>a!==e));let t=j[e];if(t&&M[t]){let e={...M};delete e[t],F(e)}})(a)},e)})})})}),(0,l.jsxs)("button",{onClick:()=>P(!0),className:"w-full mt-2 py-2 border border-dashed border-black/10 dark:border-white/10 rounded-lg text-xs text-primary font-medium hover:text-primary hover:border-primary/50 transition-colors flex items-center justify-center gap-1",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"add"}),"Add Model"]})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-2 pt-1 sm:flex-row",children:[(0,l.jsx)(d.$n,{onClick:a,variant:"ghost",fullWidth:!0,size:"sm",children:"Cancel"}),(0,l.jsx)(d.$n,{onClick:V,fullWidth:!0,size:"sm",disabled:!g.trim()||!!_||q,children:q?"Saving...":Q?"Save":"Create"})]})]})}),(0,l.jsx)(d.rq,{isOpen:E,onClose:()=>P(!1),onSelect:e=>{j.includes(e.value)||v([...j,e.value])},onDeselect:e=>{v(j.filter(t=>t!==e.value))},activeProviders:c,modelAliases:T,title:"Add Model to Combo",kindFilter:u,addedModelValues:j,closeOnSelect:!1})]})}function F({capacityAdapter:e,onChange:t,activeProviders:a,getCaps:s}){return(0,l.jsx)(d.Zp,{padding:"sm",children:(0,l.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,l.jsx)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsx)("p",{className:"text-sm font-medium text-text-main",children:"Capacity Adapter"}),(0,l.jsx)("p",{className:"text-xs text-text-muted mt-0.5",children:"Request carries images or audio your model can't read? Auto-switches to a model in the pool below."}),(0,l.jsxs)("ul",{className:"mt-1.5 text-[11px] text-text-muted flex flex-col gap-0.5",children:[(0,l.jsxs)("li",{children:[(0,l.jsx)("span",{className:"font-medium text-text-main",children:"Vision"})," — images (png, jpg, webp, …)"]}),(0,l.jsxs)("li",{children:[(0,l.jsx)("span",{className:"font-medium text-text-main",children:"Audio"})," — audio input"]})]})]})}),(0,l.jsx)("div",{className:"flex flex-col gap-4",children:g.map(r=>(0,l.jsx)(E,{cap:r,entry:e[r.key]||y,onChange:a=>t({...e,[r.key]:a}),activeProviders:a,getCaps:s},r.key))})]})})}function E({cap:e,entry:t,onChange:a,activeProviders:r,getCaps:i}){let[o,n]=(0,s.useState)(!1),{enabled:c,roundRobin:m,models:x}=t,u=e=>a({...t,...e}),p=(e,t)=>{let a=e+t;if(a<0||a>=x.length)return;let l=[...x];[l[e],l[a]]=[l[a],l[e]],u({models:l})};return(0,l.jsxs)("div",{className:`group rounded-lg border border-black/5 p-3 ${!c?"opacity-50":""} dark:border-white/10`,children:[(0,l.jsxs)("div",{className:"flex min-w-0 flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,l.jsxs)("div",{className:"flex min-w-0 flex-1 items-start gap-2.5 sm:items-center",children:[(0,l.jsx)(d.lM,{checked:c,onChange:e=>u({enabled:e}),"aria-label":`Enable ${e.label} adapter`}),(0,l.jsx)("div",{className:"size-8 rounded-lg bg-primary/10 flex items-center justify-center shrink-0",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-primary text-[18px]",children:e.icon})}),(0,l.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,l.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,l.jsx)("code",{className:"font-mono text-sm font-medium text-text-main",children:e.label}),(0,l.jsxs)("span",{className:"text-[10px] text-text-muted",children:["— ",e.desc]})]}),(0,l.jsx)("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1",children:0===x.length?(0,l.jsx)("span",{className:"text-xs text-text-muted italic",children:"No models"}):x.map((e,t)=>(0,l.jsxs)("code",{className:"group/chip inline-flex items-center gap-1 rounded bg-black/5 px-1.5 py-0.5 font-mono text-xs text-text-muted dark:bg-white/5",children:[(0,l.jsx)("span",{children:e}),(0,l.jsx)(d.nh,{caps:i?.(e)}),(0,l.jsx)("button",{onClick:()=>p(t,-1),disabled:0===t,className:`leading-none opacity-0 group-hover/chip:opacity-100 ${0===t?"text-text-muted/20":"text-text-muted hover:text-primary"}`,children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"arrow_upward"})}),(0,l.jsx)("button",{onClick:()=>p(t,1),disabled:t===x.length-1,className:`leading-none opacity-0 group-hover/chip:opacity-100 ${t===x.length-1?"text-text-muted/20":"text-text-muted hover:text-primary"}`,children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"arrow_downward"})}),(0,l.jsx)("button",{onClick:()=>{let e;u({models:0===(e=x.filter((e,a)=>a!==t)).length?["oc/mimo-v2.5-free"]:e})},className:"leading-none opacity-0 group-hover/chip:opacity-100 text-text-muted hover:text-red-500",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"close"})})]},`${e}-${t}`))})]})]}),(0,l.jsxs)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center sm:gap-3 sm:shrink-0",children:[(0,l.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-text-muted cursor-pointer select-none",children:[(0,l.jsx)(d.lM,{checked:m,onChange:e=>u({roundRobin:e}),disabled:!c,"aria-label":`Round-robin ${e.label} adapter`}),(0,l.jsx)("span",{children:"Round"})]}),(0,l.jsx)(d.$n,{icon:"add",variant:"ghost",size:"sm",onClick:()=>n(!0),disabled:!c,title:`Add ${e.label} model`,children:"Add Model"})]})]}),o&&(0,l.jsx)(d.rq,{isOpen:o,onClose:()=>n(!1),onSelect:e=>{x.includes(e.value)||u({models:[...x,e.value]})},activeProviders:r,title:`Add ${e.label} Model`,addedModelValues:x,capFilter:e.key,closeOnSelect:!1})]})}},80063:(e,t,a)=>{Promise.resolve().then(a.bind(a,41483))}},e=>{e.O(0,[2574,3862,782,8500,594,7055,1321,4707,1330,979,8441,3794,7358],()=>e(e.s=80063)),_N_E=e.O()}]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[624],{35497:(e,t,s)=>{"use strict";s.d(t,{x0:()=>k.default,Ex:()=>c.default,$n:()=>a.default,nh:()=>L.default,Zp:()=>o.default,Qv:()=>i.CardSkeleton,CK:()=>u.default,uo:()=>n.ConfirmModal,G9:()=>j.default,wI:()=>v.default,vj:()=>y.default,vE:()=>N.default,pd:()=>r.default,Mh:()=>g.default,uR:()=>p.default,Nf:()=>h.default,aF:()=>n.default,rq:()=>m.default,gw:()=>w.default,LF:()=>x.default,Wx:()=>M.default,gM:()=>f.default,Iz:()=>S.default,l6:()=>l.default,lM:()=>d.default,m_:()=>C.default,jK:()=>b.default});var a=s(92542),r=s(11910),l=s(98),o=s(84588),n=s(81127),i=s(25086);s(56319);var c=s(56061),d=s(98542);s(61929),s(21110),s(92622),s(8823),s(92173);var x=s(90882),m=s(72908),p=s(28815),u=s(45455),h=s(28058),b=s(4809);s(21931),s(80752),s(40197);var f=s(23615);s(44736);var g=s(62899);s(94230);var j=s(30815),N=s(23936),y=s(95088),v=s(73579),k=s(96748),w=s(4823),S=s(28067),C=s(97677),M=s(51825),L=s(29366);s(76361),s(91450)},61872:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>L,formatRoutingTimestamp:()=>C,formatWorkerScoreLabel:()=>S});var a=s(95155),r=s(12115),l=s(73321),o=s(98500),n=s.n(o),i=s(21742),c=s(16746),d=s(28408),x=s(32539),m=s(59656),p=s(84420),u=s(19381),h=s(94977),b=s(48035),f=s(67869),g=s(67389),j=s(85545),N=s(35497);let y=["#3987e5","#199e70","#c98500","#9085e9","#008300","#e66767"],v="#8a8172",k=[{key:"router",label:"Router"},{key:"bandit_policy",label:"Bandit policy"},{key:"cached_route",label:"Cached route"},{key:"exploration",label:"Exploration"},{key:"judge_flag_escalation",label:"Judge escalation"},{key:"fallback_rescue",label:"Fallback rescue"}],w={backgroundColor:"var(--color-bg)",border:"1px solid var(--color-border)",borderRadius:"8px",color:"var(--color-text)",fontSize:"12px"};function S(e){return null==e?"—":Math.round(Number(e))}function C(e){if(!e)return"—";let t=new Date(e);return Number.isNaN(t.getTime())?String(e):t.toLocaleString()}function M({active:e,payload:t}){if(!e||!t?.length)return null;let s=t[0].payload;return(0,a.jsxs)("div",{className:"font-mono",style:w,children:[(0,a.jsx)("p",{className:"mb-1 text-text-muted",children:s.worker}),(0,a.jsxs)("p",{className:"text-text-main",children:["Score: ",S(s.avgScore)]}),null!=s.winRate&&(0,a.jsxs)("p",{className:"text-text-main",children:["Win rate: ",Math.round(100*s.winRate),"%"]}),(0,a.jsxs)("p",{className:"text-text-main",children:["Latency: ",Math.round(Number(s.avgLatencyMs)||0),"ms"]})]})}function L(){return(0,a.jsx)(r.Suspense,{fallback:(0,a.jsx)("p",{className:"text-sm text-text-muted p-4",children:"Loading insights…"}),children:(0,a.jsx)(O,{})})}function O(){let e,t,s=(0,l.useSearchParams)().get("combo")||"",[o,L]=(0,r.useState)(null),[O,R]=(0,r.useState)(null),[F,_]=(0,r.useState)(!1),[E,A]=(0,r.useState)(""),[T,z]=(0,r.useState)(""),[P,W]=(0,r.useState)(14),[Z,I]=(0,r.useState)(""),[K,J]=(0,r.useState)(""),[q,D]=(0,r.useState)(!1),B=(0,r.useCallback)(async()=>{if(s){_(!0),A("");try{let e=new URLSearchParams({combo:s,days:String(P)});Z&&e.set("cluster",Z),K&&e.set("worker",K),q&&e.set("exploration","1");let[t,a]=await Promise.all([fetch(`/api/routing/insights?${e}`,{cache:"no-store"}),fetch(`/api/routing/stats?combo=${encodeURIComponent(s)}&days=${P}`,{cache:"no-store"}).then(async e=>e.ok?e.json():null).catch(()=>null)]),r=await t.json();if(!t.ok)throw Error(r.error||"Failed to load insights");L(r),R(a)}catch(e){A(e.message||"Failed"),L(null),R(null)}finally{_(!1)}}},[s,P,Z,K,q]);(0,r.useEffect)(()=>{B()},[B]);let G=(0,r.useCallback)(async(e,t)=>{if(e)try{let s=await fetch("/api/routing/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:e,rating:t})}),a=await s.json().catch(()=>({}));if(!s.ok)throw Error(a.error||"Feedback failed");z(0===t?"Feedback cleared":"Thanks — feedback recorded"),await B()}catch(e){z(e.message||"Feedback failed")}},[B]),U=(0,r.useMemo)(()=>{if(!o?.heatmap)return 100;let e=1;for(let t of o.heatmap)for(let s of t.cells||[])null!=s.avg&&s.avg>e&&(e=s.avg);return e},[o]),Q=O?.timeline||[],V=(e=[...new Set([...(o?.modelStats||[]).map(e=>e.worker),...Q.map(e=>e.worker)].filter(Boolean))].sort(),t={},e.forEach((e,s)=>{t[e]=s<6?y[s]:v}),t),H=(o?.modelStats||[]).map(e=>({...e,workerLabel:e.worker.split("/").pop(),winRate:null!=e.wins&&Number(e.n)>0?Number(e.wins)/Number(e.n):null})),X=[...new Set(Q.map(e=>e.worker).filter(Boolean))].sort(),Y=X.filter(e=>V[e]!==v),ee=X.some(e=>V[e]===v),et=new Map;for(let e of Q){let t=Number(e.avgScore);if(!Number.isFinite(t))continue;let s=et.get(e.day)||{day:e.day,otherN:0,otherScore:0};if(V[e.worker]===v){let a=Number(e.n)||0;s.otherN+=a,s.otherScore+=t*a}else s[e.worker]=t;et.set(e.day,s)}let es=[...et.values()].map(e=>(e.otherN>0&&(e.Other=e.otherScore/e.otherN),delete e.otherN,delete e.otherScore,e)),ea=ee?[...Y,"Other"]:Y,er=O?.pickSource||{},el=Object.values(er).reduce((e,t)=>e+(Number(t)||0),0),eo=el?Math.round(((Number(er.bandit_policy)||0)+(Number(er.cached_route)||0))/el*100):null,en=Q.reduce((e,t)=>e+(Number(t.n)||0),0),ei=Q.reduce((e,t)=>e+(Number(t.avgScore)||0)*(Number(t.n)||0),0),ec=O?.judgeCoverage,ed=ec?.total?Math.round(Number(ec.judged)/Number(ec.total)*100):null;return s?(0,a.jsxs)("div",{className:"flex flex-col gap-5 max-w-[1180px]",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,a.jsx)("h1",{className:"text-[17px] font-semibold tracking-tight",children:"Routing insights"}),(0,a.jsxs)("p",{className:"text-xs font-mono text-text-subtle",children:["combo: ",s,o?.strategy?.routerModel?` \xb7 router ${o.strategy.routerModel}`:"",o?.strategy?.objective?` \xb7 ${o.strategy.objective}`:"",o?.strategy?.explorationRate!=null?` \xb7 ε=${Math.round((o.strategy.explorationRate??.05)*100)}% (cap ${Math.round((o.strategy.explorationRateCap??.2)*100)}%)`:""]})]}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2 items-center",children:[(0,a.jsxs)("select",{value:P,onChange:e=>W(Number(e.target.value)||14),className:"text-[11.5px] font-mono text-text-subtle px-2 py-1.5 rounded-[7px] bg-surface-2 border border-border",title:"Date range",children:[(0,a.jsx)("option",{value:7,children:"last 7 days"}),(0,a.jsx)("option",{value:14,children:"last 14 days"}),(0,a.jsx)("option",{value:30,children:"last 30 days"}),(0,a.jsx)("option",{value:90,children:"last 90 days"})]}),(0,a.jsx)(N.$n,{size:"sm",variant:"secondary",onClick:B,disabled:F,children:"Refresh"}),(0,a.jsx)(N.$n,{size:"sm",disabled:F,onClick:async()=>{z("");try{let e=await fetch("/api/routing/learn",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({comboName:s})}),t=await e.json();z(t.message||JSON.stringify(t)),await B()}catch(e){z(e.message)}},children:"Relearn now"}),(0,a.jsx)(n(),{href:"/dashboard/combos",className:"text-xs text-text-muted hover:text-primary px-2 py-1.5",children:"← Combos"})]})]}),T&&(0,a.jsx)("p",{className:"text-xs font-mono text-text-subtle",children:T}),E&&(0,a.jsx)("p",{className:"text-sm text-red-400",children:E}),F&&!o&&(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Loading…"}),o&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[(0,a.jsx)($,{label:"Requests",value:String(o.eventCount??0)}),(0,a.jsx)($,{label:"Need for learn",value:o.needMore>0?`${o.needMore} more`:"ready"}),(0,a.jsx)($,{label:"Active version",value:o.promoted?`v${o.promoted.version}`:"—"}),(0,a.jsx)($,{label:"Eval score",value:o.promoted?.evalScore!=null?Number(o.promoted.evalScore).toFixed(1):"—"})]}),(0,a.jsxs)("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[(0,a.jsx)($,{label:"Router-skip %",value:null==eo?"—":`${eo}%`}),(0,a.jsx)($,{label:"Avg score",value:en>0?(ei/en).toFixed(1):"—"}),(0,a.jsx)($,{label:"Judge coverage %",value:null==ed?"—":`${ed}%`}),(0,a.jsx)($,{label:"Total picks",value:String(el)})]}),(0,a.jsxs)("p",{className:"text-[11px] text-text-subtle font-mono -mt-2",children:["Request-level counts (one per chat). Intermediate fallback attempts",null!=o.attemptCount&&o.attemptCount!==o.eventCount?` (${o.attemptCount} attempt rows)`:""," ","feed the bandit but not the min-events gate. Single-worker and heuristic shortcuts are not logged here."]}),(0,a.jsxs)(N.Zp,{padding:"md",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-1 flex-wrap gap-2",children:[(0,a.jsx)("span",{className:"text-[13px] font-semibold",children:"Win-rate heatmap"}),(0,a.jsxs)("div",{className:"flex items-center gap-2 text-[10.5px] font-mono text-text-subtle",children:[(0,a.jsx)("span",{children:"low"}),(0,a.jsx)("span",{className:"w-[120px] h-2 rounded",style:{background:"linear-gradient(90deg,rgba(229,180,84,.1),rgba(229,180,84,.72))"}}),(0,a.jsx)("span",{children:"high \xb7 number always shown"})]})]}),(0,a.jsx)("p",{className:"text-[11.5px] font-mono text-text-subtle mb-3",children:"cluster \xd7 worker \xb7 average outcome score (0–100)"}),o.clusters?.length&&o.workers?.length?(0,a.jsxs)("div",{className:"grid gap-1 overflow-x-auto",style:{gridTemplateColumns:`112px repeat(${o.workers.length}, minmax(56px, 1fr))`},children:[(0,a.jsx)("div",{}),o.workers.map(e=>(0,a.jsx)("div",{className:"font-mono text-[10.5px] text-text-muted text-center pb-1 truncate",title:e,children:e.split("/").pop()},e)),o.heatmap.map(e=>(0,a.jsxs)("div",{className:"contents",children:[(0,a.jsx)("div",{className:"text-[11px] uppercase tracking-wide text-text-muted flex items-center font-medium",children:e.cluster}),e.cells.map(t=>{let s=t.avg,r=null==s||U<=0?0:Math.min(1,s/U);return(0,a.jsx)("div",{className:"rounded text-center font-mono text-[11px] py-2 border border-border",style:{background:`rgba(229,180,84,${.08+.55*r})`,color:null==s?"#6F6653":"#ECE4D2"},title:`${t.worker}: n=${t.n}`,children:null==s?"—":Math.round(s)},`${e.cluster}-${t.worker}`)})]},e.cluster))]}):(0,a.jsx)("p",{className:"text-sm text-text-muted py-6 text-center",children:"No routing events yet. Point a client at this combo with strategy Auto."})]}),(0,a.jsxs)(N.Zp,{padding:"md",children:[(0,a.jsx)("span",{className:"text-[13px] font-semibold",children:"Score trend"}),(0,a.jsx)("p",{className:"text-[11px] text-text-subtle font-mono mb-2",children:"mean outcome score per worker per day (request-level)"}),0===es.length?(0,a.jsx)("p",{className:"text-xs text-text-muted py-6 text-center",children:"No routing data in this window — Auto combos learn as they route"}):(0,a.jsx)(i.u,{width:"100%",height:220,children:(0,a.jsxs)(c.b,{data:es,margin:{top:8,right:12,left:0,bottom:0},children:[(0,a.jsx)(d.d,{strokeDasharray:"3 3",strokeOpacity:.1}),(0,a.jsx)(x.W,{dataKey:"day",tick:{className:"font-mono",fill:"currentColor",fillOpacity:.65,fontSize:10},tickFormatter:e=>String(e).slice(5),tickLine:!1,axisLine:!1}),(0,a.jsx)(m.h,{domain:[0,100],tick:{className:"font-mono",fill:"currentColor",fillOpacity:.65,fontSize:10},tickLine:!1,axisLine:!1,width:32}),(0,a.jsx)(p.m,{contentStyle:w,itemStyle:{color:"var(--color-text)"},labelStyle:{color:"var(--color-text-muted)"},formatter:(e,t)=>[Math.round(Number(e)),t]}),ea.length>=2&&(0,a.jsx)(u.s,{formatter:e=>(0,a.jsx)("span",{className:"font-mono text-[10px] text-text-muted",children:e})}),ea.map(e=>(0,a.jsx)(h.N1,{type:"monotone",dataKey:t=>t[e]??null,name:"Other"===e?"Other":e.split("/").pop(),stroke:"Other"===e?v:V[e],strokeWidth:2,dot:!1,activeDot:{r:4},connectNulls:!0,isAnimationActive:!1},e))]})})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[(0,a.jsxs)(N.Zp,{padding:"md",children:[(0,a.jsx)("span",{className:"text-[13px] font-semibold",children:"Worker comparison"}),(0,a.jsx)("p",{className:"text-[11px] text-text-subtle font-mono mb-3",children:"average outcome score (0–100)"}),0===H.length?(0,a.jsx)("p",{className:"text-xs text-text-muted py-6 text-center",children:"No routing data in this window — Auto combos learn as they route"}):(0,a.jsx)(i.u,{width:"100%",height:Math.max(180,34*H.length),children:(0,a.jsxs)(b.E,{data:H,layout:"vertical",margin:{top:2,right:34,left:0,bottom:0},children:[(0,a.jsx)(d.d,{strokeDasharray:"3 3",strokeOpacity:.1,horizontal:!1}),(0,a.jsx)(x.W,{type:"number",domain:[0,100],tick:{className:"font-mono",fill:"currentColor",fillOpacity:.65,fontSize:10},tickLine:!1,axisLine:!1}),(0,a.jsx)(m.h,{type:"category",dataKey:"workerLabel",width:110,tick:{className:"font-mono",fill:"currentColor",fillOpacity:.65,fontSize:10},tickLine:!1,axisLine:!1}),(0,a.jsx)(p.m,{content:(0,a.jsx)(M,{}),contentStyle:w}),(0,a.jsxs)(f.yP,{dataKey:"avgScore",name:"Average score",barSize:16,radius:[0,4,4,0],isAnimationActive:!1,children:[H.map(e=>(0,a.jsx)(g.f,{fill:V[e.worker]||v},e.worker)),(0,a.jsx)(j.Ze,{dataKey:"avgScore",position:"right",formatter:e=>S(e),fill:"var(--color-text-muted)",className:"font-mono"})]})]})})]}),(0,a.jsxs)(N.Zp,{padding:"md",children:[(0,a.jsx)("span",{className:"text-[13px] font-semibold",children:"Pick source"}),(0,a.jsx)("p",{className:"text-[11px] text-text-subtle font-mono mb-3",children:"terminal selections in the selected window"}),0===el?(0,a.jsx)("p",{className:"text-xs text-text-muted py-6 text-center",children:"No routing data in this window — Auto combos learn as they route"}):(0,a.jsx)(i.u,{width:"100%",height:180,children:(0,a.jsxs)(b.E,{data:[{name:"window",...er}],margin:{top:8,right:8,left:0,bottom:0},children:[(0,a.jsx)(d.d,{strokeDasharray:"3 3",strokeOpacity:.1,vertical:!1}),(0,a.jsx)(x.W,{type:"number",tick:{className:"font-mono",fill:"currentColor",fillOpacity:.65,fontSize:10},tickLine:!1,axisLine:!1}),(0,a.jsx)(m.h,{type:"category",dataKey:"name",width:48,tick:{className:"font-mono",fill:"currentColor",fillOpacity:.65,fontSize:10},tickLine:!1,axisLine:!1}),(0,a.jsx)(p.m,{contentStyle:w,itemStyle:{color:"var(--color-text)"},labelStyle:{color:"var(--color-text-muted)"}}),(0,a.jsx)(u.s,{formatter:e=>(0,a.jsx)("span",{className:"font-mono text-[10px] text-text-muted",children:e})}),k.map((e,t)=>(0,a.jsx)(f.yP,{dataKey:e.key,name:e.label,stackId:"s",fill:t<6?y[t]:v,isAnimationActive:!1},e.key))]})})]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[(0,a.jsxs)(N.Zp,{padding:"md",children:[(0,a.jsx)("span",{className:"text-[13px] font-semibold",children:"Model performance"}),(0,a.jsxs)("div",{className:"mt-3 space-y-2",children:[0===(o.modelStats||[]).length&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"No data"}),(o.modelStats||[]).map(e=>(0,a.jsxs)("div",{className:"grid grid-cols-[1fr_52px_60px_40px] gap-2 items-center text-xs",children:[(0,a.jsx)("span",{className:"font-mono truncate text-text-main",title:e.worker,children:e.worker}),(0,a.jsx)("span",{className:"text-right font-mono text-text-muted",children:null!=e.avgScore?Math.round(e.avgScore):"—"}),(0,a.jsx)("span",{className:"text-right font-mono text-text-muted",children:null!=e.avgLatencyMs?`${Math.round(e.avgLatencyMs)}ms`:"—"}),(0,a.jsx)("span",{className:"text-right font-mono text-text-subtle",children:e.errors||0})]},e.worker))]})]}),(0,a.jsxs)(N.Zp,{padding:"md",children:[(0,a.jsx)("span",{className:"text-[13px] font-semibold",children:"Learning versions"}),(0,a.jsx)("p",{className:"text-[11px] text-text-subtle font-mono mb-2",children:"immutable \xb7 rollback-safe"}),(0,a.jsxs)("div",{className:"space-y-2 max-h-64 overflow-y-auto",children:[0===(o.versions||[]).length&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"No versions yet"}),(o.versions||[]).map(e=>(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2 text-xs border-b border-border py-1.5",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("span",{className:"font-mono text-text-main",children:["v",e.version,e.promoted?" \xb7 active":""]}),(0,a.jsxs)("div",{className:"text-[10px] text-text-subtle font-mono",children:["eval ",null!=e.evalScore?Number(e.evalScore).toFixed(1):"—"," \xb7"," ",e.source]})]}),!e.promoted&&(0,a.jsx)("button",{type:"button",className:"text-primary text-[11px] hover:underline",onClick:async()=>{await fetch("/api/routing/versions/promote",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e.id})}),B()},children:"Promote"})]},e.id))]}),o.promoted?.prevVersionId&&(0,a.jsx)(N.$n,{size:"sm",variant:"outline",className:"mt-3",onClick:async()=>{await fetch("/api/routing/versions/rollback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({comboName:s})}),B()},children:"Rollback"})]})]}),(0,a.jsxs)(N.Zp,{padding:"md",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,a.jsx)("span",{className:"text-[13px] font-semibold",children:"Recent decisions"}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2","aria-label":"Filter recent decisions",children:[(0,a.jsx)("span",{className:"text-[10.5px] font-mono text-text-subtle",children:"filter decisions:"}),(0,a.jsxs)("select",{value:Z,onChange:e=>I(e.target.value),className:"text-[11.5px] font-mono text-text-subtle px-2 py-1.5 rounded-[7px] bg-surface-2 border border-border max-w-[140px]",title:"Filter recent decisions by cluster","aria-label":"Filter recent decisions by cluster",children:[(0,a.jsx)("option",{value:"",children:"all clusters"}),(o?.clusters||[]).map(e=>(0,a.jsx)("option",{value:e,children:e},e))]}),(0,a.jsxs)("select",{value:K,onChange:e=>J(e.target.value),className:"text-[11.5px] font-mono text-text-subtle px-2 py-1.5 rounded-[7px] bg-surface-2 border border-border max-w-[160px]",title:"Filter recent decisions by worker","aria-label":"Filter recent decisions by worker",children:[(0,a.jsx)("option",{value:"",children:"all workers"}),(o?.workers||[]).map(e=>(0,a.jsx)("option",{value:e,children:e.split("/").pop()},e))]}),(0,a.jsxs)("label",{className:"inline-flex items-center gap-1 text-[11px] text-text-muted cursor-pointer",children:[(0,a.jsx)("input",{type:"checkbox",className:"rounded border-border",checked:q,onChange:e=>D(e.target.checked)}),"exploration only"]})]})]}),(0,a.jsxs)("div",{className:"mt-3 overflow-x-auto",children:[(0,a.jsxs)("table",{className:"w-full text-left text-xs",children:[(0,a.jsx)("thead",{className:"text-text-subtle font-mono uppercase tracking-wide",children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:"py-1 pr-2",children:"Time"}),(0,a.jsx)("th",{className:"py-1 pr-2",children:"Cluster"}),(0,a.jsx)("th",{className:"py-1 pr-2",children:"Worker"}),(0,a.jsx)("th",{className:"py-1 pr-2",children:"Score"}),(0,a.jsx)("th",{className:"py-1 pr-2",children:"Reason"}),(0,a.jsx)("th",{className:"py-1",children:"Rate"})]})}),(0,a.jsx)("tbody",{children:(o.recent||[]).map(e=>{let t=e.meta?.userRating??null;return(0,a.jsxs)("tr",{className:"border-t border-border",children:[(0,a.jsxs)("td",{className:"py-1.5 pr-2 font-mono text-text-muted whitespace-nowrap",children:[C(e.timestamp),e.meta?.exploration?(0,a.jsx)("span",{className:"ml-1 text-[9px] text-primary",children:"ε"}):null,e.meta?.judgeScore!=null?(0,a.jsxs)("span",{className:"ml-1 text-[9px] text-text-subtle",title:`LLM-judge score ${e.meta.judgeScore}/10`,children:["J",e.meta.judgeScore]}):null]}),(0,a.jsx)("td",{className:"py-1.5 pr-2",children:e.cluster||"—"}),(0,a.jsx)("td",{className:"py-1.5 pr-2 font-mono truncate max-w-[160px]",title:e.pickedWorker,children:e.pickedWorker?.split("/").pop()||"—"}),(0,a.jsx)("td",{className:"py-1.5 pr-2 font-mono",children:null!=e.outcomeScore?Math.round(e.outcomeScore):"—"}),(0,a.jsx)("td",{className:"py-1.5 pr-2 text-text-muted truncate max-w-[240px]",title:e.routerReason,children:e.routerReason||"—"}),(0,a.jsx)("td",{className:"py-1.5 whitespace-nowrap",children:e.requestId?(0,a.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,a.jsx)("button",{type:"button",title:"Good route",className:`text-[13px] leading-none ${1===t?"text-primary":"text-text-subtle hover:text-primary"}`,onClick:()=>G(e.requestId,+(1!==t)),children:"▲"}),(0,a.jsx)("button",{type:"button",title:"Bad route",className:`text-[13px] leading-none ${-1===t?"text-red-400":"text-text-subtle hover:text-red-400"}`,onClick:()=>G(e.requestId,-1===t?0:-1),children:"▼"})]}):(0,a.jsx)("span",{className:"text-[10px] text-text-subtle",children:"—"})})]},e.id)})})]}),!(o.recent||[]).length&&(0,a.jsx)("p",{className:"text-xs text-text-muted py-4 text-center",children:"No decisions logged"})]})]}),(0,a.jsxs)(N.Zp,{padding:"md",children:[(0,a.jsx)("span",{className:"text-[13px] font-semibold",children:"Exploration log"}),(0,a.jsx)("p",{className:"text-[11px] text-text-subtle font-mono mb-2",children:"epsilon-greedy random picks (meta.exploration)"}),(0,a.jsxs)("div",{className:"space-y-1.5 max-h-48 overflow-y-auto",children:[0===(o.explorationLog||[]).length&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"No exploration events in this window"}),(o.explorationLog||[]).map(e=>(0,a.jsxs)("div",{className:"flex flex-wrap gap-2 text-[11px] font-mono border-b border-border py-1",children:[(0,a.jsx)("span",{className:"text-text-muted",children:C(e.timestamp)}),(0,a.jsx)("span",{children:e.cluster||"—"}),(0,a.jsx)("span",{className:"text-primary",children:e.pickedWorker?.split("/").pop()}),(0,a.jsxs)("span",{className:"text-text-subtle",children:["score ",null!=e.outcomeScore?Math.round(e.outcomeScore):"—"]})]},`ex-${e.id}`))]})]})]})]}):(0,a.jsxs)("div",{className:"max-w-lg space-y-3",children:[(0,a.jsx)("h1",{className:"text-[17px] font-semibold",children:"Routing insights"}),(0,a.jsxs)("p",{className:"text-sm text-text-muted",children:["Open from a combo card with strategy ",(0,a.jsx)("strong",{children:"Auto"}),", or append"," ",(0,a.jsx)("code",{className:"text-xs",children:"?combo=your-combo"}),"."]}),(0,a.jsx)(n(),{href:"/dashboard/combos",className:"text-sm text-primary hover:underline",children:"← Combos"})]})}function $({label:e,value:t}){return(0,a.jsxs)("div",{className:"rounded-[11px] border border-border bg-surface p-3.5",children:[(0,a.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-text-subtle mb-1.5",children:e}),(0,a.jsx)("div",{className:"font-mono text-[18px] font-semibold text-text-main",children:t})]})}},63759:(e,t,s)=>{Promise.resolve().then(s.bind(s,61872))}},e=>{e.O(0,[2574,3862,782,8500,594,136,1321,4707,1330,8441,3794,7358],()=>e(e.s=63759)),_N_E=e.O()}]);
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[624],{35497:(e,t,s)=>{"use strict";s.d(t,{x0:()=>k.default,Ex:()=>c.default,$n:()=>a.default,nh:()=>M.default,Zp:()=>o.default,Qv:()=>i.CardSkeleton,CK:()=>u.default,uo:()=>n.ConfirmModal,G9:()=>j.default,wI:()=>v.default,vj:()=>y.default,vE:()=>N.default,pd:()=>r.default,Mh:()=>g.default,uR:()=>p.default,Nf:()=>h.default,aF:()=>n.default,rq:()=>m.default,gw:()=>w.default,LF:()=>x.default,Wx:()=>$.default,gM:()=>f.default,Iz:()=>S.default,l6:()=>l.default,lM:()=>d.default,m_:()=>C.default,jK:()=>b.default});var a=s(92542),r=s(11910),l=s(98),o=s(84588),n=s(81127),i=s(25086);s(56319);var c=s(56061),d=s(98542);s(61929),s(21110),s(92622),s(8823),s(92173);var x=s(90882),m=s(72908),p=s(28815),u=s(45455),h=s(28058),b=s(4809);s(21931),s(80752),s(40197);var f=s(23615);s(44736);var g=s(62899);s(94230);var j=s(30815),N=s(23936),y=s(95088),v=s(73579),k=s(96748),w=s(4823),S=s(28067),C=s(97677),$=s(51825),M=s(29366);s(76361),s(91450)},61872:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>M,formatRoutingTimestamp:()=>C,formatWorkerScoreLabel:()=>S});var a=s(95155),r=s(12115),l=s(73321),o=s(98500),n=s.n(o),i=s(21742),c=s(16746),d=s(28408),x=s(32539),m=s(59656),p=s(84420),u=s(19381),h=s(94977),b=s(48035),f=s(67869),g=s(67389),j=s(85545),N=s(35497);let y=["#3987e5","#199e70","#c98500","#9085e9","#008300","#e66767"],v="#8a8172",k=[{key:"router",label:"Router"},{key:"bandit_policy",label:"Bandit policy"},{key:"cached_route",label:"Cached route"},{key:"exploration",label:"Exploration"},{key:"judge_flag_escalation",label:"Judge escalation"},{key:"fallback_rescue",label:"Fallback rescue"}],w={backgroundColor:"var(--color-bg)",border:"1px solid var(--color-border)",borderRadius:"8px",color:"var(--color-text)",fontSize:"12px"};function S(e){return null==e?"—":Math.round(Number(e))}function C(e){if(!e)return"—";let t=new Date(e);return Number.isNaN(t.getTime())?String(e):t.toLocaleString()}function $({active:e,payload:t}){if(!e||!t?.length)return null;let s=t[0].payload;return(0,a.jsxs)("div",{className:"font-mono",style:w,children:[(0,a.jsx)("p",{className:"mb-1 text-text-muted",children:s.worker}),(0,a.jsxs)("p",{className:"text-text-main",children:["Score: ",S(s.avgScore)]}),null!=s.winRate&&(0,a.jsxs)("p",{className:"text-text-main",children:["Win rate: ",Math.round(100*s.winRate),"%"]}),(0,a.jsxs)("p",{className:"text-text-main",children:["Latency: ",Math.round(Number(s.avgLatencyMs)||0),"ms"]})]})}function M(){return(0,a.jsx)(r.Suspense,{fallback:(0,a.jsx)("p",{className:"text-sm text-text-muted p-4",children:"Loading insights…"}),children:(0,a.jsx)(L,{})})}function L(){let e,t,s=(0,l.useSearchParams)().get("combo")||"",[o,M]=(0,r.useState)(null),[L,R]=(0,r.useState)(null),[F,_]=(0,r.useState)(!1),[E,A]=(0,r.useState)(""),[T,z]=(0,r.useState)(""),[P,W]=(0,r.useState)(14),[Z,I]=(0,r.useState)(""),[K,J]=(0,r.useState)(""),[q,D]=(0,r.useState)(!1),B=(0,r.useCallback)(async()=>{if(s){_(!0),A("");try{let e=new URLSearchParams({combo:s,days:String(P)});Z&&e.set("cluster",Z),K&&e.set("worker",K),q&&e.set("exploration","1");let[t,a]=await Promise.all([fetch(`/api/routing/insights?${e}`,{cache:"no-store"}),fetch(`/api/routing/stats?combo=${encodeURIComponent(s)}&days=${P}`,{cache:"no-store"}).then(async e=>e.ok?e.json():null).catch(()=>null)]),r=await t.json();if(!t.ok)throw Error(r.error||"Failed to load insights");M(r),R(a)}catch(e){A(e.message||"Failed"),M(null),R(null)}finally{_(!1)}}},[s,P,Z,K,q]);(0,r.useEffect)(()=>{B()},[B]);let G=(0,r.useCallback)(async(e,t)=>{if(e)try{let s=await fetch("/api/routing/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:e,rating:t})}),a=await s.json().catch(()=>({}));if(!s.ok)throw Error(a.error||"Feedback failed");z(0===t?"Feedback cleared":"Thanks — feedback recorded"),await B()}catch(e){z(e.message||"Feedback failed")}},[B]),U=(0,r.useMemo)(()=>{if(!o?.heatmap)return 100;let e=1;for(let t of o.heatmap)for(let s of t.cells||[])null!=s.avg&&s.avg>e&&(e=s.avg);return e},[o]),Q=L?.timeline||[],V=(e=[...new Set([...(o?.modelStats||[]).map(e=>e.worker),...Q.map(e=>e.worker)].filter(Boolean))].sort(),t={},e.forEach((e,s)=>{t[e]=s<6?y[s]:v}),t),H=(o?.modelStats||[]).map(e=>({...e,workerLabel:e.worker.split("/").pop(),winRate:null!=e.wins&&Number(e.n)>0?Number(e.wins)/Number(e.n):null})),X=[...new Set(Q.map(e=>e.worker).filter(Boolean))].sort(),Y=X.filter(e=>V[e]!==v),ee=X.some(e=>V[e]===v),et=new Map;for(let e of Q){let t=Number(e.avgScore);if(!Number.isFinite(t))continue;let s=et.get(e.day)||{day:e.day,otherN:0,otherScore:0};if(V[e.worker]===v){let a=Number(e.n)||0;s.otherN+=a,s.otherScore+=t*a}else s[e.worker]=t;et.set(e.day,s)}let es=[...et.values()].map(e=>(e.otherN>0&&(e.Other=e.otherScore/e.otherN),delete e.otherN,delete e.otherScore,e)),ea=ee?[...Y,"Other"]:Y,er=L?.pickSource||{},el=Object.values(er).reduce((e,t)=>e+(Number(t)||0),0),eo=el?Math.round(((Number(er.bandit_policy)||0)+(Number(er.cached_route)||0))/el*100):null,en=Q.reduce((e,t)=>e+(Number(t.n)||0),0),ei=Q.reduce((e,t)=>e+(Number(t.avgScore)||0)*(Number(t.n)||0),0),ec=L?.judgeCoverage,ed=ec?.total?Math.round(Number(ec.judged)/Number(ec.total)*100):null;return s?(0,a.jsxs)("div",{className:"flex flex-col gap-5 max-w-[1180px]",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,a.jsx)("h1",{className:"text-[17px] font-semibold tracking-tight",children:"Routing insights"}),(0,a.jsxs)("p",{className:"text-xs font-mono text-text-subtle",children:["combo: ",s,o?.strategy?.routerModel?` \xb7 router ${o.strategy.routerModel}`:"",o?.strategy?.objective?` \xb7 ${o.strategy.objective}`:"",o?.strategy?.explorationRate!=null?` \xb7 ε=${Math.round((o.strategy.explorationRate??.05)*100)}% (cap ${Math.round((o.strategy.explorationRateCap??.2)*100)}%)`:""]})]}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2 items-center",children:[(0,a.jsxs)("select",{value:P,onChange:e=>W(Number(e.target.value)||14),className:"text-[11.5px] font-mono text-text-subtle px-2 py-1.5 rounded-[7px] bg-surface-2 border border-border",title:"Date range",children:[(0,a.jsx)("option",{value:7,children:"last 7 days"}),(0,a.jsx)("option",{value:14,children:"last 14 days"}),(0,a.jsx)("option",{value:30,children:"last 30 days"}),(0,a.jsx)("option",{value:90,children:"last 90 days"})]}),(0,a.jsx)(N.$n,{size:"sm",variant:"secondary",onClick:B,disabled:F,children:"Refresh"}),(0,a.jsx)(N.$n,{size:"sm",disabled:F,onClick:async()=>{z("");try{let e=await fetch("/api/routing/learn",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({comboName:s})}),t=await e.json();z(t.message||JSON.stringify(t)),await B()}catch(e){z(e.message)}},children:"Relearn now"}),(0,a.jsx)(n(),{href:"/dashboard/combos",className:"text-xs text-text-muted hover:text-primary px-2 py-1.5",children:"← Combos"})]})]}),T&&(0,a.jsx)("p",{className:"text-xs font-mono text-text-subtle",children:T}),E&&(0,a.jsx)("p",{className:"text-sm text-red-400",children:E}),F&&!o&&(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Loading…"}),o&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[(0,a.jsx)(O,{label:"Requests",value:String(o.eventCount??0)}),(0,a.jsx)(O,{label:"Need for learn",value:o.needMore>0?`${o.needMore} more`:"ready"}),(0,a.jsx)(O,{label:"Active version",value:o.promoted?`v${o.promoted.version}`:"—"}),(0,a.jsx)(O,{label:"Eval score",value:o.promoted?.evalScore!=null?Number(o.promoted.evalScore).toFixed(1):"—"})]}),(0,a.jsxs)("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[(0,a.jsx)(O,{label:"Router-skip %",value:null==eo?"—":`${eo}%`}),(0,a.jsx)(O,{label:"Avg score",value:en>0?(ei/en).toFixed(1):"—"}),(0,a.jsx)(O,{label:"Judge coverage %",value:null==ed?"—":`${ed}%`}),(0,a.jsx)(O,{label:"Total picks",value:String(el)})]}),(0,a.jsxs)("p",{className:"text-[11px] text-text-subtle font-mono -mt-2",children:["Request-level counts (one per chat). Intermediate fallback attempts",null!=o.attemptCount&&o.attemptCount!==o.eventCount?` (${o.attemptCount} attempt rows)`:""," ","feed the bandit but not the min-events gate. Single-worker and heuristic shortcuts are not logged here."]}),(0,a.jsxs)(N.Zp,{padding:"md",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-1 flex-wrap gap-2",children:[(0,a.jsx)("span",{className:"text-[13px] font-semibold",children:"Win-rate heatmap"}),(0,a.jsxs)("div",{className:"flex items-center gap-2 text-[10.5px] font-mono text-text-subtle",children:[(0,a.jsx)("span",{children:"low"}),(0,a.jsx)("span",{className:"w-[120px] h-2 rounded",style:{background:"linear-gradient(90deg,rgba(229,180,84,.1),rgba(229,180,84,.72))"}}),(0,a.jsx)("span",{children:"high \xb7 number always shown"})]})]}),(0,a.jsx)("p",{className:"text-[11.5px] font-mono text-text-subtle mb-3",children:"cluster \xd7 worker \xb7 average outcome score (0–100)"}),o.clusters?.length&&o.workers?.length?(0,a.jsxs)("div",{className:"grid gap-1 overflow-x-auto",style:{gridTemplateColumns:`112px repeat(${o.workers.length}, minmax(56px, 1fr))`},children:[(0,a.jsx)("div",{}),o.workers.map(e=>(0,a.jsx)("div",{className:"font-mono text-[10.5px] text-text-muted text-center pb-1 truncate",title:e,children:e.split("/").pop()},e)),o.heatmap.map(e=>(0,a.jsxs)("div",{className:"contents",children:[(0,a.jsx)("div",{className:"text-[11px] uppercase tracking-wide text-text-muted flex items-center font-medium",children:e.cluster}),e.cells.map(t=>{let s=t.avg,r=null==s||U<=0?0:Math.min(1,s/U);return(0,a.jsx)("div",{className:"rounded text-center font-mono text-[11px] py-2 border border-border",style:{background:`rgba(229,180,84,${.08+.55*r})`,color:null==s?"#6F6653":"#ECE4D2"},title:`${t.worker}: n=${t.n}`,children:null==s?"—":Math.round(s)},`${e.cluster}-${t.worker}`)})]},e.cluster))]}):(0,a.jsx)("p",{className:"text-sm text-text-muted py-6 text-center",children:"No routing events yet. Point a client at this combo with strategy Auto."})]}),(0,a.jsxs)(N.Zp,{padding:"md",children:[(0,a.jsx)("span",{className:"text-[13px] font-semibold",children:"Score trend"}),(0,a.jsx)("p",{className:"text-[11px] text-text-subtle font-mono mb-2",children:"mean outcome score per worker per day (request-level)"}),0===es.length?(0,a.jsx)("p",{className:"text-xs text-text-muted py-6 text-center",children:"No routing data in this window — Auto combos learn as they route"}):(0,a.jsx)(i.u,{width:"100%",height:220,children:(0,a.jsxs)(c.b,{data:es,margin:{top:8,right:12,left:0,bottom:0},children:[(0,a.jsx)(d.d,{strokeDasharray:"3 3",strokeOpacity:.1}),(0,a.jsx)(x.W,{dataKey:"day",tick:{className:"font-mono",fill:"currentColor",fillOpacity:.65,fontSize:10},tickFormatter:e=>String(e).slice(5),tickLine:!1,axisLine:!1}),(0,a.jsx)(m.h,{domain:[0,100],tick:{className:"font-mono",fill:"currentColor",fillOpacity:.65,fontSize:10},tickLine:!1,axisLine:!1,width:32}),(0,a.jsx)(p.m,{contentStyle:w,itemStyle:{color:"var(--color-text)"},labelStyle:{color:"var(--color-text-muted)"},formatter:(e,t)=>[Math.round(Number(e)),t]}),ea.length>=2&&(0,a.jsx)(u.s,{formatter:e=>(0,a.jsx)("span",{className:"font-mono text-[10px] text-text-muted",children:e})}),ea.map(e=>(0,a.jsx)(h.N1,{type:"monotone",dataKey:t=>t[e]??null,name:"Other"===e?"Other":e.split("/").pop(),stroke:"Other"===e?v:V[e],strokeWidth:2,dot:!1,activeDot:{r:4},connectNulls:!0,isAnimationActive:!1},e))]})})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[(0,a.jsxs)(N.Zp,{padding:"md",children:[(0,a.jsx)("span",{className:"text-[13px] font-semibold",children:"Worker comparison"}),(0,a.jsx)("p",{className:"text-[11px] text-text-subtle font-mono mb-3",children:"average outcome score (0–100)"}),0===H.length?(0,a.jsx)("p",{className:"text-xs text-text-muted py-6 text-center",children:"No routing data in this window — Auto combos learn as they route"}):(0,a.jsx)(i.u,{width:"100%",height:Math.max(180,34*H.length),children:(0,a.jsxs)(b.E,{data:H,layout:"vertical",margin:{top:2,right:34,left:0,bottom:0},children:[(0,a.jsx)(d.d,{strokeDasharray:"3 3",strokeOpacity:.1,horizontal:!1}),(0,a.jsx)(x.W,{type:"number",domain:[0,100],tick:{className:"font-mono",fill:"currentColor",fillOpacity:.65,fontSize:10},tickLine:!1,axisLine:!1}),(0,a.jsx)(m.h,{type:"category",dataKey:"workerLabel",width:110,tick:{className:"font-mono",fill:"currentColor",fillOpacity:.65,fontSize:10},tickLine:!1,axisLine:!1}),(0,a.jsx)(p.m,{content:(0,a.jsx)($,{}),contentStyle:w}),(0,a.jsxs)(f.yP,{dataKey:"avgScore",name:"Average score",barSize:16,radius:[0,4,4,0],isAnimationActive:!1,children:[H.map(e=>(0,a.jsx)(g.f,{fill:V[e.worker]||v},e.worker)),(0,a.jsx)(j.Ze,{dataKey:"avgScore",position:"right",formatter:e=>S(e),fill:"var(--color-text-muted)",className:"font-mono"})]})]})})]}),(0,a.jsxs)(N.Zp,{padding:"md",children:[(0,a.jsx)("span",{className:"text-[13px] font-semibold",children:"Pick source"}),(0,a.jsx)("p",{className:"text-[11px] text-text-subtle font-mono mb-3",children:"terminal selections in the selected window"}),0===el?(0,a.jsx)("p",{className:"text-xs text-text-muted py-6 text-center",children:"No routing data in this window — Auto combos learn as they route"}):(0,a.jsx)(i.u,{width:"100%",height:180,children:(0,a.jsxs)(b.E,{data:[{name:"window",...er}],margin:{top:8,right:8,left:0,bottom:0},children:[(0,a.jsx)(d.d,{strokeDasharray:"3 3",strokeOpacity:.1,vertical:!1}),(0,a.jsx)(x.W,{type:"number",tick:{className:"font-mono",fill:"currentColor",fillOpacity:.65,fontSize:10},tickLine:!1,axisLine:!1}),(0,a.jsx)(m.h,{type:"category",dataKey:"name",width:48,tick:{className:"font-mono",fill:"currentColor",fillOpacity:.65,fontSize:10},tickLine:!1,axisLine:!1}),(0,a.jsx)(p.m,{contentStyle:w,itemStyle:{color:"var(--color-text)"},labelStyle:{color:"var(--color-text-muted)"}}),(0,a.jsx)(u.s,{formatter:e=>(0,a.jsx)("span",{className:"font-mono text-[10px] text-text-muted",children:e})}),k.map((e,t)=>(0,a.jsx)(f.yP,{dataKey:e.key,name:e.label,stackId:"s",fill:t<6?y[t]:v,isAnimationActive:!1},e.key))]})})]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[(0,a.jsxs)(N.Zp,{padding:"md",children:[(0,a.jsx)("span",{className:"text-[13px] font-semibold",children:"Model performance"}),(0,a.jsxs)("div",{className:"mt-3 space-y-2",children:[0===(o.modelStats||[]).length&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"No data"}),(o.modelStats||[]).map(e=>(0,a.jsxs)("div",{className:"grid grid-cols-[1fr_52px_60px_40px] gap-2 items-center text-xs",children:[(0,a.jsx)("span",{className:"font-mono truncate text-text-main",title:e.worker,children:e.worker}),(0,a.jsx)("span",{className:"text-right font-mono text-text-muted",children:null!=e.avgScore?Math.round(e.avgScore):"—"}),(0,a.jsx)("span",{className:"text-right font-mono text-text-muted",children:null!=e.avgLatencyMs?`${Math.round(e.avgLatencyMs)}ms`:"—"}),(0,a.jsx)("span",{className:"text-right font-mono text-text-subtle",children:e.errors||0})]},e.worker))]})]}),(0,a.jsxs)(N.Zp,{padding:"md",children:[(0,a.jsx)("span",{className:"text-[13px] font-semibold",children:"Learning versions"}),(0,a.jsx)("p",{className:"text-[11px] text-text-subtle font-mono mb-2",children:"immutable \xb7 rollback-safe"}),(0,a.jsxs)("div",{className:"space-y-2 max-h-64 overflow-y-auto",children:[0===(o.versions||[]).length&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"No versions yet"}),(o.versions||[]).map(e=>(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2 text-xs border-b border-border py-1.5",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("span",{className:"font-mono text-text-main",children:["v",e.version,e.promoted?" \xb7 active":""]}),(0,a.jsxs)("div",{className:"text-[10px] text-text-subtle font-mono",children:["eval ",null!=e.evalScore?Number(e.evalScore).toFixed(1):"—"," \xb7"," ",e.source]})]}),!e.promoted&&(0,a.jsx)("button",{type:"button",className:"text-primary text-[11px] hover:underline",onClick:async()=>{await fetch("/api/routing/versions/promote",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e.id})}),B()},children:"Promote"})]},e.id))]}),o.promoted?.prevVersionId&&(0,a.jsx)(N.$n,{size:"sm",variant:"outline",className:"mt-3",onClick:async()=>{await fetch("/api/routing/versions/rollback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({comboName:s})}),B()},children:"Rollback"})]})]}),(0,a.jsxs)(N.Zp,{padding:"md",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,a.jsx)("span",{className:"text-[13px] font-semibold",children:"Recent decisions"}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2","aria-label":"Filter recent decisions",children:[(0,a.jsx)("span",{className:"text-[10.5px] font-mono text-text-subtle",children:"filter decisions:"}),(0,a.jsxs)("select",{value:Z,onChange:e=>I(e.target.value),className:"text-[11.5px] font-mono text-text-subtle px-2 py-1.5 rounded-[7px] bg-surface-2 border border-border max-w-[140px]",title:"Filter recent decisions by cluster","aria-label":"Filter recent decisions by cluster",children:[(0,a.jsx)("option",{value:"",children:"all clusters"}),(o?.clusters||[]).map(e=>(0,a.jsx)("option",{value:e,children:e},e))]}),(0,a.jsxs)("select",{value:K,onChange:e=>J(e.target.value),className:"text-[11.5px] font-mono text-text-subtle px-2 py-1.5 rounded-[7px] bg-surface-2 border border-border max-w-[160px]",title:"Filter recent decisions by worker","aria-label":"Filter recent decisions by worker",children:[(0,a.jsx)("option",{value:"",children:"all workers"}),(o?.workers||[]).map(e=>(0,a.jsx)("option",{value:e,children:e.split("/").pop()},e))]}),(0,a.jsxs)("label",{className:"inline-flex items-center gap-1 text-[11px] text-text-muted cursor-pointer",children:[(0,a.jsx)("input",{type:"checkbox",className:"rounded border-border",checked:q,onChange:e=>D(e.target.checked)}),"exploration only"]})]})]}),(0,a.jsxs)("div",{className:"mt-3 overflow-x-auto",children:[(0,a.jsxs)("table",{className:"w-full text-left text-xs",children:[(0,a.jsx)("thead",{className:"text-text-subtle font-mono uppercase tracking-wide",children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:"py-1 pr-2",children:"Time"}),(0,a.jsx)("th",{className:"py-1 pr-2",children:"Cluster"}),(0,a.jsx)("th",{className:"py-1 pr-2",children:"Worker"}),(0,a.jsx)("th",{className:"py-1 pr-2",children:"Score"}),(0,a.jsx)("th",{className:"py-1 pr-2",children:"Reason"}),(0,a.jsx)("th",{className:"py-1",children:"Rate"})]})}),(0,a.jsx)("tbody",{children:(o.recent||[]).map(e=>{let t=e.meta?.userRating??null;return(0,a.jsxs)("tr",{className:"border-t border-border",children:[(0,a.jsxs)("td",{className:"py-1.5 pr-2 font-mono text-text-muted whitespace-nowrap",children:[C(e.timestamp),e.meta?.scheduleSkips?.length?(0,a.jsxs)("span",{className:"ml-1 text-[9px] text-amber-600 dark:text-amber-400",title:e.meta.scheduleSkips.map(e=>`skipped ${e.model} (${e.availability}; provider ${"peak"===e.status?"peak":"off-peak"} until ${e.until})`).join("\n"),children:["⏱",e.meta.scheduleSkips.length]}):null,e.meta?.exploration?(0,a.jsx)("span",{className:"ml-1 text-[9px] text-primary",children:"ε"}):null,e.meta?.judgeScore!=null?(0,a.jsxs)("span",{className:"ml-1 text-[9px] text-text-subtle",title:`LLM-judge score ${e.meta.judgeScore}/10`,children:["J",e.meta.judgeScore]}):null]}),(0,a.jsx)("td",{className:"py-1.5 pr-2",children:e.cluster||"—"}),(0,a.jsx)("td",{className:"py-1.5 pr-2 font-mono truncate max-w-[160px]",title:e.pickedWorker,children:e.pickedWorker?.split("/").pop()||"—"}),(0,a.jsx)("td",{className:"py-1.5 pr-2 font-mono",children:null!=e.outcomeScore?Math.round(e.outcomeScore):"—"}),(0,a.jsx)("td",{className:"py-1.5 pr-2 text-text-muted truncate max-w-[240px]",title:e.routerReason,children:e.routerReason||"—"}),(0,a.jsx)("td",{className:"py-1.5 whitespace-nowrap",children:e.requestId?(0,a.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,a.jsx)("button",{type:"button",title:"Good route",className:`text-[13px] leading-none ${1===t?"text-primary":"text-text-subtle hover:text-primary"}`,onClick:()=>G(e.requestId,+(1!==t)),children:"▲"}),(0,a.jsx)("button",{type:"button",title:"Bad route",className:`text-[13px] leading-none ${-1===t?"text-red-400":"text-text-subtle hover:text-red-400"}`,onClick:()=>G(e.requestId,-1===t?0:-1),children:"▼"})]}):(0,a.jsx)("span",{className:"text-[10px] text-text-subtle",children:"—"})})]},e.id)})})]}),!(o.recent||[]).length&&(0,a.jsx)("p",{className:"text-xs text-text-muted py-4 text-center",children:"No decisions logged"})]})]}),(0,a.jsxs)(N.Zp,{padding:"md",children:[(0,a.jsx)("span",{className:"text-[13px] font-semibold",children:"Exploration log"}),(0,a.jsx)("p",{className:"text-[11px] text-text-subtle font-mono mb-2",children:"epsilon-greedy random picks (meta.exploration)"}),(0,a.jsxs)("div",{className:"space-y-1.5 max-h-48 overflow-y-auto",children:[0===(o.explorationLog||[]).length&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"No exploration events in this window"}),(o.explorationLog||[]).map(e=>(0,a.jsxs)("div",{className:"flex flex-wrap gap-2 text-[11px] font-mono border-b border-border py-1",children:[(0,a.jsx)("span",{className:"text-text-muted",children:C(e.timestamp)}),(0,a.jsx)("span",{children:e.cluster||"—"}),(0,a.jsx)("span",{className:"text-primary",children:e.pickedWorker?.split("/").pop()}),(0,a.jsxs)("span",{className:"text-text-subtle",children:["score ",null!=e.outcomeScore?Math.round(e.outcomeScore):"—"]})]},`ex-${e.id}`))]})]})]})]}):(0,a.jsxs)("div",{className:"max-w-lg space-y-3",children:[(0,a.jsx)("h1",{className:"text-[17px] font-semibold",children:"Routing insights"}),(0,a.jsxs)("p",{className:"text-sm text-text-muted",children:["Open from a combo card with strategy ",(0,a.jsx)("strong",{children:"Auto"}),", or append"," ",(0,a.jsx)("code",{className:"text-xs",children:"?combo=your-combo"}),"."]}),(0,a.jsx)(n(),{href:"/dashboard/combos",className:"text-sm text-primary hover:underline",children:"← Combos"})]})}function O({label:e,value:t}){return(0,a.jsxs)("div",{className:"rounded-[11px] border border-border bg-surface p-3.5",children:[(0,a.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-text-subtle mb-1.5",children:e}),(0,a.jsx)("div",{className:"font-mono text-[18px] font-semibold text-text-main",children:t})]})}},63759:(e,t,s)=>{Promise.resolve().then(s.bind(s,61872))}},e=>{e.O(0,[2574,3862,782,8500,594,136,1321,4707,1330,8441,3794,7358],()=>e(e.s=63759)),_N_E=e.O()}]);
|
package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/[id]/page-68344fb15a77b2c5.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2134],{7687:(e,t,s)=>{Promise.resolve().then(s.bind(s,58046))},48874:(e,t,s)=>{"use strict";async function a(e,t){let s=await fetch(e,{...t,headers:{"Content-Type":"application/json",...t?.headers||{}},credentials:"same-origin"}),a=null;try{a=await s.json()}catch{a=null}if(!s.ok){let e=a&&(a.error||a.message)||`Request failed (${s.status})`,t=Error("string"==typeof e?e:"Request failed");throw t.status=s.status,t.data=a,t}return a}s.d(t,{x:()=>a})},53578:(e,t,s)=>{"use strict";s.d(t,{T:()=>i});let a=Symbol("delete-provider-strategy"),r=Promise.resolve();async function i(e,t,s=fetch){let a=r.then(()=>l(e,t,s));return r=a.catch(()=>{}),a}async function l(e,t,s){let r=await s("/api/settings",{cache:"no-store"});if(!r.ok)throw Error(`Failed to load settings (${r.status})`);let i=(await r.json()).providerStrategies||{},l=i[e]||{},n=t(l);if(void 0===n)return console.warn(`[patchProviderStrategy] updater for "${e}" returned undefined; keeping previous entry`),l;let o={...i};n===a?delete o[e]:n&&Object.keys(n).length>0?o[e]=n:delete o[e];let d=await s("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerStrategies:o})});if(!d.ok)throw Error(`Failed to save settings (${d.status})`);return n===a?void 0:n}},58046:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>X});var a=s(95155),r=s(12115),i=s(73321),l=s(98500),n=s.n(l),o=s(5772),d=s(35497),c=s(88105),m=s(28777),u=s(16600),p=s(47224);let x=["none","low","medium","high"],h=["none","thinking"],f=["none","low","medium","high","max"],b={openai:["none","minimal","low","medium","high","xhigh"],"claude-adaptive":f,"claude-budget":["none","low","medium","high","xhigh","max"],"gemini-level":["minimal","low","medium","high"],"gemini-budget":x,zai:h,qwen:x,kimi:f,deepseek:["none","high","max"],minimax:h,hunyuan:x,step:x},g=[{pattern:"*codex*",levels:["low","medium","high","xhigh"]}];function y(e,t){let s=(0,u.nl)(e,t);if(!s.reasoning)return null;let a=g.find(e=>(0,p.gH)(e.pattern,t)),r=a?.levels||b[s.thinkingFormat]||x;return!1===s.thinkingCanDisable&&(r=r.filter(e=>"none"!==e)),r}var v=s(11059),j=s(929),w=s(73006);let k=new Map;async function N(e){if(!e?.url||!e?.type||e.requiresAuth)return[];let t=k.get(e.url);if(t&&Date.now()<t.expiresAt)return t.data;try{let t=new URLSearchParams({url:e.url,type:e.type}),s=await fetch(`/api/providers/suggested-models?${t}`);if(!s.ok)return[];let a=(await s.json()).data??[];return k.set(e.url,{data:a,expiresAt:Date.now()+6e5}),a}catch{return[]}}var C=s(81231),S=s(68501),$=s(14051),A=s.n($);function T({model:e,fullModel:t,alias:s,copied:r,onCopy:i,testStatus:l,isCustom:n,isFree:o,onDeleteAlias:c,onTest:m,isTesting:u,onDisable:p,caps:x,thinkingSuffix:h,latencyMs:f,probeState:b}){let g=h?`${t}(${h})`:t,y="ok"===l||"ok"===b,v="error"===l||"dead"===b,j="retry"===b||u||"testing"===b;return(0,a.jsx)("div",{className:`group relative min-w-0 max-w-full rounded-xl border bg-surface/50 p-3 transition-all hover:bg-surface/80 hover:shadow-soft ${y?"border-green-500/30 hover:border-green-500/50":v?"border-red-500/30 hover:border-red-500/50":j?"border-amber-500/30 hover:border-amber-500/50":"border-border/60 hover:border-primary/40"}`,children:(0,a.jsxs)("div",{className:"flex min-w-0 items-start justify-between gap-2.5",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-1 items-start gap-2.5",children:[(0,a.jsx)("div",{className:"mt-0.5 flex size-7 shrink-0 items-center justify-center rounded-lg bg-surface-2 border border-border/40 text-text-muted",children:u||"testing"===b?(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 animate-spin text-[15px] text-primary",title:"Testing model...",children:"progress_activity"}):y?(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-[16px] text-green-500",title:"Model reachable",children:"check_circle"}):v?(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-[16px] text-red-500",title:"Model unavailable",children:"cancel"}):"retry"===b?(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-[16px] text-amber-500",title:"Retry later",children:"schedule"}):(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-[16px]","aria-hidden":"true",children:"smart_toy"})}),(0,a.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap",children:[(0,a.jsx)("code",{className:"max-w-[70vw] truncate rounded-md bg-surface-2 border border-border/40 px-2 py-0.5 font-mono text-xs font-medium text-text-main sm:max-w-[340px]",children:g}),n&&(0,a.jsx)("span",{className:"rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary",children:"Custom"})]}),(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2 text-xs",children:[e.name&&(0,a.jsx)("span",{className:"truncate text-xs text-text-muted",children:e.name}),Number.isFinite(f)&&(0,a.jsxs)("span",{className:"inline-flex items-center gap-0.5 text-[11px] font-medium text-text-muted tabular-nums",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px] text-primary",children:"bolt"}),Math.round(f),"ms"]}),(0,a.jsx)(d.nh,{caps:x,colorOverride:"text-text-muted/80",size:13})]})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[m&&(0,a.jsx)("button",{onClick:m,disabled:u,"aria-label":u?`Testing ${g}`:`Test ${g}`,title:u?"Testing...":"Test model",className:`rounded-lg p-1 text-text-muted transition-all hover:bg-surface-2 hover:text-primary ${u?"opacity-100":"opacity-70 group-hover:opacity-100"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]","aria-hidden":"true",style:u?{animation:"spin 1s linear infinite"}:void 0,children:u?"progress_activity":"science"})}),(0,a.jsx)("button",{onClick:()=>i(g,`model-${e.id}`),"aria-label":r===`model-${e.id}`?`Copied ${g}`:`Copy ${g}`,title:r===`model-${e.id}`?"Copied!":"Copy model name",className:"rounded-lg p-1 text-text-muted transition-all hover:bg-surface-2 hover:text-primary opacity-70 group-hover:opacity-100",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]","aria-hidden":"true",children:r===`model-${e.id}`?"check":"content_copy"})}),n?(0,a.jsx)("button",{onClick:c,className:"rounded-lg p-1 text-text-muted transition-all hover:bg-red-500/10 hover:text-red-400 opacity-60 hover:opacity-100","aria-label":`Remove custom model ${g}`,title:"Remove custom model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]","aria-hidden":"true",children:"close"})}):p?(0,a.jsx)("button",{onClick:p,className:"rounded-lg p-1 text-text-muted transition-all hover:bg-red-500/10 hover:text-red-400 opacity-60 hover:opacity-100","aria-label":`Disable ${g}`,title:"Disable this model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]","aria-hidden":"true",children:"close"})}):null]})]})})}T.propTypes={model:A().shape({id:A().string.isRequired}).isRequired,fullModel:A().string.isRequired,alias:A().string,copied:A().string,onCopy:A().func.isRequired,testStatus:A().oneOf(["ok","error"]),isCustom:A().bool,isFree:A().bool,onDeleteAlias:A().func,onTest:A().func,isTesting:A().bool,onDisable:A().func,caps:A().object,thinkingSuffix:A().string,latencyMs:A().number,probeState:A().string};var O=s(78559);function E({modelId:e,fullModel:t,copied:s,onCopy:r,onDeleteAlias:i,onTest:l,testStatus:n,isTesting:o}){let d="ok"===n?"#22c55e":"error"===n?"#ef4444":void 0;return(0,a.jsxs)("div",{className:`flex items-center gap-3 p-3 rounded-lg border ${"ok"===n?"border-green-500/40":"error"===n?"border-red-500/40":"border-border"} hover:bg-sidebar/50`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base text-text-muted",style:d?{color:d}:void 0,children:"ok"===n?"check_circle":"error"===n?"cancel":"smart_toy"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"text-sm font-medium truncate",children:e}),(0,a.jsxs)("div",{className:"flex items-center gap-1 mt-1",children:[(0,a.jsx)("code",{className:"text-xs text-text-muted font-mono bg-sidebar px-1.5 py-0.5 rounded",children:t}),(0,a.jsxs)("div",{className:"relative group/btn",children:[(0,a.jsx)("button",{onClick:()=>r(t,`model-${e}`),className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:s===`model-${e}`?"check":"content_copy"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:s===`model-${e}`?"Copied!":"Copy"})]}),l&&(0,a.jsxs)("div",{className:"relative group/btn",children:[(0,a.jsx)("button",{onClick:l,disabled:o,className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",style:o?{animation:"spin 1s linear infinite"}:void 0,children:o?"progress_activity":"science"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:o?"Testing...":"Test"})]})]})]}),(0,a.jsx)("button",{onClick:i,className:"p-1 hover:bg-red-50 rounded text-red-500",title:"Remove model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"delete"})})]})}function R({providerStorageAlias:e,providerDisplayAlias:t,modelAliases:s,customModels:i,copied:l,onCopy:n,onDeleteAlias:o,onAddCustomModel:c,onDeleteCustomModel:m,onRefreshModels:u,connections:p,isAnthropic:x,disabledModelIds:h=[],onEnableModel:f}){let[b,g]=(0,r.useState)(""),[y,v]=(0,r.useState)(!1),[j,w]=(0,r.useState)(!1),[k,N]=(0,r.useState)(""),[S,$]=(0,r.useState)(null),[A,T]=(0,r.useState)({}),I=async t=>{if(!S){$(t);try{let s=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${e}/${t}`})}),a=await s.json();T(e=>({...e,[t]:a.ok?"ok":"error"}))}catch{T(e=>({...e,[t]:"error"}))}finally{$(null)}}},D=(0,C.Iz)(h,e),P=[...D],M=(0,C.R3)({customModels:i,modelAliases:s,providerAlias:e,type:"llm"}),z=M.filter(t=>!(0,C.uJ)(D,t.id,e)),U=async()=>{if(!b.trim()||y)return;let t=b.trim();if(z.some(e=>e.id===t))return void(0,O.s)("Model already exists for this provider.");v(!0);try{if((0,C.uJ)(D,t,e)){let e=await f?.(t);if(!1===e)throw Error("Failed to enable removed model")}await c(t),g("")}catch(e){(0,O.s)("Error adding model:",e)}finally{v(!1)}},q=async()=>{if(j)return;let t=p.find(e=>!1!==e.isActive);if(t){w(!0),N("");try{let s=await fetch(`/api/providers/${t.id}/models`),a=await s.json().catch(()=>({}));if(!s.ok)return void(0,O.s)(a.error||"Failed to import models");let r=a.models||[];if(0===r.length)return void(0,O.s)("No models returned from /models.");let i=new Set(M.map(e=>e.id)),l=[],n=new Set;for(let t of r){let s=String(t.id||t.name||t.model||"").trim();!s||i.has(s)||n.has(s)||(0,C.uJ)(D,s,e)||(n.add(s),l.push({providerAlias:e,id:s,type:"llm",name:t.display_name||t.displayName||t.name||s}))}if(0===l.length)return void N("All models already in list");let o=await fetch("/api/models/custom",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({models:l})}),d=await o.json().catch(()=>({}));if(!o.ok){let e=0;for(let t of l)await c(t.id),e+=1;N(e?`Imported ${e} model(s)`:"No new models were added");return}N(`Imported ${d.added??l.length} model(s)`),"function"==typeof u?await u():window.dispatchEvent(new CustomEvent("customModelChanged"))}catch(e){(0,O.s)("Error importing models:",e),(0,O.s)(e?.message||"Import failed")}finally{w(!1)}}},_=p.some(e=>!1!==e.isActive);return(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("p",{className:"text-sm text-text-muted",children:["Add ",x?"Anthropic":"OpenAI","-compatible models manually or import them from the /models endpoint."]}),(0,a.jsxs)("div",{className:"flex items-end gap-2 flex-wrap",children:[(0,a.jsxs)("div",{className:"flex-1 min-w-[240px]",children:[(0,a.jsx)("label",{htmlFor:"new-compatible-model-input",className:"text-xs text-text-muted mb-1 block",children:"Model ID"}),(0,a.jsx)("input",{id:"new-compatible-model-input",type:"text",value:b,onChange:e=>g(e.target.value),onKeyDown:e=>"Enter"===e.key&&U(),placeholder:x?"claude-3-opus-20240229":"gpt-4o",className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})]}),(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:U,disabled:!b.trim()||y,children:y?"Adding...":"Add"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"cloud_download",onClick:q,disabled:!_||j,children:j?"Importing...":"Import models"})]}),!_&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Add a connection to enable importing models."}),k&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:k}),z.length>0&&(0,a.jsx)("div",{className:"flex flex-col gap-3",children:z.map(({id:s,alias:r,source:i})=>(0,a.jsx)(E,{modelId:s,fullModel:`${t}/${s}`,copied:l,onCopy:n,onDeleteAlias:()=>"custom"===i?m(s):o(r),onTest:p.length>0?()=>I(s):void 0,testStatus:A[s],isTesting:S===s},`${i}-${e}/${s}`))}),P.length>0&&(0,a.jsxs)("details",{className:"rounded-lg border border-border bg-surface/30 p-3",children:[(0,a.jsxs)("summary",{className:"cursor-pointer text-sm font-medium text-text-main",children:["Removed models (",P.length,")"]}),(0,a.jsx)("p",{className:"mt-1 text-xs text-text-muted",children:"Enable a model to make it available for import and selection again."}),(0,a.jsx)("div",{className:"mt-3 flex max-h-56 flex-col gap-1.5 overflow-y-auto",children:P.map(e=>(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3 rounded border border-border bg-background px-2 py-1.5",children:[(0,a.jsx)("code",{className:"min-w-0 flex-1 truncate text-xs",title:e,children:e}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",onClick:()=>f?.(e),children:"Enable"})]},e))})]})]})}A().string.isRequired,A().string.isRequired,A().string,A().func.isRequired,A().func.isRequired,A().func,A().oneOf(["ok","error"]),A().bool,A().string.isRequired,A().object.isRequired,A().arrayOf(A().object),A().string,A().func.isRequired,A().func.isRequired,A().func.isRequired,A().func.isRequired,R.propTypes={providerStorageAlias:A().string.isRequired,providerDisplayAlias:A().string.isRequired,modelAliases:A().object.isRequired,customModels:A().arrayOf(A().object),copied:A().string,onCopy:A().func.isRequired,onDeleteAlias:A().func.isRequired,onAddCustomModel:A().func.isRequired,onDeleteCustomModel:A().func.isRequired,onRefreshModels:A().func,connections:A().arrayOf(A().shape({id:A().string,isActive:A().bool})).isRequired,isAnthropic:A().bool,disabledModelIds:A().arrayOf(A().string),onEnableModel:A().func};var I=s(70217);function D({until:e}){let[t,s]=(0,r.useState)("");return((0,r.useEffect)(()=>{let t=()=>{let t=new Date(e).getTime()-Date.now();if(t<=0)return void s("");let a=Math.floor(t/1e3);if(a<60)s(`${a}s`);else if(a<3600)s(`${Math.floor(a/60)}m ${a%60}s`);else{let e=Math.floor(a/3600),t=Math.floor(a%3600/60);s(`${e}h ${t}m`)}};t();let a=setInterval(t,1e3);return()=>clearInterval(a)},[e]),t)?(0,a.jsxs)("span",{className:"text-xs text-orange-500 font-mono",children:["⏱ ",t]}):null}function P({connection:e,isOAuth:t,isFirst:s,isLast:i,onMoveUp:l,onMoveDown:n,onToggleActive:o,onEdit:c,onDelete:m,onAllowlistHost:u=null,oneByOneStatus:p=null,autoPing:x=null}){let h=e.authType||(t?"oauth":"apikey"),f="oauth"===h,b="cookie"===h,g=e.name?.trim()||e.email?.trim()||e.displayName?.trim()||(f?"OAuth Account":b?"Cookie Account":"API Key"),y=e.name?.trim()&&e.email?.trim()&&e.name.trim()!==e.email.trim()?e.email.trim():e.name?.trim()&&e.displayName?.trim()&&e.name.trim()!==e.displayName.trim()?e.displayName.trim():null,v=/SSRF blocked|Blocked URL: (private IP|internal host)/i.test(e.lastError||""),j=(e=>{if(!e)return null;let t=String(e).trim();try{let e=t.match(/\{[\s\S]*\}$/);if(e){let s=JSON.parse(e[0]),a=s?.error?.message||s?.message||s?.error;"string"==typeof a&&a.trim()&&(t=a.trim())}}catch{}return(t=t.replace(/^\[\d+\]:\s*/,""),/not have a valid license|license of this product|license required/i.test(t))?{type:"license",title:"License Required",message:"No active Gemini Code Assist or Antigravity license found for this Google account. Visit antigravity.google to activate, or reconnect.",action:f?"reconnect":null}:/invalid_grant|token expired|credentials expired|expired or revoked|session expired/i.test(t)?{type:"auth",title:"Session Expired",message:"OAuth token expired or was revoked. Please reconnect.",action:f?"reconnect":null}:/rate limit|quota|429|resource has been exhausted/i.test(t)?{type:"quota",title:"Rate Limited",message:t||"Upstream rate limit reached.",action:null}:v?{type:"ssrf",title:"Network Guard",message:"SSRF guard blocked local/private IP address.",action:"allowlist"}:{type:"error",title:"Error",message:t,action:f?"reconnect":null}})(e.lastError),w=e.providerSpecificData?.connectionProxyEnabled===!0&&!!e.providerSpecificData?.connectionProxyUrl,k=w?`Proxy: ${e.providerSpecificData?.connectionProxyUrl}`:"",N=x?.provider==="codex"?"Auto-starts the next 5h Codex window after reset by sending a tiny gpt-5.5 request. Consumes a small amount of quota.":"When your 5h quota runs out, auto-sends a request the moment it resets so a new window starts right away.",C="";if(e.providerSpecificData?.connectionProxyUrl){let t=e.providerSpecificData?.connectionProxyUrl;try{let e=new URL(t);C=`${e.protocol}//${e.hostname}${e.port?`:${e.port}`:""}`}catch{C=t}}let S=e.providerSpecificData?.connectionNoProxy||"",$=w?"success":"default",[A,T]=(0,r.useState)(!1),O=Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>e).filter(e=>!!e).sort()[0]||null;(0,r.useEffect)(()=>{let t=()=>{T(!!Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>e).filter(e=>e&&new Date(e).getTime()>Date.now()).sort()[0])};t();let s=O?setInterval(t,1e3):null;return()=>{s&&clearInterval(s)}},[e,O]);let E="unavailable"!==e.testStatus||A?e.testStatus:"active",R=()=>p?"queued"===p.state?"queued":"testing"===p.state?"testing":"success"===p.state?"success":"failed"===p.state?p.error?`failed: ${p.error}`:"failed":null:null;return(0,a.jsx)("div",{className:`group flex min-w-0 flex-col gap-3 rounded-xl border border-border/60 bg-surface/40 p-3 transition-all hover:border-border hover:bg-surface/70 ${!1===e.isActive?"opacity-60":""}`,children:(0,a.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-2.5",children:[(0,a.jsxs)("div",{className:"flex shrink-0 flex-col",children:[(0,a.jsx)("button",{onClick:l,disabled:s,"aria-label":`Move ${g} up`,title:`Move ${g} up`,className:`p-0.5 rounded ${s?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm","aria-hidden":"true",children:"keyboard_arrow_up"})}),(0,a.jsx)("button",{onClick:n,disabled:i,"aria-label":`Move ${g} down`,title:`Move ${g} down`,className:`p-0.5 rounded ${i?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm","aria-hidden":"true",children:"keyboard_arrow_down"})})]}),(0,a.jsx)("div",{className:"flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-2 border border-border/40 text-text-muted",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]","aria-hidden":"true",children:b?"cookie":f?"lock":"key"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:"text-sm font-medium text-text-main truncate",children:g}),y&&(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:y})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[x&&(0,a.jsx)(d.m_,{text:N,children:(0,a.jsxs)("button",{onClick:()=>x.onToggle(!x.on),className:`flex items-center gap-1 rounded-lg px-2 py-1 text-xs transition-colors hover:bg-white/5 ${x.on?"text-primary bg-primary/10 font-medium":"text-text-muted hover:text-primary"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"bolt"}),(0,a.jsx)("span",{className:"hidden sm:inline text-xs",children:"Auto-ping"})]})}),(0,a.jsxs)("button",{onClick:c,className:"flex items-center gap-1 rounded-lg px-2.5 py-1 text-xs text-text-muted hover:bg-white/5 hover:text-primary transition-colors",title:"Edit connection",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"edit"}),(0,a.jsx)("span",{className:"hidden sm:inline",children:"Edit"})]}),(0,a.jsxs)("button",{onClick:m,className:"flex items-center gap-1 rounded-lg px-2.5 py-1 text-xs text-red-400 hover:bg-red-500/10 transition-colors",title:"Delete connection",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"delete"}),(0,a.jsx)("span",{className:"hidden sm:inline",children:"Delete"})]})]}),(0,a.jsx)("div",{className:"h-4 w-px bg-border/60 mx-1"}),(0,a.jsx)(d.lM,{size:"sm",checked:e.isActive??!0,onChange:o,title:e.isActive??!0?"Disable connection":"Enable connection"})]})]}),(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5 pl-0 sm:pl-10",children:[(0,a.jsx)(d.Ex,{variant:(0,I.g)(e.isActive,E),size:"sm",dot:!0,children:!1===e.isActive?"disabled":E||"Unknown"}),(0,a.jsx)(d.Ex,{variant:"default",size:"sm",children:f?"OAuth":b?"Cookie":"API Key"}),w&&(0,a.jsx)(d.Ex,{variant:$,size:"sm",children:"Proxy"}),A&&!1!==e.isActive&&(0,a.jsx)(D,{until:O}),(0,a.jsxs)("span",{className:"text-xs text-text-muted",children:["#",e.priority]}),e.globalPriority&&(0,a.jsxs)("span",{className:"text-xs text-text-muted",children:["Auto: ",e.globalPriority]}),R()&&(0,a.jsx)(d.Ex,{variant:p?"success"===p.state?"success":"failed"===p.state?"error":"testing"===p.state?"primary":"default":"default",size:"sm",children:R()})]}),j&&!1!==e.isActive&&(0,a.jsxs)("div",{className:"mt-1.5 flex min-w-0 flex-col sm:flex-row sm:items-center justify-between gap-2 rounded-lg border border-red-500/25 bg-red-500/8 px-3 py-2 text-xs text-red-600 dark:text-red-400 sm:ml-10",children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-start sm:items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-[16px] text-red-500 mt-0.5 sm:mt-0",children:"license"===j.type?"workspace_premium":"auth"===j.type?"key_off":"error"}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("span",{className:"font-semibold",children:[j.title,": "]}),(0,a.jsx)("span",{className:"break-words",children:j.message})]})]}),"reconnect"===j.action&&(0,a.jsxs)("button",{onClick:c,className:"inline-flex shrink-0 items-center justify-center gap-1 rounded-md bg-red-500/15 hover:bg-red-500/25 px-2.5 py-1 text-xs font-medium text-red-600 dark:text-red-300 transition-colors",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"refresh"}),"Reconnect"]}),"allowlist"===j.action&&u&&(0,a.jsxs)("button",{onClick:u,className:"inline-flex shrink-0 items-center justify-center gap-1 rounded-md border border-amber-500/40 bg-amber-500/10 px-2.5 py-1 text-xs font-medium text-amber-600 dark:text-amber-300 hover:bg-amber-500/20 transition-colors",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"verified_user"}),"Add to allow list"]})]}),w&&(0,a.jsxs)("div",{className:"mt-1 flex items-center gap-2 flex-wrap sm:ml-10",children:[(0,a.jsx)("span",{className:"max-w-full truncate text-[11px] text-text-muted sm:max-w-[420px]",title:k,children:k}),C&&(0,a.jsx)("code",{className:"max-w-full truncate rounded bg-black/5 px-1 py-0.5 font-mono text-[10px] text-text-muted dark:bg-white/5 sm:max-w-[260px]",children:C}),S&&(0,a.jsxs)("span",{className:"max-w-full truncate text-[11px] text-text-muted sm:max-w-[320px]",title:S,children:["no_proxy: ",S]})]})]})})}D.propTypes={until:A().string.isRequired},P.propTypes={connection:A().shape({id:A().string,name:A().string,email:A().string,displayName:A().string,modelLockUntil:A().string,testStatus:A().string,isActive:A().bool,lastError:A().string,priority:A().number,globalPriority:A().number,providerSpecificData:A().object}).isRequired,isOAuth:A().bool.isRequired,isFirst:A().bool.isRequired,isLast:A().bool.isRequired,onMoveUp:A().func.isRequired,onMoveDown:A().func.isRequired,onToggleActive:A().func.isRequired,onEdit:A().func.isRequired,onDelete:A().func.isRequired,onAllowlistHost:A().func,oneByOneStatus:A().shape({state:A().string,error:A().string}),autoPing:A().shape({on:A().bool,onToggle:A().func,provider:A().string})};let M=`name1|sk-key1
|
|
2
|
+
name2|sk-key2
|
|
3
|
+
sk-key-only-auto-named`;function z({isOpen:e,provider:t,providerName:s,isCompatible:i,isAnthropic:l,authType:n,authHint:o,website:m,error:u,onSave:p,onBulkDone:x,onClose:h}){let f="ollama-local"===t,b=t.startsWith("selfhosted-"),g="cookie"===n,y="xai"===t&&!g,v=g?"Cookie Value":"API Key",j=g?"grok-web"===t?"sso=xxxxx... or just the raw value":"eyJhbGciOi...":y?"xai-...":"",w="azure"===t,k="cloudflare-ai"===t,N=c.Q2?.[t]?.regions||null,C=c.Q2?.[t]?.defaultRegion||N?.[0]?.id||"",[S,$]=(0,r.useState)({name:"",apiKey:"",defaultModel:"",priority:1,ollamaHostUrl:"",baseUrl:""}),[A,T]=(0,r.useState)({azureEndpoint:"",apiVersion:"2024-10-01-preview",deployment:"",organization:""}),[O,E]=(0,r.useState)({accountId:""}),[R,I]=(0,r.useState)(C),[D,P]=(0,r.useState)(!1),[U,q]=(0,r.useState)(null),[_,F]=(0,r.useState)(!1),[J,L]=(0,r.useState)("single"),[K,B]=(0,r.useState)(""),[W,H]=(0,r.useState)(null),V=S.name.trim().length>0,G=S.apiKey.trim().length>0,Z=()=>b?{baseUrl:S.baseUrl.trim()}:f&&S.ollamaHostUrl.trim()?{baseUrl:S.ollamaHostUrl.trim()}:w?{azureEndpoint:A.azureEndpoint,apiVersion:A.apiVersion,deployment:A.deployment,organization:A.organization}:k?{accountId:O.accountId}:N&&R?{region:R}:void 0,Q=async()=>{let e=S.apiKey.trim();if(e){P(!0);try{let s=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:e,providerSpecificData:Z()})}),a=await s.json();q(a.valid?"success":"failed")}catch{q("failed")}finally{P(!1)}}},Y=async()=>{if(!t)return;let e=S.name.trim(),s=S.apiKey.trim();if((f||b||s)&&(!b||S.baseUrl.trim())&&(f||e)&&(!i||S.defaultModel.trim())){F(!0);try{let a=!1;try{P(!0),q(null);let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:s,providerSpecificData:Z()})});a=!!(await e.json()).valid,q(a?"success":"failed")}catch{q("failed")}finally{P(!1)}await p({name:e||(f?"Ollama Local":""),apiKey:s,defaultModel:i?S.defaultModel.trim():void 0,priority:S.priority,testStatus:a?"active":"unknown",providerSpecificData:Z()})}finally{F(!1)}}},X=async()=>{let e=K.split("\n").map(e=>e.trim()).filter(Boolean);if(!e.length)return;F(!0),H(null);let s=0,a=0;for(let r=0;r<e.length;r++){let i=e[r].split("|"),l=i.length>=2?i.slice(1).join("|").trim():i[0].trim();if(!l){a++;continue}let n=i.length>=2&&i[0].trim()||"Key",o=`${n} ${r+1}`;try{(await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:l,name:o,priority:1,testStatus:"unknown"})})).ok?s++:a++}catch{a++}}F(!1),H({success:s,failed:a}),s>0&&x&&x()};return t?(0,a.jsx)(d.aF,{isOpen:e,title:`Add ${s||t} ${v}`,onClose:h,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[!b&&(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{size:"sm",variant:"single"===J?"primary":"ghost",onClick:()=>{L("single"),H(null)},children:"Single"}),(0,a.jsx)(d.$n,{size:"sm",variant:"bulk"===J?"primary":"ghost",onClick:()=>{L("bulk"),H(null)},children:"Bulk Add"})]}),"bulk"===J&&!b&&(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["One key per line. Format: ",(0,a.jsx)("code",{children:"name|apiKey"})," or just ",(0,a.jsx)("code",{children:"apiKey"})," (auto-named by index)."]}),(0,a.jsx)("textarea",{className:"w-full rounded border border-accent/30 bg-sidebar p-2 text-sm font-mono resize-y min-h-[140px] focus:outline-none focus:ring-1 focus:ring-primary",placeholder:M,value:K,onChange:e=>B(e.target.value)}),W&&(0,a.jsxs)("div",{className:`text-sm font-medium ${W.failed>0?"text-yellow-400":"text-green-400"}`,children:["✓ ",W.success," added",W.failed>0?`, ✗ ${W.failed} failed`:""]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{onClick:X,fullWidth:!0,disabled:_||!K.trim(),children:_?"Adding...":"Add All Keys"}),(0,a.jsx)(d.$n,{onClick:h,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),("single"===J||b)&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.pd,{label:"Name",value:S.name,onChange:e=>$({...S,name:e.target.value}),placeholder:f?"Ollama Local":"Production Key"}),b&&(0,a.jsx)(d.pd,{label:"Base URL",value:S.baseUrl,onChange:e=>$({...S,baseUrl:e.target.value}),placeholder:"selfhosted-stt"===t?"http://localhost:8080/v1/audio/transcriptions":"selfhosted-tts"===t?"http://localhost:8880":"http://localhost:8080/v1"}),f&&(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.pd,{label:"Ollama Host URL",value:S.ollamaHostUrl,onChange:e=>$({...S,ollamaHostUrl:e.target.value}),placeholder:"http://localhost:11434",className:"flex-1"}),(0,a.jsx)("div",{className:"pt-6",children:(0,a.jsx)(d.$n,{onClick:Q,disabled:D||_,variant:"secondary",children:D?"Checking...":"Check"})})]}),!f&&(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.pd,{label:b?"API Key (optional)":v,type:g?"text":"password",autoComplete:"off",value:S.apiKey,onChange:e=>$({...S,apiKey:e.target.value}),placeholder:j,className:"flex-1"}),!b&&(0,a.jsx)("div",{className:"pt-6",children:(0,a.jsx)(d.$n,{onClick:Q,disabled:!S.apiKey||D||_,variant:"secondary",children:D?"Checking...":"Check"})})]}),y&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Use a direct xAI API key from console.x.ai. This is separate from Grok Build OAuth."}),g&&o&&(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:[o,m&&(0,a.jsxs)(a.Fragment,{children:[" ",(0,a.jsxs)("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline",children:["Open ",m.replace(/^https?:\/\//,"")]})]})]}),N&&(0,a.jsx)(d.l6,{label:"Region",value:R,onChange:e=>I(e.target.value),options:N.map(e=>({value:e.id,label:e.label}))}),i&&(0,a.jsx)(d.pd,{label:"Default Model",value:S.defaultModel,onChange:e=>$({...S,defaultModel:e.target.value}),placeholder:l?"claude-3-5-sonnet-latest":"gpt-4o-mini"}),f&&(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["Leave blank to use ",(0,a.jsx)("code",{children:"http://localhost:11434"}),". For remote Ollama, enter the full host URL (e.g. ",(0,a.jsx)("code",{children:"http://192.168.1.10:11434"}),")."]}),U&&(0,a.jsx)(d.Ex,{variant:"success"===U?"success":"error",children:"success"===U?"Valid":"Invalid"}),u&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:u}),i&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Enter the model ID exactly as your compatible endpoint expects it. This model will be saved as the connection default."}),k&&(0,a.jsxs)("div",{className:"bg-sidebar/50 p-4 rounded-lg border border-accent/20",children:[(0,a.jsx)("h3",{className:"font-semibold mb-3 text-sm",children:"Cloudflare Workers AI"}),(0,a.jsx)(d.pd,{label:"Account ID",value:O.accountId,onChange:e=>E({...O,accountId:e.target.value}),placeholder:"abc123def456..."}),(0,a.jsxs)("p",{className:"text-xs text-text-muted mt-2",children:["Find your Account ID in the right sidebar of ",(0,a.jsx)("a",{href:"https://dash.cloudflare.com",target:"_blank",rel:"noopener noreferrer",className:"text-primary underline",children:"dash.cloudflare.com"})]})]}),w&&(0,a.jsxs)("div",{className:"bg-sidebar/50 p-4 rounded-lg border border-accent/20",children:[(0,a.jsx)("h3",{className:"font-semibold mb-3 text-sm",children:"Azure OpenAI Configuration"}),(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsx)(d.pd,{label:"Azure Endpoint",value:A.azureEndpoint,onChange:e=>T({...A,azureEndpoint:e.target.value}),placeholder:"https://your-resource.openai.azure.com"}),(0,a.jsx)(d.pd,{label:"Deployment Name",value:A.deployment,onChange:e=>T({...A,deployment:e.target.value}),placeholder:"gpt-4"}),(0,a.jsx)(d.pd,{label:"API Version",value:A.apiVersion,onChange:e=>T({...A,apiVersion:e.target.value}),placeholder:"2024-10-01-preview"}),(0,a.jsx)(d.pd,{label:"Organization",value:A.organization,onChange:e=>T({...A,organization:e.target.value}),placeholder:"Organization ID"})]})]}),(0,a.jsx)(d.pd,{label:"Priority",type:"number",min:1,value:S.priority,onChange:e=>$({...S,priority:Number.parseInt(e.target.value)||1})}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{onClick:Y,fullWidth:!0,disabled:_||!f&&!b&&(!V||!G)||b&&(!V||!S.baseUrl.trim())||i&&!S.defaultModel.trim()||w&&(!A.azureEndpoint||!A.deployment||!A.organization)||k&&!O.accountId,children:_?"Saving...":"Save"}),(0,a.jsx)(d.$n,{onClick:h,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})}):null}function U({isOpen:e,node:t,onSave:s,onClose:i,isAnthropic:l}){let[n,o]=(0,r.useState)({name:"",apiType:"chat",baseUrl:"https://api.openai.com/v1"}),[c,m]=(0,r.useState)(!1),[u,p]=(0,r.useState)(""),[x,h]=(0,r.useState)(""),[f,b]=(0,r.useState)(!1),[g,y]=(0,r.useState)(null),v=function(e){try{return["http:","https:"].includes(new URL(e).protocol)}catch{return!1}}(n.baseUrl.trim());(0,r.useEffect)(()=>{t&&(o({name:t.name||"",apiType:t.apiType||"chat",baseUrl:t.baseUrl||(l?"https://api.anthropic.com/v1":"https://api.openai.com/v1")}),y(null),p(""),h(""))},[t,l]);let j=async()=>{if(n.name.trim()&&v){m(!0);try{let e={name:n.name.trim(),baseUrl:n.baseUrl.trim()};l||(e.apiType=n.apiType),await s(e)}finally{m(!1)}}},w=async()=>{b(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:n.baseUrl,apiKey:u,type:l?"anthropic-compatible":"openai-compatible",modelId:x.trim()||void 0})}),t=await e.json();y(t.valid?"success":"failed")}catch{y("failed")}finally{b(!1)}};return t?(0,a.jsx)(d.aF,{isOpen:e,title:`Edit ${l?"Anthropic":"OpenAI"} Compatible`,onClose:i,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)(d.pd,{label:"Name",value:n.name,onChange:e=>o({...n,name:e.target.value}),placeholder:`${l?"Anthropic":"OpenAI"} Compatible`,hint:"Friendly label for this provider."}),!l&&(0,a.jsx)(d.l6,{label:"API Type",options:[{value:"chat",label:"Chat Completions"},{value:"responses",label:"Responses API"}],value:n.apiType,onChange:e=>o({...n,apiType:e.target.value})}),(0,a.jsx)(d.pd,{label:"Base URL",value:n.baseUrl,onChange:e=>o({...n,baseUrl:e.target.value}),placeholder:l?"https://api.anthropic.com/v1":"https://api.openai.com/v1",hint:`Base URL ending in /v1 for your ${l?"Anthropic":"OpenAI"}-compatible API.`}),t.prefix?(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["Model IDs use prefix ",(0,a.jsx)("code",{className:"bg-sidebar px-1 rounded font-mono",children:t.prefix})," ","(auto-assigned; stable so combos keep working)."]}):null,(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.pd,{label:"API Key (for Check)",type:"password",autoComplete:"off",value:u,onChange:e=>p(e.target.value),className:"flex-1"}),(0,a.jsx)("div",{className:"pt-6",children:(0,a.jsx)(d.$n,{onClick:w,disabled:!u||f||!v,variant:"secondary",children:f?"Checking...":"Check"})})]}),(0,a.jsx)(d.pd,{label:"Model ID (optional)",value:x,onChange:e=>h(e.target.value),placeholder:"e.g. my-model-id",hint:"If the provider has no /models endpoint, test with a model ID."}),g&&(0,a.jsx)(d.Ex,{variant:"success"===g?"success":"error",children:"success"===g?"Valid":"Invalid"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{onClick:j,fullWidth:!0,disabled:!n.name.trim()||!v||c,children:c?"Saving...":"Save"}),(0,a.jsx)(d.$n,{onClick:i,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}function q({isOpen:e,providerAlias:t,providerDisplayAlias:s,onSave:i,onClose:l}){let[n,o]=(0,r.useState)(""),[c,m]=(0,r.useState)(null),[u,p]=(0,r.useState)(""),[x,h]=(0,r.useState)(!1);(0,r.useEffect)(()=>{e&&(o(""),m(null),p(""))},[e]);let f=e=>{let s=`${t}/`;return e.startsWith(s)?e.slice(s.length):e},b=async()=>{let e=f(n.trim());if(e){m("testing"),p("");try{let s=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${t}/${e}`})}),a=await s.json();m(a.ok?"ok":"error"),p(a.error||"")}catch(e){m("error"),p(e.message)}}},g=async()=>{let e=f(n.trim());if(e&&!x){h(!0);try{await i(e)}finally{h(!1)}}};return(0,a.jsx)(d.aF,{isOpen:e,onClose:l,title:"Add Custom Model",children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"text-sm font-medium mb-1.5 block",children:"Model ID"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)("input",{type:"text",value:n,onChange:e=>{o(e.target.value),m(null),p("")},onKeyDown:e=>{"Enter"===e.key&&b()},placeholder:"e.g. claude-opus-4-5",className:"flex-1 px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",autoFocus:!0}),(0,a.jsx)(d.$n,{variant:"secondary",icon:"science",loading:"testing"===c,onClick:b,disabled:!n.trim()||"testing"===c,children:"testing"===c?"Testing...":"Test"})]}),(0,a.jsxs)("p",{className:"text-xs text-text-muted mt-1",children:["Sent to provider as: ",(0,a.jsx)("code",{className:"font-mono bg-sidebar px-1 rounded",children:f(n.trim())||"model-id"})]})]}),"ok"===c&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-sm text-green-600",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base",children:"check_circle"}),"Model is reachable"]}),"error"===c&&(0,a.jsxs)("div",{className:"flex items-start gap-2 text-sm text-red-500",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base shrink-0",children:"cancel"}),(0,a.jsx)("span",{children:u||"Model not reachable"})]}),(0,a.jsxs)("div",{className:"flex gap-2 pt-1",children:[(0,a.jsx)(d.$n,{onClick:l,variant:"ghost",fullWidth:!0,size:"sm",children:"Cancel"}),(0,a.jsx)(d.$n,{onClick:g,fullWidth:!0,size:"sm",disabled:!n.trim()||x,children:x?"Adding...":"Add Model"})]})]})})}z.propTypes={isOpen:A().bool.isRequired,provider:A().string,providerName:A().string,isCompatible:A().bool,isAnthropic:A().bool,authType:A().string,authHint:A().string,website:A().string,error:A().string,onSave:A().func.isRequired,onBulkDone:A().func,onClose:A().func.isRequired},U.propTypes={isOpen:A().bool.isRequired,node:A().shape({id:A().string,name:A().string,prefix:A().string,apiType:A().string,baseUrl:A().string}),onSave:A().func.isRequired,onClose:A().func.isRequired,isAnthropic:A().bool},q.propTypes={isOpen:A().bool.isRequired,providerAlias:A().string.isRequired,providerDisplayAlias:A().string.isRequired,onSave:A().func.isRequired,onClose:A().func.isRequired};let _=`[
|
|
4
|
+
{
|
|
5
|
+
"accessToken": "eyJhbGc...",
|
|
6
|
+
"refreshToken": "rt_...",
|
|
7
|
+
"idToken": "eyJhbGc...",
|
|
8
|
+
"email": "user@example.com"
|
|
9
|
+
}
|
|
10
|
+
]`;function F({isOpen:e,onClose:t,onSuccess:s}){let[i,l]=(0,r.useState)(""),[n,o]=(0,r.useState)(!1),[c,m]=(0,r.useState)(""),[u,p]=(0,r.useState)(null),x=()=>{n||(l(""),m(""),p(null),t())},h=async()=>{var e;let t;m(""),p(null);let a=i.trim();if(!a)return;try{t=JSON.parse(a)}catch(e){m(`${(0,w.Tl)("Invalid JSON")}: ${e.message}`);return}let r=Array.isArray(e=t)?e:e&&"object"==typeof e?Array.isArray(e.accounts)?e.accounts:[e]:null;if(!r||0===r.length)return void m((0,w.Tl)("No accounts found in input"));o(!0);try{let e=await fetch("/api/oauth/codex/bulk-import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({accounts:r})}),t=await e.json();if(!e.ok)return void m(t?.error||`Request failed: ${e.status}`);p(t),t.success>0&&"function"==typeof s&&s()}catch(e){m(e.message||(0,w.Tl)("Request failed"))}finally{o(!1)}},f=u?.results?.filter(e=>!e.ok)||[];return(0,a.jsx)(d.aF,{isOpen:e,title:(0,w.Tl)("Bulk Add Codex Accounts"),onClose:x,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)("p",{className:"text-xs text-text-muted",children:(0,w.Tl)("Paste an array of codex account JSON objects. Each must include accessToken (and ideally refreshToken, idToken).")}),(0,a.jsx)("textarea",{className:"w-full rounded border border-accent/30 bg-sidebar p-2 text-sm font-mono resize-y min-h-[240px] focus:outline-none focus:ring-1 focus:ring-primary",placeholder:_,value:i,onChange:e=>l(e.target.value),disabled:n}),c&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:c}),u&&(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:`text-sm font-medium ${u.failed>0?"text-yellow-400":"text-green-400"}`,children:["✓ ",u.success," ",(0,w.Tl)("added"),u.failed>0?`, ✗ ${u.failed} ${(0,w.Tl)("failed")}`:""]}),f.length>0&&(0,a.jsx)("ul",{className:"rounded border border-accent/20 bg-sidebar/50 p-2 text-xs font-mono max-h-40 overflow-y-auto",children:f.map(e=>(0,a.jsxs)("li",{className:"text-red-400",children:["[",e.index,"] ",e.error]},e.index))})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{onClick:h,fullWidth:!0,disabled:n||!i.trim(),children:n?(0,w.Tl)("Importing..."):(0,w.Tl)("Import All")}),(0,a.jsx)(d.$n,{onClick:x,variant:"ghost",fullWidth:!0,disabled:n,children:(0,w.Tl)("Close")})]})]})})}F.propTypes={isOpen:A().bool.isRequired,onClose:A().func.isRequired,onSuccess:A().func};var J=s(77251);function L({connectionId:e,providerAlias:t,models:s,jobSnapshot:i,onComplete:l,onStarted:n,onClose:o}){let[c,m]=(0,r.useState)(4),[u,p]=(0,r.useState)(50),[x,h]=(0,r.useState)(Math.round(20)),[f,b]=(0,r.useState)(!1),[g,y]=(0,r.useState)(null),[v,j]=(0,r.useState)(null),[w,k]=(0,r.useState)(""),[N,C]=(0,r.useState)(""),[S,$]=(0,r.useState)(""),A=(0,r.useRef)({onComplete:l,onStarted:n}),T=(0,r.useRef)(null),O=(0,r.useRef)(e),E=(0,r.useRef)(null),R=s?.length||0,I=(0,r.useMemo)(()=>`max concurrency 16 \xb7 batch 200 \xb7 timeout ${60}s`,[]);function D(e){if(e){if("idle"===e.status){E.current=null,b(!1);return}if(y({done:e.done||0,total:e.total||0,ok:e.ok||0,dead:e.dead||0,retryable:e.retryable||0,skippedDead:e.skippedDead||0,skippedDup:e.skippedDup||0}),"running"===e.status&&(E.current=e.connectionId||O.current,T.current=null,b(!0)),e.currentRange&&C(`Probing ${e.currentRange.from}–${e.currentRange.to} of ${e.total}…`),e.error&&k(e.error),"done"===e.status||"cancelled"===e.status||"error"===e.status){E.current=null,b(!1);let t={ok:e.ok||0,dead:e.dead||0,retryable:e.retryable||0,tested:e.done||0,skippedDead:e.skippedDead||0,skippedDup:e.skippedDup||0,cancelled:"cancelled"===e.status,retryableAuthOnly:!0===e.retryableAuthOnly};j(t),C("cancelled"===e.status?"Cancelled (partial results saved).":"error"===e.status?"Stopped.":"Done.");let s=`${e.startedAt||"unknown"}:${e.status}`;T.current!==s&&(T.current=s,A.current.onComplete?.(t))}}}async function P(){if(f||!e||0===R)return;b(!0),k(""),j(null),C("Starting…");let a={concurrency:Math.max(1,Math.min(16,Number(c)||4)),batchSize:Math.max(1,Math.min(200,Number(u)||50)),timeoutMs:Math.max(1e3,Math.min(6e4,1e3*(Number(x)||20)))};E.current=e;try{let r=await fetch(`/api/providers/${e}/model-probes/verify/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({models:s,providerAlias:t,...a,timeoutMs:a.timeoutMs})}),i=await r.json().catch(()=>({}));if(O.current!==e){E.current=null,b(!1);return}if(!r.ok){E.current=null,k(i.error||"Failed to start"),b(!1);return}A.current.onStarted?.(i),D(i),"running"!==i.status&&b(!1)}catch(e){E.current=null,k(e?.message||"Verify failed"),b(!1)}}async function M(){let t=E.current||e;await fetch(`/api/providers/${t}/model-probes/verify/cancel`,{method:"POST"}).catch(()=>{})}async function z(s){if(!e)return;let a="retryable"===s,r=a?Number(v?.retryable||0):Number(v?.dead||0);if(!a||await (0,J.l)({title:"Remove retry-failed models?",message:`Review ${r} retryable result(s) and remove the eligible models? Timeouts, rate limits, network failures, and provider errors may be temporary. Credential failures are kept. Removed models can be enabled or imported again later.`,confirmText:"Remove eligible"})){$(s),k(""),C(`Removing ${a?"retry-failed":"dead"} models…`);try{let r=await fetch(`/api/providers/${e}/model-probes/remove-unavailable`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:t,kind:"llm",status:s})}),i=await r.json().catch(()=>({}));if(!r.ok)return void k(i.error||"Remove failed");let l=Number(i.removed||0),n=Number(i.kept||0),o=v?{...v,[a?"retryable":"dead"]:n,...a?{retryableAuthOnly:n>0}:{}}:v;j(o),C(`Removed ${l} ${a?"retry-failed":"dead"} model(s).`+(n>0?` Kept ${n} credential failure(s).`:"")),A.current.onComplete?.({...o||{},removed:l,kept:n,removedStatus:s})}catch(e){k(e?.message||"Remove failed")}finally{$("")}}}async function U(){if(!e)return;let t=await fetch(`/api/providers/${e}/model-probes/cache`,{method:"DELETE"}),s=await t.json().catch(()=>({}));t.ok?(C(`Cleared probe cache (${s.cleared||0} rows). Next verify will re-test everything.`),j(null),y(null),A.current.onComplete?.({cacheCleared:!0,cleared:s.cleared||0})):k(s.error||"Clear cache failed")}(0,r.useEffect)(()=>{A.current={onComplete:l,onStarted:n},O.current=e}),(0,r.useEffect)(()=>{D(i)},[i]);let q=g?.total?Math.min(100,Math.round(g.done/g.total*100)):0;return(0,a.jsxs)("div",{className:"mb-4 rounded-lg border border-border bg-sidebar/40 p-3 space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"text-sm font-semibold text-text-main",children:"Verify models"}),(0,a.jsxs)("p",{className:"text-[11px] text-text-muted mt-0.5",children:["Batch-ping availability and latency. Dead = permanently unavailable (missing, blocked, or deprecated) and can be removed; retry = transient (timeout/429/5xx). Known-dead models are skipped until you Clear cache. Caps: ",I,"."]})]}),o&&(0,a.jsx)("button",{type:"button",onClick:o,className:"p-1 text-text-muted hover:text-text-main rounded",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"close"})})]}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-3 items-end",children:[(0,a.jsxs)("label",{className:"text-xs text-text-muted",children:["Concurrency",(0,a.jsx)("input",{type:"number",min:1,max:16,value:c,disabled:f,onChange:e=>m(e.target.value),className:"mt-1 block w-20 rounded-md border border-border bg-background px-2 py-1 text-xs"})]}),(0,a.jsxs)("label",{className:"text-xs text-text-muted",children:["Batch size",(0,a.jsx)("input",{type:"number",min:1,max:200,value:u,disabled:f,onChange:e=>p(e.target.value),className:"mt-1 block w-20 rounded-md border border-border bg-background px-2 py-1 text-xs"})]}),(0,a.jsxs)("label",{className:"text-xs text-text-muted",children:["Timeout (s)",(0,a.jsx)("input",{type:"number",min:1,max:60,value:x,disabled:f,onChange:e=>h(e.target.value),className:"mt-1 block w-20 rounded-md border border-border bg-background px-2 py-1 text-xs"})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[f?(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"stop",onClick:M,children:"Cancel"}):(0,a.jsx)(d.$n,{size:"sm",icon:"science",onClick:P,disabled:!e||0===R,children:"Start"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"delete_sweep",onClick:U,disabled:f,children:"Clear cache"})]})]}),g&&(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)("div",{className:"h-1.5 w-full rounded-full bg-border overflow-hidden",children:(0,a.jsx)("div",{className:"h-full bg-primary transition-all",style:{width:`${q}%`}})}),(0,a.jsxs)("p",{className:"text-[11px] text-text-muted flex flex-wrap gap-x-2",children:[(0,a.jsxs)("span",{title:"Models probed this run",children:[g.done,"/",g.total," tested"]}),(0,a.jsxs)("span",{title:"Reachable",children:["\xb7 ok ",g.ok]}),(0,a.jsxs)("span",{title:"Permanently unavailable this run (missing, blocked, or deprecated)",children:["\xb7 dead ",g.dead]}),(0,a.jsxs)("span",{title:"Transient failure this run (timeout / 429 / 5xx / network); re-testable",children:["\xb7 retry ",g.retryable]}),g.skippedDead?(0,a.jsxs)("span",{title:"Not probed — cache already marks them dead. Clear cache to re-test.",children:["\xb7 skipped known-dead ",g.skippedDead]}):null,g.skippedDup?(0,a.jsxs)("span",{title:"Duplicate ids collapsed",children:["\xb7 dupes ",g.skippedDup]}):null]})]}),N&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:N}),w&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:w}),v&&(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:[(0,a.jsxs)("span",{className:"text-xs text-text-main",children:["Summary: ",v.ok," ok \xb7 ",v.dead," dead \xb7 ",v.retryable," retry",v.skippedDead?` \xb7 ${v.skippedDead} skipped known-dead`:"",v.cancelled?" \xb7 cancelled":""]}),v.dead>0&&(0,a.jsxs)(d.$n,{size:"sm",variant:"primary",icon:"delete_sweep",onClick:()=>z("dead"),disabled:f||!!S,loading:"dead"===S,children:["Remove ",v.dead," dead"]}),v.retryable>0&&!v.retryableAuthOnly&&(0,a.jsxs)(d.$n,{size:"sm",variant:"danger",icon:"delete_sweep",onClick:()=>z("retryable"),disabled:f||!!S,loading:"retryable"===S,children:["Remove ",v.retryable," retry failures"]})]})]})}L.propTypes={connectionId:A().string,providerAlias:A().string,models:A().arrayOf(A().object),jobSnapshot:A().object,onComplete:A().func,onStarted:A().func,onClose:A().func};var K=s(68875);let B=["UTC","America/Los_Angeles","America/Denver","America/Chicago","America/New_York","America/Sao_Paulo","Europe/London","Europe/Berlin","Europe/Moscow","Asia/Kolkata","Asia/Shanghai","Asia/Tokyo","Asia/Singapore","Australia/Sydney"],W=(()=>{let e=[];try{e=Intl.supportedValuesOf?.("timeZone")||[]}catch{e=[]}try{let e=Intl.DateTimeFormat().resolvedOptions().timeZone;e&&!B.includes(e)&&B.unshift(e)}catch{}return[...new Set([...B,...e.filter(e=>!B.includes(e))])]})(),H={mon:"Mo",tue:"Tu",wed:"We",thu:"Th",fri:"Fr",sat:"Sa",sun:"Su"};function V({providerId:e,scheduleKey:t}){let s=t||e,i=(0,r.useId)(),[l,n]=(0,r.useState)(!1),[o,c]=(0,r.useState)(!1),[m,u]=(0,r.useState)("UTC"),[p,x]=(0,r.useState)("offPeak"),[h,f]=(0,r.useState)([]),[b,g]=(0,r.useState)(!1),[y,v]=(0,r.useState)(""),[j,w]=(0,r.useState)(0),[,k]=(0,r.useState)(0),N=(0,r.useCallback)(e=>{let t=K.Z9.find(t=>t.id===e);t&&(u(t.config.timezone||"UTC"),x("peak"===t.config.defaultState?"peak":"offPeak"),f(t.config.windows.map(e=>({type:e.type,start:e.start,end:e.end,days:Array.isArray(e.days)&&e.days.length?[...e.days]:[...K.de]}))),w(0))},[]);(0,r.useEffect)(()=>{let e=!1;return c(!1),u("UTC"),x("offPeak"),f([]),w(0),v(""),fetch("/api/settings",{cache:"no-store"}).then(e=>e.ok?e.json():{}).then(t=>{if(e)return;let a=(t.providerSchedules||{})[s];a&&Array.isArray(a.windows)&&a.windows.length&&(c(!0),u(a.timezone||"UTC"),x("peak"===a.defaultState?"peak":"offPeak"),f(a.windows.map(e=>({type:"offPeak"===e.type?"offPeak":"peak",start:e.start||"09:00",end:e.end||"17:00",days:Array.isArray(e.days)&&e.days.length?[...e.days]:[...K.de]})))),n(!0)}).catch(()=>{e||n(!0)}),()=>{e=!0}},[s]),(0,r.useEffect)(()=>{let e=setInterval(()=>k(e=>e+1),3e4);return()=>clearInterval(e)},[]);let C=(0,r.useMemo)(()=>o?{timezone:m,defaultState:p,windows:h}:null,[o,m,p,h]),S=(0,K.yW)(C),$="unscheduled"===S?null:(0,K.bC)(C),A=(0,r.useCallback)((e,t)=>{f(s=>s.map((s,a)=>a===e?{...s,...t}:s)),w(0)},[]),T=(0,r.useCallback)((e,t)=>{f(s=>s.map((s,a)=>{if(a!==e)return s;let r=s.days.includes(t)?s.days.filter(e=>e!==t):[...s.days,t];return{...s,days:r.length?r:s.days}})),w(0)},[]),O=async()=>{v("");let t=o?(0,K.v2)({timezone:m,defaultState:p,windows:h},e):null;if(o&&t.error)return void v(t.error);g(!0);try{let e=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerSchedules:{[s]:o?t.value:null}})});if(!e.ok){let t=await e.json().catch(()=>({}));v(t.error||`Failed to save peak hours (${e.status})`);return}w(Date.now())}catch{v("Failed to save peak hours")}finally{g(!1)}};return l?(0,a.jsxs)(d.Zp,{children:[(0,a.jsxs)("div",{className:"mb-3 flex flex-wrap items-center justify-between gap-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Peak hours"}),"unscheduled"!==S&&(0,a.jsxs)("span",{className:`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[11px] font-medium ${"peak"===S?"bg-red-500/10 text-red-600 dark:text-red-400":"bg-green-500/10 text-green-600 dark:text-green-400"}`,title:$?`Changes at ${function(e,t){try{return new Intl.DateTimeFormat("en-US",{timeZone:t,weekday:"short",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).format(new Date(e))}catch{return e}}(new Date($).toISOString(),m)}`:void 0,children:[(0,a.jsx)("span",{className:`size-1.5 rounded-full ${"peak"===S?"bg-red-500":"bg-green-500"}`}),"peak"===S?"Peak now":"Off-peak now",$?` \xb7 ${(0,K.zt)($-Date.now())} left`:""]})]}),(0,a.jsx)(d.lM,{checked:o,onChange:e=>{c(e),w(0),e&&!h.length&&(u("UTC"),x("offPeak"),f([{type:"peak",start:"09:00",end:"17:00",days:[...K.de]}]))},label:"Enable peak / off-peak hours",size:"sm"})]}),(0,a.jsx)("p",{className:"mb-3 text-xs text-text-muted leading-relaxed",children:"Optional. Some providers (e.g. DeepSeek) charge less outside peak hours. Define this provider's windows once, then mark models in a combo as peak-only or off-peak-only to skip them at the wrong hours."}),o&&(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsx)("label",{htmlFor:i,className:"text-sm font-medium text-text-main",children:"Timezone"}),(0,a.jsx)("input",{id:i,list:`${i}-zones`,value:m,onChange:e=>{u(e.target.value),w(0)},placeholder:"UTC — type to search IANA zones",className:"rounded-md border border-border bg-background px-3 py-2 text-sm text-text-main outline-none focus:border-primary",autoComplete:"off"}),(0,a.jsx)("datalist",{id:`${i}-zones`,children:W.map(e=>(0,a.jsx)("option",{value:e},e))}),(0,a.jsx)("p",{className:"text-[10px] text-text-muted",children:"Windows are wall-clock in this zone (provider docs usually quote UTC)"})]}),(0,a.jsx)(d.l6,{label:"Outside all windows is",options:[{value:"offPeak",label:"Off-peak (peak is the exception)"},{value:"peak",label:"Peak (off-peak discount is the exception)"}],value:p,onChange:e=>{x(e.target.value),w(0)}})]}),(0,a.jsx)(d.l6,{label:"Load a preset",options:K.Z9.map(e=>({value:e.id,label:e.label})),value:"",onChange:e=>N(e.target.value),placeholder:"Choose a known provider policy…",hint:"Fills the editor below — review the provider's current pricing page, then Save"}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[h.map((e,t)=>(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2 rounded-md border border-border bg-black/[0.02] px-2 py-2 dark:bg-white/[0.02]",children:[(0,a.jsxs)("select",{value:e.type,onChange:e=>A(t,{type:e.target.value}),className:"rounded-md border border-border bg-background px-2 py-1 text-xs","aria-label":`Window ${t+1} type`,children:[(0,a.jsx)("option",{value:"peak",children:"Peak"}),(0,a.jsx)("option",{value:"offPeak",children:"Off-peak"})]}),(0,a.jsx)("input",{type:"time",value:e.start,onChange:e=>A(t,{start:e.target.value}),className:"rounded-md border border-border bg-background px-2 py-1 text-xs","aria-label":`Window ${t+1} start`}),(0,a.jsx)("span",{className:"text-xs text-text-muted",children:"→"}),(0,a.jsx)("input",{type:"time",value:e.end,onChange:e=>A(t,{end:e.target.value}),className:"rounded-md border border-border bg-background px-2 py-1 text-xs","aria-label":`Window ${t+1} end`}),(0,a.jsx)("div",{className:"flex items-center gap-1",children:K.de.map(s=>(0,a.jsx)("button",{type:"button",onClick:()=>T(t,s),className:`size-6 rounded text-[10px] font-medium transition-colors ${e.days.includes(s)?"bg-primary/15 text-primary":"text-text-muted hover:bg-black/5 dark:hover:bg-white/5"}`,title:s,children:H[s]},s))}),(0,a.jsx)("button",{type:"button",onClick:()=>{f(e=>e.filter((e,s)=>s!==t)),w(0)},className:"ml-auto rounded p-1 text-text-muted transition-colors hover:bg-red-500/10 hover:text-red-500",title:"Remove window","aria-label":`Remove window ${t+1}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]},t)),(0,a.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"add",onClick:()=>{f(e=>[...e,{type:"peak",start:"09:00",end:"17:00",days:[...K.de]}]),w(0)},children:"Add window"})})]})]}),y&&(0,a.jsx)("p",{className:"mt-2 text-xs text-red-500",children:y}),j>0&&!y&&(0,a.jsx)("p",{className:"mt-2 text-xs text-green-600 dark:text-green-400",children:"Saved"}),(0,a.jsx)("div",{className:"mt-3",children:(0,a.jsx)(d.$n,{size:"sm",onClick:O,disabled:b,children:b?"Saving...":o?"Save peak hours":"Save (disable schedule)"})})]}):null}var G=s(36861),Z=s(48874),Q=s(53578);let Y={claude:"claudeAutoPing",codex:"codexAutoPing"};function X(){let e,t,s,l=(0,i.useParams)(),u=(0,i.useRouter)(),p=l.id,{getCaps:x}=(0,j.y)(),[h,f]=(0,r.useState)([]),[b,g]=(0,r.useState)([]),[k,$]=(0,r.useState)(!0),[A,E]=(0,r.useState)(null),[I,D]=(0,r.useState)(!1),[M,_]=(0,r.useState)(!1),[J,K]=(0,r.useState)(!1),[B,W]=(0,r.useState)(""),[H,X]=(0,r.useState)(!1),[ee,et]=(0,r.useState)(!1),[es,ea]=(0,r.useState)(!1),[er,ei]=(0,r.useState)(null),[el,en]=(0,r.useState)({}),[eo,ed]=(0,r.useState)([]),[ec,em]=(0,r.useState)(!1),[eu,ep]=(0,r.useState)({}),[ex,eh]=(0,r.useState)(""),[ef,eb]=(0,r.useState)(()=>new Set),[eg,ey]=(0,r.useState)(!1),[ev,ej]=(0,r.useState)(null),[ew,ek]=(0,r.useState)(""),[eN,eC]=(0,r.useState)(!1),[eS,e$]=(0,r.useState)("30"),[eA,eT]=(0,r.useState)("auto"),[eO,eE]=(0,r.useState)({enabled:!1,connections:{}}),[eR,eI]=(0,r.useState)([]),[eD,eP]=(0,r.useState)([]),[eM,ez]=(0,r.useState)([]),[eU,eq]=(0,r.useState)([]),[e_,eF]=(0,r.useState)(null),[eJ,eL]=(0,r.useState)(!1),[eK,eB]=(0,r.useState)(!1),[eW,eH]=(0,r.useState)(!1),[eV,eG]=(0,r.useState)(null),[eZ,eQ]=(0,r.useState)({}),[eY,eX]=(0,r.useState)(null),e0=(0,r.useRef)(!1),e1=(0,r.useRef)(null),e2=(0,r.useRef)(0),e5=(0,r.useRef)(0),[e3,e4]=(0,r.useState)(!1),[e6,e7]=(0,r.useState)(""),[e8,e9]=(0,r.useState)(!1),[te,tt]=(0,r.useState)(null),[ts,ta]=(0,r.useState)({}),[tr,ti]=(0,r.useState)({}),[tl,tn]=(0,r.useState)("all"),{copied:to,copy:td}=(0,v.C)(),tc="ag_risk_confirmed",tm=A?{id:A.id,name:A.name||("anthropic-compatible"===A.type?"Anthropic Compatible":"OpenAI Compatible"),color:"anthropic-compatible"===A.type?"#D97757":"#10A37F",textIcon:"anthropic-compatible"===A.type?"AC":"OC",apiType:A.apiType,baseUrl:A.baseUrl,type:A.type}:c.zN[p]||c.fg[p]||c.IS[p]||c.nJ[p]||c.br[p],tu=tm?.authModes||[],tp=!!c.zN[p]||!!c.IS[p]||tu.includes("oauth"),tx=!!c.fg[p]||tu.includes("apikey"),th=!!c.IS[p]?.noAuth,tf=(0,m.KC)(p),tb=(()=>{let e=new Map(tf.map(e=>[e.id,e]));for(let t of eD)t?.id&&e.set(t.id,{...e.get(t.id),...t});return[...e.values()]})(),tg=(0,c.wG)(p),ty=(0,c.mq)(p),tv=(0,c.gb)(p),tj=ty||tv,tw=h.some(e=>!1!==e.isActive),tk=function({isCompatible:e,hasActiveConnection:t}){let s=!e,a=!e;return{showToolbar:s||t||a,showImport:s,showVerify:t,showBulkControls:a}}({isCompatible:tj,hasActiveConnection:tw}),tN=!tj&&tp&&tx,tC="xai"===p?"Grok Build OAuth":"OAuth",tS="xai"===p?"xAI API Key":"API Key",t$=()=>{D(!0)},tA=()=>{"antigravity"===p&&"true"!==window.localStorage.getItem(tc)?eL(!0):tp?t$():(W(""),K(!0))},tT=()=>{W(""),K(!0)},tO=()=>{tp?tA():tT()},tE=e=>{if(!eA||"auto"===eA)return null;let t=y(p,e);return t&&t.includes(eA)?eA:null},tR=(()=>{let e=new Set;for(let t of tb){let s=y(p,t.id);s&&s.forEach(t=>{"none"!==t&&e.add(t)})}return e.size?["auto",...e]:null})(),tI=tj?p:tg,tD=tj?A?.prefix||p:tg,tP=(0,C.Iz)(eU,tI),tM=e=>(0,C.uJ)(tP,e,tI),tz=(0,r.useCallback)(async()=>{try{let e=await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(tI)}`,{cache:"no-store"}),t=await e.json();e.ok&&eq(t.ids||[])}catch(e){(0,O.s)("Error fetching disabled models:",e)}},[tI]),tU=async e=>{try{await (0,Z.x)("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:tI,ids:[e]})}),await tz()}catch(e){(0,O.s)("Error disabling model:",e)}},tq=async e=>{try{return await (0,Z.x)(`/api/models/disabled?providerAlias=${encodeURIComponent(tI)}&id=${encodeURIComponent(e)}`,{method:"DELETE"}),await tz(),!0}catch(e){return(0,O.s)("Error enabling model:",e),!1}},t_=async e=>{e.length&&eF({title:"Disable All Models",message:`Disable all ${e.length} model(s)?`,onConfirm:async()=>{eF(null);try{await (0,Z.x)("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:tI,ids:e})}),await tz()}catch(e){(0,O.s)("Error disabling all models:",e)}}})},tF=async()=>{try{await (0,Z.x)(`/api/models/disabled?providerAlias=${encodeURIComponent(tI)}`,{method:"DELETE"}),await tz()}catch(e){(0,O.s)("Error enabling all models:",e)}},tJ=(0,r.useCallback)(async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&en(t.aliases||{})}catch(e){(0,O.s)("Error fetching aliases:",e)}},[]),tL=(0,r.useCallback)(async()=>{try{let e=await fetch("/api/models/custom",{cache:"no-store"}),t=await e.json();e.ok&&ed(t.models||[])}catch(e){(0,O.s)("Error fetching custom models:",e)}},[]);(0,r.useEffect)(()=>{"kilocode"===p&&fetch("/api/providers/kilo/free-models").then(e=>e.json()).then(e=>{e.models?.length&&ez(e.models)}).catch(()=>{})},[p]);let tK=(0,r.useCallback)(async()=>{try{let[e,t,s]=await Promise.all([fetch("/api/providers",{cache:"no-store"}),fetch("/api/provider-nodes",{cache:"no-store"}),fetch("/api/settings",{cache:"no-store"})]),a=await e.json(),r=await t.json(),i=s.ok?await s.json():{};if(e.ok){let e=(a.connections||[]).filter(e=>e.provider===p);f(e)}let l=(i.providerStrategies||{})[p]||{};ej(l.fallbackStrategy||null),ek(null!=l.stickyRoundRobinLimit?String(l.stickyRoundRobinLimit):"1");let n=l.accountScheduler||{};eC(!0===n.enabled),e$(String(Math.max(1,Math.round((n.sessionAffinityTtlSeconds||1800)/60))));let o=(i.providerThinking||{})[p]||{};eT(o.mode||"auto");let d=Y[p],c=d&&i[d]||{};if(eE({enabled:!0===c.enabled,connections:c.connections||{}}),t.ok){let e=(r.nodes||[]).find(e=>e.id===p)||null;if(!e&&tj)for(let t=0;t<3;t+=1){await new Promise(e=>setTimeout(e,150));let t=await fetch("/api/provider-nodes",{cache:"no-store"});if(t.ok&&(e=((await t.json()).nodes||[]).find(e=>e.id===p)||null))break}E(e)}}catch(e){(0,O.s)("Error fetching connections:",e)}finally{$(!1)}},[p,tj]),tB=(0,r.useCallback)(async(e=null)=>{let t=++e5.current,s=e?h.find(t=>t.id===e&&!1!==t.isActive):h.find(e=>b.includes(e.id)&&!1!==e.isActive)||h.find(e=>!1!==e.isActive);if(!s){ti({}),ta({});return}try{let e=await fetch(`/api/providers/${s.id}/model-probes`,{cache:"no-store"});if(!e.ok)return;let a=await e.json().catch(()=>({})),r={},i={};for(let e of a.probes||[])r[e.modelId]="ok"===e.status?"ok":"dead"===e.status?"dead":"retry",null!=e.latencyMs&&(i[e.modelId]=e.latencyMs);if(t!==e5.current)return;ti(r),ta(i)}catch{}},[h,b]),tW=async e=>{try{let t=await fetch(`/api/provider-nodes/${p}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),s=await t.json();t.ok?(E(s.node),await tK(),ea(!1)):(0,O.s)(s?.error||"Failed to update provider node")}catch(e){(0,O.s)("Error updating provider node:",e)}},tH=async(e,t)=>{try{return await (0,Q.T)(p,s=>{let a={...s};return e?a.fallbackStrategy=e:delete a.fallbackStrategy,"round-robin"===e&&""!==t?a.stickyRoundRobinLimit=Number(t)||3:e||delete a.stickyRoundRobinLimit,a}),!0}catch(e){return(0,O.s)("Error saving provider strategy:",e),!1}},tV=async(e,t)=>{let s=Math.min(1440,Math.max(1,Number.parseInt(t,10)||30));try{return await (0,Q.T)(p,t=>({...t,accountScheduler:{...t.accountScheduler||{},enabled:e,sessionAffinityTtlSeconds:60*s}})),!0}catch(e){return(0,O.s)("Error saving balanced scheduler:",e),!1}},tG=async e=>{let t=e?"round-robin":null,s=e?ew||"1":ew;await tH(t,s)&&(e&&!ew&&ek("1"),ej(t))},tZ=async e=>{await tH("round-robin",e)&&ek(e)},tQ=async e=>{await tV(e,eS)&&eC(e)},tY=async e=>{await tV(eN,e)&&e$(e)},tX=async e=>{try{let t=await fetch("/api/settings",{cache:"no-store"}),s={...(t.ok?await t.json():{}).providerThinking||{}};e&&"auto"!==e?s[p]={mode:e}:delete s[p],await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerThinking:s})})}catch(e){(0,O.s)("Error saving thinking config:",e)}},t0=async e=>{let t=Y[p];if(t){eE(e);try{await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[t]:e})})}catch(e){(0,O.s)("Error saving auto-ping config:",e)}}};(0,r.useEffect)(()=>{tK(),tJ(),tL(),tz()},[tK,tJ,tL,tz]),(0,r.useEffect)(()=>{tB()},[tB]),(0,r.useEffect)(()=>{if(tj)return;let e=h.find(e=>!1!==e.isActive);if(!e)return void eP([]);let t=!1;return fetch(`/api/providers/${e.id}/models`,{cache:"no-store"}).then(e=>e.json().catch(()=>({}))).then(e=>{!t&&Array.isArray(e.models)&&e.models.length>0&&eP(e.models)}).catch(()=>{}),()=>{t=!0}},[h,tj]),(0,r.useEffect)(()=>{let e=(c.zN[p]||c.fg[p]||c.IS[p]||c.nJ[p])?.modelsFetcher;e&&N(e).then(eI)},[p]);let t1=(0,r.useCallback)(e=>{let t=++e2.current;e1.current&&(clearTimeout(e1.current),e1.current=null);let s=async()=>{try{let a=await fetch(`/api/providers/${e}/model-probes/verify/status`,{cache:"no-store"}),r=await a.json().catch(()=>null);if(t!==e2.current)return;if(!a.ok||!r?.status)throw Error("Verify status temporarily unavailable");tt(r&&r.status?r:null),r?.status==="running"?e1.current=setTimeout(s,1500):(e1.current=null,await tB(e))}catch{t===e2.current&&(e1.current=setTimeout(s,1500))}};e1.current=setTimeout(s,0)},[tB]);(0,r.useEffect)(()=>{let e=h.find(e=>b.includes(e.id)&&!1!==e.isActive)||h.find(e=>!1!==e.isActive);return e?(t1(e.id),()=>{e2.current+=1,e1.current&&(clearTimeout(e1.current),e1.current=null)}):void tt(null)},[h,b,t1]);let t2=async(e,t,s=tg)=>{let a=`${s}/${e}`;try{let e=await fetch("/api/models/alias",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:a,alias:t})});if(e.ok)await tJ();else{let t=await e.json();(0,O.s)(t.error||"Failed to set alias")}}catch(e){(0,O.s)("Error setting alias:",e)}},t5=async e=>{try{await (0,Z.x)(`/api/models/alias?alias=${encodeURIComponent(e)}`,{method:"DELETE"}),await tJ()}catch(e){(0,O.s)("Error deleting alias:",e)}},t3=async(e,t="llm",s=tI)=>{try{let a=await fetch("/api/models/custom",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:s,id:e,type:t})});if(a.ok)await tL(),window.dispatchEvent(new CustomEvent("customModelChanged"));else{let e=await a.json();(0,O.s)(e.error||"Failed to add custom model")}}catch(e){(0,O.s)("Error adding custom model:",e)}},t4=async(e,t="llm",s=tI)=>{try{let a=new URLSearchParams({providerAlias:s,id:e,type:t});await (0,Z.x)(`/api/models/custom?${a}`,{method:"DELETE"}),await tL(),window.dispatchEvent(new CustomEvent("customModelChanged"))}catch(e){(0,O.s)("Error deleting custom model:",e)}},t6=async()=>{if(e3)return;let e=h.find(e=>b.includes(e.id)&&!1!==e.isActive)||h.find(e=>!1!==e.isActive);if(!e)return void(0,O.s)((0,w.Tl)("Add an active connection first"));e4(!0),e7("");try{let t=await fetch(`/api/providers/${e.id}/models`),s=await t.json().catch(()=>({}));if(!t.ok)return void(0,O.s)(s.error||(0,w.Tl)("Failed to fetch models"));let a=s.models||[];if(0===a.length)return void(0,O.s)(s.warning||(0,w.Tl)("No models returned"));let r=new Set;try{let t=await fetch(`/api/providers/${e.id}/model-probes`,{cache:"no-store"});for(let e of(await t.json().catch(()=>({}))).probes||[])"dead"===e.status&&r.add(e.modelId)}catch{}let i=0,l=new Set(tb.map(e=>e.id)),n=[],o=[],d=new Set;for(let e of a){let t=(0,S.R2)(e,tI);if(!t)continue;let{id:s,name:a,type:c}=t;if(r.has((0,G.v)(s,tI))){i+=1;continue}let m=`${c}|${s}`;if(d.has(m))continue;if(d.add(m),l.has(s)){tM(s)&&o.push(s);continue}if(eo.some(e=>e.providerAlias===tI&&e.id===s&&(0,S.ki)(e.kind||e.type||"llm")===c))continue;let u=`${tI}/${s}`;Object.values(el).includes(u)||n.push({providerAlias:tI,id:s,type:c,name:a})}let c=0;if(o.length>0)try{for(let e of o)(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(tI)}&id=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&(c+=1);await tz()}catch{}let m=0;if(n.length>0){let e=await fetch("/api/models/custom",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({models:n})}),t=await e.json().catch(()=>({}));if(!e.ok)return void(0,O.s)(t.error||(0,w.Tl)("Failed to save models"));m=t.added??n.length,await tL(),window.dispatchEvent(new CustomEvent("customModelChanged"))}let u=n.filter(e=>"llm"!==e.type).length,p=[];if(m>0&&p.push(`${m} new`),c>0&&p.push(`${c} re-enabled`),0===p.length)e7((0,w.Tl)("All models already in list"));else{let e=`Imported ${p.join(" \xb7 ")} (${a.length} from provider)`;u>0&&(e+=" \xb7 non-chat types stored for media pages"),s.warning&&(e+=` \xb7 ${s.warning}`),e7(e)}if(i>0&&e7(e=>`${e} \xb7 ${i} skipped (known dead)`),m>0||c>0)try{let t=[...tb,...n.map(e=>({id:e.id,name:e.name,kind:e.type}))],s=await fetch(`/api/providers/${e.id}/model-probes/verify/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({models:t,providerAlias:tI})}),a=await s.json().catch(()=>({}));if(!s.ok)throw Error(a.error||"Failed to start auto-verify");tt(a&&a.status?a:null),t1(e.id)}catch(e){e7(t=>`${t} \xb7 auto-verify failed: ${e?.message||e}`)}}catch(e){(0,O.s)("Error importing models:",e),(0,O.s)((0,w.Tl)("Error fetching models")+": "+(e?.message||e))}finally{e4(!1)}},t7=async()=>{if(eK||0===h.length)return;let e=Object.fromEntries(h.map(e=>[e.id,{state:"queued",error:null}]));e0.current=!1,eB(!0),eH(!1),eG(null),eQ(e),eX({total:h.length,completed:0,passed:0,failed:0,stopped:!1});let t=0,s=0;try{for(let e=0;e<h.length;e+=1){if(e0.current){eX({total:h.length,completed:e,passed:t,failed:s,stopped:!0});break}let a=h[e];eG(a.id),eQ(e=>({...e,[a.id]:{state:"testing",error:null}}));try{let e=await fetch(`/api/providers/${a.id}/test`,{method:"POST"}),r=await e.json(),i=!!r.valid;i?t+=1:s+=1,eQ(e=>({...e,[a.id]:{state:i?"success":"failed",error:i?null:r.error||null}}))}catch(e){s+=1,eQ(t=>({...t,[a.id]:{state:"failed",error:e.message||"Test failed"}}))}eX({total:h.length,completed:e+1,passed:t,failed:s,stopped:!1}),e<h.length-1&&await new Promise(e=>setTimeout(e,1e3))}}finally{eG(null),eB(!1),eH(!1),e0.current=!1}},t8=async e=>{let t=h.find(t=>t.id===e),s=t?.name?.trim()||t?.email?.trim()||e;eF({title:"Delete Connection",message:`Delete connection “${s}”?`,onConfirm:async()=>{eF(null);try{await (0,Z.x)(`/api/providers/${e}`,{method:"DELETE"}),f(t=>t.filter(t=>t.id!==e))}catch(e){(0,O.s)("Error deleting connection:",e)}}})},t9=()=>{tK(),D(!1)},se=async e=>{W("");try{let t=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:p,...e})}),s=null;try{s=await t.json()}catch{s=null}if(t.ok){await tK(),K(!1);return}W(s?.error||"Failed to save connection")}catch(e){(0,O.s)("Error saving connection:",e),W("Failed to save connection")}},st=async e=>{try{await (0,Z.x)(`/api/providers/${er.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),await tK(),et(!1)}catch(e){(0,O.s)("Error updating connection:",e)}},ss=async(e,t)=>{try{await (0,Z.x)(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})}),f(s=>s.map(s=>s.id===e?{...s,isActive:t}:s))}catch(e){(0,O.s)("Error updating connection status:",e)}},sa=async e=>{let t,s=e?.providerSpecificData?.baseUrl;if(s){try{t=new URL(s).hostname.toLowerCase().replace(/^\[|\]$/g,"")}catch{(0,O.s)("Cannot allow-list: invalid base URL",s);return}try{let e=await fetch("/api/settings",{cache:"no-store"});if(!e.ok)throw Error(`Failed to load settings (${e.status})`);let s=await e.json(),a=[...new Set([...s.ssrfAllowHosts||[],t])],r=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({ssrfAllowHosts:a})});if(!r.ok)throw Error(`Failed to update allow list (${r.status})`);await tK()}catch(e){(0,O.s)("Error adding host to allow list:",e)}}},sr=async(e,t)=>{let s=[...h];[s[e],s[t]]=[s[t],s[e]],f(s);try{if((await Promise.all([fetch(`/api/providers/${s[e].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:e})}),fetch(`/api/providers/${s[t].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:t})})])).some(e=>!e.ok))throw Error("Failed to reorder connections")}catch(e){(0,O.s)("Error swapping priority:",e),await tK()}},si=h.length>0&&b.length===h.length,sl=(0,a.jsx)("div",{className:"flex min-w-0 flex-col divide-y divide-black/[0.03] dark:divide-white/[0.03]",children:h.map((e,t)=>(0,a.jsxs)("div",{className:"flex min-w-0 items-stretch",children:[(0,a.jsx)("div",{className:"flex shrink-0 items-center pl-1 sm:pl-2",children:(0,a.jsx)("input",{type:"checkbox",checked:b.includes(e.id),onChange:()=>{var t;return t=e.id,void g(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])},className:"h-4 w-4 rounded border-gray-300 text-primary focus:ring-primary"})}),(0,a.jsx)("div",{className:"flex-1 min-w-0",children:(0,a.jsx)(P,{connection:e,isOAuth:tp,isFirst:0===t,isLast:t===h.length-1,onMoveUp:()=>sr(t,t-1),onMoveDown:()=>sr(t,t+1),onToggleActive:t=>ss(e.id,t),autoPing:Y[p]&&"oauth"===e.authType?{on:!0===eO.connections[e.id],onToggle:t=>{var s;return s=e.id,void t0({...eO,connections:{...eO.connections,[s]:t}})},provider:p}:null,onEdit:()=>{ei(e),et(!0)},onDelete:()=>t8(e.id),onAllowlistHost:()=>sa(e),oneByOneStatus:eZ[e.id]||null})})]},e.id))}),sn=async e=>{if(!ef.has(e)){eb(t=>new Set(t).add(e));try{let t=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${tI}/${e}`})}),s=await t.json();ep(t=>({...t,[e]:s.ok?"ok":"error"})),eh(s.ok?"":s.error||"Model not reachable")}catch{ep(t=>({...t,[e]:"error"})),eh("Network error")}finally{eb(t=>{let s=new Set(t);return s.delete(e),s})}}};return k?(0,a.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,a.jsx)(d.Qv,{}),(0,a.jsx)(d.Qv,{})]}):tm?(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:gap-8 sm:px-0",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)(n(),{href:"/dashboard/providers",className:"inline-flex items-center gap-1 text-sm text-text-muted hover:text-primary transition-colors mb-4",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-lg",children:"arrow_back"}),"Back to Providers"]}),(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3 sm:gap-4",children:[(0,a.jsx)("div",{className:"flex size-12 shrink-0 items-center justify-center rounded-lg",style:{backgroundColor:`${tm.color}15`},children:ec?(0,a.jsx)("span",{className:"text-sm font-bold",style:{color:tm.color},children:tm.textIcon||tm.id.slice(0,2).toUpperCase()}):(0,a.jsx)(o.default,{src:ty&&tm.apiType?"responses"===tm.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":tv?"/providers/anthropic-m.png":`/providers/${tm.id}.png`,alt:tm.name,width:48,height:48,className:"max-h-12 max-w-12 rounded-lg object-contain",sizes:"48px",onError:()=>em(!0)})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 flex-wrap",children:[(0,a.jsx)("h1",{className:"truncate text-2xl font-semibold tracking-tight sm:text-3xl",children:tm.name}),(tm.notice?.apiKeyUrl||tm.notice?.signupUrl||tm.website)&&(0,a.jsxs)("a",{href:tm.notice?.apiKeyUrl||tm.notice?.signupUrl||tm.website,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline inline-flex items-center gap-1",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"open_in_new"}),tm.notice?.apiKeyUrl?"Get API Key":"Sign up / Learn more"]})]}),(0,a.jsxs)("p",{className:"text-text-muted",children:[h.length," connection",1===h.length?"":"s"]})]})]})]}),tm.deprecated&&(0,a.jsxs)("div",{className:"flex items-start gap-3 rounded-xl border border-amber-500/25 bg-amber-500/8 px-4 py-3 text-xs text-amber-600 dark:text-amber-400",children:[(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-base text-amber-500 mt-0.5",children:"warning"}),(0,a.jsx)("p",{className:"leading-relaxed font-normal",children:String(tm.deprecationNotice).replace(/^⚠️\s*⚠️?\s*/,"")})]}),tm.notice?.text&&!tm.deprecated&&(0,a.jsxs)("div",{className:"flex flex-col gap-2 rounded-lg border border-blue-500/30 bg-blue-500/10 px-3 py-2 sm:flex-row sm:items-center",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px] text-blue-500 shrink-0",children:"info"}),(0,a.jsx)("p",{className:"min-w-0 flex-1 text-xs leading-relaxed text-blue-600 dark:text-blue-400",children:tm.notice.text}),tm.notice.apiKeyUrl&&(0,a.jsx)("a",{href:tm.notice.apiKeyUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex justify-center rounded bg-blue-500 px-2 py-1 text-xs font-medium text-white transition-colors hover:bg-blue-600 sm:py-0.5",children:"Get API Key →"})]}),tj&&A&&(0,a.jsx)(d.Zp,{children:(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:tv?"Anthropic Compatible Details":"OpenAI Compatible Details"}),(0,a.jsxs)("p",{className:"break-all text-sm text-text-muted",children:[tv?"Messages API":"responses"===A.apiType?"Responses API":"Chat Completions"," \xb7 ",(A.baseUrl||"").replace(/\/$/,""),"/",tv?"messages":"responses"===A.apiType?"responses":"chat/completions"]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:()=>{W(""),K(!0)},className:"w-full sm:w-auto",children:"Add API Key"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"edit",onClick:()=>ea(!0),className:"w-full sm:w-auto",children:"Edit"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"delete",onClick:async()=>{eF({title:"Delete Compatible Node",message:`Delete this ${tv?"Anthropic":"OpenAI"} Compatible node?`,onConfirm:async()=>{eF(null);try{await (0,Z.x)(`/api/provider-nodes/${p}`,{method:"DELETE"}),u.push("/dashboard/providers")}catch(e){(0,O.s)("Error deleting provider node:",e)}}})},className:"w-full sm:w-auto",children:"Delete"})]})]})}),th?(0,a.jsx)(d.gw,{providerId:p}):(0,a.jsxs)(d.Zp,{children:[(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Connections"}),(0,a.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:gap-4",children:[h.length>0&&(0,a.jsxs)(a.Fragment,{children:[b.length>0&&(0,a.jsxs)(d.$n,{size:"sm",variant:"danger",icon:"delete",onClick:()=>{let e=b.length;0!==e&&eF({title:`Delete ${e} Connection${e>1?"s":""}`,message:`Delete ${e} connection${e>1?"s":""}? This cannot be undone.`,onConfirm:async()=>{eF(null);let e=0,t=[...b],s=[];for(let a of t)try{(await fetch(`/api/providers/${a}`,{method:"DELETE"})).ok?s.push(a):e+=1}catch(t){(0,O.s)("Error deleting connection:",t),e+=1}f(e=>e.filter(e=>!s.includes(e.id))),g([]),e>0&&(0,O.s)(`Deleted ${t.length-e} connection(s), ${e} failed.`)}})},children:["Delete Selected (",b.length,")"]}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"sync",onClick:t7,disabled:eK,children:eK?"Testing Connection One-by-One...":"Test Connection One-by-One"}),eK&&(0,a.jsx)(d.$n,{size:"sm",variant:"ghost",icon:"stop",onClick:()=>{eK&&(e0.current=!0,eH(!0))},disabled:eW,children:eW?"Stopping...":"Stop"})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2 rounded-xl border border-border/60 bg-surface-2/40 p-3",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-medium text-text-main",children:"Balanced Scheduler"}),(0,a.jsx)(d.m_,{text:"Process-local least-inflight scheduling with fresh quota signals. Sessions stay on one account and rebind on failure, cooldown, or cap.",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[15px] text-text-muted cursor-help",children:"info"})})]}),(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[eN&&(0,a.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-text-muted",children:["Affinity",(0,a.jsx)("input",{"aria-label":"Session affinity minutes",type:"number",min:1,max:1440,value:eS,onChange:e=>tY(e.target.value),className:"w-14 px-2 py-0.5 text-xs border border-border rounded-md bg-background text-text-main focus:outline-none focus:border-primary"}),(0,a.jsx)("span",{className:"text-[11px]",children:"min"})]}),(0,a.jsx)(d.lM,{checked:eN,onChange:tQ,"aria-label":"Balanced scheduler"})]})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3 pt-2 border-t border-border/40",title:eN?"Saved and used again when balanced scheduling is off":void 0,children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-medium text-text-main",children:"Round Robin"}),(0,a.jsx)(d.m_,{text:"Cycles through connections sequentially in round-robin fashion.",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[15px] text-text-muted cursor-help",children:"info"})})]}),(0,a.jsxs)("div",{className:"flex items-center gap-3",children:["round-robin"===ev&&(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"text-xs text-text-muted",children:"Sticky:"}),(0,a.jsx)("input",{type:"number",min:1,value:ew,onChange:e=>tZ(e.target.value),placeholder:"1",disabled:eN,title:eN?"Saved and used again when balanced scheduling is off":void 0,className:"w-14 px-2 py-0.5 text-xs border border-border rounded-md bg-background text-text-main focus:outline-none focus:border-primary disabled:cursor-not-allowed disabled:opacity-50"})]}),(0,a.jsx)(d.lM,{checked:"round-robin"===ev,onChange:tG,"aria-label":"Round Robin",disabled:eN,title:eN?"Saved and used again when balanced scheduling is off":void 0})]})]})]})]})]}),0===h.length?(0,a.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"inline-flex items-center justify-center w-9 h-9 rounded-full bg-primary/10 text-primary shrink-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:tp?"lock":"key"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"No connections yet"}),tN&&(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["Choose ",tC," or ",tS,"."]})]})]}),(0,a.jsx)("div",{className:"flex gap-2",children:tN?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.$n,{size:"sm",icon:"lock",variant:"secondary",onClick:tA,children:tC}),(0,a.jsx)(d.$n,{size:"sm",icon:"key",onClick:tT,children:tS})]}):(0,a.jsxs)(a.Fragment,{children:[!tj&&"iflow"===p&&(0,a.jsx)(d.$n,{size:"sm",icon:"cookie",variant:"secondary",onClick:()=>_(!0),children:"Cookie"}),"codex"===p&&(0,a.jsx)(d.$n,{size:"sm",icon:"playlist_add",variant:"secondary",onClick:()=>X(!0),children:(0,w.Tl)("Bulk Add")}),(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:tO,children:tj?"Add API Key":"iflow"===p?"OAuth":"Add Connection"})]})})]}):(0,a.jsxs)(a.Fragment,{children:[eY&&(0,a.jsx)("div",{className:"mb-4 rounded-lg border border-black/10 bg-black/[0.02] px-3 py-2 text-xs text-text-muted dark:border-white/10 dark:bg-white/[0.03]",children:(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,a.jsxs)("span",{children:["Total: ",eY.total]}),(0,a.jsxs)("span",{children:["Completed: ",eY.completed]}),(0,a.jsxs)("span",{children:["Passed: ",eY.passed]}),(0,a.jsxs)("span",{children:["Failed: ",eY.failed]}),eY.stopped&&(0,a.jsx)("span",{className:"text-amber-600 dark:text-amber-400",children:"Stopped"}),eK&&eV&&(0,a.jsxs)("span",{children:["Running: ",h.find(e=>e.id===eV)?.name||eV]})]})}),h.length>0&&(0,a.jsx)("div",{className:"mb-3 flex items-center gap-2 border-b border-black/[0.03] pb-2 dark:border-white/[0.03]",children:(0,a.jsxs)("label",{className:"flex cursor-pointer items-center gap-1.5 text-xs text-text-muted hover:text-primary",children:[(0,a.jsx)("input",{type:"checkbox",checked:si,onChange:()=>{si?g([]):g(h.map(e=>e.id))},className:"h-3.5 w-3.5 rounded border-gray-300 text-primary focus:ring-primary"}),"Select All"]})}),sl,!tj&&(0,a.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-2 sm:flex",children:["iflow"===p&&(0,a.jsx)(d.$n,{size:"sm",icon:"cookie",variant:"secondary",onClick:()=>_(!0),title:"Add connection using browser cookie",className:"w-full sm:w-auto",children:"Cookie"}),"codex"===p&&(0,a.jsx)(d.$n,{size:"sm",icon:"playlist_add",variant:"secondary",onClick:()=>X(!0),title:(0,w.Tl)("Bulk import codex accounts from JSON"),className:"w-full sm:w-auto",children:(0,w.Tl)("Bulk Add")}),tN?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.$n,{size:"sm",icon:"lock",variant:"secondary",onClick:tA,className:"w-full sm:w-auto",children:tC}),(0,a.jsx)(d.$n,{size:"sm",icon:"key",onClick:tT,className:"w-full sm:w-auto",children:tS})]}):(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:tO,className:"w-full sm:w-auto",children:"Add"})]})]})]}),(0,a.jsx)(V,{providerId:p,scheduleKey:tD},p),(0,a.jsxs)(d.Zp,{children:[(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Available Models"}),tR&&(0,a.jsx)("select",{value:eA,onChange:e=>{var t;eT(t=e.target.value),tX(t)},title:"Appends (level) suffix to copied model names",className:"rounded-md border border-border bg-background px-2 py-1 text-xs focus:border-primary focus:outline-none",children:tR.map(e=>(0,a.jsx)("option",{value:e,children:`Thinking: ${e.charAt(0).toUpperCase()+e.slice(1)}`},e))})]}),tk.showToolbar&&(e=(tk.showBulkControls?[...tb,...eM.filter(e=>!tb.some(t=>t.id===e.id))].filter(e=>{let t=(0,m.CP)(e);return!t||"llm"===t}).map(e=>e.id):[]).filter(e=>!tM(e)),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[tk.showImport&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:e3?"progress_activity":"cloud_download",onClick:t6,disabled:e3||!tw,title:tw?"Import models from the active connection":"Add an active connection to import models",children:e3?"Importing...":"Import models"}),tk.showVerify&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:te?.status==="running"?"progress_activity":"science",onClick:()=>e9(e=>!e),children:te?.status==="running"?`Verifying ${te.done}/${te.total}`:e8?"Hide verify":"Verify models"}),tk.showBulkControls&&eU.length>0&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"restart_alt",onClick:tF,children:"Active All"}),tk.showBulkControls&&e.length>0&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"block",onClick:()=>t_(e),children:"Disable All"})]}))]}),!!ex&&(0,a.jsx)("p",{className:"text-xs text-red-500 mb-3 break-words",children:ex}),e6&&(0,a.jsxs)("div",{className:"mb-3 flex items-center justify-between gap-2 rounded-xl border border-primary/30 bg-primary/10 px-3.5 py-2 text-xs font-medium text-text-main",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px] text-primary",children:"info"}),(0,a.jsx)("span",{children:e6})]}),(0,a.jsx)("button",{onClick:()=>e7(""),className:"text-text-muted hover:text-text-main p-0.5 rounded",title:"Dismiss",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"close"})})]}),e8&&(t=h.find(e=>b.includes(e.id)&&!1!==e.isActive)||h.find(e=>!1!==e.isActive),s=[...(0,C.R3)({customModels:eo,modelAliases:el,providerAlias:tI,builtInModels:tb,type:"llm"}).filter(e=>!tM(e.id)).map(e=>({id:e.id,name:e.name||e.id,kind:"llm"})),...tb.filter(e=>{let t=(0,m.CP)(e);return(!t||"llm"===t)&&!tM(e.id)}).map(e=>({id:e.id,name:e.name||e.id,kind:"llm"}))],(0,a.jsx)(L,{connectionId:t?.id,providerAlias:tI,models:s,jobSnapshot:te,onClose:()=>e9(!1),onStarted:e=>{tt(e&&e.status?e:null);let s=e?.connectionId||t?.id;s&&t1(s)},onComplete:async e=>{e?.removedStatus&&tt(t=>t?{...t,dead:Number(e.dead??t.dead??0),retryable:Number(e.retryable??t.retryable??0),retryableAuthOnly:!0===e.retryableAuthOnly}:t),e?.removed>0&&await tL(),e?.removed>0&&await tz(),(e?.removed>0||e?.cacheCleared)&&await tB(t?.id)}})),(()=>{let e,t,s;if(tj)return(0,a.jsx)(R,{providerStorageAlias:tI,providerDisplayAlias:tD,modelAliases:el,customModels:eo,copied:to,onCopy:td,onSetAlias:t2,onDeleteAlias:t5,onAddCustomModel:e=>t3(e,"llm",tI),onDeleteCustomModel:e=>t4(e,"llm",tI),onRefreshModels:tL,connections:h,isAnthropic:tv,disabledModelIds:eU,onEnableModel:tq});let r=[...tb,...eM.filter(e=>!tb.some(t=>t.id===e.id))].filter(e=>{let t=(0,m.CP)(e);return!t||"llm"===t}),i=r.filter(e=>!tM(e.id)),l=r.filter(e=>tM(e.id)),n=(0,C.R3)({customModels:eo,modelAliases:el,providerAlias:tI,builtInModels:tb,type:"llm"}),o=n.filter(e=>!tM(e.id)&&("all"===tl||(tr[(0,G.v)(e.id,tI)]||null)===tl)),d=i.filter(e=>"all"===tl||(tr[(0,G.v)(e.id,tI)]||null)===tl);return(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsx)("div",{className:"mb-2 flex flex-wrap items-center gap-1.5 text-xs",children:[{id:"all",label:"All",count:i.length+n.filter(e=>!tM(e.id)).length},{id:"ok",label:"Reachable",count:[...i,...n].filter(e=>!tM(e.id)&&("ok"===tr[(0,G.v)(e.id,tI)]||"ok"===eu[e.id])).length},{id:"dead",label:"Dead",count:[...i,...n].filter(e=>!tM(e.id)&&("dead"===tr[(0,G.v)(e.id,tI)]||"error"===eu[e.id])).length},{id:"retry",label:"Retry",count:[...i,...n].filter(e=>!tM(e.id)&&"retry"===tr[(0,G.v)(e.id,tI)]).length}].map(e=>(0,a.jsxs)("button",{onClick:()=>tn(e.id),className:`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1 text-xs font-medium transition-all ${tl===e.id?"bg-primary text-black font-semibold shadow-sm":"bg-surface-2/60 border border-border/40 text-text-muted hover:border-border hover:text-text-main"}`,children:[(0,a.jsx)("span",{children:e.label}),(0,a.jsx)("span",{className:`rounded-full px-1.5 py-0.2 text-[10px] tabular-nums ${tl===e.id?"bg-black/20 text-black font-bold":"bg-black/10 dark:bg-white/10 text-text-muted"}`,children:e.count})]},e.id))}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-3",children:[o.map(e=>{let t=(0,G.v)(e.id,tI);return(0,a.jsx)(T,{model:{id:e.id,name:e.name},fullModel:`${tD}/${e.id}`,alias:e.alias,copied:to,onCopy:td,onSetAlias:()=>{},onDeleteAlias:()=>{"custom"===e.source?t4(e.id,"llm",tI):t5(e.alias)},testStatus:eu[e.id],onTest:h.length>0||th?()=>sn(e.id):void 0,isTesting:ef.has(e.id),isCustom:!0,isFree:!1,caps:x(`${p}/${e.id}`),thinkingSuffix:tE(e.id),latencyMs:ts[e.id]??ts[t],probeState:te?.status==="running"&&te?.perModel?.[t]?te.perModel[t]:tr[t]||null},`${e.source}-${e.fullModel}`)}),d.map(e=>{let t=`${tI}/${e.id}`,s=`${p}/${e.id}`,r=Object.entries(el).find(([,e])=>e===t||e===s)?.[0],i=(0,G.v)(e.id,tI);return(0,a.jsx)(T,{model:e,fullModel:`${tD}/${e.id}`,alias:r,copied:to,onSetAlias:t=>t2(e.id,t,tI),onCopy:td,onDeleteAlias:()=>t5(r),testStatus:eu[e.id],onTest:h.length>0||th?()=>sn(e.id):void 0,isTesting:ef.has(e.id),isFree:e.isFree,onDisable:()=>tU(e.id),caps:x(`${p}/${e.id}`),thinkingSuffix:tE(e.id),latencyMs:ts[e.id]??ts[i],probeState:te?.status==="running"&&te?.perModel?.[i]?te.perModel[i]:tr[i]||null},e.id)}),(0,a.jsxs)("button",{onClick:()=>ey(!0),className:"flex min-h-[58px] min-w-[200px] flex-1 items-center justify-center gap-2 rounded-xl border border-dashed border-primary/40 bg-primary/5 px-4 py-3 text-xs font-medium text-primary transition-all hover:border-primary hover:bg-primary/10 hover:shadow-soft sm:flex-none",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"add_circle"}),"Add Custom Model"]}),eR.length>0&&(e=new Set([...Object.values(el),...n.map(e=>e.fullModel)]),t=new Set(tb.map(e=>e.id)),0===(s=eR.filter(s=>!e.has(`${tI}/${s.id}`)&&!t.has(s.id))).length?null:(0,a.jsxs)("div",{className:"w-full mt-2",children:[(0,a.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"Suggested free models (≥200k context):"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:s.map(e=>(0,a.jsxs)("button",{onClick:async()=>{await t3(e.id,"llm",tI)},className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg border border-black/10 dark:border-white/10 text-xs text-text-muted hover:text-primary hover:border-primary/40 hover:bg-primary/5 transition-colors",title:`${e.name} \xb7 ${(e.contextLength/1e3).toFixed(0)}k ctx`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"add"}),e.id.split("/").pop()]},e.id))})]})),l.length>0&&(0,a.jsxs)("div",{className:"w-full mt-2",children:[(0,a.jsxs)("p",{className:"text-xs text-text-muted mb-2",children:["Disabled models (",l.length,"):"]}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:l.map(e=>(0,a.jsxs)("button",{onClick:()=>tq(e.id),className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg border border-dashed border-black/10 dark:border-white/10 text-xs text-text-muted hover:text-primary hover:border-primary/40 hover:bg-primary/5 transition-colors",title:"Restore model",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"add"}),e.id]},e.id))})]})]})]})})()]}),"kiro"===p?(0,a.jsx)(d.Mh,{isOpen:I,providerInfo:tm,onSuccess:t9,onClose:()=>D(!1)}):"cursor"===p?(0,a.jsx)(d.G9,{isOpen:I,onSuccess:t9,onClose:()=>D(!1)}):"gitlab"===p?(0,a.jsx)(d.vj,{isOpen:I,providerInfo:tm,onSuccess:t9,onClose:()=>D(!1)}):(0,a.jsx)(d.LF,{isOpen:I,provider:p,providerInfo:tm,onSuccess:t9,onClose:()=>D(!1)}),"iflow"===p&&(0,a.jsx)(d.vE,{isOpen:M,onSuccess:()=>{tK(),_(!1)},onClose:()=>_(!1)}),(0,a.jsx)(z,{isOpen:J,provider:p,providerName:tm.name,isCompatible:tj,isAnthropic:tv,authType:tm?.authType,authHint:tm?.authHint,website:tm?.website,error:B,onSave:se,onBulkDone:tK,onClose:()=>{W(""),K(!1)}}),(0,a.jsx)(d.wI,{isOpen:ee,connection:er,onSave:st,onClose:()=>et(!1)}),tj&&(0,a.jsx)(U,{isOpen:es,node:A,onSave:tW,onClose:()=>ea(!1),isAnthropic:tv}),!tj&&(0,a.jsx)(q,{isOpen:eg,providerAlias:tI,providerDisplayAlias:tD,onSave:async e=>{await t3(e,"llm",tI),ey(!1)},onClose:()=>ey(!1)}),"codex"===p&&(0,a.jsx)(F,{isOpen:H,onClose:()=>X(!1),onSuccess:tK}),(0,a.jsx)(d.uo,{isOpen:eJ,onClose:()=>eL(!1),onConfirm:()=>{(window.localStorage.setItem(tc,"true"),eL(!1),tp)?t$():tT()},title:"Risk Notice",message:tm?.deprecationNotice,confirmText:"I Understand, Continue",cancelText:"Cancel",variant:"danger"}),(0,a.jsx)(d.uo,{isOpen:!!e_,onClose:()=>eF(null),onConfirm:e_?.onConfirm,title:e_?.title||"Confirm",message:e_?.message,variant:"danger"})]}):(0,a.jsxs)("div",{className:"text-center py-20",children:[(0,a.jsx)("p",{className:"text-text-muted",children:"Provider not found"}),(0,a.jsx)(n(),{href:"/dashboard/providers",className:"text-primary mt-4 inline-block",children:"Back to Providers"})]})}},70217:(e,t,s)=>{"use strict";function a(e){return"error"===e||"expired"===e||"unavailable"===e||"reauth_required"===e||"invalid"===e}function r(e,t){return!1===e?"default":"active"===t||"success"===t?"success":a(t)?"error":"default"}s.d(t,{g:()=>r,t:()=>a})}},e=>{e.O(0,[2574,3862,782,8500,594,1321,4707,1330,979,8441,3794,7358],()=>e(e.s=7687)),_N_E=e.O()}]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
e7Ha89rDlp2qPIlpARdsI
|