switchboard-router 0.9.2 → 0.9.3
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-4de88db4bd94a23c.js → 1321-6bd6f91d24e9863e.js} +1 -1
- package/app/.next/static/chunks/1330-56405eca78b12fee.js +7 -0
- package/app/{.next-cli-build/static/chunks/3531-936a1e7912d9876c.js → .next/static/chunks/3531-eb5d385c954b3765.js} +7 -7
- package/app/.next/static/chunks/app/(dashboard)/dashboard/agent-library/page-cf3bc192f7a27304.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/basic-chat/page-0e1d54e59ac767a1.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/cli-tools/[toolId]/{page-d7205b7328b3fed1.js → page-af0d85c06970853b.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/cli-tools/{page-d0b6efe01e687aec.js → page-2cfc2352bc42d9b8.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/combos/page-62cd36ee99eaa630.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/combos/routing/page-0b02e9a2f1cc6e43.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/console-log/page-ded6ec41e583b3b3.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/endpoint/page-ca47b09e6ed6ae7b.js +16 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/[id]/{page-772f246688672d59.js → page-78d098f14f8cff05.js} +8 -8
- package/app/.next/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/page-d1654fba27199492.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/media-providers/combo/[id]/{page-8554ba79c854167f.js → page-ff13a39fb7744f5e.js} +3 -3
- package/app/.next/static/chunks/app/(dashboard)/dashboard/media-providers/page-919f3eec8dfc9b6e.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/media-providers/web/page-db19da41661d630b.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/mitm/{page-8779ff2bc755ba78.js → page-309b09a142a2995d.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/page-86cd6523dcd61f1b.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/profile/{page-d32871b974f7e72f.js → page-ae6cf9ce7ac84eb7.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/[id]/{page-d8610d9b77a2cae4.js → page-97e0f7067cab0724.js} +3 -3
- package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/new/page-413b59dd764a1563.js +1 -0
- package/app/{.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/page-555f079cdf31bbf6.js → .next/static/chunks/app/(dashboard)/dashboard/providers/page-31212a5a4a9825b0.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/pxpipe/page-1805f993834a1adb.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/quota/page-798a65a8c4d2708a.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/skills/[id]/page-aba614778bfe50ad.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/skills/page-b1e9603ce7be0155.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/token-saver/page-1711a424a8dcad0e.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/translator/page-0c7b901caf8614b9.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/dashboard/usage/page-b085086e6c5b9387.js +1 -0
- package/app/.next/static/chunks/app/(dashboard)/{layout-62b4e2cdf745f8d0.js → layout-59baac68c7aedd25.js} +1 -1
- package/app/.next/static/css/c5928b380ef8a163.css +1 -0
- package/app/.next-cli-build/BUILD_ID +1 -1
- package/app/.next-cli-build/app-path-routes-manifest.json +6 -6
- 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 +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 +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_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/routing/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/routing/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page.js +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 +15 -2
- 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 +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 +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 +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 +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 +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_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/page.js +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 +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page.js +2 -2
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page.js +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 +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 +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 +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 +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 +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 +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 +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 +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_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_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 +4 -4
- package/app/.next-cli-build/server/app/_not-found.segments/_full.segment.rsc +4 -4
- package/app/.next-cli-build/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +4 -4
- package/app/.next-cli-build/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- 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/all-statuses/route.js +5 -5
- 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/cline-settings/route.js +2 -2
- 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/cowork-mcp-registry/route.js +2 -2
- 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-settings/route.js +2 -2
- 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/droid-settings/route.js +2 -2
- 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/grok-settings/route.js +3 -3
- package/app/.next-cli-build/server/app/api/cli-tools/hermes-settings/route.js +3 -3
- 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/kilo-settings/route.js +2 -2
- 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/opencode-settings/route.js +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/pi-settings/route.js +1 -1
- package/app/.next-cli-build/server/app/api/v1/messages/route.js +1 -1
- package/app/.next-cli-build/server/app/api/v1/models/[kind]/route.js +1 -1
- package/app/.next-cli-build/server/app/api/v1/models/info/route.js +1 -1
- package/app/.next-cli-build/server/app/api/v1/models/route.js +1 -1
- package/app/.next-cli-build/server/app/api/v1/route.js +1 -1
- package/app/.next-cli-build/server/app/api/v1beta/models/route.js +1 -1
- package/app/.next-cli-build/server/app/api/version/route.js +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 +4 -4
- package/app/.next-cli-build/server/app/callback.segments/_full.segment.rsc +4 -4
- package/app/.next-cli-build/server/app/callback.segments/_tree.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/callback.segments/callback/__PAGE__.segment.rsc +4 -4
- 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 +2 -2
- 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/index.html +1 -1
- package/app/.next-cli-build/server/app/index.rsc +4 -4
- package/app/.next-cli-build/server/app/index.segments/__PAGE__.segment.rsc +4 -4
- package/app/.next-cli-build/server/app/index.segments/_full.segment.rsc +4 -4
- package/app/.next-cli-build/server/app/index.segments/_tree.segment.rsc +2 -2
- 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 +4 -4
- package/app/.next-cli-build/server/app/landing.segments/_full.segment.rsc +4 -4
- package/app/.next-cli-build/server/app/landing.segments/_tree.segment.rsc +2 -2
- package/app/.next-cli-build/server/app/landing.segments/landing/__PAGE__.segment.rsc +4 -4
- 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 +2 -2
- package/app/.next-cli-build/server/app/login.segments/login/__PAGE__.segment.rsc +4 -4
- package/app/.next-cli-build/server/app/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app-paths-manifest.json +6 -6
- package/app/.next-cli-build/server/chunks/1350.js +1 -1
- package/app/.next-cli-build/server/chunks/194.js +1 -1
- package/app/.next-cli-build/server/chunks/6395.js +1 -1
- package/app/.next-cli-build/server/chunks/6406.js +1 -1
- package/app/.next-cli-build/server/chunks/646.js +1 -1
- package/app/.next-cli-build/server/chunks/6985.js +1 -1
- package/app/.next-cli-build/server/chunks/7454.js +1 -1
- package/app/.next-cli-build/server/chunks/869.js +1 -1
- package/app/.next-cli-build/server/chunks/8834.js +1 -1
- package/app/.next-cli-build/server/chunks/8976.js +1 -1
- package/app/.next-cli-build/server/chunks/8998.js +9 -9
- package/app/.next-cli-build/server/chunks/9261.js +6 -6
- 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-4de88db4bd94a23c.js → 1321-6bd6f91d24e9863e.js} +1 -1
- package/app/.next-cli-build/static/chunks/1330-56405eca78b12fee.js +7 -0
- package/app/{.next/static/chunks/3531-936a1e7912d9876c.js → .next-cli-build/static/chunks/3531-eb5d385c954b3765.js} +7 -7
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/agent-library/page-cf3bc192f7a27304.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/basic-chat/page-0e1d54e59ac767a1.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/cli-tools/[toolId]/{page-d7205b7328b3fed1.js → page-af0d85c06970853b.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/cli-tools/{page-d0b6efe01e687aec.js → page-2cfc2352bc42d9b8.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/combos/page-62cd36ee99eaa630.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/combos/routing/page-0b02e9a2f1cc6e43.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/console-log/page-ded6ec41e583b3b3.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/endpoint/page-ca47b09e6ed6ae7b.js +16 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/[id]/{page-772f246688672d59.js → page-78d098f14f8cff05.js} +8 -8
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/page-d1654fba27199492.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/combo/[id]/{page-8554ba79c854167f.js → page-ff13a39fb7744f5e.js} +3 -3
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/page-919f3eec8dfc9b6e.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/web/page-db19da41661d630b.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/mitm/{page-8779ff2bc755ba78.js → page-309b09a142a2995d.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/page-86cd6523dcd61f1b.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/profile/{page-d32871b974f7e72f.js → page-ae6cf9ce7ac84eb7.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/[id]/{page-d8610d9b77a2cae4.js → page-97e0f7067cab0724.js} +3 -3
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/new/page-413b59dd764a1563.js +1 -0
- package/app/{.next/static/chunks/app/(dashboard)/dashboard/providers/page-555f079cdf31bbf6.js → .next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/page-31212a5a4a9825b0.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/pxpipe/page-1805f993834a1adb.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/quota/page-798a65a8c4d2708a.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/skills/[id]/page-aba614778bfe50ad.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/skills/page-b1e9603ce7be0155.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/token-saver/page-1711a424a8dcad0e.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/translator/page-0c7b901caf8614b9.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/usage/page-b085086e6c5b9387.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/{layout-62b4e2cdf745f8d0.js → layout-59baac68c7aedd25.js} +1 -1
- package/app/.next-cli-build/static/css/c5928b380ef8a163.css +1 -0
- package/app/open-sse/identity/tls/bin/darwin/arm64/switchboard-claude-tls +0 -0
- package/app/open-sse/identity/tls/bin/darwin/x64/switchboard-claude-tls +0 -0
- package/app/open-sse/identity/tls/bin/linux/arm64/switchboard-claude-tls +0 -0
- package/app/open-sse/identity/tls/bin/linux/x64/switchboard-claude-tls +0 -0
- package/app/open-sse/identity/tls/bin/win32/arm64/switchboard-claude-tls.exe +0 -0
- package/app/open-sse/identity/tls/bin/win32/x64/switchboard-claude-tls.exe +0 -0
- package/app/package.json +1 -1
- package/package.json +1 -1
- package/src/cli/api/client.js +1 -1
- package/app/.next/static/chunks/5497-78bd7208dc4a083d.js +0 -7
- package/app/.next/static/chunks/app/(dashboard)/dashboard/agent-library/page-24b5a8515eee26d6.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/basic-chat/page-4ec8bfa73afe20a6.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/combos/page-5cfdfdf507c8222f.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/combos/routing/page-25629f96675ad55d.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/console-log/page-b54cd17200807e49.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/endpoint/page-cd44cb44125275b6.js +0 -3
- package/app/.next/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/page-52c12af07f9a6de0.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/media-providers/page-0f54c9a5e7391a77.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/media-providers/web/page-cfbd3661ac75b8c5.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/page-c33d24bdadcf0c6e.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/new/page-74d56b3b7ac42546.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/pxpipe/page-bd18ad88b98cd373.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/quota/page-b3ffcc7df06a37d8.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/skills/[id]/page-56bf48ee2068208e.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/skills/page-46986a955b8c89b2.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/token-saver/page-20972a96e348f397.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/translator/page-0cc2ccbe11cc0013.js +0 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/usage/page-5af5fff7d28ed91d.js +0 -1
- package/app/.next/static/css/d89fdbc0e71b454e.css +0 -1
- package/app/.next-cli-build/static/chunks/5497-78bd7208dc4a083d.js +0 -7
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/agent-library/page-24b5a8515eee26d6.js +0 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/basic-chat/page-4ec8bfa73afe20a6.js +0 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/combos/page-5cfdfdf507c8222f.js +0 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/combos/routing/page-25629f96675ad55d.js +0 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/console-log/page-b54cd17200807e49.js +0 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/endpoint/page-cd44cb44125275b6.js +0 -3
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/page-52c12af07f9a6de0.js +0 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/page-0f54c9a5e7391a77.js +0 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/web/page-cfbd3661ac75b8c5.js +0 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/page-c33d24bdadcf0c6e.js +0 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/new/page-74d56b3b7ac42546.js +0 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/pxpipe/page-bd18ad88b98cd373.js +0 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/quota/page-b3ffcc7df06a37d8.js +0 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/skills/[id]/page-56bf48ee2068208e.js +0 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/skills/page-46986a955b8c89b2.js +0 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/token-saver/page-20972a96e348f397.js +0 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/translator/page-0cc2ccbe11cc0013.js +0 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/usage/page-5af5fff7d28ed91d.js +0 -1
- package/app/.next-cli-build/static/css/d89fdbc0e71b454e.css +0 -1
- /package/app/.next/static/{Fq0KReA64JGBdC8atypku → kGdbG3TEpkBeoqsRS2Mre}/_buildManifest.js +0 -0
- /package/app/.next/static/{Fq0KReA64JGBdC8atypku → kGdbG3TEpkBeoqsRS2Mre}/_ssgManifest.js +0 -0
- /package/app/.next-cli-build/static/{Fq0KReA64JGBdC8atypku → kGdbG3TEpkBeoqsRS2Mre}/_buildManifest.js +0 -0
- /package/app/.next-cli-build/static/{Fq0KReA64JGBdC8atypku → kGdbG3TEpkBeoqsRS2Mre}/_ssgManifest.js +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2134],{7687:(e,t,s)=>{Promise.resolve().then(s.bind(s,42710))},42710:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>V});var a=s(95155),i=s(12115),r=s(73321),l=s(98500),n=s.n(l),o=s(5772),d=s(35497),c=s(88105),m=s(28777),u=s(16600),p=s(47224);let x=["none","low","medium","high"],h=["none","thinking"],f=["none","low","medium","high","max"],b={openai:["none","minimal","low","medium","high","xhigh"],"claude-adaptive":f,"claude-budget":["none","low","medium","high","xhigh","max"],"gemini-level":["minimal","low","medium","high"],"gemini-budget":x,zai:h,qwen:x,kimi:f,deepseek:["none","high","max"],minimax:h,hunyuan:x,step:x},g=[{pattern:"*codex*",levels:["low","medium","high","xhigh"]}];function y(e,t){let s=(0,u.nl)(e,t);if(!s.reasoning)return null;let a=g.find(e=>(0,p.gH)(e.pattern,t)),i=a?.levels||b[s.thinkingFormat]||x;return!1===s.thinkingCanDisable&&(i=i.filter(e=>"none"!==e)),i}var v=s(11059),j=s(929),w=s(73006);let k=new Map;async function N(e){if(!e?.url||!e?.type||e.requiresAuth)return[];let t=k.get(e.url);if(t&&Date.now()<t.expiresAt)return t.data;try{let t=new URLSearchParams({url:e.url,type:e.type}),s=await fetch(`/api/providers/suggested-models?${t}`);if(!s.ok)return[];let a=(await s.json()).data??[];return k.set(e.url,{data:a,expiresAt:Date.now()+6e5}),a}catch{return[]}}var C=s(81231),S=s(68501),$=s(14051),A=s.n($);function T({model:e,fullModel:t,alias:s,copied:i,onCopy:r,testStatus:l,isCustom:n,isFree:o,onDeleteAlias:c,onTest:m,isTesting:u,onDisable:p,caps:x,thinkingSuffix:h,latencyMs:f,probeState:b}){let g=h?`${t}(${h})`:t,y="ok"===l||"ok"===b,v="error"===l||"dead"===b,j="retry"===b||u||"testing"===b;return(0,a.jsx)("div",{className:`group relative min-w-0 max-w-full rounded-xl border bg-surface/50 p-3 transition-all hover:bg-surface/80 hover:shadow-soft ${y?"border-green-500/30 hover:border-green-500/50":v?"border-red-500/30 hover:border-red-500/50":j?"border-amber-500/30 hover:border-amber-500/50":"border-border/60 hover:border-primary/40"}`,children:(0,a.jsxs)("div",{className:"flex min-w-0 items-start justify-between gap-2.5",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-1 items-start gap-2.5",children:[(0,a.jsx)("div",{className:"mt-0.5 flex size-7 shrink-0 items-center justify-center rounded-lg bg-surface-2 border border-border/40 text-text-muted",children:u||"testing"===b?(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 animate-spin text-[15px] text-primary",title:"Testing model...",children:"progress_activity"}):y?(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-[16px] text-green-500",title:"Model reachable",children:"check_circle"}):v?(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-[16px] text-red-500",title:"Model unavailable",children:"cancel"}):"retry"===b?(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-[16px] text-amber-500",title:"Retry later",children:"schedule"}):(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-[16px]","aria-hidden":"true",children:"smart_toy"})}),(0,a.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap",children:[(0,a.jsx)("code",{className:"max-w-[70vw] truncate rounded-md bg-surface-2 border border-border/40 px-2 py-0.5 font-mono text-xs font-medium text-text-main sm:max-w-[340px]",children:g}),n&&(0,a.jsx)("span",{className:"rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary",children:"Custom"})]}),(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2 text-xs",children:[e.name&&(0,a.jsx)("span",{className:"truncate text-xs text-text-muted",children:e.name}),Number.isFinite(f)&&(0,a.jsxs)("span",{className:"inline-flex items-center gap-0.5 text-[11px] font-medium text-text-muted tabular-nums",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px] text-primary",children:"bolt"}),Math.round(f),"ms"]}),(0,a.jsx)(d.nh,{caps:x,colorOverride:"text-text-muted/80",size:13})]})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[m&&(0,a.jsx)("button",{onClick:m,disabled:u,"aria-label":u?`Testing ${g}`:`Test ${g}`,title:u?"Testing...":"Test model",className:`rounded-lg p-1 text-text-muted transition-all hover:bg-surface-2 hover:text-primary ${u?"opacity-100":"opacity-70 group-hover:opacity-100"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]","aria-hidden":"true",style:u?{animation:"spin 1s linear infinite"}:void 0,children:u?"progress_activity":"science"})}),(0,a.jsx)("button",{onClick:()=>r(g,`model-${e.id}`),"aria-label":i===`model-${e.id}`?`Copied ${g}`:`Copy ${g}`,title:i===`model-${e.id}`?"Copied!":"Copy model name",className:"rounded-lg p-1 text-text-muted transition-all hover:bg-surface-2 hover:text-primary opacity-70 group-hover:opacity-100",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]","aria-hidden":"true",children:i===`model-${e.id}`?"check":"content_copy"})}),n?(0,a.jsx)("button",{onClick:c,className:"rounded-lg p-1 text-text-muted transition-all hover:bg-red-500/10 hover:text-red-400 opacity-60 hover:opacity-100","aria-label":`Remove custom model ${g}`,title:"Remove custom model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]","aria-hidden":"true",children:"close"})}):p?(0,a.jsx)("button",{onClick:p,className:"rounded-lg p-1 text-text-muted transition-all hover:bg-red-500/10 hover:text-red-400 opacity-60 hover:opacity-100","aria-label":`Disable ${g}`,title:"Disable this model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]","aria-hidden":"true",children:"close"})}):null]})]})})}T.propTypes={model:A().shape({id:A().string.isRequired}).isRequired,fullModel:A().string.isRequired,alias:A().string,copied:A().string,onCopy:A().func.isRequired,testStatus:A().oneOf(["ok","error"]),isCustom:A().bool,isFree:A().bool,onDeleteAlias:A().func,onTest:A().func,isTesting:A().bool,onDisable:A().func,caps:A().object,thinkingSuffix:A().string,latencyMs:A().number,probeState:A().string};var O=s(78559);function R({modelId:e,fullModel:t,copied:s,onCopy:i,onDeleteAlias:r,onTest:l,testStatus:n,isTesting:o}){let d="ok"===n?"#22c55e":"error"===n?"#ef4444":void 0;return(0,a.jsxs)("div",{className:`flex items-center gap-3 p-3 rounded-lg border ${"ok"===n?"border-green-500/40":"error"===n?"border-red-500/40":"border-border"} hover:bg-sidebar/50`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base text-text-muted",style:d?{color:d}:void 0,children:"ok"===n?"check_circle":"error"===n?"cancel":"smart_toy"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"text-sm font-medium truncate",children:e}),(0,a.jsxs)("div",{className:"flex items-center gap-1 mt-1",children:[(0,a.jsx)("code",{className:"text-xs text-text-muted font-mono bg-sidebar px-1.5 py-0.5 rounded",children:t}),(0,a.jsxs)("div",{className:"relative group/btn",children:[(0,a.jsx)("button",{onClick:()=>i(t,`model-${e}`),className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:s===`model-${e}`?"check":"content_copy"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:s===`model-${e}`?"Copied!":"Copy"})]}),l&&(0,a.jsxs)("div",{className:"relative group/btn",children:[(0,a.jsx)("button",{onClick:l,disabled:o,className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",style:o?{animation:"spin 1s linear infinite"}:void 0,children:o?"progress_activity":"science"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:o?"Testing...":"Test"})]})]})]}),(0,a.jsx)("button",{onClick:r,className:"p-1 hover:bg-red-50 rounded text-red-500",title:"Remove model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"delete"})})]})}function E({providerStorageAlias:e,providerDisplayAlias:t,modelAliases:s,customModels:r,copied:l,onCopy:n,onDeleteAlias:o,onAddCustomModel:c,onDeleteCustomModel:m,onRefreshModels:u,connections:p,isAnthropic:x,disabledModelIds:h=[],onEnableModel:f}){let[b,g]=(0,i.useState)(""),[y,v]=(0,i.useState)(!1),[j,w]=(0,i.useState)(!1),[k,N]=(0,i.useState)(""),[S,$]=(0,i.useState)(null),[A,T]=(0,i.useState)({}),I=async t=>{if(!S){$(t);try{let s=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${e}/${t}`})}),a=await s.json();T(e=>({...e,[t]:a.ok?"ok":"error"}))}catch{T(e=>({...e,[t]:"error"}))}finally{$(null)}}},D=(0,C.Iz)(h,e),M=[...D],P=(0,C.R3)({customModels:r,modelAliases:s,providerAlias:e,type:"llm"}),U=P.filter(t=>!(0,C.uJ)(D,t.id,e)),z=async()=>{if(!b.trim()||y)return;let t=b.trim();if(U.some(e=>e.id===t))return void(0,O.s)("Model already exists for this provider.");v(!0);try{if((0,C.uJ)(D,t,e)){let e=await f?.(t);if(!1===e)throw Error("Failed to enable removed model")}await c(t),g("")}catch(e){(0,O.s)("Error adding model:",e)}finally{v(!1)}},q=async()=>{if(j)return;let t=p.find(e=>!1!==e.isActive);if(t){w(!0),N("");try{let s=await fetch(`/api/providers/${t.id}/models`),a=await s.json().catch(()=>({}));if(!s.ok)return void(0,O.s)(a.error||"Failed to import models");let i=a.models||[];if(0===i.length)return void(0,O.s)("No models returned from /models.");let r=new Set(P.map(e=>e.id)),l=[],n=new Set;for(let t of i){let s=String(t.id||t.name||t.model||"").trim();!s||r.has(s)||n.has(s)||(0,C.uJ)(D,s,e)||(n.add(s),l.push({providerAlias:e,id:s,type:"llm",name:t.display_name||t.displayName||t.name||s}))}if(0===l.length)return void N("All models already in list");let o=await fetch("/api/models/custom",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({models:l})}),d=await o.json().catch(()=>({}));if(!o.ok){let e=0;for(let t of l)await c(t.id),e+=1;N(e?`Imported ${e} model(s)`:"No new models were added");return}N(`Imported ${d.added??l.length} model(s)`),"function"==typeof u?await u():window.dispatchEvent(new CustomEvent("customModelChanged"))}catch(e){(0,O.s)("Error importing models:",e),(0,O.s)(e?.message||"Import failed")}finally{w(!1)}}},_=p.some(e=>!1!==e.isActive);return(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("p",{className:"text-sm text-text-muted",children:["Add ",x?"Anthropic":"OpenAI","-compatible models manually or import them from the /models endpoint."]}),(0,a.jsxs)("div",{className:"flex items-end gap-2 flex-wrap",children:[(0,a.jsxs)("div",{className:"flex-1 min-w-[240px]",children:[(0,a.jsx)("label",{htmlFor:"new-compatible-model-input",className:"text-xs text-text-muted mb-1 block",children:"Model ID"}),(0,a.jsx)("input",{id:"new-compatible-model-input",type:"text",value:b,onChange:e=>g(e.target.value),onKeyDown:e=>"Enter"===e.key&&z(),placeholder:x?"claude-3-opus-20240229":"gpt-4o",className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})]}),(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:z,disabled:!b.trim()||y,children:y?"Adding...":"Add"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"cloud_download",onClick:q,disabled:!_||j,children:j?"Importing...":"Import models"})]}),!_&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Add a connection to enable importing models."}),k&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:k}),U.length>0&&(0,a.jsx)("div",{className:"flex flex-col gap-3",children:U.map(({id:s,alias:i,source:r})=>(0,a.jsx)(R,{modelId:s,fullModel:`${t}/${s}`,copied:l,onCopy:n,onDeleteAlias:()=>"custom"===r?m(s):o(i),onTest:p.length>0?()=>I(s):void 0,testStatus:A[s],isTesting:S===s},`${r}-${e}/${s}`))}),M.length>0&&(0,a.jsxs)("details",{className:"rounded-lg border border-border bg-surface/30 p-3",children:[(0,a.jsxs)("summary",{className:"cursor-pointer text-sm font-medium text-text-main",children:["Removed models (",M.length,")"]}),(0,a.jsx)("p",{className:"mt-1 text-xs text-text-muted",children:"Enable a model to make it available for import and selection again."}),(0,a.jsx)("div",{className:"mt-3 flex max-h-56 flex-col gap-1.5 overflow-y-auto",children:M.map(e=>(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3 rounded border border-border bg-background px-2 py-1.5",children:[(0,a.jsx)("code",{className:"min-w-0 flex-1 truncate text-xs",title:e,children:e}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",onClick:()=>f?.(e),children:"Enable"})]},e))})]})]})}A().string.isRequired,A().string.isRequired,A().string,A().func.isRequired,A().func.isRequired,A().func,A().oneOf(["ok","error"]),A().bool,A().string.isRequired,A().object.isRequired,A().arrayOf(A().object),A().string,A().func.isRequired,A().func.isRequired,A().func.isRequired,A().func.isRequired,E.propTypes={providerStorageAlias:A().string.isRequired,providerDisplayAlias:A().string.isRequired,modelAliases:A().object.isRequired,customModels:A().arrayOf(A().object),copied:A().string,onCopy:A().func.isRequired,onDeleteAlias:A().func.isRequired,onAddCustomModel:A().func.isRequired,onDeleteCustomModel:A().func.isRequired,onRefreshModels:A().func,connections:A().arrayOf(A().shape({id:A().string,isActive:A().bool})).isRequired,isAnthropic:A().bool,disabledModelIds:A().arrayOf(A().string),onEnableModel:A().func};var I=s(70217);function D({until:e}){let[t,s]=(0,i.useState)("");return((0,i.useEffect)(()=>{let t=()=>{let t=new Date(e).getTime()-Date.now();if(t<=0)return void s("");let a=Math.floor(t/1e3);if(a<60)s(`${a}s`);else if(a<3600)s(`${Math.floor(a/60)}m ${a%60}s`);else{let e=Math.floor(a/3600),t=Math.floor(a%3600/60);s(`${e}h ${t}m`)}};t();let a=setInterval(t,1e3);return()=>clearInterval(a)},[e]),t)?(0,a.jsxs)("span",{className:"text-xs text-orange-500 font-mono",children:["⏱ ",t]}):null}function M({connection:e,isOAuth:t,isFirst:s,isLast:r,onMoveUp:l,onMoveDown:n,onToggleActive:o,onEdit:c,onDelete:m,onAllowlistHost:u=null,oneByOneStatus:p=null,autoPing:x=null}){let h=/SSRF blocked|Blocked URL: (private IP|internal host)/i.test(e.lastError||""),f=(e=>{if(!e)return null;let t=String(e).trim();try{let e=t.match(/\{[\s\S]*\}$/);if(e){let s=JSON.parse(e[0]),a=s?.error?.message||s?.message||s?.error;"string"==typeof a&&a.trim()&&(t=a.trim())}}catch{}return(t=t.replace(/^\[\d+\]:\s*/,""),/not have a valid license|license of this product|license required/i.test(t))?{type:"license",title:"License Required",message:"No active Gemini Code Assist or Antigravity license found for this Google account. Visit antigravity.google to activate, or reconnect.",action:N?"reconnect":null}:/invalid_grant|token expired|credentials expired|expired or revoked|session expired/i.test(t)?{type:"auth",title:"Session Expired",message:"OAuth token expired or was revoked. Please reconnect.",action:N?"reconnect":null}:/rate limit|quota|429|resource has been exhausted/i.test(t)?{type:"quota",title:"Rate Limited",message:t||"Upstream rate limit reached.",action:null}:h?{type:"ssrf",title:"Network Guard",message:"SSRF guard blocked local/private IP address.",action:"allowlist"}:{type:"error",title:"Error",message:t,action:N?"reconnect":null}})(e.lastError),b=e.providerSpecificData?.connectionProxyEnabled===!0&&!!e.providerSpecificData?.connectionProxyUrl,g=b?`Proxy: ${e.providerSpecificData?.connectionProxyUrl}`:"",y=x?.provider==="codex"?"Auto-starts the next 5h Codex window after reset by sending a tiny gpt-5.5 request. Consumes a small amount of quota.":"When your 5h quota runs out, auto-sends a request the moment it resets so a new window starts right away.",v="";if(e.providerSpecificData?.connectionProxyUrl){let t=e.providerSpecificData?.connectionProxyUrl;try{let e=new URL(t);v=`${e.protocol}//${e.hostname}${e.port?`:${e.port}`:""}`}catch{v=t}}let j=e.providerSpecificData?.connectionNoProxy||"",w=b?"success":"default",k=e.authType||(t?"oauth":"apikey"),N="oauth"===k,C="cookie"===k,S=e.name?.trim()||e.email?.trim()||e.displayName?.trim()||(N?"OAuth Account":C?"Cookie Account":"API Key"),$=e.name?.trim()&&e.email?.trim()&&e.name.trim()!==e.email.trim()?e.email.trim():e.name?.trim()&&e.displayName?.trim()&&e.name.trim()!==e.displayName.trim()?e.displayName.trim():null,[A,T]=(0,i.useState)(!1),O=Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>e).filter(e=>!!e).sort()[0]||null;(0,i.useEffect)(()=>{let t=()=>{T(!!Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>e).filter(e=>e&&new Date(e).getTime()>Date.now()).sort()[0])};t();let s=O?setInterval(t,1e3):null;return()=>{s&&clearInterval(s)}},[e,O]);let R="unavailable"!==e.testStatus||A?e.testStatus:"active",E=()=>p?"queued"===p.state?"queued":"testing"===p.state?"testing":"success"===p.state?"success":"failed"===p.state?p.error?`failed: ${p.error}`:"failed":null:null;return(0,a.jsx)("div",{className:`group flex min-w-0 flex-col gap-3 rounded-xl border border-border/60 bg-surface/40 p-3 transition-all hover:border-border hover:bg-surface/70 ${!1===e.isActive?"opacity-60":""}`,children:(0,a.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-2.5",children:[(0,a.jsxs)("div",{className:"flex shrink-0 flex-col",children:[(0,a.jsx)("button",{onClick:l,disabled:s,"aria-label":`Move ${S} up`,title:`Move ${S} up`,className:`p-0.5 rounded ${s?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm","aria-hidden":"true",children:"keyboard_arrow_up"})}),(0,a.jsx)("button",{onClick:n,disabled:r,"aria-label":`Move ${S} down`,title:`Move ${S} down`,className:`p-0.5 rounded ${r?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm","aria-hidden":"true",children:"keyboard_arrow_down"})})]}),(0,a.jsx)("div",{className:"flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-2 border border-border/40 text-text-muted",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]","aria-hidden":"true",children:C?"cookie":N?"lock":"key"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:"text-sm font-medium text-text-main truncate",children:S}),$&&(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:$})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[x&&(0,a.jsx)(d.m_,{text:y,children:(0,a.jsxs)("button",{onClick:()=>x.onToggle(!x.on),className:`flex items-center gap-1 rounded-lg px-2 py-1 text-xs transition-colors hover:bg-white/5 ${x.on?"text-primary bg-primary/10 font-medium":"text-text-muted hover:text-primary"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"bolt"}),(0,a.jsx)("span",{className:"hidden sm:inline text-xs",children:"Auto-ping"})]})}),(0,a.jsxs)("button",{onClick:c,className:"flex items-center gap-1 rounded-lg px-2.5 py-1 text-xs text-text-muted hover:bg-white/5 hover:text-primary transition-colors",title:"Edit connection",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"edit"}),(0,a.jsx)("span",{className:"hidden sm:inline",children:"Edit"})]}),(0,a.jsxs)("button",{onClick:m,className:"flex items-center gap-1 rounded-lg px-2.5 py-1 text-xs text-red-400 hover:bg-red-500/10 transition-colors",title:"Delete connection",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"delete"}),(0,a.jsx)("span",{className:"hidden sm:inline",children:"Delete"})]})]}),(0,a.jsx)("div",{className:"h-4 w-px bg-border/60 mx-1"}),(0,a.jsx)(d.lM,{size:"sm",checked:e.isActive??!0,onChange:o,title:e.isActive??!0?"Disable connection":"Enable connection"})]})]}),(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5 pl-0 sm:pl-10",children:[(0,a.jsx)(d.Ex,{variant:(0,I.g)(e.isActive,R),size:"sm",dot:!0,children:!1===e.isActive?"disabled":R||"Unknown"}),(0,a.jsx)(d.Ex,{variant:"default",size:"sm",children:N?"OAuth":C?"Cookie":"API Key"}),b&&(0,a.jsx)(d.Ex,{variant:w,size:"sm",children:"Proxy"}),A&&!1!==e.isActive&&(0,a.jsx)(D,{until:O}),(0,a.jsxs)("span",{className:"text-xs text-text-muted",children:["#",e.priority]}),e.globalPriority&&(0,a.jsxs)("span",{className:"text-xs text-text-muted",children:["Auto: ",e.globalPriority]}),E()&&(0,a.jsx)(d.Ex,{variant:p?"success"===p.state?"success":"failed"===p.state?"error":"testing"===p.state?"primary":"default":"default",size:"sm",children:E()})]}),f&&!1!==e.isActive&&(0,a.jsxs)("div",{className:"mt-1.5 flex min-w-0 flex-col sm:flex-row sm:items-center justify-between gap-2 rounded-lg border border-red-500/25 bg-red-500/8 px-3 py-2 text-xs text-red-600 dark:text-red-400 sm:ml-10",children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-start sm:items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-[16px] text-red-500 mt-0.5 sm:mt-0",children:"license"===f.type?"workspace_premium":"auth"===f.type?"key_off":"error"}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("span",{className:"font-semibold",children:[f.title,": "]}),(0,a.jsx)("span",{className:"break-words",children:f.message})]})]}),"reconnect"===f.action&&(0,a.jsxs)("button",{onClick:c,className:"inline-flex shrink-0 items-center justify-center gap-1 rounded-md bg-red-500/15 hover:bg-red-500/25 px-2.5 py-1 text-xs font-medium text-red-600 dark:text-red-300 transition-colors",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"refresh"}),"Reconnect"]}),"allowlist"===f.action&&u&&(0,a.jsxs)("button",{onClick:u,className:"inline-flex shrink-0 items-center justify-center gap-1 rounded-md border border-amber-500/40 bg-amber-500/10 px-2.5 py-1 text-xs font-medium text-amber-600 dark:text-amber-300 hover:bg-amber-500/20 transition-colors",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"verified_user"}),"Add to allow list"]})]}),b&&(0,a.jsxs)("div",{className:"mt-1 flex items-center gap-2 flex-wrap sm:ml-10",children:[(0,a.jsx)("span",{className:"max-w-full truncate text-[11px] text-text-muted sm:max-w-[420px]",title:g,children:g}),v&&(0,a.jsx)("code",{className:"max-w-full truncate rounded bg-black/5 px-1 py-0.5 font-mono text-[10px] text-text-muted dark:bg-white/5 sm:max-w-[260px]",children:v}),j&&(0,a.jsxs)("span",{className:"max-w-full truncate text-[11px] text-text-muted sm:max-w-[320px]",title:j,children:["no_proxy: ",j]})]})]})})}D.propTypes={until:A().string.isRequired},M.propTypes={connection:A().shape({id:A().string,name:A().string,email:A().string,displayName:A().string,modelLockUntil:A().string,testStatus:A().string,isActive:A().bool,lastError:A().string,priority:A().number,globalPriority:A().number,providerSpecificData:A().object}).isRequired,isOAuth:A().bool.isRequired,isFirst:A().bool.isRequired,isLast:A().bool.isRequired,onMoveUp:A().func.isRequired,onMoveDown:A().func.isRequired,onToggleActive:A().func.isRequired,onEdit:A().func.isRequired,onDelete:A().func.isRequired,onAllowlistHost:A().func,oneByOneStatus:A().shape({state:A().string,error:A().string}),autoPing:A().shape({on:A().bool,onToggle:A().func,provider:A().string})};let P=`name1|sk-key1
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2134],{7687:(e,t,s)=>{Promise.resolve().then(s.bind(s,42710))},35497:(e,t,s)=>{"use strict";s.d(t,{x0:()=>k.default,Ex:()=>d.default,$n:()=>a.default,nh:()=>A.default,Zp:()=>l.default,Qv:()=>o.CardSkeleton,CK:()=>x.default,uo:()=>n.ConfirmModal,G9:()=>y.default,wI:()=>w.default,vj:()=>j.default,vE:()=>v.default,pd:()=>i.default,Mh:()=>g.default,uR:()=>p.default,Nf:()=>h.default,aF:()=>n.default,rq:()=>u.default,gw:()=>N.default,LF:()=>m.default,Wx:()=>$.default,gM:()=>b.default,Iz:()=>C.default,l6:()=>r.default,lM:()=>c.default,m_:()=>S.default,jK:()=>f.default});var a=s(92542),i=s(11910),r=s(98),l=s(84588),n=s(81127),o=s(25086);s(56319);var d=s(56061),c=s(98542);s(38587),s(21110),s(92622),s(8823),s(92173);var m=s(90882),u=s(72908),p=s(28815),x=s(45455),h=s(28058),f=s(4809);s(21931),s(80752),s(40197);var b=s(23615);s(44736);var g=s(62899);s(94230);var y=s(30815),v=s(23936),j=s(95088),w=s(73579),k=s(96748),N=s(4823),C=s(28067),S=s(97677),$=s(51825),A=s(29366);s(76361),s(91450)},42710:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>V});var a=s(95155),i=s(12115),r=s(73321),l=s(98500),n=s.n(l),o=s(5772),d=s(35497),c=s(88105),m=s(28777),u=s(16600),p=s(47224);let x=["none","low","medium","high"],h=["none","thinking"],f=["none","low","medium","high","max"],b={openai:["none","minimal","low","medium","high","xhigh"],"claude-adaptive":f,"claude-budget":["none","low","medium","high","xhigh","max"],"gemini-level":["minimal","low","medium","high"],"gemini-budget":x,zai:h,qwen:x,kimi:f,deepseek:["none","high","max"],minimax:h,hunyuan:x,step:x},g=[{pattern:"*codex*",levels:["low","medium","high","xhigh"]}];function y(e,t){let s=(0,u.nl)(e,t);if(!s.reasoning)return null;let a=g.find(e=>(0,p.gH)(e.pattern,t)),i=a?.levels||b[s.thinkingFormat]||x;return!1===s.thinkingCanDisable&&(i=i.filter(e=>"none"!==e)),i}var v=s(11059),j=s(929),w=s(73006);let k=new Map;async function N(e){if(!e?.url||!e?.type||e.requiresAuth)return[];let t=k.get(e.url);if(t&&Date.now()<t.expiresAt)return t.data;try{let t=new URLSearchParams({url:e.url,type:e.type}),s=await fetch(`/api/providers/suggested-models?${t}`);if(!s.ok)return[];let a=(await s.json()).data??[];return k.set(e.url,{data:a,expiresAt:Date.now()+6e5}),a}catch{return[]}}var C=s(81231),S=s(68501),$=s(14051),A=s.n($);function T({model:e,fullModel:t,alias:s,copied:i,onCopy:r,testStatus:l,isCustom:n,isFree:o,onDeleteAlias:c,onTest:m,isTesting:u,onDisable:p,caps:x,thinkingSuffix:h,latencyMs:f,probeState:b}){let g=h?`${t}(${h})`:t,y="ok"===l||"ok"===b,v="error"===l||"dead"===b,j="retry"===b||u||"testing"===b;return(0,a.jsx)("div",{className:`group relative min-w-0 max-w-full rounded-xl border bg-surface/50 p-3 transition-all hover:bg-surface/80 hover:shadow-soft ${y?"border-green-500/30 hover:border-green-500/50":v?"border-red-500/30 hover:border-red-500/50":j?"border-amber-500/30 hover:border-amber-500/50":"border-border/60 hover:border-primary/40"}`,children:(0,a.jsxs)("div",{className:"flex min-w-0 items-start justify-between gap-2.5",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-1 items-start gap-2.5",children:[(0,a.jsx)("div",{className:"mt-0.5 flex size-7 shrink-0 items-center justify-center rounded-lg bg-surface-2 border border-border/40 text-text-muted",children:u||"testing"===b?(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 animate-spin text-[15px] text-primary",title:"Testing model...",children:"progress_activity"}):y?(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-[16px] text-green-500",title:"Model reachable",children:"check_circle"}):v?(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-[16px] text-red-500",title:"Model unavailable",children:"cancel"}):"retry"===b?(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-[16px] text-amber-500",title:"Retry later",children:"schedule"}):(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-[16px]","aria-hidden":"true",children:"smart_toy"})}),(0,a.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap",children:[(0,a.jsx)("code",{className:"max-w-[70vw] truncate rounded-md bg-surface-2 border border-border/40 px-2 py-0.5 font-mono text-xs font-medium text-text-main sm:max-w-[340px]",children:g}),n&&(0,a.jsx)("span",{className:"rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary",children:"Custom"})]}),(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2 text-xs",children:[e.name&&(0,a.jsx)("span",{className:"truncate text-xs text-text-muted",children:e.name}),Number.isFinite(f)&&(0,a.jsxs)("span",{className:"inline-flex items-center gap-0.5 text-[11px] font-medium text-text-muted tabular-nums",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px] text-primary",children:"bolt"}),Math.round(f),"ms"]}),(0,a.jsx)(d.nh,{caps:x,colorOverride:"text-text-muted/80",size:13})]})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[m&&(0,a.jsx)("button",{onClick:m,disabled:u,"aria-label":u?`Testing ${g}`:`Test ${g}`,title:u?"Testing...":"Test model",className:`rounded-lg p-1 text-text-muted transition-all hover:bg-surface-2 hover:text-primary ${u?"opacity-100":"opacity-70 group-hover:opacity-100"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]","aria-hidden":"true",style:u?{animation:"spin 1s linear infinite"}:void 0,children:u?"progress_activity":"science"})}),(0,a.jsx)("button",{onClick:()=>r(g,`model-${e.id}`),"aria-label":i===`model-${e.id}`?`Copied ${g}`:`Copy ${g}`,title:i===`model-${e.id}`?"Copied!":"Copy model name",className:"rounded-lg p-1 text-text-muted transition-all hover:bg-surface-2 hover:text-primary opacity-70 group-hover:opacity-100",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]","aria-hidden":"true",children:i===`model-${e.id}`?"check":"content_copy"})}),n?(0,a.jsx)("button",{onClick:c,className:"rounded-lg p-1 text-text-muted transition-all hover:bg-red-500/10 hover:text-red-400 opacity-60 hover:opacity-100","aria-label":`Remove custom model ${g}`,title:"Remove custom model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]","aria-hidden":"true",children:"close"})}):p?(0,a.jsx)("button",{onClick:p,className:"rounded-lg p-1 text-text-muted transition-all hover:bg-red-500/10 hover:text-red-400 opacity-60 hover:opacity-100","aria-label":`Disable ${g}`,title:"Disable this model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]","aria-hidden":"true",children:"close"})}):null]})]})})}T.propTypes={model:A().shape({id:A().string.isRequired}).isRequired,fullModel:A().string.isRequired,alias:A().string,copied:A().string,onCopy:A().func.isRequired,testStatus:A().oneOf(["ok","error"]),isCustom:A().bool,isFree:A().bool,onDeleteAlias:A().func,onTest:A().func,isTesting:A().bool,onDisable:A().func,caps:A().object,thinkingSuffix:A().string,latencyMs:A().number,probeState:A().string};var E=s(78559);function O({modelId:e,fullModel:t,copied:s,onCopy:i,onDeleteAlias:r,onTest:l,testStatus:n,isTesting:o}){let d="ok"===n?"#22c55e":"error"===n?"#ef4444":void 0;return(0,a.jsxs)("div",{className:`flex items-center gap-3 p-3 rounded-lg border ${"ok"===n?"border-green-500/40":"error"===n?"border-red-500/40":"border-border"} hover:bg-sidebar/50`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base text-text-muted",style:d?{color:d}:void 0,children:"ok"===n?"check_circle":"error"===n?"cancel":"smart_toy"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"text-sm font-medium truncate",children:e}),(0,a.jsxs)("div",{className:"flex items-center gap-1 mt-1",children:[(0,a.jsx)("code",{className:"text-xs text-text-muted font-mono bg-sidebar px-1.5 py-0.5 rounded",children:t}),(0,a.jsxs)("div",{className:"relative group/btn",children:[(0,a.jsx)("button",{onClick:()=>i(t,`model-${e}`),className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:s===`model-${e}`?"check":"content_copy"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:s===`model-${e}`?"Copied!":"Copy"})]}),l&&(0,a.jsxs)("div",{className:"relative group/btn",children:[(0,a.jsx)("button",{onClick:l,disabled:o,className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",style:o?{animation:"spin 1s linear infinite"}:void 0,children:o?"progress_activity":"science"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:o?"Testing...":"Test"})]})]})]}),(0,a.jsx)("button",{onClick:r,className:"p-1 hover:bg-red-50 rounded text-red-500",title:"Remove model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"delete"})})]})}function R({providerStorageAlias:e,providerDisplayAlias:t,modelAliases:s,customModels:r,copied:l,onCopy:n,onDeleteAlias:o,onAddCustomModel:c,onDeleteCustomModel:m,onRefreshModels:u,connections:p,isAnthropic:x,disabledModelIds:h=[],onEnableModel:f}){let[b,g]=(0,i.useState)(""),[y,v]=(0,i.useState)(!1),[j,w]=(0,i.useState)(!1),[k,N]=(0,i.useState)(""),[S,$]=(0,i.useState)(null),[A,T]=(0,i.useState)({}),I=async t=>{if(!S){$(t);try{let s=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${e}/${t}`})}),a=await s.json();T(e=>({...e,[t]:a.ok?"ok":"error"}))}catch{T(e=>({...e,[t]:"error"}))}finally{$(null)}}},D=(0,C.Iz)(h,e),M=[...D],P=(0,C.R3)({customModels:r,modelAliases:s,providerAlias:e,type:"llm"}),U=P.filter(t=>!(0,C.uJ)(D,t.id,e)),z=async()=>{if(!b.trim()||y)return;let t=b.trim();if(U.some(e=>e.id===t))return void(0,E.s)("Model already exists for this provider.");v(!0);try{if((0,C.uJ)(D,t,e)){let e=await f?.(t);if(!1===e)throw Error("Failed to enable removed model")}await c(t),g("")}catch(e){(0,E.s)("Error adding model:",e)}finally{v(!1)}},q=async()=>{if(j)return;let t=p.find(e=>!1!==e.isActive);if(t){w(!0),N("");try{let s=await fetch(`/api/providers/${t.id}/models`),a=await s.json().catch(()=>({}));if(!s.ok)return void(0,E.s)(a.error||"Failed to import models");let i=a.models||[];if(0===i.length)return void(0,E.s)("No models returned from /models.");let r=new Set(P.map(e=>e.id)),l=[],n=new Set;for(let t of i){let s=String(t.id||t.name||t.model||"").trim();!s||r.has(s)||n.has(s)||(0,C.uJ)(D,s,e)||(n.add(s),l.push({providerAlias:e,id:s,type:"llm",name:t.display_name||t.displayName||t.name||s}))}if(0===l.length)return void N("All models already in list");let o=await fetch("/api/models/custom",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({models:l})}),d=await o.json().catch(()=>({}));if(!o.ok){let e=0;for(let t of l)await c(t.id),e+=1;N(e?`Imported ${e} model(s)`:"No new models were added");return}N(`Imported ${d.added??l.length} model(s)`),"function"==typeof u?await u():window.dispatchEvent(new CustomEvent("customModelChanged"))}catch(e){(0,E.s)("Error importing models:",e),(0,E.s)(e?.message||"Import failed")}finally{w(!1)}}},_=p.some(e=>!1!==e.isActive);return(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("p",{className:"text-sm text-text-muted",children:["Add ",x?"Anthropic":"OpenAI","-compatible models manually or import them from the /models endpoint."]}),(0,a.jsxs)("div",{className:"flex items-end gap-2 flex-wrap",children:[(0,a.jsxs)("div",{className:"flex-1 min-w-[240px]",children:[(0,a.jsx)("label",{htmlFor:"new-compatible-model-input",className:"text-xs text-text-muted mb-1 block",children:"Model ID"}),(0,a.jsx)("input",{id:"new-compatible-model-input",type:"text",value:b,onChange:e=>g(e.target.value),onKeyDown:e=>"Enter"===e.key&&z(),placeholder:x?"claude-3-opus-20240229":"gpt-4o",className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})]}),(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:z,disabled:!b.trim()||y,children:y?"Adding...":"Add"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"cloud_download",onClick:q,disabled:!_||j,children:j?"Importing...":"Import models"})]}),!_&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Add a connection to enable importing models."}),k&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:k}),U.length>0&&(0,a.jsx)("div",{className:"flex flex-col gap-3",children:U.map(({id:s,alias:i,source:r})=>(0,a.jsx)(O,{modelId:s,fullModel:`${t}/${s}`,copied:l,onCopy:n,onDeleteAlias:()=>"custom"===r?m(s):o(i),onTest:p.length>0?()=>I(s):void 0,testStatus:A[s],isTesting:S===s},`${r}-${e}/${s}`))}),M.length>0&&(0,a.jsxs)("details",{className:"rounded-lg border border-border bg-surface/30 p-3",children:[(0,a.jsxs)("summary",{className:"cursor-pointer text-sm font-medium text-text-main",children:["Removed models (",M.length,")"]}),(0,a.jsx)("p",{className:"mt-1 text-xs text-text-muted",children:"Enable a model to make it available for import and selection again."}),(0,a.jsx)("div",{className:"mt-3 flex max-h-56 flex-col gap-1.5 overflow-y-auto",children:M.map(e=>(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3 rounded border border-border bg-background px-2 py-1.5",children:[(0,a.jsx)("code",{className:"min-w-0 flex-1 truncate text-xs",title:e,children:e}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",onClick:()=>f?.(e),children:"Enable"})]},e))})]})]})}A().string.isRequired,A().string.isRequired,A().string,A().func.isRequired,A().func.isRequired,A().func,A().oneOf(["ok","error"]),A().bool,A().string.isRequired,A().object.isRequired,A().arrayOf(A().object),A().string,A().func.isRequired,A().func.isRequired,A().func.isRequired,A().func.isRequired,R.propTypes={providerStorageAlias:A().string.isRequired,providerDisplayAlias:A().string.isRequired,modelAliases:A().object.isRequired,customModels:A().arrayOf(A().object),copied:A().string,onCopy:A().func.isRequired,onDeleteAlias:A().func.isRequired,onAddCustomModel:A().func.isRequired,onDeleteCustomModel:A().func.isRequired,onRefreshModels:A().func,connections:A().arrayOf(A().shape({id:A().string,isActive:A().bool})).isRequired,isAnthropic:A().bool,disabledModelIds:A().arrayOf(A().string),onEnableModel:A().func};var I=s(70217);function D({until:e}){let[t,s]=(0,i.useState)("");return((0,i.useEffect)(()=>{let t=()=>{let t=new Date(e).getTime()-Date.now();if(t<=0)return void s("");let a=Math.floor(t/1e3);if(a<60)s(`${a}s`);else if(a<3600)s(`${Math.floor(a/60)}m ${a%60}s`);else{let e=Math.floor(a/3600),t=Math.floor(a%3600/60);s(`${e}h ${t}m`)}};t();let a=setInterval(t,1e3);return()=>clearInterval(a)},[e]),t)?(0,a.jsxs)("span",{className:"text-xs text-orange-500 font-mono",children:["⏱ ",t]}):null}function M({connection:e,isOAuth:t,isFirst:s,isLast:r,onMoveUp:l,onMoveDown:n,onToggleActive:o,onEdit:c,onDelete:m,onAllowlistHost:u=null,oneByOneStatus:p=null,autoPing:x=null}){let h=e.authType||(t?"oauth":"apikey"),f="oauth"===h,b="cookie"===h,g=e.name?.trim()||e.email?.trim()||e.displayName?.trim()||(f?"OAuth Account":b?"Cookie Account":"API Key"),y=e.name?.trim()&&e.email?.trim()&&e.name.trim()!==e.email.trim()?e.email.trim():e.name?.trim()&&e.displayName?.trim()&&e.name.trim()!==e.displayName.trim()?e.displayName.trim():null,v=/SSRF blocked|Blocked URL: (private IP|internal host)/i.test(e.lastError||""),j=(e=>{if(!e)return null;let t=String(e).trim();try{let e=t.match(/\{[\s\S]*\}$/);if(e){let s=JSON.parse(e[0]),a=s?.error?.message||s?.message||s?.error;"string"==typeof a&&a.trim()&&(t=a.trim())}}catch{}return(t=t.replace(/^\[\d+\]:\s*/,""),/not have a valid license|license of this product|license required/i.test(t))?{type:"license",title:"License Required",message:"No active Gemini Code Assist or Antigravity license found for this Google account. Visit antigravity.google to activate, or reconnect.",action:f?"reconnect":null}:/invalid_grant|token expired|credentials expired|expired or revoked|session expired/i.test(t)?{type:"auth",title:"Session Expired",message:"OAuth token expired or was revoked. Please reconnect.",action:f?"reconnect":null}:/rate limit|quota|429|resource has been exhausted/i.test(t)?{type:"quota",title:"Rate Limited",message:t||"Upstream rate limit reached.",action:null}:v?{type:"ssrf",title:"Network Guard",message:"SSRF guard blocked local/private IP address.",action:"allowlist"}:{type:"error",title:"Error",message:t,action:f?"reconnect":null}})(e.lastError),w=e.providerSpecificData?.connectionProxyEnabled===!0&&!!e.providerSpecificData?.connectionProxyUrl,k=w?`Proxy: ${e.providerSpecificData?.connectionProxyUrl}`:"",N=x?.provider==="codex"?"Auto-starts the next 5h Codex window after reset by sending a tiny gpt-5.5 request. Consumes a small amount of quota.":"When your 5h quota runs out, auto-sends a request the moment it resets so a new window starts right away.",C="";if(e.providerSpecificData?.connectionProxyUrl){let t=e.providerSpecificData?.connectionProxyUrl;try{let e=new URL(t);C=`${e.protocol}//${e.hostname}${e.port?`:${e.port}`:""}`}catch{C=t}}let S=e.providerSpecificData?.connectionNoProxy||"",$=w?"success":"default",[A,T]=(0,i.useState)(!1),E=Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>e).filter(e=>!!e).sort()[0]||null;(0,i.useEffect)(()=>{let t=()=>{T(!!Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>e).filter(e=>e&&new Date(e).getTime()>Date.now()).sort()[0])};t();let s=E?setInterval(t,1e3):null;return()=>{s&&clearInterval(s)}},[e,E]);let O="unavailable"!==e.testStatus||A?e.testStatus:"active",R=()=>p?"queued"===p.state?"queued":"testing"===p.state?"testing":"success"===p.state?"success":"failed"===p.state?p.error?`failed: ${p.error}`:"failed":null:null;return(0,a.jsx)("div",{className:`group flex min-w-0 flex-col gap-3 rounded-xl border border-border/60 bg-surface/40 p-3 transition-all hover:border-border hover:bg-surface/70 ${!1===e.isActive?"opacity-60":""}`,children:(0,a.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-2.5",children:[(0,a.jsxs)("div",{className:"flex shrink-0 flex-col",children:[(0,a.jsx)("button",{onClick:l,disabled:s,"aria-label":`Move ${g} up`,title:`Move ${g} up`,className:`p-0.5 rounded ${s?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm","aria-hidden":"true",children:"keyboard_arrow_up"})}),(0,a.jsx)("button",{onClick:n,disabled:r,"aria-label":`Move ${g} down`,title:`Move ${g} down`,className:`p-0.5 rounded ${r?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm","aria-hidden":"true",children:"keyboard_arrow_down"})})]}),(0,a.jsx)("div",{className:"flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-2 border border-border/40 text-text-muted",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]","aria-hidden":"true",children:b?"cookie":f?"lock":"key"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:"text-sm font-medium text-text-main truncate",children:g}),y&&(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:y})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[x&&(0,a.jsx)(d.m_,{text:N,children:(0,a.jsxs)("button",{onClick:()=>x.onToggle(!x.on),className:`flex items-center gap-1 rounded-lg px-2 py-1 text-xs transition-colors hover:bg-white/5 ${x.on?"text-primary bg-primary/10 font-medium":"text-text-muted hover:text-primary"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"bolt"}),(0,a.jsx)("span",{className:"hidden sm:inline text-xs",children:"Auto-ping"})]})}),(0,a.jsxs)("button",{onClick:c,className:"flex items-center gap-1 rounded-lg px-2.5 py-1 text-xs text-text-muted hover:bg-white/5 hover:text-primary transition-colors",title:"Edit connection",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"edit"}),(0,a.jsx)("span",{className:"hidden sm:inline",children:"Edit"})]}),(0,a.jsxs)("button",{onClick:m,className:"flex items-center gap-1 rounded-lg px-2.5 py-1 text-xs text-red-400 hover:bg-red-500/10 transition-colors",title:"Delete connection",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"delete"}),(0,a.jsx)("span",{className:"hidden sm:inline",children:"Delete"})]})]}),(0,a.jsx)("div",{className:"h-4 w-px bg-border/60 mx-1"}),(0,a.jsx)(d.lM,{size:"sm",checked:e.isActive??!0,onChange:o,title:e.isActive??!0?"Disable connection":"Enable connection"})]})]}),(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5 pl-0 sm:pl-10",children:[(0,a.jsx)(d.Ex,{variant:(0,I.g)(e.isActive,O),size:"sm",dot:!0,children:!1===e.isActive?"disabled":O||"Unknown"}),(0,a.jsx)(d.Ex,{variant:"default",size:"sm",children:f?"OAuth":b?"Cookie":"API Key"}),w&&(0,a.jsx)(d.Ex,{variant:$,size:"sm",children:"Proxy"}),A&&!1!==e.isActive&&(0,a.jsx)(D,{until:E}),(0,a.jsxs)("span",{className:"text-xs text-text-muted",children:["#",e.priority]}),e.globalPriority&&(0,a.jsxs)("span",{className:"text-xs text-text-muted",children:["Auto: ",e.globalPriority]}),R()&&(0,a.jsx)(d.Ex,{variant:p?"success"===p.state?"success":"failed"===p.state?"error":"testing"===p.state?"primary":"default":"default",size:"sm",children:R()})]}),j&&!1!==e.isActive&&(0,a.jsxs)("div",{className:"mt-1.5 flex min-w-0 flex-col sm:flex-row sm:items-center justify-between gap-2 rounded-lg border border-red-500/25 bg-red-500/8 px-3 py-2 text-xs text-red-600 dark:text-red-400 sm:ml-10",children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-start sm:items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-[16px] text-red-500 mt-0.5 sm:mt-0",children:"license"===j.type?"workspace_premium":"auth"===j.type?"key_off":"error"}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("span",{className:"font-semibold",children:[j.title,": "]}),(0,a.jsx)("span",{className:"break-words",children:j.message})]})]}),"reconnect"===j.action&&(0,a.jsxs)("button",{onClick:c,className:"inline-flex shrink-0 items-center justify-center gap-1 rounded-md bg-red-500/15 hover:bg-red-500/25 px-2.5 py-1 text-xs font-medium text-red-600 dark:text-red-300 transition-colors",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"refresh"}),"Reconnect"]}),"allowlist"===j.action&&u&&(0,a.jsxs)("button",{onClick:u,className:"inline-flex shrink-0 items-center justify-center gap-1 rounded-md border border-amber-500/40 bg-amber-500/10 px-2.5 py-1 text-xs font-medium text-amber-600 dark:text-amber-300 hover:bg-amber-500/20 transition-colors",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"verified_user"}),"Add to allow list"]})]}),w&&(0,a.jsxs)("div",{className:"mt-1 flex items-center gap-2 flex-wrap sm:ml-10",children:[(0,a.jsx)("span",{className:"max-w-full truncate text-[11px] text-text-muted sm:max-w-[420px]",title:k,children:k}),C&&(0,a.jsx)("code",{className:"max-w-full truncate rounded bg-black/5 px-1 py-0.5 font-mono text-[10px] text-text-muted dark:bg-white/5 sm:max-w-[260px]",children:C}),S&&(0,a.jsxs)("span",{className:"max-w-full truncate text-[11px] text-text-muted sm:max-w-[320px]",title:S,children:["no_proxy: ",S]})]})]})})}D.propTypes={until:A().string.isRequired},M.propTypes={connection:A().shape({id:A().string,name:A().string,email:A().string,displayName:A().string,modelLockUntil:A().string,testStatus:A().string,isActive:A().bool,lastError:A().string,priority:A().number,globalPriority:A().number,providerSpecificData:A().object}).isRequired,isOAuth:A().bool.isRequired,isFirst:A().bool.isRequired,isLast:A().bool.isRequired,onMoveUp:A().func.isRequired,onMoveDown:A().func.isRequired,onToggleActive:A().func.isRequired,onEdit:A().func.isRequired,onDelete:A().func.isRequired,onAllowlistHost:A().func,oneByOneStatus:A().shape({state:A().string,error:A().string}),autoPing:A().shape({on:A().bool,onToggle:A().func,provider:A().string})};let P=`name1|sk-key1
|
|
2
2
|
name2|sk-key2
|
|
3
|
-
sk-key-only-auto-named`;function U({isOpen:e,provider:t,providerName:s,isCompatible:r,isAnthropic:l,authType:n,authHint:o,website:m,error:u,onSave:p,onBulkDone:x,onClose:h}){let f="ollama-local"===t,b=t.startsWith("selfhosted-"),g="cookie"===n,y="xai"===t&&!g,v=g?"Cookie Value":"API Key",j=g?"grok-web"===t?"sso=xxxxx... or just the raw value":"eyJhbGciOi...":y?"xai-...":"",w="azure"===t,k="cloudflare-ai"===t,N=c.Q2?.[t]?.regions||null,C=c.Q2?.[t]?.defaultRegion||N?.[0]?.id||"",[S,$]=(0,i.useState)({name:"",apiKey:"",defaultModel:"",priority:1,ollamaHostUrl:"",baseUrl:""}),[A,T]=(0,i.useState)({azureEndpoint:"",apiVersion:"2024-10-01-preview",deployment:"",organization:""}),[O,R]=(0,i.useState)({accountId:""}),[E,I]=(0,i.useState)(C),[D,M]=(0,i.useState)(!1),[z,q]=(0,i.useState)(null),[_,F]=(0,i.useState)(!1),[J,L]=(0,i.useState)("single"),[K,B]=(0,i.useState)(""),[H,V]=(0,i.useState)(null),W=S.name.trim().length>0,G=S.apiKey.trim().length>0,Q=()=>b?{baseUrl:S.baseUrl.trim()}:f&&S.ollamaHostUrl.trim()?{baseUrl:S.ollamaHostUrl.trim()}:w?{azureEndpoint:A.azureEndpoint,apiVersion:A.apiVersion,deployment:A.deployment,organization:A.organization}:k?{accountId:O.accountId}:N&&E?{region:E}:void 0,Z=async()=>{let e=S.apiKey.trim();if(e){M(!0);try{let s=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:e,providerSpecificData:Q()})}),a=await s.json();q(a.valid?"success":"failed")}catch{q("failed")}finally{M(!1)}}},X=async()=>{if(!t)return;let e=S.name.trim(),s=S.apiKey.trim();if((f||b||s)&&(!b||S.baseUrl.trim())&&(f||e)&&(!r||S.defaultModel.trim())){F(!0);try{let a=!1;try{M(!0),q(null);let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:s,providerSpecificData:Q()})});a=!!(await e.json()).valid,q(a?"success":"failed")}catch{q("failed")}finally{M(!1)}await p({name:e||(f?"Ollama Local":""),apiKey:s,defaultModel:r?S.defaultModel.trim():void 0,priority:S.priority,testStatus:a?"active":"unknown",providerSpecificData:Q()})}finally{F(!1)}}},Y=async()=>{let e=K.split("\n").map(e=>e.trim()).filter(Boolean);if(!e.length)return;F(!0),V(null);let s=0,a=0;for(let i=0;i<e.length;i++){let r=e[i].split("|"),l=r.length>=2?r.slice(1).join("|").trim():r[0].trim();if(!l){a++;continue}let n=r.length>=2&&r[0].trim()||"Key",o=`${n} ${i+1}`;try{(await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:l,name:o,priority:1,testStatus:"unknown"})})).ok?s++:a++}catch{a++}}F(!1),V({success:s,failed:a}),s>0&&x&&x()};return t?(0,a.jsx)(d.aF,{isOpen:e,title:`Add ${s||t} ${v}`,onClose:h,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[!b&&(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{size:"sm",variant:"single"===J?"primary":"ghost",onClick:()=>{L("single"),V(null)},children:"Single"}),(0,a.jsx)(d.$n,{size:"sm",variant:"bulk"===J?"primary":"ghost",onClick:()=>{L("bulk"),V(null)},children:"Bulk Add"})]}),"bulk"===J&&!b&&(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["One key per line. Format: ",(0,a.jsx)("code",{children:"name|apiKey"})," or just ",(0,a.jsx)("code",{children:"apiKey"})," (auto-named by index)."]}),(0,a.jsx)("textarea",{className:"w-full rounded border border-accent/30 bg-sidebar p-2 text-sm font-mono resize-y min-h-[140px] focus:outline-none focus:ring-1 focus:ring-primary",placeholder:P,value:K,onChange:e=>B(e.target.value)}),H&&(0,a.jsxs)("div",{className:`text-sm font-medium ${H.failed>0?"text-yellow-400":"text-green-400"}`,children:["✓ ",H.success," added",H.failed>0?`, ✗ ${H.failed} failed`:""]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{onClick:Y,fullWidth:!0,disabled:_||!K.trim(),children:_?"Adding...":"Add All Keys"}),(0,a.jsx)(d.$n,{onClick:h,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),("single"===J||b)&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.pd,{label:"Name",value:S.name,onChange:e=>$({...S,name:e.target.value}),placeholder:f?"Ollama Local":"Production Key"}),b&&(0,a.jsx)(d.pd,{label:"Base URL",value:S.baseUrl,onChange:e=>$({...S,baseUrl:e.target.value}),placeholder:"selfhosted-stt"===t?"http://localhost:8080/v1/audio/transcriptions":"selfhosted-tts"===t?"http://localhost:8880":"http://localhost:8080/v1"}),f&&(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.pd,{label:"Ollama Host URL",value:S.ollamaHostUrl,onChange:e=>$({...S,ollamaHostUrl:e.target.value}),placeholder:"http://localhost:11434",className:"flex-1"}),(0,a.jsx)("div",{className:"pt-6",children:(0,a.jsx)(d.$n,{onClick:Z,disabled:D||_,variant:"secondary",children:D?"Checking...":"Check"})})]}),!f&&(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.pd,{label:b?"API Key (optional)":v,type:g?"text":"password",autoComplete:"off",value:S.apiKey,onChange:e=>$({...S,apiKey:e.target.value}),placeholder:j,className:"flex-1"}),!b&&(0,a.jsx)("div",{className:"pt-6",children:(0,a.jsx)(d.$n,{onClick:Z,disabled:!S.apiKey||D||_,variant:"secondary",children:D?"Checking...":"Check"})})]}),y&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Use a direct xAI API key from console.x.ai. This is separate from Grok Build OAuth."}),g&&o&&(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:[o,m&&(0,a.jsxs)(a.Fragment,{children:[" ",(0,a.jsxs)("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline",children:["Open ",m.replace(/^https?:\/\//,"")]})]})]}),N&&(0,a.jsx)(d.l6,{label:"Region",value:E,onChange:e=>I(e.target.value),options:N.map(e=>({value:e.id,label:e.label}))}),r&&(0,a.jsx)(d.pd,{label:"Default Model",value:S.defaultModel,onChange:e=>$({...S,defaultModel:e.target.value}),placeholder:l?"claude-3-5-sonnet-latest":"gpt-4o-mini"}),f&&(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["Leave blank to use ",(0,a.jsx)("code",{children:"http://localhost:11434"}),". For remote Ollama, enter the full host URL (e.g. ",(0,a.jsx)("code",{children:"http://192.168.1.10:11434"}),")."]}),z&&(0,a.jsx)(d.Ex,{variant:"success"===z?"success":"error",children:"success"===z?"Valid":"Invalid"}),u&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:u}),r&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Enter the model ID exactly as your compatible endpoint expects it. This model will be saved as the connection default."}),k&&(0,a.jsxs)("div",{className:"bg-sidebar/50 p-4 rounded-lg border border-accent/20",children:[(0,a.jsx)("h3",{className:"font-semibold mb-3 text-sm",children:"Cloudflare Workers AI"}),(0,a.jsx)(d.pd,{label:"Account ID",value:O.accountId,onChange:e=>R({...O,accountId:e.target.value}),placeholder:"abc123def456..."}),(0,a.jsxs)("p",{className:"text-xs text-text-muted mt-2",children:["Find your Account ID in the right sidebar of ",(0,a.jsx)("a",{href:"https://dash.cloudflare.com",target:"_blank",rel:"noopener noreferrer",className:"text-primary underline",children:"dash.cloudflare.com"})]})]}),w&&(0,a.jsxs)("div",{className:"bg-sidebar/50 p-4 rounded-lg border border-accent/20",children:[(0,a.jsx)("h3",{className:"font-semibold mb-3 text-sm",children:"Azure OpenAI Configuration"}),(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsx)(d.pd,{label:"Azure Endpoint",value:A.azureEndpoint,onChange:e=>T({...A,azureEndpoint:e.target.value}),placeholder:"https://your-resource.openai.azure.com"}),(0,a.jsx)(d.pd,{label:"Deployment Name",value:A.deployment,onChange:e=>T({...A,deployment:e.target.value}),placeholder:"gpt-4"}),(0,a.jsx)(d.pd,{label:"API Version",value:A.apiVersion,onChange:e=>T({...A,apiVersion:e.target.value}),placeholder:"2024-10-01-preview"}),(0,a.jsx)(d.pd,{label:"Organization",value:A.organization,onChange:e=>T({...A,organization:e.target.value}),placeholder:"Organization ID"})]})]}),(0,a.jsx)(d.pd,{label:"Priority",type:"number",min:1,value:S.priority,onChange:e=>$({...S,priority:Number.parseInt(e.target.value)||1})}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{onClick:X,fullWidth:!0,disabled:_||!f&&!b&&(!W||!G)||b&&(!W||!S.baseUrl.trim())||r&&!S.defaultModel.trim()||w&&(!A.azureEndpoint||!A.deployment||!A.organization)||k&&!O.accountId,children:_?"Saving...":"Save"}),(0,a.jsx)(d.$n,{onClick:h,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})}):null}function z({isOpen:e,node:t,onSave:s,onClose:r,isAnthropic:l}){let[n,o]=(0,i.useState)({name:"",apiType:"chat",baseUrl:"https://api.openai.com/v1"}),[c,m]=(0,i.useState)(!1),[u,p]=(0,i.useState)(""),[x,h]=(0,i.useState)(""),[f,b]=(0,i.useState)(!1),[g,y]=(0,i.useState)(null),v=function(e){try{return["http:","https:"].includes(new URL(e).protocol)}catch{return!1}}(n.baseUrl.trim());(0,i.useEffect)(()=>{t&&(o({name:t.name||"",apiType:t.apiType||"chat",baseUrl:t.baseUrl||(l?"https://api.anthropic.com/v1":"https://api.openai.com/v1")}),y(null),p(""),h(""))},[t,l]);let j=async()=>{if(n.name.trim()&&v){m(!0);try{let e={name:n.name.trim(),baseUrl:n.baseUrl.trim()};l||(e.apiType=n.apiType),await s(e)}finally{m(!1)}}},w=async()=>{b(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:n.baseUrl,apiKey:u,type:l?"anthropic-compatible":"openai-compatible",modelId:x.trim()||void 0})}),t=await e.json();y(t.valid?"success":"failed")}catch{y("failed")}finally{b(!1)}};return t?(0,a.jsx)(d.aF,{isOpen:e,title:`Edit ${l?"Anthropic":"OpenAI"} Compatible`,onClose:r,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)(d.pd,{label:"Name",value:n.name,onChange:e=>o({...n,name:e.target.value}),placeholder:`${l?"Anthropic":"OpenAI"} Compatible`,hint:"Friendly label for this provider."}),!l&&(0,a.jsx)(d.l6,{label:"API Type",options:[{value:"chat",label:"Chat Completions"},{value:"responses",label:"Responses API"}],value:n.apiType,onChange:e=>o({...n,apiType:e.target.value})}),(0,a.jsx)(d.pd,{label:"Base URL",value:n.baseUrl,onChange:e=>o({...n,baseUrl:e.target.value}),placeholder:l?"https://api.anthropic.com/v1":"https://api.openai.com/v1",hint:`Base URL ending in /v1 for your ${l?"Anthropic":"OpenAI"}-compatible API.`}),t.prefix?(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["Model IDs use prefix ",(0,a.jsx)("code",{className:"bg-sidebar px-1 rounded font-mono",children:t.prefix})," ","(auto-assigned; stable so combos keep working)."]}):null,(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.pd,{label:"API Key (for Check)",type:"password",autoComplete:"off",value:u,onChange:e=>p(e.target.value),className:"flex-1"}),(0,a.jsx)("div",{className:"pt-6",children:(0,a.jsx)(d.$n,{onClick:w,disabled:!u||f||!v,variant:"secondary",children:f?"Checking...":"Check"})})]}),(0,a.jsx)(d.pd,{label:"Model ID (optional)",value:x,onChange:e=>h(e.target.value),placeholder:"e.g. my-model-id",hint:"If the provider has no /models endpoint, test with a model ID."}),g&&(0,a.jsx)(d.Ex,{variant:"success"===g?"success":"error",children:"success"===g?"Valid":"Invalid"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{onClick:j,fullWidth:!0,disabled:!n.name.trim()||!v||c,children:c?"Saving...":"Save"}),(0,a.jsx)(d.$n,{onClick:r,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}function q({isOpen:e,providerAlias:t,providerDisplayAlias:s,onSave:r,onClose:l}){let[n,o]=(0,i.useState)(""),[c,m]=(0,i.useState)(null),[u,p]=(0,i.useState)(""),[x,h]=(0,i.useState)(!1);(0,i.useEffect)(()=>{e&&(o(""),m(null),p(""))},[e]);let f=e=>{let s=`${t}/`;return e.startsWith(s)?e.slice(s.length):e},b=async()=>{let e=f(n.trim());if(e){m("testing"),p("");try{let s=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${t}/${e}`})}),a=await s.json();m(a.ok?"ok":"error"),p(a.error||"")}catch(e){m("error"),p(e.message)}}},g=async()=>{let e=f(n.trim());if(e&&!x){h(!0);try{await r(e)}finally{h(!1)}}};return(0,a.jsx)(d.aF,{isOpen:e,onClose:l,title:"Add Custom Model",children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"text-sm font-medium mb-1.5 block",children:"Model ID"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)("input",{type:"text",value:n,onChange:e=>{o(e.target.value),m(null),p("")},onKeyDown:e=>{"Enter"===e.key&&b()},placeholder:"e.g. claude-opus-4-5",className:"flex-1 px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",autoFocus:!0}),(0,a.jsx)(d.$n,{variant:"secondary",icon:"science",loading:"testing"===c,onClick:b,disabled:!n.trim()||"testing"===c,children:"testing"===c?"Testing...":"Test"})]}),(0,a.jsxs)("p",{className:"text-xs text-text-muted mt-1",children:["Sent to provider as: ",(0,a.jsx)("code",{className:"font-mono bg-sidebar px-1 rounded",children:f(n.trim())||"model-id"})]})]}),"ok"===c&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-sm text-green-600",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base",children:"check_circle"}),"Model is reachable"]}),"error"===c&&(0,a.jsxs)("div",{className:"flex items-start gap-2 text-sm text-red-500",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base shrink-0",children:"cancel"}),(0,a.jsx)("span",{children:u||"Model not reachable"})]}),(0,a.jsxs)("div",{className:"flex gap-2 pt-1",children:[(0,a.jsx)(d.$n,{onClick:l,variant:"ghost",fullWidth:!0,size:"sm",children:"Cancel"}),(0,a.jsx)(d.$n,{onClick:g,fullWidth:!0,size:"sm",disabled:!n.trim()||x,children:x?"Adding...":"Add Model"})]})]})})}U.propTypes={isOpen:A().bool.isRequired,provider:A().string,providerName:A().string,isCompatible:A().bool,isAnthropic:A().bool,authType:A().string,authHint:A().string,website:A().string,error:A().string,onSave:A().func.isRequired,onBulkDone:A().func,onClose:A().func.isRequired},z.propTypes={isOpen:A().bool.isRequired,node:A().shape({id:A().string,name:A().string,prefix:A().string,apiType:A().string,baseUrl:A().string}),onSave:A().func.isRequired,onClose:A().func.isRequired,isAnthropic:A().bool},q.propTypes={isOpen:A().bool.isRequired,providerAlias:A().string.isRequired,providerDisplayAlias:A().string.isRequired,onSave:A().func.isRequired,onClose:A().func.isRequired};let _=`[
|
|
3
|
+
sk-key-only-auto-named`;function U({isOpen:e,provider:t,providerName:s,isCompatible:r,isAnthropic:l,authType:n,authHint:o,website:m,error:u,onSave:p,onBulkDone:x,onClose:h}){let f="ollama-local"===t,b=t.startsWith("selfhosted-"),g="cookie"===n,y="xai"===t&&!g,v=g?"Cookie Value":"API Key",j=g?"grok-web"===t?"sso=xxxxx... or just the raw value":"eyJhbGciOi...":y?"xai-...":"",w="azure"===t,k="cloudflare-ai"===t,N=c.Q2?.[t]?.regions||null,C=c.Q2?.[t]?.defaultRegion||N?.[0]?.id||"",[S,$]=(0,i.useState)({name:"",apiKey:"",defaultModel:"",priority:1,ollamaHostUrl:"",baseUrl:""}),[A,T]=(0,i.useState)({azureEndpoint:"",apiVersion:"2024-10-01-preview",deployment:"",organization:""}),[E,O]=(0,i.useState)({accountId:""}),[R,I]=(0,i.useState)(C),[D,M]=(0,i.useState)(!1),[z,q]=(0,i.useState)(null),[_,F]=(0,i.useState)(!1),[J,L]=(0,i.useState)("single"),[K,B]=(0,i.useState)(""),[H,V]=(0,i.useState)(null),W=S.name.trim().length>0,G=S.apiKey.trim().length>0,Q=()=>b?{baseUrl:S.baseUrl.trim()}:f&&S.ollamaHostUrl.trim()?{baseUrl:S.ollamaHostUrl.trim()}:w?{azureEndpoint:A.azureEndpoint,apiVersion:A.apiVersion,deployment:A.deployment,organization:A.organization}:k?{accountId:E.accountId}:N&&R?{region:R}:void 0,Z=async()=>{let e=S.apiKey.trim();if(e){M(!0);try{let s=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:e,providerSpecificData:Q()})}),a=await s.json();q(a.valid?"success":"failed")}catch{q("failed")}finally{M(!1)}}},X=async()=>{if(!t)return;let e=S.name.trim(),s=S.apiKey.trim();if((f||b||s)&&(!b||S.baseUrl.trim())&&(f||e)&&(!r||S.defaultModel.trim())){F(!0);try{let a=!1;try{M(!0),q(null);let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:s,providerSpecificData:Q()})});a=!!(await e.json()).valid,q(a?"success":"failed")}catch{q("failed")}finally{M(!1)}await p({name:e||(f?"Ollama Local":""),apiKey:s,defaultModel:r?S.defaultModel.trim():void 0,priority:S.priority,testStatus:a?"active":"unknown",providerSpecificData:Q()})}finally{F(!1)}}},Y=async()=>{let e=K.split("\n").map(e=>e.trim()).filter(Boolean);if(!e.length)return;F(!0),V(null);let s=0,a=0;for(let i=0;i<e.length;i++){let r=e[i].split("|"),l=r.length>=2?r.slice(1).join("|").trim():r[0].trim();if(!l){a++;continue}let n=r.length>=2&&r[0].trim()||"Key",o=`${n} ${i+1}`;try{(await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:l,name:o,priority:1,testStatus:"unknown"})})).ok?s++:a++}catch{a++}}F(!1),V({success:s,failed:a}),s>0&&x&&x()};return t?(0,a.jsx)(d.aF,{isOpen:e,title:`Add ${s||t} ${v}`,onClose:h,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[!b&&(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{size:"sm",variant:"single"===J?"primary":"ghost",onClick:()=>{L("single"),V(null)},children:"Single"}),(0,a.jsx)(d.$n,{size:"sm",variant:"bulk"===J?"primary":"ghost",onClick:()=>{L("bulk"),V(null)},children:"Bulk Add"})]}),"bulk"===J&&!b&&(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["One key per line. Format: ",(0,a.jsx)("code",{children:"name|apiKey"})," or just ",(0,a.jsx)("code",{children:"apiKey"})," (auto-named by index)."]}),(0,a.jsx)("textarea",{className:"w-full rounded border border-accent/30 bg-sidebar p-2 text-sm font-mono resize-y min-h-[140px] focus:outline-none focus:ring-1 focus:ring-primary",placeholder:P,value:K,onChange:e=>B(e.target.value)}),H&&(0,a.jsxs)("div",{className:`text-sm font-medium ${H.failed>0?"text-yellow-400":"text-green-400"}`,children:["✓ ",H.success," added",H.failed>0?`, ✗ ${H.failed} failed`:""]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{onClick:Y,fullWidth:!0,disabled:_||!K.trim(),children:_?"Adding...":"Add All Keys"}),(0,a.jsx)(d.$n,{onClick:h,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),("single"===J||b)&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.pd,{label:"Name",value:S.name,onChange:e=>$({...S,name:e.target.value}),placeholder:f?"Ollama Local":"Production Key"}),b&&(0,a.jsx)(d.pd,{label:"Base URL",value:S.baseUrl,onChange:e=>$({...S,baseUrl:e.target.value}),placeholder:"selfhosted-stt"===t?"http://localhost:8080/v1/audio/transcriptions":"selfhosted-tts"===t?"http://localhost:8880":"http://localhost:8080/v1"}),f&&(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.pd,{label:"Ollama Host URL",value:S.ollamaHostUrl,onChange:e=>$({...S,ollamaHostUrl:e.target.value}),placeholder:"http://localhost:11434",className:"flex-1"}),(0,a.jsx)("div",{className:"pt-6",children:(0,a.jsx)(d.$n,{onClick:Z,disabled:D||_,variant:"secondary",children:D?"Checking...":"Check"})})]}),!f&&(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.pd,{label:b?"API Key (optional)":v,type:g?"text":"password",autoComplete:"off",value:S.apiKey,onChange:e=>$({...S,apiKey:e.target.value}),placeholder:j,className:"flex-1"}),!b&&(0,a.jsx)("div",{className:"pt-6",children:(0,a.jsx)(d.$n,{onClick:Z,disabled:!S.apiKey||D||_,variant:"secondary",children:D?"Checking...":"Check"})})]}),y&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Use a direct xAI API key from console.x.ai. This is separate from Grok Build OAuth."}),g&&o&&(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:[o,m&&(0,a.jsxs)(a.Fragment,{children:[" ",(0,a.jsxs)("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline",children:["Open ",m.replace(/^https?:\/\//,"")]})]})]}),N&&(0,a.jsx)(d.l6,{label:"Region",value:R,onChange:e=>I(e.target.value),options:N.map(e=>({value:e.id,label:e.label}))}),r&&(0,a.jsx)(d.pd,{label:"Default Model",value:S.defaultModel,onChange:e=>$({...S,defaultModel:e.target.value}),placeholder:l?"claude-3-5-sonnet-latest":"gpt-4o-mini"}),f&&(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["Leave blank to use ",(0,a.jsx)("code",{children:"http://localhost:11434"}),". For remote Ollama, enter the full host URL (e.g. ",(0,a.jsx)("code",{children:"http://192.168.1.10:11434"}),")."]}),z&&(0,a.jsx)(d.Ex,{variant:"success"===z?"success":"error",children:"success"===z?"Valid":"Invalid"}),u&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:u}),r&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Enter the model ID exactly as your compatible endpoint expects it. This model will be saved as the connection default."}),k&&(0,a.jsxs)("div",{className:"bg-sidebar/50 p-4 rounded-lg border border-accent/20",children:[(0,a.jsx)("h3",{className:"font-semibold mb-3 text-sm",children:"Cloudflare Workers AI"}),(0,a.jsx)(d.pd,{label:"Account ID",value:E.accountId,onChange:e=>O({...E,accountId:e.target.value}),placeholder:"abc123def456..."}),(0,a.jsxs)("p",{className:"text-xs text-text-muted mt-2",children:["Find your Account ID in the right sidebar of ",(0,a.jsx)("a",{href:"https://dash.cloudflare.com",target:"_blank",rel:"noopener noreferrer",className:"text-primary underline",children:"dash.cloudflare.com"})]})]}),w&&(0,a.jsxs)("div",{className:"bg-sidebar/50 p-4 rounded-lg border border-accent/20",children:[(0,a.jsx)("h3",{className:"font-semibold mb-3 text-sm",children:"Azure OpenAI Configuration"}),(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsx)(d.pd,{label:"Azure Endpoint",value:A.azureEndpoint,onChange:e=>T({...A,azureEndpoint:e.target.value}),placeholder:"https://your-resource.openai.azure.com"}),(0,a.jsx)(d.pd,{label:"Deployment Name",value:A.deployment,onChange:e=>T({...A,deployment:e.target.value}),placeholder:"gpt-4"}),(0,a.jsx)(d.pd,{label:"API Version",value:A.apiVersion,onChange:e=>T({...A,apiVersion:e.target.value}),placeholder:"2024-10-01-preview"}),(0,a.jsx)(d.pd,{label:"Organization",value:A.organization,onChange:e=>T({...A,organization:e.target.value}),placeholder:"Organization ID"})]})]}),(0,a.jsx)(d.pd,{label:"Priority",type:"number",min:1,value:S.priority,onChange:e=>$({...S,priority:Number.parseInt(e.target.value)||1})}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{onClick:X,fullWidth:!0,disabled:_||!f&&!b&&(!W||!G)||b&&(!W||!S.baseUrl.trim())||r&&!S.defaultModel.trim()||w&&(!A.azureEndpoint||!A.deployment||!A.organization)||k&&!E.accountId,children:_?"Saving...":"Save"}),(0,a.jsx)(d.$n,{onClick:h,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})}):null}function z({isOpen:e,node:t,onSave:s,onClose:r,isAnthropic:l}){let[n,o]=(0,i.useState)({name:"",apiType:"chat",baseUrl:"https://api.openai.com/v1"}),[c,m]=(0,i.useState)(!1),[u,p]=(0,i.useState)(""),[x,h]=(0,i.useState)(""),[f,b]=(0,i.useState)(!1),[g,y]=(0,i.useState)(null),v=function(e){try{return["http:","https:"].includes(new URL(e).protocol)}catch{return!1}}(n.baseUrl.trim());(0,i.useEffect)(()=>{t&&(o({name:t.name||"",apiType:t.apiType||"chat",baseUrl:t.baseUrl||(l?"https://api.anthropic.com/v1":"https://api.openai.com/v1")}),y(null),p(""),h(""))},[t,l]);let j=async()=>{if(n.name.trim()&&v){m(!0);try{let e={name:n.name.trim(),baseUrl:n.baseUrl.trim()};l||(e.apiType=n.apiType),await s(e)}finally{m(!1)}}},w=async()=>{b(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:n.baseUrl,apiKey:u,type:l?"anthropic-compatible":"openai-compatible",modelId:x.trim()||void 0})}),t=await e.json();y(t.valid?"success":"failed")}catch{y("failed")}finally{b(!1)}};return t?(0,a.jsx)(d.aF,{isOpen:e,title:`Edit ${l?"Anthropic":"OpenAI"} Compatible`,onClose:r,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)(d.pd,{label:"Name",value:n.name,onChange:e=>o({...n,name:e.target.value}),placeholder:`${l?"Anthropic":"OpenAI"} Compatible`,hint:"Friendly label for this provider."}),!l&&(0,a.jsx)(d.l6,{label:"API Type",options:[{value:"chat",label:"Chat Completions"},{value:"responses",label:"Responses API"}],value:n.apiType,onChange:e=>o({...n,apiType:e.target.value})}),(0,a.jsx)(d.pd,{label:"Base URL",value:n.baseUrl,onChange:e=>o({...n,baseUrl:e.target.value}),placeholder:l?"https://api.anthropic.com/v1":"https://api.openai.com/v1",hint:`Base URL ending in /v1 for your ${l?"Anthropic":"OpenAI"}-compatible API.`}),t.prefix?(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["Model IDs use prefix ",(0,a.jsx)("code",{className:"bg-sidebar px-1 rounded font-mono",children:t.prefix})," ","(auto-assigned; stable so combos keep working)."]}):null,(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.pd,{label:"API Key (for Check)",type:"password",autoComplete:"off",value:u,onChange:e=>p(e.target.value),className:"flex-1"}),(0,a.jsx)("div",{className:"pt-6",children:(0,a.jsx)(d.$n,{onClick:w,disabled:!u||f||!v,variant:"secondary",children:f?"Checking...":"Check"})})]}),(0,a.jsx)(d.pd,{label:"Model ID (optional)",value:x,onChange:e=>h(e.target.value),placeholder:"e.g. my-model-id",hint:"If the provider has no /models endpoint, test with a model ID."}),g&&(0,a.jsx)(d.Ex,{variant:"success"===g?"success":"error",children:"success"===g?"Valid":"Invalid"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{onClick:j,fullWidth:!0,disabled:!n.name.trim()||!v||c,children:c?"Saving...":"Save"}),(0,a.jsx)(d.$n,{onClick:r,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}function q({isOpen:e,providerAlias:t,providerDisplayAlias:s,onSave:r,onClose:l}){let[n,o]=(0,i.useState)(""),[c,m]=(0,i.useState)(null),[u,p]=(0,i.useState)(""),[x,h]=(0,i.useState)(!1);(0,i.useEffect)(()=>{e&&(o(""),m(null),p(""))},[e]);let f=e=>{let s=`${t}/`;return e.startsWith(s)?e.slice(s.length):e},b=async()=>{let e=f(n.trim());if(e){m("testing"),p("");try{let s=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${t}/${e}`})}),a=await s.json();m(a.ok?"ok":"error"),p(a.error||"")}catch(e){m("error"),p(e.message)}}},g=async()=>{let e=f(n.trim());if(e&&!x){h(!0);try{await r(e)}finally{h(!1)}}};return(0,a.jsx)(d.aF,{isOpen:e,onClose:l,title:"Add Custom Model",children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"text-sm font-medium mb-1.5 block",children:"Model ID"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)("input",{type:"text",value:n,onChange:e=>{o(e.target.value),m(null),p("")},onKeyDown:e=>{"Enter"===e.key&&b()},placeholder:"e.g. claude-opus-4-5",className:"flex-1 px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",autoFocus:!0}),(0,a.jsx)(d.$n,{variant:"secondary",icon:"science",loading:"testing"===c,onClick:b,disabled:!n.trim()||"testing"===c,children:"testing"===c?"Testing...":"Test"})]}),(0,a.jsxs)("p",{className:"text-xs text-text-muted mt-1",children:["Sent to provider as: ",(0,a.jsx)("code",{className:"font-mono bg-sidebar px-1 rounded",children:f(n.trim())||"model-id"})]})]}),"ok"===c&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-sm text-green-600",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base",children:"check_circle"}),"Model is reachable"]}),"error"===c&&(0,a.jsxs)("div",{className:"flex items-start gap-2 text-sm text-red-500",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base shrink-0",children:"cancel"}),(0,a.jsx)("span",{children:u||"Model not reachable"})]}),(0,a.jsxs)("div",{className:"flex gap-2 pt-1",children:[(0,a.jsx)(d.$n,{onClick:l,variant:"ghost",fullWidth:!0,size:"sm",children:"Cancel"}),(0,a.jsx)(d.$n,{onClick:g,fullWidth:!0,size:"sm",disabled:!n.trim()||x,children:x?"Adding...":"Add Model"})]})]})})}U.propTypes={isOpen:A().bool.isRequired,provider:A().string,providerName:A().string,isCompatible:A().bool,isAnthropic:A().bool,authType:A().string,authHint:A().string,website:A().string,error:A().string,onSave:A().func.isRequired,onBulkDone:A().func,onClose:A().func.isRequired},z.propTypes={isOpen:A().bool.isRequired,node:A().shape({id:A().string,name:A().string,prefix:A().string,apiType:A().string,baseUrl:A().string}),onSave:A().func.isRequired,onClose:A().func.isRequired,isAnthropic:A().bool},q.propTypes={isOpen:A().bool.isRequired,providerAlias:A().string.isRequired,providerDisplayAlias:A().string.isRequired,onSave:A().func.isRequired,onClose:A().func.isRequired};let _=`[
|
|
4
4
|
{
|
|
5
5
|
"accessToken": "eyJhbGc...",
|
|
6
6
|
"refreshToken": "rt_...",
|
|
7
7
|
"idToken": "eyJhbGc...",
|
|
8
8
|
"email": "user@example.com"
|
|
9
9
|
}
|
|
10
|
-
]`;function F({isOpen:e,onClose:t,onSuccess:s}){let[r,l]=(0,i.useState)(""),[n,o]=(0,i.useState)(!1),[c,m]=(0,i.useState)(""),[u,p]=(0,i.useState)(null),x=()=>{n||(l(""),m(""),p(null),t())},h=async()=>{var e;let t;m(""),p(null);let a=r.trim();if(!a)return;try{t=JSON.parse(a)}catch(e){m(`${(0,w.Tl)("Invalid JSON")}: ${e.message}`);return}let i=Array.isArray(e=t)?e:e&&"object"==typeof e?Array.isArray(e.accounts)?e.accounts:[e]:null;if(!i||0===i.length)return void m((0,w.Tl)("No accounts found in input"));o(!0);try{let e=await fetch("/api/oauth/codex/bulk-import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({accounts:i})}),t=await e.json();if(!e.ok)return void m(t?.error||`Request failed: ${e.status}`);p(t),t.success>0&&"function"==typeof s&&s()}catch(e){m(e.message||(0,w.Tl)("Request failed"))}finally{o(!1)}},f=u?.results?.filter(e=>!e.ok)||[];return(0,a.jsx)(d.aF,{isOpen:e,title:(0,w.Tl)("Bulk Add Codex Accounts"),onClose:x,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)("p",{className:"text-xs text-text-muted",children:(0,w.Tl)("Paste an array of codex account JSON objects. Each must include accessToken (and ideally refreshToken, idToken).")}),(0,a.jsx)("textarea",{className:"w-full rounded border border-accent/30 bg-sidebar p-2 text-sm font-mono resize-y min-h-[240px] focus:outline-none focus:ring-1 focus:ring-primary",placeholder:_,value:r,onChange:e=>l(e.target.value),disabled:n}),c&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:c}),u&&(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:`text-sm font-medium ${u.failed>0?"text-yellow-400":"text-green-400"}`,children:["✓ ",u.success," ",(0,w.Tl)("added"),u.failed>0?`, ✗ ${u.failed} ${(0,w.Tl)("failed")}`:""]}),f.length>0&&(0,a.jsx)("ul",{className:"rounded border border-accent/20 bg-sidebar/50 p-2 text-xs font-mono max-h-40 overflow-y-auto",children:f.map(e=>(0,a.jsxs)("li",{className:"text-red-400",children:["[",e.index,"] ",e.error]},e.index))})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{onClick:h,fullWidth:!0,disabled:n||!r.trim(),children:n?(0,w.Tl)("Importing..."):(0,w.Tl)("Import All")}),(0,a.jsx)(d.$n,{onClick:x,variant:"ghost",fullWidth:!0,disabled:n,children:(0,w.Tl)("Close")})]})]})})}F.propTypes={isOpen:A().bool.isRequired,onClose:A().func.isRequired,onSuccess:A().func};var J=s(77251);function L({connectionId:e,providerAlias:t,models:s,jobSnapshot:r,onComplete:l,onStarted:n,onClose:o}){let[c,m]=(0,i.useState)(4),[u,p]=(0,i.useState)(50),[x,h]=(0,i.useState)(Math.round(20)),[f,b]=(0,i.useState)(!1),[g,y]=(0,i.useState)(null),[v,j]=(0,i.useState)(null),[w,k]=(0,i.useState)(""),[N,C]=(0,i.useState)(""),[S,$]=(0,i.useState)(""),A=(0,i.useRef)({onComplete:l,onStarted:n}),T=(0,i.useRef)(null),O=(0,i.useRef)(e),R=(0,i.useRef)(null),E=s?.length||0,I=(0,i.useMemo)(()=>`max concurrency 16 \xb7 batch 200 \xb7 timeout ${60}s`,[]);function D(e){if(e){if("idle"===e.status){R.current=null,b(!1);return}if(y({done:e.done||0,total:e.total||0,ok:e.ok||0,dead:e.dead||0,retryable:e.retryable||0,skippedDead:e.skippedDead||0,skippedDup:e.skippedDup||0}),"running"===e.status&&(R.current=e.connectionId||O.current,T.current=null,b(!0)),e.currentRange&&C(`Probing ${e.currentRange.from}–${e.currentRange.to} of ${e.total}…`),e.error&&k(e.error),"done"===e.status||"cancelled"===e.status||"error"===e.status){R.current=null,b(!1);let t={ok:e.ok||0,dead:e.dead||0,retryable:e.retryable||0,tested:e.done||0,skippedDead:e.skippedDead||0,skippedDup:e.skippedDup||0,cancelled:"cancelled"===e.status,retryableAuthOnly:!0===e.retryableAuthOnly};j(t),C("cancelled"===e.status?"Cancelled (partial results saved).":"error"===e.status?"Stopped.":"Done.");let s=`${e.startedAt||"unknown"}:${e.status}`;T.current!==s&&(T.current=s,A.current.onComplete?.(t))}}}async function M(){if(f||!e||0===E)return;b(!0),k(""),j(null),C("Starting…");let a={concurrency:Math.max(1,Math.min(16,Number(c)||4)),batchSize:Math.max(1,Math.min(200,Number(u)||50)),timeoutMs:Math.max(1e3,Math.min(6e4,1e3*(Number(x)||20)))};R.current=e;try{let i=await fetch(`/api/providers/${e}/model-probes/verify/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({models:s,providerAlias:t,...a,timeoutMs:a.timeoutMs})}),r=await i.json().catch(()=>({}));if(O.current!==e){R.current=null,b(!1);return}if(!i.ok){R.current=null,k(r.error||"Failed to start"),b(!1);return}A.current.onStarted?.(r),D(r),"running"!==r.status&&b(!1)}catch(e){R.current=null,k(e?.message||"Verify failed"),b(!1)}}async function P(){let t=R.current||e;await fetch(`/api/providers/${t}/model-probes/verify/cancel`,{method:"POST"}).catch(()=>{})}async function U(s){if(!e)return;let a="retryable"===s,i=a?Number(v?.retryable||0):Number(v?.dead||0);if(!a||await (0,J.l)({title:"Remove retry-failed models?",message:`Review ${i} retryable result(s) and remove the eligible models? Timeouts, rate limits, network failures, and provider errors may be temporary. Credential failures are kept. Removed models can be enabled or imported again later.`,confirmText:"Remove eligible"})){$(s),k(""),C(`Removing ${a?"retry-failed":"dead"} models…`);try{let i=await fetch(`/api/providers/${e}/model-probes/remove-unavailable`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:t,kind:"llm",status:s})}),r=await i.json().catch(()=>({}));if(!i.ok)return void k(r.error||"Remove failed");let l=Number(r.removed||0),n=Number(r.kept||0),o=v?{...v,[a?"retryable":"dead"]:n,...a?{retryableAuthOnly:n>0}:{}}:v;j(o),C(`Removed ${l} ${a?"retry-failed":"dead"} model(s).`+(n>0?` Kept ${n} credential failure(s).`:"")),A.current.onComplete?.({...o||{},removed:l,kept:n,removedStatus:s})}catch(e){k(e?.message||"Remove failed")}finally{$("")}}}async function z(){if(!e)return;let t=await fetch(`/api/providers/${e}/model-probes/cache`,{method:"DELETE"}),s=await t.json().catch(()=>({}));t.ok?(C(`Cleared probe cache (${s.cleared||0} rows). Next verify will re-test everything.`),j(null),y(null),A.current.onComplete?.({cacheCleared:!0,cleared:s.cleared||0})):k(s.error||"Clear cache failed")}(0,i.useEffect)(()=>{A.current={onComplete:l,onStarted:n},O.current=e}),(0,i.useEffect)(()=>{D(r)},[r]);let q=g?.total?Math.min(100,Math.round(g.done/g.total*100)):0;return(0,a.jsxs)("div",{className:"mb-4 rounded-lg border border-border bg-sidebar/40 p-3 space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"text-sm font-semibold text-text-main",children:"Verify models"}),(0,a.jsxs)("p",{className:"text-[11px] text-text-muted mt-0.5",children:["Batch-ping availability and latency. Dead = permanently unavailable (missing, blocked, or deprecated) and can be removed; retry = transient (timeout/429/5xx). Known-dead models are skipped until you Clear cache. Caps: ",I,"."]})]}),o&&(0,a.jsx)("button",{type:"button",onClick:o,className:"p-1 text-text-muted hover:text-text-main rounded",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"close"})})]}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-3 items-end",children:[(0,a.jsxs)("label",{className:"text-xs text-text-muted",children:["Concurrency",(0,a.jsx)("input",{type:"number",min:1,max:16,value:c,disabled:f,onChange:e=>m(e.target.value),className:"mt-1 block w-20 rounded-md border border-border bg-background px-2 py-1 text-xs"})]}),(0,a.jsxs)("label",{className:"text-xs text-text-muted",children:["Batch size",(0,a.jsx)("input",{type:"number",min:1,max:200,value:u,disabled:f,onChange:e=>p(e.target.value),className:"mt-1 block w-20 rounded-md border border-border bg-background px-2 py-1 text-xs"})]}),(0,a.jsxs)("label",{className:"text-xs text-text-muted",children:["Timeout (s)",(0,a.jsx)("input",{type:"number",min:1,max:60,value:x,disabled:f,onChange:e=>h(e.target.value),className:"mt-1 block w-20 rounded-md border border-border bg-background px-2 py-1 text-xs"})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[f?(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"stop",onClick:P,children:"Cancel"}):(0,a.jsx)(d.$n,{size:"sm",icon:"science",onClick:M,disabled:!e||0===E,children:"Start"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"delete_sweep",onClick:z,disabled:f,children:"Clear cache"})]})]}),g&&(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)("div",{className:"h-1.5 w-full rounded-full bg-border overflow-hidden",children:(0,a.jsx)("div",{className:"h-full bg-primary transition-all",style:{width:`${q}%`}})}),(0,a.jsxs)("p",{className:"text-[11px] text-text-muted flex flex-wrap gap-x-2",children:[(0,a.jsxs)("span",{title:"Models probed this run",children:[g.done,"/",g.total," tested"]}),(0,a.jsxs)("span",{title:"Reachable",children:["\xb7 ok ",g.ok]}),(0,a.jsxs)("span",{title:"Permanently unavailable this run (missing, blocked, or deprecated)",children:["\xb7 dead ",g.dead]}),(0,a.jsxs)("span",{title:"Transient failure this run (timeout / 429 / 5xx / network); re-testable",children:["\xb7 retry ",g.retryable]}),g.skippedDead?(0,a.jsxs)("span",{title:"Not probed — cache already marks them dead. Clear cache to re-test.",children:["\xb7 skipped known-dead ",g.skippedDead]}):null,g.skippedDup?(0,a.jsxs)("span",{title:"Duplicate ids collapsed",children:["\xb7 dupes ",g.skippedDup]}):null]})]}),N&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:N}),w&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:w}),v&&(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:[(0,a.jsxs)("span",{className:"text-xs text-text-main",children:["Summary: ",v.ok," ok \xb7 ",v.dead," dead \xb7 ",v.retryable," retry",v.skippedDead?` \xb7 ${v.skippedDead} skipped known-dead`:"",v.cancelled?" \xb7 cancelled":""]}),v.dead>0&&(0,a.jsxs)(d.$n,{size:"sm",variant:"primary",icon:"delete_sweep",onClick:()=>U("dead"),disabled:f||!!S,loading:"dead"===S,children:["Remove ",v.dead," dead"]}),v.retryable>0&&!v.retryableAuthOnly&&(0,a.jsxs)(d.$n,{size:"sm",variant:"danger",icon:"delete_sweep",onClick:()=>U("retryable"),disabled:f||!!S,loading:"retryable"===S,children:["Remove ",v.retryable," retry failures"]})]})]})}L.propTypes={connectionId:A().string,providerAlias:A().string,models:A().arrayOf(A().object),jobSnapshot:A().object,onComplete:A().func,onStarted:A().func,onClose:A().func};var K=s(36861),B=s(53578);let H={claude:"claudeAutoPing",codex:"codexAutoPing"};function V(){let e,t,s,l=(0,r.useParams)(),u=(0,r.useRouter)(),p=l.id,{getCaps:x}=(0,j.y)(),[h,f]=(0,i.useState)([]),[b,g]=(0,i.useState)([]),[k,$]=(0,i.useState)(!0),[A,R]=(0,i.useState)(null),[I,D]=(0,i.useState)(!1),[P,_]=(0,i.useState)(!1),[J,V]=(0,i.useState)(!1),[W,G]=(0,i.useState)(""),[Q,Z]=(0,i.useState)(!1),[X,Y]=(0,i.useState)(!1),[ee,et]=(0,i.useState)(!1),[es,ea]=(0,i.useState)(null),[ei,er]=(0,i.useState)({}),[el,en]=(0,i.useState)([]),[eo,ed]=(0,i.useState)(!1),[ec,em]=(0,i.useState)({}),[eu,ep]=(0,i.useState)(""),[ex,eh]=(0,i.useState)(()=>new Set),[ef,eb]=(0,i.useState)(!1),[eg,ey]=(0,i.useState)(null),[ev,ej]=(0,i.useState)(""),[ew,ek]=(0,i.useState)(!1),[eN,eC]=(0,i.useState)("30"),[eS,e$]=(0,i.useState)("auto"),[eA,eT]=(0,i.useState)({enabled:!1,connections:{}}),[eO,eR]=(0,i.useState)([]),[eE,eI]=(0,i.useState)([]),[eD,eM]=(0,i.useState)([]),[eP,eU]=(0,i.useState)([]),[ez,eq]=(0,i.useState)(null),[e_,eF]=(0,i.useState)(!1),[eJ,eL]=(0,i.useState)(!1),[eK,eB]=(0,i.useState)(!1),[eH,eV]=(0,i.useState)(null),[eW,eG]=(0,i.useState)({}),[eQ,eZ]=(0,i.useState)(null),eX=(0,i.useRef)(!1),eY=(0,i.useRef)(null),e0=(0,i.useRef)(0),e1=(0,i.useRef)(0),[e2,e5]=(0,i.useState)(!1),[e3,e4]=(0,i.useState)(""),[e6,e7]=(0,i.useState)(!1),[e8,e9]=(0,i.useState)(null),[te,tt]=(0,i.useState)({}),[ts,ta]=(0,i.useState)({}),[ti,tr]=(0,i.useState)("all"),{copied:tl,copy:tn}=(0,v.C)(),to="ag_risk_confirmed",td=()=>{D(!0)},tc=()=>{"antigravity"===p&&"true"!==window.localStorage.getItem(to)?eF(!0):th?td():(G(""),V(!0))},tm=()=>{G(""),V(!0)},tu=()=>{th?tc():tm()},tp=A?{id:A.id,name:A.name||("anthropic-compatible"===A.type?"Anthropic Compatible":"OpenAI Compatible"),color:"anthropic-compatible"===A.type?"#D97757":"#10A37F",textIcon:"anthropic-compatible"===A.type?"AC":"OC",apiType:A.apiType,baseUrl:A.baseUrl,type:A.type}:c.zN[p]||c.fg[p]||c.IS[p]||c.nJ[p]||c.br[p],tx=tp?.authModes||[],th=!!c.zN[p]||!!c.IS[p]||tx.includes("oauth"),tf=!!c.fg[p]||tx.includes("apikey"),tb=!!c.IS[p]?.noAuth,tg=(0,m.KC)(p),ty=(()=>{let e=new Map(tg.map(e=>[e.id,e]));for(let t of eE)t?.id&&e.set(t.id,{...e.get(t.id),...t});return[...e.values()]})(),tv=(0,c.wG)(p),tj=(0,c.mq)(p),tw=(0,c.gb)(p),tk=tj||tw,tN=h.some(e=>!1!==e.isActive),tC=function({isCompatible:e,hasActiveConnection:t}){let s=!e,a=!e;return{showToolbar:s||t||a,showImport:s,showVerify:t,showBulkControls:a}}({isCompatible:tk,hasActiveConnection:tN}),tS=!tk&&th&&tf,t$="xai"===p?"Grok Build OAuth":"OAuth",tA="xai"===p?"xAI API Key":"API Key",tT=e=>{if(!eS||"auto"===eS)return null;let t=y(p,e);return t&&t.includes(eS)?eS:null},tO=(()=>{let e=new Set;for(let t of ty){let s=y(p,t.id);s&&s.forEach(t=>{"none"!==t&&e.add(t)})}return e.size?["auto",...e]:null})(),tR=tk?p:tv,tE=tk?A?.prefix||p:tv,tI=(0,C.Iz)(eP,tR),tD=e=>(0,C.uJ)(tI,e,tR),tM=(0,i.useCallback)(async()=>{try{let e=await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(tR)}`,{cache:"no-store"}),t=await e.json();e.ok&&eU(t.ids||[])}catch(e){(0,O.s)("Error fetching disabled models:",e)}},[tR]),tP=async e=>{try{(await fetch("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:tR,ids:[e]})})).ok&&await tM()}catch(e){(0,O.s)("Error disabling model:",e)}},tU=async e=>{try{if(!(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(tR)}&id=${encodeURIComponent(e)}`,{method:"DELETE"})).ok)return!1;return await tM(),!0}catch(e){return(0,O.s)("Error enabling model:",e),!1}},tz=async e=>{e.length&&eq({title:"Disable All Models",message:`Disable all ${e.length} model(s)?`,onConfirm:async()=>{eq(null);try{(await fetch("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:tR,ids:e})})).ok&&await tM()}catch(e){(0,O.s)("Error disabling all models:",e)}}})},tq=async()=>{try{(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(tR)}`,{method:"DELETE"})).ok&&await tM()}catch(e){(0,O.s)("Error enabling all models:",e)}},t_=(0,i.useCallback)(async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&er(t.aliases||{})}catch(e){(0,O.s)("Error fetching aliases:",e)}},[]),tF=(0,i.useCallback)(async()=>{try{let e=await fetch("/api/models/custom",{cache:"no-store"}),t=await e.json();e.ok&&en(t.models||[])}catch(e){(0,O.s)("Error fetching custom models:",e)}},[]);(0,i.useEffect)(()=>{"kilocode"===p&&fetch("/api/providers/kilo/free-models").then(e=>e.json()).then(e=>{e.models?.length&&eM(e.models)}).catch(()=>{})},[p]);let tJ=(0,i.useCallback)(async()=>{try{let[e,t,s]=await Promise.all([fetch("/api/providers",{cache:"no-store"}),fetch("/api/provider-nodes",{cache:"no-store"}),fetch("/api/settings",{cache:"no-store"})]),a=await e.json(),i=await t.json(),r=s.ok?await s.json():{};if(e.ok){let e=(a.connections||[]).filter(e=>e.provider===p);f(e)}let l=(r.providerStrategies||{})[p]||{};ey(l.fallbackStrategy||null),ej(null!=l.stickyRoundRobinLimit?String(l.stickyRoundRobinLimit):"1");let n=l.accountScheduler||{};ek(!0===n.enabled),eC(String(Math.max(1,Math.round((n.sessionAffinityTtlSeconds||1800)/60))));let o=(r.providerThinking||{})[p]||{};e$(o.mode||"auto");let d=H[p],c=d&&r[d]||{};if(eT({enabled:!0===c.enabled,connections:c.connections||{}}),t.ok){let e=(i.nodes||[]).find(e=>e.id===p)||null;if(!e&&tk)for(let t=0;t<3;t+=1){await new Promise(e=>setTimeout(e,150));let t=await fetch("/api/provider-nodes",{cache:"no-store"});if(t.ok&&(e=((await t.json()).nodes||[]).find(e=>e.id===p)||null))break}R(e)}}catch(e){(0,O.s)("Error fetching connections:",e)}finally{$(!1)}},[p,tk]),tL=(0,i.useCallback)(async(e=null)=>{let t=++e1.current,s=e?h.find(t=>t.id===e&&!1!==t.isActive):h.find(e=>b.includes(e.id)&&!1!==e.isActive)||h.find(e=>!1!==e.isActive);if(!s){ta({}),tt({});return}try{let e=await fetch(`/api/providers/${s.id}/model-probes`,{cache:"no-store"});if(!e.ok)return;let a=await e.json().catch(()=>({})),i={},r={};for(let e of a.probes||[])i[e.modelId]="ok"===e.status?"ok":"dead"===e.status?"dead":"retry",null!=e.latencyMs&&(r[e.modelId]=e.latencyMs);if(t!==e1.current)return;ta(i),tt(r)}catch{}},[h,b]),tK=async e=>{try{let t=await fetch(`/api/provider-nodes/${p}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),s=await t.json();t.ok&&(R(s.node),await tJ(),et(!1))}catch(e){(0,O.s)("Error updating provider node:",e)}},tB=async(e,t)=>{try{return await (0,B.T)(p,s=>{let a={...s};return e?a.fallbackStrategy=e:delete a.fallbackStrategy,"round-robin"===e&&""!==t?a.stickyRoundRobinLimit=Number(t)||3:e||delete a.stickyRoundRobinLimit,a}),!0}catch(e){return(0,O.s)("Error saving provider strategy:",e),!1}},tH=async(e,t)=>{let s=Math.min(1440,Math.max(1,Number.parseInt(t,10)||30));try{return await (0,B.T)(p,t=>({...t,accountScheduler:{...t.accountScheduler||{},enabled:e,sessionAffinityTtlSeconds:60*s}})),!0}catch(e){return(0,O.s)("Error saving balanced scheduler:",e),!1}},tV=async e=>{let t=e?"round-robin":null,s=e?ev||"1":ev;await tB(t,s)&&(e&&!ev&&ej("1"),ey(t))},tW=async e=>{await tB("round-robin",e)&&ej(e)},tG=async e=>{await tH(e,eN)&&ek(e)},tQ=async e=>{await tH(ew,e)&&eC(e)},tZ=async e=>{try{let t=await fetch("/api/settings",{cache:"no-store"}),s={...(t.ok?await t.json():{}).providerThinking||{}};e&&"auto"!==e?s[p]={mode:e}:delete s[p],await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerThinking:s})})}catch(e){(0,O.s)("Error saving thinking config:",e)}},tX=async e=>{let t=H[p];if(t){eT(e);try{await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[t]:e})})}catch(e){(0,O.s)("Error saving auto-ping config:",e)}}};(0,i.useEffect)(()=>{tJ(),t_(),tF(),tM()},[tJ,t_,tF,tM]),(0,i.useEffect)(()=>{tL()},[tL]),(0,i.useEffect)(()=>{if(tk)return;let e=h.find(e=>!1!==e.isActive);if(!e)return void eI([]);let t=!1;return fetch(`/api/providers/${e.id}/models`,{cache:"no-store"}).then(e=>e.json().catch(()=>({}))).then(e=>{!t&&Array.isArray(e.models)&&e.models.length>0&&eI(e.models)}).catch(()=>{}),()=>{t=!0}},[h,tk]),(0,i.useEffect)(()=>{let e=(c.zN[p]||c.fg[p]||c.IS[p]||c.nJ[p])?.modelsFetcher;e&&N(e).then(eR)},[p]);let tY=(0,i.useCallback)(e=>{let t=++e0.current;eY.current&&(clearTimeout(eY.current),eY.current=null);let s=async()=>{try{let a=await fetch(`/api/providers/${e}/model-probes/verify/status`,{cache:"no-store"}),i=await a.json().catch(()=>null);if(t!==e0.current)return;if(!a.ok||!i?.status)throw Error("Verify status temporarily unavailable");e9(i&&i.status?i:null),i?.status==="running"?eY.current=setTimeout(s,1500):(eY.current=null,await tL(e))}catch{t===e0.current&&(eY.current=setTimeout(s,1500))}};eY.current=setTimeout(s,0)},[tL]);(0,i.useEffect)(()=>{let e=h.find(e=>b.includes(e.id)&&!1!==e.isActive)||h.find(e=>!1!==e.isActive);return e?(tY(e.id),()=>{e0.current+=1,eY.current&&(clearTimeout(eY.current),eY.current=null)}):void e9(null)},[h,b,tY]);let t0=async(e,t,s=tv)=>{let a=`${s}/${e}`;try{let e=await fetch("/api/models/alias",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:a,alias:t})});if(e.ok)await t_();else{let t=await e.json();(0,O.s)(t.error||"Failed to set alias")}}catch(e){(0,O.s)("Error setting alias:",e)}},t1=async e=>{try{(await fetch(`/api/models/alias?alias=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await t_()}catch(e){(0,O.s)("Error deleting alias:",e)}},t2=async(e,t="llm",s=tR)=>{try{let a=await fetch("/api/models/custom",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:s,id:e,type:t})});if(a.ok)await tF(),window.dispatchEvent(new CustomEvent("customModelChanged"));else{let e=await a.json();(0,O.s)(e.error||"Failed to add custom model")}}catch(e){(0,O.s)("Error adding custom model:",e)}},t5=async(e,t="llm",s=tR)=>{try{let a=new URLSearchParams({providerAlias:s,id:e,type:t});(await fetch(`/api/models/custom?${a}`,{method:"DELETE"})).ok&&(await tF(),window.dispatchEvent(new CustomEvent("customModelChanged")))}catch(e){(0,O.s)("Error deleting custom model:",e)}},t3=async()=>{if(e2)return;let e=h.find(e=>b.includes(e.id)&&!1!==e.isActive)||h.find(e=>!1!==e.isActive);if(!e)return void(0,O.s)((0,w.Tl)("Add an active connection first"));e5(!0),e4("");try{let t=await fetch(`/api/providers/${e.id}/models`),s=await t.json().catch(()=>({}));if(!t.ok)return void(0,O.s)(s.error||(0,w.Tl)("Failed to fetch models"));let a=s.models||[];if(0===a.length)return void(0,O.s)(s.warning||(0,w.Tl)("No models returned"));let i=new Set;try{let t=await fetch(`/api/providers/${e.id}/model-probes`,{cache:"no-store"});for(let e of(await t.json().catch(()=>({}))).probes||[])"dead"===e.status&&i.add(e.modelId)}catch{}let r=0,l=new Set(ty.map(e=>e.id)),n=[],o=[],d=new Set;for(let e of a){let t=(0,S.R2)(e,tR);if(!t)continue;let{id:s,name:a,type:c}=t;if(i.has((0,K.v)(s,tR))){r+=1;continue}let m=`${c}|${s}`;if(d.has(m))continue;if(d.add(m),l.has(s)){tD(s)&&o.push(s);continue}if(el.some(e=>e.providerAlias===tR&&e.id===s&&(0,S.ki)(e.kind||e.type||"llm")===c))continue;let u=`${tR}/${s}`;Object.values(ei).includes(u)||n.push({providerAlias:tR,id:s,type:c,name:a})}let c=0;if(o.length>0)try{for(let e of o)(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(tR)}&id=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&(c+=1);await tM()}catch{}let m=0;if(n.length>0){let e=await fetch("/api/models/custom",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({models:n})}),t=await e.json().catch(()=>({}));if(!e.ok)return void(0,O.s)(t.error||(0,w.Tl)("Failed to save models"));m=t.added??n.length,await tF(),window.dispatchEvent(new CustomEvent("customModelChanged"))}let u=n.filter(e=>"llm"!==e.type).length,p=[];if(m>0&&p.push(`${m} new`),c>0&&p.push(`${c} re-enabled`),0===p.length)e4((0,w.Tl)("All models already in list"));else{let e=`Imported ${p.join(" \xb7 ")} (${a.length} from provider)`;u>0&&(e+=" \xb7 non-chat types stored for media pages"),s.warning&&(e+=` \xb7 ${s.warning}`),e4(e)}if(r>0&&e4(e=>`${e} \xb7 ${r} skipped (known dead)`),m>0||c>0)try{let t=[...ty,...n.map(e=>({id:e.id,name:e.name,kind:e.type}))],s=await fetch(`/api/providers/${e.id}/model-probes/verify/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({models:t,providerAlias:tR})}),a=await s.json().catch(()=>({}));if(!s.ok)throw Error(a.error||"Failed to start auto-verify");e9(a&&a.status?a:null),tY(e.id)}catch(e){e4(t=>`${t} \xb7 auto-verify failed: ${e?.message||e}`)}}catch(e){(0,O.s)("Error importing models:",e),(0,O.s)((0,w.Tl)("Error fetching models")+": "+(e?.message||e))}finally{e5(!1)}},t4=async()=>{if(eJ||0===h.length)return;let e=Object.fromEntries(h.map(e=>[e.id,{state:"queued",error:null}]));eX.current=!1,eL(!0),eB(!1),eV(null),eG(e),eZ({total:h.length,completed:0,passed:0,failed:0,stopped:!1});let t=0,s=0;try{for(let e=0;e<h.length;e+=1){if(eX.current){eZ({total:h.length,completed:e,passed:t,failed:s,stopped:!0});break}let a=h[e];eV(a.id),eG(e=>({...e,[a.id]:{state:"testing",error:null}}));try{let e=await fetch(`/api/providers/${a.id}/test`,{method:"POST"}),i=await e.json(),r=!!i.valid;r?t+=1:s+=1,eG(e=>({...e,[a.id]:{state:r?"success":"failed",error:r?null:i.error||null}}))}catch(e){s+=1,eG(t=>({...t,[a.id]:{state:"failed",error:e.message||"Test failed"}}))}eZ({total:h.length,completed:e+1,passed:t,failed:s,stopped:!1}),e<h.length-1&&await new Promise(e=>setTimeout(e,1e3))}}finally{eV(null),eL(!1),eB(!1),eX.current=!1}},t6=async e=>{let t=h.find(t=>t.id===e),s=t?.name?.trim()||t?.email?.trim()||e;eq({title:"Delete Connection",message:`Delete connection “${s}”?`,onConfirm:async()=>{eq(null);try{(await fetch(`/api/providers/${e}`,{method:"DELETE"})).ok&&f(t=>t.filter(t=>t.id!==e))}catch(e){(0,O.s)("Error deleting connection:",e)}}})},t7=()=>{tJ(),D(!1)},t8=async e=>{G("");try{let t=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:p,...e})}),s=null;try{s=await t.json()}catch{s=null}if(t.ok){await tJ(),V(!1);return}G(s?.error||"Failed to save connection")}catch(e){(0,O.s)("Error saving connection:",e),G("Failed to save connection")}},t9=async e=>{try{(await fetch(`/api/providers/${es.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok&&(await tJ(),Y(!1))}catch(e){(0,O.s)("Error updating connection:",e)}},se=async(e,t)=>{try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&f(s=>s.map(s=>s.id===e?{...s,isActive:t}:s))}catch(e){(0,O.s)("Error updating connection status:",e)}},st=async e=>{let t,s=e?.providerSpecificData?.baseUrl;if(s){try{t=new URL(s).hostname.toLowerCase().replace(/^\[|\]$/g,"")}catch{(0,O.s)("Cannot allow-list: invalid base URL",s);return}try{let e=await fetch("/api/settings",{cache:"no-store"});if(!e.ok)throw Error(`Failed to load settings (${e.status})`);let s=await e.json(),a=[...new Set([...s.ssrfAllowHosts||[],t])],i=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({ssrfAllowHosts:a})});if(!i.ok)throw Error(`Failed to update allow list (${i.status})`);await tJ()}catch(e){(0,O.s)("Error adding host to allow list:",e)}}},ss=async(e,t)=>{let s=[...h];[s[e],s[t]]=[s[t],s[e]],f(s);try{await Promise.all([fetch(`/api/providers/${s[e].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:e})}),fetch(`/api/providers/${s[t].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:t})})])}catch(e){(0,O.s)("Error swapping priority:",e),await tJ()}},sa=h.length>0&&b.length===h.length,si=(0,a.jsx)("div",{className:"flex min-w-0 flex-col divide-y divide-black/[0.03] dark:divide-white/[0.03]",children:h.map((e,t)=>(0,a.jsxs)("div",{className:"flex min-w-0 items-stretch",children:[(0,a.jsx)("div",{className:"flex shrink-0 items-center pl-1 sm:pl-2",children:(0,a.jsx)("input",{type:"checkbox",checked:b.includes(e.id),onChange:()=>{var t;return t=e.id,void g(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])},className:"h-4 w-4 rounded border-gray-300 text-primary focus:ring-primary"})}),(0,a.jsx)("div",{className:"flex-1 min-w-0",children:(0,a.jsx)(M,{connection:e,isOAuth:th,isFirst:0===t,isLast:t===h.length-1,onMoveUp:()=>ss(t,t-1),onMoveDown:()=>ss(t,t+1),onToggleActive:t=>se(e.id,t),autoPing:H[p]&&"oauth"===e.authType?{on:!0===eA.connections[e.id],onToggle:t=>{var s;return s=e.id,void tX({...eA,connections:{...eA.connections,[s]:t}})},provider:p}:null,onEdit:()=>{ea(e),Y(!0)},onDelete:()=>t6(e.id),onAllowlistHost:()=>st(e),oneByOneStatus:eW[e.id]||null})})]},e.id))}),sr=async e=>{if(!ex.has(e)){eh(t=>new Set(t).add(e));try{let t=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${tR}/${e}`})}),s=await t.json();em(t=>({...t,[e]:s.ok?"ok":"error"})),ep(s.ok?"":s.error||"Model not reachable")}catch{em(t=>({...t,[e]:"error"})),ep("Network error")}finally{eh(t=>{let s=new Set(t);return s.delete(e),s})}}};return k?(0,a.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,a.jsx)(d.Qv,{}),(0,a.jsx)(d.Qv,{})]}):tp?(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:gap-8 sm:px-0",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)(n(),{href:"/dashboard/providers",className:"inline-flex items-center gap-1 text-sm text-text-muted hover:text-primary transition-colors mb-4",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-lg",children:"arrow_back"}),"Back to Providers"]}),(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3 sm:gap-4",children:[(0,a.jsx)("div",{className:"flex size-12 shrink-0 items-center justify-center rounded-lg",style:{backgroundColor:`${tp.color}15`},children:eo?(0,a.jsx)("span",{className:"text-sm font-bold",style:{color:tp.color},children:tp.textIcon||tp.id.slice(0,2).toUpperCase()}):(0,a.jsx)(o.default,{src:tj&&tp.apiType?"responses"===tp.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":tw?"/providers/anthropic-m.png":`/providers/${tp.id}.png`,alt:tp.name,width:48,height:48,className:"max-h-12 max-w-12 rounded-lg object-contain",sizes:"48px",onError:()=>ed(!0)})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 flex-wrap",children:[(0,a.jsx)("h1",{className:"truncate text-2xl font-semibold tracking-tight sm:text-3xl",children:tp.name}),(tp.notice?.apiKeyUrl||tp.notice?.signupUrl||tp.website)&&(0,a.jsxs)("a",{href:tp.notice?.apiKeyUrl||tp.notice?.signupUrl||tp.website,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline inline-flex items-center gap-1",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"open_in_new"}),tp.notice?.apiKeyUrl?"Get API Key":"Sign up / Learn more"]})]}),(0,a.jsxs)("p",{className:"text-text-muted",children:[h.length," connection",1===h.length?"":"s"]})]})]})]}),tp.deprecated&&(0,a.jsxs)("div",{className:"flex items-start gap-3 rounded-xl border border-amber-500/25 bg-amber-500/8 px-4 py-3 text-xs text-amber-600 dark:text-amber-400",children:[(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-base text-amber-500 mt-0.5",children:"warning"}),(0,a.jsx)("p",{className:"leading-relaxed font-normal",children:String(tp.deprecationNotice).replace(/^⚠️\s*⚠️?\s*/,"")})]}),tp.notice?.text&&!tp.deprecated&&(0,a.jsxs)("div",{className:"flex flex-col gap-2 rounded-lg border border-blue-500/30 bg-blue-500/10 px-3 py-2 sm:flex-row sm:items-center",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px] text-blue-500 shrink-0",children:"info"}),(0,a.jsx)("p",{className:"min-w-0 flex-1 text-xs leading-relaxed text-blue-600 dark:text-blue-400",children:tp.notice.text}),tp.notice.apiKeyUrl&&(0,a.jsx)("a",{href:tp.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 →"})]}),tk&&A&&(0,a.jsx)(d.Zp,{children:(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:tw?"Anthropic Compatible Details":"OpenAI Compatible Details"}),(0,a.jsxs)("p",{className:"break-all text-sm text-text-muted",children:[tw?"Messages API":"responses"===A.apiType?"Responses API":"Chat Completions"," \xb7 ",(A.baseUrl||"").replace(/\/$/,""),"/",tw?"messages":"responses"===A.apiType?"responses":"chat/completions"]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:()=>{G(""),V(!0)},className:"w-full sm:w-auto",children:"Add API Key"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"edit",onClick:()=>et(!0),className:"w-full sm:w-auto",children:"Edit"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"delete",onClick:async()=>{eq({title:"Delete Compatible Node",message:`Delete this ${tw?"Anthropic":"OpenAI"} Compatible node?`,onConfirm:async()=>{eq(null);try{(await fetch(`/api/provider-nodes/${p}`,{method:"DELETE"})).ok&&u.push("/dashboard/providers")}catch(e){(0,O.s)("Error deleting provider node:",e)}}})},className:"w-full sm:w-auto",children:"Delete"})]})]})}),tb?(0,a.jsx)(d.gw,{providerId:p}):(0,a.jsxs)(d.Zp,{children:[(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Connections"}),(0,a.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:gap-4",children:[h.length>0&&(0,a.jsxs)(a.Fragment,{children:[b.length>0&&(0,a.jsxs)(d.$n,{size:"sm",variant:"danger",icon:"delete",onClick:()=>{let e=b.length;0!==e&&eq({title:`Delete ${e} Connection${e>1?"s":""}`,message:`Delete ${e} connection${e>1?"s":""}? This cannot be undone.`,onConfirm:async()=>{eq(null);let e=0,t=[...b];for(let s of t)try{(await fetch(`/api/providers/${s}`,{method:"DELETE"})).ok||(e+=1)}catch(t){(0,O.s)("Error deleting connection:",t),e+=1}f(e=>e.filter(e=>!t.includes(e.id))),g([]),e>0&&(0,O.s)(`Deleted ${t.length-e} connection(s), ${e} failed.`)}})},children:["Delete Selected (",b.length,")"]}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"sync",onClick:t4,disabled:eJ,children:eJ?"Testing Connection One-by-One...":"Test Connection One-by-One"}),eJ&&(0,a.jsx)(d.$n,{size:"sm",variant:"ghost",icon:"stop",onClick:()=>{eJ&&(eX.current=!0,eB(!0))},disabled:eK,children:eK?"Stopping...":"Stop"})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2 rounded-xl border border-border/60 bg-surface-2/40 p-3",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-medium text-text-main",children:"Balanced Scheduler"}),(0,a.jsx)(d.m_,{text:"Process-local least-inflight scheduling with fresh quota signals. Sessions stay on one account and rebind on failure, cooldown, or cap.",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[15px] text-text-muted cursor-help",children:"info"})})]}),(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[ew&&(0,a.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-text-muted",children:["Affinity",(0,a.jsx)("input",{"aria-label":"Session affinity minutes",type:"number",min:1,max:1440,value:eN,onChange:e=>tQ(e.target.value),className:"w-14 px-2 py-0.5 text-xs border border-border rounded-md bg-background text-text-main focus:outline-none focus:border-primary"}),(0,a.jsx)("span",{className:"text-[11px]",children:"min"})]}),(0,a.jsx)(d.lM,{checked:ew,onChange:tG,"aria-label":"Balanced scheduler"})]})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3 pt-2 border-t border-border/40",title:ew?"Saved and used again when balanced scheduling is off":void 0,children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-medium text-text-main",children:"Round Robin"}),(0,a.jsx)(d.m_,{text:"Cycles through connections sequentially in round-robin fashion.",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[15px] text-text-muted cursor-help",children:"info"})})]}),(0,a.jsxs)("div",{className:"flex items-center gap-3",children:["round-robin"===eg&&(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"text-xs text-text-muted",children:"Sticky:"}),(0,a.jsx)("input",{type:"number",min:1,value:ev,onChange:e=>tW(e.target.value),placeholder:"1",disabled:ew,title:ew?"Saved and used again when balanced scheduling is off":void 0,className:"w-14 px-2 py-0.5 text-xs border border-border rounded-md bg-background text-text-main focus:outline-none focus:border-primary disabled:cursor-not-allowed disabled:opacity-50"})]}),(0,a.jsx)(d.lM,{checked:"round-robin"===eg,onChange:tV,"aria-label":"Round Robin",disabled:ew,title:ew?"Saved and used again when balanced scheduling is off":void 0})]})]})]})]})]}),0===h.length?(0,a.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"inline-flex items-center justify-center w-9 h-9 rounded-full bg-primary/10 text-primary shrink-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:th?"lock":"key"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"No connections yet"}),tS&&(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["Choose ",t$," or ",tA,"."]})]})]}),(0,a.jsx)("div",{className:"flex gap-2",children:tS?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.$n,{size:"sm",icon:"lock",variant:"secondary",onClick:tc,children:t$}),(0,a.jsx)(d.$n,{size:"sm",icon:"key",onClick:tm,children:tA})]}):(0,a.jsxs)(a.Fragment,{children:[!tk&&"iflow"===p&&(0,a.jsx)(d.$n,{size:"sm",icon:"cookie",variant:"secondary",onClick:()=>_(!0),children:"Cookie"}),"codex"===p&&(0,a.jsx)(d.$n,{size:"sm",icon:"playlist_add",variant:"secondary",onClick:()=>Z(!0),children:(0,w.Tl)("Bulk Add")}),(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:tu,children:tk?"Add API Key":"iflow"===p?"OAuth":"Add Connection"})]})})]}):(0,a.jsxs)(a.Fragment,{children:[eQ&&(0,a.jsx)("div",{className:"mb-4 rounded-lg border border-black/10 bg-black/[0.02] px-3 py-2 text-xs text-text-muted dark:border-white/10 dark:bg-white/[0.03]",children:(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,a.jsxs)("span",{children:["Total: ",eQ.total]}),(0,a.jsxs)("span",{children:["Completed: ",eQ.completed]}),(0,a.jsxs)("span",{children:["Passed: ",eQ.passed]}),(0,a.jsxs)("span",{children:["Failed: ",eQ.failed]}),eQ.stopped&&(0,a.jsx)("span",{className:"text-amber-600 dark:text-amber-400",children:"Stopped"}),eJ&&eH&&(0,a.jsxs)("span",{children:["Running: ",h.find(e=>e.id===eH)?.name||eH]})]})}),h.length>0&&(0,a.jsx)("div",{className:"mb-3 flex items-center gap-2 border-b border-black/[0.03] pb-2 dark:border-white/[0.03]",children:(0,a.jsxs)("label",{className:"flex cursor-pointer items-center gap-1.5 text-xs text-text-muted hover:text-primary",children:[(0,a.jsx)("input",{type:"checkbox",checked:sa,onChange:()=>{sa?g([]):g(h.map(e=>e.id))},className:"h-3.5 w-3.5 rounded border-gray-300 text-primary focus:ring-primary"}),"Select All"]})}),si,!tk&&(0,a.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-2 sm:flex",children:["iflow"===p&&(0,a.jsx)(d.$n,{size:"sm",icon:"cookie",variant:"secondary",onClick:()=>_(!0),title:"Add connection using browser cookie",className:"w-full sm:w-auto",children:"Cookie"}),"codex"===p&&(0,a.jsx)(d.$n,{size:"sm",icon:"playlist_add",variant:"secondary",onClick:()=>Z(!0),title:(0,w.Tl)("Bulk import codex accounts from JSON"),className:"w-full sm:w-auto",children:(0,w.Tl)("Bulk Add")}),tS?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.$n,{size:"sm",icon:"lock",variant:"secondary",onClick:tc,className:"w-full sm:w-auto",children:t$}),(0,a.jsx)(d.$n,{size:"sm",icon:"key",onClick:tm,className:"w-full sm:w-auto",children:tA})]}):(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:tu,className:"w-full sm:w-auto",children:"Add"})]})]})]}),(0,a.jsxs)(d.Zp,{children:[(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Available Models"}),tO&&(0,a.jsx)("select",{value:eS,onChange:e=>{var t;e$(t=e.target.value),tZ(t)},title:"Appends (level) suffix to copied model names",className:"rounded-md border border-border bg-background px-2 py-1 text-xs focus:border-primary focus:outline-none",children:tO.map(e=>(0,a.jsx)("option",{value:e,children:`Thinking: ${e.charAt(0).toUpperCase()+e.slice(1)}`},e))})]}),tC.showToolbar&&(e=(tC.showBulkControls?[...ty,...eD.filter(e=>!ty.some(t=>t.id===e.id))].filter(e=>{let t=(0,m.CP)(e);return!t||"llm"===t}).map(e=>e.id):[]).filter(e=>!tD(e)),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[tC.showImport&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:e2?"progress_activity":"cloud_download",onClick:t3,disabled:e2||!tN,title:tN?"Import models from the active connection":"Add an active connection to import models",children:e2?"Importing...":"Import models"}),tC.showVerify&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:e8?.status==="running"?"progress_activity":"science",onClick:()=>e7(e=>!e),children:e8?.status==="running"?`Verifying ${e8.done}/${e8.total}`:e6?"Hide verify":"Verify models"}),tC.showBulkControls&&eP.length>0&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"restart_alt",onClick:tq,children:"Active All"}),tC.showBulkControls&&e.length>0&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"block",onClick:()=>tz(e),children:"Disable All"})]}))]}),!!eu&&(0,a.jsx)("p",{className:"text-xs text-red-500 mb-3 break-words",children:eu}),e3&&(0,a.jsxs)("div",{className:"mb-3 flex items-center justify-between gap-2 rounded-xl border border-primary/30 bg-primary/10 px-3.5 py-2 text-xs font-medium text-text-main",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px] text-primary",children:"info"}),(0,a.jsx)("span",{children:e3})]}),(0,a.jsx)("button",{onClick:()=>e4(""),className:"text-text-muted hover:text-text-main p-0.5 rounded",title:"Dismiss",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"close"})})]}),e6&&(t=h.find(e=>b.includes(e.id)&&!1!==e.isActive)||h.find(e=>!1!==e.isActive),s=[...(0,C.R3)({customModels:el,modelAliases:ei,providerAlias:tR,builtInModels:ty,type:"llm"}).filter(e=>!tD(e.id)).map(e=>({id:e.id,name:e.name||e.id,kind:"llm"})),...ty.filter(e=>{let t=(0,m.CP)(e);return(!t||"llm"===t)&&!tD(e.id)}).map(e=>({id:e.id,name:e.name||e.id,kind:"llm"}))],(0,a.jsx)(L,{connectionId:t?.id,providerAlias:tR,models:s,jobSnapshot:e8,onClose:()=>e7(!1),onStarted:e=>{e9(e&&e.status?e:null);let s=e?.connectionId||t?.id;s&&tY(s)},onComplete:async e=>{e?.removedStatus&&e9(t=>t?{...t,dead:Number(e.dead??t.dead??0),retryable:Number(e.retryable??t.retryable??0),retryableAuthOnly:!0===e.retryableAuthOnly}:t),e?.removed>0&&await tF(),e?.removed>0&&await tM(),(e?.removed>0||e?.cacheCleared)&&await tL(t?.id)}})),(()=>{let e,t,s;if(tk)return(0,a.jsx)(E,{providerStorageAlias:tR,providerDisplayAlias:tE,modelAliases:ei,customModels:el,copied:tl,onCopy:tn,onSetAlias:t0,onDeleteAlias:t1,onAddCustomModel:e=>t2(e,"llm",tR),onDeleteCustomModel:e=>t5(e,"llm",tR),onRefreshModels:tF,connections:h,isAnthropic:tw,disabledModelIds:eP,onEnableModel:tU});let i=[...ty,...eD.filter(e=>!ty.some(t=>t.id===e.id))].filter(e=>{let t=(0,m.CP)(e);return!t||"llm"===t}),r=i.filter(e=>!tD(e.id)),l=i.filter(e=>tD(e.id)),n=(0,C.R3)({customModels:el,modelAliases:ei,providerAlias:tR,builtInModels:ty,type:"llm"}),o=n.filter(e=>!tD(e.id)&&("all"===ti||(ts[(0,K.v)(e.id,tR)]||null)===ti)),d=r.filter(e=>"all"===ti||(ts[(0,K.v)(e.id,tR)]||null)===ti);return(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsx)("div",{className:"mb-2 flex flex-wrap items-center gap-1.5 text-xs",children:[{id:"all",label:"All",count:r.length+n.filter(e=>!tD(e.id)).length},{id:"ok",label:"Reachable",count:[...r,...n].filter(e=>!tD(e.id)&&("ok"===ts[(0,K.v)(e.id,tR)]||"ok"===ec[e.id])).length},{id:"dead",label:"Dead",count:[...r,...n].filter(e=>!tD(e.id)&&("dead"===ts[(0,K.v)(e.id,tR)]||"error"===ec[e.id])).length},{id:"retry",label:"Retry",count:[...r,...n].filter(e=>!tD(e.id)&&"retry"===ts[(0,K.v)(e.id,tR)]).length}].map(e=>(0,a.jsxs)("button",{onClick:()=>tr(e.id),className:`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1 text-xs font-medium transition-all ${ti===e.id?"bg-primary text-black font-semibold shadow-sm":"bg-surface-2/60 border border-border/40 text-text-muted hover:border-border hover:text-text-main"}`,children:[(0,a.jsx)("span",{children:e.label}),(0,a.jsx)("span",{className:`rounded-full px-1.5 py-0.2 text-[10px] tabular-nums ${ti===e.id?"bg-black/20 text-black font-bold":"bg-black/10 dark:bg-white/10 text-text-muted"}`,children:e.count})]},e.id))}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-3",children:[o.map(e=>{let t=(0,K.v)(e.id,tR);return(0,a.jsx)(T,{model:{id:e.id,name:e.name},fullModel:`${tE}/${e.id}`,alias:e.alias,copied:tl,onCopy:tn,onSetAlias:()=>{},onDeleteAlias:()=>{"custom"===e.source?t5(e.id,"llm",tR):t1(e.alias)},testStatus:ec[e.id],onTest:h.length>0||tb?()=>sr(e.id):void 0,isTesting:ex.has(e.id),isCustom:!0,isFree:!1,caps:x(`${p}/${e.id}`),thinkingSuffix:tT(e.id),latencyMs:te[e.id]??te[t],probeState:e8?.status==="running"&&e8?.perModel?.[t]?e8.perModel[t]:ts[t]||null},`${e.source}-${e.fullModel}`)}),d.map(e=>{let t=`${tR}/${e.id}`,s=`${p}/${e.id}`,i=Object.entries(ei).find(([,e])=>e===t||e===s)?.[0],r=(0,K.v)(e.id,tR);return(0,a.jsx)(T,{model:e,fullModel:`${tE}/${e.id}`,alias:i,copied:tl,onSetAlias:t=>t0(e.id,t,tR),onCopy:tn,onDeleteAlias:()=>t1(i),testStatus:ec[e.id],onTest:h.length>0||tb?()=>sr(e.id):void 0,isTesting:ex.has(e.id),isFree:e.isFree,onDisable:()=>tP(e.id),caps:x(`${p}/${e.id}`),thinkingSuffix:tT(e.id),latencyMs:te[e.id]??te[r],probeState:e8?.status==="running"&&e8?.perModel?.[r]?e8.perModel[r]:ts[r]||null},e.id)}),(0,a.jsxs)("button",{onClick:()=>eb(!0),className:"flex min-h-[58px] min-w-[200px] flex-1 items-center justify-center gap-2 rounded-xl border border-dashed border-primary/40 bg-primary/5 px-4 py-3 text-xs font-medium text-primary transition-all hover:border-primary hover:bg-primary/10 hover:shadow-soft sm:flex-none",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"add_circle"}),"Add Custom Model"]}),eO.length>0&&(e=new Set([...Object.values(ei),...n.map(e=>e.fullModel)]),t=new Set(ty.map(e=>e.id)),0===(s=eO.filter(s=>!e.has(`${tR}/${s.id}`)&&!t.has(s.id))).length?null:(0,a.jsxs)("div",{className:"w-full mt-2",children:[(0,a.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"Suggested free models (≥200k context):"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:s.map(e=>(0,a.jsxs)("button",{onClick:async()=>{await t2(e.id,"llm",tR)},className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg border border-black/10 dark:border-white/10 text-xs text-text-muted hover:text-primary hover:border-primary/40 hover:bg-primary/5 transition-colors",title:`${e.name} \xb7 ${(e.contextLength/1e3).toFixed(0)}k ctx`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"add"}),e.id.split("/").pop()]},e.id))})]})),l.length>0&&(0,a.jsxs)("div",{className:"w-full mt-2",children:[(0,a.jsxs)("p",{className:"text-xs text-text-muted mb-2",children:["Disabled models (",l.length,"):"]}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:l.map(e=>(0,a.jsxs)("button",{onClick:()=>tU(e.id),className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg border border-dashed border-black/10 dark:border-white/10 text-xs text-text-muted hover:text-primary hover:border-primary/40 hover:bg-primary/5 transition-colors",title:"Restore model",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"add"}),e.id]},e.id))})]})]})]})})()]}),"kiro"===p?(0,a.jsx)(d.Mh,{isOpen:I,providerInfo:tp,onSuccess:t7,onClose:()=>D(!1)}):"cursor"===p?(0,a.jsx)(d.G9,{isOpen:I,onSuccess:t7,onClose:()=>D(!1)}):"gitlab"===p?(0,a.jsx)(d.vj,{isOpen:I,providerInfo:tp,onSuccess:t7,onClose:()=>D(!1)}):(0,a.jsx)(d.LF,{isOpen:I,provider:p,providerInfo:tp,onSuccess:t7,onClose:()=>D(!1)}),"iflow"===p&&(0,a.jsx)(d.vE,{isOpen:P,onSuccess:()=>{tJ(),_(!1)},onClose:()=>_(!1)}),(0,a.jsx)(U,{isOpen:J,provider:p,providerName:tp.name,isCompatible:tk,isAnthropic:tw,authType:tp?.authType,authHint:tp?.authHint,website:tp?.website,error:W,onSave:t8,onBulkDone:tJ,onClose:()=>{G(""),V(!1)}}),(0,a.jsx)(d.wI,{isOpen:X,connection:es,onSave:t9,onClose:()=>Y(!1)}),tk&&(0,a.jsx)(z,{isOpen:ee,node:A,onSave:tK,onClose:()=>et(!1),isAnthropic:tw}),!tk&&(0,a.jsx)(q,{isOpen:ef,providerAlias:tR,providerDisplayAlias:tE,onSave:async e=>{await t2(e,"llm",tR),eb(!1)},onClose:()=>eb(!1)}),"codex"===p&&(0,a.jsx)(F,{isOpen:Q,onClose:()=>Z(!1),onSuccess:tJ}),(0,a.jsx)(d.uo,{isOpen:e_,onClose:()=>eF(!1),onConfirm:()=>{(window.localStorage.setItem(to,"true"),eF(!1),th)?td():tm()},title:"Risk Notice",message:tp?.deprecationNotice,confirmText:"I Understand, Continue",cancelText:"Cancel",variant:"danger"}),(0,a.jsx)(d.uo,{isOpen:!!ez,onClose:()=>eq(null),onConfirm:ez?.onConfirm,title:ez?.title||"Confirm",message:ez?.message,variant:"danger"})]}):(0,a.jsxs)("div",{className:"text-center py-20",children:[(0,a.jsx)("p",{className:"text-text-muted",children:"Provider not found"}),(0,a.jsx)(n(),{href:"/dashboard/providers",className:"text-primary mt-4 inline-block",children:"Back to Providers"})]})}},53578:(e,t,s)=>{"use strict";async function a(e,t,s=fetch){let i=await s("/api/settings",{cache:"no-store"});if(!i.ok)throw Error(`Failed to load settings (${i.status})`);let r=(await i.json()).providerStrategies||{},l=t(r[e]||{}),n={...r};l&&Object.keys(l).length>0?n[e]=l:delete n[e];let o=await s("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerStrategies:n})});if(!o.ok)throw Error(`Failed to save settings (${o.status})`);return l}s.d(t,{T:()=>a})},70217:(e,t,s)=>{"use strict";function a(e,t){return!1===e?"default":"active"===t||"success"===t?"success":"error"===t||"expired"===t||"unavailable"===t?"error":"default"}s.d(t,{g:()=>a})}},e=>{e.O(0,[2574,3862,782,8500,594,1321,4707,5497,8441,3794,7358],()=>e(e.s=7687)),_N_E=e.O()}]);
|
|
10
|
+
]`;function F({isOpen:e,onClose:t,onSuccess:s}){let[r,l]=(0,i.useState)(""),[n,o]=(0,i.useState)(!1),[c,m]=(0,i.useState)(""),[u,p]=(0,i.useState)(null),x=()=>{n||(l(""),m(""),p(null),t())},h=async()=>{var e;let t;m(""),p(null);let a=r.trim();if(!a)return;try{t=JSON.parse(a)}catch(e){m(`${(0,w.Tl)("Invalid JSON")}: ${e.message}`);return}let i=Array.isArray(e=t)?e:e&&"object"==typeof e?Array.isArray(e.accounts)?e.accounts:[e]:null;if(!i||0===i.length)return void m((0,w.Tl)("No accounts found in input"));o(!0);try{let e=await fetch("/api/oauth/codex/bulk-import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({accounts:i})}),t=await e.json();if(!e.ok)return void m(t?.error||`Request failed: ${e.status}`);p(t),t.success>0&&"function"==typeof s&&s()}catch(e){m(e.message||(0,w.Tl)("Request failed"))}finally{o(!1)}},f=u?.results?.filter(e=>!e.ok)||[];return(0,a.jsx)(d.aF,{isOpen:e,title:(0,w.Tl)("Bulk Add Codex Accounts"),onClose:x,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)("p",{className:"text-xs text-text-muted",children:(0,w.Tl)("Paste an array of codex account JSON objects. Each must include accessToken (and ideally refreshToken, idToken).")}),(0,a.jsx)("textarea",{className:"w-full rounded border border-accent/30 bg-sidebar p-2 text-sm font-mono resize-y min-h-[240px] focus:outline-none focus:ring-1 focus:ring-primary",placeholder:_,value:r,onChange:e=>l(e.target.value),disabled:n}),c&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:c}),u&&(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:`text-sm font-medium ${u.failed>0?"text-yellow-400":"text-green-400"}`,children:["✓ ",u.success," ",(0,w.Tl)("added"),u.failed>0?`, ✗ ${u.failed} ${(0,w.Tl)("failed")}`:""]}),f.length>0&&(0,a.jsx)("ul",{className:"rounded border border-accent/20 bg-sidebar/50 p-2 text-xs font-mono max-h-40 overflow-y-auto",children:f.map(e=>(0,a.jsxs)("li",{className:"text-red-400",children:["[",e.index,"] ",e.error]},e.index))})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{onClick:h,fullWidth:!0,disabled:n||!r.trim(),children:n?(0,w.Tl)("Importing..."):(0,w.Tl)("Import All")}),(0,a.jsx)(d.$n,{onClick:x,variant:"ghost",fullWidth:!0,disabled:n,children:(0,w.Tl)("Close")})]})]})})}F.propTypes={isOpen:A().bool.isRequired,onClose:A().func.isRequired,onSuccess:A().func};var J=s(77251);function L({connectionId:e,providerAlias:t,models:s,jobSnapshot:r,onComplete:l,onStarted:n,onClose:o}){let[c,m]=(0,i.useState)(4),[u,p]=(0,i.useState)(50),[x,h]=(0,i.useState)(Math.round(20)),[f,b]=(0,i.useState)(!1),[g,y]=(0,i.useState)(null),[v,j]=(0,i.useState)(null),[w,k]=(0,i.useState)(""),[N,C]=(0,i.useState)(""),[S,$]=(0,i.useState)(""),A=(0,i.useRef)({onComplete:l,onStarted:n}),T=(0,i.useRef)(null),E=(0,i.useRef)(e),O=(0,i.useRef)(null),R=s?.length||0,I=(0,i.useMemo)(()=>`max concurrency 16 \xb7 batch 200 \xb7 timeout ${60}s`,[]);function D(e){if(e){if("idle"===e.status){O.current=null,b(!1);return}if(y({done:e.done||0,total:e.total||0,ok:e.ok||0,dead:e.dead||0,retryable:e.retryable||0,skippedDead:e.skippedDead||0,skippedDup:e.skippedDup||0}),"running"===e.status&&(O.current=e.connectionId||E.current,T.current=null,b(!0)),e.currentRange&&C(`Probing ${e.currentRange.from}–${e.currentRange.to} of ${e.total}…`),e.error&&k(e.error),"done"===e.status||"cancelled"===e.status||"error"===e.status){O.current=null,b(!1);let t={ok:e.ok||0,dead:e.dead||0,retryable:e.retryable||0,tested:e.done||0,skippedDead:e.skippedDead||0,skippedDup:e.skippedDup||0,cancelled:"cancelled"===e.status,retryableAuthOnly:!0===e.retryableAuthOnly};j(t),C("cancelled"===e.status?"Cancelled (partial results saved).":"error"===e.status?"Stopped.":"Done.");let s=`${e.startedAt||"unknown"}:${e.status}`;T.current!==s&&(T.current=s,A.current.onComplete?.(t))}}}async function M(){if(f||!e||0===R)return;b(!0),k(""),j(null),C("Starting…");let a={concurrency:Math.max(1,Math.min(16,Number(c)||4)),batchSize:Math.max(1,Math.min(200,Number(u)||50)),timeoutMs:Math.max(1e3,Math.min(6e4,1e3*(Number(x)||20)))};O.current=e;try{let i=await fetch(`/api/providers/${e}/model-probes/verify/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({models:s,providerAlias:t,...a,timeoutMs:a.timeoutMs})}),r=await i.json().catch(()=>({}));if(E.current!==e){O.current=null,b(!1);return}if(!i.ok){O.current=null,k(r.error||"Failed to start"),b(!1);return}A.current.onStarted?.(r),D(r),"running"!==r.status&&b(!1)}catch(e){O.current=null,k(e?.message||"Verify failed"),b(!1)}}async function P(){let t=O.current||e;await fetch(`/api/providers/${t}/model-probes/verify/cancel`,{method:"POST"}).catch(()=>{})}async function U(s){if(!e)return;let a="retryable"===s,i=a?Number(v?.retryable||0):Number(v?.dead||0);if(!a||await (0,J.l)({title:"Remove retry-failed models?",message:`Review ${i} retryable result(s) and remove the eligible models? Timeouts, rate limits, network failures, and provider errors may be temporary. Credential failures are kept. Removed models can be enabled or imported again later.`,confirmText:"Remove eligible"})){$(s),k(""),C(`Removing ${a?"retry-failed":"dead"} models…`);try{let i=await fetch(`/api/providers/${e}/model-probes/remove-unavailable`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:t,kind:"llm",status:s})}),r=await i.json().catch(()=>({}));if(!i.ok)return void k(r.error||"Remove failed");let l=Number(r.removed||0),n=Number(r.kept||0),o=v?{...v,[a?"retryable":"dead"]:n,...a?{retryableAuthOnly:n>0}:{}}:v;j(o),C(`Removed ${l} ${a?"retry-failed":"dead"} model(s).`+(n>0?` Kept ${n} credential failure(s).`:"")),A.current.onComplete?.({...o||{},removed:l,kept:n,removedStatus:s})}catch(e){k(e?.message||"Remove failed")}finally{$("")}}}async function z(){if(!e)return;let t=await fetch(`/api/providers/${e}/model-probes/cache`,{method:"DELETE"}),s=await t.json().catch(()=>({}));t.ok?(C(`Cleared probe cache (${s.cleared||0} rows). Next verify will re-test everything.`),j(null),y(null),A.current.onComplete?.({cacheCleared:!0,cleared:s.cleared||0})):k(s.error||"Clear cache failed")}(0,i.useEffect)(()=>{A.current={onComplete:l,onStarted:n},E.current=e}),(0,i.useEffect)(()=>{D(r)},[r]);let q=g?.total?Math.min(100,Math.round(g.done/g.total*100)):0;return(0,a.jsxs)("div",{className:"mb-4 rounded-lg border border-border bg-sidebar/40 p-3 space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"text-sm font-semibold text-text-main",children:"Verify models"}),(0,a.jsxs)("p",{className:"text-[11px] text-text-muted mt-0.5",children:["Batch-ping availability and latency. Dead = permanently unavailable (missing, blocked, or deprecated) and can be removed; retry = transient (timeout/429/5xx). Known-dead models are skipped until you Clear cache. Caps: ",I,"."]})]}),o&&(0,a.jsx)("button",{type:"button",onClick:o,className:"p-1 text-text-muted hover:text-text-main rounded",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"close"})})]}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-3 items-end",children:[(0,a.jsxs)("label",{className:"text-xs text-text-muted",children:["Concurrency",(0,a.jsx)("input",{type:"number",min:1,max:16,value:c,disabled:f,onChange:e=>m(e.target.value),className:"mt-1 block w-20 rounded-md border border-border bg-background px-2 py-1 text-xs"})]}),(0,a.jsxs)("label",{className:"text-xs text-text-muted",children:["Batch size",(0,a.jsx)("input",{type:"number",min:1,max:200,value:u,disabled:f,onChange:e=>p(e.target.value),className:"mt-1 block w-20 rounded-md border border-border bg-background px-2 py-1 text-xs"})]}),(0,a.jsxs)("label",{className:"text-xs text-text-muted",children:["Timeout (s)",(0,a.jsx)("input",{type:"number",min:1,max:60,value:x,disabled:f,onChange:e=>h(e.target.value),className:"mt-1 block w-20 rounded-md border border-border bg-background px-2 py-1 text-xs"})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[f?(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"stop",onClick:P,children:"Cancel"}):(0,a.jsx)(d.$n,{size:"sm",icon:"science",onClick:M,disabled:!e||0===R,children:"Start"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"delete_sweep",onClick:z,disabled:f,children:"Clear cache"})]})]}),g&&(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)("div",{className:"h-1.5 w-full rounded-full bg-border overflow-hidden",children:(0,a.jsx)("div",{className:"h-full bg-primary transition-all",style:{width:`${q}%`}})}),(0,a.jsxs)("p",{className:"text-[11px] text-text-muted flex flex-wrap gap-x-2",children:[(0,a.jsxs)("span",{title:"Models probed this run",children:[g.done,"/",g.total," tested"]}),(0,a.jsxs)("span",{title:"Reachable",children:["\xb7 ok ",g.ok]}),(0,a.jsxs)("span",{title:"Permanently unavailable this run (missing, blocked, or deprecated)",children:["\xb7 dead ",g.dead]}),(0,a.jsxs)("span",{title:"Transient failure this run (timeout / 429 / 5xx / network); re-testable",children:["\xb7 retry ",g.retryable]}),g.skippedDead?(0,a.jsxs)("span",{title:"Not probed — cache already marks them dead. Clear cache to re-test.",children:["\xb7 skipped known-dead ",g.skippedDead]}):null,g.skippedDup?(0,a.jsxs)("span",{title:"Duplicate ids collapsed",children:["\xb7 dupes ",g.skippedDup]}):null]})]}),N&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:N}),w&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:w}),v&&(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:[(0,a.jsxs)("span",{className:"text-xs text-text-main",children:["Summary: ",v.ok," ok \xb7 ",v.dead," dead \xb7 ",v.retryable," retry",v.skippedDead?` \xb7 ${v.skippedDead} skipped known-dead`:"",v.cancelled?" \xb7 cancelled":""]}),v.dead>0&&(0,a.jsxs)(d.$n,{size:"sm",variant:"primary",icon:"delete_sweep",onClick:()=>U("dead"),disabled:f||!!S,loading:"dead"===S,children:["Remove ",v.dead," dead"]}),v.retryable>0&&!v.retryableAuthOnly&&(0,a.jsxs)(d.$n,{size:"sm",variant:"danger",icon:"delete_sweep",onClick:()=>U("retryable"),disabled:f||!!S,loading:"retryable"===S,children:["Remove ",v.retryable," retry failures"]})]})]})}L.propTypes={connectionId:A().string,providerAlias:A().string,models:A().arrayOf(A().object),jobSnapshot:A().object,onComplete:A().func,onStarted:A().func,onClose:A().func};var K=s(36861),B=s(53578);let H={claude:"claudeAutoPing",codex:"codexAutoPing"};function V(){let e,t,s,l=(0,r.useParams)(),u=(0,r.useRouter)(),p=l.id,{getCaps:x}=(0,j.y)(),[h,f]=(0,i.useState)([]),[b,g]=(0,i.useState)([]),[k,$]=(0,i.useState)(!0),[A,O]=(0,i.useState)(null),[I,D]=(0,i.useState)(!1),[P,_]=(0,i.useState)(!1),[J,V]=(0,i.useState)(!1),[W,G]=(0,i.useState)(""),[Q,Z]=(0,i.useState)(!1),[X,Y]=(0,i.useState)(!1),[ee,et]=(0,i.useState)(!1),[es,ea]=(0,i.useState)(null),[ei,er]=(0,i.useState)({}),[el,en]=(0,i.useState)([]),[eo,ed]=(0,i.useState)(!1),[ec,em]=(0,i.useState)({}),[eu,ep]=(0,i.useState)(""),[ex,eh]=(0,i.useState)(()=>new Set),[ef,eb]=(0,i.useState)(!1),[eg,ey]=(0,i.useState)(null),[ev,ej]=(0,i.useState)(""),[ew,ek]=(0,i.useState)(!1),[eN,eC]=(0,i.useState)("30"),[eS,e$]=(0,i.useState)("auto"),[eA,eT]=(0,i.useState)({enabled:!1,connections:{}}),[eE,eO]=(0,i.useState)([]),[eR,eI]=(0,i.useState)([]),[eD,eM]=(0,i.useState)([]),[eP,eU]=(0,i.useState)([]),[ez,eq]=(0,i.useState)(null),[e_,eF]=(0,i.useState)(!1),[eJ,eL]=(0,i.useState)(!1),[eK,eB]=(0,i.useState)(!1),[eH,eV]=(0,i.useState)(null),[eW,eG]=(0,i.useState)({}),[eQ,eZ]=(0,i.useState)(null),eX=(0,i.useRef)(!1),eY=(0,i.useRef)(null),e0=(0,i.useRef)(0),e1=(0,i.useRef)(0),[e2,e5]=(0,i.useState)(!1),[e3,e4]=(0,i.useState)(""),[e6,e8]=(0,i.useState)(!1),[e7,e9]=(0,i.useState)(null),[te,tt]=(0,i.useState)({}),[ts,ta]=(0,i.useState)({}),[ti,tr]=(0,i.useState)("all"),{copied:tl,copy:tn}=(0,v.C)(),to="ag_risk_confirmed",td=A?{id:A.id,name:A.name||("anthropic-compatible"===A.type?"Anthropic Compatible":"OpenAI Compatible"),color:"anthropic-compatible"===A.type?"#D97757":"#10A37F",textIcon:"anthropic-compatible"===A.type?"AC":"OC",apiType:A.apiType,baseUrl:A.baseUrl,type:A.type}:c.zN[p]||c.fg[p]||c.IS[p]||c.nJ[p]||c.br[p],tc=td?.authModes||[],tm=!!c.zN[p]||!!c.IS[p]||tc.includes("oauth"),tu=!!c.fg[p]||tc.includes("apikey"),tp=!!c.IS[p]?.noAuth,tx=(0,m.KC)(p),th=(()=>{let e=new Map(tx.map(e=>[e.id,e]));for(let t of eR)t?.id&&e.set(t.id,{...e.get(t.id),...t});return[...e.values()]})(),tf=(0,c.wG)(p),tb=(0,c.mq)(p),tg=(0,c.gb)(p),ty=tb||tg,tv=h.some(e=>!1!==e.isActive),tj=function({isCompatible:e,hasActiveConnection:t}){let s=!e,a=!e;return{showToolbar:s||t||a,showImport:s,showVerify:t,showBulkControls:a}}({isCompatible:ty,hasActiveConnection:tv}),tw=!ty&&tm&&tu,tk="xai"===p?"Grok Build OAuth":"OAuth",tN="xai"===p?"xAI API Key":"API Key",tC=()=>{D(!0)},tS=()=>{"antigravity"===p&&"true"!==window.localStorage.getItem(to)?eF(!0):tm?tC():(G(""),V(!0))},t$=()=>{G(""),V(!0)},tA=()=>{tm?tS():t$()},tT=e=>{if(!eS||"auto"===eS)return null;let t=y(p,e);return t&&t.includes(eS)?eS:null},tE=(()=>{let e=new Set;for(let t of th){let s=y(p,t.id);s&&s.forEach(t=>{"none"!==t&&e.add(t)})}return e.size?["auto",...e]:null})(),tO=ty?p:tf,tR=ty?A?.prefix||p:tf,tI=(0,C.Iz)(eP,tO),tD=e=>(0,C.uJ)(tI,e,tO),tM=(0,i.useCallback)(async()=>{try{let e=await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(tO)}`,{cache:"no-store"}),t=await e.json();e.ok&&eU(t.ids||[])}catch(e){(0,E.s)("Error fetching disabled models:",e)}},[tO]),tP=async e=>{try{(await fetch("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:tO,ids:[e]})})).ok&&await tM()}catch(e){(0,E.s)("Error disabling model:",e)}},tU=async e=>{try{if(!(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(tO)}&id=${encodeURIComponent(e)}`,{method:"DELETE"})).ok)return!1;return await tM(),!0}catch(e){return(0,E.s)("Error enabling model:",e),!1}},tz=async e=>{e.length&&eq({title:"Disable All Models",message:`Disable all ${e.length} model(s)?`,onConfirm:async()=>{eq(null);try{(await fetch("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:tO,ids:e})})).ok&&await tM()}catch(e){(0,E.s)("Error disabling all models:",e)}}})},tq=async()=>{try{(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(tO)}`,{method:"DELETE"})).ok&&await tM()}catch(e){(0,E.s)("Error enabling all models:",e)}},t_=(0,i.useCallback)(async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&er(t.aliases||{})}catch(e){(0,E.s)("Error fetching aliases:",e)}},[]),tF=(0,i.useCallback)(async()=>{try{let e=await fetch("/api/models/custom",{cache:"no-store"}),t=await e.json();e.ok&&en(t.models||[])}catch(e){(0,E.s)("Error fetching custom models:",e)}},[]);(0,i.useEffect)(()=>{"kilocode"===p&&fetch("/api/providers/kilo/free-models").then(e=>e.json()).then(e=>{e.models?.length&&eM(e.models)}).catch(()=>{})},[p]);let tJ=(0,i.useCallback)(async()=>{try{let[e,t,s]=await Promise.all([fetch("/api/providers",{cache:"no-store"}),fetch("/api/provider-nodes",{cache:"no-store"}),fetch("/api/settings",{cache:"no-store"})]),a=await e.json(),i=await t.json(),r=s.ok?await s.json():{};if(e.ok){let e=(a.connections||[]).filter(e=>e.provider===p);f(e)}let l=(r.providerStrategies||{})[p]||{};ey(l.fallbackStrategy||null),ej(null!=l.stickyRoundRobinLimit?String(l.stickyRoundRobinLimit):"1");let n=l.accountScheduler||{};ek(!0===n.enabled),eC(String(Math.max(1,Math.round((n.sessionAffinityTtlSeconds||1800)/60))));let o=(r.providerThinking||{})[p]||{};e$(o.mode||"auto");let d=H[p],c=d&&r[d]||{};if(eT({enabled:!0===c.enabled,connections:c.connections||{}}),t.ok){let e=(i.nodes||[]).find(e=>e.id===p)||null;if(!e&&ty)for(let t=0;t<3;t+=1){await new Promise(e=>setTimeout(e,150));let t=await fetch("/api/provider-nodes",{cache:"no-store"});if(t.ok&&(e=((await t.json()).nodes||[]).find(e=>e.id===p)||null))break}O(e)}}catch(e){(0,E.s)("Error fetching connections:",e)}finally{$(!1)}},[p,ty]),tL=(0,i.useCallback)(async(e=null)=>{let t=++e1.current,s=e?h.find(t=>t.id===e&&!1!==t.isActive):h.find(e=>b.includes(e.id)&&!1!==e.isActive)||h.find(e=>!1!==e.isActive);if(!s){ta({}),tt({});return}try{let e=await fetch(`/api/providers/${s.id}/model-probes`,{cache:"no-store"});if(!e.ok)return;let a=await e.json().catch(()=>({})),i={},r={};for(let e of a.probes||[])i[e.modelId]="ok"===e.status?"ok":"dead"===e.status?"dead":"retry",null!=e.latencyMs&&(r[e.modelId]=e.latencyMs);if(t!==e1.current)return;ta(i),tt(r)}catch{}},[h,b]),tK=async e=>{try{let t=await fetch(`/api/provider-nodes/${p}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),s=await t.json();t.ok&&(O(s.node),await tJ(),et(!1))}catch(e){(0,E.s)("Error updating provider node:",e)}},tB=async(e,t)=>{try{return await (0,B.T)(p,s=>{let a={...s};return e?a.fallbackStrategy=e:delete a.fallbackStrategy,"round-robin"===e&&""!==t?a.stickyRoundRobinLimit=Number(t)||3:e||delete a.stickyRoundRobinLimit,a}),!0}catch(e){return(0,E.s)("Error saving provider strategy:",e),!1}},tH=async(e,t)=>{let s=Math.min(1440,Math.max(1,Number.parseInt(t,10)||30));try{return await (0,B.T)(p,t=>({...t,accountScheduler:{...t.accountScheduler||{},enabled:e,sessionAffinityTtlSeconds:60*s}})),!0}catch(e){return(0,E.s)("Error saving balanced scheduler:",e),!1}},tV=async e=>{let t=e?"round-robin":null,s=e?ev||"1":ev;await tB(t,s)&&(e&&!ev&&ej("1"),ey(t))},tW=async e=>{await tB("round-robin",e)&&ej(e)},tG=async e=>{await tH(e,eN)&&ek(e)},tQ=async e=>{await tH(ew,e)&&eC(e)},tZ=async e=>{try{let t=await fetch("/api/settings",{cache:"no-store"}),s={...(t.ok?await t.json():{}).providerThinking||{}};e&&"auto"!==e?s[p]={mode:e}:delete s[p],await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerThinking:s})})}catch(e){(0,E.s)("Error saving thinking config:",e)}},tX=async e=>{let t=H[p];if(t){eT(e);try{await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[t]:e})})}catch(e){(0,E.s)("Error saving auto-ping config:",e)}}};(0,i.useEffect)(()=>{tJ(),t_(),tF(),tM()},[tJ,t_,tF,tM]),(0,i.useEffect)(()=>{tL()},[tL]),(0,i.useEffect)(()=>{if(ty)return;let e=h.find(e=>!1!==e.isActive);if(!e)return void eI([]);let t=!1;return fetch(`/api/providers/${e.id}/models`,{cache:"no-store"}).then(e=>e.json().catch(()=>({}))).then(e=>{!t&&Array.isArray(e.models)&&e.models.length>0&&eI(e.models)}).catch(()=>{}),()=>{t=!0}},[h,ty]),(0,i.useEffect)(()=>{let e=(c.zN[p]||c.fg[p]||c.IS[p]||c.nJ[p])?.modelsFetcher;e&&N(e).then(eO)},[p]);let tY=(0,i.useCallback)(e=>{let t=++e0.current;eY.current&&(clearTimeout(eY.current),eY.current=null);let s=async()=>{try{let a=await fetch(`/api/providers/${e}/model-probes/verify/status`,{cache:"no-store"}),i=await a.json().catch(()=>null);if(t!==e0.current)return;if(!a.ok||!i?.status)throw Error("Verify status temporarily unavailable");e9(i&&i.status?i:null),i?.status==="running"?eY.current=setTimeout(s,1500):(eY.current=null,await tL(e))}catch{t===e0.current&&(eY.current=setTimeout(s,1500))}};eY.current=setTimeout(s,0)},[tL]);(0,i.useEffect)(()=>{let e=h.find(e=>b.includes(e.id)&&!1!==e.isActive)||h.find(e=>!1!==e.isActive);return e?(tY(e.id),()=>{e0.current+=1,eY.current&&(clearTimeout(eY.current),eY.current=null)}):void e9(null)},[h,b,tY]);let t0=async(e,t,s=tf)=>{let a=`${s}/${e}`;try{let e=await fetch("/api/models/alias",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:a,alias:t})});if(e.ok)await t_();else{let t=await e.json();(0,E.s)(t.error||"Failed to set alias")}}catch(e){(0,E.s)("Error setting alias:",e)}},t1=async e=>{try{(await fetch(`/api/models/alias?alias=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await t_()}catch(e){(0,E.s)("Error deleting alias:",e)}},t2=async(e,t="llm",s=tO)=>{try{let a=await fetch("/api/models/custom",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:s,id:e,type:t})});if(a.ok)await tF(),window.dispatchEvent(new CustomEvent("customModelChanged"));else{let e=await a.json();(0,E.s)(e.error||"Failed to add custom model")}}catch(e){(0,E.s)("Error adding custom model:",e)}},t5=async(e,t="llm",s=tO)=>{try{let a=new URLSearchParams({providerAlias:s,id:e,type:t});(await fetch(`/api/models/custom?${a}`,{method:"DELETE"})).ok&&(await tF(),window.dispatchEvent(new CustomEvent("customModelChanged")))}catch(e){(0,E.s)("Error deleting custom model:",e)}},t3=async()=>{if(e2)return;let e=h.find(e=>b.includes(e.id)&&!1!==e.isActive)||h.find(e=>!1!==e.isActive);if(!e)return void(0,E.s)((0,w.Tl)("Add an active connection first"));e5(!0),e4("");try{let t=await fetch(`/api/providers/${e.id}/models`),s=await t.json().catch(()=>({}));if(!t.ok)return void(0,E.s)(s.error||(0,w.Tl)("Failed to fetch models"));let a=s.models||[];if(0===a.length)return void(0,E.s)(s.warning||(0,w.Tl)("No models returned"));let i=new Set;try{let t=await fetch(`/api/providers/${e.id}/model-probes`,{cache:"no-store"});for(let e of(await t.json().catch(()=>({}))).probes||[])"dead"===e.status&&i.add(e.modelId)}catch{}let r=0,l=new Set(th.map(e=>e.id)),n=[],o=[],d=new Set;for(let e of a){let t=(0,S.R2)(e,tO);if(!t)continue;let{id:s,name:a,type:c}=t;if(i.has((0,K.v)(s,tO))){r+=1;continue}let m=`${c}|${s}`;if(d.has(m))continue;if(d.add(m),l.has(s)){tD(s)&&o.push(s);continue}if(el.some(e=>e.providerAlias===tO&&e.id===s&&(0,S.ki)(e.kind||e.type||"llm")===c))continue;let u=`${tO}/${s}`;Object.values(ei).includes(u)||n.push({providerAlias:tO,id:s,type:c,name:a})}let c=0;if(o.length>0)try{for(let e of o)(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(tO)}&id=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&(c+=1);await tM()}catch{}let m=0;if(n.length>0){let e=await fetch("/api/models/custom",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({models:n})}),t=await e.json().catch(()=>({}));if(!e.ok)return void(0,E.s)(t.error||(0,w.Tl)("Failed to save models"));m=t.added??n.length,await tF(),window.dispatchEvent(new CustomEvent("customModelChanged"))}let u=n.filter(e=>"llm"!==e.type).length,p=[];if(m>0&&p.push(`${m} new`),c>0&&p.push(`${c} re-enabled`),0===p.length)e4((0,w.Tl)("All models already in list"));else{let e=`Imported ${p.join(" \xb7 ")} (${a.length} from provider)`;u>0&&(e+=" \xb7 non-chat types stored for media pages"),s.warning&&(e+=` \xb7 ${s.warning}`),e4(e)}if(r>0&&e4(e=>`${e} \xb7 ${r} skipped (known dead)`),m>0||c>0)try{let t=[...th,...n.map(e=>({id:e.id,name:e.name,kind:e.type}))],s=await fetch(`/api/providers/${e.id}/model-probes/verify/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({models:t,providerAlias:tO})}),a=await s.json().catch(()=>({}));if(!s.ok)throw Error(a.error||"Failed to start auto-verify");e9(a&&a.status?a:null),tY(e.id)}catch(e){e4(t=>`${t} \xb7 auto-verify failed: ${e?.message||e}`)}}catch(e){(0,E.s)("Error importing models:",e),(0,E.s)((0,w.Tl)("Error fetching models")+": "+(e?.message||e))}finally{e5(!1)}},t4=async()=>{if(eJ||0===h.length)return;let e=Object.fromEntries(h.map(e=>[e.id,{state:"queued",error:null}]));eX.current=!1,eL(!0),eB(!1),eV(null),eG(e),eZ({total:h.length,completed:0,passed:0,failed:0,stopped:!1});let t=0,s=0;try{for(let e=0;e<h.length;e+=1){if(eX.current){eZ({total:h.length,completed:e,passed:t,failed:s,stopped:!0});break}let a=h[e];eV(a.id),eG(e=>({...e,[a.id]:{state:"testing",error:null}}));try{let e=await fetch(`/api/providers/${a.id}/test`,{method:"POST"}),i=await e.json(),r=!!i.valid;r?t+=1:s+=1,eG(e=>({...e,[a.id]:{state:r?"success":"failed",error:r?null:i.error||null}}))}catch(e){s+=1,eG(t=>({...t,[a.id]:{state:"failed",error:e.message||"Test failed"}}))}eZ({total:h.length,completed:e+1,passed:t,failed:s,stopped:!1}),e<h.length-1&&await new Promise(e=>setTimeout(e,1e3))}}finally{eV(null),eL(!1),eB(!1),eX.current=!1}},t6=async e=>{let t=h.find(t=>t.id===e),s=t?.name?.trim()||t?.email?.trim()||e;eq({title:"Delete Connection",message:`Delete connection “${s}”?`,onConfirm:async()=>{eq(null);try{(await fetch(`/api/providers/${e}`,{method:"DELETE"})).ok&&f(t=>t.filter(t=>t.id!==e))}catch(e){(0,E.s)("Error deleting connection:",e)}}})},t8=()=>{tJ(),D(!1)},t7=async e=>{G("");try{let t=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:p,...e})}),s=null;try{s=await t.json()}catch{s=null}if(t.ok){await tJ(),V(!1);return}G(s?.error||"Failed to save connection")}catch(e){(0,E.s)("Error saving connection:",e),G("Failed to save connection")}},t9=async e=>{try{(await fetch(`/api/providers/${es.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok&&(await tJ(),Y(!1))}catch(e){(0,E.s)("Error updating connection:",e)}},se=async(e,t)=>{try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&f(s=>s.map(s=>s.id===e?{...s,isActive:t}:s))}catch(e){(0,E.s)("Error updating connection status:",e)}},st=async e=>{let t,s=e?.providerSpecificData?.baseUrl;if(s){try{t=new URL(s).hostname.toLowerCase().replace(/^\[|\]$/g,"")}catch{(0,E.s)("Cannot allow-list: invalid base URL",s);return}try{let e=await fetch("/api/settings",{cache:"no-store"});if(!e.ok)throw Error(`Failed to load settings (${e.status})`);let s=await e.json(),a=[...new Set([...s.ssrfAllowHosts||[],t])],i=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({ssrfAllowHosts:a})});if(!i.ok)throw Error(`Failed to update allow list (${i.status})`);await tJ()}catch(e){(0,E.s)("Error adding host to allow list:",e)}}},ss=async(e,t)=>{let s=[...h];[s[e],s[t]]=[s[t],s[e]],f(s);try{await Promise.all([fetch(`/api/providers/${s[e].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:e})}),fetch(`/api/providers/${s[t].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:t})})])}catch(e){(0,E.s)("Error swapping priority:",e),await tJ()}},sa=h.length>0&&b.length===h.length,si=(0,a.jsx)("div",{className:"flex min-w-0 flex-col divide-y divide-black/[0.03] dark:divide-white/[0.03]",children:h.map((e,t)=>(0,a.jsxs)("div",{className:"flex min-w-0 items-stretch",children:[(0,a.jsx)("div",{className:"flex shrink-0 items-center pl-1 sm:pl-2",children:(0,a.jsx)("input",{type:"checkbox",checked:b.includes(e.id),onChange:()=>{var t;return t=e.id,void g(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])},className:"h-4 w-4 rounded border-gray-300 text-primary focus:ring-primary"})}),(0,a.jsx)("div",{className:"flex-1 min-w-0",children:(0,a.jsx)(M,{connection:e,isOAuth:tm,isFirst:0===t,isLast:t===h.length-1,onMoveUp:()=>ss(t,t-1),onMoveDown:()=>ss(t,t+1),onToggleActive:t=>se(e.id,t),autoPing:H[p]&&"oauth"===e.authType?{on:!0===eA.connections[e.id],onToggle:t=>{var s;return s=e.id,void tX({...eA,connections:{...eA.connections,[s]:t}})},provider:p}:null,onEdit:()=>{ea(e),Y(!0)},onDelete:()=>t6(e.id),onAllowlistHost:()=>st(e),oneByOneStatus:eW[e.id]||null})})]},e.id))}),sr=async e=>{if(!ex.has(e)){eh(t=>new Set(t).add(e));try{let t=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${tO}/${e}`})}),s=await t.json();em(t=>({...t,[e]:s.ok?"ok":"error"})),ep(s.ok?"":s.error||"Model not reachable")}catch{em(t=>({...t,[e]:"error"})),ep("Network error")}finally{eh(t=>{let s=new Set(t);return s.delete(e),s})}}};return k?(0,a.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,a.jsx)(d.Qv,{}),(0,a.jsx)(d.Qv,{})]}):td?(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:gap-8 sm:px-0",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)(n(),{href:"/dashboard/providers",className:"inline-flex items-center gap-1 text-sm text-text-muted hover:text-primary transition-colors mb-4",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-lg",children:"arrow_back"}),"Back to Providers"]}),(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3 sm:gap-4",children:[(0,a.jsx)("div",{className:"flex size-12 shrink-0 items-center justify-center rounded-lg",style:{backgroundColor:`${td.color}15`},children:eo?(0,a.jsx)("span",{className:"text-sm font-bold",style:{color:td.color},children:td.textIcon||td.id.slice(0,2).toUpperCase()}):(0,a.jsx)(o.default,{src:tb&&td.apiType?"responses"===td.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":tg?"/providers/anthropic-m.png":`/providers/${td.id}.png`,alt:td.name,width:48,height:48,className:"max-h-12 max-w-12 rounded-lg object-contain",sizes:"48px",onError:()=>ed(!0)})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 flex-wrap",children:[(0,a.jsx)("h1",{className:"truncate text-2xl font-semibold tracking-tight sm:text-3xl",children:td.name}),(td.notice?.apiKeyUrl||td.notice?.signupUrl||td.website)&&(0,a.jsxs)("a",{href:td.notice?.apiKeyUrl||td.notice?.signupUrl||td.website,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline inline-flex items-center gap-1",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"open_in_new"}),td.notice?.apiKeyUrl?"Get API Key":"Sign up / Learn more"]})]}),(0,a.jsxs)("p",{className:"text-text-muted",children:[h.length," connection",1===h.length?"":"s"]})]})]})]}),td.deprecated&&(0,a.jsxs)("div",{className:"flex items-start gap-3 rounded-xl border border-amber-500/25 bg-amber-500/8 px-4 py-3 text-xs text-amber-600 dark:text-amber-400",children:[(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-base text-amber-500 mt-0.5",children:"warning"}),(0,a.jsx)("p",{className:"leading-relaxed font-normal",children:String(td.deprecationNotice).replace(/^⚠️\s*⚠️?\s*/,"")})]}),td.notice?.text&&!td.deprecated&&(0,a.jsxs)("div",{className:"flex flex-col gap-2 rounded-lg border border-blue-500/30 bg-blue-500/10 px-3 py-2 sm:flex-row sm:items-center",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px] text-blue-500 shrink-0",children:"info"}),(0,a.jsx)("p",{className:"min-w-0 flex-1 text-xs leading-relaxed text-blue-600 dark:text-blue-400",children:td.notice.text}),td.notice.apiKeyUrl&&(0,a.jsx)("a",{href:td.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 →"})]}),ty&&A&&(0,a.jsx)(d.Zp,{children:(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:tg?"Anthropic Compatible Details":"OpenAI Compatible Details"}),(0,a.jsxs)("p",{className:"break-all text-sm text-text-muted",children:[tg?"Messages API":"responses"===A.apiType?"Responses API":"Chat Completions"," \xb7 ",(A.baseUrl||"").replace(/\/$/,""),"/",tg?"messages":"responses"===A.apiType?"responses":"chat/completions"]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:()=>{G(""),V(!0)},className:"w-full sm:w-auto",children:"Add API Key"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"edit",onClick:()=>et(!0),className:"w-full sm:w-auto",children:"Edit"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"delete",onClick:async()=>{eq({title:"Delete Compatible Node",message:`Delete this ${tg?"Anthropic":"OpenAI"} Compatible node?`,onConfirm:async()=>{eq(null);try{(await fetch(`/api/provider-nodes/${p}`,{method:"DELETE"})).ok&&u.push("/dashboard/providers")}catch(e){(0,E.s)("Error deleting provider node:",e)}}})},className:"w-full sm:w-auto",children:"Delete"})]})]})}),tp?(0,a.jsx)(d.gw,{providerId:p}):(0,a.jsxs)(d.Zp,{children:[(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Connections"}),(0,a.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:gap-4",children:[h.length>0&&(0,a.jsxs)(a.Fragment,{children:[b.length>0&&(0,a.jsxs)(d.$n,{size:"sm",variant:"danger",icon:"delete",onClick:()=>{let e=b.length;0!==e&&eq({title:`Delete ${e} Connection${e>1?"s":""}`,message:`Delete ${e} connection${e>1?"s":""}? This cannot be undone.`,onConfirm:async()=>{eq(null);let e=0,t=[...b];for(let s of t)try{(await fetch(`/api/providers/${s}`,{method:"DELETE"})).ok||(e+=1)}catch(t){(0,E.s)("Error deleting connection:",t),e+=1}f(e=>e.filter(e=>!t.includes(e.id))),g([]),e>0&&(0,E.s)(`Deleted ${t.length-e} connection(s), ${e} failed.`)}})},children:["Delete Selected (",b.length,")"]}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"sync",onClick:t4,disabled:eJ,children:eJ?"Testing Connection One-by-One...":"Test Connection One-by-One"}),eJ&&(0,a.jsx)(d.$n,{size:"sm",variant:"ghost",icon:"stop",onClick:()=>{eJ&&(eX.current=!0,eB(!0))},disabled:eK,children:eK?"Stopping...":"Stop"})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2 rounded-xl border border-border/60 bg-surface-2/40 p-3",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-medium text-text-main",children:"Balanced Scheduler"}),(0,a.jsx)(d.m_,{text:"Process-local least-inflight scheduling with fresh quota signals. Sessions stay on one account and rebind on failure, cooldown, or cap.",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[15px] text-text-muted cursor-help",children:"info"})})]}),(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[ew&&(0,a.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-text-muted",children:["Affinity",(0,a.jsx)("input",{"aria-label":"Session affinity minutes",type:"number",min:1,max:1440,value:eN,onChange:e=>tQ(e.target.value),className:"w-14 px-2 py-0.5 text-xs border border-border rounded-md bg-background text-text-main focus:outline-none focus:border-primary"}),(0,a.jsx)("span",{className:"text-[11px]",children:"min"})]}),(0,a.jsx)(d.lM,{checked:ew,onChange:tG,"aria-label":"Balanced scheduler"})]})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3 pt-2 border-t border-border/40",title:ew?"Saved and used again when balanced scheduling is off":void 0,children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-medium text-text-main",children:"Round Robin"}),(0,a.jsx)(d.m_,{text:"Cycles through connections sequentially in round-robin fashion.",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[15px] text-text-muted cursor-help",children:"info"})})]}),(0,a.jsxs)("div",{className:"flex items-center gap-3",children:["round-robin"===eg&&(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"text-xs text-text-muted",children:"Sticky:"}),(0,a.jsx)("input",{type:"number",min:1,value:ev,onChange:e=>tW(e.target.value),placeholder:"1",disabled:ew,title:ew?"Saved and used again when balanced scheduling is off":void 0,className:"w-14 px-2 py-0.5 text-xs border border-border rounded-md bg-background text-text-main focus:outline-none focus:border-primary disabled:cursor-not-allowed disabled:opacity-50"})]}),(0,a.jsx)(d.lM,{checked:"round-robin"===eg,onChange:tV,"aria-label":"Round Robin",disabled:ew,title:ew?"Saved and used again when balanced scheduling is off":void 0})]})]})]})]})]}),0===h.length?(0,a.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"inline-flex items-center justify-center w-9 h-9 rounded-full bg-primary/10 text-primary shrink-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:tm?"lock":"key"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"No connections yet"}),tw&&(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["Choose ",tk," or ",tN,"."]})]})]}),(0,a.jsx)("div",{className:"flex gap-2",children:tw?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.$n,{size:"sm",icon:"lock",variant:"secondary",onClick:tS,children:tk}),(0,a.jsx)(d.$n,{size:"sm",icon:"key",onClick:t$,children:tN})]}):(0,a.jsxs)(a.Fragment,{children:[!ty&&"iflow"===p&&(0,a.jsx)(d.$n,{size:"sm",icon:"cookie",variant:"secondary",onClick:()=>_(!0),children:"Cookie"}),"codex"===p&&(0,a.jsx)(d.$n,{size:"sm",icon:"playlist_add",variant:"secondary",onClick:()=>Z(!0),children:(0,w.Tl)("Bulk Add")}),(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:tA,children:ty?"Add API Key":"iflow"===p?"OAuth":"Add Connection"})]})})]}):(0,a.jsxs)(a.Fragment,{children:[eQ&&(0,a.jsx)("div",{className:"mb-4 rounded-lg border border-black/10 bg-black/[0.02] px-3 py-2 text-xs text-text-muted dark:border-white/10 dark:bg-white/[0.03]",children:(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,a.jsxs)("span",{children:["Total: ",eQ.total]}),(0,a.jsxs)("span",{children:["Completed: ",eQ.completed]}),(0,a.jsxs)("span",{children:["Passed: ",eQ.passed]}),(0,a.jsxs)("span",{children:["Failed: ",eQ.failed]}),eQ.stopped&&(0,a.jsx)("span",{className:"text-amber-600 dark:text-amber-400",children:"Stopped"}),eJ&&eH&&(0,a.jsxs)("span",{children:["Running: ",h.find(e=>e.id===eH)?.name||eH]})]})}),h.length>0&&(0,a.jsx)("div",{className:"mb-3 flex items-center gap-2 border-b border-black/[0.03] pb-2 dark:border-white/[0.03]",children:(0,a.jsxs)("label",{className:"flex cursor-pointer items-center gap-1.5 text-xs text-text-muted hover:text-primary",children:[(0,a.jsx)("input",{type:"checkbox",checked:sa,onChange:()=>{sa?g([]):g(h.map(e=>e.id))},className:"h-3.5 w-3.5 rounded border-gray-300 text-primary focus:ring-primary"}),"Select All"]})}),si,!ty&&(0,a.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-2 sm:flex",children:["iflow"===p&&(0,a.jsx)(d.$n,{size:"sm",icon:"cookie",variant:"secondary",onClick:()=>_(!0),title:"Add connection using browser cookie",className:"w-full sm:w-auto",children:"Cookie"}),"codex"===p&&(0,a.jsx)(d.$n,{size:"sm",icon:"playlist_add",variant:"secondary",onClick:()=>Z(!0),title:(0,w.Tl)("Bulk import codex accounts from JSON"),className:"w-full sm:w-auto",children:(0,w.Tl)("Bulk Add")}),tw?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.$n,{size:"sm",icon:"lock",variant:"secondary",onClick:tS,className:"w-full sm:w-auto",children:tk}),(0,a.jsx)(d.$n,{size:"sm",icon:"key",onClick:t$,className:"w-full sm:w-auto",children:tN})]}):(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:tA,className:"w-full sm:w-auto",children:"Add"})]})]})]}),(0,a.jsxs)(d.Zp,{children:[(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Available Models"}),tE&&(0,a.jsx)("select",{value:eS,onChange:e=>{var t;e$(t=e.target.value),tZ(t)},title:"Appends (level) suffix to copied model names",className:"rounded-md border border-border bg-background px-2 py-1 text-xs focus:border-primary focus:outline-none",children:tE.map(e=>(0,a.jsx)("option",{value:e,children:`Thinking: ${e.charAt(0).toUpperCase()+e.slice(1)}`},e))})]}),tj.showToolbar&&(e=(tj.showBulkControls?[...th,...eD.filter(e=>!th.some(t=>t.id===e.id))].filter(e=>{let t=(0,m.CP)(e);return!t||"llm"===t}).map(e=>e.id):[]).filter(e=>!tD(e)),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[tj.showImport&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:e2?"progress_activity":"cloud_download",onClick:t3,disabled:e2||!tv,title:tv?"Import models from the active connection":"Add an active connection to import models",children:e2?"Importing...":"Import models"}),tj.showVerify&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:e7?.status==="running"?"progress_activity":"science",onClick:()=>e8(e=>!e),children:e7?.status==="running"?`Verifying ${e7.done}/${e7.total}`:e6?"Hide verify":"Verify models"}),tj.showBulkControls&&eP.length>0&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"restart_alt",onClick:tq,children:"Active All"}),tj.showBulkControls&&e.length>0&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"block",onClick:()=>tz(e),children:"Disable All"})]}))]}),!!eu&&(0,a.jsx)("p",{className:"text-xs text-red-500 mb-3 break-words",children:eu}),e3&&(0,a.jsxs)("div",{className:"mb-3 flex items-center justify-between gap-2 rounded-xl border border-primary/30 bg-primary/10 px-3.5 py-2 text-xs font-medium text-text-main",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px] text-primary",children:"info"}),(0,a.jsx)("span",{children:e3})]}),(0,a.jsx)("button",{onClick:()=>e4(""),className:"text-text-muted hover:text-text-main p-0.5 rounded",title:"Dismiss",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"close"})})]}),e6&&(t=h.find(e=>b.includes(e.id)&&!1!==e.isActive)||h.find(e=>!1!==e.isActive),s=[...(0,C.R3)({customModels:el,modelAliases:ei,providerAlias:tO,builtInModels:th,type:"llm"}).filter(e=>!tD(e.id)).map(e=>({id:e.id,name:e.name||e.id,kind:"llm"})),...th.filter(e=>{let t=(0,m.CP)(e);return(!t||"llm"===t)&&!tD(e.id)}).map(e=>({id:e.id,name:e.name||e.id,kind:"llm"}))],(0,a.jsx)(L,{connectionId:t?.id,providerAlias:tO,models:s,jobSnapshot:e7,onClose:()=>e8(!1),onStarted:e=>{e9(e&&e.status?e:null);let s=e?.connectionId||t?.id;s&&tY(s)},onComplete:async e=>{e?.removedStatus&&e9(t=>t?{...t,dead:Number(e.dead??t.dead??0),retryable:Number(e.retryable??t.retryable??0),retryableAuthOnly:!0===e.retryableAuthOnly}:t),e?.removed>0&&await tF(),e?.removed>0&&await tM(),(e?.removed>0||e?.cacheCleared)&&await tL(t?.id)}})),(()=>{let e,t,s;if(ty)return(0,a.jsx)(R,{providerStorageAlias:tO,providerDisplayAlias:tR,modelAliases:ei,customModels:el,copied:tl,onCopy:tn,onSetAlias:t0,onDeleteAlias:t1,onAddCustomModel:e=>t2(e,"llm",tO),onDeleteCustomModel:e=>t5(e,"llm",tO),onRefreshModels:tF,connections:h,isAnthropic:tg,disabledModelIds:eP,onEnableModel:tU});let i=[...th,...eD.filter(e=>!th.some(t=>t.id===e.id))].filter(e=>{let t=(0,m.CP)(e);return!t||"llm"===t}),r=i.filter(e=>!tD(e.id)),l=i.filter(e=>tD(e.id)),n=(0,C.R3)({customModels:el,modelAliases:ei,providerAlias:tO,builtInModels:th,type:"llm"}),o=n.filter(e=>!tD(e.id)&&("all"===ti||(ts[(0,K.v)(e.id,tO)]||null)===ti)),d=r.filter(e=>"all"===ti||(ts[(0,K.v)(e.id,tO)]||null)===ti);return(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsx)("div",{className:"mb-2 flex flex-wrap items-center gap-1.5 text-xs",children:[{id:"all",label:"All",count:r.length+n.filter(e=>!tD(e.id)).length},{id:"ok",label:"Reachable",count:[...r,...n].filter(e=>!tD(e.id)&&("ok"===ts[(0,K.v)(e.id,tO)]||"ok"===ec[e.id])).length},{id:"dead",label:"Dead",count:[...r,...n].filter(e=>!tD(e.id)&&("dead"===ts[(0,K.v)(e.id,tO)]||"error"===ec[e.id])).length},{id:"retry",label:"Retry",count:[...r,...n].filter(e=>!tD(e.id)&&"retry"===ts[(0,K.v)(e.id,tO)]).length}].map(e=>(0,a.jsxs)("button",{onClick:()=>tr(e.id),className:`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1 text-xs font-medium transition-all ${ti===e.id?"bg-primary text-black font-semibold shadow-sm":"bg-surface-2/60 border border-border/40 text-text-muted hover:border-border hover:text-text-main"}`,children:[(0,a.jsx)("span",{children:e.label}),(0,a.jsx)("span",{className:`rounded-full px-1.5 py-0.2 text-[10px] tabular-nums ${ti===e.id?"bg-black/20 text-black font-bold":"bg-black/10 dark:bg-white/10 text-text-muted"}`,children:e.count})]},e.id))}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-3",children:[o.map(e=>{let t=(0,K.v)(e.id,tO);return(0,a.jsx)(T,{model:{id:e.id,name:e.name},fullModel:`${tR}/${e.id}`,alias:e.alias,copied:tl,onCopy:tn,onSetAlias:()=>{},onDeleteAlias:()=>{"custom"===e.source?t5(e.id,"llm",tO):t1(e.alias)},testStatus:ec[e.id],onTest:h.length>0||tp?()=>sr(e.id):void 0,isTesting:ex.has(e.id),isCustom:!0,isFree:!1,caps:x(`${p}/${e.id}`),thinkingSuffix:tT(e.id),latencyMs:te[e.id]??te[t],probeState:e7?.status==="running"&&e7?.perModel?.[t]?e7.perModel[t]:ts[t]||null},`${e.source}-${e.fullModel}`)}),d.map(e=>{let t=`${tO}/${e.id}`,s=`${p}/${e.id}`,i=Object.entries(ei).find(([,e])=>e===t||e===s)?.[0],r=(0,K.v)(e.id,tO);return(0,a.jsx)(T,{model:e,fullModel:`${tR}/${e.id}`,alias:i,copied:tl,onSetAlias:t=>t0(e.id,t,tO),onCopy:tn,onDeleteAlias:()=>t1(i),testStatus:ec[e.id],onTest:h.length>0||tp?()=>sr(e.id):void 0,isTesting:ex.has(e.id),isFree:e.isFree,onDisable:()=>tP(e.id),caps:x(`${p}/${e.id}`),thinkingSuffix:tT(e.id),latencyMs:te[e.id]??te[r],probeState:e7?.status==="running"&&e7?.perModel?.[r]?e7.perModel[r]:ts[r]||null},e.id)}),(0,a.jsxs)("button",{onClick:()=>eb(!0),className:"flex min-h-[58px] min-w-[200px] flex-1 items-center justify-center gap-2 rounded-xl border border-dashed border-primary/40 bg-primary/5 px-4 py-3 text-xs font-medium text-primary transition-all hover:border-primary hover:bg-primary/10 hover:shadow-soft sm:flex-none",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"add_circle"}),"Add Custom Model"]}),eE.length>0&&(e=new Set([...Object.values(ei),...n.map(e=>e.fullModel)]),t=new Set(th.map(e=>e.id)),0===(s=eE.filter(s=>!e.has(`${tO}/${s.id}`)&&!t.has(s.id))).length?null:(0,a.jsxs)("div",{className:"w-full mt-2",children:[(0,a.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"Suggested free models (≥200k context):"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:s.map(e=>(0,a.jsxs)("button",{onClick:async()=>{await t2(e.id,"llm",tO)},className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg border border-black/10 dark:border-white/10 text-xs text-text-muted hover:text-primary hover:border-primary/40 hover:bg-primary/5 transition-colors",title:`${e.name} \xb7 ${(e.contextLength/1e3).toFixed(0)}k ctx`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"add"}),e.id.split("/").pop()]},e.id))})]})),l.length>0&&(0,a.jsxs)("div",{className:"w-full mt-2",children:[(0,a.jsxs)("p",{className:"text-xs text-text-muted mb-2",children:["Disabled models (",l.length,"):"]}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:l.map(e=>(0,a.jsxs)("button",{onClick:()=>tU(e.id),className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg border border-dashed border-black/10 dark:border-white/10 text-xs text-text-muted hover:text-primary hover:border-primary/40 hover:bg-primary/5 transition-colors",title:"Restore model",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"add"}),e.id]},e.id))})]})]})]})})()]}),"kiro"===p?(0,a.jsx)(d.Mh,{isOpen:I,providerInfo:td,onSuccess:t8,onClose:()=>D(!1)}):"cursor"===p?(0,a.jsx)(d.G9,{isOpen:I,onSuccess:t8,onClose:()=>D(!1)}):"gitlab"===p?(0,a.jsx)(d.vj,{isOpen:I,providerInfo:td,onSuccess:t8,onClose:()=>D(!1)}):(0,a.jsx)(d.LF,{isOpen:I,provider:p,providerInfo:td,onSuccess:t8,onClose:()=>D(!1)}),"iflow"===p&&(0,a.jsx)(d.vE,{isOpen:P,onSuccess:()=>{tJ(),_(!1)},onClose:()=>_(!1)}),(0,a.jsx)(U,{isOpen:J,provider:p,providerName:td.name,isCompatible:ty,isAnthropic:tg,authType:td?.authType,authHint:td?.authHint,website:td?.website,error:W,onSave:t7,onBulkDone:tJ,onClose:()=>{G(""),V(!1)}}),(0,a.jsx)(d.wI,{isOpen:X,connection:es,onSave:t9,onClose:()=>Y(!1)}),ty&&(0,a.jsx)(z,{isOpen:ee,node:A,onSave:tK,onClose:()=>et(!1),isAnthropic:tg}),!ty&&(0,a.jsx)(q,{isOpen:ef,providerAlias:tO,providerDisplayAlias:tR,onSave:async e=>{await t2(e,"llm",tO),eb(!1)},onClose:()=>eb(!1)}),"codex"===p&&(0,a.jsx)(F,{isOpen:Q,onClose:()=>Z(!1),onSuccess:tJ}),(0,a.jsx)(d.uo,{isOpen:e_,onClose:()=>eF(!1),onConfirm:()=>{(window.localStorage.setItem(to,"true"),eF(!1),tm)?tC():t$()},title:"Risk Notice",message:td?.deprecationNotice,confirmText:"I Understand, Continue",cancelText:"Cancel",variant:"danger"}),(0,a.jsx)(d.uo,{isOpen:!!ez,onClose:()=>eq(null),onConfirm:ez?.onConfirm,title:ez?.title||"Confirm",message:ez?.message,variant:"danger"})]}):(0,a.jsxs)("div",{className:"text-center py-20",children:[(0,a.jsx)("p",{className:"text-text-muted",children:"Provider not found"}),(0,a.jsx)(n(),{href:"/dashboard/providers",className:"text-primary mt-4 inline-block",children:"Back to Providers"})]})}},53578:(e,t,s)=>{"use strict";async function a(e,t,s=fetch){let i=await s("/api/settings",{cache:"no-store"});if(!i.ok)throw Error(`Failed to load settings (${i.status})`);let r=(await i.json()).providerStrategies||{},l=t(r[e]||{}),n={...r};l&&Object.keys(l).length>0?n[e]=l:delete n[e];let o=await s("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerStrategies:n})});if(!o.ok)throw Error(`Failed to save settings (${o.status})`);return l}s.d(t,{T:()=>a})},70217:(e,t,s)=>{"use strict";function a(e,t){return!1===e?"default":"active"===t||"success"===t?"success":"error"===t||"expired"===t||"unavailable"===t?"error":"default"}s.d(t,{g:()=>a})}},e=>{e.O(0,[2574,3862,782,8500,594,1321,4707,1330,8441,3794,7358],()=>e(e.s=7687)),_N_E=e.O()}]);
|
package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/new/page-413b59dd764a1563.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9089],{15615:(e,a,r)=>{"use strict";r.r(a),r.d(a,{default:()=>p});var t=r(95155),l=r(12115),i=r(73321),s=r(98500),d=r.n(s),o=r(35497),n=r(90620);let c=Object.values(n.Q2).map(e=>({value:e.id,label:e.name})),u=Object.values(n.MA).map(e=>({value:e.id,label:e.name}));function p(){let e=(0,i.useRouter)(),[a,r]=(0,l.useState)(!1),[s,p]=(0,l.useState)({provider:"",authMethod:"apikey",apiKey:"",displayName:"",isActive:!0}),[m,h]=(0,l.useState)({}),x=(e,a)=>{p(r=>({...r,[e]:a})),m[e]&&h(a=>({...a,[e]:null}))},f=async a=>{let t;if(a.preventDefault(),t={},s.provider||(t.provider="Please select a provider"),"apikey"!==s.authMethod||s.apiKey.trim()||(t.apiKey="API Key is required"),h(t),0===Object.keys(t).length){r(!0);try{let a=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,apiKey:s.apiKey.trim()})});if(a.ok)e.push("/dashboard/providers");else{let e=await a.json();h({submit:e.error||"Failed to create provider"})}}catch(e){h({submit:"An error occurred. Please try again."})}finally{r(!1)}}},v=n.Q2[s.provider];return(0,t.jsxs)("div",{className:"max-w-2xl mx-auto",children:[(0,t.jsxs)("div",{className:"mb-8",children:[(0,t.jsxs)(d(),{href:"/dashboard/providers",className:"inline-flex items-center gap-1 text-sm text-text-muted hover:text-primary transition-colors mb-4",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-lg",children:"arrow_back"}),"Back to Providers"]}),(0,t.jsx)("h1",{className:"text-3xl font-semibold tracking-tight",children:"Add New Provider"}),(0,t.jsx)("p",{className:"text-text-muted mt-2",children:"Configure a new AI provider to use with your applications."})]}),(0,t.jsx)(o.Zp,{children:(0,t.jsxs)("form",{onSubmit:f,className:"flex flex-col gap-6",children:[(0,t.jsx)(o.l6,{label:"Provider",options:c,value:s.provider,onChange:e=>x("provider",e.target.value),placeholder:"Select a provider",error:m.provider,required:!0}),v&&(0,t.jsxs)(o.Zp.Section,{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"size-10 rounded-lg flex items-center justify-center bg-bg border border-border",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-xl",style:{color:v.color},children:v.icon})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"font-medium",children:v.name}),(0,t.jsx)("p",{className:"text-sm text-text-muted",children:"Selected provider"})]})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,t.jsxs)("span",{id:"new-provider-auth-method-label",className:"text-sm font-medium",children:["Authentication Method ",(0,t.jsx)("span",{className:"text-red-500","aria-hidden":"true",children:"*"})]}),(0,t.jsx)("div",{className:"flex gap-3",role:"radiogroup","aria-labelledby":"new-provider-auth-method-label",children:u.map(e=>(0,t.jsxs)("button",{type:"button",role:"radio","aria-checked":s.authMethod===e.value,onClick:()=>x("authMethod",e.value),className:`flex-1 flex items-center justify-center gap-2 p-4 rounded-lg border transition-all ${s.authMethod===e.value?"border-primary bg-primary/5 text-primary":"border-border hover:border-primary/50"}`,children:[(0,t.jsx)("span",{className:"material-symbols-outlined","aria-hidden":"true",children:"apikey"===e.value?"key":"cookie"===e.value?"cookie":"lock"}),(0,t.jsx)("span",{className:"font-medium",children:e.label})]},e.value))})]}),"apikey"===s.authMethod&&(0,t.jsx)(o.pd,{label:"API Key",type:"password",autoComplete:"off",placeholder:"Enter your API key",value:s.apiKey,onChange:e=>x("apiKey",e.target.value),error:m.apiKey,hint:v?.notice?.apiKeyUrl?(0,t.jsxs)("span",{children:["Your key is encrypted and stored locally."," ",(0,t.jsxs)("a",{href:v.notice.apiKeyUrl,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline inline-flex items-center gap-0.5",children:["Get API Key ",(0,t.jsx)("span",{className:"material-symbols-outlined text-xs",children:"open_in_new"})]})]}):"Your API key will be encrypted and stored securely.",required:!0}),"cookie"===s.authMethod&&(0,t.jsx)(o.pd,{label:"Session Cookie / Token",type:"password",autoComplete:"off",placeholder:"Paste your session cookie or token",value:s.apiKey,onChange:e=>x("apiKey",e.target.value),error:m.apiKey,hint:"Your cookie credential will be encrypted and stored securely.",required:!0}),"oauth"===s.authMethod&&(0,t.jsxs)("div",{className:"p-4 rounded-lg bg-surface-2 border border-border text-sm text-text-muted flex items-start gap-3",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-primary text-lg mt-0.5",children:"lock_open"}),(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)("p",{className:"font-medium text-text-main",children:"OAuth Authentication"}),(0,t.jsxs)("p",{className:"text-xs text-text-muted mt-0.5",children:["OAuth authorization for ",v?.name||"this provider"," will launch via official browser sign-in on the Provider Settings page."]})]})]}),(0,t.jsx)(o.pd,{label:"Display Name",placeholder:"e.g., Production API, Dev Environment",value:s.displayName,onChange:e=>x("displayName",e.target.value),hint:"Optional. A friendly name to identify this configuration."}),(0,t.jsx)(o.lM,{checked:s.isActive,onChange:e=>x("isActive",e),label:"Active",description:"Enable this provider for use in your applications"}),m.submit&&(0,t.jsx)("div",{role:"alert",className:"p-4 rounded-lg bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 text-red-600 dark:text-red-400 text-sm",children:m.submit}),(0,t.jsxs)("div",{className:"flex gap-3 pt-4 border-t border-border",children:[(0,t.jsx)(d(),{href:"/dashboard/providers",className:"flex-1",children:(0,t.jsx)(o.$n,{type:"button",variant:"ghost",fullWidth:!0,children:"Cancel"})}),(0,t.jsx)(o.$n,{type:"submit",loading:a,fullWidth:!0,className:"flex-1",children:"Create Provider"})]})]})})]})}},35497:(e,a,r)=>{"use strict";r.d(a,{x0:()=>k.default,Ex:()=>n.default,$n:()=>t.default,nh:()=>P.default,Zp:()=>s.default,Qv:()=>o.CardSkeleton,CK:()=>h.default,uo:()=>d.ConfirmModal,G9:()=>b.default,wI:()=>N.default,vj:()=>g.default,vE:()=>j.default,pd:()=>l.default,Mh:()=>y.default,uR:()=>m.default,Nf:()=>x.default,aF:()=>d.default,rq:()=>p.default,gw:()=>w.default,LF:()=>u.default,Wx:()=>K.default,gM:()=>v.default,Iz:()=>A.default,l6:()=>i.default,lM:()=>c.default,m_:()=>C.default,jK:()=>f.default});var t=r(92542),l=r(11910),i=r(98),s=r(84588),d=r(81127),o=r(25086);r(56319);var n=r(56061),c=r(98542);r(38587),r(21110),r(92622),r(8823),r(92173);var u=r(90882),p=r(72908),m=r(28815),h=r(45455),x=r(28058),f=r(4809);r(21931),r(80752),r(40197);var v=r(23615);r(44736);var y=r(62899);r(94230);var b=r(30815),j=r(23936),g=r(95088),N=r(73579),k=r(96748),w=r(4823),A=r(28067),C=r(97677),K=r(51825),P=r(29366);r(76361),r(91450)},80800:(e,a,r)=>{Promise.resolve().then(r.bind(r,15615))}},e=>{e.O(0,[2574,3862,782,8500,594,1321,4707,1330,8441,3794,7358],()=>e(e.s=80800)),_N_E=e.O()}]);
|