switchboard-router 0.6.11 → 0.6.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/.next-cli-build/BUILD_ID +1 -1
- package/app/.next-cli-build/app-path-routes-manifest.json +3 -3
- 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.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/agent-library/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/basic-chat/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/basic-chat/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/basic-chat/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/routing/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/routing/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/routing/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page.js +3 -3
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/mitm/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/mitm/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/mitm/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page.js +3 -3
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/[id]/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/[id]/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/[id]/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/_global-error/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/_global-error.html +1 -1
- package/app/.next-cli-build/server/app/_global-error.rsc +1 -1
- package/app/.next-cli-build/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/_not-found/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/_not-found.html +1 -1
- package/app/.next-cli-build/server/app/_not-found.rsc +3 -3
- package/app/.next-cli-build/server/app/_not-found.segments/_full.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/_not-found.segments/_index.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/api/agent-library/catalog/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/agent-library/doctor/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/agent-library/export/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/agent-library/mcp/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/agent-library/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/agent-library/skills/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/agent-library/sync/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/agent-library/updates/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/auth/status/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/aider-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/aider-settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/all-statuses/route.js +4 -4
- package/app/.next-cli-build/server/app/api/cli-tools/all-statuses/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/alias/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/alias/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/claude-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/claude-settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/cline-settings/route.js +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/cline-settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/codex-settings/route.js +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/codex-settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-registry/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-registry/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-tools/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-tools/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/cowork-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/cowork-settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/deepseek-tui-settings/route.js +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/deepseek-tui-settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/droid-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/droid-settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/gemini-cli-settings/route.js +3 -3
- package/app/.next-cli-build/server/app/api/cli-tools/gemini-cli-settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/grok-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/grok-settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/hermes-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/hermes-settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/jcode-settings/route.js +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/jcode-settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/kilo-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/kilo-settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/openclaw-settings/route.js +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/openclaw-settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/opencode-settings/route.js +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/opencode-settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/pi-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/pi-settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/combos/[id]/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/combos/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/headroom/proxy/[...path]/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/headroom/start/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/headroom/status/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/headroom/stop/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/health/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/keys/[id]/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/keys/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/locale/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/mcp/[plugin]/message/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/mcp/[plugin]/sse/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/media-providers/tts/deepgram/voices/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/media-providers/tts/elevenlabs/voices/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/media-providers/tts/inworld/voices/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/media-providers/tts/minimax/voices/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/media-providers/tts/voices/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/mgmt/v1/combos/[id]/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/mgmt/v1/combos/[id]/strategy/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/mgmt/v1/combos/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/mgmt/v1/health/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/mgmt/v1/providers/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/mgmt/v1/routing/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/mgmt/v1/usage/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/mgmt/v1/version/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/models/alias/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/models/availability/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/models/custom/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/models/disabled/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/models/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/models/test/route.js +1 -1
- package/app/.next-cli-build/server/app/api/models/test/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/oauth/[provider]/[action]/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/oauth/codex/bulk-import/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/oauth/codex/import-token/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/oauth/cursor/auto-import/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/oauth/cursor/import/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/oauth/gitlab/pat/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/oauth/iflow/cookie/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/oauth/kiro/api-key/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/oauth/kiro/auto-import/route.js +1 -1
- package/app/.next-cli-build/server/app/api/oauth/kiro/auto-import/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/oauth/kiro/import/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/oauth/kiro/import-cli-proxy/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/oauth/kiro/social-authorize/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/oauth/kiro/social-exchange/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/pricing/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/provider-nodes/[id]/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/provider-nodes/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/provider-nodes/validate/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/batch/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/cache/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/prepare/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/remove-unavailable/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/verify/cancel/route.js +1 -1
- package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/verify/cancel/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/verify/start/route.js +1 -1
- package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/verify/start/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/verify/status/route.js +1 -1
- package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/verify/status/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/[id]/models/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/[id]/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/[id]/test/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/[id]/test-models/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/client/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/kilo/free-models/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/suggested-models/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/test-batch/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/providers/validate/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/routing/feedback/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/routing/insights/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/routing/learn/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/routing/stats/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/routing/versions/promote/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/routing/versions/rollback/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/settings/database/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/settings/proxy-test/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/settings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/shutdown/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/skills/[id]/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/tags/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/token-saver/vault-stats/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/translator/console-logs/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/translator/console-logs/stream/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/translator/load/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/translator/save/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/translator/send/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/translator/translate/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/usage/[connectionId]/codex-reset-credits/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/usage/[connectionId]/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/usage/chart/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/usage/history/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/usage/logs/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/usage/providers/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/usage/request-details/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/usage/request-logs/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/usage/stats/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/usage/stream/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/api/chat/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/audio/speech/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/audio/transcriptions/route.js +1 -1
- package/app/.next-cli-build/server/app/api/v1/audio/transcriptions/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/audio/voices/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/chat/completions/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/embeddings/route.js +1 -1
- package/app/.next-cli-build/server/app/api/v1/embeddings/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/images/generations/route.js +1 -1
- package/app/.next-cli-build/server/app/api/v1/images/generations/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/messages/count_tokens/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/messages/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/models/[kind]/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/models/info/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/models/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/responses/compact/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/responses/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/search/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1/web/fetch/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1beta/models/[...path]/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/v1beta/models/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/version/route.js +1 -1
- package/app/.next-cli-build/server/app/api/version/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/version/shutdown/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/api/version/update/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/callback/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/callback/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/callback.html +1 -1
- package/app/.next-cli-build/server/app/callback.rsc +3 -3
- package/app/.next-cli-build/server/app/callback.segments/_full.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/callback.segments/_head.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/callback.segments/_index.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/callback.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/callback.segments/callback/__PAGE__.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/callback.segments/callback.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/settings/pricing/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.rsc +3 -3
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_full.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_head.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_index.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing/__PAGE__.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/favicon.ico/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/index.html +1 -1
- package/app/.next-cli-build/server/app/index.rsc +3 -3
- package/app/.next-cli-build/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/index.segments/_full.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/index.segments/_head.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/index.segments/_index.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/index.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/landing/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/landing/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/landing.html +1 -1
- package/app/.next-cli-build/server/app/landing.rsc +3 -3
- package/app/.next-cli-build/server/app/landing.segments/_full.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/landing.segments/_head.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/landing.segments/_index.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/landing.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/landing.segments/landing/__PAGE__.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/landing.segments/landing.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/login/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/login/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/login.html +1 -1
- package/app/.next-cli-build/server/app/login.rsc +3 -3
- package/app/.next-cli-build/server/app/login.segments/_full.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/login.segments/_head.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/login.segments/_index.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/login.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/login.segments/login/__PAGE__.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/login.segments/login.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/manifest.webmanifest/route.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/page.js.nft.json +1 -1
- package/app/.next-cli-build/server/app/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app-paths-manifest.json +3 -3
- package/app/.next-cli-build/server/chunks/194.js +1 -1
- package/app/.next-cli-build/server/chunks/{1062.js → 3787.js} +2 -2
- package/app/.next-cli-build/server/chunks/4126.js +1 -1
- package/app/.next-cli-build/server/chunks/4746.js +1 -1
- package/app/.next-cli-build/server/chunks/5821.js +1 -1
- package/app/.next-cli-build/server/chunks/7155.js +1 -1
- package/app/.next-cli-build/server/chunks/869.js +1 -1
- package/app/.next-cli-build/server/chunks/8998.js +1 -1
- package/app/.next-cli-build/server/chunks/9489.js +2 -2
- package/app/.next-cli-build/server/chunks/9696.js +5 -5
- 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-3452b6d48b71f4a2.js → 1321-f614c7c6e5ab4bcc.js} +1 -1
- package/app/.next-cli-build/static/chunks/{5497-d866b97bf9a716ba.js → 5497-3d546c1b7aa357b1.js} +5 -5
- package/app/.next-cli-build/static/chunks/594-e392353337efef19.js +64 -0
- package/app/.next-cli-build/static/chunks/6430-4c528cfc35666c11.js +1 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/agent-library/{page-d720efb4c9d427e6.js → page-62bea7b75b3f2692.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/basic-chat/{page-04509a38b9fd3dcf.js → page-1eb380280857cf20.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/cli-tools/[toolId]/{page-fa35870caaeabe20.js → page-9aa986f145130c08.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/cli-tools/{page-aa9c65a5e73a3f5d.js → page-a09d7692b3ea9179.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/combos/{page-a8d77d24b4c71915.js → page-4bf0abe7c7119ac0.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/combos/routing/{page-95f09ae849f539d6.js → page-1fc70bcd434deb73.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/console-log/{page-6678759c536b4008.js → page-fdc5377da12ec933.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/endpoint/page-b48bd39cb03c4985.js +3 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/[id]/{page-183cf5498e6d3e42.js → page-9e60537a4b8f5a0c.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/{page-b67e7e3b9acaf1cc.js → page-95bf830096d019fd.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/combo/[id]/{page-a4bad553cba810e7.js → page-45ebe6bb46c9f65e.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/{page-0568602ac2385103.js → page-7ac82c8930583633.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/media-providers/web/{page-f6e3507247a819e5.js → page-961013b570bbeac6.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/mitm/{page-08fe6612a31239da.js → page-8619928e4b74f46b.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/profile/{page-a1ab95a02951c91d.js → page-b5b9038ea28e63b6.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/[id]/page-e023b0417bbc3b44.js +10 -0
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/new/{page-608cdc11e7047159.js → page-fe7ccc9c117d7d38.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/{page-ad84a479883e6cc3.js → page-d3e35265648406f2.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/quota/{page-f312c1076859630e.js → page-5ac3900baf3fe9ca.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/skills/[id]/{page-90277b8688f387c1.js → page-bb4af1ac9b13a514.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/skills/{page-33e127c15efc66a5.js → page-4382c14f28ddfc7f.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/token-saver/{page-0f74a450b98fa125.js → page-1b2b6b736fe98698.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/translator/{page-ad2eda4b48c9319b.js → page-92fe95bd4e6b3d0a.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/usage/{page-025d20cc7b091120.js → page-4c47b9660f3066e2.js} +1 -1
- package/app/.next-cli-build/static/chunks/app/(dashboard)/layout-d1fa5b81e1c386ab.js +1 -0
- package/app/package.json +1 -1
- package/cli.js +18 -2
- package/package.json +1 -1
- package/src/cli/interfaceMenu.js +11 -4
- package/app/.next-cli-build/static/chunks/1631-cb80453bf5d4173d.js +0 -1
- package/app/.next-cli-build/static/chunks/2176-8ad9ce4b3cb01006.js +0 -1
- package/app/.next-cli-build/static/chunks/2280-61262f8359f37a85.js +0 -64
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/endpoint/page-59e92d48daea1aed.js +0 -3
- package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/[id]/page-c6f3cad64d4ef25a.js +0 -10
- package/app/.next-cli-build/static/chunks/app/(dashboard)/layout-acc24d6e7d8eb782.js +0 -1
- /package/app/.next-cli-build/static/{cirxzk63Mj76HYSOHUdGc → y86nLCzoD011gXPeccvk9}/_buildManifest.js +0 -0
- /package/app/.next-cli-build/static/{cirxzk63Mj76HYSOHUdGc → y86nLCzoD011gXPeccvk9}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2134],{4003:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>H});var a=s(95155),i=s(12115),r=s(73321),n=s(98500),l=s.n(n),o=s(5772),d=s(35497),c=s(88105),m=s(28777),p=s(16600),u=s(47224);let x=["none","low","medium","high"],h=["none","thinking"],f=["none","low","medium","high","max"],g={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},y=[{pattern:"*codex*",levels:["low","medium","high","xhigh"]}];function b(e,t){let s=(0,p.nl)(e,t);if(!s.reasoning)return null;let a=y.find(e=>(0,u.gH)(e.pattern,t)),i=a?.levels||g[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);function S(e,t={}){let s=t.kind||t.type;if(s&&"string"==typeof s){let e=s.toLowerCase();return"chat"===e||"text"===e||"language"===e?"llm":e}let a=String(e||"").toLowerCase();return/embed/.test(a)?"embedding":/(^|[-_/])(tts|speech)([-_/]|$)/.test(a)?"tts":/(whisper|transcri|speech-to-text|(^|[-_/])stt([-_/]|$))/.test(a)?"stt":/(imagine-video|video-gen|(^|[-_/])video([-_/]|$))/.test(a)&&!/revision/.test(a)?"video":/(imagine-image|dall-e|stable-diffusion|sdxl|flux|midjourney|image-gen)/.test(a)||/(^|[-_/])image([-_/]|$)/.test(a)&&!/(vision|vl|multimodal)/.test(a)?"image":"llm"}function $(e,t){let s=String(e||"").trim();if(!s)return"";if(s=s.replace(/^models\//,""),t){let e=`${t}/`;s.startsWith(e)&&(s=s.slice(e.length))}return(s=s.replace(/^(openai|anthropic|google|x-ai|xai|meta-llama|mistralai)\//i,"")).trim()}var A=s(14051),T=s.n(A);function O({model:e,fullModel:t,alias:s,copied:i,onCopy:r,testStatus:n,isCustom:l,isFree:o,onDeleteAlias:c,onTest:m,isTesting:p,onDisable:u,caps:x,thinkingSuffix:h,latencyMs:f,probeState:g}){let y=h?`${t}(${h})`:t,b="ok"===n?"#22c55e":"error"===n?"#ef4444":void 0;return(0,a.jsx)("div",{className:`group min-w-0 max-w-full rounded-lg border px-3 py-2 ${"ok"===n?"border-green-500/40":"error"===n?"border-red-500/40":"border-border"} hover:bg-sidebar/50`,children:(0,a.jsxs)("div",{className:"flex min-w-0 items-start gap-2 sm:items-center",children:[(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-base",style:b?{color:b}:void 0,children:"ok"===n?"check_circle":"error"===n?"cancel":"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",children:[(0,a.jsx)("code",{className:"max-w-[72vw] truncate rounded bg-sidebar px-1.5 py-0.5 font-mono text-xs text-text-muted sm:max-w-[360px]",children:y}),g&&("testing"===g?(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 animate-spin text-[14px] text-text-muted",title:"Testing...",children:"progress_activity"}):(0,a.jsx)("span",{title:"ok"===g?"Reachable":"dead"===g?"Unavailable (dead)":"Retry later",className:`shrink-0 inline-block h-2 w-2 rounded-full ${"ok"===g?"bg-green-500":"dead"===g?"bg-red-500":"bg-amber-500"}`}))]}),(0,a.jsxs)("span",{className:"flex min-w-0 items-center text-[9px] gap-1 pl-1",children:[e.name&&(0,a.jsx)("span",{className:"truncate text-[9px] italic text-text-muted/70",children:e.name}),Number.isFinite(f)&&(0,a.jsxs)("span",{className:"shrink-0 text-[9px] text-text-muted/70 tabular-nums",children:[Math.round(f),"ms"]}),(0,a.jsx)(d.nh,{caps:x,colorOverride:"text-text-muted/70",size:12})]})]}),m&&(0,a.jsxs)("div",{className:"relative shrink-0 group/btn",children:[(0,a.jsx)("button",{onClick:m,disabled:p,className:`rounded p-0.5 text-text-muted transition-opacity hover:bg-sidebar hover:text-primary ${p?"opacity-100":"opacity-100 sm:opacity-0 sm:group-hover:opacity-100"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",style:p?{animation:"spin 1s linear infinite"}:void 0,children:p?"progress_activity":"science"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute mt-1 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:p?"Testing...":"Test"})]}),(0,a.jsxs)("div",{className:"relative shrink-0 group/btn",children:[(0,a.jsx)("button",{onClick:()=>r(y,`model-${e.id}`),className:"rounded p-0.5 text-text-muted hover:bg-sidebar hover:text-primary",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:i===`model-${e.id}`?"check":"content_copy"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute mt-1 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:i===`model-${e.id}`?"Copied!":"Copy"})]}),l?(0,a.jsx)("button",{onClick:c,className:"ml-auto rounded p-0.5 text-text-muted opacity-100 transition-opacity hover:bg-red-500/10 hover:text-red-500 sm:opacity-0 sm:group-hover:opacity-100",title:"Remove custom model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"close"})}):u?(0,a.jsx)("button",{onClick:u,className:"ml-auto rounded p-0.5 text-text-muted opacity-100 transition-opacity hover:bg-red-500/10 hover:text-red-500 sm:opacity-0 sm:group-hover:opacity-100",title:"Disable this model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"close"})}):null]})})}O.propTypes={model:T().shape({id:T().string.isRequired}).isRequired,fullModel:T().string.isRequired,alias:T().string,copied:T().string,onCopy:T().func.isRequired,testStatus:T().oneOf(["ok","error"]),isCustom:T().bool,isFree:T().bool,onDeleteAlias:T().func,onTest:T().func,isTesting:T().bool,onDisable:T().func,caps:T().object,thinkingSuffix:T().string,latencyMs:T().number,probeState:T().string};var E=s(78559);function R({modelId:e,fullModel:t,copied:s,onCopy:i,onDeleteAlias:r,onTest:n,testStatus:l,isTesting:o}){let d="ok"===l?"#22c55e":"error"===l?"#ef4444":void 0;return(0,a.jsxs)("div",{className:`flex items-center gap-3 p-3 rounded-lg border ${"ok"===l?"border-green-500/40":"error"===l?"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"===l?"check_circle":"error"===l?"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"})]}),n&&(0,a.jsxs)("div",{className:"relative group/btn",children:[(0,a.jsx)("button",{onClick:n,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 D({providerStorageAlias:e,providerDisplayAlias:t,modelAliases:s,customModels:r,copied:n,onCopy:l,onDeleteAlias:o,onAddCustomModel:c,onDeleteCustomModel:m,onRefreshModels:p,connections:u,isAnthropic:x}){let[h,f]=(0,i.useState)(""),[g,y]=(0,i.useState)(!1),[b,v]=(0,i.useState)(!1),[j,w]=(0,i.useState)(""),[k,N]=(0,i.useState)(null),[S,$]=(0,i.useState)({}),A=async t=>{if(!k){N(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();$(e=>({...e,[t]:a.ok?"ok":"error"}))}catch{$(e=>({...e,[t]:"error"}))}finally{N(null)}}},T=(0,C.R)({customModels:r,modelAliases:s,providerAlias:e,type:"llm"}),O=async()=>{if(!h.trim()||g)return;let e=h.trim();if(T.some(t=>t.id===e))return void(0,E.s)("Model already exists for this provider.");y(!0);try{await c(e),f("")}catch(e){(0,E.s)("Error adding model:",e)}finally{y(!1)}},I=async()=>{if(b)return;let t=u.find(e=>!1!==e.isActive);if(t){v(!0),w("");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(T.map(e=>e.id)),n=[],l=new Set;for(let t of i){let s=String(t.id||t.name||t.model||"").trim();!s||r.has(s)||l.has(s)||(l.add(s),n.push({providerAlias:e,id:s,type:"llm",name:t.display_name||t.displayName||t.name||s}))}if(0===n.length)return void w("All models already in list");let o=await fetch("/api/models/custom",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({models:n})}),d=await o.json().catch(()=>({}));if(!o.ok){let e=0;for(let t of n)await c(t.id),e+=1;w(e?`Imported ${e} model(s)`:"No new models were added");return}w(`Imported ${d.added??n.length} model(s)`),"function"==typeof p?await p():window.dispatchEvent(new CustomEvent("customModelChanged"))}catch(e){(0,E.s)("Error importing models:",e),(0,E.s)(e?.message||"Import failed")}finally{v(!1)}}},P=u.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:h,onChange:e=>f(e.target.value),onKeyDown:e=>"Enter"===e.key&&O(),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:O,disabled:!h.trim()||g,children:g?"Adding...":"Add"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"cloud_download",onClick:I,disabled:!P||b,children:b?"Importing...":"Import models"})]}),!P&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Add a connection to enable importing models."}),j&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:j}),T.length>0&&(0,a.jsx)("div",{className:"flex flex-col gap-3",children:T.map(({id:s,alias:i,source:r})=>(0,a.jsx)(R,{modelId:s,fullModel:`${t}/${s}`,copied:n,onCopy:l,onDeleteAlias:()=>"custom"===r?m(s):o(i),onTest:u.length>0?()=>A(s):void 0,testStatus:S[s],isTesting:k===s},`${r}-${e}/${s}`))})]})}T().string.isRequired,T().string.isRequired,T().string,T().func.isRequired,T().func.isRequired,T().func,T().oneOf(["ok","error"]),T().bool,T().string.isRequired,T().object.isRequired,T().arrayOf(T().object),T().string,T().func.isRequired,T().func.isRequired,T().func.isRequired,T().func.isRequired,D.propTypes={providerStorageAlias:T().string.isRequired,providerDisplayAlias:T().string.isRequired,modelAliases:T().object.isRequired,customModels:T().arrayOf(T().object),copied:T().string,onCopy:T().func.isRequired,onDeleteAlias:T().func.isRequired,onAddCustomModel:T().func.isRequired,onDeleteCustomModel:T().func.isRequired,onRefreshModels:T().func,connections:T().arrayOf(T().shape({id:T().string,isActive:T().bool})).isRequired,isAnthropic:T().bool};var I=s(70217);function P({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:n,onMoveDown:l,onToggleActive:o,onEdit:c,onDelete:m,onAllowlistHost:p=null,oneByOneStatus:u=null,autoPing:x=null}){let h=/SSRF blocked|Blocked URL: (private IP|internal host)/i.test(e.lastError||""),f=e.providerSpecificData?.connectionProxyEnabled===!0&&!!e.providerSpecificData?.connectionProxyUrl,g=f?`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.",b="";if(e.providerSpecificData?.connectionProxyUrl){let t=e.providerSpecificData?.connectionProxyUrl;try{let e=new URL(t);b=`${e.protocol}//${e.hostname}${e.port?`:${e.port}`:""}`}catch{b=t}}let v=e.providerSpecificData?.connectionNoProxy||"",j=f?"success":"default",w=e.authType||(t?"oauth":"apikey"),k="oauth"===w,N="cookie"===w,C=e.name?.trim()||e.email?.trim()||e.displayName?.trim()||(k?"OAuth Account":N?"Cookie Account":"API Key"),S=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]=(0,i.useState)(!1),T=Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>e).filter(e=>!!e).sort()[0]||null;(0,i.useEffect)(()=>{let t=()=>{A(!!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=T?setInterval(t,1e3):null;return()=>{s&&clearInterval(s)}},[e,T]);let O="unavailable"!==e.testStatus||$?e.testStatus:"active",E=()=>u?"queued"===u.state?"queued":"testing"===u.state?"testing":"success"===u.state?"success":"failed"===u.state?u.error?`failed: ${u.error}`:"failed":null:null;return(0,a.jsxs)("div",{className:`group flex min-w-0 flex-col gap-3 rounded-lg p-2 transition-colors hover:bg-black/[0.02] dark:hover:bg-white/[0.02] sm:flex-row sm:items-center sm:justify-between ${!1===e.isActive?"opacity-60":""}`,children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-1 items-start gap-2 sm:items-center sm:gap-3",children:[(0,a.jsxs)("div",{className:"flex shrink-0 flex-col",children:[(0,a.jsx)("button",{onClick:n,disabled:s,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",children:"keyboard_arrow_up"})}),(0,a.jsx)("button",{onClick:l,disabled:r,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",children:"keyboard_arrow_down"})})]}),(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-base text-text-muted",children:N?"cookie":k?"lock":"key"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"text-sm font-medium truncate",children:C}),S&&(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:S}),(0,a.jsxs)("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1.5 sm:gap-2",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:k?"OAuth":N?"Cookie":"API Key"}),f&&(0,a.jsx)(d.Ex,{variant:j,size:"sm",children:"Proxy"}),$&&!1!==e.isActive&&(0,a.jsx)(P,{until:T}),e.lastError&&!1!==e.isActive&&(0,a.jsx)("span",{className:"max-w-full truncate text-xs text-red-500 sm:max-w-[300px]",title:e.lastError,children:e.lastError}),h&&!1!==e.isActive&&p&&(0,a.jsxs)("button",{onClick:p,title:"Trust this host past the SSRF guard and retry",className:"inline-flex items-center gap-1 rounded border border-amber-500/40 px-1.5 py-0.5 text-xs text-amber-600 hover:bg-amber-500/10 dark:text-amber-400",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"verified_user"}),"Add to allow list"]}),(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:u?"success"===u.state?"success":"failed"===u.state?"error":"testing"===u.state?"primary":"default":"default",size:"sm",children:E()})]}),f&&(0,a.jsxs)("div",{className:"mt-1 flex items-center gap-2 flex-wrap",children:[(0,a.jsx)("span",{className:"max-w-full truncate text-[11px] text-text-muted sm:max-w-[420px]",title:g,children:g}),b&&(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:b}),v&&(0,a.jsxs)("span",{className:"max-w-full truncate text-[11px] text-text-muted sm:max-w-[320px]",title:v,children:["no_proxy: ",v]})]})]})]}),(0,a.jsxs)("div",{className:"flex w-full items-center justify-between gap-2 sm:w-auto sm:justify-end",children:[(0,a.jsxs)("div",{className:"grid flex-1 grid-cols-3 gap-1 sm:flex sm:flex-none",children:[x&&(0,a.jsx)(d.m_,{text:y,children:(0,a.jsxs)("button",{onClick:()=>x.onToggle(!x.on),className:`flex w-full flex-col items-center rounded px-2 py-1 transition-colors hover:bg-black/5 dark:hover:bg-white/5 ${x.on?"text-primary":"text-text-muted hover:text-primary"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"bolt"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Auto-ping"})]})}),(0,a.jsxs)("button",{onClick:c,className:"flex flex-col items-center rounded px-2 py-1 text-text-muted hover:bg-black/5 hover:text-primary dark:hover:bg-white/5",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"edit"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Edit"})]}),(0,a.jsxs)("button",{onClick:m,className:"flex flex-col items-center rounded px-2 py-1 text-red-500 hover:bg-red-500/10",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"delete"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Delete"})]})]}),(0,a.jsx)(d.lM,{size:"sm",checked:e.isActive??!0,onChange:o,title:e.isActive??!0?"Disable connection":"Enable connection"})]})]})}P.propTypes={until:T().string.isRequired},M.propTypes={connection:T().shape({id:T().string,name:T().string,email:T().string,displayName:T().string,modelLockUntil:T().string,testStatus:T().string,isActive:T().bool,lastError:T().string,priority:T().number,globalPriority:T().number,providerSpecificData:T().object}).isRequired,isOAuth:T().bool.isRequired,isFirst:T().bool.isRequired,isLast:T().bool.isRequired,onMoveUp:T().func.isRequired,onMoveDown:T().func.isRequired,onToggleActive:T().func.isRequired,onEdit:T().func.isRequired,onDelete:T().func.isRequired,onAllowlistHost:T().func,oneByOneStatus:T().shape({state:T().string,error:T().string}),autoPing:T().shape({on:T().bool,onToggle:T().func,provider:T().string})};let z=`name1|sk-key1
|
|
2
|
+
name2|sk-key2
|
|
3
|
+
sk-key-only-auto-named`;function U({isOpen:e,provider:t,providerName:s,isCompatible:r,isAnthropic:n,authType:l,authHint:o,website:m,error:p,onSave:u,onBulkDone:x,onClose:h}){let f="ollama-local"===t,g="cookie"===l,y="xai"===t&&!g,b=g?"Cookie Value":"API Key",v="azure"===t,j="cloudflare-ai"===t,w=c.Q2?.[t]?.regions||null,k=c.Q2?.[t]?.defaultRegion||w?.[0]?.id||"",[N,C]=(0,i.useState)({name:"",apiKey:"",defaultModel:"",priority:1,ollamaHostUrl:""}),[S,$]=(0,i.useState)({azureEndpoint:"",apiVersion:"2024-10-01-preview",deployment:"",organization:""}),[A,T]=(0,i.useState)({accountId:""}),[O,E]=(0,i.useState)(k),[R,D]=(0,i.useState)(!1),[I,P]=(0,i.useState)(null),[M,q]=(0,i.useState)(!1),[_,F]=(0,i.useState)("single"),[L,J]=(0,i.useState)(""),[K,B]=(0,i.useState)(null),H=N.name.trim().length>0,W=N.apiKey.trim().length>0,V=()=>f&&N.ollamaHostUrl.trim()?{baseUrl:N.ollamaHostUrl.trim()}:v?{azureEndpoint:S.azureEndpoint,apiVersion:S.apiVersion,deployment:S.deployment,organization:S.organization}:j?{accountId:A.accountId}:w&&O?{region:O}:void 0,G=async()=>{let e=N.apiKey.trim();if(e){D(!0);try{let s=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:e,providerSpecificData:V()})}),a=await s.json();P(a.valid?"success":"failed")}catch{P("failed")}finally{D(!1)}}},Q=async()=>{if(!t)return;let e=N.name.trim(),s=N.apiKey.trim();if((f||s)&&(f||e)&&(!r||N.defaultModel.trim())){q(!0);try{let a=!1;try{D(!0),P(null);let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:s,providerSpecificData:V()})});a=!!(await e.json()).valid,P(a?"success":"failed")}catch{P("failed")}finally{D(!1)}await u({name:e||(f?"Ollama Local":""),apiKey:s,defaultModel:r?N.defaultModel.trim():void 0,priority:N.priority,testStatus:a?"active":"unknown",providerSpecificData:V()})}finally{q(!1)}}},Z=async()=>{let e=L.split("\n").map(e=>e.trim()).filter(Boolean);if(!e.length)return;q(!0),B(null);let s=0,a=0;for(let i=0;i<e.length;i++){let r=e[i].split("|"),n=r.length>=2?r.slice(1).join("|").trim():r[0].trim();if(!n){a++;continue}let l=r.length>=2&&r[0].trim()||"Key",o=`${l} ${i+1}`;try{(await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:n,name:o,priority:1,testStatus:"unknown"})})).ok?s++:a++}catch{a++}}q(!1),B({success:s,failed:a}),s>0&&x&&x()};return t?(0,a.jsx)(d.aF,{isOpen:e,title:`Add ${s||t} ${b}`,onClose:h,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{size:"sm",variant:"single"===_?"primary":"ghost",onClick:()=>{F("single"),B(null)},children:"Single"}),(0,a.jsx)(d.$n,{size:"sm",variant:"bulk"===_?"primary":"ghost",onClick:()=>{F("bulk"),B(null)},children:"Bulk Add"})]}),"bulk"===_&&(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:z,value:L,onChange:e=>J(e.target.value)}),K&&(0,a.jsxs)("div",{className:`text-sm font-medium ${K.failed>0?"text-yellow-400":"text-green-400"}`,children:["✓ ",K.success," added",K.failed>0?`, ✗ ${K.failed} failed`:""]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{onClick:Z,fullWidth:!0,disabled:M||!L.trim(),children:M?"Adding...":"Add All Keys"}),(0,a.jsx)(d.$n,{onClick:h,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),"single"===_&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.pd,{label:"Name",value:N.name,onChange:e=>C({...N,name:e.target.value}),placeholder:f?"Ollama Local":"Production Key"}),f&&(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.pd,{label:"Ollama Host URL",value:N.ollamaHostUrl,onChange:e=>C({...N,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:G,disabled:R||M,variant:"secondary",children:R?"Checking...":"Check"})})]}),!f&&(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.pd,{label:b,type:g?"text":"password",autoComplete:"off",value:N.apiKey,onChange:e=>C({...N,apiKey:e.target.value}),placeholder:g?"grok-web"===t?"sso=xxxxx... or just the raw value":"eyJhbGciOi...":y?"xai-...":"",className:"flex-1"}),(0,a.jsx)("div",{className:"pt-6",children:(0,a.jsx)(d.$n,{onClick:G,disabled:!N.apiKey||R||M,variant:"secondary",children:R?"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?:\/\//,"")]})]})]}),w&&(0,a.jsx)(d.l6,{label:"Region",value:O,onChange:e=>E(e.target.value),options:w.map(e=>({value:e.id,label:e.label}))}),r&&(0,a.jsx)(d.pd,{label:"Default Model",value:N.defaultModel,onChange:e=>C({...N,defaultModel:e.target.value}),placeholder:n?"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"}),")."]}),I&&(0,a.jsx)(d.Ex,{variant:"success"===I?"success":"error",children:"success"===I?"Valid":"Invalid"}),p&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:p}),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."}),j&&(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:A.accountId,onChange:e=>T({...A,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"})]})]}),v&&(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:S.azureEndpoint,onChange:e=>$({...S,azureEndpoint:e.target.value}),placeholder:"https://your-resource.openai.azure.com"}),(0,a.jsx)(d.pd,{label:"Deployment Name",value:S.deployment,onChange:e=>$({...S,deployment:e.target.value}),placeholder:"gpt-4"}),(0,a.jsx)(d.pd,{label:"API Version",value:S.apiVersion,onChange:e=>$({...S,apiVersion:e.target.value}),placeholder:"2024-10-01-preview"}),(0,a.jsx)(d.pd,{label:"Organization",value:S.organization,onChange:e=>$({...S,organization:e.target.value}),placeholder:"Organization ID"})]})]}),(0,a.jsx)(d.pd,{label:"Priority",type:"number",min:1,value:N.priority,onChange:e=>C({...N,priority:Number.parseInt(e.target.value)||1})}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{onClick:Q,fullWidth:!0,disabled:M||!f&&(!H||!W)||r&&!N.defaultModel.trim()||v&&(!S.azureEndpoint||!S.deployment||!S.organization)||j&&!A.accountId,children:M?"Saving...":"Save"}),(0,a.jsx)(d.$n,{onClick:h,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})}):null}function q({isOpen:e,node:t,onSave:s,onClose:r,isAnthropic:n}){let[l,o]=(0,i.useState)({name:"",apiType:"chat",baseUrl:"https://api.openai.com/v1"}),[c,m]=(0,i.useState)(!1),[p,u]=(0,i.useState)(""),[x,h]=(0,i.useState)(""),[f,g]=(0,i.useState)(!1),[y,b]=(0,i.useState)(null),v=function(e){try{return["http:","https:"].includes(new URL(e).protocol)}catch{return!1}}(l.baseUrl.trim());(0,i.useEffect)(()=>{t&&(o({name:t.name||"",apiType:t.apiType||"chat",baseUrl:t.baseUrl||(n?"https://api.anthropic.com/v1":"https://api.openai.com/v1")}),b(null),u(""),h(""))},[t,n]);let j=async()=>{if(l.name.trim()&&v){m(!0);try{let e={name:l.name.trim(),baseUrl:l.baseUrl.trim()};n||(e.apiType=l.apiType),await s(e)}finally{m(!1)}}},w=async()=>{g(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:l.baseUrl,apiKey:p,type:n?"anthropic-compatible":"openai-compatible",modelId:x.trim()||void 0})}),t=await e.json();b(t.valid?"success":"failed")}catch{b("failed")}finally{g(!1)}};return t?(0,a.jsx)(d.aF,{isOpen:e,title:`Edit ${n?"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:l.name,onChange:e=>o({...l,name:e.target.value}),placeholder:`${n?"Anthropic":"OpenAI"} Compatible`,hint:"Friendly label for this provider."}),!n&&(0,a.jsx)(d.l6,{label:"API Type",options:[{value:"chat",label:"Chat Completions"},{value:"responses",label:"Responses API"}],value:l.apiType,onChange:e=>o({...l,apiType:e.target.value})}),(0,a.jsx)(d.pd,{label:"Base URL",value:l.baseUrl,onChange:e=>o({...l,baseUrl:e.target.value}),placeholder:n?"https://api.anthropic.com/v1":"https://api.openai.com/v1",hint:`Base URL ending in /v1 for your ${n?"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:p,onChange:e=>u(e.target.value),className:"flex-1"}),(0,a.jsx)("div",{className:"pt-6",children:(0,a.jsx)(d.$n,{onClick:w,disabled:!p||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."}),y&&(0,a.jsx)(d.Ex,{variant:"success"===y?"success":"error",children:"success"===y?"Valid":"Invalid"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{onClick:j,fullWidth:!0,disabled:!l.name.trim()||!v||c,children:c?"Saving...":"Save"}),(0,a.jsx)(d.$n,{onClick:r,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}function _({isOpen:e,providerAlias:t,providerDisplayAlias:s,onSave:r,onClose:n}){let[l,o]=(0,i.useState)(""),[c,m]=(0,i.useState)(null),[p,u]=(0,i.useState)(""),[x,h]=(0,i.useState)(!1);(0,i.useEffect)(()=>{e&&(o(""),m(null),u(""))},[e]);let f=e=>{let s=`${t}/`;return e.startsWith(s)?e.slice(s.length):e},g=async()=>{let e=f(l.trim());if(e){m("testing"),u("");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"),u(a.error||"")}catch(e){m("error"),u(e.message)}}},y=async()=>{let e=f(l.trim());if(e&&!x){h(!0);try{await r(e)}finally{h(!1)}}};return(0,a.jsx)(d.aF,{isOpen:e,onClose:n,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:l,onChange:e=>{o(e.target.value),m(null),u("")},onKeyDown:e=>{"Enter"===e.key&&g()},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:g,disabled:!l.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(l.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:p||"Model not reachable"})]}),(0,a.jsxs)("div",{className:"flex gap-2 pt-1",children:[(0,a.jsx)(d.$n,{onClick:n,variant:"ghost",fullWidth:!0,size:"sm",children:"Cancel"}),(0,a.jsx)(d.$n,{onClick:y,fullWidth:!0,size:"sm",disabled:!l.trim()||x,children:x?"Adding...":"Add Model"})]})]})})}U.propTypes={isOpen:T().bool.isRequired,provider:T().string,providerName:T().string,isCompatible:T().bool,isAnthropic:T().bool,authType:T().string,authHint:T().string,website:T().string,error:T().string,onSave:T().func.isRequired,onBulkDone:T().func,onClose:T().func.isRequired},q.propTypes={isOpen:T().bool.isRequired,node:T().shape({id:T().string,name:T().string,prefix:T().string,apiType:T().string,baseUrl:T().string}),onSave:T().func.isRequired,onClose:T().func.isRequired,isAnthropic:T().bool},_.propTypes={isOpen:T().bool.isRequired,providerAlias:T().string.isRequired,providerDisplayAlias:T().string.isRequired,onSave:T().func.isRequired,onClose:T().func.isRequired};let F=`[
|
|
4
|
+
{
|
|
5
|
+
"accessToken": "eyJhbGc...",
|
|
6
|
+
"refreshToken": "rt_...",
|
|
7
|
+
"idToken": "eyJhbGc...",
|
|
8
|
+
"email": "user@example.com"
|
|
9
|
+
}
|
|
10
|
+
]`;function L({isOpen:e,onClose:t,onSuccess:s}){let[r,n]=(0,i.useState)(""),[l,o]=(0,i.useState)(!1),[c,m]=(0,i.useState)(""),[p,u]=(0,i.useState)(null),x=()=>{l||(n(""),m(""),u(null),t())},h=async()=>{var e;let t;m(""),u(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}`);u(t),t.success>0&&"function"==typeof s&&s()}catch(e){m(e.message||(0,w.Tl)("Request failed"))}finally{o(!1)}},f=p?.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:F,value:r,onChange:e=>n(e.target.value),disabled:l}),c&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:c}),p&&(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:`text-sm font-medium ${p.failed>0?"text-yellow-400":"text-green-400"}`,children:["✓ ",p.success," ",(0,w.Tl)("added"),p.failed>0?`, ✗ ${p.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:l||!r.trim(),children:l?(0,w.Tl)("Importing..."):(0,w.Tl)("Import All")}),(0,a.jsx)(d.$n,{onClick:x,variant:"ghost",fullWidth:!0,disabled:l,children:(0,w.Tl)("Close")})]})]})})}L.propTypes={isOpen:T().bool.isRequired,onClose:T().func.isRequired,onSuccess:T().func};function J({connectionId:e,providerAlias:t,models:s,jobSnapshot:r,onComplete:n,onStarted:l,onClose:o}){let[c,m]=(0,i.useState)(4),[p,u]=(0,i.useState)(50),[x,h]=(0,i.useState)(Math.round(20)),[f,g]=(0,i.useState)(!1),[y,b]=(0,i.useState)(null),[v,j]=(0,i.useState)(null),[w,k]=(0,i.useState)(""),[N,C]=(0,i.useState)(""),S=(0,i.useRef)({onComplete:n,onStarted:l}),$=(0,i.useRef)(null),A=(0,i.useRef)(e),T=(0,i.useRef)(null),O=s?.length||0,E=(0,i.useMemo)(()=>`max concurrency 16 \xb7 batch 200 \xb7 timeout ${60}s`,[]);function R(e){if(e){if("idle"===e.status){T.current=null,g(!1);return}if(b({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&&(T.current=e.connectionId||A.current,$.current=null,g(!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){T.current=null,g(!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};j(t),C("cancelled"===e.status?"Cancelled (partial results saved).":"error"===e.status?"Stopped.":"Done.");let s=`${e.startedAt||"unknown"}:${e.status}`;$.current!==s&&($.current=s,S.current.onComplete?.(t))}}}async function D(){if(f||!e||0===O)return;g(!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(p)||50)),timeoutMs:Math.max(1e3,Math.min(6e4,1e3*(Number(x)||20)))};T.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(A.current!==e){T.current=null,g(!1);return}if(!i.ok){T.current=null,k(r.error||"Failed to start"),g(!1);return}S.current.onStarted?.(r),R(r),"running"!==r.status&&g(!1)}catch(e){T.current=null,k(e?.message||"Verify failed"),g(!1)}}async function I(){let t=T.current||e;await fetch(`/api/providers/${t}/model-probes/verify/cancel`,{method:"POST"}).catch(()=>{})}async function P(){if(!e)return;C("Removing unavailable custom models…");let s=await fetch(`/api/providers/${e}/model-probes/remove-unavailable`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:t,kind:"llm"})}),a=await s.json().catch(()=>({}));s.ok?(C(`Removed ${a.removed||0} unavailable custom model(s).`),S.current.onComplete?.({...v||{},removed:a.removed||0})):k(a.error||"Remove failed")}async function M(){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),b(null),S.current.onComplete?.({cacheCleared:!0,cleared:s.cleared||0})):k(s.error||"Clear cache failed")}(0,i.useEffect)(()=>{S.current={onComplete:n,onStarted:l},A.current=e}),(0,i.useEffect)(()=>{R(r)},[r]);let z=y?.total?Math.min(100,Math.round(y.done/y.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 (404/403) and can be removed; retry = transient (timeout/429/5xx). Known-dead models are skipped until you Clear cache. Caps: ",E,"."]})]}),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:p,disabled:f,onChange:e=>u(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:I,children:"Cancel"}):(0,a.jsx)(d.$n,{size:"sm",icon:"science",onClick:D,disabled:!e||0===O,children:"Start"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"delete_sweep",onClick:M,disabled:f,children:"Clear cache"})]})]}),y&&(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:`${z}%`}})}),(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:[y.done,"/",y.total," tested"]}),(0,a.jsxs)("span",{title:"Reachable",children:["\xb7 ok ",y.ok]}),(0,a.jsxs)("span",{title:"Permanently unavailable this run (404 not found / 403 access denied)",children:["\xb7 dead ",y.dead]}),(0,a.jsxs)("span",{title:"Transient failure this run (timeout / 429 / 5xx / network); re-testable",children:["\xb7 retry ",y.retryable]}),y.skippedDead?(0,a.jsxs)("span",{title:"Not probed — cache already marks them dead. Clear cache to re-test.",children:["\xb7 skipped known-dead ",y.skippedDead]}):null,y.skippedDup?(0,a.jsxs)("span",{title:"Duplicate ids collapsed",children:["\xb7 dupes ",y.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:P,disabled:f,children:["Remove ",v.dead," dead"]})]})]})}function K(e,t=""){let s=String(e||"").trim();if(!s)return"";s=(s=s.replace(/\s+/g,"")).replace(/^models\//i,"");let a=String(t||"").trim();return a&&s.toLowerCase().startsWith(`${a.toLowerCase()}/`)&&(s=s.slice(a.length+1)),(s=s.replace(/\/{2,}/g,"/").replace(/^\/+|\/+$/g,"")).toLowerCase()}J.propTypes={connectionId:T().string,providerAlias:T().string,models:T().arrayOf(T().object),jobSnapshot:T().object,onComplete:T().func,onStarted:T().func,onClose:T().func};let B={claude:"claudeAutoPing",codex:"codexAutoPing"};function H(){let e,t,s,n=(0,r.useParams)(),p=(0,r.useRouter)(),u=n.id,{getCaps:x}=(0,j.y)(),[h,f]=(0,i.useState)([]),[g,y]=(0,i.useState)([]),[k,A]=(0,i.useState)(!0),[T,R]=(0,i.useState)(null),[I,P]=(0,i.useState)(!1),[z,F]=(0,i.useState)(!1),[H,W]=(0,i.useState)(!1),[V,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)({}),[en,el]=(0,i.useState)([]),[eo,ed]=(0,i.useState)(!1),[ec,em]=(0,i.useState)({}),[ep,eu]=(0,i.useState)(""),[ex,eh]=(0,i.useState)(()=>new Set),[ef,eg]=(0,i.useState)(!1),[ey,eb]=(0,i.useState)(null),[ev,ej]=(0,i.useState)(""),[ew,ek]=(0,i.useState)("auto"),[eN,eC]=(0,i.useState)({enabled:!1,connections:{}}),[eS,e$]=(0,i.useState)([]),[eA,eT]=(0,i.useState)([]),[eO,eE]=(0,i.useState)([]),[eR,eD]=(0,i.useState)([]),[eI,eP]=(0,i.useState)(null),[eM,ez]=(0,i.useState)(!1),[eU,eq]=(0,i.useState)(!1),[e_,eF]=(0,i.useState)(!1),[eL,eJ]=(0,i.useState)(null),[eK,eB]=(0,i.useState)({}),[eH,eW]=(0,i.useState)(null),eV=(0,i.useRef)(!1),eG=(0,i.useRef)(null),eQ=(0,i.useRef)(0),eZ=(0,i.useRef)(0),[eX,eY]=(0,i.useState)(!1),[e0,e1]=(0,i.useState)(""),[e2,e5]=(0,i.useState)(!1),[e4,e3]=(0,i.useState)(null),[e6,e7]=(0,i.useState)({}),[e8,e9]=(0,i.useState)({}),[te,tt]=(0,i.useState)("all"),{copied:ts,copy:ta}=(0,v.C)(),ti="ag_risk_confirmed",tr=()=>{P(!0)},tn=()=>{"antigravity"===u&&"true"!==window.localStorage.getItem(ti)?ez(!0):tm?tr():(G(""),W(!0))},tl=()=>{G(""),W(!0)},to=()=>{tm?tn():tl()},td=T?{id:T.id,name:T.name||("anthropic-compatible"===T.type?"Anthropic Compatible":"OpenAI Compatible"),color:"anthropic-compatible"===T.type?"#D97757":"#10A37F",textIcon:"anthropic-compatible"===T.type?"AC":"OC",apiType:T.apiType,baseUrl:T.baseUrl,type:T.type}:c.zN[u]||c.fg[u]||c.IS[u]||c.nJ[u]||c.br[u],tc=td?.authModes||[],tm=!!c.zN[u]||!!c.IS[u]||tc.includes("oauth"),tp=!!c.fg[u]||tc.includes("apikey"),tu=!!c.IS[u]?.noAuth,tx=(0,m.KC)(u),th=(()=>{let e=new Map(tx.map(e=>[e.id,e]));for(let t of eA)t?.id&&e.set(t.id,{...e.get(t.id),...t});return[...e.values()]})(),tf=(0,c.wG)(u),tg=(0,c.mq)(u),ty=(0,c.gb)(u),tb=tg||ty,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:tb,hasActiveConnection:tv}),tw=!tb&&tm&&tp,tk="xai"===u?"Grok Build OAuth":"OAuth",tN="xai"===u?"xAI API Key":"API Key",tC=e=>{if(!ew||"auto"===ew)return null;let t=b(u,e);return t&&t.includes(ew)?ew:null},tS=(()=>{let e=new Set;for(let t of th){let s=b(u,t.id);s&&s.forEach(t=>{"none"!==t&&e.add(t)})}return e.size?["auto",...e]:null})(),t$=tb?u:tf,tA=tb?T?.prefix||u:tf,tT=(0,i.useCallback)(async()=>{try{let e=await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(t$)}`,{cache:"no-store"}),t=await e.json();e.ok&&eD(t.ids||[])}catch(e){(0,E.s)("Error fetching disabled models:",e)}},[t$]),tO=async e=>{try{(await fetch("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:t$,ids:[e]})})).ok&&await tT()}catch(e){(0,E.s)("Error disabling model:",e)}},tE=async e=>{try{(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(t$)}&id=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await tT()}catch(e){(0,E.s)("Error enabling model:",e)}},tR=async e=>{e.length&&eP({title:"Disable All Models",message:`Disable all ${e.length} model(s)?`,onConfirm:async()=>{eP(null);try{(await fetch("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:t$,ids:e})})).ok&&await tT()}catch(e){(0,E.s)("Error disabling all models:",e)}}})},tD=async()=>{try{(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(t$)}`,{method:"DELETE"})).ok&&await tT()}catch(e){(0,E.s)("Error enabling all models:",e)}},tI=(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)}},[]),tP=(0,i.useCallback)(async()=>{try{let e=await fetch("/api/models/custom",{cache:"no-store"}),t=await e.json();e.ok&&el(t.models||[])}catch(e){(0,E.s)("Error fetching custom models:",e)}},[]);(0,i.useEffect)(()=>{"kilocode"===u&&fetch("/api/providers/kilo/free-models").then(e=>e.json()).then(e=>{e.models?.length&&eE(e.models)}).catch(()=>{})},[u]);let tM=(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===u);f(e)}let n=(r.providerStrategies||{})[u]||{};eb(n.fallbackStrategy||null),ej(null!=n.stickyRoundRobinLimit?String(n.stickyRoundRobinLimit):"1");let l=(r.providerThinking||{})[u]||{};ek(l.mode||"auto");let o=B[u],d=o&&r[o]||{};if(eC({enabled:!0===d.enabled,connections:d.connections||{}}),t.ok){let e=(i.nodes||[]).find(e=>e.id===u)||null;if(!e&&tb)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===u)||null))break}R(e)}}catch(e){(0,E.s)("Error fetching connections:",e)}finally{A(!1)}},[u,tb]),tz=(0,i.useCallback)(async(e=null)=>{let t=++eZ.current,s=e?h.find(t=>t.id===e&&!1!==t.isActive):h.find(e=>g.includes(e.id)&&!1!==e.isActive)||h.find(e=>!1!==e.isActive);if(!s){e9({}),e7({});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!==eZ.current)return;e9(i),e7(r)}catch{}},[h,g]),tU=async e=>{try{let t=await fetch(`/api/provider-nodes/${u}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),s=await t.json();t.ok&&(R(s.node),await tM(),et(!1))}catch(e){(0,E.s)("Error updating provider node:",e)}},tq=async(e,t)=>{try{let s=await fetch("/api/settings",{cache:"no-store"}),a=(s.ok?await s.json():{}).providerStrategies||{},i={};e&&(i.fallbackStrategy=e),"round-robin"===e&&""!==t&&(i.stickyRoundRobinLimit=Number(t)||3);let r={...a};0===Object.keys(i).length?delete r[u]:r[u]=i,await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerStrategies:r})})}catch(e){(0,E.s)("Error saving provider strategy:",e)}},t_=async e=>{try{let t=await fetch("/api/settings",{cache:"no-store"}),s={...(t.ok?await t.json():{}).providerThinking||{}};e&&"auto"!==e?s[u]={mode:e}:delete s[u],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)}},tF=async e=>{let t=B[u];if(t){eC(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)(()=>{tM(),tI(),tP(),tT()},[tM,tI,tP,tT]),(0,i.useEffect)(()=>{tz()},[tz]),(0,i.useEffect)(()=>{if(tb)return;let e=h.find(e=>!1!==e.isActive);if(!e)return void eT([]);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&&eT(e.models)}).catch(()=>{}),()=>{t=!0}},[h,tb]),(0,i.useEffect)(()=>{let e=(c.zN[u]||c.fg[u]||c.IS[u]||c.nJ[u])?.modelsFetcher;e&&N(e).then(e$)},[u]);let tL=(0,i.useCallback)(e=>{let t=++eQ.current;eG.current&&(clearTimeout(eG.current),eG.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!==eQ.current)return;if(!a.ok||!i?.status)throw Error("Verify status temporarily unavailable");e3(i&&i.status?i:null),i?.status==="running"?eG.current=setTimeout(s,1500):(eG.current=null,await tz(e))}catch{t===eQ.current&&(eG.current=setTimeout(s,1500))}};eG.current=setTimeout(s,0)},[tz]);(0,i.useEffect)(()=>{let e=h.find(e=>g.includes(e.id)&&!1!==e.isActive)||h.find(e=>!1!==e.isActive);return e?(tL(e.id),()=>{eQ.current+=1,eG.current&&(clearTimeout(eG.current),eG.current=null)}):void e3(null)},[h,g,tL]);let tJ=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 tI();else{let t=await e.json();(0,E.s)(t.error||"Failed to set alias")}}catch(e){(0,E.s)("Error setting alias:",e)}},tK=async e=>{try{(await fetch(`/api/models/alias?alias=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await tI()}catch(e){(0,E.s)("Error deleting alias:",e)}},tB=async(e,t="llm",s=t$)=>{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 tP(),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)}},tH=async(e,t="llm",s=t$)=>{try{let a=new URLSearchParams({providerAlias:s,id:e,type:t});(await fetch(`/api/models/custom?${a}`,{method:"DELETE"})).ok&&(await tP(),window.dispatchEvent(new CustomEvent("customModelChanged")))}catch(e){(0,E.s)("Error deleting custom model:",e)}},tW=async()=>{if(eX)return;let e=h.find(e=>g.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"));eY(!0),e1("");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,n=new Set(th.map(e=>e.id)),l=[],o=[],d=new Set;for(let e of a){let t=function(e,t){if(null==e)return null;if("string"==typeof e){let s=$(e,t);return s?{id:s,name:s,type:S(s)}:null}let s=e.id||e.name||e.model||e.slug;if(!s)return null;let a=$(s,t);if(!a)return null;let i=e.display_name||e.displayName||e.name||e.title||a;return{id:a,name:String(i),type:S(a,e)}}(e,t$);if(!t)continue;let{id:s,name:a,type:c}=t;if(i.has(K(s,t$))){r+=1;continue}let m=`${c}|${s}`;if(d.has(m))continue;if(d.add(m),n.has(s)){eR.includes(s)&&o.push(s);continue}if(en.some(e=>e.providerAlias===t$&&e.id===s&&(e.kind||e.type||"llm")===c))continue;let p=`${t$}/${s}`;Object.values(ei).includes(p)||l.push({providerAlias:t$,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(t$)}&id=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&(c+=1);await tT()}catch{}let m=0;if(l.length>0){let e=await fetch("/api/models/custom",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({models:l})}),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??l.length,await tP(),window.dispatchEvent(new CustomEvent("customModelChanged"))}let p=l.filter(e=>"llm"!==e.type).length,u=[];if(m>0&&u.push(`${m} new`),c>0&&u.push(`${c} re-enabled`),0===u.length)e1((0,w.Tl)("All models already in list"));else{let e=`Imported ${u.join(" \xb7 ")} (${a.length} from provider)`;p>0&&(e+=" \xb7 non-chat types stored for media pages"),s.warning&&(e+=` \xb7 ${s.warning}`),e1(e)}if(r>0&&e1(e=>`${e} \xb7 ${r} skipped (known dead)`),m>0||c>0)try{let t=[...th,...l.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:t$})}),a=await s.json().catch(()=>({}));if(!s.ok)throw Error(a.error||"Failed to start auto-verify");e3(a&&a.status?a:null),tL(e.id)}catch(e){e1(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{eY(!1)}},tV=async()=>{if(eU||0===h.length)return;let e=Object.fromEntries(h.map(e=>[e.id,{state:"queued",error:null}]));eV.current=!1,eq(!0),eF(!1),eJ(null),eB(e),eW({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(eV.current){eW({total:h.length,completed:e,passed:t,failed:s,stopped:!0});break}let a=h[e];eJ(a.id),eB(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,eB(e=>({...e,[a.id]:{state:r?"success":"failed",error:r?null:i.error||null}}))}catch(e){s+=1,eB(t=>({...t,[a.id]:{state:"failed",error:e.message||"Test failed"}}))}eW({total:h.length,completed:e+1,passed:t,failed:s,stopped:!1}),e<h.length-1&&await new Promise(e=>setTimeout(e,1e3))}}finally{eJ(null),eq(!1),eF(!1),eV.current=!1}},tG=async e=>{let t=h.find(t=>t.id===e),s=t?.name?.trim()||t?.email?.trim()||e;eP({title:"Delete Connection",message:`Delete connection “${s}”?`,onConfirm:async()=>{eP(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)}}})},tQ=()=>{tM(),P(!1)},tZ=async e=>{G("");try{let t=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:u,...e})}),s=null;try{s=await t.json()}catch{s=null}if(t.ok){await tM(),W(!1);return}G(s?.error||"Failed to save connection")}catch(e){(0,E.s)("Error saving connection:",e),G("Failed to save connection")}},tX=async e=>{try{(await fetch(`/api/providers/${es.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok&&(await tM(),Y(!1))}catch(e){(0,E.s)("Error updating connection:",e)}},tY=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)}},t0=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 tM()}catch(e){(0,E.s)("Error adding host to allow list:",e)}}},t1=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 tM()}},t2=h.length>0&&g.length===h.length,t5=(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:g.includes(e.id),onChange:()=>{var t;return t=e.id,void y(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:()=>t1(t,t-1),onMoveDown:()=>t1(t,t+1),onToggleActive:t=>tY(e.id,t),autoPing:B[u]&&"oauth"===e.authType?{on:!0===eN.connections[e.id],onToggle:t=>{var s;return s=e.id,void tF({...eN,connections:{...eN.connections,[s]:t}})},provider:u}:null,onEdit:()=>{ea(e),Y(!0)},onDelete:()=>tG(e.id),onAllowlistHost:()=>t0(e),oneByOneStatus:eK[e.id]||null})})]},e.id))}),t4=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:`${t$}/${e}`})}),s=await t.json();em(t=>({...t,[e]:s.ok?"ok":"error"})),eu(s.ok?"":s.error||"Model not reachable")}catch{em(t=>({...t,[e]:"error"})),eu("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)(l(),{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:tg&&td.apiType?"responses"===td.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":ty?"/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-center gap-2 px-3 py-2 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px] text-yellow-500 mt-0.5 shrink-0",children:"warning"}),(0,a.jsx)("p",{className:"text-xs text-red-600 dark:text-yellow-400 leading-relaxed",children:td.deprecationNotice})]}),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 →"})]}),tb&&T&&(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:ty?"Anthropic Compatible Details":"OpenAI Compatible Details"}),(0,a.jsxs)("p",{className:"break-all text-sm text-text-muted",children:[ty?"Messages API":"responses"===T.apiType?"Responses API":"Chat Completions"," \xb7 ",(T.baseUrl||"").replace(/\/$/,""),"/",ty?"messages":"responses"===T.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(""),W(!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()=>{eP({title:"Delete Compatible Node",message:`Delete this ${ty?"Anthropic":"OpenAI"} Compatible node?`,onConfirm:async()=>{eP(null);try{(await fetch(`/api/provider-nodes/${u}`,{method:"DELETE"})).ok&&p.push("/dashboard/providers")}catch(e){(0,E.s)("Error deleting provider node:",e)}}})},className:"w-full sm:w-auto",children:"Delete"})]})]})}),tu?(0,a.jsx)(d.gw,{providerId:u}):(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:[g.length>0&&(0,a.jsxs)(d.$n,{size:"sm",variant:"danger",icon:"delete",onClick:()=>{let e=g.length;0!==e&&eP({title:`Delete ${e} Connection${e>1?"s":""}`,message:`Delete ${e} connection${e>1?"s":""}? This cannot be undone.`,onConfirm:async()=>{eP(null);let e=0,t=[...g];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))),y([]),e>0&&(0,E.s)(`Deleted ${t.length-e} connection(s), ${e} failed.`)}})},children:["Delete Selected (",g.length,")"]}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"sync",onClick:tV,disabled:eU,children:eU?"Testing Connection One-by-One...":"Test Connection One-by-One"}),eU&&(0,a.jsx)(d.$n,{size:"sm",variant:"ghost",icon:"stop",onClick:()=>{eU&&(eV.current=!0,eF(!0))},disabled:e_,children:e_?"Stopping...":"Stop"})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,a.jsx)("span",{className:"text-xs text-text-muted font-medium",children:"Round Robin"}),(0,a.jsx)(d.lM,{checked:"round-robin"===ey,onChange:e=>{let t=e?"round-robin":null,s=e?ev||"1":ev;e&&!ev&&ej("1"),eb(t),tq(t,s)}}),"round-robin"===ey&&(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=>{var t;ej(t=e.target.value),tq("round-robin",t)},placeholder:"1",className:"w-14 px-2 py-1 text-xs border border-border rounded-md bg-background focus:outline-none focus:border-primary"})]})]})]})]}),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:tn,children:tk}),(0,a.jsx)(d.$n,{size:"sm",icon:"key",onClick:tl,children:tN})]}):(0,a.jsxs)(a.Fragment,{children:[!tb&&"iflow"===u&&(0,a.jsx)(d.$n,{size:"sm",icon:"cookie",variant:"secondary",onClick:()=>F(!0),children:"Cookie"}),"codex"===u&&(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:to,children:tb?"Add API Key":"iflow"===u?"OAuth":"Add Connection"})]})})]}):(0,a.jsxs)(a.Fragment,{children:[eH&&(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: ",eH.total]}),(0,a.jsxs)("span",{children:["Completed: ",eH.completed]}),(0,a.jsxs)("span",{children:["Passed: ",eH.passed]}),(0,a.jsxs)("span",{children:["Failed: ",eH.failed]}),eH.stopped&&(0,a.jsx)("span",{className:"text-amber-600 dark:text-amber-400",children:"Stopped"}),eU&&eL&&(0,a.jsxs)("span",{children:["Running: ",h.find(e=>e.id===eL)?.name||eL]})]})}),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:t2,onChange:()=>{t2?y([]):y(h.map(e=>e.id))},className:"h-3.5 w-3.5 rounded border-gray-300 text-primary focus:ring-primary"}),"Select All"]})}),t5,!tb&&(0,a.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-2 sm:flex",children:["iflow"===u&&(0,a.jsx)(d.$n,{size:"sm",icon:"cookie",variant:"secondary",onClick:()=>F(!0),title:"Add connection using browser cookie",className:"w-full sm:w-auto",children:"Cookie"}),"codex"===u&&(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:tn,className:"w-full sm:w-auto",children:tk}),(0,a.jsx)(d.$n,{size:"sm",icon:"key",onClick:tl,className:"w-full sm:w-auto",children:tN})]}):(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:to,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"}),tS&&(0,a.jsx)("select",{value:ew,onChange:e=>{var t;ek(t=e.target.value),t_(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:tS.map(e=>(0,a.jsx)("option",{value:e,children:`Thinking: ${e.charAt(0).toUpperCase()+e.slice(1)}`},e))})]}),tj.showToolbar&&(e=(tj.showBulkControls?[...th,...eO.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=>!eR.includes(e)),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[tj.showImport&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:eX?"progress_activity":"cloud_download",onClick:tW,disabled:eX||!tv,title:tv?"Import models from the active connection":"Add an active connection to import models",children:eX?"Importing...":"Import models"}),tj.showVerify&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:e4?.status==="running"?"progress_activity":"science",onClick:()=>e5(e=>!e),children:e4?.status==="running"?`Verifying ${e4.done}/${e4.total}`:e2?"Hide verify":"Verify models"}),tj.showBulkControls&&eR.length>0&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"restart_alt",onClick:tD,children:"Active All"}),tj.showBulkControls&&e.length>0&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"block",onClick:()=>tR(e),children:"Disable All"})]}))]}),!!ep&&(0,a.jsx)("p",{className:"text-xs text-red-500 mb-3 break-words",children:ep}),e0&&(0,a.jsx)("p",{className:"text-xs text-text-muted mb-3",children:e0}),e2&&(t=h.find(e=>g.includes(e.id)&&!1!==e.isActive)||h.find(e=>!1!==e.isActive),s=[...(0,C.R)({customModels:en,modelAliases:ei,providerAlias:t$,builtInModels:th,type:"llm"}).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)&&!eR.includes(e.id)}).map(e=>({id:e.id,name:e.name||e.id,kind:"llm"}))],(0,a.jsx)(J,{connectionId:t?.id,providerAlias:t$,models:s,jobSnapshot:e4,onClose:()=>e5(!1),onStarted:e=>{e3(e&&e.status?e:null);let s=e?.connectionId||t?.id;s&&tL(s)},onComplete:async e=>{e?.removed>0&&await tP(),(e?.removed>0||e?.cacheCleared)&&await tz(t?.id)}})),(()=>{let e,t,s;if(tb)return(0,a.jsx)(D,{providerStorageAlias:t$,providerDisplayAlias:tA,modelAliases:ei,customModels:en,copied:ts,onCopy:ta,onSetAlias:tJ,onDeleteAlias:tK,onAddCustomModel:e=>tB(e,"llm",t$),onDeleteCustomModel:e=>tH(e,"llm",t$),onRefreshModels:tP,connections:h,isAnthropic:ty});let i=[...th,...eO.filter(e=>!th.some(t=>t.id===e.id))].filter(e=>{let t=(0,m.CP)(e);return!t||"llm"===t}),r=new Set(eR),n=i.filter(e=>!r.has(e.id)),l=i.filter(e=>r.has(e.id)),o=(0,C.R)({customModels:en,modelAliases:ei,providerAlias:t$,builtInModels:th,type:"llm"}),d=o.filter(e=>"all"===te||(e8[K(e.id,t$)]||null)===te),c=n.filter(e=>"all"===te||(e8[K(e.id,t$)]||null)===te);return(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsx)("div",{className:"mb-2 flex gap-1 text-xs",children:["all","ok","dead","retry"].map(e=>(0,a.jsx)("button",{onClick:()=>tt(e),className:`rounded px-2 py-0.5 ${te===e?"bg-primary text-white":"text-text-muted hover:bg-black/5 dark:hover:bg-white/5"}`,children:"all"===e?"All":"ok"===e?"OK":"dead"===e?"Dead":"Retry"},e))}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-3",children:[d.map(e=>{let t=K(e.id,t$);return(0,a.jsx)(O,{model:{id:e.id,name:e.name},fullModel:`${tA}/${e.id}`,alias:e.alias,copied:ts,onCopy:ta,onSetAlias:()=>{},onDeleteAlias:()=>{"custom"===e.source?tH(e.id,"llm",t$):tK(e.alias)},testStatus:ec[e.id],onTest:h.length>0||tu?()=>t4(e.id):void 0,isTesting:ex.has(e.id),isCustom:!0,isFree:!1,caps:x(`${u}/${e.id}`),thinkingSuffix:tC(e.id),latencyMs:e6[e.id]??e6[t],probeState:e4?.status==="running"&&e4?.perModel?.[t]?e4.perModel[t]:e8[t]||null},`${e.source}-${e.fullModel}`)}),c.map(e=>{let t=`${t$}/${e.id}`,s=`${u}/${e.id}`,i=Object.entries(ei).find(([,e])=>e===t||e===s)?.[0],r=K(e.id,t$);return(0,a.jsx)(O,{model:e,fullModel:`${tA}/${e.id}`,alias:i,copied:ts,onSetAlias:t=>tJ(e.id,t,t$),onCopy:ta,onDeleteAlias:()=>tK(i),testStatus:ec[e.id],onTest:h.length>0||tu?()=>t4(e.id):void 0,isTesting:ex.has(e.id),isFree:e.isFree,onDisable:()=>tO(e.id),caps:x(`${u}/${e.id}`),thinkingSuffix:tC(e.id),latencyMs:e6[e.id]??e6[r],probeState:e4?.status==="running"&&e4?.perModel?.[r]?e4.perModel[r]:e8[r]||null},e.id)}),(0,a.jsxs)("button",{onClick:()=>eg(!0),className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-primary/40 px-3 py-2 text-xs text-primary transition-colors hover:border-primary hover:bg-primary/5 sm:w-auto",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"add"}),"Add Model"]}),eS.length>0&&(e=new Set([...Object.values(ei),...o.map(e=>e.fullModel)]),t=new Set(th.map(e=>e.id)),0===(s=eS.filter(s=>!e.has(`${t$}/${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 tB(e.id,"llm",t$)},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:()=>tE(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"===u?(0,a.jsx)(d.Mh,{isOpen:I,providerInfo:td,onSuccess:tQ,onClose:()=>P(!1)}):"cursor"===u?(0,a.jsx)(d.G9,{isOpen:I,onSuccess:tQ,onClose:()=>P(!1)}):"gitlab"===u?(0,a.jsx)(d.vj,{isOpen:I,providerInfo:td,onSuccess:tQ,onClose:()=>P(!1)}):(0,a.jsx)(d.LF,{isOpen:I,provider:u,providerInfo:td,onSuccess:tQ,onClose:()=>P(!1)}),"iflow"===u&&(0,a.jsx)(d.vE,{isOpen:z,onSuccess:()=>{tM(),F(!1)},onClose:()=>F(!1)}),(0,a.jsx)(U,{isOpen:H,provider:u,providerName:td.name,isCompatible:tb,isAnthropic:ty,authType:td?.authType,authHint:td?.authHint,website:td?.website,error:V,onSave:tZ,onBulkDone:tM,onClose:()=>{G(""),W(!1)}}),(0,a.jsx)(d.wI,{isOpen:X,connection:es,onSave:tX,onClose:()=>Y(!1)}),tb&&(0,a.jsx)(q,{isOpen:ee,node:T,onSave:tU,onClose:()=>et(!1),isAnthropic:ty}),!tb&&(0,a.jsx)(_,{isOpen:ef,providerAlias:t$,providerDisplayAlias:tA,onSave:async e=>{await tB(e,"llm",t$),eg(!1)},onClose:()=>eg(!1)}),"codex"===u&&(0,a.jsx)(L,{isOpen:Q,onClose:()=>Z(!1),onSuccess:tM}),(0,a.jsx)(d.uo,{isOpen:eM,onClose:()=>ez(!1),onConfirm:()=>{(window.localStorage.setItem(ti,"true"),ez(!1),tm)?tr():tl()},title:"Risk Notice",message:td?.deprecationNotice,confirmText:"I Understand, Continue",cancelText:"Cancel",variant:"danger"}),(0,a.jsx)(d.uo,{isOpen:!!eI,onClose:()=>eP(null),onConfirm:eI?.onConfirm,title:eI?.title||"Confirm",message:eI?.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)(l(),{href:"/dashboard/providers",className:"text-primary mt-4 inline-block",children:"Back to Providers"})]})}},7687:(e,t,s)=>{Promise.resolve().then(s.bind(s,4003))},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,7592,5497,8441,3794,7358],()=>e(e.s=7687)),_N_E=e.O()}]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9089],{15615:(e,r,a)=>{"use strict";a.r(r),a.d(r,{default:()=>m});var t=a(95155),s=a(12115),i=a(73321),l=a(98500),d=a.n(l),o=a(35497),n=a(90620);let c=Object.values(n.Q2).map(e=>({value:e.id,label:e.name})),p=Object.values(n.MA).map(e=>({value:e.id,label:e.name}));function m(){let e=(0,i.useRouter)(),[r,a]=(0,s.useState)(!1),[l,m]=(0,s.useState)({provider:"",authMethod:"api_key",apiKey:"",displayName:"",isActive:!0}),[u,h]=(0,s.useState)({}),x=(e,r)=>{m(a=>({...a,[e]:r})),u[e]&&h(r=>({...r,[e]:null}))},b=async r=>{let t;if(r.preventDefault(),t={},l.provider||(t.provider="Please select a provider"),"api_key"!==l.authMethod||l.apiKey.trim()||(t.apiKey="API Key is required"),h(t),0===Object.keys(t).length){a(!0);try{let r=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...l,apiKey:l.apiKey.trim()})});if(r.ok)e.push("/dashboard/providers");else{let e=await r.json();h({submit:e.error||"Failed to create provider"})}}catch(e){h({submit:"An error occurred. Please try again."})}finally{a(!1)}}},v=n.Q2[l.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:b,className:"flex flex-col gap-6",children:[(0,t.jsx)(o.l6,{label:"Provider",options:c,value:l.provider,onChange:e=>x("provider",e.target.value),placeholder:"Select a provider",error:u.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)("label",{className:"text-sm font-medium",children:["Authentication Method ",(0,t.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,t.jsx)("div",{className:"flex gap-3",children:p.map(e=>(0,t.jsxs)("button",{type:"button",onClick:()=>x("authMethod",e.value),className:`flex-1 flex items-center justify-center gap-2 p-4 rounded-lg border transition-all ${l.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",children:"api_key"===e.value?"key":"lock"}),(0,t.jsx)("span",{className:"font-medium",children:e.label})]},e.value))})]}),"api_key"===l.authMethod&&(0,t.jsx)(o.pd,{label:"API Key",type:"password",autoComplete:"off",placeholder:"Enter your API key",value:l.apiKey,onChange:e=>x("apiKey",e.target.value),error:u.apiKey,hint:"Your API key will be encrypted and stored securely.",required:!0}),(0,t.jsx)(o.pd,{label:"Display Name",placeholder:"e.g., Production API, Dev Environment",value:l.displayName,onChange:e=>x("displayName",e.target.value),hint:"Optional. A friendly name to identify this configuration."}),(0,t.jsx)(o.lM,{checked:l.isActive,onChange:e=>x("isActive",e),label:"Active",description:"Enable this provider for use in your applications"}),u.submit&&(0,t.jsx)("div",{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:u.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:r,fullWidth:!0,className:"flex-1",children:"Create Provider"})]})]})})]})}},80800:(e,r,a)=>{Promise.resolve().then(a.bind(a,15615))}},e=>{e.O(0,[2574,3862,782,8500,
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9089],{15615:(e,r,a)=>{"use strict";a.r(r),a.d(r,{default:()=>m});var t=a(95155),s=a(12115),i=a(73321),l=a(98500),d=a.n(l),o=a(35497),n=a(90620);let c=Object.values(n.Q2).map(e=>({value:e.id,label:e.name})),p=Object.values(n.MA).map(e=>({value:e.id,label:e.name}));function m(){let e=(0,i.useRouter)(),[r,a]=(0,s.useState)(!1),[l,m]=(0,s.useState)({provider:"",authMethod:"api_key",apiKey:"",displayName:"",isActive:!0}),[u,h]=(0,s.useState)({}),x=(e,r)=>{m(a=>({...a,[e]:r})),u[e]&&h(r=>({...r,[e]:null}))},b=async r=>{let t;if(r.preventDefault(),t={},l.provider||(t.provider="Please select a provider"),"api_key"!==l.authMethod||l.apiKey.trim()||(t.apiKey="API Key is required"),h(t),0===Object.keys(t).length){a(!0);try{let r=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...l,apiKey:l.apiKey.trim()})});if(r.ok)e.push("/dashboard/providers");else{let e=await r.json();h({submit:e.error||"Failed to create provider"})}}catch(e){h({submit:"An error occurred. Please try again."})}finally{a(!1)}}},v=n.Q2[l.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:b,className:"flex flex-col gap-6",children:[(0,t.jsx)(o.l6,{label:"Provider",options:c,value:l.provider,onChange:e=>x("provider",e.target.value),placeholder:"Select a provider",error:u.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)("label",{className:"text-sm font-medium",children:["Authentication Method ",(0,t.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,t.jsx)("div",{className:"flex gap-3",children:p.map(e=>(0,t.jsxs)("button",{type:"button",onClick:()=>x("authMethod",e.value),className:`flex-1 flex items-center justify-center gap-2 p-4 rounded-lg border transition-all ${l.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",children:"api_key"===e.value?"key":"lock"}),(0,t.jsx)("span",{className:"font-medium",children:e.label})]},e.value))})]}),"api_key"===l.authMethod&&(0,t.jsx)(o.pd,{label:"API Key",type:"password",autoComplete:"off",placeholder:"Enter your API key",value:l.apiKey,onChange:e=>x("apiKey",e.target.value),error:u.apiKey,hint:"Your API key will be encrypted and stored securely.",required:!0}),(0,t.jsx)(o.pd,{label:"Display Name",placeholder:"e.g., Production API, Dev Environment",value:l.displayName,onChange:e=>x("displayName",e.target.value),hint:"Optional. A friendly name to identify this configuration."}),(0,t.jsx)(o.lM,{checked:l.isActive,onChange:e=>x("isActive",e),label:"Active",description:"Enable this provider for use in your applications"}),u.submit&&(0,t.jsx)("div",{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:u.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:r,fullWidth:!0,className:"flex-1",children:"Create Provider"})]})]})})]})}},80800:(e,r,a)=>{Promise.resolve().then(a.bind(a,15615))}},e=>{e.O(0,[2574,3862,782,8500,594,1321,7592,5497,8441,3794,7358],()=>e(e.s=80800)),_N_E=e.O()}]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8460],{18964:(e,t,s)=>{"use strict";s.d(t,{default:()=>N});var r=s(95155),a=s(12115),l=s(14051),i=s.n(l),n=s(35497),o=s(57250),d=s(65921),c=s(90620),m=s(88105),p=s(98500),x=s.n(p),u=s(38003);let h={available:{icon:"check_circle",color:"#22c55e",label:"Available"},cooldown:{icon:"schedule",color:"#f59e0b",label:"Cooldown"},unavailable:{icon:"error",color:"#ef4444",label:"Unavailable"},unknown:{icon:"help",color:"#6b7280",label:"Unknown"}};function f(){let[e,t]=(0,a.useState)(null),[s,l]=(0,a.useState)(!0),[i,o]=(0,a.useState)(!1),[c,m]=(0,a.useState)(null),p=(0,a.useRef)(null),x=(0,d.i)(),u=(0,a.useCallback)(async()=>{try{let e=await fetch("/api/models/availability");if(e.ok){let s=await e.json();t(s)}}catch{}finally{l(!1)}},[]);(0,a.useEffect)(()=>{u();let e=setInterval(u,3e4);return()=>clearInterval(e)},[u]),(0,a.useEffect)(()=>{let e=e=>{p.current&&!p.current.contains(e.target)&&o(!1)};return i&&document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[i]);let f=async(e,t)=>{m(`${e}:${t}`);try{(await fetch("/api/models/availability",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clearCooldown",provider:e,model:t})})).ok?(x.success(`Cooldown cleared for ${t}`),await u()):x.error("Failed to clear cooldown")}catch{x.error("Failed to clear cooldown")}finally{m(null)}};if(s)return null;let g=e?.models||[],b=0===(e?.unavailableCount||g.filter(e=>"available"!==e.status).length),y={};return g.forEach(e=>{if("available"===e.status)return;let t=e.provider||"unknown";y[t]||(y[t]=[]),y[t].push(e)}),(0,r.jsx)("div",{className:"relative",ref:p,children:i&&(0,r.jsxs)("div",{className:"absolute top-full right-0 mt-2 w-80 bg-surface border border-border rounded-xl shadow-2xl z-50 overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-bg",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[16px]",style:{color:b?"#22c55e":"#f59e0b"},children:b?"verified":"warning"}),(0,r.jsx)("span",{className:"text-sm font-semibold text-text-main",children:"Model Status"})]}),(0,r.jsx)("button",{onClick:u,className:"p-1 rounded-lg hover:bg-surface text-text-muted hover:text-text-main transition-colors",title:"Refresh",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"refresh"})})]}),(0,r.jsx)("div",{className:"px-4 py-3 max-h-60 overflow-y-auto",children:b?(0,r.jsx)("p",{className:"text-sm text-text-muted text-center py-2",children:"All models are responding normally."}):(0,r.jsx)("div",{className:"flex flex-col gap-2.5",children:Object.entries(y).map(([e,t])=>(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-xs font-semibold text-text-main mb-1.5 capitalize",children:e}),(0,r.jsx)("div",{className:"flex flex-col gap-1",children:t.map(e=>{let t=h[e.status]||h.unknown,s=c===`${e.provider}:${e.model}`;return(0,r.jsxs)("div",{className:"flex items-center justify-between px-2.5 py-1.5 rounded-lg bg-surface/30",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[14px] shrink-0",style:{color:t.color},children:t.icon}),(0,r.jsx)("span",{className:"font-mono text-xs text-text-main truncate",children:e.model})]}),"cooldown"===e.status&&(0,r.jsx)(n.$n,{size:"sm",variant:"ghost",onClick:()=>f(e.provider,e.model),disabled:s,className:"text-[10px] px-1.5! py-0.5! ml-2",children:s?"...":"Clear"})]},`${e.provider}-${e.model}`)})})]},e))})})]})})}var g=s(78559);let b={openai:{title:"Add OpenAI Compatible",type:"openai-compatible",defaultBaseUrl:"https://api.openai.com/v1",namePlaceholder:"My LiteLLM / OpenRouter / vLLM",baseUrlHint:"Base URL ending in /v1 for your OpenAI-compatible API.",modelIdPlaceholder:"e.g. gpt-4, claude-3-opus",errorLabel:"OpenAI Compatible",hasApiType:!0},anthropic:{title:"Add Anthropic Compatible",type:"anthropic-compatible",defaultBaseUrl:"https://api.anthropic.com/v1",namePlaceholder:"My Claude proxy",baseUrlHint:"Base URL ending in /v1. /messages is appended automatically.",modelIdPlaceholder:"e.g. claude-3-opus",errorLabel:"Anthropic Compatible",hasApiType:!1}},y=[{value:"chat",label:"Chat Completions"},{value:"responses",label:"Responses API"}];function v({variant:e,isOpen:t,onClose:s,onCreated:l}){let i=b[e],o=()=>({name:"",...i.hasApiType?{apiType:"chat"}:{},baseUrl:i.defaultBaseUrl}),[d,c]=(0,a.useState)(o),[m,p]=(0,a.useState)(!1),[x,u]=(0,a.useState)(""),[h,f]=(0,a.useState)(""),[j,N]=(0,a.useState)(""),[w,k]=(0,a.useState)(!1),[C,T]=(0,a.useState)(null),A=function(e){try{return["http:","https:"].includes(new URL(e).protocol)}catch{return!1}}(d.baseUrl.trim());(0,a.useEffect)(()=>{t&&(c(o()),u(""),f(""),N(""),T(null))},[t,e]),(0,a.useEffect)(()=>{i.hasApiType&&t&&c(e=>({...e,baseUrl:i.defaultBaseUrl}))},[d.apiType]);let I=async()=>{if(!d.name.trim()||!A)return void u("Enter a valid http:// or https:// base URL");p(!0),u("");try{let e=await fetch("/api/provider-nodes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:d.name.trim(),...i.hasApiType?{apiType:d.apiType}:{},baseUrl:d.baseUrl.trim(),type:i.type})}),t=await e.json();e.ok?(l(t.node),c(o()),f(""),T(null)):u(t.error||"Failed to create provider")}catch(e){(0,g.s)(`Error creating ${i.errorLabel} node:`,e),u("Network error")}finally{p(!1)}},E=async()=>{k(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:d.baseUrl,apiKey:h,type:i.type,modelId:j.trim()||void 0})}),t=await e.json();T(t)}catch{T({valid:!1,error:"Network error"})}finally{k(!1)}};return(0,r.jsx)(n.aF,{isOpen:t,title:i.title,onClose:s,children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsx)(n.pd,{label:"Name",value:d.name,onChange:e=>c({...d,name:e.target.value}),placeholder:i.namePlaceholder,hint:"Friendly label (e.g. Work LiteLLM)."}),i.hasApiType&&(0,r.jsx)(n.l6,{label:"API Type",options:y,value:d.apiType,onChange:e=>c({...d,apiType:e.target.value})}),(0,r.jsx)(n.pd,{label:"Base URL",value:d.baseUrl,onChange:e=>c({...d,baseUrl:e.target.value}),placeholder:i.defaultBaseUrl,hint:i.baseUrlHint}),(0,r.jsx)(n.pd,{label:"API Key (for Check)",type:"password",autoComplete:"off",value:h,onChange:e=>f(e.target.value)}),(0,r.jsx)(n.pd,{label:"Model ID (optional)",value:j,onChange:e=>N(e.target.value),placeholder:i.modelIdPlaceholder,hint:"If the provider has no /models endpoint, enter a model ID to test chat/completions."}),(0,r.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[(0,r.jsx)(n.$n,{onClick:E,disabled:!h||w||!A,variant:"secondary",className:"w-full sm:w-auto",children:w?"Checking...":"Check"}),(()=>{if(!C)return null;let{valid:e,error:t,method:s}=C;return e?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.Ex,{variant:"success",children:"Valid"}),"chat"===s&&(0,r.jsx)("span",{className:"text-sm text-text-muted",children:"(via inference test)"})]}):(0,r.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,r.jsx)(n.Ex,{variant:"error",children:"Invalid"}),t&&(0,r.jsx)("span",{className:"text-sm text-red-500",children:t})]})})()]}),x?(0,r.jsx)("p",{className:"text-sm text-red-500",children:x}):null,(0,r.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row",children:[(0,r.jsx)(n.$n,{onClick:I,fullWidth:!0,disabled:!d.name.trim()||!A||m,children:m?"Creating...":"Create"}),(0,r.jsx)(n.$n,{onClick:s,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}function j(e,t,s){let a=[];if(e>0&&a.push((0,r.jsxs)(n.Ex,{variant:"success",size:"sm",dot:!0,children:[e," Connected"]},"connected")),t>0){let e=s?`${t} Error (${s})`:`${t} Error`;a.push((0,r.jsx)(n.Ex,{variant:"error",size:"sm",dot:!0,children:e},"error"))}return 0===a.length?(0,r.jsx)("span",{className:"text-text-muted",children:"No connections"}):a}function N({initialData:e}){let[t,s]=(0,a.useState)(e?.connections||[]),[l,i]=(0,a.useState)(e?.nodes||[]),[o,p]=(0,a.useState)(!e),[x,h]=(0,a.useState)(!1),[g,b]=(0,a.useState)(!1),[y,j]=(0,a.useState)(!1),[T,A]=(0,a.useState)(!1),[I,E]=(0,a.useState)(null),[$,R]=(0,a.useState)(null),O=(0,d.i)(),S=(0,u.C)(e=>e.query),P=(0,u.C)(e=>e.register),U=(0,u.C)(e=>e.unregister);(0,a.useEffect)(()=>(P("Search providers..."),()=>U()),[P,U]);let _=e=>!S.trim()||e.toLowerCase().includes(S.trim().toLowerCase()),z=(e,t)=>[...e].sort(([e,s],[r,a])=>{let l=s.priority??999,i=a.priority??999;if(l!==i)return l-i;let n=M(e,t),o=M(r,t),d=+(n.connected>0),c=+(o.connected>0);return d!==c?c-d:(s.name||"").localeCompare(a.name||"")}),L=(0,a.useCallback)(async()=>{try{let[e,t]=await Promise.all([fetch("/api/providers"),fetch("/api/provider-nodes")]);if(!e.ok||!t.ok)throw Error("Failed to fetch provider data");let r=await e.json(),a=await t.json();e.ok&&s(r.connections||[]),t.ok&&i(a.nodes||[])}catch(e){O.error("Failed to fetch provider data")}finally{p(!1)}},[O]);(0,a.useEffect)(()=>{e?.connections?p(!1):L()},[e,L]);let M=(e,s)=>{let r=Array.isArray(s)?s:[s],a=t.filter(t=>t.provider===e&&r.includes(t.authType)),l=e=>{let t=Object.entries(e).some(([e,t])=>e.startsWith("modelLock_")&&t&&new Date(t).getTime()>Date.now());return"unavailable"!==e.testStatus||t?e.testStatus:"active"},i=a.filter(e=>{let t=l(e);return"active"===t||"success"===t}).length,n=a.filter(e=>{let t=l(e);return"error"===t||"expired"===t||"unavailable"===t}),o=n.length,d=a.length,c=d>0&&a.every(e=>!1===e.isActive),m=n.sort((e,t)=>new Date(t.lastErrorAt||0)-new Date(e.lastErrorAt||0))[0];return{connected:i,error:o,total:d,errorCode:m?function(e){if(!e)return null;let t=e.lastErrorType;if("runtime_error"===t)return"RUNTIME";if("upstream_auth_error"===t||"auth_missing"===t||"token_refresh_failed"===t||"token_expired"===t)return"AUTH";if("upstream_rate_limited"===t)return"429";if("upstream_unavailable"===t)return"5XX";if("network_error"===t)return"NET";let s=Number(e.errorCode);if(Number.isFinite(s)&&s>=400)return String(s);let r=function(e){if(!e)return null;let t=e.match(/\b([45]\d{2})\b/);return t?t[1]:"ERR"}(e.lastError);if("401"===r||"403"===r)return"AUTH";if(r&&"ERR"!==r)return r;let a=(e.lastError||"").toLowerCase();return a.includes("runtime")||a.includes("not runnable")||a.includes("not installed")?"RUNTIME":a.includes("invalid api key")||a.includes("token invalid")||a.includes("revoked")||a.includes("unauthorized")?"AUTH":"ERR"}(m):null,errorTime:m?.lastErrorAt?function(e){if(!e)return"";let t=Math.floor((Date.now()-new Date(e).getTime())/6e4);if(t<1)return"just now";if(t<60)return`${t}m ago`;let s=Math.floor(t/60);if(s<24)return`${s}h ago`;let r=Math.floor(s/24);return`${r}d ago`}(m.lastErrorAt):null,allDisabled:c}},q=async(e,r,a)=>{let l=Array.isArray(r)?r:[r],i=t=>t.provider===e&&l.includes(t.authType),n=t.filter(i);s(e=>e.map(e=>i(e)?{...e,isActive:a}:e)),await Promise.allSettled(n.map(e=>fetch(`/api/providers/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:a})})))},F=async(e,t=null)=>{if(!I){E("provider"===e?t:e),R(null);try{let s=await fetch("/api/providers/test-batch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:e,providerId:t})}),r=await s.json();if(R(r),r.summary){let{passed:e,failed:t,total:s}=r.summary;0===t?O.success(`All ${s} tests passed`):O.warning(`${e}/${s} passed, ${t} failed`)}}catch(e){R({error:"Test request failed"}),O.error("Provider test failed")}finally{E(null)}}},D=l.filter(e=>"openai-compatible"===e.type).map(e=>({id:e.id,name:e.name||"OpenAI Compatible",color:"#10A37F",textIcon:"OC",apiType:e.apiType})).filter(e=>_(e.name)),B=l.filter(e=>"anthropic-compatible"===e.type).map(e=>({id:e.id,name:e.name||"Anthropic Compatible",color:"#D97757",textIcon:"AC"})).filter(e=>_(e.name)),K=z(Object.entries(c.zN).filter(([,e])=>!e.hidden&&_(e.name)),"oauth"),H=Object.entries(m.IS).filter(([,e])=>!e.hidden&&_(e.name)).sort(([,e],[,t])=>!!t.noAuth-!!e.noAuth),J=z(Object.entries(m.nJ).filter(([,e])=>!e.hidden&&_(e.name)&&(e.serviceKinds??["llm"]).includes("llm")),"freeTier").sort(([,e],[,t])=>!!t.noAuth-!!e.noAuth),W=Object.entries(c.fg).filter(([,e])=>!e.hidden&&(e.serviceKinds??["llm"]).includes("llm")&&_(e.name)).sort(([e,t],[s,r])=>{let a=M(e,"apikey").total>0?0:1,l=M(s,"apikey").total>0?0:1;return a!==l?a-l:(t.name||"").localeCompare(r.name||"")}),Q=!!S.trim(),X=Q||x?W:W.slice(0,20),Z=W.length-20;if(o)return(0,r.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,r.jsx)(n.Qv,{}),(0,r.jsx)(n.Qv,{})]});let V=!S.trim()||K.length>0||H.length>0||J.length>0||W.length>0||D.length>0||B.length>0;return(0,r.jsxs)("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:px-0",children:[!V&&(0,r.jsxs)("div",{className:"text-center py-8 border border-dashed border-border rounded-xl",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[32px] text-text-muted mb-2",children:"search_off"}),(0,r.jsx)("p",{className:"text-text-muted text-sm",children:"No providers match your search"})]}),K.length>0&&(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,r.jsx)("h2",{className:"text-lg sm:text-xl font-semibold flex items-center gap-2 leading-tight",children:"OAuth Providers"}),(0,r.jsxs)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center",children:[(0,r.jsx)(f,{}),(0,r.jsxs)("button",{onClick:()=>F("oauth"),disabled:!!I,className:`flex w-full items-center justify-center gap-1.5 rounded-lg border px-3 py-2 text-xs font-medium transition-colors sm:w-auto sm:py-1.5 ${"oauth"===I?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg border-border text-text-muted hover:text-text-main hover:border-primary/40"}`,title:"Test all OAuth connections","aria-label":"Test all OAuth connections",children:[(0,r.jsx)("span",{className:`material-symbols-outlined text-[14px]${"oauth"===I?" animate-spin":""}`,children:"play_arrow"}),"oauth"===I?"Testing...":"Test All"]})]})]}),(0,r.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4",children:K.map(([e,t])=>(0,r.jsx)(w,{providerId:e,provider:t,stats:M(e,"oauth"),authType:"oauth",onToggle:t=>q(e,"oauth",t)},e))})]}),(H.length>0||J.length>0)&&(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,r.jsx)("h2",{className:"text-lg sm:text-xl font-semibold flex items-center gap-2 leading-tight",children:"Free Tier Providers"}),(0,r.jsxs)("button",{onClick:()=>F("free"),disabled:!!I,className:`flex w-full items-center justify-center gap-1.5 rounded-lg border px-3 py-2 text-xs font-medium transition-colors sm:w-auto sm:py-1.5 ${"free"===I?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg border-border text-text-muted hover:text-text-main hover:border-primary/40"}`,title:"Test all Free connections","aria-label":"Test all Free provider connections",children:[(0,r.jsx)("span",{className:`material-symbols-outlined text-[14px]${"free"===I?" animate-spin":""}`,children:"play_arrow"}),"free"===I?"Testing...":"Test All"]})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4",children:[H.map(([e,t])=>{let s="kiro"===e?["oauth","apikey","api_key"]:"oauth";return(0,r.jsx)(w,{providerId:e,provider:t,stats:M(e,s),authType:"free",onToggle:t=>q(e,s,t)},e)}),J.map(([e,t])=>(0,r.jsx)(k,{providerId:e,provider:t,stats:M(e,"apikey"),authType:"apikey",onToggle:t=>q(e,"apikey",t)},e))]})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("h2",{className:"text-lg sm:text-xl font-semibold flex items-center gap-2 leading-tight",children:"API Key Providers"}),(0,r.jsx)("p",{className:"text-xs text-text-muted mt-1",children:"Built-in providers plus your own OpenAI- or Anthropic-compatible endpoints."})]}),(0,r.jsxs)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center",children:[(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)(n.$n,{size:"sm",icon:"add",onClick:()=>A(e=>!e),className:"w-full sm:w-auto",children:"Add custom provider"}),T&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{type:"button",className:"fixed inset-0 z-40 cursor-default","aria-label":"Close menu",onClick:()=>A(!1)}),(0,r.jsxs)("div",{className:"absolute right-0 top-full z-50 mt-1 w-64 rounded-xl border border-border bg-surface p-1 shadow-xl",children:[(0,r.jsxs)("button",{type:"button",className:"flex w-full items-start gap-2 rounded-lg px-3 py-2.5 text-left text-sm transition-colors hover:bg-bg",onClick:()=>{A(!1),b(!0)},children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[18px] text-primary mt-0.5",children:"api"}),(0,r.jsxs)("span",{children:[(0,r.jsx)("span",{className:"block font-medium",children:"OpenAI compatible"}),(0,r.jsx)("span",{className:"block text-xs text-text-muted",children:"Any OpenAI-style base URL + API key"})]})]}),(0,r.jsxs)("button",{type:"button",className:"flex w-full items-start gap-2 rounded-lg px-3 py-2.5 text-left text-sm transition-colors hover:bg-bg",onClick:()=>{A(!1),j(!0)},children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[18px] text-primary mt-0.5",children:"psychology"}),(0,r.jsxs)("span",{children:[(0,r.jsx)("span",{className:"block font-medium",children:"Anthropic compatible"}),(0,r.jsx)("span",{className:"block text-xs text-text-muted",children:"Messages API base URL + API key"})]})]})]})]})]}),W.length>0&&(0,r.jsxs)("button",{onClick:()=>F("apikey"),disabled:!!I,className:`flex w-full items-center justify-center gap-1.5 rounded-lg border px-3 py-2 text-xs font-medium transition-colors sm:w-auto sm:py-1.5 ${"apikey"===I?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg border-border text-text-muted hover:text-text-main hover:border-primary/40"}`,title:"Test all API Key connections","aria-label":"Test all API Key connections",children:[(0,r.jsx)("span",{className:`material-symbols-outlined text-[14px]${"apikey"===I?" animate-spin":""}`,children:"play_arrow"}),"apikey"===I?"Testing...":"Test All"]})]})]}),(D.length>0||B.length>0)&&(0,r.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,r.jsx)("p",{className:"text-xs font-semibold uppercase tracking-wider text-text-muted",children:"Your custom providers"}),(0,r.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4",children:[...D,...B].map(e=>(0,r.jsx)(k,{providerId:e.id,provider:e,stats:M(e.id,"apikey"),authType:"compatible",onToggle:t=>q(e.id,"apikey",t)},e.id))})]}),0===D.length&&0===B.length&&0===W.length&&(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center gap-3 py-8 border border-dashed border-border rounded-xl text-text-muted text-sm",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[28px]",children:"extension"}),(0,r.jsx)("p",{children:"No API key providers yet."}),(0,r.jsx)(n.$n,{size:"sm",icon:"add",onClick:()=>b(!0),children:"Add custom provider"})]}),X.length>0&&(0,r.jsxs)("div",{className:"flex flex-col gap-2",children:[(D.length>0||B.length>0)&&(0,r.jsx)("p",{className:"text-xs font-semibold uppercase tracking-wider text-text-muted",children:"Built-in providers"}),(0,r.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4",children:X.map(([e,t])=>(0,r.jsx)(k,{providerId:e,provider:t,stats:M(e,"apikey"),authType:"apikey",onToggle:t=>q(e,"apikey",t)},e))})]}),!Q&&!x&&Z>0&&(0,r.jsxs)("button",{onClick:()=>h(!0),className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-primary/40 px-3 py-2.5 text-sm font-medium text-primary transition-colors hover:border-primary hover:bg-primary/5",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"expand_more"}),"Show all ",W.length," providers"]})]}),(0,r.jsx)(v,{variant:"openai",isOpen:g,onClose:()=>b(!1),onCreated:e=>{i(t=>[...t,e]),b(!1)}}),(0,r.jsx)(v,{variant:"anthropic",isOpen:y,onClose:()=>j(!1),onCreated:e=>{i(t=>[...t,e]),j(!1)}}),$&&(0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex items-start justify-center px-3 pt-[6vh] sm:pt-[10vh]",onClick:()=>R(null),children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),(0,r.jsxs)("div",{className:"relative bg-surface border border-border rounded-xl w-full max-w-[600px] max-h-[86vh] sm:max-h-[80vh] overflow-y-auto shadow-2xl",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"sticky top-0 z-10 flex items-center justify-between px-5 py-3 border-b border-border bg-surface/95 backdrop-blur-sm rounded-t-xl",children:[(0,r.jsx)("h3",{className:"font-semibold",children:"Test Results"}),(0,r.jsx)("button",{onClick:()=>R(null),className:"p-1 rounded-lg hover:bg-bg text-text-muted hover:text-text-main transition-colors","aria-label":"Close test results",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-lg",children:"close"})})]}),(0,r.jsx)("div",{className:"p-5",children:(0,r.jsx)(C,{results:$})})]})]})]})}function w({providerId:e,provider:t,stats:s,authType:a,onToggle:l}){let{connected:i,error:d,errorCode:c,errorTime:m,allDisabled:p}=s,u=!!t.noAuth;return(0,r.jsx)(x(),{href:`/dashboard/providers/${e}`,className:"group min-w-0",children:(0,r.jsx)(n.Zp,{padding:"xs",className:`h-full hover:bg-black/[0.01] dark:hover:bg-white/[0.01] transition-colors cursor-pointer ${p?"opacity-50":""}`,children:(0,r.jsxs)("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,r.jsx)("div",{className:"size-8 shrink-0 rounded-lg flex items-center justify-center",style:{backgroundColor:`${t.color?.length>7?t.color:t.color+"15"}`},children:(0,r.jsx)(o.A,{src:`/providers/${t.id}.png`,alt:t.name,size:30,className:"object-contain rounded-lg max-w-[32px] max-h-[32px]",fallbackText:t.textIcon||t.id.slice(0,2).toUpperCase(),fallbackColor:t.color})}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("h3",{className:"truncate font-semibold",children:t.name}),(0,r.jsx)("div",{className:"flex min-w-0 items-center gap-1.5 text-xs flex-wrap",children:p?(0,r.jsx)(n.Ex,{variant:"default",size:"sm",children:(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"pause_circle"}),"Disabled"]})}):u?(0,r.jsx)(n.Ex,{variant:"success",size:"sm",dot:!0,children:"Ready"}):(0,r.jsxs)(r.Fragment,{children:[j(i,d,c),m&&(0,r.jsx)("span",{className:"text-text-muted",children:m})]})})]})]}),(0,r.jsx)("div",{className:"flex shrink-0 items-center gap-2",children:s.total>0&&(0,r.jsx)("div",{className:"opacity-100 transition-opacity sm:opacity-0 sm:group-hover:opacity-100",onClick:e=>{e.preventDefault(),e.stopPropagation(),l(!!p)},children:(0,r.jsx)(n.lM,{size:"sm",checked:!p,onChange:()=>{},title:p?"Enable provider":"Disable provider"})})})]})})})}function k({providerId:e,provider:t,stats:s,authType:a,onToggle:l}){let{connected:i,error:d,errorCode:c,errorTime:p,allDisabled:u}=s,h=e.startsWith(m.JH),f=e.startsWith(m.DI);return(0,r.jsx)(x(),{href:`/dashboard/providers/${e}`,className:"group min-w-0",children:(0,r.jsx)(n.Zp,{padding:"xs",className:`h-full hover:bg-black/[0.01] dark:hover:bg-white/[0.01] transition-colors cursor-pointer ${u?"opacity-50":""}`,children:(0,r.jsxs)("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,r.jsx)("div",{className:"size-8 shrink-0 rounded-lg flex items-center justify-center",style:{backgroundColor:`${t.color?.length>7?t.color:t.color+"15"}`},children:(0,r.jsx)(o.A,{src:h?"responses"===t.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":f?"/providers/anthropic-m.png":`/providers/${t.id}.png`,alt:t.name,size:30,className:"object-contain rounded-lg max-w-[30px] max-h-[30px]",fallbackText:t.textIcon||t.id.slice(0,2).toUpperCase(),fallbackColor:t.color})}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("h3",{className:"truncate font-semibold",children:t.name}),(0,r.jsx)("div",{className:"flex min-w-0 items-center gap-1.5 text-xs flex-wrap",children:u?(0,r.jsx)(n.Ex,{variant:"default",size:"sm",children:(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"pause_circle"}),"Disabled"]})}):(0,r.jsxs)(r.Fragment,{children:[j(i,d,c),h&&(0,r.jsx)(n.Ex,{variant:"default",size:"sm",children:"responses"===t.apiType?"Responses":"Chat"}),f&&(0,r.jsx)(n.Ex,{variant:"default",size:"sm",children:"Messages"}),p&&(0,r.jsx)("span",{className:"text-text-muted",children:p})]})})]})]}),(0,r.jsx)("div",{className:"flex shrink-0 items-center gap-2",children:s.total>0&&(0,r.jsx)("div",{className:"opacity-100 transition-opacity sm:opacity-0 sm:group-hover:opacity-100",onClick:e=>{e.preventDefault(),e.stopPropagation(),l(!!u)},children:(0,r.jsx)(n.lM,{size:"sm",checked:!u,onChange:()=>{},title:u?"Enable provider":"Disable provider"})})})]})})})}function C({results:e}){if(e.error&&!e.results)return(0,r.jsxs)("div",{className:"text-center py-6",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-red-500 text-[32px] mb-2 block",children:"error"}),(0,r.jsx)("p",{className:"text-sm text-red-400",children:e.error})]});let{summary:t,mode:s}=e,a=e.results||[];return(0,r.jsxs)("div",{className:"flex min-w-0 flex-col gap-3",children:[t&&(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs mb-1 sm:gap-3",children:[(0,r.jsxs)("span",{className:"text-text-muted",children:[{oauth:"OAuth",free:"Free",apikey:"API Key",provider:"Provider",all:"All"}[s]||s," Test"]}),(0,r.jsxs)("span",{className:"px-2 py-0.5 rounded bg-emerald-500/15 text-emerald-400 font-medium",children:[t.passed," passed"]}),t.failed>0&&(0,r.jsxs)("span",{className:"px-2 py-0.5 rounded bg-red-500/15 text-red-400 font-medium",children:[t.failed," failed"]}),(0,r.jsxs)("span",{className:"text-text-muted sm:ml-auto",children:[t.total," tested"]})]}),a.map((e,t)=>(0,r.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2 rounded-lg bg-black/[0.03] px-3 py-2 text-xs dark:bg-white/[0.03] sm:flex-nowrap",children:[(0,r.jsx)("span",{className:`material-symbols-outlined text-[16px] ${e.valid?"text-emerald-500":"text-red-500"}`,children:e.valid?"check_circle":"error"}),(0,r.jsxs)("div",{className:"min-w-0 flex-[1_1_160px]",children:[(0,r.jsx)("span",{className:"block truncate font-medium sm:inline",children:e.connectionName}),(0,r.jsxs)("span",{className:"block truncate text-text-muted sm:ml-1.5 sm:inline",children:["(",e.provider,")"]})]}),void 0!==e.latencyMs&&(0,r.jsxs)("span",{className:"shrink-0 text-text-muted font-mono tabular-nums",children:[e.latencyMs,"ms"]}),(0,r.jsx)("span",{className:`shrink-0 text-[10px] uppercase font-bold px-1.5 py-0.5 rounded ${e.valid?"bg-emerald-500/15 text-emerald-400":"bg-red-500/15 text-red-400"}`,children:e.valid?"OK":e.diagnosis?.type||"ERROR"})]},e.connectionId||t)),0===a.length&&(0,r.jsx)("div",{className:"text-center py-4 text-text-muted text-sm",children:"No active connections found for this group."})]})}v.propTypes={variant:i().oneOf(["openai","anthropic"]).isRequired,isOpen:i().bool.isRequired,onClose:i().func.isRequired,onCreated:i().func.isRequired},w.propTypes={providerId:i().string.isRequired,provider:i().shape({id:i().string.isRequired,name:i().string.isRequired,color:i().string,textIcon:i().string}).isRequired,stats:i().shape({connected:i().number,error:i().number,errorCode:i().string,errorTime:i().string}).isRequired,authType:i().string,onToggle:i().func},k.propTypes={providerId:i().string.isRequired,provider:i().shape({id:i().string.isRequired,name:i().string.isRequired,color:i().string,textIcon:i().string,apiType:i().string}).isRequired,stats:i().shape({connected:i().number,error:i().number,errorCode:i().string,errorTime:i().string}).isRequired,authType:i().string,onToggle:i().func},C.propTypes={results:i().shape({mode:i().string,results:i().array,summary:i().shape({total:i().number,passed:i().number,failed:i().number}),error:i().string}).isRequired}},93979:(e,t,s)=>{Promise.resolve().then(s.bind(s,18964))}},e=>{e.O(0,[2574,3862,782,8500,2280,1321,7592,5497,8441,3794,7358],()=>e(e.s=93979)),_N_E=e.O()}]);
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8460],{18964:(e,t,s)=>{"use strict";s.d(t,{default:()=>N});var r=s(95155),a=s(12115),l=s(14051),i=s.n(l),n=s(35497),o=s(57250),d=s(65921),c=s(90620),m=s(88105),p=s(98500),x=s.n(p),u=s(38003);let h={available:{icon:"check_circle",color:"#22c55e",label:"Available"},cooldown:{icon:"schedule",color:"#f59e0b",label:"Cooldown"},unavailable:{icon:"error",color:"#ef4444",label:"Unavailable"},unknown:{icon:"help",color:"#6b7280",label:"Unknown"}};function f(){let[e,t]=(0,a.useState)(null),[s,l]=(0,a.useState)(!0),[i,o]=(0,a.useState)(!1),[c,m]=(0,a.useState)(null),p=(0,a.useRef)(null),x=(0,d.i)(),u=(0,a.useCallback)(async()=>{try{let e=await fetch("/api/models/availability");if(e.ok){let s=await e.json();t(s)}}catch{}finally{l(!1)}},[]);(0,a.useEffect)(()=>{u();let e=setInterval(u,3e4);return()=>clearInterval(e)},[u]),(0,a.useEffect)(()=>{let e=e=>{p.current&&!p.current.contains(e.target)&&o(!1)};return i&&document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[i]);let f=async(e,t)=>{m(`${e}:${t}`);try{(await fetch("/api/models/availability",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clearCooldown",provider:e,model:t})})).ok?(x.success(`Cooldown cleared for ${t}`),await u()):x.error("Failed to clear cooldown")}catch{x.error("Failed to clear cooldown")}finally{m(null)}};if(s)return null;let g=e?.models||[],b=0===(e?.unavailableCount||g.filter(e=>"available"!==e.status).length),y={};return g.forEach(e=>{if("available"===e.status)return;let t=e.provider||"unknown";y[t]||(y[t]=[]),y[t].push(e)}),(0,r.jsx)("div",{className:"relative",ref:p,children:i&&(0,r.jsxs)("div",{className:"absolute top-full right-0 mt-2 w-80 bg-surface border border-border rounded-xl shadow-2xl z-50 overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-bg",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[16px]",style:{color:b?"#22c55e":"#f59e0b"},children:b?"verified":"warning"}),(0,r.jsx)("span",{className:"text-sm font-semibold text-text-main",children:"Model Status"})]}),(0,r.jsx)("button",{onClick:u,className:"p-1 rounded-lg hover:bg-surface text-text-muted hover:text-text-main transition-colors",title:"Refresh",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"refresh"})})]}),(0,r.jsx)("div",{className:"px-4 py-3 max-h-60 overflow-y-auto",children:b?(0,r.jsx)("p",{className:"text-sm text-text-muted text-center py-2",children:"All models are responding normally."}):(0,r.jsx)("div",{className:"flex flex-col gap-2.5",children:Object.entries(y).map(([e,t])=>(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-xs font-semibold text-text-main mb-1.5 capitalize",children:e}),(0,r.jsx)("div",{className:"flex flex-col gap-1",children:t.map(e=>{let t=h[e.status]||h.unknown,s=c===`${e.provider}:${e.model}`;return(0,r.jsxs)("div",{className:"flex items-center justify-between px-2.5 py-1.5 rounded-lg bg-surface/30",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[14px] shrink-0",style:{color:t.color},children:t.icon}),(0,r.jsx)("span",{className:"font-mono text-xs text-text-main truncate",children:e.model})]}),"cooldown"===e.status&&(0,r.jsx)(n.$n,{size:"sm",variant:"ghost",onClick:()=>f(e.provider,e.model),disabled:s,className:"text-[10px] px-1.5! py-0.5! ml-2",children:s?"...":"Clear"})]},`${e.provider}-${e.model}`)})})]},e))})})]})})}var g=s(78559);let b={openai:{title:"Add OpenAI Compatible",type:"openai-compatible",defaultBaseUrl:"https://api.openai.com/v1",namePlaceholder:"My LiteLLM / OpenRouter / vLLM",baseUrlHint:"Base URL ending in /v1 for your OpenAI-compatible API.",modelIdPlaceholder:"e.g. gpt-4, claude-3-opus",errorLabel:"OpenAI Compatible",hasApiType:!0},anthropic:{title:"Add Anthropic Compatible",type:"anthropic-compatible",defaultBaseUrl:"https://api.anthropic.com/v1",namePlaceholder:"My Claude proxy",baseUrlHint:"Base URL ending in /v1. /messages is appended automatically.",modelIdPlaceholder:"e.g. claude-3-opus",errorLabel:"Anthropic Compatible",hasApiType:!1}},y=[{value:"chat",label:"Chat Completions"},{value:"responses",label:"Responses API"}];function v({variant:e,isOpen:t,onClose:s,onCreated:l}){let i=b[e],o=()=>({name:"",...i.hasApiType?{apiType:"chat"}:{},baseUrl:i.defaultBaseUrl}),[d,c]=(0,a.useState)(o),[m,p]=(0,a.useState)(!1),[x,u]=(0,a.useState)(""),[h,f]=(0,a.useState)(""),[j,N]=(0,a.useState)(""),[w,k]=(0,a.useState)(!1),[C,T]=(0,a.useState)(null),A=function(e){try{return["http:","https:"].includes(new URL(e).protocol)}catch{return!1}}(d.baseUrl.trim());(0,a.useEffect)(()=>{t&&(c(o()),u(""),f(""),N(""),T(null))},[t,e]),(0,a.useEffect)(()=>{i.hasApiType&&t&&c(e=>({...e,baseUrl:i.defaultBaseUrl}))},[d.apiType]);let I=async()=>{if(!d.name.trim()||!A)return void u("Enter a valid http:// or https:// base URL");p(!0),u("");try{let e=await fetch("/api/provider-nodes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:d.name.trim(),...i.hasApiType?{apiType:d.apiType}:{},baseUrl:d.baseUrl.trim(),type:i.type})}),t=await e.json();e.ok?(l(t.node),c(o()),f(""),T(null)):u(t.error||"Failed to create provider")}catch(e){(0,g.s)(`Error creating ${i.errorLabel} node:`,e),u("Network error")}finally{p(!1)}},E=async()=>{k(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:d.baseUrl,apiKey:h,type:i.type,modelId:j.trim()||void 0})}),t=await e.json();T(t)}catch{T({valid:!1,error:"Network error"})}finally{k(!1)}};return(0,r.jsx)(n.aF,{isOpen:t,title:i.title,onClose:s,children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsx)(n.pd,{label:"Name",value:d.name,onChange:e=>c({...d,name:e.target.value}),placeholder:i.namePlaceholder,hint:"Friendly label (e.g. Work LiteLLM)."}),i.hasApiType&&(0,r.jsx)(n.l6,{label:"API Type",options:y,value:d.apiType,onChange:e=>c({...d,apiType:e.target.value})}),(0,r.jsx)(n.pd,{label:"Base URL",value:d.baseUrl,onChange:e=>c({...d,baseUrl:e.target.value}),placeholder:i.defaultBaseUrl,hint:i.baseUrlHint}),(0,r.jsx)(n.pd,{label:"API Key (for Check)",type:"password",autoComplete:"off",value:h,onChange:e=>f(e.target.value)}),(0,r.jsx)(n.pd,{label:"Model ID (optional)",value:j,onChange:e=>N(e.target.value),placeholder:i.modelIdPlaceholder,hint:"If the provider has no /models endpoint, enter a model ID to test chat/completions."}),(0,r.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[(0,r.jsx)(n.$n,{onClick:E,disabled:!h||w||!A,variant:"secondary",className:"w-full sm:w-auto",children:w?"Checking...":"Check"}),(()=>{if(!C)return null;let{valid:e,error:t,method:s}=C;return e?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.Ex,{variant:"success",children:"Valid"}),"chat"===s&&(0,r.jsx)("span",{className:"text-sm text-text-muted",children:"(via inference test)"})]}):(0,r.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,r.jsx)(n.Ex,{variant:"error",children:"Invalid"}),t&&(0,r.jsx)("span",{className:"text-sm text-red-500",children:t})]})})()]}),x?(0,r.jsx)("p",{className:"text-sm text-red-500",children:x}):null,(0,r.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row",children:[(0,r.jsx)(n.$n,{onClick:I,fullWidth:!0,disabled:!d.name.trim()||!A||m,children:m?"Creating...":"Create"}),(0,r.jsx)(n.$n,{onClick:s,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}function j(e,t,s){let a=[];if(e>0&&a.push((0,r.jsxs)(n.Ex,{variant:"success",size:"sm",dot:!0,children:[e," Connected"]},"connected")),t>0){let e=s?`${t} Error (${s})`:`${t} Error`;a.push((0,r.jsx)(n.Ex,{variant:"error",size:"sm",dot:!0,children:e},"error"))}return 0===a.length?(0,r.jsx)("span",{className:"text-text-muted",children:"No connections"}):a}function N({initialData:e}){let[t,s]=(0,a.useState)(e?.connections||[]),[l,i]=(0,a.useState)(e?.nodes||[]),[o,p]=(0,a.useState)(!e),[x,h]=(0,a.useState)(!1),[g,b]=(0,a.useState)(!1),[y,j]=(0,a.useState)(!1),[T,A]=(0,a.useState)(!1),[I,E]=(0,a.useState)(null),[$,R]=(0,a.useState)(null),O=(0,d.i)(),S=(0,u.C)(e=>e.query),P=(0,u.C)(e=>e.register),U=(0,u.C)(e=>e.unregister);(0,a.useEffect)(()=>(P("Search providers..."),()=>U()),[P,U]);let _=e=>!S.trim()||e.toLowerCase().includes(S.trim().toLowerCase()),z=(e,t)=>[...e].sort(([e,s],[r,a])=>{let l=s.priority??999,i=a.priority??999;if(l!==i)return l-i;let n=M(e,t),o=M(r,t),d=+(n.connected>0),c=+(o.connected>0);return d!==c?c-d:(s.name||"").localeCompare(a.name||"")}),L=(0,a.useCallback)(async()=>{try{let[e,t]=await Promise.all([fetch("/api/providers"),fetch("/api/provider-nodes")]);if(!e.ok||!t.ok)throw Error("Failed to fetch provider data");let r=await e.json(),a=await t.json();e.ok&&s(r.connections||[]),t.ok&&i(a.nodes||[])}catch(e){O.error("Failed to fetch provider data")}finally{p(!1)}},[O]);(0,a.useEffect)(()=>{e?.connections?p(!1):L()},[e,L]);let M=(e,s)=>{let r=Array.isArray(s)?s:[s],a=t.filter(t=>t.provider===e&&r.includes(t.authType)),l=e=>{let t=Object.entries(e).some(([e,t])=>e.startsWith("modelLock_")&&t&&new Date(t).getTime()>Date.now());return"unavailable"!==e.testStatus||t?e.testStatus:"active"},i=a.filter(e=>{let t=l(e);return"active"===t||"success"===t}).length,n=a.filter(e=>{let t=l(e);return"error"===t||"expired"===t||"unavailable"===t}),o=n.length,d=a.length,c=d>0&&a.every(e=>!1===e.isActive),m=n.sort((e,t)=>new Date(t.lastErrorAt||0)-new Date(e.lastErrorAt||0))[0];return{connected:i,error:o,total:d,errorCode:m?function(e){if(!e)return null;let t=e.lastErrorType;if("runtime_error"===t)return"RUNTIME";if("upstream_auth_error"===t||"auth_missing"===t||"token_refresh_failed"===t||"token_expired"===t)return"AUTH";if("upstream_rate_limited"===t)return"429";if("upstream_unavailable"===t)return"5XX";if("network_error"===t)return"NET";let s=Number(e.errorCode);if(Number.isFinite(s)&&s>=400)return String(s);let r=function(e){if(!e)return null;let t=e.match(/\b([45]\d{2})\b/);return t?t[1]:"ERR"}(e.lastError);if("401"===r||"403"===r)return"AUTH";if(r&&"ERR"!==r)return r;let a=(e.lastError||"").toLowerCase();return a.includes("runtime")||a.includes("not runnable")||a.includes("not installed")?"RUNTIME":a.includes("invalid api key")||a.includes("token invalid")||a.includes("revoked")||a.includes("unauthorized")?"AUTH":"ERR"}(m):null,errorTime:m?.lastErrorAt?function(e){if(!e)return"";let t=Math.floor((Date.now()-new Date(e).getTime())/6e4);if(t<1)return"just now";if(t<60)return`${t}m ago`;let s=Math.floor(t/60);if(s<24)return`${s}h ago`;let r=Math.floor(s/24);return`${r}d ago`}(m.lastErrorAt):null,allDisabled:c}},q=async(e,r,a)=>{let l=Array.isArray(r)?r:[r],i=t=>t.provider===e&&l.includes(t.authType),n=t.filter(i);s(e=>e.map(e=>i(e)?{...e,isActive:a}:e)),await Promise.allSettled(n.map(e=>fetch(`/api/providers/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:a})})))},F=async(e,t=null)=>{if(!I){E("provider"===e?t:e),R(null);try{let s=await fetch("/api/providers/test-batch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:e,providerId:t})}),r=await s.json();if(R(r),r.summary){let{passed:e,failed:t,total:s}=r.summary;0===t?O.success(`All ${s} tests passed`):O.warning(`${e}/${s} passed, ${t} failed`)}}catch(e){R({error:"Test request failed"}),O.error("Provider test failed")}finally{E(null)}}},D=l.filter(e=>"openai-compatible"===e.type).map(e=>({id:e.id,name:e.name||"OpenAI Compatible",color:"#10A37F",textIcon:"OC",apiType:e.apiType})).filter(e=>_(e.name)),B=l.filter(e=>"anthropic-compatible"===e.type).map(e=>({id:e.id,name:e.name||"Anthropic Compatible",color:"#D97757",textIcon:"AC"})).filter(e=>_(e.name)),K=z(Object.entries(c.zN).filter(([,e])=>!e.hidden&&_(e.name)),"oauth"),H=Object.entries(m.IS).filter(([,e])=>!e.hidden&&_(e.name)).sort(([,e],[,t])=>!!t.noAuth-!!e.noAuth),J=z(Object.entries(m.nJ).filter(([,e])=>!e.hidden&&_(e.name)&&(e.serviceKinds??["llm"]).includes("llm")),"freeTier").sort(([,e],[,t])=>!!t.noAuth-!!e.noAuth),W=Object.entries(c.fg).filter(([,e])=>!e.hidden&&(e.serviceKinds??["llm"]).includes("llm")&&_(e.name)).sort(([e,t],[s,r])=>{let a=M(e,"apikey").total>0?0:1,l=M(s,"apikey").total>0?0:1;return a!==l?a-l:(t.name||"").localeCompare(r.name||"")}),Q=!!S.trim(),X=Q||x?W:W.slice(0,20),Z=W.length-20;if(o)return(0,r.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,r.jsx)(n.Qv,{}),(0,r.jsx)(n.Qv,{})]});let V=!S.trim()||K.length>0||H.length>0||J.length>0||W.length>0||D.length>0||B.length>0;return(0,r.jsxs)("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:px-0",children:[!V&&(0,r.jsxs)("div",{className:"text-center py-8 border border-dashed border-border rounded-xl",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[32px] text-text-muted mb-2",children:"search_off"}),(0,r.jsx)("p",{className:"text-text-muted text-sm",children:"No providers match your search"})]}),K.length>0&&(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,r.jsx)("h2",{className:"text-lg sm:text-xl font-semibold flex items-center gap-2 leading-tight",children:"OAuth Providers"}),(0,r.jsxs)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center",children:[(0,r.jsx)(f,{}),(0,r.jsxs)("button",{onClick:()=>F("oauth"),disabled:!!I,className:`flex w-full items-center justify-center gap-1.5 rounded-lg border px-3 py-2 text-xs font-medium transition-colors sm:w-auto sm:py-1.5 ${"oauth"===I?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg border-border text-text-muted hover:text-text-main hover:border-primary/40"}`,title:"Test all OAuth connections","aria-label":"Test all OAuth connections",children:[(0,r.jsx)("span",{className:`material-symbols-outlined text-[14px]${"oauth"===I?" animate-spin":""}`,children:"play_arrow"}),"oauth"===I?"Testing...":"Test All"]})]})]}),(0,r.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4",children:K.map(([e,t])=>(0,r.jsx)(w,{providerId:e,provider:t,stats:M(e,"oauth"),authType:"oauth",onToggle:t=>q(e,"oauth",t)},e))})]}),(H.length>0||J.length>0)&&(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,r.jsx)("h2",{className:"text-lg sm:text-xl font-semibold flex items-center gap-2 leading-tight",children:"Free Tier Providers"}),(0,r.jsxs)("button",{onClick:()=>F("free"),disabled:!!I,className:`flex w-full items-center justify-center gap-1.5 rounded-lg border px-3 py-2 text-xs font-medium transition-colors sm:w-auto sm:py-1.5 ${"free"===I?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg border-border text-text-muted hover:text-text-main hover:border-primary/40"}`,title:"Test all Free connections","aria-label":"Test all Free provider connections",children:[(0,r.jsx)("span",{className:`material-symbols-outlined text-[14px]${"free"===I?" animate-spin":""}`,children:"play_arrow"}),"free"===I?"Testing...":"Test All"]})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4",children:[H.map(([e,t])=>{let s="kiro"===e?["oauth","apikey","api_key"]:"oauth";return(0,r.jsx)(w,{providerId:e,provider:t,stats:M(e,s),authType:"free",onToggle:t=>q(e,s,t)},e)}),J.map(([e,t])=>(0,r.jsx)(k,{providerId:e,provider:t,stats:M(e,"apikey"),authType:"apikey",onToggle:t=>q(e,"apikey",t)},e))]})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("h2",{className:"text-lg sm:text-xl font-semibold flex items-center gap-2 leading-tight",children:"API Key Providers"}),(0,r.jsx)("p",{className:"text-xs text-text-muted mt-1",children:"Built-in providers plus your own OpenAI- or Anthropic-compatible endpoints."})]}),(0,r.jsxs)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center",children:[(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)(n.$n,{size:"sm",icon:"add",onClick:()=>A(e=>!e),className:"w-full sm:w-auto",children:"Add custom provider"}),T&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{type:"button",className:"fixed inset-0 z-40 cursor-default","aria-label":"Close menu",onClick:()=>A(!1)}),(0,r.jsxs)("div",{className:"absolute right-0 top-full z-50 mt-1 w-64 rounded-xl border border-border bg-surface p-1 shadow-xl",children:[(0,r.jsxs)("button",{type:"button",className:"flex w-full items-start gap-2 rounded-lg px-3 py-2.5 text-left text-sm transition-colors hover:bg-bg",onClick:()=>{A(!1),b(!0)},children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[18px] text-primary mt-0.5",children:"api"}),(0,r.jsxs)("span",{children:[(0,r.jsx)("span",{className:"block font-medium",children:"OpenAI compatible"}),(0,r.jsx)("span",{className:"block text-xs text-text-muted",children:"Any OpenAI-style base URL + API key"})]})]}),(0,r.jsxs)("button",{type:"button",className:"flex w-full items-start gap-2 rounded-lg px-3 py-2.5 text-left text-sm transition-colors hover:bg-bg",onClick:()=>{A(!1),j(!0)},children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[18px] text-primary mt-0.5",children:"psychology"}),(0,r.jsxs)("span",{children:[(0,r.jsx)("span",{className:"block font-medium",children:"Anthropic compatible"}),(0,r.jsx)("span",{className:"block text-xs text-text-muted",children:"Messages API base URL + API key"})]})]})]})]})]}),W.length>0&&(0,r.jsxs)("button",{onClick:()=>F("apikey"),disabled:!!I,className:`flex w-full items-center justify-center gap-1.5 rounded-lg border px-3 py-2 text-xs font-medium transition-colors sm:w-auto sm:py-1.5 ${"apikey"===I?"bg-primary/20 border-primary/40 text-primary animate-pulse":"bg-bg border-border text-text-muted hover:text-text-main hover:border-primary/40"}`,title:"Test all API Key connections","aria-label":"Test all API Key connections",children:[(0,r.jsx)("span",{className:`material-symbols-outlined text-[14px]${"apikey"===I?" animate-spin":""}`,children:"play_arrow"}),"apikey"===I?"Testing...":"Test All"]})]})]}),(D.length>0||B.length>0)&&(0,r.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,r.jsx)("p",{className:"text-xs font-semibold uppercase tracking-wider text-text-muted",children:"Your custom providers"}),(0,r.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4",children:[...D,...B].map(e=>(0,r.jsx)(k,{providerId:e.id,provider:e,stats:M(e.id,"apikey"),authType:"compatible",onToggle:t=>q(e.id,"apikey",t)},e.id))})]}),0===D.length&&0===B.length&&0===W.length&&(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center gap-3 py-8 border border-dashed border-border rounded-xl text-text-muted text-sm",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[28px]",children:"extension"}),(0,r.jsx)("p",{children:"No API key providers yet."}),(0,r.jsx)(n.$n,{size:"sm",icon:"add",onClick:()=>b(!0),children:"Add custom provider"})]}),X.length>0&&(0,r.jsxs)("div",{className:"flex flex-col gap-2",children:[(D.length>0||B.length>0)&&(0,r.jsx)("p",{className:"text-xs font-semibold uppercase tracking-wider text-text-muted",children:"Built-in providers"}),(0,r.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4",children:X.map(([e,t])=>(0,r.jsx)(k,{providerId:e,provider:t,stats:M(e,"apikey"),authType:"apikey",onToggle:t=>q(e,"apikey",t)},e))})]}),!Q&&!x&&Z>0&&(0,r.jsxs)("button",{onClick:()=>h(!0),className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-primary/40 px-3 py-2.5 text-sm font-medium text-primary transition-colors hover:border-primary hover:bg-primary/5",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"expand_more"}),"Show all ",W.length," providers"]})]}),(0,r.jsx)(v,{variant:"openai",isOpen:g,onClose:()=>b(!1),onCreated:e=>{i(t=>[...t,e]),b(!1)}}),(0,r.jsx)(v,{variant:"anthropic",isOpen:y,onClose:()=>j(!1),onCreated:e=>{i(t=>[...t,e]),j(!1)}}),$&&(0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex items-start justify-center px-3 pt-[6vh] sm:pt-[10vh]",onClick:()=>R(null),children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),(0,r.jsxs)("div",{className:"relative bg-surface border border-border rounded-xl w-full max-w-[600px] max-h-[86vh] sm:max-h-[80vh] overflow-y-auto shadow-2xl",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"sticky top-0 z-10 flex items-center justify-between px-5 py-3 border-b border-border bg-surface/95 backdrop-blur-sm rounded-t-xl",children:[(0,r.jsx)("h3",{className:"font-semibold",children:"Test Results"}),(0,r.jsx)("button",{onClick:()=>R(null),className:"p-1 rounded-lg hover:bg-bg text-text-muted hover:text-text-main transition-colors","aria-label":"Close test results",children:(0,r.jsx)("span",{className:"material-symbols-outlined text-lg",children:"close"})})]}),(0,r.jsx)("div",{className:"p-5",children:(0,r.jsx)(C,{results:$})})]})]})]})}function w({providerId:e,provider:t,stats:s,authType:a,onToggle:l}){let{connected:i,error:d,errorCode:c,errorTime:m,allDisabled:p}=s,u=!!t.noAuth;return(0,r.jsx)(x(),{href:`/dashboard/providers/${e}`,className:"group min-w-0",children:(0,r.jsx)(n.Zp,{padding:"xs",className:`h-full hover:bg-black/[0.01] dark:hover:bg-white/[0.01] transition-colors cursor-pointer ${p?"opacity-50":""}`,children:(0,r.jsxs)("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,r.jsx)("div",{className:"size-8 shrink-0 rounded-lg flex items-center justify-center",style:{backgroundColor:`${t.color?.length>7?t.color:t.color+"15"}`},children:(0,r.jsx)(o.A,{src:`/providers/${t.id}.png`,alt:t.name,size:30,className:"object-contain rounded-lg max-w-[32px] max-h-[32px]",fallbackText:t.textIcon||t.id.slice(0,2).toUpperCase(),fallbackColor:t.color})}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("h3",{className:"truncate font-semibold",children:t.name}),(0,r.jsx)("div",{className:"flex min-w-0 items-center gap-1.5 text-xs flex-wrap",children:p?(0,r.jsx)(n.Ex,{variant:"default",size:"sm",children:(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"pause_circle"}),"Disabled"]})}):u?(0,r.jsx)(n.Ex,{variant:"success",size:"sm",dot:!0,children:"Ready"}):(0,r.jsxs)(r.Fragment,{children:[j(i,d,c),m&&(0,r.jsx)("span",{className:"text-text-muted",children:m})]})})]})]}),(0,r.jsx)("div",{className:"flex shrink-0 items-center gap-2",children:s.total>0&&(0,r.jsx)("div",{className:"opacity-100 transition-opacity sm:opacity-0 sm:group-hover:opacity-100",onClick:e=>{e.preventDefault(),e.stopPropagation(),l(!!p)},children:(0,r.jsx)(n.lM,{size:"sm",checked:!p,onChange:()=>{},title:p?"Enable provider":"Disable provider"})})})]})})})}function k({providerId:e,provider:t,stats:s,authType:a,onToggle:l}){let{connected:i,error:d,errorCode:c,errorTime:p,allDisabled:u}=s,h=e.startsWith(m.JH),f=e.startsWith(m.DI);return(0,r.jsx)(x(),{href:`/dashboard/providers/${e}`,className:"group min-w-0",children:(0,r.jsx)(n.Zp,{padding:"xs",className:`h-full hover:bg-black/[0.01] dark:hover:bg-white/[0.01] transition-colors cursor-pointer ${u?"opacity-50":""}`,children:(0,r.jsxs)("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,r.jsx)("div",{className:"size-8 shrink-0 rounded-lg flex items-center justify-center",style:{backgroundColor:`${t.color?.length>7?t.color:t.color+"15"}`},children:(0,r.jsx)(o.A,{src:h?"responses"===t.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":f?"/providers/anthropic-m.png":`/providers/${t.id}.png`,alt:t.name,size:30,className:"object-contain rounded-lg max-w-[30px] max-h-[30px]",fallbackText:t.textIcon||t.id.slice(0,2).toUpperCase(),fallbackColor:t.color})}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("h3",{className:"truncate font-semibold",children:t.name}),(0,r.jsx)("div",{className:"flex min-w-0 items-center gap-1.5 text-xs flex-wrap",children:u?(0,r.jsx)(n.Ex,{variant:"default",size:"sm",children:(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"pause_circle"}),"Disabled"]})}):(0,r.jsxs)(r.Fragment,{children:[j(i,d,c),h&&(0,r.jsx)(n.Ex,{variant:"default",size:"sm",children:"responses"===t.apiType?"Responses":"Chat"}),f&&(0,r.jsx)(n.Ex,{variant:"default",size:"sm",children:"Messages"}),p&&(0,r.jsx)("span",{className:"text-text-muted",children:p})]})})]})]}),(0,r.jsx)("div",{className:"flex shrink-0 items-center gap-2",children:s.total>0&&(0,r.jsx)("div",{className:"opacity-100 transition-opacity sm:opacity-0 sm:group-hover:opacity-100",onClick:e=>{e.preventDefault(),e.stopPropagation(),l(!!u)},children:(0,r.jsx)(n.lM,{size:"sm",checked:!u,onChange:()=>{},title:u?"Enable provider":"Disable provider"})})})]})})})}function C({results:e}){if(e.error&&!e.results)return(0,r.jsxs)("div",{className:"text-center py-6",children:[(0,r.jsx)("span",{className:"material-symbols-outlined text-red-500 text-[32px] mb-2 block",children:"error"}),(0,r.jsx)("p",{className:"text-sm text-red-400",children:e.error})]});let{summary:t,mode:s}=e,a=e.results||[];return(0,r.jsxs)("div",{className:"flex min-w-0 flex-col gap-3",children:[t&&(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs mb-1 sm:gap-3",children:[(0,r.jsxs)("span",{className:"text-text-muted",children:[{oauth:"OAuth",free:"Free",apikey:"API Key",provider:"Provider",all:"All"}[s]||s," Test"]}),(0,r.jsxs)("span",{className:"px-2 py-0.5 rounded bg-emerald-500/15 text-emerald-400 font-medium",children:[t.passed," passed"]}),t.failed>0&&(0,r.jsxs)("span",{className:"px-2 py-0.5 rounded bg-red-500/15 text-red-400 font-medium",children:[t.failed," failed"]}),(0,r.jsxs)("span",{className:"text-text-muted sm:ml-auto",children:[t.total," tested"]})]}),a.map((e,t)=>(0,r.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2 rounded-lg bg-black/[0.03] px-3 py-2 text-xs dark:bg-white/[0.03] sm:flex-nowrap",children:[(0,r.jsx)("span",{className:`material-symbols-outlined text-[16px] ${e.valid?"text-emerald-500":"text-red-500"}`,children:e.valid?"check_circle":"error"}),(0,r.jsxs)("div",{className:"min-w-0 flex-[1_1_160px]",children:[(0,r.jsx)("span",{className:"block truncate font-medium sm:inline",children:e.connectionName}),(0,r.jsxs)("span",{className:"block truncate text-text-muted sm:ml-1.5 sm:inline",children:["(",e.provider,")"]})]}),void 0!==e.latencyMs&&(0,r.jsxs)("span",{className:"shrink-0 text-text-muted font-mono tabular-nums",children:[e.latencyMs,"ms"]}),(0,r.jsx)("span",{className:`shrink-0 text-[10px] uppercase font-bold px-1.5 py-0.5 rounded ${e.valid?"bg-emerald-500/15 text-emerald-400":"bg-red-500/15 text-red-400"}`,children:e.valid?"OK":e.diagnosis?.type||"ERROR"})]},e.connectionId||t)),0===a.length&&(0,r.jsx)("div",{className:"text-center py-4 text-text-muted text-sm",children:"No active connections found for this group."})]})}v.propTypes={variant:i().oneOf(["openai","anthropic"]).isRequired,isOpen:i().bool.isRequired,onClose:i().func.isRequired,onCreated:i().func.isRequired},w.propTypes={providerId:i().string.isRequired,provider:i().shape({id:i().string.isRequired,name:i().string.isRequired,color:i().string,textIcon:i().string}).isRequired,stats:i().shape({connected:i().number,error:i().number,errorCode:i().string,errorTime:i().string}).isRequired,authType:i().string,onToggle:i().func},k.propTypes={providerId:i().string.isRequired,provider:i().shape({id:i().string.isRequired,name:i().string.isRequired,color:i().string,textIcon:i().string,apiType:i().string}).isRequired,stats:i().shape({connected:i().number,error:i().number,errorCode:i().string,errorTime:i().string}).isRequired,authType:i().string,onToggle:i().func},C.propTypes={results:i().shape({mode:i().string,results:i().array,summary:i().shape({total:i().number,passed:i().number,failed:i().number}),error:i().string}).isRequired}},93979:(e,t,s)=>{Promise.resolve().then(s.bind(s,18964))}},e=>{e.O(0,[2574,3862,782,8500,594,1321,7592,5497,8441,3794,7358],()=>e(e.s=93979)),_N_E=e.O()}]);
|