switchboard-router 0.9.61 → 0.9.62
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/static/chunks/1321-5586527eb9770b48.js +1 -0
- package/app/.next/static/chunks/4601-44deee06e6597c34.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/agent-library/{page-fa24110e606e19b6.js → page-5099a8abbc816db2.js} +1 -1
- package/app/{.next-cli-build/static/chunks/app/(dashboard)/dashboard/basic-chat/page-7b00fb83303d1d11.js → .next/static/chunks/app/(dashboard)/dashboard/basic-chat/page-f19524e912fe1985.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/cli-tools/[toolId]/{page-e59f3822e2167ab7.js → page-5ffac5b1a7f569eb.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/cli-tools/{page-d994adf3e0ce78c1.js → page-e88926cdf34f51b4.js} +1 -1
- package/app/{.next-cli-build/static/chunks/app/(dashboard)/dashboard/combos/page-99d3be5c7da63d57.js → .next/static/chunks/app/(dashboard)/dashboard/combos/page-f18e04dca95f62e1.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/combos/routing/{page-650dc0927f999aaf.js → page-0fbb282f4f13b383.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/console-log/{page-eefda4a8f32e649e.js → page-a6d96961aa96c6f6.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/endpoint/{page-adba2750c4fbf61e.js → page-57222cb64d90dbc5.js} +1 -1
- package/app/{.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page-e6fc3a5c25ce1247.js → .next/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page-b538f94596e78384.js} +1 -1
- package/app/{.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/page-078eb5d8bfc3f4d1.js → .next/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/page-e5f3c1f8be627058.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/media-providers/combo/[id]/{page-7dfde081613f35f3.js → page-3b278b46c2e9b047.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/media-providers/{page-1d63cfd88010b65f.js → page-768e0fe3ec5c50cb.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/media-providers/web/{page-281c93713fd1e960.js → page-932db86bb9b65c82.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/mitm/{page-f44e14a7efc8f81a.js → page-77d678509c4b9807.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/profile/{page-0e0047609d5634c9.js → page-be26ebe2eb5fe86f.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/[id]/page-7650a3a5ee2467f7.js +10 -0
- package/app/{.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/new/page-604dae851964c441.js → .next/static/chunks/app/(dashboard)/dashboard/providers/new/page-40b58bbd9ed53384.js} +1 -1
- package/app/{.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/page-e1c9f4ce8466e3ad.js → .next/static/chunks/app/(dashboard)/dashboard/providers/page-62fb355a1fda21fb.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/pxpipe/{page-6ca234b58c5e9feb.js → page-da3416bfce941d67.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/quota/{page-cf70f587dc7ab205.js → page-c9a257b85e05472a.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/skills/[id]/{page-ea262b6192d5a92c.js → page-2141fe25b428c1a8.js} +1 -1
- package/app/{.next-cli-build/static/chunks/app/(dashboard)/dashboard/skills/page-36d107b083ad3a43.js → .next/static/chunks/app/(dashboard)/dashboard/skills/page-459447066f6cd1d5.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/token-saver/{page-14e5599c720c645b.js → page-93ce8e180c126dcc.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/translator/{page-687e09f904b04cea.js → page-b6c5cc339e7a5ef3.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/usage/{page-195bdcbea10136e1.js → page-492962969724f559.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/{layout-6dfa9d7deb27d461.js → layout-c0725f0b6b7f0bea.js} +1 -1
- package/app/.next/static/chunks/app/dashboard/settings/pricing/page-e08a7bfc3255b9c7.js +1 -0
- package/app/.next/static/chunks/app/layout-5fa07c6e20da16ba.js +1 -0
- package/app/.next/static/chunks/app/login/{page-f326e6c17a8b0e04.js → page-df9fdce0e38e5f58.js} +1 -1
- package/app/.next/static/media/catalog.b2c6512a.json +38874 -0
- package/app/.next-cli-build/BUILD_ID +1 -1
- package/app/.next-cli-build/app-path-routes-manifest.json +13 -13
- 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.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.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 +3 -3
- 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 +6 -6
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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/fx-settings/manual-configs/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/fx-settings/route.js +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/fx-settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/gemini-cli-settings/route.js +3 -3
- 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 +2 -2
- 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 +1 -1
- 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 +1 -1
- 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/manual-configs/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/pi-settings/route.js +2 -2
- 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.nft.json +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/live/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.nft.json +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.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.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/routable/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 +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.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.nft.json +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.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.nft.json +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.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.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.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.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.nft.json +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.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.nft.json +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 +4 -4
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_full.segment.rsc +4 -4
- 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 +4 -4
- 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 +13 -13
- package/app/.next-cli-build/server/chunks/1350.js +1 -1
- package/app/.next-cli-build/server/chunks/2847.js +1 -1
- package/app/.next-cli-build/server/chunks/3464.js +1 -1
- package/app/.next-cli-build/server/chunks/3904.js +1 -1
- package/app/.next-cli-build/server/chunks/4454.js +1 -1
- package/app/.next-cli-build/server/chunks/4646.js +1 -1
- package/app/.next-cli-build/server/chunks/5139.js +1 -1
- package/app/.next-cli-build/server/chunks/7662.js +1 -1
- package/app/.next-cli-build/server/chunks/7757.js +1 -1
- package/app/.next-cli-build/server/chunks/869.js +1 -1
- package/app/.next-cli-build/server/chunks/8998.js +7 -7
- package/app/.next-cli-build/server/chunks/static/media/catalog.b2c6512a.json +38874 -0
- package/app/.next-cli-build/server/middleware-build-manifest.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-cli-build/static/chunks/1321-5586527eb9770b48.js +1 -0
- package/app/.next-cli-build/static/chunks/4601-44deee06e6597c34.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/agent-library/{page-fa24110e606e19b6.js → page-5099a8abbc816db2.js} +1 -1
- package/app/{.next/static/chunks/app/(dashboard)/dashboard/basic-chat/page-7b00fb83303d1d11.js → .next-cli-build/static/chunks/app/(dashboard)/dashboard/basic-chat/page-f19524e912fe1985.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/cli-tools/[toolId]/{page-e59f3822e2167ab7.js → page-5ffac5b1a7f569eb.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/cli-tools/{page-d994adf3e0ce78c1.js → page-e88926cdf34f51b4.js} +1 -1
- package/app/{.next/static/chunks/app/(dashboard)/dashboard/combos/page-99d3be5c7da63d57.js → .next-cli-build/static/chunks/app/(dashboard)/dashboard/combos/page-f18e04dca95f62e1.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/combos/routing/{page-650dc0927f999aaf.js → page-0fbb282f4f13b383.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/console-log/{page-eefda4a8f32e649e.js → page-a6d96961aa96c6f6.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/endpoint/{page-adba2750c4fbf61e.js → page-57222cb64d90dbc5.js} +1 -1
- package/app/{.next/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page-e6fc3a5c25ce1247.js → .next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page-b538f94596e78384.js} +1 -1
- package/app/{.next/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/page-078eb5d8bfc3f4d1.js → .next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/page-e5f3c1f8be627058.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/combo/[id]/{page-7dfde081613f35f3.js → page-3b278b46c2e9b047.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/{page-1d63cfd88010b65f.js → page-768e0fe3ec5c50cb.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/web/{page-281c93713fd1e960.js → page-932db86bb9b65c82.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/mitm/{page-f44e14a7efc8f81a.js → page-77d678509c4b9807.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/profile/{page-0e0047609d5634c9.js → page-be26ebe2eb5fe86f.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/[id]/page-7650a3a5ee2467f7.js +10 -0
- package/app/{.next/static/chunks/app/(dashboard)/dashboard/providers/new/page-604dae851964c441.js → .next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/new/page-40b58bbd9ed53384.js} +1 -1
- package/app/{.next/static/chunks/app/(dashboard)/dashboard/providers/page-e1c9f4ce8466e3ad.js → .next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/page-62fb355a1fda21fb.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/pxpipe/{page-6ca234b58c5e9feb.js → page-da3416bfce941d67.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/quota/{page-cf70f587dc7ab205.js → page-c9a257b85e05472a.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/skills/[id]/{page-ea262b6192d5a92c.js → page-2141fe25b428c1a8.js} +1 -1
- package/app/{.next/static/chunks/app/(dashboard)/dashboard/skills/page-36d107b083ad3a43.js → .next-cli-build/static/chunks/app/(dashboard)/dashboard/skills/page-459447066f6cd1d5.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/token-saver/{page-14e5599c720c645b.js → page-93ce8e180c126dcc.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/translator/{page-687e09f904b04cea.js → page-b6c5cc339e7a5ef3.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/usage/{page-195bdcbea10136e1.js → page-492962969724f559.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/{layout-6dfa9d7deb27d461.js → layout-c0725f0b6b7f0bea.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/dashboard/settings/pricing/page-e08a7bfc3255b9c7.js +1 -0
- package/app/.next-cli-build/static/chunks/app/layout-5fa07c6e20da16ba.js +1 -0
- package/app/.next-cli-build/static/chunks/app/login/{page-f326e6c17a8b0e04.js → page-df9fdce0e38e5f58.js} +1 -1
- package/app/.next-cli-build/static/media/catalog.b2c6512a.json +38874 -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/open-sse/providers/generated/catalog.json +37152 -0
- package/app/package.json +3 -2
- package/package.json +1 -1
- package/app/.next/static/chunks/1321-8f2bc21e3e1510f8.js +0 -1
- package/app/.next/static/chunks/4707-8ea6ba647d0a40c9.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/[id]/page-9bc17a08bc8f466c.js +0 -10
- package/app/.next/static/chunks/app/dashboard/settings/pricing/page-423a4c1e078872dd.js +0 -1
- package/app/.next/static/chunks/app/layout-26e1615874db4cd7.js +0 -1
- package/app/.next/static/media/catalog.fb7b1b70.json +0 -1722
- package/app/.next-cli-build/server/chunks/static/media/catalog.fb7b1b70.json +0 -1722
- package/app/.next-cli-build/static/chunks/1321-8f2bc21e3e1510f8.js +0 -1
- package/app/.next-cli-build/static/chunks/4707-8ea6ba647d0a40c9.js +0 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/[id]/page-9bc17a08bc8f466c.js +0 -10
- package/app/.next-cli-build/static/chunks/app/dashboard/settings/pricing/page-423a4c1e078872dd.js +0 -1
- package/app/.next-cli-build/static/chunks/app/layout-26e1615874db4cd7.js +0 -1
- package/app/.next-cli-build/static/media/catalog.fb7b1b70.json +0 -1722
- /package/app/.next/static/{buFm6Q9XY8OxLsQzoorjq → cd9DZQ978U7eW2QFBhfwd}/_buildManifest.js +0 -0
- /package/app/.next/static/{buFm6Q9XY8OxLsQzoorjq → cd9DZQ978U7eW2QFBhfwd}/_ssgManifest.js +0 -0
- /package/app/.next-cli-build/static/{buFm6Q9XY8OxLsQzoorjq → cd9DZQ978U7eW2QFBhfwd}/_buildManifest.js +0 -0
- /package/app/.next-cli-build/static/{buFm6Q9XY8OxLsQzoorjq → cd9DZQ978U7eW2QFBhfwd}/_ssgManifest.js +0 -0
|
@@ -1 +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
|
+
(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,4601,1321,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:()=>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()}]);
|
|
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,4601,1321,1330,8441,3794,7358],()=>e(e.s=63759)),_N_E=e.O()}]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[712],{35497:(e,t,l)=>{"use strict";l.d(t,{x0:()=>E.default,Ex:()=>i.default,$n:()=>s.default,nh:()=>R.default,Zp:()=>r.default,Qv:()=>c.CardSkeleton,CK:()=>p.default,uo:()=>o.ConfirmModal,G9:()=>y.default,wI:()=>b.default,vj:()=>N.default,vE:()=>j.default,pd:()=>n.default,Mh:()=>v.default,uR:()=>x.default,Nf:()=>h.default,aF:()=>o.default,rq:()=>f.default,gw:()=>C.default,LF:()=>u.default,Wx:()=>_.default,gM:()=>g.default,Iz:()=>w.default,l6:()=>a.default,lM:()=>d.default,m_:()=>k.default,jK:()=>m.default});var s=l(92542),n=l(11910),a=l(98),r=l(84588),o=l(81127),c=l(25086);l(56319);var i=l(56061),d=l(98542);l(61929),l(21110),l(92622),l(8823),l(92173);var u=l(90882),f=l(72908),x=l(28815),p=l(45455),h=l(28058),m=l(4809);l(21931),l(80752),l(40197);var g=l(23615);l(44736);var v=l(62899);l(94230);var y=l(30815),j=l(23936),N=l(95088),b=l(73579),E=l(96748),C=l(4823),w=l(28067),k=l(97677),_=l(51825),R=l(29366);l(76361),l(91450)},44493:(e,t,l)=>{"use strict";l.d(t,{default:()=>d});var s=l(95155),n=l(12115),a=l(35497),r=l(11059),o=l(90620),c=l(78559);let i={LOG:"text-green-400",INFO:"text-blue-400",WARN:"text-yellow-400",ERROR:"text-red-400",DEBUG:"text-purple-400"};function d(){let[e,t]=(0,n.useState)([]),[l,d]=(0,n.useState)(!1),[u,f]=(0,n.useState)(!1),[x,p]=(0,n.useState)(0),h=(0,n.useRef)(null),m=(0,n.useRef)(null),g=async()=>{try{let e=await fetch("/api/translator/console-logs",{method:"DELETE"});if(!e.ok)throw Error(`Request failed with status ${e.status}`)}catch(e){(0,c.s)("Failed to clear console logs:",e)}};(0,n.useEffect)(()=>{let e=new EventSource("/api/translator/console-logs/stream");return m.current=e,e.onopen=()=>{d(!0),f(!1)},e.onmessage=e=>{try{let l=JSON.parse(e.data);"init"===l.type?t(Array.isArray(l.logs)?l.logs.slice(-o.UY.maxLines):[]):"line"===l.type?t(e=>{let t=[...e,l.line];return t.length>o.UY.maxLines?t.slice(-o.UY.maxLines):t}):"lines"===l.type?t(e=>{let t=[...e,...Array.isArray(l.lines)?l.lines:[]];return t.length>o.UY.maxLines?t.slice(-o.UY.maxLines):t}):"clear"===l.type&&t([])}catch(e){(0,c.s)("Failed to parse console log SSE message:",e)}},e.onerror=()=>{d(!1),f(!0)},()=>{e.close(),m.current=null}},[x]);let v=(0,n.useRef)(!0);(0,n.useEffect)(()=>{let e=h.current;e&&v.current&&(e.scrollTop=e.scrollHeight)},[e]);let{copied:y,copy:j}=(0,r.C)();return(0,s.jsx)("div",{className:"",children:(0,s.jsxs)(a.Zp,{children:[(0,s.jsxs)("div",{className:"flex items-center justify-end gap-2 px-4 pt-3 pb-2",children:[(0,s.jsx)("span",{className:`text-xs font-mono mr-auto ${l?"text-green-500":"text-text-muted"}`,role:"status","aria-live":"polite",children:l?"connected":u?"disconnected":"connecting"}),u&&(0,s.jsx)(a.$n,{size:"sm",variant:"outline",icon:"refresh",onClick:()=>{m.current?.close(),f(!1),d(!1),p(e=>e+1)},children:"Reconnect"}),e.length>0&&(0,s.jsx)(a.$n,{size:"sm",variant:"outline",icon:"console_logs"===y?"check":"content_copy",onClick:()=>{j(e.join("\n"),"console_logs")},children:"console_logs"===y?"Copied":"Copy Logs"}),(0,s.jsx)(a.$n,{size:"sm",variant:"outline",icon:"delete",onClick:g,children:"Clear"})]}),u&&(0,s.jsxs)("div",{role:"alert",className:"mx-4 mb-2 flex items-start gap-2 rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-xs text-red-500",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[16px] leading-none mt-0.5",children:"error"}),(0,s.jsx)("span",{children:"Console stream disconnected — the log view is paused and new logs are not being received."})]}),(0,s.jsx)("div",{ref:h,onScroll:()=>{let e=h.current;e&&(v.current=e.scrollHeight-e.scrollTop-e.clientHeight<48)},className:"bg-black rounded-b-lg p-4 text-xs font-mono h-[calc(100vh-220px)] overflow-y-auto","aria-label":"Console log stream",children:0===e.length?(0,s.jsx)("span",{className:"text-text-muted",children:u?"No console logs received yet (disconnected).":"No console logs yet."}):(0,s.jsx)("div",{className:"space-y-0.5",children:e.map((e,t)=>{let l,n;return(0,s.jsx)("div",{children:(n=i[(l=e.match(/\[(\w+)\]/))?l[1]:null]||"text-green-400",(0,s.jsx)("span",{className:n,children:e}))},t)})})})]})})}},63131:(e,t,l)=>{Promise.resolve().then(l.bind(l,44493))}},e=>{e.O(0,[2574,3862,782,8500,594,1321,
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[712],{35497:(e,t,l)=>{"use strict";l.d(t,{x0:()=>E.default,Ex:()=>i.default,$n:()=>s.default,nh:()=>R.default,Zp:()=>r.default,Qv:()=>c.CardSkeleton,CK:()=>p.default,uo:()=>o.ConfirmModal,G9:()=>y.default,wI:()=>b.default,vj:()=>N.default,vE:()=>j.default,pd:()=>n.default,Mh:()=>v.default,uR:()=>x.default,Nf:()=>h.default,aF:()=>o.default,rq:()=>f.default,gw:()=>C.default,LF:()=>u.default,Wx:()=>_.default,gM:()=>g.default,Iz:()=>w.default,l6:()=>a.default,lM:()=>d.default,m_:()=>k.default,jK:()=>m.default});var s=l(92542),n=l(11910),a=l(98),r=l(84588),o=l(81127),c=l(25086);l(56319);var i=l(56061),d=l(98542);l(61929),l(21110),l(92622),l(8823),l(92173);var u=l(90882),f=l(72908),x=l(28815),p=l(45455),h=l(28058),m=l(4809);l(21931),l(80752),l(40197);var g=l(23615);l(44736);var v=l(62899);l(94230);var y=l(30815),j=l(23936),N=l(95088),b=l(73579),E=l(96748),C=l(4823),w=l(28067),k=l(97677),_=l(51825),R=l(29366);l(76361),l(91450)},44493:(e,t,l)=>{"use strict";l.d(t,{default:()=>d});var s=l(95155),n=l(12115),a=l(35497),r=l(11059),o=l(90620),c=l(78559);let i={LOG:"text-green-400",INFO:"text-blue-400",WARN:"text-yellow-400",ERROR:"text-red-400",DEBUG:"text-purple-400"};function d(){let[e,t]=(0,n.useState)([]),[l,d]=(0,n.useState)(!1),[u,f]=(0,n.useState)(!1),[x,p]=(0,n.useState)(0),h=(0,n.useRef)(null),m=(0,n.useRef)(null),g=async()=>{try{let e=await fetch("/api/translator/console-logs",{method:"DELETE"});if(!e.ok)throw Error(`Request failed with status ${e.status}`)}catch(e){(0,c.s)("Failed to clear console logs:",e)}};(0,n.useEffect)(()=>{let e=new EventSource("/api/translator/console-logs/stream");return m.current=e,e.onopen=()=>{d(!0),f(!1)},e.onmessage=e=>{try{let l=JSON.parse(e.data);"init"===l.type?t(Array.isArray(l.logs)?l.logs.slice(-o.UY.maxLines):[]):"line"===l.type?t(e=>{let t=[...e,l.line];return t.length>o.UY.maxLines?t.slice(-o.UY.maxLines):t}):"lines"===l.type?t(e=>{let t=[...e,...Array.isArray(l.lines)?l.lines:[]];return t.length>o.UY.maxLines?t.slice(-o.UY.maxLines):t}):"clear"===l.type&&t([])}catch(e){(0,c.s)("Failed to parse console log SSE message:",e)}},e.onerror=()=>{d(!1),f(!0)},()=>{e.close(),m.current=null}},[x]);let v=(0,n.useRef)(!0);(0,n.useEffect)(()=>{let e=h.current;e&&v.current&&(e.scrollTop=e.scrollHeight)},[e]);let{copied:y,copy:j}=(0,r.C)();return(0,s.jsx)("div",{className:"",children:(0,s.jsxs)(a.Zp,{children:[(0,s.jsxs)("div",{className:"flex items-center justify-end gap-2 px-4 pt-3 pb-2",children:[(0,s.jsx)("span",{className:`text-xs font-mono mr-auto ${l?"text-green-500":"text-text-muted"}`,role:"status","aria-live":"polite",children:l?"connected":u?"disconnected":"connecting"}),u&&(0,s.jsx)(a.$n,{size:"sm",variant:"outline",icon:"refresh",onClick:()=>{m.current?.close(),f(!1),d(!1),p(e=>e+1)},children:"Reconnect"}),e.length>0&&(0,s.jsx)(a.$n,{size:"sm",variant:"outline",icon:"console_logs"===y?"check":"content_copy",onClick:()=>{j(e.join("\n"),"console_logs")},children:"console_logs"===y?"Copied":"Copy Logs"}),(0,s.jsx)(a.$n,{size:"sm",variant:"outline",icon:"delete",onClick:g,children:"Clear"})]}),u&&(0,s.jsxs)("div",{role:"alert",className:"mx-4 mb-2 flex items-start gap-2 rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-xs text-red-500",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[16px] leading-none mt-0.5",children:"error"}),(0,s.jsx)("span",{children:"Console stream disconnected — the log view is paused and new logs are not being received."})]}),(0,s.jsx)("div",{ref:h,onScroll:()=>{let e=h.current;e&&(v.current=e.scrollHeight-e.scrollTop-e.clientHeight<48)},className:"bg-black rounded-b-lg p-4 text-xs font-mono h-[calc(100vh-220px)] overflow-y-auto","aria-label":"Console log stream",children:0===e.length?(0,s.jsx)("span",{className:"text-text-muted",children:u?"No console logs received yet (disconnected).":"No console logs yet."}):(0,s.jsx)("div",{className:"space-y-0.5",children:e.map((e,t)=>{let l,n;return(0,s.jsx)("div",{children:(n=i[(l=e.match(/\[(\w+)\]/))?l[1]:null]||"text-green-400",(0,s.jsx)("span",{className:n,children:e}))},t)})})})]})})}},63131:(e,t,l)=>{Promise.resolve().then(l.bind(l,44493))}},e=>{e.O(0,[2574,3862,782,8500,594,4601,1321,1330,8441,3794,7358],()=>e(e.s=63131)),_N_E=e.O()}]);
|
|
@@ -13,4 +13,4 @@ client = OpenAI(
|
|
|
13
13
|
"messages": [{"role": "user", "content": "Hello"}]
|
|
14
14
|
}'`;return(0,a.jsxs)(x.Zp,{children:[(0,a.jsx)("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 mb-4",children:(0,a.jsxs)("div",{children:[(0,a.jsxs)("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-primary",children:"hub"}),"Protocol & Tool Endpoints"]}),(0,a.jsx)("p",{className:"text-sm text-text-muted mt-1",children:"Every route and protocol exposed by Switchboard with format translation."})]})}),(0,a.jsx)("div",{className:"mb-6 overflow-x-auto pb-1",children:(0,a.jsx)(x.Iz,{options:g,value:n,onChange:r,size:"sm"})}),"snippets"===n?(0,a.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,a.jsxs)("div",{className:"rounded-[10px] bg-surface-2 p-4 border border-border",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,a.jsxs)("span",{className:"text-sm font-semibold flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-primary text-[18px]",children:"terminal"}),"Claude Code CLI Environment"]}),(0,a.jsxs)("button",{type:"button",onClick:()=>s(d,"snippet_claude"),className:"p-1.5 hover:bg-surface rounded text-text-muted hover:text-primary transition-colors text-xs flex items-center gap-1 border border-border/50",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"snippet_claude"===t?"check":"content_copy"}),"snippet_claude"===t?"Copied":"Copy"]})]}),(0,a.jsx)("pre",{className:"text-xs font-mono bg-black/5 dark:bg-black/40 p-3 rounded-[6px] overflow-x-auto text-text-main",children:d})]}),(0,a.jsxs)("div",{className:"rounded-[10px] bg-surface-2 p-4 border border-border",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,a.jsxs)("span",{className:"text-sm font-semibold flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-primary text-[18px]",children:"code"}),"OpenAI Python SDK"]}),(0,a.jsxs)("button",{type:"button",onClick:()=>s(c,"snippet_python"),className:"p-1.5 hover:bg-surface rounded text-text-muted hover:text-primary transition-colors text-xs flex items-center gap-1 border border-border/50",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"snippet_python"===t?"check":"content_copy"}),"snippet_python"===t?"Copied":"Copy"]})]}),(0,a.jsx)("pre",{className:"text-xs font-mono bg-black/5 dark:bg-black/40 p-3 rounded-[6px] overflow-x-auto text-text-main",children:c})]}),(0,a.jsxs)("div",{className:"rounded-[10px] bg-surface-2 p-4 border border-border",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,a.jsxs)("span",{className:"text-sm font-semibold flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-primary text-[18px]",children:"send"}),"Direct cURL"]}),(0,a.jsxs)("button",{type:"button",onClick:()=>s(u,"snippet_curl"),className:"p-1.5 hover:bg-surface rounded text-text-muted hover:text-primary transition-colors text-xs flex items-center gap-1 border border-border/50",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"snippet_curl"===t?"check":"content_copy"}),"snippet_curl"===t?"Copied":"Copy"]})]}),(0,a.jsx)("pre",{className:"text-xs font-mono bg-black/5 dark:bg-black/40 p-3 rounded-[6px] overflow-x-auto text-text-main",children:u})]})]}):(0,a.jsx)("div",{className:"flex flex-col divide-y divide-border/60",children:l.map(e=>{let i=`${o}${e.path}`;return(0,a.jsxs)("div",{className:"py-3.5 first:pt-0 last:pb-0 flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,a.jsx)("span",{className:`text-[11px] font-mono font-semibold px-2 py-0.5 rounded border shrink-0 ${function(e){switch(e){case"POST":return"bg-teal-500/10 text-teal-600 dark:text-teal-400 border-teal-500/20";case"GET":return"bg-sky-500/10 text-sky-600 dark:text-sky-400 border-sky-500/20";default:return"bg-primary/10 text-primary border-primary/25"}}(e.method)}`,children:e.method}),(0,a.jsx)("span",{className:"text-sm font-medium truncate",children:e.label})]}),e.headerHint&&(0,a.jsx)("span",{className:"text-[11px] font-mono text-text-muted hidden md:inline truncate max-w-[280px]",children:e.headerHint})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,a.jsx)(x.pd,{value:i,readOnly:!0,className:"flex-1 min-w-0",inputClassName:"font-mono text-xs bg-surface-2"}),(0,a.jsx)("button",{type:"button",onClick:()=>s(i,e.id),className:"p-2 hover:bg-surface-2 rounded text-text-muted hover:text-primary transition-colors shrink-0 border border-transparent hover:border-border",title:"Copy URL","aria-label":`Copy ${e.label} URL`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] leading-none",children:t===e.id?"check":"content_copy"})})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:e.desc})]},e.id)})})]})}function j({message:e,action:t}){return(0,a.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-brand-500/10 border border-brand-500/30 text-brand-400",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px] shrink-0 leading-none",children:"warning"}),(0,a.jsx)("p",{className:"text-xs flex-1 text-brand-300",children:e}),t&&(0,a.jsx)("a",{href:t.href,className:"text-xs font-medium underline shrink-0 hover:opacity-80",onClick:t.href.startsWith("#")?e=>{e.preventDefault(),document.getElementById(t.href.slice(1))?.scrollIntoView({behavior:"smooth"})}:void 0,children:t.label})]})}function k(e){return String(e||"").split("\n").map(e=>e.trim()).filter(Boolean)}function C(e){if(""===e||null==e)return null;let t=Number(e);return Number.isFinite(t)?t:null}function N({apiKey:e,isOpen:t,isSaving:s,onClose:n,onSave:r}){let[o,l]=(0,i.useState)(""),[d,c]=(0,i.useState)(!0),[u,m]=(0,i.useState)(""),[h,p]=(0,i.useState)(""),[y,b]=(0,i.useState)(""),[f,g]=(0,i.useState)(""),[v,j]=(0,i.useState)(""),[w,S]=(0,i.useState)("");return(0,i.useEffect)(()=>{t&&e&&(l(e.name||""),c(!1!==e.isActive),m((e.allowedModels||[]).join("\n")),p((e.allowedCombos||[]).join("\n")),b(function(e){if(!e)return"";let t=new Date(e);return Number.isNaN(t.getTime())?"":new Date(t.getTime()-6e4*t.getTimezoneOffset()).toISOString().slice(0,16)}(e.expiresAt)),g(e.rateLimitPerMinute??""),j(e.concurrencyLimit??""),S(e.spendLimitUsd??""))},[e,t]),(0,a.jsx)(x.aF,{isOpen:t,onClose:n,title:"Edit API Key Policy",size:"lg",children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)(x.pd,{label:"Key name",value:o,onChange:e=>l(e.target.value)}),(0,a.jsxs)("div",{className:"flex items-center justify-between rounded-lg border border-border p-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-sm font-medium",children:"Active"}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Paused keys cannot authenticate."})]}),(0,a.jsx)(x.lM,{checked:d,onChange:c})]}),(0,a.jsxs)("label",{className:"flex flex-col gap-1.5 text-sm font-medium",children:["Allowed model IDs",(0,a.jsx)("textarea",{className:"min-h-24 rounded-lg border border-border bg-surface-2 p-3 font-mono text-sm",value:u,onChange:e=>m(e.target.value),placeholder:"openai/gpt-5\\nanthropic/claude-sonnet"}),(0,a.jsx)("span",{className:"text-xs font-normal text-text-muted",children:"One exact model ID per line. Empty allows all targets."})]}),(0,a.jsxs)("label",{className:"flex flex-col gap-1.5 text-sm font-medium",children:["Allowed combo names",(0,a.jsx)("textarea",{className:"min-h-20 rounded-lg border border-border bg-surface-2 p-3 font-mono text-sm",value:h,onChange:e=>p(e.target.value),placeholder:"fast\\nquality"}),(0,a.jsx)("span",{className:"text-xs font-normal text-text-muted",children:"One exact combo name per line."})]}),(0,a.jsx)(x.pd,{label:"Expires at",type:"datetime-local",value:y,onChange:e=>b(e.target.value)}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:[(0,a.jsx)(x.pd,{label:"Requests / minute",type:"number",min:"1",step:"1",value:f,onChange:e=>g(e.target.value)}),(0,a.jsx)(x.pd,{label:"Concurrent requests",type:"number",min:"1",step:"1",value:v,onChange:e=>j(e.target.value)}),(0,a.jsx)(x.pd,{label:"Spend ceiling (USD)",type:"number",min:"0",step:"0.01",value:w,onChange:e=>S(e.target.value)})]}),(0,a.jsxs)("p",{className:"text-sm text-text-muted",children:["Current spend: ",(0,a.jsxs)("span",{className:"font-mono text-text-main",children:["$",Number(e?.spentUsd||0).toFixed(4)]})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(x.$n,{fullWidth:!0,loading:s,disabled:s||!o.trim(),onClick:()=>r({name:o,isActive:d,allowedModels:k(u),allowedCombos:k(h),expiresAt:y?new Date(y).toISOString():null,rateLimitPerMinute:C(f),concurrencyLimit:C(v),spendLimitUsd:C(w)}),children:"Save policy"}),(0,a.jsx)(x.$n,{fullWidth:!0,variant:"ghost",disabled:s,onClick:n,children:"Cancel"})]})]})})}v.propTypes={origin:r().string.isRequired,copied:r().string,onCopy:r().func.isRequired},N.propTypes={apiKey:r().object,isOpen:r().bool.isRequired,isSaving:r().bool.isRequired,onClose:r().func.isRequired,onSave:r().func.isRequired};let w=()=>["endpoint","keys"],S=()=>["endpoint","settings"];var A=s(48874),P=s(65921);function O({initialData:e}){let t=(0,o.jE)(),s=e?.machineId||"",n=(0,P.i)(e=>e.error),r=(0,l.I)({queryKey:w(),queryFn:async()=>{let e=async()=>(await (0,A.x)("/api/keys")).keys||[],t=await e();if(0===t.length){try{await (0,A.x)("/api/keys",{method:"POST",body:JSON.stringify({name:"Default Key",findOrCreate:!0})})}catch{}try{t=await e()}catch{}}return t},initialData:e?.keys||[]}),d=(0,l.I)({queryKey:S(),queryFn:()=>(0,A.x)("/api/settings"),initialData:e?.settings||{}}),c=r.data||[],u=d.data?.requireApiKey===!0,[m,h]=(0,i.useState)(!1),[f,g]=(0,i.useState)(""),[k,C]=(0,i.useState)(null),[I,R]=(0,i.useState)(null),[_,T]=(0,i.useState)(null),[E,M]=(0,i.useState)("/v1"),[K,L]=(0,i.useState)("http://127.0.0.1:20128");(0,i.useEffect)(()=>{M(`${window.location.origin}/v1`),L(window.location.origin)},[]);let{copied:$,copy:q}=(0,y.C)(),D=p({mutationFn:e=>(0,A.x)("/api/settings",{method:"PATCH",body:JSON.stringify({requireApiKey:e})}),onSuccess:()=>{t.invalidateQueries({queryKey:S()})},onError:()=>n("Failed to update API key requirement")}),F=p({mutationFn:e=>(0,A.x)("/api/keys",{method:"POST",body:JSON.stringify({name:e})}),onSuccess:e=>{C(e.key||null),g(""),h(!1),t.invalidateQueries({queryKey:w()})},onError:()=>n("Failed to create API key")}),U=p({mutationFn:e=>(0,A.x)(`/api/keys/${e}`,{method:"DELETE"}),onSuccess:()=>{t.invalidateQueries({queryKey:w()})},onError:()=>n("Failed to delete API key")}),H=p({mutationFn:({id:e,isActive:t})=>(0,A.x)(`/api/keys/${e}`,{method:"PUT",body:JSON.stringify({isActive:t})}),onSuccess:()=>{t.invalidateQueries({queryKey:w()})},onError:()=>n("Failed to toggle API key")}),G=p({mutationFn:({id:e,patch:t})=>(0,A.x)(`/api/keys/${e}`,{method:"PUT",body:JSON.stringify(t)}),onSuccess:()=>{T(null),t.invalidateQueries({queryKey:w()})},onError:()=>n("Failed to update API key policy")});return(0,a.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,a.jsxs)(x.Zp,{children:[(0,a.jsxs)("h2",{className:"text-lg font-semibold mb-4 flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-primary",children:"api"}),"API Endpoint"]}),(0,a.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Local OpenAI-compatible base URL for coding agents and SDKs. Switchboard is local-only — no tunnels or remote exposure."}),(0,a.jsx)(b,{label:"Local",url:E,copyId:"local_url",copied:$,onCopy:q}),s?(0,a.jsxs)("p",{className:"mt-3 text-xs text-text-muted font-mono",children:["Machine: ",s]}):null]}),(0,a.jsx)(v,{origin:K,copied:$,onCopy:q}),(0,a.jsxs)(x.Zp,{id:"require-api-key",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,a.jsxs)("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-primary",children:"vpn_key"}),"API Keys"]}),(0,a.jsx)(x.$n,{icon:"add",onClick:()=>h(!0),children:"Create Key"})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between pb-4 mb-4 border-b border-border",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"font-medium",children:"Require API key"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Requests without a valid key will be rejected"})]}),(0,a.jsx)(x.lM,{checked:u,onChange:()=>{u?R({title:"Disable API key protection?",message:"Any client that can reach this Switchboard endpoint will be able to use your provider accounts.",onConfirm:()=>{R(null),D.mutate(!1)}}):D.mutate(!0)},"aria-label":"Require API key"})]}),!u&&(0,a.jsx)("div",{className:"mb-4 -mt-2",children:(0,a.jsx)(j,{message:"API key is not required — any local client can call /v1."})}),0===c.length?(0,a.jsxs)("div",{className:"text-center py-12",children:[(0,a.jsx)("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-primary/10 text-primary mb-4",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[32px]",children:"vpn_key"})}),(0,a.jsx)("p",{className:"text-text-main font-medium mb-1",children:"No API keys yet"}),(0,a.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Create your first API key to get started"}),(0,a.jsx)(x.$n,{icon:"add",onClick:()=>h(!0),children:"Create Key"})]}):(0,a.jsx)("div",{className:"flex flex-col",children:c.map(e=>{let t=e.name?.trim()||e.id;return(0,a.jsxs)("div",{className:`group flex items-center justify-between py-3 border-b border-black/[0.03] dark:border-white/[0.03] last:border-b-0 ${!1===e.isActive?"opacity-60":""}`,children:[(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"text-sm font-medium",children:e.name}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2 mt-1",children:[(0,a.jsx)("code",{className:"text-xs text-text-muted font-mono",children:e.keyPrefix}),e.rotationRequired?(0,a.jsx)("span",{className:"rounded-full bg-orange-500/10 px-2 py-0.5 text-[11px] text-orange-600",title:"This legacy key remains usable through its compatibility verifier until you create a replacement.",children:"Rotation required"}):null,e.allowedModels?.length||e.allowedCombos?.length?(0,a.jsx)("span",{className:"rounded-full bg-primary/10 px-2 py-0.5 text-[11px] text-primary",children:"Restricted targets"}):(0,a.jsx)("span",{className:"rounded-full bg-black/5 px-2 py-0.5 text-[11px] text-text-muted dark:bg-white/5",children:"All targets"}),e.rateLimitPerMinute?(0,a.jsxs)("span",{className:"rounded-full bg-black/5 px-2 py-0.5 text-[11px] text-text-muted dark:bg-white/5",children:[e.rateLimitPerMinute,"/min"]}):null,e.concurrencyLimit?(0,a.jsxs)("span",{className:"rounded-full bg-black/5 px-2 py-0.5 text-[11px] text-text-muted dark:bg-white/5",children:[e.concurrencyLimit," concurrent"]}):null,null!=e.spendLimitUsd?(0,a.jsxs)("span",{className:"rounded-full bg-black/5 px-2 py-0.5 text-[11px] text-text-muted dark:bg-white/5",children:["$",Number(e.spentUsd||0).toFixed(2)," / $",Number(e.spendLimitUsd).toFixed(2)]}):null]}),(0,a.jsxs)("p",{className:"text-xs text-text-muted mt-1",children:["Created ",new Date(e.createdAt).toLocaleDateString()]}),!1===e.isActive&&(0,a.jsx)("p",{className:"text-xs text-orange-500 mt-1",children:"Paused"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(x.lM,{size:"sm",checked:e.isActive??!0,onChange:s=>{e.isActive&&!s?R({title:"Pause API Key",message:`Pause API key "${t}"?
|
|
15
15
|
|
|
16
|
-
This key will stop working immediately but can be resumed later.`,onConfirm:async()=>{R(null),H.mutate({id:e.id,isActive:s})}}):H.mutate({id:e.id,isActive:s})},title:e.isActive?"Pause key":"Resume key","aria-label":e.isActive?`Pause API key ${t}`:`Resume API key ${t}`}),(0,a.jsx)("button",{type:"button",onClick:()=>T(e),className:"p-2 hover:bg-primary/10 rounded text-text-muted hover:text-primary opacity-100 sm:opacity-0 sm:group-hover:opacity-100 transition-all",title:"Edit key policy","aria-label":`Edit API key ${t} policy`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"edit"})}),(0,a.jsx)("button",{type:"button",onClick:()=>R({title:"Delete API Key",message:`Delete API key "${t}"?`,onConfirm:async()=>{R(null),U.mutate(e.id)}}),className:"p-2 hover:bg-red-500/10 rounded text-red-500 opacity-100 sm:opacity-0 sm:group-hover:opacity-100 transition-all","aria-label":`Delete API key ${t}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"delete"})})]})]},e.id)})})]}),(0,a.jsx)(x.aF,{isOpen:m,title:"Create API Key",onClose:()=>{h(!1),g("")},children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)(x.pd,{label:"Key Name",value:f,onChange:e=>g(e.target.value),placeholder:"Production Key"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(x.$n,{onClick:()=>F.mutate(f.trim()),fullWidth:!0,disabled:!f.trim()||F.isPending,loading:F.isPending,children:"Create"}),(0,a.jsx)(x.$n,{onClick:()=>{h(!1),g("")},variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}),(0,a.jsx)(x.aF,{isOpen:!!k,title:"API Key Created",onClose:()=>C(null),children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-4",children:[(0,a.jsx)("p",{className:"text-sm text-yellow-800 dark:text-yellow-200 mb-2 font-medium",children:"Save this key now!"}),(0,a.jsx)("p",{className:"text-sm text-yellow-700 dark:text-yellow-300",children:"This is the only time you will see this key. Store it securely."})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(x.pd,{value:k||"",readOnly:!0,className:"flex-1 font-mono text-sm"}),(0,a.jsx)(x.$n,{variant:"secondary",icon:"created_key"===$?"check":"content_copy",onClick:()=>q(k,"created_key"),children:"created_key"===$?"Copied!":"Copy"})]}),(0,a.jsx)(x.$n,{onClick:()=>C(null),fullWidth:!0,children:"Done"})]})}),(0,a.jsx)(N,{apiKey:_,isOpen:!!_,isSaving:G.isPending,onClose:()=>T(null),onSave:e=>G.mutate({id:_.id,patch:e})}),(0,a.jsx)(x.uo,{isOpen:!!I,onClose:()=>R(null),onConfirm:I?.onConfirm,title:I?.title||"Confirm",message:I?.message,variant:"danger"})]})}O.propTypes={initialData:r().shape({machineId:r().string,keys:r().array,settings:r().object}).isRequired}}},e=>{e.O(0,[2574,3862,782,8500,594,1321,
|
|
16
|
+
This key will stop working immediately but can be resumed later.`,onConfirm:async()=>{R(null),H.mutate({id:e.id,isActive:s})}}):H.mutate({id:e.id,isActive:s})},title:e.isActive?"Pause key":"Resume key","aria-label":e.isActive?`Pause API key ${t}`:`Resume API key ${t}`}),(0,a.jsx)("button",{type:"button",onClick:()=>T(e),className:"p-2 hover:bg-primary/10 rounded text-text-muted hover:text-primary opacity-100 sm:opacity-0 sm:group-hover:opacity-100 transition-all",title:"Edit key policy","aria-label":`Edit API key ${t} policy`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"edit"})}),(0,a.jsx)("button",{type:"button",onClick:()=>R({title:"Delete API Key",message:`Delete API key "${t}"?`,onConfirm:async()=>{R(null),U.mutate(e.id)}}),className:"p-2 hover:bg-red-500/10 rounded text-red-500 opacity-100 sm:opacity-0 sm:group-hover:opacity-100 transition-all","aria-label":`Delete API key ${t}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"delete"})})]})]},e.id)})})]}),(0,a.jsx)(x.aF,{isOpen:m,title:"Create API Key",onClose:()=>{h(!1),g("")},children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)(x.pd,{label:"Key Name",value:f,onChange:e=>g(e.target.value),placeholder:"Production Key"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(x.$n,{onClick:()=>F.mutate(f.trim()),fullWidth:!0,disabled:!f.trim()||F.isPending,loading:F.isPending,children:"Create"}),(0,a.jsx)(x.$n,{onClick:()=>{h(!1),g("")},variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}),(0,a.jsx)(x.aF,{isOpen:!!k,title:"API Key Created",onClose:()=>C(null),children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-4",children:[(0,a.jsx)("p",{className:"text-sm text-yellow-800 dark:text-yellow-200 mb-2 font-medium",children:"Save this key now!"}),(0,a.jsx)("p",{className:"text-sm text-yellow-700 dark:text-yellow-300",children:"This is the only time you will see this key. Store it securely."})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(x.pd,{value:k||"",readOnly:!0,className:"flex-1 font-mono text-sm"}),(0,a.jsx)(x.$n,{variant:"secondary",icon:"created_key"===$?"check":"content_copy",onClick:()=>q(k,"created_key"),children:"created_key"===$?"Copied!":"Copy"})]}),(0,a.jsx)(x.$n,{onClick:()=>C(null),fullWidth:!0,children:"Done"})]})}),(0,a.jsx)(N,{apiKey:_,isOpen:!!_,isSaving:G.isPending,onClose:()=>T(null),onSave:e=>G.mutate({id:_.id,patch:e})}),(0,a.jsx)(x.uo,{isOpen:!!I,onClose:()=>R(null),onConfirm:I?.onConfirm,title:I?.title||"Confirm",message:I?.message,variant:"danger"})]})}O.propTypes={initialData:r().shape({machineId:r().string,keys:r().array,settings:r().object}).isRequired}}},e=>{e.O(0,[2574,3862,782,8500,594,4601,1321,1330,8441,3794,7358],()=>e(e.s=53427)),_N_E=e.O()}]);
|
|
@@ -56,4 +56,4 @@
|
|
|
56
56
|
-F "temperature=${k}"`:""}${p.includes("prompt")&&g?` \\
|
|
57
57
|
-F "prompt=${g}"`:""}`,V=async()=>{if(!x||!z||!S.trim())return;M(!0),L(""),A(null);let e=Date.now();try{let t=new FormData;t.append("file",x),t.append("model",z),p.includes("language")&&f&&t.append("language",f),p.includes("response_format")&&t.append("response_format",w),p.includes("temperature")&&k&&t.append("temperature",k),p.includes("prompt")&&g&&t.append("prompt",g);let a={};S&&(a.Authorization=`Bearer ${S}`);let s=await fetch("/api/v1/audio/transcriptions",{method:"POST",headers:a,body:t});I(Date.now()-e);let r=(s.headers.get("content-type")||"").includes("application/json")?await s.json():await s.text();if(!s.ok){let e=r?.error?.message||r?.error||r;L("string"==typeof e&&e?e:`HTTP ${s.status}`);return}A(r)}catch(e){L(e.message||"Network error")}finally{M(!1)}},H="string"==typeof T?T:T?JSON.stringify(T,null,2):`{
|
|
58
58
|
"text": "Hello world..."
|
|
59
|
-
}`;return(0,s.jsxs)(n.Zp,{children:[(0,s.jsx)("h2",{className:"text-lg font-semibold mb-4",children:"Example"}),(0,s.jsxs)("div",{className:"flex flex-col gap-2.5",children:[o.length>0?(0,s.jsx)($,{label:"Model",htmlFor:"stt-example-model",children:(0,s.jsx)("select",{id:"stt-example-model",value:d,onChange:e=>m(e.target.value),className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:o.map(e=>(0,s.jsx)("option",{value:e.id,children:e.name||e.id},e.id))})}):(0,s.jsx)($,{label:"Model",htmlFor:"stt-example-model",children:(0,s.jsx)("input",{id:"stt-example-model",value:d,onChange:e=>m(e.target.value),placeholder:"Enter model id",className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary font-mono"})}),(0,s.jsx)($,{label:"Endpoint",children:(0,s.jsx)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center",children:(0,s.jsxs)("span",{className:"w-full min-w-0 flex-1 px-3 py-1.5 text-sm font-mono text-text-main bg-sidebar rounded-lg truncate",children:[E,"/v1/audio/transcriptions"]})})}),(0,s.jsx)($,{label:"API Key",htmlFor:"stt-example-key",children:(0,s.jsx)("input",{id:"stt-example-key",type:"password",autoComplete:"off",value:S,onChange:e=>F(e.target.value),placeholder:"Paste a Switchboard client key secret (sk-...)",className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary font-mono"})}),(0,s.jsx)($,{label:"Audio File",htmlFor:"stt-example-audio",children:(0,s.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,s.jsx)("input",{id:"stt-example-audio",type:"file",accept:"audio/*,video/mp4,.m4a,.mp3,.wav,.ogg,.flac,.webm,.opus",onChange:e=>h(e.target.files?.[0]||null),className:"w-full text-xs text-text-muted file:mr-2 file:py-1 file:px-2.5 file:rounded-lg file:border file:border-border file:bg-background file:text-text-main hover:file:bg-sidebar file:cursor-pointer"}),x&&(0,s.jsxs)("span",{className:"text-xs text-text-muted font-mono",children:[x.name," \xb7 ",(x.size/1024).toFixed(1)," KB"]})]})}),p.includes("language")&&(0,s.jsx)($,{label:"Language",htmlFor:"stt-example-language",children:(0,s.jsx)("input",{id:"stt-example-language",value:f,onChange:e=>b(e.target.value),placeholder:"e.g. en, vi, ja (auto-detect if empty)",className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary font-mono"})}),p.includes("prompt")&&(0,s.jsx)($,{label:"Prompt",htmlFor:"stt-example-prompt",children:(0,s.jsx)("input",{id:"stt-example-prompt",value:g,onChange:e=>y(e.target.value),placeholder:"optional context to improve accuracy",className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})}),p.includes("temperature")&&(0,s.jsx)($,{label:"Temperature",htmlFor:"stt-example-temperature",children:(0,s.jsx)("input",{id:"stt-example-temperature",type:"number",step:"0.1",min:"0",max:"1",value:k,onChange:e=>C(e.target.value),placeholder:"0 - 1 (default 0)",className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})}),p.includes("response_format")&&(0,s.jsx)($,{label:"Response Format",htmlFor:"stt-example-format",children:(0,s.jsxs)("select",{id:"stt-example-format",value:w,onChange:e=>N(e.target.value),className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:[(0,s.jsx)("option",{value:"json",children:"json"}),(0,s.jsx)("option",{value:"text",children:"text"}),(0,s.jsx)("option",{value:"srt",children:"srt"}),(0,s.jsx)("option",{value:"verbose_json",children:"verbose_json"}),(0,s.jsx)("option",{value:"vtt",children:"vtt"})]})}),(0,s.jsxs)("div",{className:"mt-1",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between mb-1.5",children:[(0,s.jsx)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:"Request"}),(0,s.jsxs)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center",children:[(0,s.jsxs)("button",{onClick:()=>D(J),className:"inline-flex items-center gap-1 text-xs text-text-muted hover:text-primary transition-colors",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:K?"check":"content_copy"}),K?"Copied":"Copy"]}),(0,s.jsxs)("button",{onClick:V,disabled:_||!x||!z||!S.trim(),className:"flex w-full sm:w-auto items-center justify-center gap-1.5 px-3 py-1 rounded-lg bg-primary text-on-primary text-xs font-medium hover:bg-primary/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",style:_?{animation:"spin 1s linear infinite"}:void 0,children:"play_arrow"}),_?"Transcribing...":"Run"]})]})]}),(0,s.jsx)("pre",{className:"bg-sidebar rounded-lg px-3 py-2.5 text-xs font-mono text-text-main overflow-x-auto whitespace-pre-wrap break-all",children:J})]}),O&&(0,s.jsx)("p",{role:"alert",className:"text-xs text-red-500 break-words",children:O}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between mb-1.5",children:[(0,s.jsxs)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:["Response ",T&&P&&(0,s.jsxs)("span",{className:"font-normal normal-case",children:["⚡ ",P,"ms"]})]}),T&&(0,s.jsxs)("button",{onClick:()=>q(H),className:"inline-flex items-center gap-1 text-xs text-text-muted hover:text-primary transition-colors",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:U?"check":"content_copy"}),U?"Copied":"Copy"]})]}),(0,s.jsx)("pre",{className:"bg-sidebar rounded-lg px-3 py-2.5 text-xs font-mono text-text-main overflow-x-auto whitespace-pre-wrap break-all opacity-70",children:H})]})]})]})}var D=a(77251);function U(){let{kind:e,id:t}=(0,r.useParams)(),a=(0,r.useRouter)(),l=c.rj.find(t=>t.id===e),m=(0,c.gC)(t)&&"embedding"===e,u=async()=>{if(await (0,D.l)({message:"Delete this Custom Embedding node?",confirmText:"Continue"}))try{await (0,N.x)(`/api/provider-nodes/${encodeURIComponent(t)}`,{method:"DELETE"}),a.push(`/dashboard/media-providers/${e}`)}catch(e){(0,w.s)("Error deleting custom embedding node:",e)}},[p,x]=(0,i.useState)(null),[h,f]=(0,i.useState)(m),[b,g]=(0,i.useState)(!1),[v,j]=(0,i.useState)(!1);if((0,i.useEffect)(()=>{if(!m)return;let e=!1;return x(null),f(!0),g(!1),fetch("/api/provider-nodes",{cache:"no-store"}).then(async e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(a=>{e||(x((a.nodes||[]).find(e=>e.id===t)||null),f(!1))}).catch(()=>{e||(f(!1),g(!0))}),()=>{e=!0}},[t,m]),!l)return(0,r.notFound)();let k=c.Q2[t],C=m?p?{id:t,name:p.name||"Custom Embedding",color:"#6366F1",textIcon:"CE"}:null:k;if(!m&&!k)return(0,r.notFound)();if(m&&b)return(0,s.jsx)("div",{role:"alert",className:"text-text-muted text-sm py-12 text-center",children:"Couldn't load this provider node. Check the server and retry."});if(m&&!h&&!p)return(0,r.notFound)();if(m&&h)return(0,s.jsx)("div",{className:"text-text-muted text-sm py-12 text-center",children:"Loading..."});let $=m?["embedding"]:C.serviceKinds??["llm"];return m||$.includes(e)?(0,s.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)(o(),{href:`/dashboard/media-providers/${e}`,className:"inline-flex items-center gap-1 text-sm text-text-muted hover:text-primary transition-colors mb-4",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-lg",children:"arrow_back"}),l.label]}),(0,s.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:gap-4",children:[(0,s.jsx)("div",{className:"size-12 rounded-lg flex items-center justify-center shrink-0",style:{backgroundColor:`${C.color}15`},children:(0,s.jsx)(d.A,{src:`/providers/${C.id}.png`,alt:C.name,size:48,className:"object-contain rounded-lg max-w-[48px] max-h-[48px]",fallbackText:C.textIcon||C.id.slice(0,2).toUpperCase(),fallbackColor:C.color})}),(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3",children:[(0,s.jsx)("h1",{className:"text-3xl font-semibold tracking-tight",children:C.name}),!m&&C.notice?.apiKeyUrl&&(0,s.jsxs)("a",{href:C.notice.apiKeyUrl,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline inline-flex items-center gap-1",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:"open_in_new"}),"Get API Key"]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-1.5 mt-1 flex-wrap",children:[m&&(0,s.jsxs)(n.Ex,{variant:"default",size:"sm",children:["Custom \xb7 ",p?.prefix]}),$.map(t=>(0,s.jsx)(n.Ex,{variant:t===e?"primary":"default",size:"sm",children:t.toUpperCase()},t))]})]}),m&&(0,s.jsxs)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center",children:[(0,s.jsx)(n.$n,{size:"sm",variant:"secondary",icon:"edit",onClick:()=>j(!0),children:"Edit"}),(0,s.jsx)(n.$n,{size:"sm",variant:"secondary",icon:"delete",onClick:u,children:"Delete"})]})]})]}),!m&&C.kindNotice?.[e]&&(0,s.jsxs)("div",{className:"flex items-start gap-3 px-4 py-3 rounded-lg bg-amber-500/10 border border-amber-500/30 text-amber-700 dark:text-amber-400",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[20px] mt-0.5",children:"warning"}),(0,s.jsx)("p",{className:"text-sm",children:C.kindNotice[e]})]}),!m&&C.notice?.text&&!C.deprecated&&(0,s.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,s.jsx)("span",{className:"material-symbols-outlined text-[16px] text-blue-500 shrink-0",children:"info"}),(0,s.jsx)("p",{className:"min-w-0 flex-1 text-xs leading-relaxed text-blue-600 dark:text-blue-400",children:C.notice.text}),C.notice.apiKeyUrl&&(0,s.jsx)("a",{href:C.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 →"})]}),!m&&C.noAuth?(0,s.jsx)(n.gw,{providerId:t}):(0,s.jsx)(y,{providerId:t,isOAuth:!1}),"tts"!==e&&"webSearch"!==e&&"webFetch"!==e&&(0,s.jsx)(S,{providerId:t,kindFilter:e,providerAliasOverride:m?p?.prefix:void 0}),!m&&(C.searchConfig||C.fetchConfig||C.ttsConfig||C.sttConfig||C.embeddingConfig||C.searchViaChat)&&(0,s.jsx)(n.Wx,{config:"webFetch"===e?C.fetchConfig:"tts"===e?C.ttsConfig:"stt"===e?C.sttConfig:"embedding"===e?C.embeddingConfig:C.searchConfig||{mode:"chat-completions",defaultModel:C.searchViaChat?.defaultModel,pricingUrl:C.searchViaChat?.pricingUrl,freeTier:C.searchViaChat?.freeTier},provider:C,title:`${l.label} Config`}),"embedding"===e&&(0,s.jsx)(R,{providerId:t,customAlias:p?.prefix}),"tts"===e&&(0,s.jsx)(_,{providerId:t}),"stt"===e&&!m&&(0,s.jsx)(B,{providerId:t}),!m&&F[e]&&(0,s.jsx)(K,{providerId:t,kind:e}),m&&(0,s.jsx)(n.x0,{isOpen:v,node:p,onClose:()=>j(!1),onSaved:e=>{x(e),j(!1)}})]}):(0,r.notFound)()}},48874:(e,t,a)=>{"use strict";async function s(e,t){let a=await fetch(e,{...t,headers:{"Content-Type":"application/json",...t?.headers||{}},credentials:"same-origin"}),s=null;try{s=await a.json()}catch{s=null}if(!a.ok){let e=s&&(s.error||s.message)||`Request failed (${a.status})`,t=Error("string"==typeof e?e:"Request failed");throw t.status=a.status,t.data=s,t}return s}a.d(t,{x:()=>s})},53578:(e,t,a)=>{"use strict";a.d(t,{T:()=>l});let s=Symbol("delete-provider-strategy"),r=Promise.resolve();async function l(e,t,a=fetch){let s=r.then(()=>o(e,t,a));return r=s.catch(()=>{}),s}async function o(e,t,a){let r=await a("/api/settings",{cache:"no-store"});if(!r.ok)throw Error(`Failed to load settings (${r.status})`);let l=(await r.json()).providerStrategies||{},o=l[e]||{},i=t(o);if(void 0===i)return console.warn(`[patchProviderStrategy] updater for "${e}" returned undefined; keeping previous entry`),o;let n={...l};i===s?delete n[e]:i&&Object.keys(i).length>0?n[e]=i:delete n[e];let d=await a("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerStrategies:n})});if(!d.ok)throw Error(`Failed to save settings (${d.status})`);return i===s?void 0:i}},70217:(e,t,a)=>{"use strict";function s(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":s(t)?"error":"default"}a.d(t,{g:()=>r,t:()=>s})}},e=>{e.O(0,[2574,3862,782,8500,594,1321,4707,1330,8441,3794,7358],()=>e(e.s=17845)),_N_E=e.O()}]);
|
|
59
|
+
}`;return(0,s.jsxs)(n.Zp,{children:[(0,s.jsx)("h2",{className:"text-lg font-semibold mb-4",children:"Example"}),(0,s.jsxs)("div",{className:"flex flex-col gap-2.5",children:[o.length>0?(0,s.jsx)($,{label:"Model",htmlFor:"stt-example-model",children:(0,s.jsx)("select",{id:"stt-example-model",value:d,onChange:e=>m(e.target.value),className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:o.map(e=>(0,s.jsx)("option",{value:e.id,children:e.name||e.id},e.id))})}):(0,s.jsx)($,{label:"Model",htmlFor:"stt-example-model",children:(0,s.jsx)("input",{id:"stt-example-model",value:d,onChange:e=>m(e.target.value),placeholder:"Enter model id",className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary font-mono"})}),(0,s.jsx)($,{label:"Endpoint",children:(0,s.jsx)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center",children:(0,s.jsxs)("span",{className:"w-full min-w-0 flex-1 px-3 py-1.5 text-sm font-mono text-text-main bg-sidebar rounded-lg truncate",children:[E,"/v1/audio/transcriptions"]})})}),(0,s.jsx)($,{label:"API Key",htmlFor:"stt-example-key",children:(0,s.jsx)("input",{id:"stt-example-key",type:"password",autoComplete:"off",value:S,onChange:e=>F(e.target.value),placeholder:"Paste a Switchboard client key secret (sk-...)",className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary font-mono"})}),(0,s.jsx)($,{label:"Audio File",htmlFor:"stt-example-audio",children:(0,s.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,s.jsx)("input",{id:"stt-example-audio",type:"file",accept:"audio/*,video/mp4,.m4a,.mp3,.wav,.ogg,.flac,.webm,.opus",onChange:e=>h(e.target.files?.[0]||null),className:"w-full text-xs text-text-muted file:mr-2 file:py-1 file:px-2.5 file:rounded-lg file:border file:border-border file:bg-background file:text-text-main hover:file:bg-sidebar file:cursor-pointer"}),x&&(0,s.jsxs)("span",{className:"text-xs text-text-muted font-mono",children:[x.name," \xb7 ",(x.size/1024).toFixed(1)," KB"]})]})}),p.includes("language")&&(0,s.jsx)($,{label:"Language",htmlFor:"stt-example-language",children:(0,s.jsx)("input",{id:"stt-example-language",value:f,onChange:e=>b(e.target.value),placeholder:"e.g. en, vi, ja (auto-detect if empty)",className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary font-mono"})}),p.includes("prompt")&&(0,s.jsx)($,{label:"Prompt",htmlFor:"stt-example-prompt",children:(0,s.jsx)("input",{id:"stt-example-prompt",value:g,onChange:e=>y(e.target.value),placeholder:"optional context to improve accuracy",className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})}),p.includes("temperature")&&(0,s.jsx)($,{label:"Temperature",htmlFor:"stt-example-temperature",children:(0,s.jsx)("input",{id:"stt-example-temperature",type:"number",step:"0.1",min:"0",max:"1",value:k,onChange:e=>C(e.target.value),placeholder:"0 - 1 (default 0)",className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})}),p.includes("response_format")&&(0,s.jsx)($,{label:"Response Format",htmlFor:"stt-example-format",children:(0,s.jsxs)("select",{id:"stt-example-format",value:w,onChange:e=>N(e.target.value),className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:[(0,s.jsx)("option",{value:"json",children:"json"}),(0,s.jsx)("option",{value:"text",children:"text"}),(0,s.jsx)("option",{value:"srt",children:"srt"}),(0,s.jsx)("option",{value:"verbose_json",children:"verbose_json"}),(0,s.jsx)("option",{value:"vtt",children:"vtt"})]})}),(0,s.jsxs)("div",{className:"mt-1",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between mb-1.5",children:[(0,s.jsx)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:"Request"}),(0,s.jsxs)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center",children:[(0,s.jsxs)("button",{onClick:()=>D(J),className:"inline-flex items-center gap-1 text-xs text-text-muted hover:text-primary transition-colors",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:K?"check":"content_copy"}),K?"Copied":"Copy"]}),(0,s.jsxs)("button",{onClick:V,disabled:_||!x||!z||!S.trim(),className:"flex w-full sm:w-auto items-center justify-center gap-1.5 px-3 py-1 rounded-lg bg-primary text-on-primary text-xs font-medium hover:bg-primary/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",style:_?{animation:"spin 1s linear infinite"}:void 0,children:"play_arrow"}),_?"Transcribing...":"Run"]})]})]}),(0,s.jsx)("pre",{className:"bg-sidebar rounded-lg px-3 py-2.5 text-xs font-mono text-text-main overflow-x-auto whitespace-pre-wrap break-all",children:J})]}),O&&(0,s.jsx)("p",{role:"alert",className:"text-xs text-red-500 break-words",children:O}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between mb-1.5",children:[(0,s.jsxs)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:["Response ",T&&P&&(0,s.jsxs)("span",{className:"font-normal normal-case",children:["⚡ ",P,"ms"]})]}),T&&(0,s.jsxs)("button",{onClick:()=>q(H),className:"inline-flex items-center gap-1 text-xs text-text-muted hover:text-primary transition-colors",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:U?"check":"content_copy"}),U?"Copied":"Copy"]})]}),(0,s.jsx)("pre",{className:"bg-sidebar rounded-lg px-3 py-2.5 text-xs font-mono text-text-main overflow-x-auto whitespace-pre-wrap break-all opacity-70",children:H})]})]})]})}var D=a(77251);function U(){let{kind:e,id:t}=(0,r.useParams)(),a=(0,r.useRouter)(),l=c.rj.find(t=>t.id===e),m=(0,c.gC)(t)&&"embedding"===e,u=async()=>{if(await (0,D.l)({message:"Delete this Custom Embedding node?",confirmText:"Continue"}))try{await (0,N.x)(`/api/provider-nodes/${encodeURIComponent(t)}`,{method:"DELETE"}),a.push(`/dashboard/media-providers/${e}`)}catch(e){(0,w.s)("Error deleting custom embedding node:",e)}},[p,x]=(0,i.useState)(null),[h,f]=(0,i.useState)(m),[b,g]=(0,i.useState)(!1),[v,j]=(0,i.useState)(!1);if((0,i.useEffect)(()=>{if(!m)return;let e=!1;return x(null),f(!0),g(!1),fetch("/api/provider-nodes",{cache:"no-store"}).then(async e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(a=>{e||(x((a.nodes||[]).find(e=>e.id===t)||null),f(!1))}).catch(()=>{e||(f(!1),g(!0))}),()=>{e=!0}},[t,m]),!l)return(0,r.notFound)();let k=c.Q2[t],C=m?p?{id:t,name:p.name||"Custom Embedding",color:"#6366F1",textIcon:"CE"}:null:k;if(!m&&!k)return(0,r.notFound)();if(m&&b)return(0,s.jsx)("div",{role:"alert",className:"text-text-muted text-sm py-12 text-center",children:"Couldn't load this provider node. Check the server and retry."});if(m&&!h&&!p)return(0,r.notFound)();if(m&&h)return(0,s.jsx)("div",{className:"text-text-muted text-sm py-12 text-center",children:"Loading..."});let $=m?["embedding"]:C.serviceKinds??["llm"];return m||$.includes(e)?(0,s.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)(o(),{href:`/dashboard/media-providers/${e}`,className:"inline-flex items-center gap-1 text-sm text-text-muted hover:text-primary transition-colors mb-4",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-lg",children:"arrow_back"}),l.label]}),(0,s.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:gap-4",children:[(0,s.jsx)("div",{className:"size-12 rounded-lg flex items-center justify-center shrink-0",style:{backgroundColor:`${C.color}15`},children:(0,s.jsx)(d.A,{src:`/providers/${C.id}.png`,alt:C.name,size:48,className:"object-contain rounded-lg max-w-[48px] max-h-[48px]",fallbackText:C.textIcon||C.id.slice(0,2).toUpperCase(),fallbackColor:C.color})}),(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3",children:[(0,s.jsx)("h1",{className:"text-3xl font-semibold tracking-tight",children:C.name}),!m&&C.notice?.apiKeyUrl&&(0,s.jsxs)("a",{href:C.notice.apiKeyUrl,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline inline-flex items-center gap-1",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:"open_in_new"}),"Get API Key"]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-1.5 mt-1 flex-wrap",children:[m&&(0,s.jsxs)(n.Ex,{variant:"default",size:"sm",children:["Custom \xb7 ",p?.prefix]}),$.map(t=>(0,s.jsx)(n.Ex,{variant:t===e?"primary":"default",size:"sm",children:t.toUpperCase()},t))]})]}),m&&(0,s.jsxs)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center",children:[(0,s.jsx)(n.$n,{size:"sm",variant:"secondary",icon:"edit",onClick:()=>j(!0),children:"Edit"}),(0,s.jsx)(n.$n,{size:"sm",variant:"secondary",icon:"delete",onClick:u,children:"Delete"})]})]})]}),!m&&C.kindNotice?.[e]&&(0,s.jsxs)("div",{className:"flex items-start gap-3 px-4 py-3 rounded-lg bg-amber-500/10 border border-amber-500/30 text-amber-700 dark:text-amber-400",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[20px] mt-0.5",children:"warning"}),(0,s.jsx)("p",{className:"text-sm",children:C.kindNotice[e]})]}),!m&&C.notice?.text&&!C.deprecated&&(0,s.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,s.jsx)("span",{className:"material-symbols-outlined text-[16px] text-blue-500 shrink-0",children:"info"}),(0,s.jsx)("p",{className:"min-w-0 flex-1 text-xs leading-relaxed text-blue-600 dark:text-blue-400",children:C.notice.text}),C.notice.apiKeyUrl&&(0,s.jsx)("a",{href:C.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 →"})]}),!m&&C.noAuth?(0,s.jsx)(n.gw,{providerId:t}):(0,s.jsx)(y,{providerId:t,isOAuth:!1}),"tts"!==e&&"webSearch"!==e&&"webFetch"!==e&&(0,s.jsx)(S,{providerId:t,kindFilter:e,providerAliasOverride:m?p?.prefix:void 0}),!m&&(C.searchConfig||C.fetchConfig||C.ttsConfig||C.sttConfig||C.embeddingConfig||C.searchViaChat)&&(0,s.jsx)(n.Wx,{config:"webFetch"===e?C.fetchConfig:"tts"===e?C.ttsConfig:"stt"===e?C.sttConfig:"embedding"===e?C.embeddingConfig:C.searchConfig||{mode:"chat-completions",defaultModel:C.searchViaChat?.defaultModel,pricingUrl:C.searchViaChat?.pricingUrl,freeTier:C.searchViaChat?.freeTier},provider:C,title:`${l.label} Config`}),"embedding"===e&&(0,s.jsx)(R,{providerId:t,customAlias:p?.prefix}),"tts"===e&&(0,s.jsx)(_,{providerId:t}),"stt"===e&&!m&&(0,s.jsx)(B,{providerId:t}),!m&&F[e]&&(0,s.jsx)(K,{providerId:t,kind:e}),m&&(0,s.jsx)(n.x0,{isOpen:v,node:p,onClose:()=>j(!1),onSaved:e=>{x(e),j(!1)}})]}):(0,r.notFound)()}},48874:(e,t,a)=>{"use strict";async function s(e,t){let a=await fetch(e,{...t,headers:{"Content-Type":"application/json",...t?.headers||{}},credentials:"same-origin"}),s=null;try{s=await a.json()}catch{s=null}if(!a.ok){let e=s&&(s.error||s.message)||`Request failed (${a.status})`,t=Error("string"==typeof e?e:"Request failed");throw t.status=a.status,t.data=s,t}return s}a.d(t,{x:()=>s})},53578:(e,t,a)=>{"use strict";a.d(t,{T:()=>l});let s=Symbol("delete-provider-strategy"),r=Promise.resolve();async function l(e,t,a=fetch){let s=r.then(()=>o(e,t,a));return r=s.catch(()=>{}),s}async function o(e,t,a){let r=await a("/api/settings",{cache:"no-store"});if(!r.ok)throw Error(`Failed to load settings (${r.status})`);let l=(await r.json()).providerStrategies||{},o=l[e]||{},i=t(o);if(void 0===i)return console.warn(`[patchProviderStrategy] updater for "${e}" returned undefined; keeping previous entry`),o;let n={...l};i===s?delete n[e]:i&&Object.keys(i).length>0?n[e]=i:delete n[e];let d=await a("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerStrategies:n})});if(!d.ok)throw Error(`Failed to save settings (${d.status})`);return i===s?void 0:i}},70217:(e,t,a)=>{"use strict";function s(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":s(t)?"error":"default"}a.d(t,{g:()=>r,t:()=>s})}},e=>{e.O(0,[2574,3862,782,8500,594,4601,1321,1330,8441,3794,7358],()=>e(e.s=17845)),_N_E=e.O()}]);
|