n9router 0.4.64 → 0.4.67
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/BUILD_ID +1 -1
- package/app/.next/app-path-routes-manifest.json +25 -25
- package/app/.next/build-manifest.json +2 -2
- package/app/.next/prerender-manifest.json +27 -27
- package/app/.next/server/app/(dashboard)/dashboard/basic-chat/page.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/basic-chat/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/basic-chat/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/combos/page.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/combos/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/console-log/page.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/console-log/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/console-log/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/endpoint/page.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/endpoint/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/media-providers/[kind]/page.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/media-providers/[kind]/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/media-providers/[kind]/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/media-providers/web/page.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/media-providers/web/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/media-providers/web/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/mitm/page.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/mitm/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/mitm/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/page.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/profile/page.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/profile/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/providers/new/page.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/providers/new/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/providers/page.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/providers/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/proxy-pools/page.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/proxy-pools/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/proxy-pools/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/pxpipe/page.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/pxpipe/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/pxpipe/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/quota/page.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/quota/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/quota/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/skills/page.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/skills/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/skills/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/token-saver/page.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/token-saver/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/token-saver/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/translator/page.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/translator/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/usage/page.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/usage/page.js.nft.json +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/_global-error/page.js.nft.json +1 -1
- package/app/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/_global-error.html +1 -1
- package/app/.next/server/app/_global-error.rsc +1 -1
- package/app/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/app/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/app/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/_not-found/page.js +1 -1
- package/app/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/app/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/_not-found.html +1 -1
- package/app/.next/server/app/_not-found.rsc +2 -2
- package/app/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
- package/app/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
- package/app/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/api/antigravity-app/route.js.nft.json +1 -1
- package/app/.next/server/app/api/antigravity-app-v2/route.js.nft.json +1 -1
- package/app/.next/server/app/api/antigravity-ide/route.js.nft.json +1 -1
- package/app/.next/server/app/api/antigravity-targets/route.js.nft.json +1 -1
- package/app/.next/server/app/api/antigravity-tools/import/route.js +1 -1
- package/app/.next/server/app/api/antigravity-tools/import/route.js.nft.json +1 -1
- package/app/.next/server/app/api/antigravity-tools/import-refresh-tokens/route.js +1 -1
- package/app/.next/server/app/api/antigravity-tools/import-refresh-tokens/route.js.nft.json +1 -1
- package/app/.next/server/app/api/auth/login/route.js.nft.json +1 -1
- package/app/.next/server/app/api/auth/logout/route.js.nft.json +1 -1
- package/app/.next/server/app/api/auth/oidc/callback/route.js.nft.json +1 -1
- package/app/.next/server/app/api/auth/oidc/start/route.js.nft.json +1 -1
- package/app/.next/server/app/api/auth/oidc/test/route.js.nft.json +1 -1
- package/app/.next/server/app/api/auth/reset-password/route.js.nft.json +1 -1
- package/app/.next/server/app/api/auth/saml/acs/route.js.nft.json +1 -1
- package/app/.next/server/app/api/auth/saml/metadata/route.js.nft.json +1 -1
- package/app/.next/server/app/api/auth/saml/start/route.js.nft.json +1 -1
- package/app/.next/server/app/api/auth/saml/test/route.js.nft.json +1 -1
- package/app/.next/server/app/api/auth/status/route.js.nft.json +1 -1
- package/app/.next/server/app/api/cli-tools/all-statuses/route.js +5 -5
- package/app/.next/server/app/api/cli-tools/all-statuses/route.js.nft.json +1 -1
- package/app/.next/server/app/api/cli-tools/antigravity-mitm/alias/route.js +1 -1
- package/app/.next/server/app/api/cli-tools/antigravity-mitm/alias/route.js.nft.json +1 -1
- package/app/.next/server/app/api/cli-tools/antigravity-mitm/route.js.nft.json +1 -1
- package/app/.next/server/app/api/cli-tools/claude-settings/route.js +1 -1
- package/app/.next/server/app/api/cli-tools/claude-settings/route.js.nft.json +1 -1
- package/app/.next/server/app/api/cli-tools/cline-settings/route.js +1 -1
- package/app/.next/server/app/api/cli-tools/cline-settings/route.js.nft.json +1 -1
- package/app/.next/server/app/api/cli-tools/codewhale-settings/route.js +1 -1
- package/app/.next/server/app/api/cli-tools/codewhale-settings/route.js.nft.json +1 -1
- package/app/.next/server/app/api/cli-tools/codex-profiles/route.js.nft.json +1 -1
- package/app/.next/server/app/api/cli-tools/codex-settings/route.js.nft.json +1 -1
- package/app/.next/server/app/api/cli-tools/copilot-settings/route.js +2 -2
- package/app/.next/server/app/api/cli-tools/copilot-settings/route.js.nft.json +1 -1
- package/app/.next/server/app/api/cli-tools/cowork-mcp-registry/route.js +2 -2
- package/app/.next/server/app/api/cli-tools/cowork-mcp-registry/route.js.nft.json +1 -1
- package/app/.next/server/app/api/cli-tools/cowork-mcp-tools/route.js +2 -2
- package/app/.next/server/app/api/cli-tools/cowork-mcp-tools/route.js.nft.json +1 -1
- package/app/.next/server/app/api/cli-tools/cowork-settings/route.js +1 -1
- package/app/.next/server/app/api/cli-tools/cowork-settings/route.js.nft.json +1 -1
- package/app/.next/server/app/api/cli-tools/crush-settings/route.js +2 -2
- package/app/.next/server/app/api/cli-tools/crush-settings/route.js.nft.json +1 -1
- package/app/.next/server/app/api/cli-tools/cursor-byok/jobs/[jobId]/events/route.js.nft.json +1 -1
- package/app/.next/server/app/api/cli-tools/cursor-byok/jobs/[jobId]/sudo/route.js.nft.json +1 -1
- package/app/.next/server/app/api/cli-tools/cursor-byok/jobs/route.js.nft.json +1 -1
- package/app/.next/server/app/api/cli-tools/cursor-byok/route.js.nft.json +1 -1
- package/app/.next/server/app/api/cli-tools/deepseek-tui-settings/route.js +3 -3
- package/app/.next/server/app/api/cli-tools/deepseek-tui-settings/route.js.nft.json +1 -1
- package/app/.next/server/app/api/cli-tools/devin-settings/route.js +1 -1
- package/app/.next/server/app/api/cli-tools/devin-settings/route.js.nft.json +1 -1
- package/app/.next/server/app/api/cli-tools/droid-settings/route.js +1 -1
- package/app/.next/server/app/api/cli-tools/droid-settings/route.js.nft.json +1 -1
- package/app/.next/server/app/api/cli-tools/forge-settings/route.js +1 -1
- package/app/.next/server/app/api/cli-tools/forge-settings/route.js.nft.json +1 -1
- package/app/.next/server/app/api/cli-tools/grok-build-settings/route.js +2 -2
- package/app/.next/server/app/api/cli-tools/grok-build-settings/route.js.nft.json +1 -1
- package/app/.next/server/app/api/cli-tools/hermes-profiles/route.js.nft.json +1 -1
- package/app/.next/server/app/api/cli-tools/hermes-settings/route.js +2 -2
- package/app/.next/server/app/api/cli-tools/hermes-settings/route.js.nft.json +1 -1
- package/app/.next/server/app/api/cli-tools/jcode-settings/route.js +1 -1
- package/app/.next/server/app/api/cli-tools/jcode-settings/route.js.nft.json +1 -1
- package/app/.next/server/app/api/cli-tools/kilo-settings/route.js +2 -2
- package/app/.next/server/app/api/cli-tools/kilo-settings/route.js.nft.json +1 -1
- package/app/.next/server/app/api/cli-tools/omp-settings/route.js +3 -3
- package/app/.next/server/app/api/cli-tools/omp-settings/route.js.nft.json +1 -1
- package/app/.next/server/app/api/cli-tools/openclaw-settings/route.js +2 -2
- package/app/.next/server/app/api/cli-tools/openclaw-settings/route.js.nft.json +1 -1
- package/app/.next/server/app/api/cli-tools/opencode-settings/route.js +1 -1
- package/app/.next/server/app/api/cli-tools/opencode-settings/route.js.nft.json +1 -1
- package/app/.next/server/app/api/cli-tools/pi-settings/route.js +2 -2
- package/app/.next/server/app/api/cli-tools/pi-settings/route.js.nft.json +1 -1
- package/app/.next/server/app/api/cli-tools/smelt-settings/route.js +2 -2
- package/app/.next/server/app/api/cli-tools/smelt-settings/route.js.nft.json +1 -1
- package/app/.next/server/app/api/combos/[id]/route.js.nft.json +1 -1
- package/app/.next/server/app/api/combos/presets/route.js.nft.json +1 -1
- package/app/.next/server/app/api/combos/route.js.nft.json +1 -1
- package/app/.next/server/app/api/donate/route.js.nft.json +1 -1
- package/app/.next/server/app/api/headroom/extras/route.js.nft.json +1 -1
- package/app/.next/server/app/api/headroom/proxy/[...path]/route.js.nft.json +1 -1
- package/app/.next/server/app/api/headroom/restart/route.js.nft.json +1 -1
- package/app/.next/server/app/api/headroom/start/route.js.nft.json +1 -1
- package/app/.next/server/app/api/headroom/status/route.js.nft.json +1 -1
- package/app/.next/server/app/api/headroom/stop/route.js.nft.json +1 -1
- package/app/.next/server/app/api/health/route.js.nft.json +1 -1
- package/app/.next/server/app/api/init/route.js.nft.json +1 -1
- package/app/.next/server/app/api/internal/account-health/route.js.nft.json +1 -1
- package/app/.next/server/app/api/internal/request-detail/route.js +1 -1
- package/app/.next/server/app/api/internal/request-detail/route.js.nft.json +1 -1
- package/app/.next/server/app/api/internal/usage/route.js +1 -1
- package/app/.next/server/app/api/internal/usage/route.js.nft.json +1 -1
- package/app/.next/server/app/api/keys/[id]/reset-usage/route.js +1 -1
- package/app/.next/server/app/api/keys/[id]/reset-usage/route.js.nft.json +1 -1
- package/app/.next/server/app/api/keys/[id]/route.js +1 -1
- package/app/.next/server/app/api/keys/[id]/route.js.nft.json +1 -1
- package/app/.next/server/app/api/keys/[id]/usage/route.js +1 -1
- package/app/.next/server/app/api/keys/[id]/usage/route.js.nft.json +1 -1
- package/app/.next/server/app/api/keys/route.js.nft.json +1 -1
- package/app/.next/server/app/api/locale/route.js.nft.json +1 -1
- package/app/.next/server/app/api/mcp/[plugin]/message/route.js.nft.json +1 -1
- package/app/.next/server/app/api/mcp/[plugin]/sse/route.js.nft.json +1 -1
- package/app/.next/server/app/api/media-providers/tts/deepgram/voices/route.js.nft.json +1 -1
- package/app/.next/server/app/api/media-providers/tts/elevenlabs/voices/route.js.nft.json +1 -1
- package/app/.next/server/app/api/media-providers/tts/inworld/voices/route.js.nft.json +1 -1
- package/app/.next/server/app/api/media-providers/tts/minimax/voices/route.js.nft.json +1 -1
- package/app/.next/server/app/api/media-providers/tts/voices/route.js.nft.json +1 -1
- package/app/.next/server/app/api/models/alias/route.js.nft.json +1 -1
- package/app/.next/server/app/api/models/availability/route.js.nft.json +1 -1
- package/app/.next/server/app/api/models/catalog-sync/route.js.nft.json +1 -1
- package/app/.next/server/app/api/models/custom/route.js.nft.json +1 -1
- package/app/.next/server/app/api/models/disabled/route.js.nft.json +1 -1
- package/app/.next/server/app/api/models/route.js.nft.json +1 -1
- package/app/.next/server/app/api/models/test/route.js.nft.json +1 -1
- package/app/.next/server/app/api/oauth/[provider]/[action]/route.js +1 -1
- package/app/.next/server/app/api/oauth/[provider]/[action]/route.js.nft.json +1 -1
- package/app/.next/server/app/api/oauth/codex/bulk-import/route.js +1 -1
- package/app/.next/server/app/api/oauth/codex/bulk-import/route.js.nft.json +1 -1
- package/app/.next/server/app/api/oauth/codex/import-token/route.js +1 -1
- package/app/.next/server/app/api/oauth/codex/import-token/route.js.nft.json +1 -1
- package/app/.next/server/app/api/oauth/commandcode/auto-import/route.js.nft.json +1 -1
- package/app/.next/server/app/api/oauth/cursor/auto-import/route.js +2 -2
- package/app/.next/server/app/api/oauth/cursor/auto-import/route.js.nft.json +1 -1
- package/app/.next/server/app/api/oauth/cursor/import/route.js.nft.json +1 -1
- package/app/.next/server/app/api/oauth/gitlab/pat/route.js.nft.json +1 -1
- package/app/.next/server/app/api/oauth/grok-cli/bulk-import/route.js.nft.json +1 -1
- package/app/.next/server/app/api/oauth/iflow/cookie/route.js.nft.json +1 -1
- package/app/.next/server/app/api/oauth/kiro/api-key/route.js.nft.json +1 -1
- package/app/.next/server/app/api/oauth/kiro/auto-import/route.js.nft.json +1 -1
- package/app/.next/server/app/api/oauth/kiro/import/route.js.nft.json +1 -1
- package/app/.next/server/app/api/oauth/kiro/import-cli-proxy/route.js.nft.json +1 -1
- package/app/.next/server/app/api/oauth/kiro/social-authorize/route.js.nft.json +1 -1
- package/app/.next/server/app/api/oauth/kiro/social-exchange/route.js.nft.json +1 -1
- package/app/.next/server/app/api/oauth/xiaomi-mimo/api-key/route.js.nft.json +1 -1
- package/app/.next/server/app/api/oauth/xiaomi-mimo/auto-import/route.js +2 -2
- package/app/.next/server/app/api/oauth/xiaomi-mimo/auto-import/route.js.nft.json +1 -1
- package/app/.next/server/app/api/oauth/xiaomi-mimo/login/start/route.js +1 -1
- package/app/.next/server/app/api/oauth/xiaomi-mimo/login/start/route.js.nft.json +1 -1
- package/app/.next/server/app/api/oauth/xiaomi-mimo/login/status/route.js +1 -1
- package/app/.next/server/app/api/oauth/xiaomi-mimo/login/status/route.js.nft.json +1 -1
- package/app/.next/server/app/api/oauth/zed/auto-import/route.js.nft.json +1 -1
- package/app/.next/server/app/api/oauth/zed/import/route.js +1 -1
- package/app/.next/server/app/api/oauth/zed/import/route.js.nft.json +1 -1
- package/app/.next/server/app/api/pricing/route.js.nft.json +1 -1
- package/app/.next/server/app/api/provider-nodes/[id]/route.js.nft.json +1 -1
- package/app/.next/server/app/api/provider-nodes/route.js.nft.json +1 -1
- package/app/.next/server/app/api/provider-nodes/validate/route.js.nft.json +1 -1
- package/app/.next/server/app/api/providers/[id]/models/route.js +1 -1
- package/app/.next/server/app/api/providers/[id]/models/route.js.nft.json +1 -1
- package/app/.next/server/app/api/providers/[id]/overrides/route.js.nft.json +1 -1
- package/app/.next/server/app/api/providers/[id]/route.js.nft.json +1 -1
- package/app/.next/server/app/api/providers/[id]/test/route.js +1 -1
- package/app/.next/server/app/api/providers/[id]/test/route.js.nft.json +1 -1
- package/app/.next/server/app/api/providers/[id]/test-models/route.js.nft.json +1 -1
- package/app/.next/server/app/api/providers/client/route.js +1 -1
- package/app/.next/server/app/api/providers/client/route.js.nft.json +1 -1
- package/app/.next/server/app/api/providers/kilo/free-models/route.js.nft.json +1 -1
- package/app/.next/server/app/api/providers/route.js.nft.json +1 -1
- package/app/.next/server/app/api/providers/suggested-models/route.js.nft.json +1 -1
- package/app/.next/server/app/api/providers/test-batch/route.js +1 -1
- package/app/.next/server/app/api/providers/test-batch/route.js.nft.json +1 -1
- package/app/.next/server/app/api/providers/validate/route.js +1 -1
- package/app/.next/server/app/api/providers/validate/route.js.nft.json +1 -1
- package/app/.next/server/app/api/providers/web-login/route.js +1 -1
- package/app/.next/server/app/api/providers/web-login/route.js.nft.json +1 -1
- package/app/.next/server/app/api/proxy-pools/[id]/route.js.nft.json +1 -1
- package/app/.next/server/app/api/proxy-pools/[id]/test/route.js +1 -1
- package/app/.next/server/app/api/proxy-pools/[id]/test/route.js.nft.json +1 -1
- package/app/.next/server/app/api/proxy-pools/cloudflare-deploy/route.js.nft.json +1 -1
- package/app/.next/server/app/api/proxy-pools/deno-deploy/route.js.nft.json +1 -1
- package/app/.next/server/app/api/proxy-pools/netlify-deploy/route.js.nft.json +1 -1
- package/app/.next/server/app/api/proxy-pools/route.js.nft.json +1 -1
- package/app/.next/server/app/api/proxy-pools/vercel-deploy/route.js.nft.json +1 -1
- package/app/.next/server/app/api/pxpipe/health/route.js.nft.json +1 -1
- package/app/.next/server/app/api/pxpipe/install/route.js.nft.json +1 -1
- package/app/.next/server/app/api/pxpipe/logs/route.js.nft.json +1 -1
- package/app/.next/server/app/api/pxpipe/restart/route.js.nft.json +1 -1
- package/app/.next/server/app/api/pxpipe/start/route.js.nft.json +1 -1
- package/app/.next/server/app/api/pxpipe/stats/route.js.nft.json +1 -1
- package/app/.next/server/app/api/pxpipe/status/route.js.nft.json +1 -1
- package/app/.next/server/app/api/pxpipe/stop/route.js.nft.json +1 -1
- package/app/.next/server/app/api/settings/database/route.js.nft.json +1 -1
- package/app/.next/server/app/api/settings/database/selective/route.js.nft.json +1 -1
- package/app/.next/server/app/api/settings/proxy-test/route.js +1 -1
- package/app/.next/server/app/api/settings/proxy-test/route.js.nft.json +1 -1
- package/app/.next/server/app/api/settings/require-login/route.js.nft.json +1 -1
- package/app/.next/server/app/api/settings/route.js +1 -1
- package/app/.next/server/app/api/settings/route.js.nft.json +1 -1
- package/app/.next/server/app/api/shutdown/route.js.nft.json +1 -1
- package/app/.next/server/app/api/tags/route.js.nft.json +1 -1
- package/app/.next/server/app/api/translator/console-logs/route.js.nft.json +1 -1
- package/app/.next/server/app/api/translator/console-logs/stream/route.js.nft.json +1 -1
- package/app/.next/server/app/api/translator/load/route.js.nft.json +1 -1
- package/app/.next/server/app/api/translator/save/route.js.nft.json +1 -1
- package/app/.next/server/app/api/translator/send/route.js +1 -1
- package/app/.next/server/app/api/translator/send/route.js.nft.json +1 -1
- package/app/.next/server/app/api/translator/translate/route.js +1 -1
- package/app/.next/server/app/api/translator/translate/route.js.nft.json +1 -1
- package/app/.next/server/app/api/tunnel/disable/route.js +1 -1
- package/app/.next/server/app/api/tunnel/disable/route.js.nft.json +1 -1
- package/app/.next/server/app/api/tunnel/enable/route.js +1 -1
- package/app/.next/server/app/api/tunnel/enable/route.js.nft.json +1 -1
- package/app/.next/server/app/api/tunnel/status/route.js.nft.json +1 -1
- package/app/.next/server/app/api/tunnel/tailscale-check/route.js.nft.json +1 -1
- package/app/.next/server/app/api/tunnel/tailscale-disable/route.js +1 -1
- package/app/.next/server/app/api/tunnel/tailscale-disable/route.js.nft.json +1 -1
- package/app/.next/server/app/api/tunnel/tailscale-enable/route.js +1 -1
- package/app/.next/server/app/api/tunnel/tailscale-enable/route.js.nft.json +1 -1
- package/app/.next/server/app/api/tunnel/tailscale-install/route.js +2 -2
- package/app/.next/server/app/api/tunnel/tailscale-install/route.js.nft.json +1 -1
- package/app/.next/server/app/api/usage/[connectionId]/claude-reset/route.js +1 -1
- package/app/.next/server/app/api/usage/[connectionId]/claude-reset/route.js.nft.json +1 -1
- package/app/.next/server/app/api/usage/[connectionId]/codex-reset-credits/route.js +1 -1
- package/app/.next/server/app/api/usage/[connectionId]/codex-reset-credits/route.js.nft.json +1 -1
- package/app/.next/server/app/api/usage/[connectionId]/route.js +1 -1
- package/app/.next/server/app/api/usage/[connectionId]/route.js.nft.json +1 -1
- package/app/.next/server/app/api/usage/chart/route.js +1 -1
- package/app/.next/server/app/api/usage/chart/route.js.nft.json +1 -1
- package/app/.next/server/app/api/usage/history/route.js +1 -1
- package/app/.next/server/app/api/usage/history/route.js.nft.json +1 -1
- package/app/.next/server/app/api/usage/logs/route.js +1 -1
- package/app/.next/server/app/api/usage/logs/route.js.nft.json +1 -1
- package/app/.next/server/app/api/usage/providers/route.js.nft.json +1 -1
- package/app/.next/server/app/api/usage/report/route.js +1 -1
- package/app/.next/server/app/api/usage/report/route.js.nft.json +1 -1
- package/app/.next/server/app/api/usage/request-details/route.js +1 -1
- package/app/.next/server/app/api/usage/request-details/route.js.nft.json +1 -1
- package/app/.next/server/app/api/usage/request-logs/route.js +1 -1
- package/app/.next/server/app/api/usage/request-logs/route.js.nft.json +1 -1
- package/app/.next/server/app/api/usage/stats/route.js +1 -1
- package/app/.next/server/app/api/usage/stats/route.js.nft.json +1 -1
- package/app/.next/server/app/api/usage/stream/route.js +1 -1
- package/app/.next/server/app/api/usage/stream/route.js.nft.json +1 -1
- package/app/.next/server/app/api/v1/api/chat/route.js +1 -1
- package/app/.next/server/app/api/v1/api/chat/route.js.nft.json +1 -1
- package/app/.next/server/app/api/v1/audio/speech/route.js +1 -1
- package/app/.next/server/app/api/v1/audio/speech/route.js.nft.json +1 -1
- package/app/.next/server/app/api/v1/audio/transcriptions/route.js +1 -1
- package/app/.next/server/app/api/v1/audio/transcriptions/route.js.nft.json +1 -1
- package/app/.next/server/app/api/v1/audio/voices/route.js.nft.json +1 -1
- package/app/.next/server/app/api/v1/chat/completions/route.js +1 -1
- package/app/.next/server/app/api/v1/chat/completions/route.js.nft.json +1 -1
- package/app/.next/server/app/api/v1/embeddings/route.js +1 -1
- package/app/.next/server/app/api/v1/embeddings/route.js.nft.json +1 -1
- package/app/.next/server/app/api/v1/images/generations/route.js +1 -1
- package/app/.next/server/app/api/v1/images/generations/route.js.nft.json +1 -1
- package/app/.next/server/app/api/v1/messages/count_tokens/route.js.nft.json +1 -1
- package/app/.next/server/app/api/v1/messages/route.js +1 -1
- package/app/.next/server/app/api/v1/messages/route.js.nft.json +1 -1
- package/app/.next/server/app/api/v1/models/[...model]/route.js +1 -1
- package/app/.next/server/app/api/v1/models/[...model]/route.js.nft.json +1 -1
- package/app/.next/server/app/api/v1/models/info/route.js.nft.json +1 -1
- package/app/.next/server/app/api/v1/models/route.js +1 -1
- package/app/.next/server/app/api/v1/models/route.js.nft.json +1 -1
- package/app/.next/server/app/api/v1/responses/compact/route.js +1 -1
- package/app/.next/server/app/api/v1/responses/compact/route.js.nft.json +1 -1
- package/app/.next/server/app/api/v1/responses/route.js +1 -1
- package/app/.next/server/app/api/v1/responses/route.js.nft.json +1 -1
- package/app/.next/server/app/api/v1/route.js +1 -1
- package/app/.next/server/app/api/v1/route.js.nft.json +1 -1
- package/app/.next/server/app/api/v1/search/route.js +1 -1
- package/app/.next/server/app/api/v1/search/route.js.nft.json +1 -1
- package/app/.next/server/app/api/v1/systemone/route.js +1 -1
- package/app/.next/server/app/api/v1/systemone/route.js.nft.json +1 -1
- package/app/.next/server/app/api/v1/videos/[id]/route.js +1 -1
- package/app/.next/server/app/api/v1/videos/[id]/route.js.nft.json +1 -1
- package/app/.next/server/app/api/v1/videos/edits/route.js +1 -1
- package/app/.next/server/app/api/v1/videos/edits/route.js.nft.json +1 -1
- package/app/.next/server/app/api/v1/videos/extensions/route.js +1 -1
- package/app/.next/server/app/api/v1/videos/extensions/route.js.nft.json +1 -1
- package/app/.next/server/app/api/v1/videos/generations/route.js +1 -1
- package/app/.next/server/app/api/v1/videos/generations/route.js.nft.json +1 -1
- package/app/.next/server/app/api/v1/web/fetch/route.js +1 -1
- package/app/.next/server/app/api/v1/web/fetch/route.js.nft.json +1 -1
- package/app/.next/server/app/api/v1beta/models/[...path]/route.js +1 -1
- package/app/.next/server/app/api/v1beta/models/[...path]/route.js.nft.json +1 -1
- package/app/.next/server/app/api/v1beta/models/route.js.nft.json +1 -1
- package/app/.next/server/app/api/version/route.js +1 -1
- package/app/.next/server/app/api/version/route.js.nft.json +1 -1
- package/app/.next/server/app/api/version/shutdown/route.js.nft.json +1 -1
- package/app/.next/server/app/api/version/update/route.js.nft.json +1 -1
- package/app/.next/server/app/callback/page.js +1 -1
- package/app/.next/server/app/callback/page.js.nft.json +1 -1
- package/app/.next/server/app/callback/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/callback.html +1 -1
- package/app/.next/server/app/callback.rsc +2 -2
- package/app/.next/server/app/callback.segments/_full.segment.rsc +2 -2
- package/app/.next/server/app/callback.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/callback.segments/callback/__PAGE__.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/basic-chat.html +1 -1
- package/app/.next/server/app/dashboard/basic-chat.rsc +2 -2
- package/app/.next/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard/basic-chat/__PAGE__.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/basic-chat.segments/_full.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/basic-chat.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/cli-tools.html +1 -1
- package/app/.next/server/app/dashboard/cli-tools.rsc +3 -3
- package/app/.next/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools/__PAGE__.segment.rsc +3 -3
- package/app/.next/server/app/dashboard/cli-tools.segments/_full.segment.rsc +3 -3
- package/app/.next/server/app/dashboard/cli-tools.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/combos.html +1 -1
- package/app/.next/server/app/dashboard/combos.rsc +2 -2
- package/app/.next/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos/__PAGE__.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/combos.segments/_full.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/combos.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/endpoint.html +1 -1
- package/app/.next/server/app/dashboard/endpoint.rsc +2 -2
- package/app/.next/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint/__PAGE__.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/endpoint.segments/_full.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/endpoint.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/media-providers/web.html +1 -1
- package/app/.next/server/app/dashboard/media-providers/web.rsc +2 -2
- package/app/.next/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers/web/__PAGE__.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/media-providers/web.segments/_full.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/media-providers/web.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/mitm.html +1 -1
- package/app/.next/server/app/dashboard/mitm.rsc +3 -3
- package/app/.next/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm/__PAGE__.segment.rsc +3 -3
- package/app/.next/server/app/dashboard/mitm.segments/_full.segment.rsc +3 -3
- package/app/.next/server/app/dashboard/mitm.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/profile.html +1 -1
- package/app/.next/server/app/dashboard/profile.rsc +2 -2
- package/app/.next/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile/__PAGE__.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/profile.segments/_full.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/profile.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/providers/new.html +1 -1
- package/app/.next/server/app/dashboard/providers/new.rsc +2 -2
- package/app/.next/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new/__PAGE__.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/providers/new.segments/_full.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/providers/new.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/providers.html +1 -1
- package/app/.next/server/app/dashboard/providers.rsc +2 -2
- package/app/.next/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers/__PAGE__.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/providers.segments/_full.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/providers.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/proxy-pools.html +1 -1
- package/app/.next/server/app/dashboard/proxy-pools.rsc +2 -2
- package/app/.next/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools/__PAGE__.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/proxy-pools.segments/_full.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/proxy-pools.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/pxpipe.html +1 -1
- package/app/.next/server/app/dashboard/pxpipe.rsc +2 -2
- package/app/.next/server/app/dashboard/pxpipe.segments/!KGRhc2hib2FyZCk/dashboard/pxpipe/__PAGE__.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/pxpipe.segments/_full.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/pxpipe.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/quota.html +1 -1
- package/app/.next/server/app/dashboard/quota.rsc +2 -2
- package/app/.next/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota/__PAGE__.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/quota.segments/_full.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/quota.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/settings/pricing/page.js +1 -1
- package/app/.next/server/app/dashboard/settings/pricing/page.js.nft.json +1 -1
- package/app/.next/server/app/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/dashboard/settings/pricing.html +1 -1
- package/app/.next/server/app/dashboard/settings/pricing.rsc +2 -2
- package/app/.next/server/app/dashboard/settings/pricing.segments/_full.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/settings/pricing.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing/__PAGE__.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/skills.html +1 -1
- package/app/.next/server/app/dashboard/skills.rsc +2 -2
- package/app/.next/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk/dashboard/skills/__PAGE__.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/skills.segments/_full.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/skills.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/token-saver.html +1 -1
- package/app/.next/server/app/dashboard/token-saver.rsc +2 -2
- package/app/.next/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk/dashboard/token-saver/__PAGE__.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/token-saver.segments/_full.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/token-saver.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/translator.html +1 -1
- package/app/.next/server/app/dashboard/translator.rsc +2 -2
- package/app/.next/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator/__PAGE__.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/translator.segments/_full.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/translator.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/usage.html +1 -1
- package/app/.next/server/app/dashboard/usage.rsc +2 -2
- package/app/.next/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage/__PAGE__.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/usage.segments/_full.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/usage.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/dashboard.html +1 -1
- package/app/.next/server/app/dashboard.rsc +2 -2
- package/app/.next/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard/__PAGE__.segment.rsc +2 -2
- package/app/.next/server/app/dashboard.segments/_full.segment.rsc +2 -2
- package/app/.next/server/app/dashboard.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/favicon.ico/route.js.nft.json +1 -1
- package/app/.next/server/app/index.html +1 -1
- package/app/.next/server/app/index.rsc +2 -2
- package/app/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
- package/app/.next/server/app/index.segments/_full.segment.rsc +2 -2
- package/app/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/landing/page.js +1 -1
- package/app/.next/server/app/landing/page.js.nft.json +1 -1
- package/app/.next/server/app/landing/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/landing.html +1 -1
- package/app/.next/server/app/landing.rsc +2 -2
- package/app/.next/server/app/landing.segments/_full.segment.rsc +2 -2
- package/app/.next/server/app/landing.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/landing.segments/landing/__PAGE__.segment.rsc +2 -2
- package/app/.next/server/app/login/page.js +1 -1
- package/app/.next/server/app/login/page.js.nft.json +1 -1
- package/app/.next/server/app/login/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/login.html +1 -1
- package/app/.next/server/app/login.rsc +2 -2
- package/app/.next/server/app/login.segments/_full.segment.rsc +2 -2
- package/app/.next/server/app/login.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/login.segments/login/__PAGE__.segment.rsc +2 -2
- package/app/.next/server/app/manifest.webmanifest/route.js.nft.json +1 -1
- package/app/.next/server/app/page.js +1 -1
- package/app/.next/server/app/page.js.nft.json +1 -1
- package/app/.next/server/app/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app-paths-manifest.json +25 -25
- package/app/.next/server/chunks/1051.js +1 -1
- package/app/.next/server/chunks/1297.js +1 -1
- package/app/.next/server/chunks/1350.js +1 -1
- package/app/.next/server/chunks/1505.js +1 -1
- package/app/.next/server/chunks/3481.js +2 -2
- package/app/.next/server/chunks/3759.js +1 -1
- package/app/.next/server/chunks/4334.js +1 -1
- package/app/.next/server/chunks/5330.js +1 -1
- package/app/.next/server/chunks/5520.js +1 -1
- package/app/.next/server/chunks/574.js +1 -1
- package/app/.next/server/chunks/6297.js +1 -1
- package/app/.next/server/chunks/7373.js +2 -2
- package/app/.next/server/chunks/7525.js +1 -1
- package/app/.next/server/chunks/7774.js +2 -2
- package/app/.next/server/chunks/7995.js +2 -2
- package/app/.next/server/chunks/8271.js +1 -1
- package/app/.next/server/chunks/8467.js +1 -1
- package/app/.next/server/chunks/869.js +1 -1
- package/app/.next/server/chunks/9819.js +4 -2
- package/app/.next/server/chunks/9889.js +1 -1
- package/app/.next/server/middleware-build-manifest.js +1 -1
- package/app/.next/server/middleware.js +1 -1
- package/app/.next/server/pages/404.html +1 -1
- package/app/.next/server/pages/500.html +1 -1
- package/app/.next/server/preview-props.json +3 -3
- package/app/.next/server/server-reference-manifest.js +1 -1
- package/app/.next/server/server-reference-manifest.json +1 -1
- package/app/.next/static/chunks/{1321-069b648d8a5aed07.js → 1321-12578fdb4d77640c.js} +1 -1
- package/app/.next/static/chunks/{2968-965b2726b4542656.js → 2968-1aad83a8ce4d997c.js} +9 -7
- package/app/.next/static/chunks/app/(dashboard)/dashboard/media-providers/[kind]/[id]/{page-50da140812e2c8ab.js → page-118c90b3a74f35e8.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/[id]/{page-7f4cf15089a43031.js → page-310c475a29336f25.js} +1 -1
- package/app/open-sse/handlers/systemoneCore.js +4 -3
- package/app/open-sse/translator/formats/openai.js +3 -2
- package/app/package.json +1 -1
- package/app/src/mitm/logger.js +1 -1
- package/app/src/mitm/server.js +65 -16
- package/app/src/mitm/tokenPool.js +52 -4
- package/app/src/mitm/tokenSwapRetry.js +19 -1
- package/app/src/mitm/unsupportedModels.js +70 -0
- package/package.json +1 -1
- /package/app/.next/static/{XH_XuO6k-mrc3KL4kNuIo → jSYt6_QzXyGYSEDxARDoM}/_buildManifest.js +0 -0
- /package/app/.next/static/{XH_XuO6k-mrc3KL4kNuIo → jSYt6_QzXyGYSEDxARDoM}/_ssgManifest.js +0 -0
|
@@ -41,7 +41,7 @@ devin --version`}},opendesign:{id:"opendesign",name:"OpenDesign",image:"/provide
|
|
|
41
41
|
gemini extensions install https://github.com/manalkaff/opendesign
|
|
42
42
|
|
|
43
43
|
# OpenCode
|
|
44
|
-
# Fetch and follow .opencode/INSTALL.md from the repo`}},pi:{id:"pi",name:"Pi (pi-coding-agent)",image:"/providers/pi.svg",color:"#6366F1",description:"Pi coding agent — minimal, extensible agent harness (pi.dev)",configType:"custom",docsUrl:"https://pi.dev",notes:[{type:"info",text:"Pi uses ~/.pi/agent/models.json. 9Router is configured under providers.9router as an OpenAI-compatible endpoint."}]},omp:{id:"omp",name:"Oh My Pi",image:"/providers/omp.png",color:"#EC4899",description:"Oh My Pi terminal AI agent with auto-discovery support",configType:"custom",docsUrl:"https://github.com/can1357/oh-my-pi",notes:[{type:"info",text:"Oh My Pi uses ~/.omp/agent/models.yml and agent.db. 9Router is configured with proxy discovery so all models appear automatically under /model."}]},crush:{id:"crush",name:"Crush",image:"/providers/crush.png",color:"#FB923C",description:"Charm Crush terminal AI coding agent",configType:"custom",docsUrl:"https://github.com/charmbracelet/crush",notes:[{type:"info",text:"Crush uses ~/.config/crush/crush.json. 9Router registers as an openai-compat provider."}]},forge:{id:"forge",name:"ForgeCode",image:"/providers/forge.png",color:"#EAB308",description:"Antinomy HQ ForgeCode agent harness",configType:"custom",docsUrl:"https://github.com/antinomyhq/forge",notes:[{type:"info",text:"ForgeCode uses ~/.forge/config.toml. 9Router updates the [openai] section with your baseUrl, apiKey, and model."}]},smelt:{id:"smelt",name:"Smelt",image:"/providers/smelt.svg",color:"#EF4444",description:"Smelt terminal AI coding assistant",configType:"custom",docsUrl:"https://github.com/leonardcser/smelt",notes:[{type:"info",text:"Smelt uses ~/.smelt/config.json for OpenAI-compatible endpoint configuration."}]},codewhale:{id:"codewhale",name:"CodeWhale",image:"/providers/codewhale.svg",color:"#4F46E5",description:"CodeWhale terminal coding agent (successor to DeepSeek TUI)",configType:"custom",docsUrl:"https://github.com/Hmbown/CodeWhale",notes:[{type:"info",text:"CodeWhale uses ~/.codewhale/config.toml. 9Router configures the [openai] provider with your base_url, api_key, and model."}]}}},22968:(e,t,s)=>{s.d(t,{Tk:()=>O,aG:()=>er,Ah:()=>U,Q6:()=>el,Mz:()=>ep,lF:()=>eo,a7:()=>W,ZM:()=>D,WE:()=>e$,E_:()=>ej,RF:()=>q,mW:()=>ed,c9:()=>ei,gY:()=>eJ,tA:()=>eO,kn:()=>eP,yZ:()=>z,qO:()=>et,xm:()=>eG});var a=s(95155),l=s(12115),r=s(35497),i=s(5772),n=s(90620);function o({storageKey:e,changeEvent:t,itemField:s,normalize:a=e=>e,defaultName:l=e=>e}){let r=()=>{try{let t=JSON.parse(window.localStorage.getItem(e)||"[]");if(!Array.isArray(t))return[];return t.filter(e=>e?.name&&e?.[s])}catch{return[]}},i=s=>{window.localStorage.setItem(e,JSON.stringify(s)),window.dispatchEvent(new CustomEvent(t))};return{read:r,subscribe:e=>(window.addEventListener(t,e),()=>window.removeEventListener(t,e)),upsert:(e,t)=>{let n=a(e);if(!n)return null;let o=r(),d=o.find(e=>a(e[s])===n);if(d&&!t)return d.name;let c=(t||l(n)).trim();return c?(i([...o.filter(e=>e.name!==c&&a(e[s])!==n),{name:c,[s]:n}].sort((e,t)=>e.name.localeCompare(t.name))),c):null},remove:e=>i(r().filter(t=>t.name!==e))}}let d=e=>(e||"").replace(/\/+$/,""),c=o({storageKey:"9router.cliToolEndpointPresets",changeEvent:"9router:endpoint-presets-changed",itemField:"baseUrl",normalize:d,defaultName:e=>{try{return new URL(e).host}catch{return e}}}),m=o({storageKey:"9router.cliToolApiKeyPresets",changeEvent:"9router:api-key-presets-changed",itemField:"key"}),x=c.read,u=c.subscribe,p=c.upsert,h=c.remove,g=m.read,f=m.subscribe,b=m.upsert,y=m.remove;function j(e,{tunnelPublicUrl:t,tailscaleUrl:s,cloudUrl:a}={}){let l=d(e);return!l||[`http://127.0.0.1:${n.h0.appPort}`,t,s,a].filter(Boolean).flatMap(e=>[d(e),`${d(e)}/v1`]).includes(l)?null:p(l)}let v="__custom__",N="__save__",w=e=>{let t=(e||"").replace(/\/+$/,"");return t?/\/v1$/.test(t)?t:`${t}/v1`:""};function k({value:e,onChange:t,requiresExternalUrl:s=!1,tunnelEnabled:r=!1,tunnelPublicUrl:i="",tailscaleEnabled:o=!1,tailscaleUrl:c="",cloudEnabled:m=!1,cloudUrl:g="",withV1:f=!0,currentUrl:b=""}){let[y,j]=(0,l.useState)([]),[C,_]=(0,l.useState)(!1),[S,A]=(0,l.useState)(""),[E,$]=(0,l.useState)(""),M=(0,l.useRef)(!1),O=(0,l.useRef)(""),T=(0,l.useRef)("");(0,l.useEffect)(()=>{let e=()=>{let e=x();j(e),A(t=>{if(t!==v)return t;let s=d(T.current);if(!s)return t;let a=e.find(e=>{let t=d(e.baseUrl);return t===s||t===w(s)});return a?`saved:${a.name}`:t})};return e(),_(!0),u(e)},[]);let P=(0,l.useMemo)(()=>(({requiresExternalUrl:e,tunnelEnabled:t,tunnelPublicUrl:s,tailscaleEnabled:a,tailscaleUrl:l,cloudEnabled:r,cloudUrl:i,savedPresets:o,withV1:d})=>{let c=[],m=e=>d?w(e):(e||"").replace(/\/+$/,"");if(!e){let e=m(`http://127.0.0.1:${n.h0.appPort}`);c.push({value:"local",label:e,url:e})}if(t&&s){let e=m(s);c.push({value:"tunnel",label:e,url:e})}if(a&&l){let e=m(l);c.push({value:"tailscale",label:e,url:e})}if(r&&i){let e=m(i);c.push({value:"cloud",label:e,url:e})}return o.forEach(e=>{c.push({value:`saved:${e.name}`,label:e.baseUrl,url:e.baseUrl,saved:!0})}),c.push({value:v,label:"Custom URL...",url:""}),c})({requiresExternalUrl:s,tunnelEnabled:r,tunnelPublicUrl:i,tailscaleEnabled:o,tailscaleUrl:c,cloudEnabled:m,cloudUrl:g,savedPresets:y,withV1:f}),[s,r,i,o,c,m,g,y,f]);(0,l.useEffect)(()=>{if(!C||0===P.length)return;let e=e=>f?w(e):d(e),s=e(b);if(M.current&&O.current===s)return;M.current=!0,O.current=s;let a=s?P.find(t=>t.value!==v&&e(t.url)===s):null;if(a)$(""),T.current="",A(a.value),t(a.url);else if(s)$(s),T.current=s,A(v),t(s);else{let e=P.find(e=>e.value!==v);if(!e)return;A(e.value),t(e.url)}},[C,P,t,b,f]);let R=S.startsWith("saved:"),I=S===v,U=I&&(E||"").trim().length>0;return(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)("select",{value:S,onChange:s=>{let a=s.target.value;if(a===N){let t=(e||"").trim();if(!t)return;let s=t;try{s=new URL(t).host}catch{}let a=window.prompt("Save endpoint as:",s),l=a?.trim()?p(t,a.trim()):null;l&&A(`saved:${l}`);return}if(A(a),a===v){$(""),t("");return}let l=P.find(e=>e.value===a);l&&t(l.url)},className:"flex-1 min-w-0 px-2 py-2 bg-surface rounded text-xs border border-border focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5",children:[P.map(e=>(0,a.jsx)("option",{value:e.value,children:e.label},e.value)),U&&(0,a.jsx)("option",{value:N,children:"+ Save current as..."})]}),R&&(0,a.jsx)("button",{type:"button",onClick:()=>{if(!S.startsWith("saved:"))return;h(S.slice(6)),$("");let e=P.find(e=>e.value!==v&&e.value!==S);e?(A(e.value),t(e.url)):(A(v),t(""))},className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors shrink-0",title:"Delete saved endpoint",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"delete"})})]}),I&&(0,a.jsx)("input",{type:"text",value:E,onChange:e=>{let s=e.target.value;T.current=s,$(s),t(s)},placeholder:f?"https://example.com/v1":"https://example.com",className:"w-full min-w-0 px-2 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"})]})}let C="__custom__",_="__save_key__";function S({value:e,onChange:t,apiKeys:s=[],cloudEnabled:r=!1,className:i=""}){let[n,o]=(0,l.useState)([]),[d,c]=(0,l.useState)(!1),[m,x]=(0,l.useState)("");(0,l.useEffect)(()=>{let e=()=>o(g());return e(),f(e)},[]);let u=(0,l.useMemo)(()=>[...s.map(e=>({value:e.key,label:e.key})),...n.map(e=>({value:`saved:${e.name}`,label:e.key,url:e.key,saved:!0})),{value:C,label:"Custom...",url:""}],[s,n]),p=e?u.find(t=>t.value===e||t.url===e):null,h=p?p.value:d||e?C:u[0]?.value??C,j=d?m:e||"",v="string"==typeof h&&h.startsWith("saved:"),N=h===C,w=N&&(e||"").trim().length>0&&!s.some(t=>t.key===e);return 0!==s.length||0!==n.length||d||e?(0,a.jsxs)("div",{className:`flex flex-col gap-1.5 ${i}`,children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)("select",{value:h,onChange:s=>{let a=s.target.value;if(a===_)return void b((e||"").trim());if(a===C){c(!0),x(""),t("");return}c(!1),x("");let l=u.find(e=>e.value===a);l&&t(l.url??l.value)},className:"flex-1 min-w-0 px-2 py-2 bg-surface rounded text-xs border border-border focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5",children:[u.map(e=>(0,a.jsx)("option",{value:e.value,children:e.label},e.value)),w&&(0,a.jsx)("option",{value:_,children:"+ Save current as..."})]}),v&&(0,a.jsx)("button",{type:"button",onClick:()=>{if(!v)return;y(h.slice(6)),c(!1),x("");let e=u.find(e=>e.value!==C&&e.value!==h);t(e?e.url??e.value:"")},className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors shrink-0",title:"Delete saved key",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"delete"})})]}),N&&(0,a.jsx)("input",{type:"text",value:j,onChange:e=>{let s=e.target.value;c(!0),x(s),t(s)},placeholder:"sk-...",className:"w-full min-w-0 px-2 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"})]}):(0,a.jsx)("span",{className:`min-w-0 rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5 ${i}`,children:r?"No API keys - Create one in Keys page":"sk_9router (default)"})}let A=e=>(e||"").replace(/\/+$/,"");function E(e,t={}){if(!e)return!1;let s=A(e),{tunnelPublicUrl:a,tailscaleUrl:l,cloudUrl:r}=t;return!!(/localhost|127\.0\.0\.1|0\.0\.0\.0/.test(s)||a&&s.startsWith(A(a))||l&&s.startsWith(A(l))||r&&s.startsWith(A(r)))}let $=/\[1m\]$/i,M=[{label:"Default",value:""},{label:"200K",value:"198000"},{label:"300K",value:"298000"},{label:"500K",value:"498000"},{label:"700K",value:"698000"}];function O({tool:e,isExpanded:t,onToggle:s,activeProviders:n,modelMappings:o,onModelMappingChange:d,baseUrl:c,hasActiveProviders:m,apiKeys:x,cloudEnabled:u,initialStatus:p,tunnelEnabled:h,tunnelPublicUrl:g,tailscaleEnabled:f,tailscaleUrl:b}){let y,v,N,[w,C]=(0,l.useState)(p||null),[_,A]=(0,l.useState)(!1),[T,P]=(0,l.useState)(!1),[R,I]=(0,l.useState)(!1),[U,D]=(0,l.useState)(null),[z,L]=(0,l.useState)(!1),[F,K]=(0,l.useState)(!1),[q,B]=(0,l.useState)(null),[H,W]=(0,l.useState)(""),[G,J]=(0,l.useState)({}),[Y,V]=(0,l.useState)(!1),[Z,Q]=(0,l.useState)(""),[X,ee]=(0,l.useState)(!1),[et,es]=(0,l.useState)(!1),[ea,el]=(0,l.useState)(""),[er,ei]=(0,l.useState)(!1),en=(0,l.useRef)(!1),eo=w?.settings?.env?.ANTHROPIC_BASE_URL||"",ed=(()=>{if(!w?.installed)return null;let e=w.settings?.env?.ANTHROPIC_BASE_URL;return e?E(e,{tunnelPublicUrl:g,tailscaleUrl:b,cloudUrl:u?"https://9router.com":null})?"configured":"other":"not_configured"})();(0,l.useEffect)(()=>{x?.length>0&&!H&&W(x[0].key)},[x,H]),(0,l.useEffect)(()=>{p&&(C(p),es(!!p.exaMcpEnabled))},[p]),(0,l.useEffect)(()=>{el(w?.settings?.env?.CLAUDE_CODE_AUTO_COMPACT_WINDOW||"")},[w?.settings?.env?.CLAUDE_CODE_AUTO_COMPACT_WINDOW]),(0,l.useEffect)(()=>{let t=w?.settings?.env;t&&ei(e.defaultModels.some(e=>t[e.envKey]?.endsWith("[1m]")))},[w?.settings?.env,e.defaultModels]),(0,l.useEffect)(()=>{t&&(w||ex(),em())},[t]),(0,l.useEffect)(()=>{fetch("/api/settings").then(e=>e.json()).then(e=>{ee(!!e.ccFilterNaming)}).catch(()=>{})},[]);let ec=async e=>{let t=e.target.checked;ee(t),await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({ccFilterNaming:t})}).catch(()=>{})},em=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&J(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}};(0,l.useEffect)(()=>{if(w?.installed&&!en.current){en.current=!0;let t=w.settings?.env||{};e.defaultModels.forEach(e=>{if(e.envKey){let s=t[e.envKey]||e.defaultValue||"";s&&d(e.alias,s)}});let s=t.ANTHROPIC_AUTH_TOKEN;s&&W(s)}},[w,x,e.defaultModels,d]);let ex=async()=>{A(!0);try{let e=await fetch("/api/cli-tools/claude-settings"),t=await e.json();C(t),es(!!t.exaMcpEnabled)}catch(e){C({installed:!1,error:e.message})}finally{A(!1)}},eu=()=>{let e=Z||c;return e.endsWith("/v1")?e:`${e}/v1`},ep=async()=>{P(!0),D(null);try{let t={ANTHROPIC_BASE_URL:eu()},s=H?.trim()||(x?.length>0?x[0].key:null)||(u?null:"sk_9router");s&&(t.ANTHROPIC_AUTH_TOKEN=s),e.defaultModels.forEach(e=>{let s=o[e.alias];s&&e.envKey&&(t[e.envKey]=s)}),ea&&(t.CLAUDE_CODE_AUTO_COMPACT_WINDOW=ea);let a=await fetch("/api/cli-tools/claude-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({env:t,exaMcpEnabled:et,autoCompactWindow:ea})}),l=await a.json();a.ok?(j(eu(),{tunnelPublicUrl:g,tailscaleUrl:b}),D({type:"success",text:"Settings applied successfully!"}),C(e=>({...e,hasBackup:!0,settings:{...e?.settings,env:t},exaMcpEnabled:et}))):D({type:"error",text:l.error||"Failed to apply settings"})}catch(e){D({type:"error",text:e.message})}finally{P(!1)}},eh=async()=>{I(!0),D(null);try{let t=await fetch("/api/cli-tools/claude-settings",{method:"DELETE"}),s=await t.json();t.ok?(D({type:"success",text:"Settings reset successfully!"}),e.defaultModels.forEach(e=>d(e.alias,e.defaultValue||"")),W(""),es(!1),el(""),ei(!1)):D({type:"error",text:s.error||"Failed to reset settings"})}catch(e){D({type:"error",text:e.message})}finally{I(!1)}};return(0,a.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3 hover:cursor-pointer sm:items-center",onClick:s,children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(i.A,{src:"/providers/claude.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===ed&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===ed&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===ed&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[_&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,a.jsx)("span",{children:"Checking Claude CLI..."})]}),!_&&w&&!w.installed&&(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Claude CLI not detected locally"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if 9router is deployed on a remote server."})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 pl-9",children:[(0,a.jsxs)(r.$n,{variant:"secondary",size:"sm",onClick:()=>V(!0),className:"!bg-yellow-500/20 !border-yellow-500/40 !text-yellow-700 dark:!text-yellow-300 hover:!bg-yellow-500/30",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:"content_copy"}),"Manual Config"]}),(0,a.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:()=>L(!z),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:z?"expand_less":"help"}),z?"Hide":"How to Install"]})]})]}),z&&(0,a.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,a.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,a.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-text-muted mb-1",children:"macOS / Linux / Windows:"}),(0,a.jsx)("code",{className:"block px-3 py-2 bg-black/5 dark:bg-white/5 rounded font-mono text-xs",children:"npm install -g @anthropic-ai/claude-code"})]}),(0,a.jsxs)("p",{className:"text-text-muted",children:["After installation, run ",(0,a.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"claude"})," to verify."]})]})]})]}),!_&&w?.installed&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Select Endpoint"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(k,{value:Z||((y=Z||c).endsWith("/v1")?y:`${y}/v1`),onChange:Q,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:h,tunnelPublicUrl:g,tailscaleEnabled:f,tailscaleUrl:b,currentUrl:eo})]}),w?.settings?.env?.ANTHROPIC_BASE_URL&&(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Current"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)("span",{className:"min-w-0 truncate rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5",children:w.settings.env.ANTHROPIC_BASE_URL})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(S,{value:H,onChange:W,apiKeys:x,cloudEnabled:u})]}),e.defaultModels.map(e=>(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:e.name}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,a.jsxs)("div",{className:"relative flex-1 min-w-0",children:[(0,a.jsx)("input",{type:"text",value:o[e.alias]||"",onChange:t=>d(e.alias,t.target.value),placeholder:"provider/model-id",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),o[e.alias]&&(0,a.jsx)("button",{onClick:()=>d(e.alias,""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,a.jsx)("button",{onClick:()=>{B(e.alias),K(!0)},disabled:!m,className:`rounded border px-2.5 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap shrink-0 ${m?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"})]})]},e.alias)),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Auto-compact"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)("select",{value:ea,onChange:e=>el(e.target.value),className:"w-full min-w-0 px-2 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5",children:M.map(e=>(0,a.jsx)("option",{value:e.value,children:e.label},e.label))})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-1.5 sm:grid sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"1M context"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("label",{className:"flex items-center gap-1.5 cursor-pointer select-none",children:[(0,a.jsx)("input",{type:"checkbox",checked:er,onChange:t=>{var s;ei(s=t.target.checked),e.defaultModels.forEach(e=>{let t=o[e.alias];t&&d(e.alias,((e,t)=>{let{model:s}=function(e){if("string"!=typeof e)return{model:e,contextMarker:null};let t=e.trim(),s=t.match($);return s?{model:t.slice(0,-s[0].length),contextMarker:s[0].slice(1,-1).toLowerCase()}:{model:e,contextMarker:null}}(e);return t?`${s}[1m]`:s})(t,s))})},className:"w-3.5 h-3.5 accent-primary cursor-pointer shrink-0"}),(0,a.jsx)("span",{className:"text-xs text-text-muted",children:"Append [1m] to the model name"}),(0,a.jsx)(r.m_,{text:"Claude Code otherwise assumes a 200K window, which clamps the auto-compact window above. Applied to every mapped model — only enable it for models that really accept 1M.",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px] cursor-help",children:"info"})})]})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-1.5 sm:grid sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Filter naming"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("label",{className:"flex items-center gap-1.5 cursor-pointer select-none",children:[(0,a.jsx)("input",{type:"checkbox",checked:X,onChange:ec,className:"w-3.5 h-3.5 accent-primary cursor-pointer shrink-0"}),(0,a.jsx)("span",{className:"text-xs text-text-muted",children:"Filter naming requests"}),(0,a.jsx)(r.m_,{text:"Intercepts Claude Code's topic-naming requests and returns a fake response locally, saving API tokens.",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px] cursor-help",children:"info"})})]})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-1.5 sm:grid sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Web Search"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("label",{className:"flex items-center gap-1.5 cursor-pointer select-none",children:[(0,a.jsx)("input",{type:"checkbox",checked:et,onChange:e=>es(e.target.checked),className:"w-3.5 h-3.5 accent-primary cursor-pointer shrink-0"}),(0,a.jsx)("span",{className:"text-xs text-text-muted",children:"Exa MCP"}),(0,a.jsx)(r.m_,{text:"Injects Exa MCP into ~/.claude.json so non-Claude models gain web search. Restart Claude Code after Apply.",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px] cursor-help",children:"info"})})]})]})]}),U&&(0,a.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===U.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===U.type?"check_circle":"error"}),(0,a.jsx)("span",{children:U.text})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,a.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:ep,disabled:!m,loading:T,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,a.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:eh,disabled:!w?.has9Router,loading:R,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,a.jsxs)(r.$n,{variant:"ghost",size:"sm",onClick:()=>V(!0),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),F&&(0,a.jsx)(r.rq,{isOpen:F,onClose:()=>K(!1),onSelect:e=>{q&&d(q,e.value)},selectedModel:q?o[q]:null,activeProviders:n,modelAliases:G,title:`Select model for ${q}`}),(0,a.jsx)(r.uR,{isOpen:Y,onClose:()=>V(!1),title:"Claude CLI - Manual Configuration",configs:(v=H&&H.trim()?H:u?"<API_KEY_FROM_DASHBOARD>":"sk_9router",N={ANTHROPIC_BASE_URL:eu(),ANTHROPIC_AUTH_TOKEN:v},e.defaultModels.forEach(e=>{let t=o[e.alias];t&&e.envKey&&(N[e.envKey]=t)}),ea&&(N.CLAUDE_CODE_AUTO_COMPACT_WINDOW=ea),[{filename:"~/.claude/settings.json",content:JSON.stringify({hasCompletedOnboarding:!0,env:N},null,2)}])})]})}var T=s(57250);let P=(e,t)=>{let s=e.match(RegExp(`^\\s*${t}\\s*=\\s*(["'])([^\\n]*?)\\1\\s*(?:#.*)?$`));return s?s[2]:""};function R(e){if("string"!=typeof e)return{baseUrl:"",apiKey:""};let t=e.split(/\r?\n/),s="",a=!0;for(let e of t){if(/^\s*\[/.test(e)){a=!1;continue}a&&(s=P(e,"model_provider")||s)}if(!s)return{baseUrl:"",apiKey:""};let l=`model_providers.${s}`,r=!1,i=!1,n="",o="";for(let e of t){let t=e.match(/^\s*\[\s*([^\]]+?)\s*\]\s*(?:#.*)?$/);if(t){r=t[1]===l,i=t[1]===`${l}.http_headers`;continue}if(r&&(n=P(e,"base_url")||n),i){let t=P(e,"Authorization").match(/^Bearer\s+(.+)$/i);o=t?t[1]:o}}return{baseUrl:n,apiKey:o}}function I(e,t=[]){if(!e||"string"!=typeof e)return"model";let s="",a=e.trim();"config"===(s=(s=a.includes("/")?a.split("/")[0].toLowerCase().replace(/[^a-z0-9_-]/g,""):a.toLowerCase().replace(/[^a-z0-9_-]/g,"")).replace(/^[-_]+|[-_]+$/g,"")||"model")&&(s="model-config");let l=s,r=2;for(;t.includes(l);)l=`${s}-${r}`,r++;return l}function U({tool:e,isExpanded:t,onToggle:s,baseUrl:n,apiKeys:o,activeProviders:d,cloudEnabled:c,initialStatus:m,tunnelEnabled:x,tunnelPublicUrl:u,tailscaleEnabled:p,tailscaleUrl:h}){let g,f,[b,y]=(0,l.useState)(m||null),[v,N]=(0,l.useState)(!1),[w,C]=(0,l.useState)(!1),[_,A]=(0,l.useState)(!1),[$,M]=(0,l.useState)(null),[O,P]=(0,l.useState)(!1),[D,z]=(0,l.useState)(""),[L,F]=(0,l.useState)(""),[K,q]=(0,l.useState)(""),[B,H]=(0,l.useState)(!1),[W,G]=(0,l.useState)(!1),[J,Y]=(0,l.useState)({}),[V,Z]=(0,l.useState)(!1),[Q,X]=(0,l.useState)(""),[ee,et]=(0,l.useState)([]),[es,ea]=(0,l.useState)(""),[el,er]=(0,l.useState)(""),[ei,en]=(0,l.useState)(!1),[eo,ed]=(0,l.useState)(!1),[ec,em]=(0,l.useState)(null),[ex,eu]=(0,l.useState)("");(0,l.useEffect)(()=>{eh()},[]),(0,l.useEffect)(()=>{!(o?.length>0)||D||b?.config||z(o[0].key)},[o,D,b?.config]),(0,l.useEffect)(()=>{m&&y(m)},[m]),(0,l.useEffect)(()=>{t&&(b||eN(),ep(),eh())},[t]);let ep=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&Y(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}},eh=async()=>{try{let e=await fetch("/api/cli-tools/codex-profiles"),t=await e.json();e.ok&&et(t.profiles||[])}catch(e){console.log("Error fetching codex profiles:",e)}},eg=async()=>{let e=es.trim().toLowerCase().replace(/[^a-z0-9_-]/g,""),t=el.trim();if(e&&t){ed(!0);try{let s=await fetch("/api/cli-tools/codex-profiles",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,model:t})}),a=await s.json();s.ok?(ea(""),er(""),eh()):M({type:"error",text:a.error||"Failed to add model"})}catch(e){M({type:"error",text:e.message})}finally{ed(!1)}}},ef=async e=>{em(e);try{(await fetch("/api/cli-tools/codex-profiles",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e})})).ok&&eh()}catch(e){console.log("Error deleting codex profile:",e)}finally{em(null)}},eb=async e=>{try{await navigator.clipboard.writeText(e),eu(e),setTimeout(()=>eu(""),2e3)}catch(e){console.log("Copy failed",e)}};(0,l.useEffect)(()=>{let e=b?.config;if(e){let{baseUrl:t,apiKey:s}=R(e);X(t),z(s);let a=e.match(/^model\s*=\s*"([^"]+)"/m);a&&F(a[1]);let l=e.match(/^default_subagent_model\s*=\s*"([^"]+)"/m);l&&q(l[1])}},[b?.config]);let ey=R(b?.config).baseUrl,ej=b?.installed?b.config?E(ey,{tunnelPublicUrl:u,tailscaleUrl:h})?"configured":"other":"not_configured":null,ev=()=>{let e=(Q||`${n}/v1`).replace(/\/+$/,"");return e.endsWith("/v1")?e:`${e}/v1`},eN=async()=>{N(!0);try{let e=await fetch("/api/cli-tools/codex-settings",{cache:"no-store"}),t=await e.json();y(t)}catch(e){y({installed:!1,error:e.message})}finally{N(!1)}},ew=async()=>{C(!0),M(null);try{let e=D&&D.trim()||c?D:"sk_9router",t=await fetch("/api/cli-tools/codex-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:ev(),apiKey:e,model:L,subagentModel:K||L})}),s=await t.json();t.ok?(j(ev(),{tunnelPublicUrl:u,tailscaleUrl:h}),M({type:"success",text:"Settings applied successfully!"}),eN()):M({type:"error",text:s.error||"Failed to apply settings"})}catch(e){M({type:"error",text:e.message})}finally{C(!1)}},ek=async()=>{A(!0),M(null);try{let e=await fetch("/api/cli-tools/codex-settings",{method:"DELETE"}),t=await e.json();e.ok?(M({type:"success",text:"Settings reset successfully!"}),F(""),q(""),eN()):M({type:"error",text:t.error||"Failed to reset settings"})}catch(e){M({type:"error",text:e.message})}finally{A(!1)}};return(0,a.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3 hover:cursor-pointer sm:items-center",onClick:s,children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(i.A,{src:"/providers/codex.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===ej&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===ej&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===ej&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[v&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,a.jsx)("span",{children:"Checking Codex CLI..."})]}),!v&&b&&!b.installed&&(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Codex CLI not detected locally"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if 9router is deployed on a remote server."})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 pl-9",children:[(0,a.jsxs)(r.$n,{variant:"secondary",size:"sm",onClick:()=>Z(!0),className:"!bg-yellow-500/20 !border-yellow-500/40 !text-yellow-700 dark:!text-yellow-300 hover:!bg-yellow-500/30",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:"content_copy"}),"Manual Config"]}),(0,a.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:()=>P(!O),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:O?"expand_less":"help"}),O?"Hide":"How to Install"]})]})]}),O&&(0,a.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,a.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,a.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-text-muted mb-1",children:"macOS / Linux / Windows:"}),(0,a.jsx)("code",{className:"block px-3 py-2 bg-black/5 dark:bg-white/5 rounded font-mono text-xs",children:"npm install -g @openai/codex"})]}),(0,a.jsxs)("p",{className:"text-text-muted",children:["After installation, run ",(0,a.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"codex"})," to verify."]}),(0,a.jsx)("div",{className:"pt-2 border-t border-border",children:(0,a.jsxs)("p",{className:"text-text-muted text-xs",children:["Codex reads custom providers from ",(0,a.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"~/.codex/config.toml"}),'. Click "Apply" to auto-configure.']})})]})]})]}),!v&&b?.installed&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Select Endpoint"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(k,{value:Q||Q||`${n}/v1`,onChange:X,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:x,tunnelPublicUrl:u,tailscaleEnabled:p,tailscaleUrl:h,currentUrl:ey})]}),b?.config&&(ey?(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Current"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)("span",{className:"min-w-0 truncate rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5",children:ey})]}):null),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(S,{value:D,onChange:z,apiKeys:o,cloudEnabled:c})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Model"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,a.jsx)("input",{type:"text",value:L,onChange:e=>F(e.target.value),placeholder:"provider/model-id",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),L&&(0,a.jsx)("button",{onClick:()=>F(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,a.jsx)("button",{onClick:()=>H(!0),disabled:!d?.length,className:`w-full sm:w-auto rounded border px-2 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap sm:shrink-0 ${d?.length?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Subagent Model"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,a.jsx)("input",{type:"text",value:K,onChange:e=>q(e.target.value),placeholder:L||"provider/model-id (defaults to main model)",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),K&&(0,a.jsx)("button",{onClick:()=>q(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear (will use main model)",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,a.jsx)("button",{onClick:()=>G(!0),disabled:!d?.length,className:`w-full sm:w-auto rounded border px-2 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap sm:shrink-0 ${d?.length?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"})]})]}),$&&(0,a.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===$.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===$.type?"check_circle":"error"}),(0,a.jsx)("span",{children:$.text})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,a.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:ew,disabled:!D&&c&&o.length>0||!L,loading:w,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,a.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:ek,disabled:_,loading:_,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,a.jsxs)(r.$n,{variant:"ghost",size:"sm",onClick:()=>Z(!0),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]}),(0,a.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-3",children:[(0,a.jsx)("div",{className:"flex items-center justify-between",children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)("span",{className:"text-xs font-semibold text-text-main flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px] text-primary",children:"layers"}),"Additional Models"]}),ee.length>0&&(0,a.jsx)("span",{className:"px-1.5 py-0.2 bg-primary/10 text-primary text-[10px] font-medium rounded-full",children:ee.length})]})}),(0,a.jsx)("div",{className:"flex flex-col gap-1.5 p-2.5 bg-surface/40 border border-border rounded-lg",children:(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-[10rem_1fr_auto_auto] sm:items-center",children:[(0,a.jsx)("input",{type:"text",value:es,onChange:e=>ea(e.target.value.toLowerCase().replace(/[^a-z0-9_-]/g,"")),placeholder:"Alias (e.g. claude)",className:"w-full min-w-0 px-2.5 py-1.5 bg-surface rounded border border-border text-xs font-mono focus:outline-none focus:ring-1 focus:ring-primary/50",onKeyDown:e=>"Enter"===e.key&&eg()}),(0,a.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,a.jsx)("input",{type:"text",value:el,onChange:e=>{let t=e.target.value;er(t),ea(I(t.includes("/")?t.split("/")[0]:t,ee.map(e=>e.name)))},placeholder:"provider/model-id",className:"w-full min-w-0 pl-2.5 pr-7 py-1.5 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50",onKeyDown:e=>"Enter"===e.key&&eg()}),el&&(0,a.jsx)("button",{onClick:()=>er(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,a.jsx)("button",{onClick:()=>en(!0),disabled:!d?.length,className:`w-full sm:w-auto rounded border px-2.5 py-1.5 text-xs transition-colors whitespace-nowrap sm:shrink-0 ${d?.length?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"}),(0,a.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:eg,disabled:!es.trim()||!el.trim()||eo,loading:eo,className:"!h-7.5 whitespace-nowrap",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[15px] mr-1",children:"add"}),"Add"]})]})}),0===ee.length?(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center p-4 border border-dashed border-border rounded-lg text-center bg-surface/30",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[20px] text-text-muted mb-1 opacity-60",children:"terminal"}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Only the main model is active. Add an alias above to configure more models for Codex CLI."})]}):(0,a.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:ee.map(e=>{let t=e.model.includes("/")?e.model.split("/")[0]:e.name,s=ex===e.command;return(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2 p-2.5 bg-surface/50 border border-border hover:border-border-hover rounded-lg transition-colors group",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2.5 min-w-0",children:[(0,a.jsx)("div",{className:"size-6 flex items-center justify-center shrink-0 rounded bg-black/5 dark:bg-white/5 p-0.5",children:(0,a.jsx)(T.A,{providerId:t,size:18,fallbackText:e.name.slice(0,2).toUpperCase()})}),(0,a.jsxs)("div",{className:"min-w-0 flex flex-col",children:[(0,a.jsx)("span",{className:"font-medium text-xs text-text-main truncate",children:e.name}),(0,a.jsx)("span",{className:"text-[11px] text-text-muted truncate font-mono",children:e.model})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,a.jsxs)("button",{onClick:()=>eb(e.command),className:`flex items-center gap-1 px-2 py-1 rounded text-[11px] font-mono border transition-all ${s?"bg-green-500/10 border-green-500/30 text-green-600 dark:text-green-400":"bg-surface border-border text-text-muted hover:text-text-main hover:border-primary/50 cursor-pointer"}`,title:"Click to copy command",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:s?"check":"terminal"}),(0,a.jsx)("span",{className:"hidden md:inline",children:e.command}),(0,a.jsx)("span",{className:"md:hidden",children:"copy"})]}),(0,a.jsx)("button",{onClick:()=>ef(e.name),disabled:ec===e.name,className:"p-1 text-text-muted hover:text-red-500 opacity-0 group-hover:opacity-100 transition-opacity rounded",title:"Delete model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[15px]",children:"close"})})]})]},e.name)})})]})]})]}),B&&(0,a.jsx)(r.rq,{isOpen:B,onClose:()=>H(!1),onSelect:e=>{F(e.value),K||q(e.value),H(!1)},selectedModel:L,activeProviders:d,modelAliases:J,title:"Select Model for Codex"}),W&&(0,a.jsx)(r.rq,{isOpen:W,onClose:()=>G(!1),onSelect:e=>{q(e.value),G(!1)},selectedModel:K,activeProviders:d,modelAliases:J,title:"Select Subagent Model for Codex"}),ei&&(0,a.jsx)(r.rq,{isOpen:ei,onClose:()=>en(!1),onSelect:e=>{en(!1);let t=e?.value||e?.id;t&&(er(t),ea(I(e?.provider||(t.includes("/")?t.split("/")[0]:t),ee.map(e=>e.name))))},selectedModel:el,activeProviders:d,modelAliases:J,title:"Select Model for Codex CLI"}),(0,a.jsx)(r.uR,{isOpen:V,onClose:()=>Z(!1),title:"Codex CLI - Manual Configuration",configs:(g=D&&D.trim()?D:c?"<API_KEY_FROM_DASHBOARD>":"sk_9router",f=K||L,[{filename:"~/.codex/config.toml",content:`# 9Router Configuration for Codex CLI
|
|
44
|
+
# Fetch and follow .opencode/INSTALL.md from the repo`}},pi:{id:"pi",name:"Pi (pi-coding-agent)",image:"/providers/pi.svg",color:"#6366F1",description:"Pi coding agent — minimal, extensible agent harness (pi.dev)",configType:"custom",docsUrl:"https://pi.dev",notes:[{type:"info",text:"Pi uses ~/.pi/agent/models.json. 9Router is configured under providers.9router as an OpenAI-compatible endpoint."}]},omp:{id:"omp",name:"Oh My Pi",image:"/providers/omp.png",color:"#EC4899",description:"Oh My Pi terminal AI agent with auto-discovery support",configType:"custom",docsUrl:"https://github.com/can1357/oh-my-pi",notes:[{type:"info",text:"Oh My Pi uses ~/.omp/agent/models.yml and agent.db. 9Router is configured with proxy discovery so all models appear automatically under /model."}]},crush:{id:"crush",name:"Crush",image:"/providers/crush.png",color:"#FB923C",description:"Charm Crush terminal AI coding agent",configType:"custom",docsUrl:"https://github.com/charmbracelet/crush",notes:[{type:"info",text:"Crush uses ~/.config/crush/crush.json. 9Router registers as an openai-compat provider."}]},forge:{id:"forge",name:"ForgeCode",image:"/providers/forge.png",color:"#EAB308",description:"Antinomy HQ ForgeCode agent harness",configType:"custom",docsUrl:"https://github.com/antinomyhq/forge",notes:[{type:"info",text:"ForgeCode uses ~/.forge/config.toml. 9Router updates the [openai] section with your baseUrl, apiKey, and model."}]},smelt:{id:"smelt",name:"Smelt",image:"/providers/smelt.svg",color:"#EF4444",description:"Smelt terminal AI coding assistant",configType:"custom",docsUrl:"https://github.com/leonardcser/smelt",notes:[{type:"info",text:"Smelt uses ~/.smelt/config.json for OpenAI-compatible endpoint configuration."}]},codewhale:{id:"codewhale",name:"CodeWhale",image:"/providers/codewhale.svg",color:"#4F46E5",description:"CodeWhale terminal coding agent (successor to DeepSeek TUI)",configType:"custom",docsUrl:"https://github.com/Hmbown/CodeWhale",notes:[{type:"info",text:"CodeWhale uses ~/.codewhale/config.toml. 9Router configures the [openai] provider with your base_url, api_key, and model."}]}}},22968:(e,t,s)=>{s.d(t,{Tk:()=>O,aG:()=>er,Ah:()=>U,Q6:()=>el,Mz:()=>ep,lF:()=>eo,a7:()=>W,ZM:()=>D,WE:()=>e$,E_:()=>ej,RF:()=>q,mW:()=>ed,c9:()=>ei,gY:()=>eY,tA:()=>eO,kn:()=>eP,yZ:()=>z,qO:()=>et,xm:()=>eJ});var a=s(95155),l=s(12115),r=s(35497),i=s(5772),n=s(90620);function o({storageKey:e,changeEvent:t,itemField:s,normalize:a=e=>e,defaultName:l=e=>e}){let r=()=>{try{let t=JSON.parse(window.localStorage.getItem(e)||"[]");if(!Array.isArray(t))return[];return t.filter(e=>e?.name&&e?.[s])}catch{return[]}},i=s=>{window.localStorage.setItem(e,JSON.stringify(s)),window.dispatchEvent(new CustomEvent(t))};return{read:r,subscribe:e=>(window.addEventListener(t,e),()=>window.removeEventListener(t,e)),upsert:(e,t)=>{let n=a(e);if(!n)return null;let o=r(),d=o.find(e=>a(e[s])===n);if(d&&!t)return d.name;let c=(t||l(n)).trim();return c?(i([...o.filter(e=>e.name!==c&&a(e[s])!==n),{name:c,[s]:n}].sort((e,t)=>e.name.localeCompare(t.name))),c):null},remove:e=>i(r().filter(t=>t.name!==e))}}let d=e=>(e||"").replace(/\/+$/,""),c=o({storageKey:"9router.cliToolEndpointPresets",changeEvent:"9router:endpoint-presets-changed",itemField:"baseUrl",normalize:d,defaultName:e=>{try{return new URL(e).host}catch{return e}}}),m=o({storageKey:"9router.cliToolApiKeyPresets",changeEvent:"9router:api-key-presets-changed",itemField:"key"}),x=c.read,u=c.subscribe,p=c.upsert,h=c.remove,g=m.read,f=m.subscribe,b=m.upsert,y=m.remove;function j(e,{tunnelPublicUrl:t,tailscaleUrl:s,cloudUrl:a}={}){let l=d(e);return!l||[`http://127.0.0.1:${n.h0.appPort}`,t,s,a].filter(Boolean).flatMap(e=>[d(e),`${d(e)}/v1`]).includes(l)?null:p(l)}let v="__custom__",N="__save__",w=e=>{let t=(e||"").replace(/\/+$/,"");return t?/\/v1$/.test(t)?t:`${t}/v1`:""};function k({value:e,onChange:t,requiresExternalUrl:s=!1,tunnelEnabled:r=!1,tunnelPublicUrl:i="",tailscaleEnabled:o=!1,tailscaleUrl:c="",cloudEnabled:m=!1,cloudUrl:g="",withV1:f=!0,currentUrl:b=""}){let[y,j]=(0,l.useState)([]),[C,S]=(0,l.useState)(!1),[_,A]=(0,l.useState)(""),[E,$]=(0,l.useState)(""),M=(0,l.useRef)(!1),O=(0,l.useRef)(""),T=(0,l.useRef)("");(0,l.useEffect)(()=>{let e=()=>{let e=x();j(e),A(t=>{if(t!==v)return t;let s=d(T.current);if(!s)return t;let a=e.find(e=>{let t=d(e.baseUrl);return t===s||t===w(s)});return a?`saved:${a.name}`:t})};return e(),S(!0),u(e)},[]);let P=(0,l.useMemo)(()=>(({requiresExternalUrl:e,tunnelEnabled:t,tunnelPublicUrl:s,tailscaleEnabled:a,tailscaleUrl:l,cloudEnabled:r,cloudUrl:i,savedPresets:o,withV1:d})=>{let c=[],m=e=>d?w(e):(e||"").replace(/\/+$/,"");if(!e){let e=m(`http://127.0.0.1:${n.h0.appPort}`);c.push({value:"local",label:e,url:e})}if(t&&s){let e=m(s);c.push({value:"tunnel",label:e,url:e})}if(a&&l){let e=m(l);c.push({value:"tailscale",label:e,url:e})}if(r&&i){let e=m(i);c.push({value:"cloud",label:e,url:e})}return o.forEach(e=>{c.push({value:`saved:${e.name}`,label:e.baseUrl,url:e.baseUrl,saved:!0})}),c.push({value:v,label:"Custom URL...",url:""}),c})({requiresExternalUrl:s,tunnelEnabled:r,tunnelPublicUrl:i,tailscaleEnabled:o,tailscaleUrl:c,cloudEnabled:m,cloudUrl:g,savedPresets:y,withV1:f}),[s,r,i,o,c,m,g,y,f]);(0,l.useEffect)(()=>{if(!C||0===P.length)return;let e=e=>f?w(e):d(e),s=e(b);if(M.current&&O.current===s)return;M.current=!0,O.current=s;let a=s?P.find(t=>t.value!==v&&e(t.url)===s):null;if(a)$(""),T.current="",A(a.value),t(a.url);else if(s)$(s),T.current=s,A(v),t(s);else{let e=P.find(e=>e.value!==v);if(!e)return;A(e.value),t(e.url)}},[C,P,t,b,f]);let R=_.startsWith("saved:"),I=_===v,U=I&&(E||"").trim().length>0;return(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)("select",{value:_,onChange:s=>{let a=s.target.value;if(a===N){let t=(e||"").trim();if(!t)return;let s=t;try{s=new URL(t).host}catch{}let a=window.prompt("Save endpoint as:",s),l=a?.trim()?p(t,a.trim()):null;l&&A(`saved:${l}`);return}if(A(a),a===v){$(""),t("");return}let l=P.find(e=>e.value===a);l&&t(l.url)},className:"flex-1 min-w-0 px-2 py-2 bg-surface rounded text-xs border border-border focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5",children:[P.map(e=>(0,a.jsx)("option",{value:e.value,children:e.label},e.value)),U&&(0,a.jsx)("option",{value:N,children:"+ Save current as..."})]}),R&&(0,a.jsx)("button",{type:"button",onClick:()=>{if(!_.startsWith("saved:"))return;h(_.slice(6)),$("");let e=P.find(e=>e.value!==v&&e.value!==_);e?(A(e.value),t(e.url)):(A(v),t(""))},className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors shrink-0",title:"Delete saved endpoint",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"delete"})})]}),I&&(0,a.jsx)("input",{type:"text",value:E,onChange:e=>{let s=e.target.value;T.current=s,$(s),t(s)},placeholder:f?"https://example.com/v1":"https://example.com",className:"w-full min-w-0 px-2 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"})]})}let C="__custom__",S="__save_key__";function _({value:e,onChange:t,apiKeys:s=[],cloudEnabled:r=!1,className:i=""}){let[n,o]=(0,l.useState)([]),[d,c]=(0,l.useState)(!1),[m,x]=(0,l.useState)("");(0,l.useEffect)(()=>{let e=()=>o(g());return e(),f(e)},[]);let u=(0,l.useMemo)(()=>[...s.map(e=>({value:e.key,label:e.key})),...n.map(e=>({value:`saved:${e.name}`,label:e.key,url:e.key,saved:!0})),{value:C,label:"Custom...",url:""}],[s,n]),p=e?u.find(t=>t.value===e||t.url===e):null,h=p?p.value:d||e?C:u[0]?.value??C,j=d?m:e||"",v="string"==typeof h&&h.startsWith("saved:"),N=h===C,w=N&&(e||"").trim().length>0&&!s.some(t=>t.key===e);return 0!==s.length||0!==n.length||d||e?(0,a.jsxs)("div",{className:`flex flex-col gap-1.5 ${i}`,children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)("select",{value:h,onChange:s=>{let a=s.target.value;if(a===S)return void b((e||"").trim());if(a===C){c(!0),x(""),t("");return}c(!1),x("");let l=u.find(e=>e.value===a);l&&t(l.url??l.value)},className:"flex-1 min-w-0 px-2 py-2 bg-surface rounded text-xs border border-border focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5",children:[u.map(e=>(0,a.jsx)("option",{value:e.value,children:e.label},e.value)),w&&(0,a.jsx)("option",{value:S,children:"+ Save current as..."})]}),v&&(0,a.jsx)("button",{type:"button",onClick:()=>{if(!v)return;y(h.slice(6)),c(!1),x("");let e=u.find(e=>e.value!==C&&e.value!==h);t(e?e.url??e.value:"")},className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors shrink-0",title:"Delete saved key",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"delete"})})]}),N&&(0,a.jsx)("input",{type:"text",value:j,onChange:e=>{let s=e.target.value;c(!0),x(s),t(s)},placeholder:"sk-...",className:"w-full min-w-0 px-2 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"})]}):(0,a.jsx)("span",{className:`min-w-0 rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5 ${i}`,children:r?"No API keys - Create one in Keys page":"sk_9router (default)"})}let A=e=>(e||"").replace(/\/+$/,"");function E(e,t={}){if(!e)return!1;let s=A(e),{tunnelPublicUrl:a,tailscaleUrl:l,cloudUrl:r}=t;return!!(/localhost|127\.0\.0\.1|0\.0\.0\.0/.test(s)||a&&s.startsWith(A(a))||l&&s.startsWith(A(l))||r&&s.startsWith(A(r)))}let $=/\[1m\]$/i,M=[{label:"Default",value:""},{label:"200K",value:"198000"},{label:"300K",value:"298000"},{label:"500K",value:"498000"},{label:"700K",value:"698000"}];function O({tool:e,isExpanded:t,onToggle:s,activeProviders:n,modelMappings:o,onModelMappingChange:d,baseUrl:c,hasActiveProviders:m,apiKeys:x,cloudEnabled:u,initialStatus:p,tunnelEnabled:h,tunnelPublicUrl:g,tailscaleEnabled:f,tailscaleUrl:b}){let y,v,N,[w,C]=(0,l.useState)(p||null),[S,A]=(0,l.useState)(!1),[T,P]=(0,l.useState)(!1),[R,I]=(0,l.useState)(!1),[U,D]=(0,l.useState)(null),[z,L]=(0,l.useState)(!1),[F,K]=(0,l.useState)(!1),[q,B]=(0,l.useState)(null),[H,W]=(0,l.useState)(""),[G,J]=(0,l.useState)({}),[Y,V]=(0,l.useState)(!1),[Z,Q]=(0,l.useState)(""),[X,ee]=(0,l.useState)(!1),[et,es]=(0,l.useState)(!1),[ea,el]=(0,l.useState)(""),[er,ei]=(0,l.useState)(!1),en=(0,l.useRef)(!1),eo=w?.settings?.env?.ANTHROPIC_BASE_URL||"",ed=(()=>{if(!w?.installed)return null;let e=w.settings?.env?.ANTHROPIC_BASE_URL;return e?E(e,{tunnelPublicUrl:g,tailscaleUrl:b,cloudUrl:u?"https://9router.com":null})?"configured":"other":"not_configured"})();(0,l.useEffect)(()=>{x?.length>0&&!H&&W(x[0].key)},[x,H]),(0,l.useEffect)(()=>{p&&(C(p),es(!!p.exaMcpEnabled))},[p]),(0,l.useEffect)(()=>{el(w?.settings?.env?.CLAUDE_CODE_AUTO_COMPACT_WINDOW||"")},[w?.settings?.env?.CLAUDE_CODE_AUTO_COMPACT_WINDOW]),(0,l.useEffect)(()=>{let t=w?.settings?.env;t&&ei(e.defaultModels.some(e=>t[e.envKey]?.endsWith("[1m]")))},[w?.settings?.env,e.defaultModels]),(0,l.useEffect)(()=>{t&&(w||ex(),em())},[t]),(0,l.useEffect)(()=>{fetch("/api/settings").then(e=>e.json()).then(e=>{ee(!!e.ccFilterNaming)}).catch(()=>{})},[]);let ec=async e=>{let t=e.target.checked;ee(t),await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({ccFilterNaming:t})}).catch(()=>{})},em=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&J(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}};(0,l.useEffect)(()=>{if(w?.installed&&!en.current){en.current=!0;let t=w.settings?.env||{};e.defaultModels.forEach(e=>{if(e.envKey){let s=t[e.envKey]||e.defaultValue||"";s&&d(e.alias,s)}});let s=t.ANTHROPIC_AUTH_TOKEN;s&&W(s)}},[w,x,e.defaultModels,d]);let ex=async()=>{A(!0);try{let e=await fetch("/api/cli-tools/claude-settings"),t=await e.json();C(t),es(!!t.exaMcpEnabled)}catch(e){C({installed:!1,error:e.message})}finally{A(!1)}},eu=()=>{let e=Z||c;return e.endsWith("/v1")?e:`${e}/v1`},ep=async()=>{P(!0),D(null);try{let t={ANTHROPIC_BASE_URL:eu()},s=H?.trim()||(x?.length>0?x[0].key:null)||(u?null:"sk_9router");s&&(t.ANTHROPIC_AUTH_TOKEN=s),e.defaultModels.forEach(e=>{let s=o[e.alias];s&&e.envKey&&(t[e.envKey]=s)}),ea&&(t.CLAUDE_CODE_AUTO_COMPACT_WINDOW=ea);let a=await fetch("/api/cli-tools/claude-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({env:t,exaMcpEnabled:et,autoCompactWindow:ea})}),l=await a.json();a.ok?(j(eu(),{tunnelPublicUrl:g,tailscaleUrl:b}),D({type:"success",text:"Settings applied successfully!"}),C(e=>({...e,hasBackup:!0,settings:{...e?.settings,env:t},exaMcpEnabled:et}))):D({type:"error",text:l.error||"Failed to apply settings"})}catch(e){D({type:"error",text:e.message})}finally{P(!1)}},eh=async()=>{I(!0),D(null);try{let t=await fetch("/api/cli-tools/claude-settings",{method:"DELETE"}),s=await t.json();t.ok?(D({type:"success",text:"Settings reset successfully!"}),e.defaultModels.forEach(e=>d(e.alias,e.defaultValue||"")),W(""),es(!1),el(""),ei(!1)):D({type:"error",text:s.error||"Failed to reset settings"})}catch(e){D({type:"error",text:e.message})}finally{I(!1)}};return(0,a.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3 hover:cursor-pointer sm:items-center",onClick:s,children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(i.A,{src:"/providers/claude.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===ed&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===ed&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===ed&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[S&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,a.jsx)("span",{children:"Checking Claude CLI..."})]}),!S&&w&&!w.installed&&(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Claude CLI not detected locally"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if 9router is deployed on a remote server."})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 pl-9",children:[(0,a.jsxs)(r.$n,{variant:"secondary",size:"sm",onClick:()=>V(!0),className:"!bg-yellow-500/20 !border-yellow-500/40 !text-yellow-700 dark:!text-yellow-300 hover:!bg-yellow-500/30",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:"content_copy"}),"Manual Config"]}),(0,a.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:()=>L(!z),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:z?"expand_less":"help"}),z?"Hide":"How to Install"]})]})]}),z&&(0,a.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,a.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,a.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-text-muted mb-1",children:"macOS / Linux / Windows:"}),(0,a.jsx)("code",{className:"block px-3 py-2 bg-black/5 dark:bg-white/5 rounded font-mono text-xs",children:"npm install -g @anthropic-ai/claude-code"})]}),(0,a.jsxs)("p",{className:"text-text-muted",children:["After installation, run ",(0,a.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"claude"})," to verify."]})]})]})]}),!S&&w?.installed&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Select Endpoint"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(k,{value:Z||((y=Z||c).endsWith("/v1")?y:`${y}/v1`),onChange:Q,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:h,tunnelPublicUrl:g,tailscaleEnabled:f,tailscaleUrl:b,currentUrl:eo})]}),w?.settings?.env?.ANTHROPIC_BASE_URL&&(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Current"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)("span",{className:"min-w-0 truncate rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5",children:w.settings.env.ANTHROPIC_BASE_URL})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(_,{value:H,onChange:W,apiKeys:x,cloudEnabled:u})]}),e.defaultModels.map(e=>(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:e.name}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,a.jsxs)("div",{className:"relative flex-1 min-w-0",children:[(0,a.jsx)("input",{type:"text",value:o[e.alias]||"",onChange:t=>d(e.alias,t.target.value),placeholder:"provider/model-id",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),o[e.alias]&&(0,a.jsx)("button",{onClick:()=>d(e.alias,""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,a.jsx)("button",{onClick:()=>{B(e.alias),K(!0)},disabled:!m,className:`rounded border px-2.5 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap shrink-0 ${m?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"})]})]},e.alias)),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Auto-compact"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)("select",{value:ea,onChange:e=>el(e.target.value),className:"w-full min-w-0 px-2 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5",children:M.map(e=>(0,a.jsx)("option",{value:e.value,children:e.label},e.label))})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-1.5 sm:grid sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"1M context"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("label",{className:"flex items-center gap-1.5 cursor-pointer select-none",children:[(0,a.jsx)("input",{type:"checkbox",checked:er,onChange:t=>{var s;ei(s=t.target.checked),e.defaultModels.forEach(e=>{let t=o[e.alias];t&&d(e.alias,((e,t)=>{let{model:s}=function(e){if("string"!=typeof e)return{model:e,contextMarker:null};let t=e.trim(),s=t.match($);return s?{model:t.slice(0,-s[0].length),contextMarker:s[0].slice(1,-1).toLowerCase()}:{model:e,contextMarker:null}}(e);return t?`${s}[1m]`:s})(t,s))})},className:"w-3.5 h-3.5 accent-primary cursor-pointer shrink-0"}),(0,a.jsx)("span",{className:"text-xs text-text-muted",children:"Append [1m] to the model name"}),(0,a.jsx)(r.m_,{text:"Claude Code otherwise assumes a 200K window, which clamps the auto-compact window above. Applied to every mapped model — only enable it for models that really accept 1M.",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px] cursor-help",children:"info"})})]})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-1.5 sm:grid sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Filter naming"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("label",{className:"flex items-center gap-1.5 cursor-pointer select-none",children:[(0,a.jsx)("input",{type:"checkbox",checked:X,onChange:ec,className:"w-3.5 h-3.5 accent-primary cursor-pointer shrink-0"}),(0,a.jsx)("span",{className:"text-xs text-text-muted",children:"Filter naming requests"}),(0,a.jsx)(r.m_,{text:"Intercepts Claude Code's topic-naming requests and returns a fake response locally, saving API tokens.",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px] cursor-help",children:"info"})})]})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-1.5 sm:grid sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Web Search"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("label",{className:"flex items-center gap-1.5 cursor-pointer select-none",children:[(0,a.jsx)("input",{type:"checkbox",checked:et,onChange:e=>es(e.target.checked),className:"w-3.5 h-3.5 accent-primary cursor-pointer shrink-0"}),(0,a.jsx)("span",{className:"text-xs text-text-muted",children:"Exa MCP"}),(0,a.jsx)(r.m_,{text:"Injects Exa MCP into ~/.claude.json so non-Claude models gain web search. Restart Claude Code after Apply.",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px] cursor-help",children:"info"})})]})]})]}),U&&(0,a.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===U.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===U.type?"check_circle":"error"}),(0,a.jsx)("span",{children:U.text})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,a.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:ep,disabled:!m,loading:T,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,a.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:eh,disabled:!w?.has9Router,loading:R,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,a.jsxs)(r.$n,{variant:"ghost",size:"sm",onClick:()=>V(!0),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),F&&(0,a.jsx)(r.rq,{isOpen:F,onClose:()=>K(!1),onSelect:e=>{q&&d(q,e.value)},selectedModel:q?o[q]:null,activeProviders:n,modelAliases:G,title:`Select model for ${q}`}),(0,a.jsx)(r.uR,{isOpen:Y,onClose:()=>V(!1),title:"Claude CLI - Manual Configuration",configs:(v=H&&H.trim()?H:u?"<API_KEY_FROM_DASHBOARD>":"sk_9router",N={ANTHROPIC_BASE_URL:eu(),ANTHROPIC_AUTH_TOKEN:v},e.defaultModels.forEach(e=>{let t=o[e.alias];t&&e.envKey&&(N[e.envKey]=t)}),ea&&(N.CLAUDE_CODE_AUTO_COMPACT_WINDOW=ea),[{filename:"~/.claude/settings.json",content:JSON.stringify({hasCompletedOnboarding:!0,env:N},null,2)}])})]})}var T=s(57250);let P=(e,t)=>{let s=e.match(RegExp(`^\\s*${t}\\s*=\\s*(["'])([^\\n]*?)\\1\\s*(?:#.*)?$`));return s?s[2]:""};function R(e){if("string"!=typeof e)return{baseUrl:"",apiKey:""};let t=e.split(/\r?\n/),s="",a=!0;for(let e of t){if(/^\s*\[/.test(e)){a=!1;continue}a&&(s=P(e,"model_provider")||s)}if(!s)return{baseUrl:"",apiKey:""};let l=`model_providers.${s}`,r=!1,i=!1,n="",o="";for(let e of t){let t=e.match(/^\s*\[\s*([^\]]+?)\s*\]\s*(?:#.*)?$/);if(t){r=t[1]===l,i=t[1]===`${l}.http_headers`;continue}if(r&&(n=P(e,"base_url")||n),i){let t=P(e,"Authorization").match(/^Bearer\s+(.+)$/i);o=t?t[1]:o}}return{baseUrl:n,apiKey:o}}function I(e,t=[]){if(!e||"string"!=typeof e)return"model";let s="",a=e.trim();"config"===(s=(s=a.includes("/")?a.split("/")[0].toLowerCase().replace(/[^a-z0-9_-]/g,""):a.toLowerCase().replace(/[^a-z0-9_-]/g,"")).replace(/^[-_]+|[-_]+$/g,"")||"model")&&(s="model-config");let l=s,r=2;for(;t.includes(l);)l=`${s}-${r}`,r++;return l}function U({tool:e,isExpanded:t,onToggle:s,baseUrl:n,apiKeys:o,activeProviders:d,cloudEnabled:c,initialStatus:m,tunnelEnabled:x,tunnelPublicUrl:u,tailscaleEnabled:p,tailscaleUrl:h}){let g,f,[b,y]=(0,l.useState)(m||null),[v,N]=(0,l.useState)(!1),[w,C]=(0,l.useState)(!1),[S,A]=(0,l.useState)(!1),[$,M]=(0,l.useState)(null),[O,P]=(0,l.useState)(!1),[D,z]=(0,l.useState)(""),[L,F]=(0,l.useState)(""),[K,q]=(0,l.useState)(""),[B,H]=(0,l.useState)(!1),[W,G]=(0,l.useState)(!1),[J,Y]=(0,l.useState)({}),[V,Z]=(0,l.useState)(!1),[Q,X]=(0,l.useState)(""),[ee,et]=(0,l.useState)([]),[es,ea]=(0,l.useState)(""),[el,er]=(0,l.useState)(""),[ei,en]=(0,l.useState)(!1),[eo,ed]=(0,l.useState)(!1),[ec,em]=(0,l.useState)(null),[ex,eu]=(0,l.useState)("");(0,l.useEffect)(()=>{eh()},[]),(0,l.useEffect)(()=>{!(o?.length>0)||D||b?.config||z(o[0].key)},[o,D,b?.config]),(0,l.useEffect)(()=>{m&&y(m)},[m]),(0,l.useEffect)(()=>{t&&(b||eN(),ep(),eh())},[t]);let ep=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&Y(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}},eh=async()=>{try{let e=await fetch("/api/cli-tools/codex-profiles"),t=await e.json();e.ok&&et(t.profiles||[])}catch(e){console.log("Error fetching codex profiles:",e)}},eg=async()=>{let e=es.trim().toLowerCase().replace(/[^a-z0-9_-]/g,""),t=el.trim();if(e&&t){ed(!0);try{let s=await fetch("/api/cli-tools/codex-profiles",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,model:t})}),a=await s.json();s.ok?(ea(""),er(""),eh()):M({type:"error",text:a.error||"Failed to add model"})}catch(e){M({type:"error",text:e.message})}finally{ed(!1)}}},ef=async e=>{em(e);try{(await fetch("/api/cli-tools/codex-profiles",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e})})).ok&&eh()}catch(e){console.log("Error deleting codex profile:",e)}finally{em(null)}},eb=async e=>{try{await navigator.clipboard.writeText(e),eu(e),setTimeout(()=>eu(""),2e3)}catch(e){console.log("Copy failed",e)}};(0,l.useEffect)(()=>{let e=b?.config;if(e){let{baseUrl:t,apiKey:s}=R(e);X(t),z(s);let a=e.match(/^model\s*=\s*"([^"]+)"/m);a&&F(a[1]);let l=e.match(/^default_subagent_model\s*=\s*"([^"]+)"/m);l&&q(l[1])}},[b?.config]);let ey=R(b?.config).baseUrl,ej=b?.installed?b.config?E(ey,{tunnelPublicUrl:u,tailscaleUrl:h})?"configured":"other":"not_configured":null,ev=()=>{let e=(Q||`${n}/v1`).replace(/\/+$/,"");return e.endsWith("/v1")?e:`${e}/v1`},eN=async()=>{N(!0);try{let e=await fetch("/api/cli-tools/codex-settings",{cache:"no-store"}),t=await e.json();y(t)}catch(e){y({installed:!1,error:e.message})}finally{N(!1)}},ew=async()=>{C(!0),M(null);try{let e=D&&D.trim()||c?D:"sk_9router",t=await fetch("/api/cli-tools/codex-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:ev(),apiKey:e,model:L,subagentModel:K||L})}),s=await t.json();t.ok?(j(ev(),{tunnelPublicUrl:u,tailscaleUrl:h}),M({type:"success",text:"Settings applied successfully!"}),eN()):M({type:"error",text:s.error||"Failed to apply settings"})}catch(e){M({type:"error",text:e.message})}finally{C(!1)}},ek=async()=>{A(!0),M(null);try{let e=await fetch("/api/cli-tools/codex-settings",{method:"DELETE"}),t=await e.json();e.ok?(M({type:"success",text:"Settings reset successfully!"}),F(""),q(""),eN()):M({type:"error",text:t.error||"Failed to reset settings"})}catch(e){M({type:"error",text:e.message})}finally{A(!1)}};return(0,a.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3 hover:cursor-pointer sm:items-center",onClick:s,children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(i.A,{src:"/providers/codex.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===ej&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===ej&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===ej&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[v&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,a.jsx)("span",{children:"Checking Codex CLI..."})]}),!v&&b&&!b.installed&&(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Codex CLI not detected locally"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if 9router is deployed on a remote server."})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 pl-9",children:[(0,a.jsxs)(r.$n,{variant:"secondary",size:"sm",onClick:()=>Z(!0),className:"!bg-yellow-500/20 !border-yellow-500/40 !text-yellow-700 dark:!text-yellow-300 hover:!bg-yellow-500/30",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:"content_copy"}),"Manual Config"]}),(0,a.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:()=>P(!O),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:O?"expand_less":"help"}),O?"Hide":"How to Install"]})]})]}),O&&(0,a.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,a.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,a.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-text-muted mb-1",children:"macOS / Linux / Windows:"}),(0,a.jsx)("code",{className:"block px-3 py-2 bg-black/5 dark:bg-white/5 rounded font-mono text-xs",children:"npm install -g @openai/codex"})]}),(0,a.jsxs)("p",{className:"text-text-muted",children:["After installation, run ",(0,a.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"codex"})," to verify."]}),(0,a.jsx)("div",{className:"pt-2 border-t border-border",children:(0,a.jsxs)("p",{className:"text-text-muted text-xs",children:["Codex reads custom providers from ",(0,a.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"~/.codex/config.toml"}),'. Click "Apply" to auto-configure.']})})]})]})]}),!v&&b?.installed&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Select Endpoint"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(k,{value:Q||Q||`${n}/v1`,onChange:X,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:x,tunnelPublicUrl:u,tailscaleEnabled:p,tailscaleUrl:h,currentUrl:ey})]}),b?.config&&(ey?(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Current"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)("span",{className:"min-w-0 truncate rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5",children:ey})]}):null),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(_,{value:D,onChange:z,apiKeys:o,cloudEnabled:c})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Model"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,a.jsx)("input",{type:"text",value:L,onChange:e=>F(e.target.value),placeholder:"provider/model-id",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),L&&(0,a.jsx)("button",{onClick:()=>F(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,a.jsx)("button",{onClick:()=>H(!0),disabled:!d?.length,className:`w-full sm:w-auto rounded border px-2 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap sm:shrink-0 ${d?.length?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Subagent Model"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,a.jsx)("input",{type:"text",value:K,onChange:e=>q(e.target.value),placeholder:L||"provider/model-id (defaults to main model)",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),K&&(0,a.jsx)("button",{onClick:()=>q(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear (will use main model)",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,a.jsx)("button",{onClick:()=>G(!0),disabled:!d?.length,className:`w-full sm:w-auto rounded border px-2 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap sm:shrink-0 ${d?.length?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"})]})]}),$&&(0,a.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===$.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===$.type?"check_circle":"error"}),(0,a.jsx)("span",{children:$.text})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,a.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:ew,disabled:!D&&c&&o.length>0||!L,loading:w,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,a.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:ek,disabled:S,loading:S,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,a.jsxs)(r.$n,{variant:"ghost",size:"sm",onClick:()=>Z(!0),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]}),(0,a.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-3",children:[(0,a.jsx)("div",{className:"flex items-center justify-between",children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)("span",{className:"text-xs font-semibold text-text-main flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px] text-primary",children:"layers"}),"Additional Models"]}),ee.length>0&&(0,a.jsx)("span",{className:"px-1.5 py-0.2 bg-primary/10 text-primary text-[10px] font-medium rounded-full",children:ee.length})]})}),(0,a.jsx)("div",{className:"flex flex-col gap-1.5 p-2.5 bg-surface/40 border border-border rounded-lg",children:(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-[10rem_1fr_auto_auto] sm:items-center",children:[(0,a.jsx)("input",{type:"text",value:es,onChange:e=>ea(e.target.value.toLowerCase().replace(/[^a-z0-9_-]/g,"")),placeholder:"Alias (e.g. claude)",className:"w-full min-w-0 px-2.5 py-1.5 bg-surface rounded border border-border text-xs font-mono focus:outline-none focus:ring-1 focus:ring-primary/50",onKeyDown:e=>"Enter"===e.key&&eg()}),(0,a.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,a.jsx)("input",{type:"text",value:el,onChange:e=>{let t=e.target.value;er(t),ea(I(t.includes("/")?t.split("/")[0]:t,ee.map(e=>e.name)))},placeholder:"provider/model-id",className:"w-full min-w-0 pl-2.5 pr-7 py-1.5 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50",onKeyDown:e=>"Enter"===e.key&&eg()}),el&&(0,a.jsx)("button",{onClick:()=>er(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,a.jsx)("button",{onClick:()=>en(!0),disabled:!d?.length,className:`w-full sm:w-auto rounded border px-2.5 py-1.5 text-xs transition-colors whitespace-nowrap sm:shrink-0 ${d?.length?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"}),(0,a.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:eg,disabled:!es.trim()||!el.trim()||eo,loading:eo,className:"!h-7.5 whitespace-nowrap",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[15px] mr-1",children:"add"}),"Add"]})]})}),0===ee.length?(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center p-4 border border-dashed border-border rounded-lg text-center bg-surface/30",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[20px] text-text-muted mb-1 opacity-60",children:"terminal"}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Only the main model is active. Add an alias above to configure more models for Codex CLI."})]}):(0,a.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:ee.map(e=>{let t=e.model.includes("/")?e.model.split("/")[0]:e.name,s=ex===e.command;return(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2 p-2.5 bg-surface/50 border border-border hover:border-border-hover rounded-lg transition-colors group",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2.5 min-w-0",children:[(0,a.jsx)("div",{className:"size-6 flex items-center justify-center shrink-0 rounded bg-black/5 dark:bg-white/5 p-0.5",children:(0,a.jsx)(T.A,{providerId:t,size:18,fallbackText:e.name.slice(0,2).toUpperCase()})}),(0,a.jsxs)("div",{className:"min-w-0 flex flex-col",children:[(0,a.jsx)("span",{className:"font-medium text-xs text-text-main truncate",children:e.name}),(0,a.jsx)("span",{className:"text-[11px] text-text-muted truncate font-mono",children:e.model})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,a.jsxs)("button",{onClick:()=>eb(e.command),className:`flex items-center gap-1 px-2 py-1 rounded text-[11px] font-mono border transition-all ${s?"bg-green-500/10 border-green-500/30 text-green-600 dark:text-green-400":"bg-surface border-border text-text-muted hover:text-text-main hover:border-primary/50 cursor-pointer"}`,title:"Click to copy command",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:s?"check":"terminal"}),(0,a.jsx)("span",{className:"hidden md:inline",children:e.command}),(0,a.jsx)("span",{className:"md:hidden",children:"copy"})]}),(0,a.jsx)("button",{onClick:()=>ef(e.name),disabled:ec===e.name,className:"p-1 text-text-muted hover:text-red-500 opacity-0 group-hover:opacity-100 transition-opacity rounded",title:"Delete model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[15px]",children:"close"})})]})]},e.name)})})]})]})]}),B&&(0,a.jsx)(r.rq,{isOpen:B,onClose:()=>H(!1),onSelect:e=>{F(e.value),K||q(e.value),H(!1)},selectedModel:L,activeProviders:d,modelAliases:J,title:"Select Model for Codex"}),W&&(0,a.jsx)(r.rq,{isOpen:W,onClose:()=>G(!1),onSelect:e=>{q(e.value),G(!1)},selectedModel:K,activeProviders:d,modelAliases:J,title:"Select Subagent Model for Codex"}),ei&&(0,a.jsx)(r.rq,{isOpen:ei,onClose:()=>en(!1),onSelect:e=>{en(!1);let t=e?.value||e?.id;t&&(er(t),ea(I(e?.provider||(t.includes("/")?t.split("/")[0]:t),ee.map(e=>e.name))))},selectedModel:el,activeProviders:d,modelAliases:J,title:"Select Model for Codex CLI"}),(0,a.jsx)(r.uR,{isOpen:V,onClose:()=>Z(!1),title:"Codex CLI - Manual Configuration",configs:(g=D&&D.trim()?D:c?"<API_KEY_FROM_DASHBOARD>":"sk_9router",f=K||L,[{filename:"~/.codex/config.toml",content:`# 9Router Configuration for Codex CLI
|
|
45
45
|
model = "${L}"
|
|
46
46
|
model_provider = "9router"
|
|
47
47
|
|
|
@@ -55,7 +55,7 @@ Authorization = "Bearer ${g}"
|
|
|
55
55
|
|
|
56
56
|
[agents]
|
|
57
57
|
default_subagent_model = "${f}"
|
|
58
|
-
`}])})]})}function D({tool:e,isExpanded:t,onToggle:s,baseUrl:n,hasActiveProviders:o,apiKeys:d,activeProviders:c,cloudEnabled:m,initialStatus:x,tunnelEnabled:u,tunnelPublicUrl:p,tailscaleEnabled:h,tailscaleUrl:g}){let f,b,y,v,[N,w]=(0,l.useState)(x||null),[C,_]=(0,l.useState)(!1),[A,$]=(0,l.useState)(!1),[M,O]=(0,l.useState)(!1),[T,P]=(0,l.useState)(null),[R,I]=(0,l.useState)(""),[U,z]=(0,l.useState)([]),[L,F]=(0,l.useState)(""),[K,q]=(0,l.useState)(!1),[B,H]=(0,l.useState)({}),[W,G]=(0,l.useState)(!1),[J,Y]=(0,l.useState)(!1),[V,Z]=(0,l.useState)(""),Q=(0,l.useRef)(!1),X=N?.settings?.customModels?.find(e=>e.id?.startsWith("custom:9Router"))?.baseUrl||"",ee=(()=>{if(!N?.installed)return null;let e=N.settings?.customModels?.find(e=>e.id?.startsWith("custom:9Router"));return e?E(e.baseUrl,{tunnelPublicUrl:p,tailscaleUrl:g,cloudUrl:m?"https://9router.com":null})?"configured":"other":"not_configured"})();(0,l.useEffect)(()=>{d?.length>0&&!R&&I(d[0].key)},[d,R]),(0,l.useEffect)(()=>{x&&w(x)},[x]),(0,l.useEffect)(()=>{t&&(N||es(),et())},[t]);let et=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&H(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}};(0,l.useEffect)(()=>{if(N?.installed&&!Q.current){Q.current=!0;let e=(N.settings?.customModels||[]).filter(e=>e.id?.startsWith("custom:9Router")).sort((e,t)=>(e.index||0)-(t.index||0)).map(e=>e.model);if(e.length>0)z(e);else{let e=N.settings?.customModels?.find(e=>"custom:9Router-0"===e.id);e?.model&&z([e.model])}}},[N]);let es=async()=>{_(!0);try{let e=await fetch("/api/cli-tools/droid-settings"),t=await e.json();w(t)}catch(e){w({installed:!1,error:e.message})}finally{_(!1)}},ea=()=>{let e=V||n;return e.endsWith("/v1")?e:`${e}/v1`},el=()=>{let e=L.trim();!e||U.includes(e)||(z(t=>[...t,e]),F(""))},er=async()=>{$(!0),P(null);try{let e=R?.trim()||(d?.length>0?d[0].key:null)||(m?null:"sk_9router"),t=await fetch("/api/cli-tools/droid-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:ea(),apiKey:e,models:U,activeModel:U[0]||""})}),s=await t.json();t.ok?(j(ea(),{tunnelPublicUrl:p,tailscaleUrl:g}),P({type:"success",text:"Settings applied successfully!"}),es()):P({type:"error",text:s.error||"Failed to apply settings"})}catch(e){P({type:"error",text:e.message})}finally{$(!1)}},ei=async()=>{O(!0),P(null);try{let e=await fetch("/api/cli-tools/droid-settings",{method:"DELETE"}),t=await e.json();e.ok?(P({type:"success",text:"Settings reset successfully!"}),z([]),es()):P({type:"error",text:t.error||"Failed to reset settings"})}catch(e){P({type:"error",text:e.message})}finally{O(!1)}};return(0,a.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3 hover:cursor-pointer sm:items-center",onClick:s,children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(i.A,{src:"/providers/droid.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===ee&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===ee&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===ee&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[C&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,a.jsx)("span",{children:"Checking Factory Droid CLI..."})]}),!C&&N&&!N.installed&&(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Factory Droid CLI not detected locally"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if 9router is deployed on a remote server."})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 pl-9",children:[(0,a.jsxs)(r.$n,{variant:"secondary",size:"sm",onClick:()=>G(!0),className:"!bg-yellow-500/20 !border-yellow-500/40 !text-yellow-700 dark:!text-yellow-300 hover:!bg-yellow-500/30",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:"content_copy"}),"Manual Config"]}),(0,a.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:()=>Y(!J),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:J?"expand_less":"help"}),J?"Hide":"How to Install"]})]})]}),J&&(0,a.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,a.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,a.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-text-muted mb-1",children:"macOS / Linux / Windows:"}),(0,a.jsx)("code",{className:"block px-3 py-2 bg-black/5 dark:bg-white/5 rounded font-mono text-xs",children:"curl -fsSL https://app.factory.ai/cli | sh"})]}),(0,a.jsxs)("p",{className:"text-text-muted",children:["After installation, run ",(0,a.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"droid"})," to verify."]})]})]})]}),!C&&N?.installed&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Select Endpoint"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(k,{value:V||((f=V||n).endsWith("/v1")?f:`${f}/v1`),onChange:Z,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:u,tunnelPublicUrl:p,tailscaleEnabled:h,tailscaleUrl:g,currentUrl:X})]}),N?.settings?.customModels?.find(e=>e.id?.startsWith("custom:9Router"))?.baseUrl&&(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Current"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)("span",{className:"min-w-0 truncate rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5",children:N.settings.customModels.find(e=>e.id?.startsWith("custom:9Router")).baseUrl})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(S,{value:R,onChange:I,apiKeys:d,cloudEnabled:m})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsxs)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:["Models ",U.length>0&&(0,a.jsxs)("span",{className:"text-primary",children:["(",U.length,")"]})]}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"flex-1 flex flex-col gap-1",children:[U.length>0&&(0,a.jsx)("div",{className:"flex flex-col gap-0.5 mb-1",children:U.map(e=>(0,a.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 bg-bg-secondary rounded border border-border",children:[(0,a.jsx)("span",{className:"flex-1 text-xs font-mono truncate",children:e}),(0,a.jsx)("button",{onClick:()=>z(t=>t.filter(t=>t!==e)),className:"text-text-muted hover:text-red-500 transition-colors shrink-0",title:"Remove",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"close"})})]},e))}),(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("input",{type:"text",value:L,onChange:e=>F(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),el())},placeholder:"provider/model-id",className:"w-full min-w-0 px-2 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),(0,a.jsx)("button",{onClick:()=>q(!0),disabled:!o,className:`px-2 py-1.5 rounded border text-xs shrink-0 ${o?"bg-surface border-border hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"}),(0,a.jsx)("button",{onClick:el,disabled:!L.trim(),className:"px-2 py-1.5 rounded border bg-surface border-border hover:border-primary text-xs shrink-0 disabled:opacity-50",title:"Add model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"add"})})]})]})]})]}),T&&(0,a.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===T.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===T.type?"check_circle":"error"}),(0,a.jsx)("span",{children:T.text})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,a.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:er,disabled:0===U.length,loading:A,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,a.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:ei,disabled:!N?.has9Router,loading:M,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,a.jsxs)(r.$n,{variant:"ghost",size:"sm",onClick:()=>G(!0),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),K&&(0,a.jsx)(r.rq,{isOpen:K,onClose:()=>q(!1),onSelect:e=>{!e.value||U.includes(e.value)||(z(t=>[...t,e.value]),q(!1))},selectedModel:null,activeProviders:c,modelAliases:B,title:"Select Model for Factory Droid"}),(0,a.jsx)(r.uR,{isOpen:W,onClose:()=>G(!1),title:"Factory Droid - Manual Configuration",configs:(b=R&&R.trim()?R:m?"<API_KEY_FROM_DASHBOARD>":"sk_9router",y={customModels:U.map((e,t)=>({model:e,id:`custom:9Router-${t}`,index:t,baseUrl:ea(),apiKey:b,displayName:e,maxOutputTokens:131072,noImageSupport:!1,provider:"openai"}))},v="u">typeof navigator&&navigator.platform,[{filename:v?.toLowerCase().includes("win")?"%USERPROFILE%\\.factory\\settings.json":"~/.factory/settings.json",content:JSON.stringify(y,null,2)}])})]})}function z({tool:e,isExpanded:t,onToggle:s,baseUrl:n,hasActiveProviders:o,apiKeys:d,activeProviders:c,cloudEnabled:m,initialStatus:x,tunnelEnabled:u,tunnelPublicUrl:p,tailscaleEnabled:h,tailscaleUrl:g}){let f,b,[y,v]=(0,l.useState)(x||null),[N,w]=(0,l.useState)(!1),[C,_]=(0,l.useState)(!1),[A,$]=(0,l.useState)(!1),[M,O]=(0,l.useState)(null),[T,P]=(0,l.useState)(""),[R,I]=(0,l.useState)(""),[U,D]=(0,l.useState)({}),[L,F]=(0,l.useState)(null),[K,q]=(0,l.useState)(!1),[B,H]=(0,l.useState)({}),[W,G]=(0,l.useState)(!1),[J,Y]=(0,l.useState)(""),V=(0,l.useRef)(!1),Z=y?.settings?.models?.providers?.["9router"]?.baseUrl||"",Q=(()=>{if(!y?.installed)return null;let e=y.settings?.models?.providers?.["9router"];return e?E(e.baseUrl,{tunnelPublicUrl:p,tailscaleUrl:g})?"configured":"other":"not_configured"})();(0,l.useEffect)(()=>{d?.length>0&&!T&&P(d[0].key)},[d,T]),(0,l.useEffect)(()=>{x&&v(x)},[x]),(0,l.useEffect)(()=>{t&&(y||ee(),X())},[t]);let X=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&H(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}};(0,l.useEffect)(()=>{if(y?.installed&&!V.current){V.current=!0;let e=y.settings?.models?.providers?.["9router"];if(e){let t=y.settings?.agents?.defaults?.model?.primary;t&&I(t.replace("9router/","")),e.apiKey&&d?.some(t=>t.key===e.apiKey)&&P(e.apiKey)}let t=y.agents||[],s={};t.forEach(e=>{e.currentModel&&(s[e.id]=e.currentModel)}),D(s)}},[y,d]);let ee=async()=>{w(!0);try{let e=await fetch("/api/cli-tools/openclaw-settings"),t=await e.json();v(t)}catch(e){v({installed:!1,error:e.message})}finally{w(!1)}},et=()=>window.location.origin.replace("://localhost","://127.0.0.1"),es=()=>{let e=J||et();return e.endsWith("/v1")?e:`${e}/v1`},ea=async()=>{_(!0),O(null);try{let e=T?.trim()||(d?.length>0?d[0].key:null)||(m?null:"sk_9router"),t=await fetch("/api/cli-tools/openclaw-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:es(),apiKey:e,model:R,agentModels:U})}),s=await t.json();t.ok?(j(es(),{tunnelPublicUrl:p,tailscaleUrl:g}),O({type:"success",text:"Settings applied successfully!"}),ee()):O({type:"error",text:s.error||"Failed to apply settings"})}catch(e){O({type:"error",text:e.message})}finally{_(!1)}},el=async()=>{$(!0),O(null);try{let e=await fetch("/api/cli-tools/openclaw-settings",{method:"DELETE"}),t=await e.json();e.ok?(O({type:"success",text:"Settings reset successfully!"}),I(""),P(""),ee()):O({type:"error",text:t.error||"Failed to reset settings"})}catch(e){O({type:"error",text:e.message})}finally{$(!1)}};return(0,a.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3 hover:cursor-pointer sm:items-center",onClick:s,children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(i.A,{src:"/providers/openclaw.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===Q&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===Q&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===Q&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[N&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,a.jsx)("span",{children:"Checking Open Claw CLI..."})]}),!N&&y&&!y.installed&&(0,a.jsx)("div",{className:"flex flex-col gap-4",children:(0,a.jsxs)("div",{className:"flex flex-col gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Open Claw CLI not detected locally"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if 9router is deployed on a remote server."})]})]}),(0,a.jsx)("div",{className:"flex items-center gap-2 pl-9",children:(0,a.jsxs)(r.$n,{variant:"secondary",size:"sm",onClick:()=>G(!0),className:"!bg-yellow-500/20 !border-yellow-500/40 !text-yellow-700 dark:!text-yellow-300 hover:!bg-yellow-500/30",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:"content_copy"}),"Manual Config"]})})]})}),!N&&y?.installed&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Select Endpoint"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(k,{value:J||((f=J||et()).endsWith("/v1")?f:`${f}/v1`),onChange:Y,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:u,tunnelPublicUrl:p,tailscaleEnabled:h,tailscaleUrl:g,currentUrl:Z})]}),y?.settings?.models?.providers?.["9router"]?.baseUrl&&(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Current"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)("span",{className:"min-w-0 truncate rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5",children:y.settings.models.providers["9router"].baseUrl})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(S,{value:T,onChange:P,apiKeys:d,cloudEnabled:m})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Default Model"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,a.jsx)("input",{type:"text",value:R,onChange:e=>I(e.target.value),placeholder:"provider/model-id",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),R&&(0,a.jsx)("button",{onClick:()=>I(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,a.jsx)("button",{onClick:()=>{F(null),q(!0)},disabled:!o,className:`w-full sm:w-auto rounded border px-2 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap sm:shrink-0 ${o?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"})]}),(y.agents||[]).filter(e=>e.agentDir).map(e=>(0,a.jsxs)("div",{className:"flex items-center gap-2 pl-4",children:[(0,a.jsxs)("span",{className:"w-32 shrink-0 text-xs text-primary text-right truncate",title:e.name||e.id,children:["Agent ",e.name||e.id]}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,a.jsx)("input",{type:"text",value:U[e.id]||"",onChange:t=>D(s=>({...s,[e.id]:t.target.value})),placeholder:`default (${R||"provider/model-id"})`,className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),U[e.id]&&(0,a.jsx)("button",{onClick:()=>D(t=>({...t,[e.id]:""})),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,a.jsx)("button",{onClick:()=>{F(e.id),q(!0)},disabled:!o,className:`w-full sm:w-auto rounded border px-2 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap sm:shrink-0 ${o?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"})]},e.id))]}),M&&(0,a.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===M.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===M.type?"check_circle":"error"}),(0,a.jsx)("span",{children:M.text})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,a.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:ea,disabled:!R,loading:C,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,a.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:el,disabled:!y?.has9Router,loading:A,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,a.jsxs)(r.$n,{variant:"ghost",size:"sm",onClick:()=>G(!0),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),K&&(0,a.jsx)(r.rq,{isOpen:K,onClose:()=>q(!1),onSelect:e=>{L?(D(t=>({...t,[L]:e.value})),F(null)):I(e.value),q(!1)},selectedModel:R,activeProviders:c,modelAliases:B,title:"Select Model for Open Claw"}),(0,a.jsx)(r.uR,{isOpen:W,onClose:()=>G(!1),title:"Open Claw - Manual Configuration",configs:(b=T&&T.trim()?T:m?"<API_KEY_FROM_DASHBOARD>":"sk_9router",[{filename:"~/.openclaw/openclaw.json",content:JSON.stringify({agents:{defaults:{model:{primary:`9router/${R||"provider/model-id"}`}}},models:{providers:{"9router":{baseUrl:es(),apiKey:b,api:"openai-completions",models:[{id:R||"provider/model-id",name:(R||"provider/model-id").split("/").pop()}]}}}},null,2)}])})]})}var L=s(3534);let F="/api/cli-tools/hermes-settings",K=L.dM.hermes?.roles||[];function q({tool:e,isExpanded:t,onToggle:s,baseUrl:n,hasActiveProviders:o,apiKeys:d,activeProviders:c,cloudEnabled:m,initialStatus:u,tunnelEnabled:p,tunnelPublicUrl:h,tailscaleEnabled:g,tailscaleUrl:f}){let b,y,v,N,w,C,[_,A]=(0,l.useState)(u||null),[$,M]=(0,l.useState)(!1),[O,T]=(0,l.useState)(!1),[P,R]=(0,l.useState)(!1),[I,U]=(0,l.useState)(null),[D,z]=(0,l.useState)(""),[L,B]=(0,l.useState)(""),[H,W]=(0,l.useState)({}),[G,J]=(0,l.useState)("default"),[Y,V]=(0,l.useState)(!1),[Z,Q]=(0,l.useState)({}),[X,ee]=(0,l.useState)(!1),[et,es]=(0,l.useState)(""),[ea,el]=(0,l.useState)([]),[er,ei]=(0,l.useState)("default"),[en,eo]=(0,l.useState)(!1),[ed,ec]=(0,l.useState)(""),[em,ex]=(0,l.useState)(!1),[eu,ep]=(0,l.useState)(""),eh=(0,l.useRef)(!1),eg=_?.settings?.model?.base_url||"",ef=(()=>{if(!_?.installed)return null;let e=_.settings?.model;return e?.base_url?E(e.base_url,{tunnelPublicUrl:h,tailscaleUrl:f})?"configured":"other":"not_configured"})(),eb={configured:"bg-green-500",other:"bg-blue-500",not_configured:"bg-yellow-500"},ey={configured:"Connected",other:"Other endpoint",not_configured:"Not configured"};(0,l.useEffect)(()=>{d?.length>0&&!D&&z(d[0].key)},[d,D]),(0,l.useEffect)(()=>{u&&A(u)},[u]);let ej=async()=>{try{let e=await fetch("/api/cli-tools/hermes-profiles"),t=await e.json();e.ok&&el(t.profiles||[])}catch(e){console.log("Error fetching hermes profiles:",e)}};(0,l.useEffect)(()=>{t&&(_||ew(),ev(),ej())},[t]);let ev=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&Q(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}};(0,l.useEffect)(()=>{if(_?.installed&&!eh.current){eh.current=!0;let e=_.settings?.model;B(e?.default||"");let t={};for(let[e,s]of(_.settings?.delegation?.model&&(t.delegation=_.settings.delegation.model),Object.entries(_.settings?.auxiliary||{})))s?.model&&(t[e]=s.model);W(t),ex(!!_.has9RouterStt),ep(_.has9RouterStt&&_.settings?.stt?.model||"")}},[_]);let eN=async e=>{try{await navigator.clipboard.writeText(e),ec(e),setTimeout(()=>ec(""),2e3)}catch(e){console.log("Copy failed",e)}},ew=async(e=er)=>{M(!0);try{let t=await fetch(`${F}?profile=${encodeURIComponent(e)}`),s=await t.json();t.ok?A(s):(U({type:"error",text:s.error||"Failed to load Hermes settings"}),404===t.status&&(ej(),ei("default")))}catch(e){A({installed:!1,error:e.message})}finally{M(!1)}},ek=()=>{let e=et||window.location.origin.replace("://localhost","://127.0.0.1");return e.endsWith("/v1")?e:`${e}/v1`},eC=()=>D?.trim()||(d?.length>0?d[0].key:null)||(m?null:"sk_9router"),e_=e=>"default"===e?"default profile":`profile "${e}"`,eS=async()=>{T(!0),U(null);try{let e=await fetch(F,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({profile:er,baseUrl:ek(),apiKey:eC(),selections:[{role:"default",model:L},...Object.entries(H).filter(([,e])=>e?.trim()).map(([e,t])=>({role:e,model:t.trim()}))],audio:{enabled:em,model:eu.trim()}})}),t=await e.json();e.ok?(j(ek(),{tunnelPublicUrl:h,tailscaleUrl:f}),U({type:"success",text:`Settings applied to ${e_(er)}!`}),ew(),ej()):U({type:"error",text:t.error||"Failed to apply settings"})}catch(e){U({type:"error",text:e.message})}finally{T(!1)}},eA=async()=>{let e=ek();if(!(E(e,{tunnelPublicUrl:h,tailscaleUrl:f})||x().some(t=>(t.baseUrl||"").replace(/\/+$/,"")===e.replace(/\/+$/,""))))return void U({type:"error",text:`"${e}" is not a 9router endpoint. Select the local, tunnel, Tailscale or a saved 9router endpoint before applying to all profiles.`});eo(!0),U(null);try{let t=await fetch(F,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({applyToAll:!0,baseUrl:e,apiKey:eC(),model:L})}),s=await t.json();if(t.ok&&s.bulk){j(e,{tunnelPublicUrl:h,tailscaleUrl:f});let t=(s.results||[]).filter(e=>"updated"!==e.status);if(0===t.length)U({type:"success",text:`Endpoint and API key applied to ${s.updated} profile(s).`});else{let e=t.map(e=>`${e.profile} — ${e.reason||e.status}`).join("; ");U({type:s.updated>0?"success":"error",text:`Updated ${s.updated} profile(s), skipped ${t.length}: ${e}`})}ej(),ew()}else U({type:"error",text:s.error||"Failed to apply settings"})}catch(e){U({type:"error",text:e.message})}finally{eo(!1)}},eE=async()=>{R(!0),U(null);try{let e=await fetch(F,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({profile:er})}),t=await e.json();e.ok?(U({type:"success",text:`Settings reset for ${e_(er)}!`}),B(""),W({}),ex(!1),ep(""),ew(),ej()):U({type:"error",text:t.error||"Failed to reset settings"})}catch(e){U({type:"error",text:e.message})}finally{R(!1)}},e$=e=>{J(e),V(!0)};return(0,a.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3 hover:cursor-pointer sm:items-center",onClick:s,children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(i.A,{src:"/providers/hermes.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===ef&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===ef&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===ef&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"}),"default"!==er&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-primary/10 text-primary rounded-full font-mono",title:"Hermes profile shown below",children:er})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[$&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,a.jsx)("span",{children:"Checking Hermes Agent..."})]}),!$&&_&&!_.installed&&(0,a.jsx)("div",{className:"flex flex-col gap-4",children:(0,a.jsxs)("div",{className:"flex flex-col gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Hermes Agent not detected locally"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Install: curl -fsSL https://raw.githubusercontent.com/NousResearch/hermes-agent/main/scripts/install.sh | bash"})]})]}),(0,a.jsx)("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 pl-0 sm:pl-9",children:(0,a.jsxs)(r.$n,{variant:"secondary",size:"sm",onClick:()=>ee(!0),className:"w-full sm:w-auto !bg-yellow-500/20 !border-yellow-500/40 !text-yellow-700 dark:!text-yellow-300 hover:!bg-yellow-500/30",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:"content_copy"}),"Manual Config"]})})]})}),!$&&_?.installed&&(0,a.jsxs)(a.Fragment,{children:[ea.length>1&&(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main mr-1",children:"Profile"}),ea.map(e=>{let t=e.name===er,s=e.has9Router||e.baseUrl&&E(e.baseUrl,{tunnelPublicUrl:h,tailscaleUrl:f})?"configured":e.baseUrl?"other":"not_configured";return(0,a.jsxs)("button",{onClick:()=>{var t;(t=e.name)!==er&&(ei(t),eh.current=!1,U(null),es(""),ex(!1),ep(""),ew(t))},title:e.isDefault?`Default profile — ${ey[s]}`:`${e.command} — ${ey[s]}`,className:`flex items-center gap-1.5 px-2 py-1 rounded border text-xs transition-colors ${t?"border-primary bg-primary/10 text-primary cursor-pointer":"bg-surface border-border text-text-muted hover:text-text-main hover:border-border-hover cursor-pointer"}`,children:[(0,a.jsx)("span",{className:`size-1.5 rounded-full shrink-0 ${eb[s]}`}),(0,a.jsx)("span",{className:"font-medium",children:e.displayName||e.name}),e.displayName&&!e.isDefault&&(0,a.jsx)("span",{className:"font-mono text-[10px] opacity-60",children:e.name})]},e.name)})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"terminal"}),(0,a.jsx)("code",{className:"px-1.5 py-0.5 bg-surface/60 rounded font-mono text-[11px]",children:ea.find(e=>e.name===er)?.command||"hermes"}),(0,a.jsx)("button",{onClick:()=>eN(ea.find(e=>e.name===er)?.command||"hermes"),className:`p-0.5 rounded transition-colors ${ed===(ea.find(e=>e.name===er)?.command||"hermes")?"text-green-600":"text-text-muted hover:text-text-main"}`,title:"Copy command",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:ed===(ea.find(e=>e.name===er)?.command||"hermes")?"check":"content_copy"})}),(0,a.jsx)("span",{className:"hidden sm:inline",children:"— every profile runs as its own agent with its own model."})]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Select Endpoint"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(k,{value:et||ek(),onChange:es,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:p,tunnelPublicUrl:h,tailscaleEnabled:g,tailscaleUrl:f,currentUrl:eg})]}),_?.settings?.model?.base_url&&(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Current"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)("span",{className:"min-w-0 truncate rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5",children:_.settings.model.base_url})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(S,{value:D,onChange:z,apiKeys:d,cloudEnabled:m})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Default Model"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,a.jsx)("input",{type:"text",value:L,onChange:e=>B(e.target.value),placeholder:"provider/model-id",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),L&&(0,a.jsx)("button",{onClick:()=>B(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,a.jsx)("button",{onClick:()=>e$("default"),disabled:!o,className:`w-full sm:w-auto rounded border px-2 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap sm:shrink-0 ${o?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Audio STT"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("label",{className:"flex items-center gap-2 text-xs text-text-muted cursor-pointer",title:"Route Hermes voice & audio transcription through 9router's /v1/audio/transcriptions — usage is tracked on this instance",children:[(0,a.jsx)("input",{type:"checkbox",checked:em,onChange:e=>ex(e.target.checked),className:"w-3.5 h-3.5 accent-primary cursor-pointer shrink-0"}),(0,a.jsx)("span",{children:"Transcribe voice & audio via 9router (per-profile)"})]}),(0,a.jsx)("span",{})]}),em&&(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"STT Model"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,a.jsx)("input",{type:"text",value:eu,onChange:e=>ep(e.target.value),placeholder:"provider/whisper-model-id",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),eu&&(0,a.jsx)("button",{onClick:()=>ep(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,a.jsx)("button",{onClick:()=>e$("stt"),disabled:!o,className:`w-full sm:w-auto rounded border px-2 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap sm:shrink-0 ${o?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"})]}),(0,a.jsxs)("details",{className:"group",children:[(0,a.jsxs)("summary",{className:"cursor-pointer select-none text-xs font-semibold text-text-main hover:text-primary transition-colors",children:[(0,a.jsx)("span",{className:"material-symbols-outlined align-middle text-[16px] text-text-muted group-open:rotate-90 transition-transform",children:"chevron_right"}),"Model Roles (optional)"]}),(0,a.jsxs)("div",{className:"mt-2 flex flex-col gap-1.5",children:[K.map(e=>(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"truncate text-xs font-semibold text-text-main sm:text-right sm:text-sm",title:e.label,children:e.label}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,a.jsx)("input",{type:"text",value:H[e.id]||"",onChange:t=>W(s=>({...s,[e.id]:t.target.value})),placeholder:"inherit default",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),H[e.id]&&(0,a.jsx)("button",{onClick:()=>W(t=>({...t,[e.id]:""})),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,a.jsx)("button",{onClick:()=>e$(e.id),disabled:!o,className:`w-full sm:w-auto rounded border px-2 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap sm:shrink-0 ${o?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"})]},e.id)),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Empty roles inherit the default model."})]})]})]}),I&&(0,a.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===I.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===I.type?"check_circle":"error"}),(0,a.jsx)("span",{children:I.text})]}),(0,a.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2",children:[(0,a.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:eS,disabled:!L||em&&!eu.trim(),title:em&&!eu.trim()?"Select an STT model first":void 0,loading:O,className:"w-full sm:w-auto",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),ea.length>1&&(0,a.jsxs)(r.$n,{variant:"secondary",size:"sm",onClick:eA,loading:en,title:"Set the endpoint and API key on every profile that routes through 9router. Each profile keeps its own model.",className:"w-full sm:w-auto",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"groups"}),"Apply to All Profiles"]}),(0,a.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:eE,disabled:!_?.has9Router&&!_?.has9RouterStt,loading:P,className:"w-full sm:w-auto",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,a.jsxs)(r.$n,{variant:"ghost",size:"sm",onClick:()=>ee(!0),className:"w-full sm:w-auto",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),Y&&(0,a.jsx)(r.rq,{isOpen:Y,onClose:()=>V(!1),onSelect:e=>{"stt"===G?ep(e.value):"default"===G?B(e.value):W(t=>({...t,[G]:e.value})),V(!1)},selectedModel:"stt"===G?eu:"default"===G?L:H[G]||"",activeProviders:c,modelAliases:Z,kindFilter:"stt"===G?"stt":void 0,title:"stt"===G?"Select STT Model — audio transcription via 9router":`Select Model for Hermes Agent${"default"!==G?` — ${K.find(e=>e.id===G)?.label||G}`:""}`}),(0,a.jsx)(r.uR,{isOpen:X,onClose:()=>ee(!1),title:"Hermes Agent - Manual Configuration",configs:(b=D&&D.trim()?D:m?"<API_KEY_FROM_DASHBOARD>":"sk_9router",y=ek(),v="default"===er?"~/.hermes":`~/.hermes/profiles/${er}`,N=ea.find(e=>e.name===er)?.command||"hermes",w=`# Run this profile: ${N}
|
|
58
|
+
`}])})]})}function D({tool:e,isExpanded:t,onToggle:s,baseUrl:n,hasActiveProviders:o,apiKeys:d,activeProviders:c,cloudEnabled:m,initialStatus:x,tunnelEnabled:u,tunnelPublicUrl:p,tailscaleEnabled:h,tailscaleUrl:g}){let f,b,y,v,[N,w]=(0,l.useState)(x||null),[C,S]=(0,l.useState)(!1),[A,$]=(0,l.useState)(!1),[M,O]=(0,l.useState)(!1),[T,P]=(0,l.useState)(null),[R,I]=(0,l.useState)(""),[U,z]=(0,l.useState)([]),[L,F]=(0,l.useState)(""),[K,q]=(0,l.useState)(!1),[B,H]=(0,l.useState)({}),[W,G]=(0,l.useState)(!1),[J,Y]=(0,l.useState)(!1),[V,Z]=(0,l.useState)(""),Q=(0,l.useRef)(!1),X=N?.settings?.customModels?.find(e=>e.id?.startsWith("custom:9Router"))?.baseUrl||"",ee=(()=>{if(!N?.installed)return null;let e=N.settings?.customModels?.find(e=>e.id?.startsWith("custom:9Router"));return e?E(e.baseUrl,{tunnelPublicUrl:p,tailscaleUrl:g,cloudUrl:m?"https://9router.com":null})?"configured":"other":"not_configured"})();(0,l.useEffect)(()=>{d?.length>0&&!R&&I(d[0].key)},[d,R]),(0,l.useEffect)(()=>{x&&w(x)},[x]),(0,l.useEffect)(()=>{t&&(N||es(),et())},[t]);let et=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&H(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}};(0,l.useEffect)(()=>{if(N?.installed&&!Q.current){Q.current=!0;let e=(N.settings?.customModels||[]).filter(e=>e.id?.startsWith("custom:9Router")).sort((e,t)=>(e.index||0)-(t.index||0)).map(e=>e.model);if(e.length>0)z(e);else{let e=N.settings?.customModels?.find(e=>"custom:9Router-0"===e.id);e?.model&&z([e.model])}}},[N]);let es=async()=>{S(!0);try{let e=await fetch("/api/cli-tools/droid-settings"),t=await e.json();w(t)}catch(e){w({installed:!1,error:e.message})}finally{S(!1)}},ea=()=>{let e=V||n;return e.endsWith("/v1")?e:`${e}/v1`},el=()=>{let e=L.trim();!e||U.includes(e)||(z(t=>[...t,e]),F(""))},er=async()=>{$(!0),P(null);try{let e=R?.trim()||(d?.length>0?d[0].key:null)||(m?null:"sk_9router"),t=await fetch("/api/cli-tools/droid-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:ea(),apiKey:e,models:U,activeModel:U[0]||""})}),s=await t.json();t.ok?(j(ea(),{tunnelPublicUrl:p,tailscaleUrl:g}),P({type:"success",text:"Settings applied successfully!"}),es()):P({type:"error",text:s.error||"Failed to apply settings"})}catch(e){P({type:"error",text:e.message})}finally{$(!1)}},ei=async()=>{O(!0),P(null);try{let e=await fetch("/api/cli-tools/droid-settings",{method:"DELETE"}),t=await e.json();e.ok?(P({type:"success",text:"Settings reset successfully!"}),z([]),es()):P({type:"error",text:t.error||"Failed to reset settings"})}catch(e){P({type:"error",text:e.message})}finally{O(!1)}};return(0,a.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3 hover:cursor-pointer sm:items-center",onClick:s,children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(i.A,{src:"/providers/droid.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===ee&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===ee&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===ee&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[C&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,a.jsx)("span",{children:"Checking Factory Droid CLI..."})]}),!C&&N&&!N.installed&&(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Factory Droid CLI not detected locally"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if 9router is deployed on a remote server."})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 pl-9",children:[(0,a.jsxs)(r.$n,{variant:"secondary",size:"sm",onClick:()=>G(!0),className:"!bg-yellow-500/20 !border-yellow-500/40 !text-yellow-700 dark:!text-yellow-300 hover:!bg-yellow-500/30",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:"content_copy"}),"Manual Config"]}),(0,a.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:()=>Y(!J),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:J?"expand_less":"help"}),J?"Hide":"How to Install"]})]})]}),J&&(0,a.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,a.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,a.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-text-muted mb-1",children:"macOS / Linux / Windows:"}),(0,a.jsx)("code",{className:"block px-3 py-2 bg-black/5 dark:bg-white/5 rounded font-mono text-xs",children:"curl -fsSL https://app.factory.ai/cli | sh"})]}),(0,a.jsxs)("p",{className:"text-text-muted",children:["After installation, run ",(0,a.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"droid"})," to verify."]})]})]})]}),!C&&N?.installed&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Select Endpoint"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(k,{value:V||((f=V||n).endsWith("/v1")?f:`${f}/v1`),onChange:Z,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:u,tunnelPublicUrl:p,tailscaleEnabled:h,tailscaleUrl:g,currentUrl:X})]}),N?.settings?.customModels?.find(e=>e.id?.startsWith("custom:9Router"))?.baseUrl&&(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Current"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)("span",{className:"min-w-0 truncate rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5",children:N.settings.customModels.find(e=>e.id?.startsWith("custom:9Router")).baseUrl})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(_,{value:R,onChange:I,apiKeys:d,cloudEnabled:m})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsxs)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:["Models ",U.length>0&&(0,a.jsxs)("span",{className:"text-primary",children:["(",U.length,")"]})]}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"flex-1 flex flex-col gap-1",children:[U.length>0&&(0,a.jsx)("div",{className:"flex flex-col gap-0.5 mb-1",children:U.map(e=>(0,a.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 bg-bg-secondary rounded border border-border",children:[(0,a.jsx)("span",{className:"flex-1 text-xs font-mono truncate",children:e}),(0,a.jsx)("button",{onClick:()=>z(t=>t.filter(t=>t!==e)),className:"text-text-muted hover:text-red-500 transition-colors shrink-0",title:"Remove",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"close"})})]},e))}),(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("input",{type:"text",value:L,onChange:e=>F(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),el())},placeholder:"provider/model-id",className:"w-full min-w-0 px-2 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),(0,a.jsx)("button",{onClick:()=>q(!0),disabled:!o,className:`px-2 py-1.5 rounded border text-xs shrink-0 ${o?"bg-surface border-border hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"}),(0,a.jsx)("button",{onClick:el,disabled:!L.trim(),className:"px-2 py-1.5 rounded border bg-surface border-border hover:border-primary text-xs shrink-0 disabled:opacity-50",title:"Add model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"add"})})]})]})]})]}),T&&(0,a.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===T.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===T.type?"check_circle":"error"}),(0,a.jsx)("span",{children:T.text})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,a.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:er,disabled:0===U.length,loading:A,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,a.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:ei,disabled:!N?.has9Router,loading:M,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,a.jsxs)(r.$n,{variant:"ghost",size:"sm",onClick:()=>G(!0),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),K&&(0,a.jsx)(r.rq,{isOpen:K,onClose:()=>q(!1),onSelect:e=>{!e.value||U.includes(e.value)||(z(t=>[...t,e.value]),q(!1))},selectedModel:null,activeProviders:c,modelAliases:B,title:"Select Model for Factory Droid"}),(0,a.jsx)(r.uR,{isOpen:W,onClose:()=>G(!1),title:"Factory Droid - Manual Configuration",configs:(b=R&&R.trim()?R:m?"<API_KEY_FROM_DASHBOARD>":"sk_9router",y={customModels:U.map((e,t)=>({model:e,id:`custom:9Router-${t}`,index:t,baseUrl:ea(),apiKey:b,displayName:e,maxOutputTokens:131072,noImageSupport:!1,provider:"openai"}))},v="u">typeof navigator&&navigator.platform,[{filename:v?.toLowerCase().includes("win")?"%USERPROFILE%\\.factory\\settings.json":"~/.factory/settings.json",content:JSON.stringify(y,null,2)}])})]})}function z({tool:e,isExpanded:t,onToggle:s,baseUrl:n,hasActiveProviders:o,apiKeys:d,activeProviders:c,cloudEnabled:m,initialStatus:x,tunnelEnabled:u,tunnelPublicUrl:p,tailscaleEnabled:h,tailscaleUrl:g}){let f,b,[y,v]=(0,l.useState)(x||null),[N,w]=(0,l.useState)(!1),[C,S]=(0,l.useState)(!1),[A,$]=(0,l.useState)(!1),[M,O]=(0,l.useState)(null),[T,P]=(0,l.useState)(""),[R,I]=(0,l.useState)(""),[U,D]=(0,l.useState)({}),[L,F]=(0,l.useState)(null),[K,q]=(0,l.useState)(!1),[B,H]=(0,l.useState)({}),[W,G]=(0,l.useState)(!1),[J,Y]=(0,l.useState)(""),V=(0,l.useRef)(!1),Z=y?.settings?.models?.providers?.["9router"]?.baseUrl||"",Q=(()=>{if(!y?.installed)return null;let e=y.settings?.models?.providers?.["9router"];return e?E(e.baseUrl,{tunnelPublicUrl:p,tailscaleUrl:g})?"configured":"other":"not_configured"})();(0,l.useEffect)(()=>{d?.length>0&&!T&&P(d[0].key)},[d,T]),(0,l.useEffect)(()=>{x&&v(x)},[x]),(0,l.useEffect)(()=>{t&&(y||ee(),X())},[t]);let X=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&H(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}};(0,l.useEffect)(()=>{if(y?.installed&&!V.current){V.current=!0;let e=y.settings?.models?.providers?.["9router"];if(e){let t=y.settings?.agents?.defaults?.model?.primary;t&&I(t.replace("9router/","")),e.apiKey&&d?.some(t=>t.key===e.apiKey)&&P(e.apiKey)}let t=y.agents||[],s={};t.forEach(e=>{e.currentModel&&(s[e.id]=e.currentModel)}),D(s)}},[y,d]);let ee=async()=>{w(!0);try{let e=await fetch("/api/cli-tools/openclaw-settings"),t=await e.json();v(t)}catch(e){v({installed:!1,error:e.message})}finally{w(!1)}},et=()=>window.location.origin.replace("://localhost","://127.0.0.1"),es=()=>{let e=J||et();return e.endsWith("/v1")?e:`${e}/v1`},ea=async()=>{S(!0),O(null);try{let e=T?.trim()||(d?.length>0?d[0].key:null)||(m?null:"sk_9router"),t=await fetch("/api/cli-tools/openclaw-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:es(),apiKey:e,model:R,agentModels:U})}),s=await t.json();t.ok?(j(es(),{tunnelPublicUrl:p,tailscaleUrl:g}),O({type:"success",text:"Settings applied successfully!"}),ee()):O({type:"error",text:s.error||"Failed to apply settings"})}catch(e){O({type:"error",text:e.message})}finally{S(!1)}},el=async()=>{$(!0),O(null);try{let e=await fetch("/api/cli-tools/openclaw-settings",{method:"DELETE"}),t=await e.json();e.ok?(O({type:"success",text:"Settings reset successfully!"}),I(""),P(""),ee()):O({type:"error",text:t.error||"Failed to reset settings"})}catch(e){O({type:"error",text:e.message})}finally{$(!1)}};return(0,a.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3 hover:cursor-pointer sm:items-center",onClick:s,children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(i.A,{src:"/providers/openclaw.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===Q&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===Q&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===Q&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[N&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,a.jsx)("span",{children:"Checking Open Claw CLI..."})]}),!N&&y&&!y.installed&&(0,a.jsx)("div",{className:"flex flex-col gap-4",children:(0,a.jsxs)("div",{className:"flex flex-col gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Open Claw CLI not detected locally"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if 9router is deployed on a remote server."})]})]}),(0,a.jsx)("div",{className:"flex items-center gap-2 pl-9",children:(0,a.jsxs)(r.$n,{variant:"secondary",size:"sm",onClick:()=>G(!0),className:"!bg-yellow-500/20 !border-yellow-500/40 !text-yellow-700 dark:!text-yellow-300 hover:!bg-yellow-500/30",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:"content_copy"}),"Manual Config"]})})]})}),!N&&y?.installed&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Select Endpoint"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(k,{value:J||((f=J||et()).endsWith("/v1")?f:`${f}/v1`),onChange:Y,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:u,tunnelPublicUrl:p,tailscaleEnabled:h,tailscaleUrl:g,currentUrl:Z})]}),y?.settings?.models?.providers?.["9router"]?.baseUrl&&(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Current"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)("span",{className:"min-w-0 truncate rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5",children:y.settings.models.providers["9router"].baseUrl})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(_,{value:T,onChange:P,apiKeys:d,cloudEnabled:m})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Default Model"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,a.jsx)("input",{type:"text",value:R,onChange:e=>I(e.target.value),placeholder:"provider/model-id",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),R&&(0,a.jsx)("button",{onClick:()=>I(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,a.jsx)("button",{onClick:()=>{F(null),q(!0)},disabled:!o,className:`w-full sm:w-auto rounded border px-2 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap sm:shrink-0 ${o?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"})]}),(y.agents||[]).filter(e=>e.agentDir).map(e=>(0,a.jsxs)("div",{className:"flex items-center gap-2 pl-4",children:[(0,a.jsxs)("span",{className:"w-32 shrink-0 text-xs text-primary text-right truncate",title:e.name||e.id,children:["Agent ",e.name||e.id]}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,a.jsx)("input",{type:"text",value:U[e.id]||"",onChange:t=>D(s=>({...s,[e.id]:t.target.value})),placeholder:`default (${R||"provider/model-id"})`,className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),U[e.id]&&(0,a.jsx)("button",{onClick:()=>D(t=>({...t,[e.id]:""})),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,a.jsx)("button",{onClick:()=>{F(e.id),q(!0)},disabled:!o,className:`w-full sm:w-auto rounded border px-2 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap sm:shrink-0 ${o?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"})]},e.id))]}),M&&(0,a.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===M.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===M.type?"check_circle":"error"}),(0,a.jsx)("span",{children:M.text})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,a.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:ea,disabled:!R,loading:C,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,a.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:el,disabled:!y?.has9Router,loading:A,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,a.jsxs)(r.$n,{variant:"ghost",size:"sm",onClick:()=>G(!0),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),K&&(0,a.jsx)(r.rq,{isOpen:K,onClose:()=>q(!1),onSelect:e=>{L?(D(t=>({...t,[L]:e.value})),F(null)):I(e.value),q(!1)},selectedModel:R,activeProviders:c,modelAliases:B,title:"Select Model for Open Claw"}),(0,a.jsx)(r.uR,{isOpen:W,onClose:()=>G(!1),title:"Open Claw - Manual Configuration",configs:(b=T&&T.trim()?T:m?"<API_KEY_FROM_DASHBOARD>":"sk_9router",[{filename:"~/.openclaw/openclaw.json",content:JSON.stringify({agents:{defaults:{model:{primary:`9router/${R||"provider/model-id"}`}}},models:{providers:{"9router":{baseUrl:es(),apiKey:b,api:"openai-completions",models:[{id:R||"provider/model-id",name:(R||"provider/model-id").split("/").pop()}]}}}},null,2)}])})]})}var L=s(3534);let F="/api/cli-tools/hermes-settings",K=L.dM.hermes?.roles||[];function q({tool:e,isExpanded:t,onToggle:s,baseUrl:n,hasActiveProviders:o,apiKeys:d,activeProviders:c,cloudEnabled:m,initialStatus:u,tunnelEnabled:p,tunnelPublicUrl:h,tailscaleEnabled:g,tailscaleUrl:f}){let b,y,v,N,w,C,[S,A]=(0,l.useState)(u||null),[$,M]=(0,l.useState)(!1),[O,T]=(0,l.useState)(!1),[P,R]=(0,l.useState)(!1),[I,U]=(0,l.useState)(null),[D,z]=(0,l.useState)(""),[L,B]=(0,l.useState)(""),[H,W]=(0,l.useState)({}),[G,J]=(0,l.useState)("default"),[Y,V]=(0,l.useState)(!1),[Z,Q]=(0,l.useState)({}),[X,ee]=(0,l.useState)(!1),[et,es]=(0,l.useState)(""),[ea,el]=(0,l.useState)([]),[er,ei]=(0,l.useState)("default"),[en,eo]=(0,l.useState)(!1),[ed,ec]=(0,l.useState)(""),[em,ex]=(0,l.useState)(!1),[eu,ep]=(0,l.useState)(""),eh=(0,l.useRef)(!1),eg=S?.settings?.model?.base_url||"",ef=(()=>{if(!S?.installed)return null;let e=S.settings?.model;return e?.base_url?E(e.base_url,{tunnelPublicUrl:h,tailscaleUrl:f})?"configured":"other":"not_configured"})(),eb={configured:"bg-green-500",other:"bg-blue-500",not_configured:"bg-yellow-500"},ey={configured:"Connected",other:"Other endpoint",not_configured:"Not configured"};(0,l.useEffect)(()=>{d?.length>0&&!D&&z(d[0].key)},[d,D]),(0,l.useEffect)(()=>{u&&A(u)},[u]);let ej=async()=>{try{let e=await fetch("/api/cli-tools/hermes-profiles"),t=await e.json();e.ok&&el(t.profiles||[])}catch(e){console.log("Error fetching hermes profiles:",e)}};(0,l.useEffect)(()=>{t&&(S||ew(),ev(),ej())},[t]);let ev=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&Q(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}};(0,l.useEffect)(()=>{if(S?.installed&&!eh.current){eh.current=!0;let e=S.settings?.model;B(e?.default||"");let t={};for(let[e,s]of(S.settings?.delegation?.model&&(t.delegation=S.settings.delegation.model),Object.entries(S.settings?.auxiliary||{})))s?.model&&(t[e]=s.model);W(t),ex(!!S.has9RouterStt),ep(S.has9RouterStt&&S.settings?.stt?.model||"")}},[S]);let eN=async e=>{try{await navigator.clipboard.writeText(e),ec(e),setTimeout(()=>ec(""),2e3)}catch(e){console.log("Copy failed",e)}},ew=async(e=er)=>{M(!0);try{let t=await fetch(`${F}?profile=${encodeURIComponent(e)}`),s=await t.json();t.ok?A(s):(U({type:"error",text:s.error||"Failed to load Hermes settings"}),404===t.status&&(ej(),ei("default")))}catch(e){A({installed:!1,error:e.message})}finally{M(!1)}},ek=()=>{let e=et||window.location.origin.replace("://localhost","://127.0.0.1");return e.endsWith("/v1")?e:`${e}/v1`},eC=()=>D?.trim()||(d?.length>0?d[0].key:null)||(m?null:"sk_9router"),eS=e=>"default"===e?"default profile":`profile "${e}"`,e_=async()=>{T(!0),U(null);try{let e=await fetch(F,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({profile:er,baseUrl:ek(),apiKey:eC(),selections:[{role:"default",model:L},...Object.entries(H).filter(([,e])=>e?.trim()).map(([e,t])=>({role:e,model:t.trim()}))],audio:{enabled:em,model:eu.trim()}})}),t=await e.json();e.ok?(j(ek(),{tunnelPublicUrl:h,tailscaleUrl:f}),U({type:"success",text:`Settings applied to ${eS(er)}!`}),ew(),ej()):U({type:"error",text:t.error||"Failed to apply settings"})}catch(e){U({type:"error",text:e.message})}finally{T(!1)}},eA=async()=>{let e=ek();if(!(E(e,{tunnelPublicUrl:h,tailscaleUrl:f})||x().some(t=>(t.baseUrl||"").replace(/\/+$/,"")===e.replace(/\/+$/,""))))return void U({type:"error",text:`"${e}" is not a 9router endpoint. Select the local, tunnel, Tailscale or a saved 9router endpoint before applying to all profiles.`});eo(!0),U(null);try{let t=await fetch(F,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({applyToAll:!0,baseUrl:e,apiKey:eC(),model:L})}),s=await t.json();if(t.ok&&s.bulk){j(e,{tunnelPublicUrl:h,tailscaleUrl:f});let t=(s.results||[]).filter(e=>"updated"!==e.status);if(0===t.length)U({type:"success",text:`Endpoint and API key applied to ${s.updated} profile(s).`});else{let e=t.map(e=>`${e.profile} — ${e.reason||e.status}`).join("; ");U({type:s.updated>0?"success":"error",text:`Updated ${s.updated} profile(s), skipped ${t.length}: ${e}`})}ej(),ew()}else U({type:"error",text:s.error||"Failed to apply settings"})}catch(e){U({type:"error",text:e.message})}finally{eo(!1)}},eE=async()=>{R(!0),U(null);try{let e=await fetch(F,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({profile:er})}),t=await e.json();e.ok?(U({type:"success",text:`Settings reset for ${eS(er)}!`}),B(""),W({}),ex(!1),ep(""),ew(),ej()):U({type:"error",text:t.error||"Failed to reset settings"})}catch(e){U({type:"error",text:e.message})}finally{R(!1)}},e$=e=>{J(e),V(!0)};return(0,a.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3 hover:cursor-pointer sm:items-center",onClick:s,children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(i.A,{src:"/providers/hermes.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===ef&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===ef&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===ef&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"}),"default"!==er&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-primary/10 text-primary rounded-full font-mono",title:"Hermes profile shown below",children:er})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[$&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,a.jsx)("span",{children:"Checking Hermes Agent..."})]}),!$&&S&&!S.installed&&(0,a.jsx)("div",{className:"flex flex-col gap-4",children:(0,a.jsxs)("div",{className:"flex flex-col gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Hermes Agent not detected locally"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Install: curl -fsSL https://raw.githubusercontent.com/NousResearch/hermes-agent/main/scripts/install.sh | bash"})]})]}),(0,a.jsx)("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 pl-0 sm:pl-9",children:(0,a.jsxs)(r.$n,{variant:"secondary",size:"sm",onClick:()=>ee(!0),className:"w-full sm:w-auto !bg-yellow-500/20 !border-yellow-500/40 !text-yellow-700 dark:!text-yellow-300 hover:!bg-yellow-500/30",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:"content_copy"}),"Manual Config"]})})]})}),!$&&S?.installed&&(0,a.jsxs)(a.Fragment,{children:[ea.length>1&&(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main mr-1",children:"Profile"}),ea.map(e=>{let t=e.name===er,s=e.has9Router||e.baseUrl&&E(e.baseUrl,{tunnelPublicUrl:h,tailscaleUrl:f})?"configured":e.baseUrl?"other":"not_configured";return(0,a.jsxs)("button",{onClick:()=>{var t;(t=e.name)!==er&&(ei(t),eh.current=!1,U(null),es(""),ex(!1),ep(""),ew(t))},title:e.isDefault?`Default profile — ${ey[s]}`:`${e.command} — ${ey[s]}`,className:`flex items-center gap-1.5 px-2 py-1 rounded border text-xs transition-colors ${t?"border-primary bg-primary/10 text-primary cursor-pointer":"bg-surface border-border text-text-muted hover:text-text-main hover:border-border-hover cursor-pointer"}`,children:[(0,a.jsx)("span",{className:`size-1.5 rounded-full shrink-0 ${eb[s]}`}),(0,a.jsx)("span",{className:"font-medium",children:e.displayName||e.name}),e.displayName&&!e.isDefault&&(0,a.jsx)("span",{className:"font-mono text-[10px] opacity-60",children:e.name})]},e.name)})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"terminal"}),(0,a.jsx)("code",{className:"px-1.5 py-0.5 bg-surface/60 rounded font-mono text-[11px]",children:ea.find(e=>e.name===er)?.command||"hermes"}),(0,a.jsx)("button",{onClick:()=>eN(ea.find(e=>e.name===er)?.command||"hermes"),className:`p-0.5 rounded transition-colors ${ed===(ea.find(e=>e.name===er)?.command||"hermes")?"text-green-600":"text-text-muted hover:text-text-main"}`,title:"Copy command",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:ed===(ea.find(e=>e.name===er)?.command||"hermes")?"check":"content_copy"})}),(0,a.jsx)("span",{className:"hidden sm:inline",children:"— every profile runs as its own agent with its own model."})]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Select Endpoint"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(k,{value:et||ek(),onChange:es,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:p,tunnelPublicUrl:h,tailscaleEnabled:g,tailscaleUrl:f,currentUrl:eg})]}),S?.settings?.model?.base_url&&(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Current"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)("span",{className:"min-w-0 truncate rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5",children:S.settings.model.base_url})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(_,{value:D,onChange:z,apiKeys:d,cloudEnabled:m})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Default Model"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,a.jsx)("input",{type:"text",value:L,onChange:e=>B(e.target.value),placeholder:"provider/model-id",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),L&&(0,a.jsx)("button",{onClick:()=>B(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,a.jsx)("button",{onClick:()=>e$("default"),disabled:!o,className:`w-full sm:w-auto rounded border px-2 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap sm:shrink-0 ${o?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Audio STT"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("label",{className:"flex items-center gap-2 text-xs text-text-muted cursor-pointer",title:"Route Hermes voice & audio transcription through 9router's /v1/audio/transcriptions — usage is tracked on this instance",children:[(0,a.jsx)("input",{type:"checkbox",checked:em,onChange:e=>ex(e.target.checked),className:"w-3.5 h-3.5 accent-primary cursor-pointer shrink-0"}),(0,a.jsx)("span",{children:"Transcribe voice & audio via 9router (per-profile)"})]}),(0,a.jsx)("span",{})]}),em&&(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"STT Model"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,a.jsx)("input",{type:"text",value:eu,onChange:e=>ep(e.target.value),placeholder:"provider/whisper-model-id",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),eu&&(0,a.jsx)("button",{onClick:()=>ep(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,a.jsx)("button",{onClick:()=>e$("stt"),disabled:!o,className:`w-full sm:w-auto rounded border px-2 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap sm:shrink-0 ${o?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"})]}),(0,a.jsxs)("details",{className:"group",children:[(0,a.jsxs)("summary",{className:"cursor-pointer select-none text-xs font-semibold text-text-main hover:text-primary transition-colors",children:[(0,a.jsx)("span",{className:"material-symbols-outlined align-middle text-[16px] text-text-muted group-open:rotate-90 transition-transform",children:"chevron_right"}),"Model Roles (optional)"]}),(0,a.jsxs)("div",{className:"mt-2 flex flex-col gap-1.5",children:[K.map(e=>(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"truncate text-xs font-semibold text-text-main sm:text-right sm:text-sm",title:e.label,children:e.label}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,a.jsx)("input",{type:"text",value:H[e.id]||"",onChange:t=>W(s=>({...s,[e.id]:t.target.value})),placeholder:"inherit default",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),H[e.id]&&(0,a.jsx)("button",{onClick:()=>W(t=>({...t,[e.id]:""})),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,a.jsx)("button",{onClick:()=>e$(e.id),disabled:!o,className:`w-full sm:w-auto rounded border px-2 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap sm:shrink-0 ${o?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"})]},e.id)),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Empty roles inherit the default model."})]})]})]}),I&&(0,a.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===I.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===I.type?"check_circle":"error"}),(0,a.jsx)("span",{children:I.text})]}),(0,a.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2",children:[(0,a.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:e_,disabled:!L||em&&!eu.trim(),title:em&&!eu.trim()?"Select an STT model first":void 0,loading:O,className:"w-full sm:w-auto",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),ea.length>1&&(0,a.jsxs)(r.$n,{variant:"secondary",size:"sm",onClick:eA,loading:en,title:"Set the endpoint and API key on every profile that routes through 9router. Each profile keeps its own model.",className:"w-full sm:w-auto",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"groups"}),"Apply to All Profiles"]}),(0,a.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:eE,disabled:!S?.has9Router&&!S?.has9RouterStt,loading:P,className:"w-full sm:w-auto",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,a.jsxs)(r.$n,{variant:"ghost",size:"sm",onClick:()=>ee(!0),className:"w-full sm:w-auto",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),Y&&(0,a.jsx)(r.rq,{isOpen:Y,onClose:()=>V(!1),onSelect:e=>{"stt"===G?ep(e.value):"default"===G?B(e.value):W(t=>({...t,[G]:e.value})),V(!1)},selectedModel:"stt"===G?eu:"default"===G?L:H[G]||"",activeProviders:c,modelAliases:Z,kindFilter:"stt"===G?"stt":void 0,title:"stt"===G?"Select STT Model — audio transcription via 9router":`Select Model for Hermes Agent${"default"!==G?` — ${K.find(e=>e.id===G)?.label||G}`:""}`}),(0,a.jsx)(r.uR,{isOpen:X,onClose:()=>ee(!1),title:"Hermes Agent - Manual Configuration",configs:(b=D&&D.trim()?D:m?"<API_KEY_FROM_DASHBOARD>":"sk_9router",y=ek(),v="default"===er?"~/.hermes":`~/.hermes/profiles/${er}`,N=ea.find(e=>e.name===er)?.command||"hermes",w=`# Run this profile: ${N}
|
|
59
59
|
model:
|
|
60
60
|
default: "${L||"provider/model-id"}"
|
|
61
61
|
provider: "custom"
|
|
@@ -80,11 +80,11 @@ ${C.map(([e,t])=>` ${e}:
|
|
|
80
80
|
base_url: "${y}"
|
|
81
81
|
api_key: $\{OPENAI_API_KEY}
|
|
82
82
|
`),[{filename:`${v}/config.yaml`,content:w},{filename:`${v}/.env`,content:`OPENAI_API_KEY=${b}
|
|
83
|
-
`}])})]})}var B=s(8247),H=s(11059);function W({toolId:e,tool:t,isExpanded:s,onToggle:n,baseUrl:o,apiKeys:d,activeProviders:c=[],cloudEnabled:m=!1,tunnelEnabled:x=!1}){let[u,p]=(0,l.useState)(null),[h,g]=(0,l.useState)(!1),[f,b]=(0,l.useState)(""),[y,j]=(0,l.useState)(()=>d?.length>0?d[0].key:""),v=e=>{let t=y&&y.trim()?y:m?"your-api-key":"sk_9router",s=o||"http://localhost:20128",a=s.endsWith("/v1")?s:`${s}/v1`;return e.replace(/\{\{baseUrl\}\}/g,a).replace(/\{\{apiKey\}\}/g,t).replace(/\{\{model\}\}/g,f||"provider/model-id")},{copy:N}=(0,H.C)(),w=async(e,t)=>{await N(v(e),`toolcard-${t}`),p(t),setTimeout(()=>p(null),2e3)},k=c.length>0,C=()=>(!t.requiresExternalUrl||!!m||!!x)&&(!t.requiresCloud||!!m);return(0,a.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden overflow-x-hidden",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between hover:cursor-pointer",onClick:n,children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 rounded-lg flex items-center justify-center shrink-0",children:(()=>{if(t.image)return(0,a.jsx)(i.A,{src:t.image,alt:t.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"},loading:"lazy",decoding:"async"});if(t.icon)return(0,a.jsx)("span",{className:"material-symbols-outlined text-xl",style:{color:t.color},children:t.icon});let s=(0,B.HY)(e);return s?(0,a.jsx)(i.A,{src:s,alt:t.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:t=>{(0,B.Kw)(e),t.target.style.display="none"},loading:"lazy",decoding:"async"}):(0,a.jsx)("span",{className:"text-xs font-bold",style:{color:t.color},children:(e||"?").slice(0,2).toUpperCase()})})()}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:t.name}),(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:t.description})]})]}),(0,a.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${s?"rotate-180":""}`,children:"expand_more"})]}),s&&(0,a.jsx)("div",{className:"mt-6 pt-6 border-t border-border",children:t.guideSteps?(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[t.notes&&0!==t.notes.length?(0,a.jsx)("div",{className:"flex flex-col gap-2 mb-4",children:t.notes.map((e,t)=>{if("cloudCheck"===e.type&&(m||x))return null;let s="warning"===e.type,l="cloudCheck"===e.type&&!m&&!x,r="bg-blue-500/10 border-blue-500/30",i="text-blue-600 dark:text-blue-400",n="text-blue-500",o="info";return s?(r="bg-yellow-500/10 border-yellow-500/30",i="text-yellow-600 dark:text-yellow-400",n="text-yellow-500",o="warning"):l&&(r="bg-red-500/10 border-red-500/30",i="text-red-600 dark:text-red-400",n="text-red-500",o="error"),(0,a.jsxs)("div",{className:`flex items-start gap-3 p-3 rounded-lg border ${r}`,children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-lg ${n}`,children:o}),(0,a.jsx)("p",{className:`text-sm ${i}`,children:e.text})]},t)})}):null,C()&&t.guideSteps.map(e=>(0,a.jsxs)("div",{className:"flex items-start gap-4",children:[(0,a.jsx)("div",{className:"size-8 rounded-full flex items-center justify-center shrink-0 text-sm font-semibold text-white",style:{backgroundColor:t.color},children:e.step}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"font-medium text-text",children:e.title}),e.desc&&(0,a.jsx)("p",{className:"text-sm text-text-muted mt-0.5",children:e.desc}),"apiKeySelector"===e.type&&(0,a.jsx)("div",{className:"mt-2 flex flex-col sm:flex-row sm:items-center gap-2",children:(0,a.jsx)(S,{value:y,onChange:j,apiKeys:d,cloudEnabled:m,className:"flex-1"})}),"modelSelector"===e.type&&(0,a.jsxs)("div",{className:"mt-2 flex flex-col sm:flex-row sm:items-center gap-2",children:[(0,a.jsx)("input",{type:"text",value:f,onChange:e=>b(e.target.value),placeholder:"provider/model-id",className:"w-full sm:w-auto flex-1 px-3 py-2 bg-bg-secondary rounded-lg text-sm border border-border focus:outline-none focus:ring-1 focus:ring-primary/50"}),(0,a.jsx)("button",{onClick:()=>g(!0),disabled:!k,className:`shrink-0 px-3 py-2 rounded-lg border text-sm transition-colors ${k?"bg-bg-secondary border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"}),f&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("button",{onClick:()=>w(f,"model"),className:"shrink-0 px-3 py-2 bg-bg-secondary hover:bg-bg-tertiary rounded-lg border border-border transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-lg",children:"model"===u?"check":"content_copy"})}),(0,a.jsx)("button",{onClick:()=>b(""),className:"p-2 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-lg",children:"close"})})]})]}),e.value&&(0,a.jsxs)("div",{className:"mt-2 flex flex-col sm:flex-row sm:items-center gap-2",children:[(0,a.jsx)("code",{className:"w-full sm:w-auto flex-1 px-3 py-2 bg-bg-secondary rounded-lg text-sm font-mono border border-border truncate",children:v(e.value)}),e.copyable&&(0,a.jsx)("button",{onClick:()=>w(e.value,`${e.step}-${e.title}`),className:"shrink-0 px-3 py-2 bg-bg-secondary hover:bg-bg-tertiary rounded-lg border border-border transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-lg",children:u===`${e.step}-${e.title}`?"check":"content_copy"})})]})]})]},e.step)),C()&&t.codeBlock&&(0,a.jsxs)("div",{className:"mt-2",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,a.jsx)("span",{className:"text-xs text-text-muted uppercase tracking-wide",children:t.codeBlock.language}),(0,a.jsxs)("button",{onClick:()=>w(t.codeBlock.code,"codeblock"),className:"flex items-center gap-1 px-2 py-1 text-xs bg-bg-secondary hover:bg-bg-tertiary rounded border border-border transition-colors",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"codeblock"===u?"check":"content_copy"}),"codeblock"===u?"Copied!":"Copy"]})]}),(0,a.jsx)("pre",{className:"p-4 bg-bg-secondary rounded-lg border border-border overflow-x-auto",children:(0,a.jsx)("code",{className:"text-sm font-mono whitespace-pre",children:v(t.codeBlock.code)})})]})]}):(0,a.jsx)("p",{className:"text-text-muted text-sm",children:"Coming soon..."})}),h&&(0,a.jsx)(r.rq,{isOpen:h,onClose:()=>g(!1),onSelect:e=>{b(e.value)},selectedModel:f,activeProviders:c,title:"Select Model"})]})}let G="round-robin",J=[{value:"round-robin",label:"Round-Robin"},{value:"fallback",label:"Fallback"}];function Y({tool:e,mappings:t,strategy:s=G,dnsActive:l=!0,hasActiveProviders:i,onChangeEntry:n,onBlurEntry:o,onOpenSelector:d,onAddEntry:c,onRemoveEntry:m,onReorderEntry:x,onChangeStrategy:u,feedback:p,compact:h=!1}){let g=h?"w-32 shrink-0 text-sm font-semibold text-text-main text-right":"w-36 shrink-0 text-xs font-semibold text-text-main text-right",f=h?"px-2 py-1.5 rounded border text-xs transition-colors shrink-0 whitespace-nowrap":"px-2 py-1.5 rounded border text-xs transition-colors shrink-0",b="h-8 min-w-8 inline-flex items-center justify-center rounded-md border border-border text-text-muted transition-colors",y=h?"h-8 px-2.5 inline-flex items-center justify-center rounded-md border border-border text-[11px] font-medium text-text-main transition-colors shrink-0 whitespace-nowrap":"h-8 px-2.5 inline-flex items-center justify-center rounded-md border border-border text-[11px] font-medium text-text-main transition-colors shrink-0",j=!l;return(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsx)("div",{className:"rounded-xl border border-border/70 bg-surface/60 p-3",children:(0,a.jsxs)("div",{className:"flex flex-col gap-1 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-xs font-semibold text-text-main",children:"Routing strategy"}),(0,a.jsx)("p",{className:"text-[11px] text-text-muted",children:"Round-robin spreads load. Fallback keeps priority order."}),(0,a.jsx)("p",{className:"text-[10px] text-text-muted mt-1",children:"Tip: paste comma-separated models into one row to expand multiple targets at once."})]}),(0,a.jsx)("div",{className:"sm:w-44",children:(0,a.jsx)(r.l6,{value:s,onChange:e=>u(e.target.value),disabled:j,options:J,selectClassName:"py-1.5 px-2 pr-8 text-xs bg-surface border-border","aria-label":`${e.name} MITM strategy`})})]})}),p&&(0,a.jsx)("div",{className:"rounded-lg border border-primary/20 bg-primary/5 px-3 py-2 text-[11px] text-text-muted",children:p}),(0,a.jsx)("div",{className:"flex flex-col gap-2",children:e.defaultModels?.map(e=>{let s=Array.isArray(t?.[e.alias])?t[e.alias]:[],r=l&&s.length<5;return(0,a.jsx)("div",{className:"rounded-xl border border-border/70 bg-surface/40 p-3",children:(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)("div",{className:g,children:(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,a.jsx)("span",{children:e.name}),(0,a.jsxs)("span",{className:"text-[10px] font-normal text-text-muted",children:["Max ",5," targets"]})]})}),(0,a.jsxs)("div",{className:"flex-1 flex flex-col gap-2",children:[s.length>0?s.map((t,l)=>{let r=j||0===l,c=j||l===s.length-1;return(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-6 text-center text-[11px] font-semibold text-text-muted",children:l+1}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,a.jsx)("input",{type:"text",value:t,onChange:t=>n(e.alias,l,t.target.value),onBlur:t=>o(e.alias,l,t.target.value),placeholder:"provider/model-id",disabled:j,className:`flex-1 px-2 py-1.5 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 ${j?"opacity-50 cursor-not-allowed":""}`}),(0,a.jsx)("button",{type:"button",onClick:()=>d(e.alias,l),disabled:!i||j,className:`${y} ${i&&!j?"hover:border-primary hover:text-primary cursor-pointer":"opacity-40 cursor-not-allowed"}`,title:"Select model",children:"Select"}),(0,a.jsx)("button",{type:"button",onClick:()=>x(e.alias,l,l-1),disabled:r,className:`${b} ${r?"opacity-40 cursor-not-allowed":"hover:border-primary hover:text-primary cursor-pointer"}`,title:"Move up",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"keyboard_arrow_up"})}),(0,a.jsx)("button",{type:"button",onClick:()=>x(e.alias,l,l+1),disabled:c,className:`${b} ${c?"opacity-40 cursor-not-allowed":"hover:border-primary hover:text-primary cursor-pointer"}`,title:"Move down",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"keyboard_arrow_down"})}),(0,a.jsx)("button",{type:"button",onClick:()=>m(e.alias,l),disabled:j,className:`${b} ${j?"opacity-40 cursor-not-allowed":"hover:border-red-500 hover:text-red-500 cursor-pointer"}`,title:"Remove",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"close"})})]},`${e.alias}-${l}`)}):(0,a.jsx)("div",{className:"rounded-lg border border-dashed border-border px-3 py-2 text-[11px] text-text-muted",children:"No mapping — passthrough"}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2 pl-8",children:[(0,a.jsx)("button",{type:"button",onClick:()=>c(e.alias),disabled:!r,className:`${f} ${r?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"+ Add"}),(0,a.jsxs)("span",{className:"text-[10px] text-text-muted",children:[s.length,"/",5," mapped"]})]})]})]})},e.alias)})})]})}function V(e){return Array.isArray(e)?e.map(e=>"string"==typeof e?e.trim():"").filter(Boolean).slice(0,5):"string"==typeof e&&e.trim()?[e.trim()]:[]}function Z(e){return Object.fromEntries(Object.entries(e||{}).map(([e,t])=>[e,V(t)]).filter(([,e])=>e.length>0))}function Q(e,t,s){let a="string"==typeof s?s.trim():"";if(!t||!a)return e;let l=V(e?.[t]);return l.length>=5?e:{...e,[t]:[...l,a]}}function X(e,t,s,a){let l=Array.isArray(e?.[t])?[...e[t]]:[];return s<0||s>=l.length?e:(l[s]=a,{...e,[t]:l})}function ee(e){return"fallback"===(e||G)?"fallback":G}function et({tool:e,isExpanded:t,onToggle:s,baseUrl:n,apiKeys:o,activeProviders:d,cloudEnabled:c,initialStatus:m,tunnelEnabled:x,tunnelPublicUrl:u,tailscaleEnabled:p,tailscaleUrl:h}){let g,f,b,y,v,[N,w]=(0,l.useState)(m||null),[C,_]=(0,l.useState)(!1),[A,$]=(0,l.useState)(!1),[M,O]=(0,l.useState)(!1),[T,P]=(0,l.useState)(null),[R,I]=(0,l.useState)(!1),[U,D]=(0,l.useState)(""),[z,L]=(0,l.useState)(""),[F,K]=(0,l.useState)(""),[q,B]=(0,l.useState)(!1),[H,W]=(0,l.useState)(!1),[G,J]=(0,l.useState)({}),[Y,V]=(0,l.useState)(!1),[Z,Q]=(0,l.useState)(""),[X,ee]=(0,l.useState)([]),[es,ea]=(0,l.useState)(""),el=(0,l.useRef)([]);(0,l.useEffect)(()=>{el.current=X},[X]),(0,l.useEffect)(()=>{o?.length>0&&!U&&D(o[0].key)},[o,U]),(0,l.useEffect)(()=>{m&&w(m)},[m]),(0,l.useEffect)(()=>{t&&(N||ec(),er())},[t]),(0,l.useEffect)(()=>{N?.opencode?.models&&ee(N.opencode.models),N?.opencode?.activeModel&&ea(N.opencode.activeModel),N?.config?.agent?.explorer?.model?.startsWith("9router/")&&K(N.config.agent.explorer.model.replace("9router/",""))},[N]);let er=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&J(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}},ei=async e=>{try{let t=U&&U.trim()||c?U:"sk_9router",s=e.includes(es)?es:e[0]||"";await fetch("/api/cli-tools/opencode-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:ed(),apiKey:t,models:e,activeModel:s,subagentModel:F})})}catch(e){console.log("Error saving models:",e)}},en=N?.config?.provider?.["9router"]?.options?.baseURL||"",eo=N?.installed?N.config&&N.has9Router?E(N.config?.provider?.["9router"]?.options?.baseURL||"",{tunnelPublicUrl:u,tailscaleUrl:h})?"configured":"other":"not_configured":null,ed=()=>{let e=Z||n;return e.endsWith("/v1")?e:`${e}/v1`},ec=async()=>{_(!0);try{let e=await fetch("/api/cli-tools/opencode-settings"),t=await e.json();w(t)}catch(e){w({installed:!1,error:e.message})}finally{_(!1)}},em=async()=>{$(!0),P(null);try{let e=U&&U.trim()||c?U:"sk_9router",t=await fetch("/api/cli-tools/opencode-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:ed(),apiKey:e,models:X,activeModel:""===es?"":es||X[0],subagentModel:F})}),s=await t.json();t.ok?(j(ed(),{tunnelPublicUrl:u,tailscaleUrl:h}),P({type:"success",text:"Settings applied successfully!"}),ec()):P({type:"error",text:s.error||"Failed to apply settings"})}catch(e){P({type:"error",text:e.message})}finally{$(!1)}},ex=async()=>{O(!0),P(null);try{let e=await fetch("/api/cli-tools/opencode-settings",{method:"DELETE"}),t=await e.json();e.ok?(P({type:"success",text:"Settings reset successfully!"}),L(""),K(""),ee([]),ea(""),ec()):P({type:"error",text:t.error||"Failed to reset settings"})}catch(e){P({type:"error",text:e.message})}finally{O(!1)}};return(0,a.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3 hover:cursor-pointer sm:items-center",onClick:s,children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(i.A,{src:"/providers/opencode.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===eo&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===eo&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===eo&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[C&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,a.jsx)("span",{children:"Checking OpenCode CLI..."})]}),!C&&N&&!N.installed&&(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"OpenCode CLI not detected locally"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if 9router is deployed on a remote server."})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 pl-9",children:[(0,a.jsxs)(r.$n,{variant:"secondary",size:"sm",onClick:()=>V(!0),className:"!bg-yellow-500/20 !border-yellow-500/40 !text-yellow-700 dark:!text-yellow-300 hover:!bg-yellow-500/30",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:"content_copy"}),"Manual Config"]}),(0,a.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:()=>I(!R),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:R?"expand_less":"help"}),R?"Hide":"How to Install"]})]})]}),R&&(0,a.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,a.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,a.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-text-muted mb-1",children:"macOS / Linux:"}),(0,a.jsx)("code",{className:"block px-3 py-2 bg-black/5 dark:bg-white/5 rounded font-mono text-xs",children:"npm install -g opencode-ai"})]}),(0,a.jsxs)("p",{className:"text-text-muted",children:["After installation, run ",(0,a.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"opencode"})," to verify."]})]})]})]}),!C&&N?.installed&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Select Endpoint"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(k,{value:Z||Z||`${n}/v1`,onChange:Q,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:x,tunnelPublicUrl:u,tailscaleEnabled:p,tailscaleUrl:h,currentUrl:en})]}),N?.config?.provider?.["9router"]?.options?.baseURL&&(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Current"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)("span",{className:"min-w-0 truncate rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5",children:N.config.provider["9router"].options.baseURL})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(S,{value:U,onChange:D,apiKeys:o,cloudEnabled:c})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-start sm:gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right pt-1",children:"Models"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px] mt-1.5",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"flex-1 flex flex-col gap-2",children:[(0,a.jsx)("div",{className:"flex flex-wrap gap-1.5 min-h-[28px] px-2 py-1.5 bg-surface rounded border border-border",children:0===X.length?(0,a.jsx)("span",{className:"text-xs text-text-muted",children:"No models selected"}):X.map(e=>(0,a.jsxs)("span",{onClick:async()=>{if(e===es)try{(await fetch("/api/cli-tools/opencode-settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({clearActiveModel:!0})})).ok&&(ea(""),ec())}catch(e){console.log("Error clearing active model:",e)}else ea(e)},className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs cursor-pointer transition-colors ${e===es?"bg-primary/10 text-primary border border-primary":"bg-black/5 dark:bg-white/5 text-text-muted border border-transparent hover:border-border"}`,title:e===es?"Click to clear active model":"Click to set as active",children:[e===es&&(0,a.jsx)("span",{className:"material-symbols-outlined text-[10px]",children:"star"}),e,(0,a.jsx)("button",{onClick:async t=>{t.stopPropagation();try{if((await fetch(`/api/cli-tools/opencode-settings?model=${encodeURIComponent(e)}`,{method:"DELETE"})).ok){let t=X.filter(t=>t!==e);ee(t),es===e&&ea(""),ec()}}catch(e){console.log("Error removing model:",e)}},className:"ml-0.5 hover:text-red-500",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"close"})})]},e))}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("button",{onClick:()=>B(!0),disabled:!d?.length,className:`px-2 py-1 rounded border text-xs transition-colors ${d?.length?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Add Model"}),(0,a.jsx)("span",{className:"text-xs text-text-muted",children:X.length>0&&es?(0,a.jsxs)(a.Fragment,{children:["Active: ",(0,a.jsx)("span",{className:"text-primary",children:es})]}):X.length>0?(0,a.jsx)("span",{className:"text-yellow-500",children:"Click a model to set/clear active"}):"Select models to add"})]})]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Subagent Model"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)("input",{type:"text",value:F,onChange:e=>K(e.target.value),placeholder:z||"provider/model-id (defaults to main model)",className:"w-full min-w-0 px-2 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),(0,a.jsx)("button",{onClick:()=>W(!0),disabled:!d?.length,className:`w-full sm:w-auto rounded border px-2 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap sm:shrink-0 ${d?.length?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"}),F&&(0,a.jsx)("button",{onClick:()=>K(""),className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear (will use main model)",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]})]}),T&&(0,a.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===T.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===T.type?"check_circle":"error"}),(0,a.jsx)("span",{children:T.text})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,a.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:em,disabled:0===X.length,loading:A,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,a.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:ex,disabled:!N.has9Router,loading:M,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,a.jsxs)(r.$n,{variant:"ghost",size:"sm",onClick:()=>V(!0),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),q&&(0,a.jsx)(r.rq,{isOpen:q,onClose:()=>{B(!1),ei(el.current)},onSelect:e=>{!X.includes(e.value)&&(ee([...X,e.value]),es||ea(e.value))},onDeselect:e=>{let t=X.filter(t=>t!==e.value);ee(t),es===e.value&&ea(t[0]||"")},selectedModel:null,activeProviders:d,modelAliases:G,addedModelValues:X,closeOnSelect:!1,title:"Add Model for OpenCode"}),H&&(0,a.jsx)(r.rq,{isOpen:H,onClose:()=>W(!1),onSelect:e=>{K(e.value),W(!1)},selectedModel:F,activeProviders:d,modelAliases:G,title:"Select Subagent Model for OpenCode"}),(0,a.jsx)(r.uR,{isOpen:Y,onClose:()=>V(!1),title:"OpenCode - Manual Configuration",configs:(g=U&&U.trim()?U:c?"<API_KEY_FROM_DASHBOARD>":"sk_9router",f=X.length>0?X:["provider/model-id"],b=es||X[0]||f[0],y=F||b,v={},f.forEach(e=>{v[e]={name:e,modalities:{input:["text","image"],output:["text"]}}}),[{filename:"~/.config/opencode/opencode.json",content:JSON.stringify({provider:{"9router":{npm:"@ai-sdk/openai-compatible",options:{baseURL:ed(),apiKey:g},models:v}},model:`9router/${b}`,agent:{explorer:{description:"Fast explorer subagent for codebase exploration",mode:"subagent",model:`9router/${y}`}}},null,2)}])})]})}let es="/api/cli-tools/cowork-settings",ea=e=>(e||"").replace(/\/v1\/?$/,"");function el({tool:e,isExpanded:t,onToggle:s,baseUrl:n,apiKeys:o,activeProviders:d,hasActiveProviders:c,cloudEnabled:m,cloudUrl:x,tunnelEnabled:u,tunnelPublicUrl:p,tailscaleEnabled:h,tailscaleUrl:g,initialStatus:f}){let b,y,v,N,[w,C]=(0,l.useState)(f||null),[_,A]=(0,l.useState)(!1),[E,$]=(0,l.useState)(!1),[M,O]=(0,l.useState)(!1),[T,P]=(0,l.useState)(null),[R,I]=(0,l.useState)(""),[U,D]=(0,l.useState)([]),[z,L]=(0,l.useState)(!1),[F,K]=(0,l.useState)(""),[q,B]=(0,l.useState)([]),[H,W]=(0,l.useState)([]),[G,J]=(0,l.useState)([]),[Y,V]=(0,l.useState)({}),[Z,Q]=(0,l.useState)(!1),[X,ee]=(0,l.useState)(!1),[et,er]=(0,l.useState)(!1),[ei,en]=(0,l.useState)(!1),[eo,ed]=(0,l.useState)({name:"",url:""});(0,l.useEffect)(()=>{o?.length>0&&!R&&I(o[0].key)},[o,R]),(0,l.useEffect)(()=>{f&&C(f)},[f]),(0,l.useEffect)(()=>{t&&!w&&ec()},[t]),(0,l.useEffect)(()=>{t&&fetch("/api/models/alias").then(e=>e.ok?e.json():null).then(e=>{e&&V(e.aliases||{})}).catch(()=>{})},[t]),(0,l.useEffect)(()=>{w?.cowork?.models?.length&&D(w.cowork.models),w?.cowork?.baseUrl&&!F&&K(ea(w.cowork.baseUrl)),Array.isArray(w?.cowork?.plugins)&&w.cowork.plugins.length>0?B(w.cowork.plugins):0===q.length&&Array.isArray(w?.defaultPlugins)&&B(w.defaultPlugins),Array.isArray(w?.cowork?.localPlugins)&&W(w.cowork.localPlugins),Array.isArray(w?.cowork?.customPlugins)&&w.cowork.customPlugins.length>0&&J(w.cowork.customPlugins)},[w]);let ec=async()=>{A(!0);try{let e=await fetch(es),t=await e.json();C(t)}catch(e){C({installed:!1,error:e.message})}finally{A(!1)}},em=()=>{let e;return(e=(F||"").replace(/\/+$/,""))?/\/v1$/.test(e)?e:`${e}/v1`:""},ex=w?.cowork?.baseUrl||"",eu=w?.installed?w?.cowork?.baseUrl?w.has9Router?"configured":"other":"not_configured":null,ep=async()=>{P(null);let e=em();if(0===U.length)return void P({type:"error",text:"Please select at least one model"});$(!0);try{let t=R?.trim()||(o?.length>0?o[0].key:null)||(m?null:"sk_9router"),s=await fetch(es,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:e,apiKey:t,models:U,plugins:q,localPlugins:H,customPlugins:G})}),a=await s.json();s.ok?(j(em(),{tunnelPublicUrl:p,tailscaleUrl:g}),P({type:"success",text:"Settings applied. Quit & reopen Claude Desktop to load."}),ec()):P({type:"error",text:a.error||"Failed to apply settings"})}catch(e){P({type:"error",text:e.message})}finally{$(!1)}},eh=async({name:e,models:t})=>{try{let s=await fetch("/api/combos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,models:t})});if(!s.ok){let e=await s.json();P({type:"error",text:e.error||"Failed to create combo"});return}U.includes(e)||D([...U,e]),Q(!1),P({type:"success",text:`Combo "${e}" created and added.`})}catch(e){P({type:"error",text:e.message})}},eg=e=>{let t=e?.value||e?.name||e;D(e=>e.filter(e=>e!==t))},ef=async()=>{O(!0),P(null);try{let e=await fetch(es,{method:"DELETE"}),t=await e.json();e.ok?(P({type:"success",text:"Settings reset successfully"}),D([]),B(w?.defaultPlugins||[]),W([]),J([]),ec()):P({type:"error",text:t.error||"Failed to reset"})}catch(e){P({type:"error",text:e.message})}finally{O(!1)}};return(0,a.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3 hover:cursor-pointer sm:items-center",onClick:s,children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(i.A,{src:e.image,alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===eu&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===eu&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===eu&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[_&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,a.jsx)("span",{children:"Checking Claude Cowork..."})]}),!_&&w&&!w.installed&&(0,a.jsxs)("div",{className:"flex flex-col gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Claude Desktop (Cowork mode) not detected"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Open Claude Desktop → Help → Troubleshooting → Enable Developer mode → Configure third-party inference, then return here."})]})]}),(0,a.jsx)("div",{className:"pl-9",children:(0,a.jsxs)(r.$n,{variant:"secondary",size:"sm",onClick:()=>L(!0),className:"!bg-yellow-500/20 !border-yellow-500/40 !text-yellow-700 dark:!text-yellow-300 hover:!bg-yellow-500/30",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:"content_copy"}),"Manual Config"]})})]}),!_&&w?.installed&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Select Endpoint"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(k,{value:em(),onChange:e=>K(ea(e)),tunnelEnabled:u,tunnelPublicUrl:p,tailscaleEnabled:h,tailscaleUrl:g,cloudEnabled:m,cloudUrl:x,currentUrl:ex})]}),w?.cowork?.baseUrl&&(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Current"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)("span",{className:"min-w-0 truncate rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5",children:w.cowork.baseUrl})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(S,{value:R,onChange:I,apiKeys:o,cloudEnabled:m})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Models"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"flex-1 flex items-center gap-2",children:[(0,a.jsx)("div",{className:"flex-1 flex flex-wrap gap-1.5 min-h-[28px] px-2 py-1.5 bg-surface rounded border border-border",children:0===U.length?(0,a.jsx)("span",{className:"text-xs text-text-muted",children:"No models selected"}):U.map(e=>(0,a.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs bg-black/5 dark:bg-white/5 text-text-muted border border-transparent hover:border-border",children:[e,(0,a.jsx)("button",{onClick:()=>eg(e),className:"ml-0.5 hover:text-red-500",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"close"})})]},e))}),(0,a.jsx)("button",{onClick:()=>Q(!0),disabled:!c,className:`shrink-0 px-2 py-1.5 rounded border text-xs whitespace-nowrap transition-colors ${c?"bg-primary/10 border-primary/40 text-primary hover:bg-primary/20 cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"+ Combo"})]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-start sm:gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right pt-2",children:"MCP"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px] mt-2",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"flex-1 flex flex-col gap-1",children:[q.filter(e=>"exa"!==e.name).map(e=>(0,a.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1 bg-surface rounded border border-border",children:[(0,a.jsx)("span",{className:"text-xs font-medium min-w-0 truncate flex-shrink-0",children:e.title||e.name}),e.oauth&&(0,a.jsx)("span",{className:"text-[8px] text-amber-600 shrink-0",children:"OAuth"}),(0,a.jsxs)("div",{className:"flex-1 flex flex-wrap gap-1 overflow-hidden",style:{maxHeight:"1.5rem"},children:[Array.isArray(e.toolNames)&&e.toolNames.slice(0,6).map(e=>(0,a.jsx)("span",{className:"text-[9px] px-1 py-0.5 rounded bg-black/5 dark:bg-white/5 text-text-muted whitespace-nowrap",children:e},e)),Array.isArray(e.toolNames)&&e.toolNames.length>6&&(0,a.jsxs)("span",{className:"text-[9px] px-1 py-0.5 rounded bg-black/5 dark:bg-white/5 text-text-muted whitespace-nowrap",children:["+",e.toolNames.length-6]})]}),(0,a.jsx)("button",{onClick:()=>{var t;return t=e.name,void B(q.filter(e=>e.name!==t))},className:"shrink-0 hover:text-red-500 ml-auto",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"close"})})]},e.name)),G.map(e=>(0,a.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1 bg-surface rounded border border-border",children:[(0,a.jsx)("span",{className:"text-xs font-medium min-w-0 truncate flex-shrink-0",children:e.name}),(0,a.jsx)("span",{className:"text-[8px] px-1 py-0.5 rounded bg-blue-500/10 text-blue-500 shrink-0",children:"custom"}),(0,a.jsx)("span",{className:"flex-1 text-[9px] text-text-muted truncate",children:e.url}),(0,a.jsx)("button",{onClick:()=>J(G.filter(t=>t.name!==e.name)),className:"shrink-0 hover:text-red-500 ml-auto",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"close"})})]},e.name)),0===q.filter(e=>"exa"!==e.name).length&&0===G.length&&(0,a.jsx)("div",{className:"px-2 py-1.5 bg-surface rounded border border-border text-xs text-text-muted",children:"No MCPs added"}),(0,a.jsxs)("div",{className:"flex items-center gap-2 mt-0.5",children:[(0,a.jsx)("button",{onClick:()=>er(!0),className:"px-2 py-1 rounded border text-xs bg-primary/10 border-primary/40 text-primary hover:bg-primary/20 cursor-pointer whitespace-nowrap",children:"+ Browse"}),(0,a.jsx)("button",{onClick:()=>{ed({name:"",url:""}),en(!0)},className:"px-2 py-1 rounded border text-xs bg-surface border-border text-text-muted hover:border-primary hover:text-primary cursor-pointer whitespace-nowrap",children:"+ Custom"}),(0,a.jsx)("a",{href:"https://mcp.so",target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-text-muted hover:text-primary underline ml-auto",children:"Find MCPs →"})]})]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-start sm:gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right pt-1",children:"Tools"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px] mt-1.5",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"flex-1 flex flex-col gap-1.5",children:[(b=q.some(e=>"exa"===e.name),y=(w?.defaultPlugins||[]).find(e=>"exa"===e.name),(0,a.jsxs)("label",{className:"flex items-start gap-2 cursor-pointer px-2 py-1.5 bg-surface rounded border border-border",children:[(0,a.jsx)("input",{type:"checkbox",checked:b,onChange:e=>{e.target.checked&&y?B([...q.filter(e=>"exa"!==e.name),y]):B(q.filter(e=>"exa"!==e.name))},className:"mt-0.5"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("div",{className:"text-xs font-medium",children:"Web Search & Fetch (Exa)"}),(0,a.jsx)("p",{className:"text-[10px] text-text-muted leading-snug",children:"Replaces built-in WebSearch/WebFetch. Auto-strips duplicates from tool list."})]})]})),(()=>{let e=(w?.localStdioPlugins||[]).find(e=>"browsermcp"===e.name);if(!e)return null;let t=H.includes("browsermcp");return(0,a.jsxs)("label",{className:"flex items-start gap-2 cursor-pointer px-2 py-1.5 bg-surface rounded border border-border",children:[(0,a.jsx)("input",{type:"checkbox",checked:t,onChange:e=>W(e.target.checked?[...H,"browsermcp"]:H.filter(e=>"browsermcp"!==e)),className:"mt-0.5"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("div",{className:"text-xs font-medium",children:"Browser Control (Browser MCP)"}),(0,a.jsxs)("p",{className:"text-[10px] text-text-muted leading-snug",children:["Controls your running Chrome. Auto-strips Cowork's built-in browser tools."," ",(0,a.jsx)("a",{href:e.extensionUrl,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline",children:"Install Chrome extension"})]})]})]})})()]})]}),Array.isArray(w?.localStdioPlugins)&&w.localStdioPlugins.filter(e=>"browsermcp"!==e.name).length>0&&(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-start sm:gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right pt-1",children:"Local Plugins"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px] mt-1.5",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"flex-1 flex flex-col gap-2",children:[(0,a.jsx)("div",{className:"flex flex-col gap-1.5 px-2 py-1.5 bg-surface rounded border border-border",children:w.localStdioPlugins.filter(e=>"browsermcp"!==e.name).map(e=>{let t=H.includes(e.name);return(0,a.jsxs)("label",{className:"flex items-start gap-2 cursor-pointer",children:[(0,a.jsx)("input",{type:"checkbox",checked:t,onChange:t=>W(t.target.checked?[...H,e.name]:H.filter(t=>t!==e.name)),className:"mt-0.5"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,a.jsx)("span",{className:"text-xs font-medium",children:e.title}),(0,a.jsx)("span",{className:"text-[8px] text-amber-600",children:"stdio"})]}),(0,a.jsx)("p",{className:"text-[10px] text-text-muted leading-snug",children:e.description}),e.extensionUrl&&(0,a.jsx)("a",{href:e.extensionUrl,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-primary underline",children:"Install Chrome extension"})]})]},e.name)})}),(0,a.jsxs)("p",{className:"text-[10px] text-text-muted leading-snug",children:["⚠️ Local plugins run as subprocess via ",(0,a.jsx)("code",{className:"px-1 py-0.5 rounded bg-black/5 dark:bg-white/5",children:"npx"}),". Requires Node.js installed."]})]})]})]}),T&&(0,a.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===T.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===T.type?"check_circle":"error"}),(0,a.jsx)("span",{children:T.text})]}),(0,a.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2",children:[(0,a.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:ep,disabled:0===U.length,loading:E,className:"w-full sm:w-auto",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,a.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:ef,disabled:!w.has9Router,loading:M,className:"w-full sm:w-auto",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,a.jsxs)(r.$n,{variant:"ghost",size:"sm",onClick:()=>L(!0),className:"w-full sm:w-auto",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),(0,a.jsx)(r.uR,{isOpen:z,onClose:()=>L(!1),title:"Claude Cowork - Manual Configuration",configs:(v=R&&R.trim()?R:m?"<API_KEY_FROM_DASHBOARD>":"sk_9router",N=U.length>0?U:["provider/model-id"],[{filename:"~/Library/Application Support/Claude-3p/configLibrary/<appliedId>.json",content:JSON.stringify({inferenceProvider:"gateway",inferenceGatewayBaseUrl:em()||"https://your-public-host/v1",inferenceGatewayApiKey:v,inferenceModels:N.map(e=>({name:e}))},null,2)}])}),Z&&(0,a.jsx)(r.CK,{isOpen:Z,combo:null,onClose:()=>Q(!1),onSave:eh,activeProviders:d,forcePrefix:"claude-",title:"Create Cowork Combo"}),X&&(0,a.jsx)(r.rq,{isOpen:X,onClose:()=>ee(!1),onSelect:e=>{let t=e?.value||e?.name||e;!t||U.includes(t)||D(e=>[...e,t])},onDeselect:eg,activeProviders:d,modelAliases:Y,title:"Select Cowork Model",addedModelValues:U,closeOnSelect:!1}),(0,a.jsx)(r.Nf,{isOpen:et,onClose:()=>er(!1),onAdd:e=>{q.some(t=>t.name===e.name)||B([...q,e])},addedNames:q.map(e=>e.name)}),ei&&(0,a.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40",onClick:()=>en(!1),children:(0,a.jsxs)("div",{className:"bg-surface border border-border rounded-xl shadow-xl w-full max-w-sm mx-4 p-5 flex flex-col gap-4",onClick:e=>e.stopPropagation(),children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("h3",{className:"font-semibold text-sm",children:"Add Custom MCP"}),(0,a.jsx)("button",{onClick:()=>en(!1),className:"text-text-muted hover:text-text-main",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"close"})})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,a.jsx)("label",{className:"text-[11px] text-text-muted font-medium",children:"Name"}),(0,a.jsx)("input",{type:"text",placeholder:"my-mcp",value:eo.name,onChange:e=>ed(t=>({...t,name:e.target.value.replace(/\s+/g,"-").toLowerCase()})),className:"px-2 py-1.5 rounded border border-border bg-surface text-xs outline-none focus:border-primary"})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,a.jsx)("label",{className:"text-[11px] text-text-muted font-medium",children:"SSE URL"}),(0,a.jsx)("input",{type:"text",placeholder:"https://your-mcp-server.com/sse",value:eo.url,onChange:e=>ed(t=>({...t,url:e.target.value})),className:"px-2 py-1.5 rounded border border-border bg-surface text-xs outline-none focus:border-primary"})]})]}),(0,a.jsxs)("div",{className:"flex gap-2 justify-end",children:[(0,a.jsx)("button",{onClick:()=>en(!1),className:"px-3 py-1.5 rounded border border-border text-xs text-text-muted hover:bg-surface cursor-pointer",children:"Cancel"}),(0,a.jsx)("button",{onClick:()=>{let e=eo.name.trim();e&&eo.url.trim()&&(J(t=>[...t.filter(t=>t.name!==e),{name:e,url:eo.url.trim(),transport:"sse",custom:!0}]),en(!1))},className:"px-3 py-1.5 rounded bg-primary text-white text-xs font-medium hover:opacity-90 cursor-pointer",children:"Add"})]})]})})]})}function er({tool:e,isExpanded:t,onToggle:s,baseUrl:n,apiKeys:o,activeProviders:d,cloudEnabled:c,initialStatus:m,tunnelEnabled:x,tunnelPublicUrl:u,tailscaleEnabled:p,tailscaleUrl:h}){let g,f,[b,y]=(0,l.useState)(m||null),[v,N]=(0,l.useState)(!1),[w,C]=(0,l.useState)(!1),[_,A]=(0,l.useState)(!1),[$,M]=(0,l.useState)(null),[O,T]=(0,l.useState)(!1),[P,R]=(0,l.useState)(""),[I,U]=(0,l.useState)(""),[D,z]=(0,l.useState)(!1),[L,F]=(0,l.useState)({}),[K,q]=(0,l.useState)(!1),[B,H]=(0,l.useState)("");(0,l.useEffect)(()=>{o?.length>0&&!P&&R(o[0].key)},[o,P]),(0,l.useEffect)(()=>{m&&y(m)},[m]),(0,l.useEffect)(()=>{t&&(b||V(),W())},[t]),(0,l.useEffect)(()=>{b?.settings?.openAiModelId&&U(b.settings.openAiModelId)},[b]);let W=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&F(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}},G=b?.settings?.openAiBaseUrl||"",J=b?.installed?b.has9Router?E(b.settings?.openAiBaseUrl||"",{tunnelPublicUrl:u,tailscaleUrl:h})?"configured":"other":"not_configured":null,Y=()=>{let e=B||`${n}/v1`;return e.endsWith("/v1")?e:`${e}/v1`},V=async()=>{N(!0);try{let e=await fetch("/api/cli-tools/cline-settings"),t=await e.json();y(t)}catch(e){y({installed:!1,error:e.message})}finally{N(!1)}},Z=async()=>{C(!0),M(null);try{let e=P&&P.trim()||c?P:"sk_9router",t=await fetch("/api/cli-tools/cline-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:Y(),apiKey:e,model:I})}),s=await t.json();t.ok?(j(Y(),{tunnelPublicUrl:u,tailscaleUrl:h}),M({type:"success",text:"Settings applied successfully!"}),V()):M({type:"error",text:s.error||"Failed to apply settings"})}catch(e){M({type:"error",text:e.message})}finally{C(!1)}},Q=async()=>{A(!0),M(null);try{let e=await fetch("/api/cli-tools/cline-settings",{method:"DELETE"}),t=await e.json();e.ok?(M({type:"success",text:"Settings reset successfully!"}),U(""),V()):M({type:"error",text:t.error||"Failed to reset settings"})}catch(e){M({type:"error",text:e.message})}finally{A(!1)}};return(0,a.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3 hover:cursor-pointer sm:items-center",onClick:s,children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(i.A,{src:"/providers/cline.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===J&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===J&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===J&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[v&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,a.jsx)("span",{children:"Checking Cline..."})]}),!v&&b&&!b.installed&&(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Cline not detected locally"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if 9router is deployed on a remote server."})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 pl-9",children:[(0,a.jsxs)(r.$n,{variant:"secondary",size:"sm",onClick:()=>q(!0),className:"!bg-yellow-500/20 !border-yellow-500/40 !text-yellow-700 dark:!text-yellow-300 hover:!bg-yellow-500/30",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:"content_copy"}),"Manual Config"]}),(0,a.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:()=>T(!O),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:O?"expand_less":"help"}),O?"Hide":"How to Install"]})]})]}),O&&(0,a.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,a.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,a.jsx)("div",{className:"space-y-3 text-sm",children:(0,a.jsxs)("p",{className:"text-text-muted",children:["Install Cline VS Code extension or CLI from ",(0,a.jsx)("a",{className:"text-primary underline",href:"https://docs.cline.bot/",target:"_blank",rel:"noreferrer",children:"docs.cline.bot"}),"."]})})]})]}),!v&&b?.installed&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Select Endpoint"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(k,{value:B||B||`${n}/v1`,onChange:H,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:x,tunnelPublicUrl:u,tailscaleEnabled:p,tailscaleUrl:h,currentUrl:G})]}),b?.settings?.openAiBaseUrl&&(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Current"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)("span",{className:"min-w-0 truncate rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5",children:b.settings.openAiBaseUrl})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(S,{value:P,onChange:R,apiKeys:o,cloudEnabled:c})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Model"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,a.jsx)("input",{type:"text",value:I,onChange:e=>U(e.target.value),placeholder:"provider/model-id",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),I&&(0,a.jsx)("button",{onClick:()=>U(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,a.jsx)("button",{onClick:()=>z(!0),disabled:!d?.length,className:`w-full sm:w-auto rounded border px-2 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap sm:shrink-0 ${d?.length?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"})]})]}),$&&(0,a.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===$.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===$.type?"check_circle":"error"}),(0,a.jsx)("span",{children:$.text})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,a.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:Z,disabled:!P&&c&&o.length>0||!I,loading:w,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,a.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:Q,disabled:_,loading:_,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,a.jsxs)(r.$n,{variant:"ghost",size:"sm",onClick:()=>q(!0),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),D&&(0,a.jsx)(r.rq,{isOpen:D,onClose:()=>z(!1),onSelect:e=>{U(e.value),z(!1)},selectedModel:I,activeProviders:d,modelAliases:L,title:"Select Model for Cline"}),(0,a.jsx)(r.uR,{isOpen:K,onClose:()=>q(!1),title:"Cline - Manual Configuration",configs:(g=P&&P.trim()?P:c?"<API_KEY_FROM_DASHBOARD>":"sk_9router",[{filename:"~/.cline/data/globalState.json",content:JSON.stringify({actModeApiProvider:"openai",planModeApiProvider:"openai",openAiBaseUrl:(f=Y()).endsWith("/v1")?f.slice(0,-3):f,openAiModelId:I||"provider/model-id",planModeOpenAiModelId:I||"provider/model-id"},null,2)},{filename:"~/.cline/data/secrets.json",content:JSON.stringify({openAiApiKey:g},null,2)}])})]})}function ei({tool:e,isExpanded:t,onToggle:s,baseUrl:n,apiKeys:o,activeProviders:d,cloudEnabled:c,initialStatus:m,tunnelEnabled:x,tunnelPublicUrl:u,tailscaleEnabled:p,tailscaleUrl:h}){let[g,f]=(0,l.useState)(m||null),[b,y]=(0,l.useState)(!1),[v,N]=(0,l.useState)(!1),[w,C]=(0,l.useState)(!1),[_,A]=(0,l.useState)(null),[E,$]=(0,l.useState)(!1),[M,O]=(0,l.useState)(""),[T,P]=(0,l.useState)(""),[R,I]=(0,l.useState)(!1),[U,D]=(0,l.useState)({}),[z,L]=(0,l.useState)(!1),[F,K]=(0,l.useState)("");(0,l.useEffect)(()=>{o?.length>0&&!M&&O(o[0].key)},[o,M]),(0,l.useEffect)(()=>{m&&f(m)},[m]),(0,l.useEffect)(()=>{t&&(g||W(),q())},[t]);let q=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&D(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}},B=g?.installed?g.has9Router?"configured":"not_configured":null,H=()=>{let e=F||`${n}/v1`;return e.endsWith("/v1")?e:`${e}/v1`},W=async()=>{y(!0);try{let e=await fetch("/api/cli-tools/kilo-settings"),t=await e.json();f(t)}catch(e){f({installed:!1,error:e.message})}finally{y(!1)}},G=async()=>{N(!0),A(null);try{let e=M&&M.trim()||c?M:"sk_9router",t=await fetch("/api/cli-tools/kilo-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:H(),apiKey:e,model:T})}),s=await t.json();t.ok?(j(H(),{tunnelPublicUrl:u,tailscaleUrl:h}),A({type:"success",text:"Settings applied successfully!"}),W()):A({type:"error",text:s.error||"Failed to apply settings"})}catch(e){A({type:"error",text:e.message})}finally{N(!1)}},J=async()=>{C(!0),A(null);try{let e=await fetch("/api/cli-tools/kilo-settings",{method:"DELETE"}),t=await e.json();e.ok?(A({type:"success",text:"Settings reset successfully!"}),P(""),W()):A({type:"error",text:t.error||"Failed to reset settings"})}catch(e){A({type:"error",text:e.message})}finally{C(!1)}};return(0,a.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3 hover:cursor-pointer sm:items-center",onClick:s,children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(i.A,{src:"/providers/kilocode.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===B&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===B&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[b&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,a.jsx)("span",{children:"Checking Kilo Code..."})]}),!b&&g&&!g.installed&&(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Kilo Code not detected locally"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if 9router is deployed on a remote server."})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 pl-9",children:[(0,a.jsxs)(r.$n,{variant:"secondary",size:"sm",onClick:()=>L(!0),className:"!bg-yellow-500/20 !border-yellow-500/40 !text-yellow-700 dark:!text-yellow-300 hover:!bg-yellow-500/30",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:"content_copy"}),"Manual Config"]}),(0,a.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:()=>$(!E),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:E?"expand_less":"help"}),E?"Hide":"How to Install"]})]})]}),E&&(0,a.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,a.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,a.jsxs)("p",{className:"text-sm text-text-muted",children:["Install Kilo Code from ",(0,a.jsx)("a",{className:"text-primary underline",href:"https://kilocode.ai",target:"_blank",rel:"noreferrer",children:"kilocode.ai"})," or VS Code extension marketplace."]})]})]}),!b&&g?.installed&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Select Endpoint"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(k,{value:F||F||`${n}/v1`,onChange:K,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:x,tunnelPublicUrl:u,tailscaleEnabled:p,tailscaleUrl:h})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(S,{value:M,onChange:O,apiKeys:o,cloudEnabled:c})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Model"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,a.jsx)("input",{type:"text",value:T,onChange:e=>P(e.target.value),placeholder:"provider/model-id",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),T&&(0,a.jsx)("button",{onClick:()=>P(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,a.jsx)("button",{onClick:()=>I(!0),disabled:!d?.length,className:`w-full sm:w-auto rounded border px-2 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap sm:shrink-0 ${d?.length?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"})]})]}),_&&(0,a.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===_.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===_.type?"check_circle":"error"}),(0,a.jsx)("span",{children:_.text})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,a.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:G,disabled:!M&&c&&o.length>0||!T,loading:v,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,a.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:J,disabled:w,loading:w,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,a.jsxs)(r.$n,{variant:"ghost",size:"sm",onClick:()=>L(!0),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),R&&(0,a.jsx)(r.rq,{isOpen:R,onClose:()=>I(!1),onSelect:e=>{P(e.value),I(!1)},selectedModel:T,activeProviders:d,modelAliases:U,title:"Select Model for Kilo Code"}),(0,a.jsx)(r.uR,{isOpen:z,onClose:()=>L(!1),title:"Kilo Code - Manual Configuration",configs:[{filename:"~/.local/share/kilo/auth.json",content:JSON.stringify({"openai-compatible":{type:"api-key",apiKey:M&&M.trim()?M:c?"<API_KEY_FROM_DASHBOARD>":"sk_9router",baseUrl:H(),model:T||"provider/model-id"}},null,2)}]})]})}let en="/api/cli-tools/deepseek-tui-settings";function eo({tool:e,isExpanded:t,onToggle:s,baseUrl:n,hasActiveProviders:o,apiKeys:d,activeProviders:c,cloudEnabled:m,initialStatus:x,tunnelEnabled:u,tunnelPublicUrl:p,tailscaleEnabled:h,tailscaleUrl:g}){let f,[b,y]=(0,l.useState)(x||null),[v,N]=(0,l.useState)(!1),[w,C]=(0,l.useState)(!1),[_,A]=(0,l.useState)(!1),[$,M]=(0,l.useState)(null),[O,T]=(0,l.useState)(""),[P,R]=(0,l.useState)(""),[I,U]=(0,l.useState)(!1),[D,z]=(0,l.useState)({}),[L,F]=(0,l.useState)(!1),[K,q]=(0,l.useState)(""),B=(0,l.useRef)(!1),H=b?.settings?.["providers.openai"]?.base_url||"",W=(()=>{if(!b?.installed)return null;let e=b.settings?.["providers.openai"];return e?.base_url?E(e.base_url,{tunnelPublicUrl:p,tailscaleUrl:g})?"configured":"other":"not_configured"})();(0,l.useEffect)(()=>{d?.length>0&&!O&&T(d[0].key)},[d,O]),(0,l.useEffect)(()=>{x&&y(x)},[x]),(0,l.useEffect)(()=>{t&&(b||J(),G())},[t]);let G=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&z(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}};(0,l.useEffect)(()=>{if(b?.installed&&!B.current){B.current=!0;let e=b.settings?.["providers.openai"];e?.model&&R(e.model)}},[b]);let J=async()=>{N(!0);try{let e=await fetch(en),t=await e.json();y(t)}catch(e){y({installed:!1,error:e.message})}finally{N(!1)}},Y=()=>{let e=K||window.location.origin.replace("://localhost","://127.0.0.1");return e.endsWith("/v1")?e:`${e}/v1`},V=async()=>{C(!0),M(null);try{let e=O?.trim()||(d?.length>0?d[0].key:null)||(m?null:"sk_9router"),t=await fetch(en,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:Y(),apiKey:e,model:P})}),s=await t.json();t.ok?(j(Y(),{tunnelPublicUrl:p,tailscaleUrl:g}),M({type:"success",text:"Settings applied successfully!"}),J()):M({type:"error",text:s.error||"Failed to apply settings"})}catch(e){M({type:"error",text:e.message})}finally{C(!1)}},Z=async()=>{A(!0),M(null);try{let e=await fetch(en,{method:"DELETE"}),t=await e.json();e.ok?(M({type:"success",text:"Settings reset successfully!"}),R(""),J()):M({type:"error",text:t.error||"Failed to reset settings"})}catch(e){M({type:"error",text:e.message})}finally{A(!1)}};return(0,a.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3 hover:cursor-pointer sm:items-center",onClick:s,children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(i.A,{src:e.image||"/providers/deepseek-tui.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===W&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===W&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===W&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[v&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,a.jsx)("span",{children:"Checking DeepSeek TUI..."})]}),!v&&b&&!b.installed&&(0,a.jsx)("div",{className:"flex flex-col gap-4",children:(0,a.jsxs)("div",{className:"flex flex-col gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"DeepSeek TUI not detected locally"}),(0,a.jsx)("p",{className:"text-sm text-text-muted mt-1",children:"Install via npm:"}),(0,a.jsx)("code",{className:"block mt-2 p-2 bg-black/20 rounded text-xs font-mono",children:"npm install -g deepseek-tui"}),(0,a.jsx)("p",{className:"text-sm text-text-muted mt-2",children:"Manual configuration is still available if 9router is deployed on a remote server."})]})]}),(0,a.jsx)("div",{className:"flex items-center gap-2 pl-9",children:(0,a.jsxs)(r.$n,{variant:"secondary",size:"sm",onClick:()=>F(!0),className:"!bg-yellow-500/20 !border-yellow-500/40 !text-yellow-700 dark:!text-yellow-300 hover:!bg-yellow-500/30",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:"content_copy"}),"Manual Config"]})})]})}),!v&&b?.installed&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[e.notes&&e.notes.length>0&&(0,a.jsx)("div",{className:"flex flex-col gap-2 mb-2",children:e.notes.map((e,t)=>(0,a.jsxs)("div",{className:`flex items-start gap-2 p-2 rounded text-xs ${"warning"===e.type?"bg-yellow-500/10 text-yellow-600 dark:text-yellow-400":"error"===e.type?"bg-red-500/10 text-red-600 dark:text-red-400":"bg-blue-500/10 text-blue-600 dark:text-blue-400"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mt-0.5",children:"warning"===e.type?"warning":"error"===e.type?"error":"info"}),(0,a.jsx)("span",{children:e.text})]},t))}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Select Endpoint"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(k,{value:K||Y(),onChange:q,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:u,tunnelPublicUrl:p,tailscaleEnabled:h,tailscaleUrl:g,currentUrl:H})]}),b?.settings?.["providers.openai"]?.base_url&&(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Current"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)("span",{className:"min-w-0 truncate rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5",children:b.settings["providers.openai"].base_url})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(S,{value:O,onChange:T,apiKeys:d,cloudEnabled:m})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Default Model"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,a.jsx)("input",{type:"text",value:P,onChange:e=>R(e.target.value),placeholder:"provider/model-id",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),P&&(0,a.jsx)("button",{onClick:()=>R(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,a.jsx)("button",{onClick:()=>U(!0),disabled:!o,className:`w-full sm:w-auto rounded border px-2 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap sm:shrink-0 ${o?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"})]})]}),$&&(0,a.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===$.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===$.type?"check_circle":"error"}),(0,a.jsx)("span",{children:$.text})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,a.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:V,disabled:!P,loading:w,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,a.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:Z,disabled:!b?.has9Router,loading:_,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,a.jsxs)(r.$n,{variant:"ghost",size:"sm",onClick:()=>F(!0),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),I&&(0,a.jsx)(r.rq,{isOpen:I,onClose:()=>U(!1),onSelect:e=>{R(e.value),U(!1)},selectedModel:P,activeProviders:c,modelAliases:D,title:"Select Model for DeepSeek TUI"}),(0,a.jsx)(r.uR,{isOpen:L,onClose:()=>F(!1),title:"DeepSeek TUI - Manual Configuration",configs:(f=O&&O.trim()?O:m?"<API_KEY_FROM_DASHBOARD>":"sk_9router",[{filename:"~/.deepseek/config.toml",content:`[providers.openai]
|
|
83
|
+
`}])})]})}var B=s(8247),H=s(11059);function W({toolId:e,tool:t,isExpanded:s,onToggle:n,baseUrl:o,apiKeys:d,activeProviders:c=[],cloudEnabled:m=!1,tunnelEnabled:x=!1}){let[u,p]=(0,l.useState)(null),[h,g]=(0,l.useState)(!1),[f,b]=(0,l.useState)(""),[y,j]=(0,l.useState)(()=>d?.length>0?d[0].key:""),v=e=>{let t=y&&y.trim()?y:m?"your-api-key":"sk_9router",s=o||"http://localhost:20128",a=s.endsWith("/v1")?s:`${s}/v1`;return e.replace(/\{\{baseUrl\}\}/g,a).replace(/\{\{apiKey\}\}/g,t).replace(/\{\{model\}\}/g,f||"provider/model-id")},{copy:N}=(0,H.C)(),w=async(e,t)=>{await N(v(e),`toolcard-${t}`),p(t),setTimeout(()=>p(null),2e3)},k=c.length>0,C=()=>(!t.requiresExternalUrl||!!m||!!x)&&(!t.requiresCloud||!!m);return(0,a.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden overflow-x-hidden",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between hover:cursor-pointer",onClick:n,children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 rounded-lg flex items-center justify-center shrink-0",children:(()=>{if(t.image)return(0,a.jsx)(i.A,{src:t.image,alt:t.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"},loading:"lazy",decoding:"async"});if(t.icon)return(0,a.jsx)("span",{className:"material-symbols-outlined text-xl",style:{color:t.color},children:t.icon});let s=(0,B.HY)(e);return s?(0,a.jsx)(i.A,{src:s,alt:t.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:t=>{(0,B.Kw)(e),t.target.style.display="none"},loading:"lazy",decoding:"async"}):(0,a.jsx)("span",{className:"text-xs font-bold",style:{color:t.color},children:(e||"?").slice(0,2).toUpperCase()})})()}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:t.name}),(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:t.description})]})]}),(0,a.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${s?"rotate-180":""}`,children:"expand_more"})]}),s&&(0,a.jsx)("div",{className:"mt-6 pt-6 border-t border-border",children:t.guideSteps?(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[t.notes&&0!==t.notes.length?(0,a.jsx)("div",{className:"flex flex-col gap-2 mb-4",children:t.notes.map((e,t)=>{if("cloudCheck"===e.type&&(m||x))return null;let s="warning"===e.type,l="cloudCheck"===e.type&&!m&&!x,r="bg-blue-500/10 border-blue-500/30",i="text-blue-600 dark:text-blue-400",n="text-blue-500",o="info";return s?(r="bg-yellow-500/10 border-yellow-500/30",i="text-yellow-600 dark:text-yellow-400",n="text-yellow-500",o="warning"):l&&(r="bg-red-500/10 border-red-500/30",i="text-red-600 dark:text-red-400",n="text-red-500",o="error"),(0,a.jsxs)("div",{className:`flex items-start gap-3 p-3 rounded-lg border ${r}`,children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-lg ${n}`,children:o}),(0,a.jsx)("p",{className:`text-sm ${i}`,children:e.text})]},t)})}):null,C()&&t.guideSteps.map(e=>(0,a.jsxs)("div",{className:"flex items-start gap-4",children:[(0,a.jsx)("div",{className:"size-8 rounded-full flex items-center justify-center shrink-0 text-sm font-semibold text-white",style:{backgroundColor:t.color},children:e.step}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"font-medium text-text",children:e.title}),e.desc&&(0,a.jsx)("p",{className:"text-sm text-text-muted mt-0.5",children:e.desc}),"apiKeySelector"===e.type&&(0,a.jsx)("div",{className:"mt-2 flex flex-col sm:flex-row sm:items-center gap-2",children:(0,a.jsx)(_,{value:y,onChange:j,apiKeys:d,cloudEnabled:m,className:"flex-1"})}),"modelSelector"===e.type&&(0,a.jsxs)("div",{className:"mt-2 flex flex-col sm:flex-row sm:items-center gap-2",children:[(0,a.jsx)("input",{type:"text",value:f,onChange:e=>b(e.target.value),placeholder:"provider/model-id",className:"w-full sm:w-auto flex-1 px-3 py-2 bg-bg-secondary rounded-lg text-sm border border-border focus:outline-none focus:ring-1 focus:ring-primary/50"}),(0,a.jsx)("button",{onClick:()=>g(!0),disabled:!k,className:`shrink-0 px-3 py-2 rounded-lg border text-sm transition-colors ${k?"bg-bg-secondary border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"}),f&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("button",{onClick:()=>w(f,"model"),className:"shrink-0 px-3 py-2 bg-bg-secondary hover:bg-bg-tertiary rounded-lg border border-border transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-lg",children:"model"===u?"check":"content_copy"})}),(0,a.jsx)("button",{onClick:()=>b(""),className:"p-2 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-lg",children:"close"})})]})]}),e.value&&(0,a.jsxs)("div",{className:"mt-2 flex flex-col sm:flex-row sm:items-center gap-2",children:[(0,a.jsx)("code",{className:"w-full sm:w-auto flex-1 px-3 py-2 bg-bg-secondary rounded-lg text-sm font-mono border border-border truncate",children:v(e.value)}),e.copyable&&(0,a.jsx)("button",{onClick:()=>w(e.value,`${e.step}-${e.title}`),className:"shrink-0 px-3 py-2 bg-bg-secondary hover:bg-bg-tertiary rounded-lg border border-border transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-lg",children:u===`${e.step}-${e.title}`?"check":"content_copy"})})]})]})]},e.step)),C()&&t.codeBlock&&(0,a.jsxs)("div",{className:"mt-2",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,a.jsx)("span",{className:"text-xs text-text-muted uppercase tracking-wide",children:t.codeBlock.language}),(0,a.jsxs)("button",{onClick:()=>w(t.codeBlock.code,"codeblock"),className:"flex items-center gap-1 px-2 py-1 text-xs bg-bg-secondary hover:bg-bg-tertiary rounded border border-border transition-colors",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"codeblock"===u?"check":"content_copy"}),"codeblock"===u?"Copied!":"Copy"]})]}),(0,a.jsx)("pre",{className:"p-4 bg-bg-secondary rounded-lg border border-border overflow-x-auto",children:(0,a.jsx)("code",{className:"text-sm font-mono whitespace-pre",children:v(t.codeBlock.code)})})]})]}):(0,a.jsx)("p",{className:"text-text-muted text-sm",children:"Coming soon..."})}),h&&(0,a.jsx)(r.rq,{isOpen:h,onClose:()=>g(!1),onSelect:e=>{b(e.value)},selectedModel:f,activeProviders:c,title:"Select Model"})]})}let G="round-robin",J=[{value:"round-robin",label:"Round-Robin"},{value:"fallback",label:"Fallback"}];function Y({tool:e,mappings:t,strategy:s=G,dnsActive:l=!0,hasActiveProviders:i,onChangeEntry:n,onBlurEntry:o,onOpenSelector:d,onAddEntry:c,onRemoveEntry:m,onReorderEntry:x,onChangeStrategy:u,feedback:p,compact:h=!1}){let g=h?"w-32 shrink-0 text-sm font-semibold text-text-main text-right":"w-36 shrink-0 text-xs font-semibold text-text-main text-right",f=h?"px-2 py-1.5 rounded border text-xs transition-colors shrink-0 whitespace-nowrap":"px-2 py-1.5 rounded border text-xs transition-colors shrink-0",b="h-8 min-w-8 inline-flex items-center justify-center rounded-md border border-border text-text-muted transition-colors",y=h?"h-8 px-2.5 inline-flex items-center justify-center rounded-md border border-border text-[11px] font-medium text-text-main transition-colors shrink-0 whitespace-nowrap":"h-8 px-2.5 inline-flex items-center justify-center rounded-md border border-border text-[11px] font-medium text-text-main transition-colors shrink-0",j=!l;return(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsx)("div",{className:"rounded-xl border border-border/70 bg-surface/60 p-3",children:(0,a.jsxs)("div",{className:"flex flex-col gap-1 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-xs font-semibold text-text-main",children:"Routing strategy"}),(0,a.jsx)("p",{className:"text-[11px] text-text-muted",children:"Round-robin spreads load. Fallback keeps priority order."}),(0,a.jsx)("p",{className:"text-[10px] text-text-muted mt-1",children:"Tip: paste comma-separated models into one row to expand multiple targets at once."})]}),(0,a.jsx)("div",{className:"sm:w-44",children:(0,a.jsx)(r.l6,{value:s,onChange:e=>u(e.target.value),disabled:j,options:J,selectClassName:"py-1.5 px-2 pr-8 text-xs bg-surface border-border","aria-label":`${e.name} MITM strategy`})})]})}),p&&(0,a.jsx)("div",{className:"rounded-lg border border-primary/20 bg-primary/5 px-3 py-2 text-[11px] text-text-muted",children:p}),(0,a.jsx)("div",{className:"flex flex-col gap-2",children:e.defaultModels?.map(e=>{let s=Array.isArray(t?.[e.alias])?t[e.alias]:[],r=l&&s.length<5;return(0,a.jsx)("div",{className:"rounded-xl border border-border/70 bg-surface/40 p-3",children:(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)("div",{className:g,children:(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,a.jsx)("span",{children:e.name}),(0,a.jsxs)("span",{className:"text-[10px] font-normal text-text-muted",children:["Max ",5," targets"]})]})}),(0,a.jsxs)("div",{className:"flex-1 flex flex-col gap-2",children:[s.length>0?s.map((t,l)=>{let r=j||0===l,c=j||l===s.length-1;return(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-6 text-center text-[11px] font-semibold text-text-muted",children:l+1}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,a.jsx)("input",{type:"text",value:t,onChange:t=>n(e.alias,l,t.target.value),onBlur:t=>o(e.alias,l,t.target.value),placeholder:"provider/model-id",disabled:j,className:`flex-1 px-2 py-1.5 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 ${j?"opacity-50 cursor-not-allowed":""}`}),(0,a.jsx)("button",{type:"button",onClick:()=>d(e.alias,l),disabled:!i||j,className:`${y} ${i&&!j?"hover:border-primary hover:text-primary cursor-pointer":"opacity-40 cursor-not-allowed"}`,title:"Select model",children:"Select"}),(0,a.jsx)("button",{type:"button",onClick:()=>x(e.alias,l,l-1),disabled:r,className:`${b} ${r?"opacity-40 cursor-not-allowed":"hover:border-primary hover:text-primary cursor-pointer"}`,title:"Move up",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"keyboard_arrow_up"})}),(0,a.jsx)("button",{type:"button",onClick:()=>x(e.alias,l,l+1),disabled:c,className:`${b} ${c?"opacity-40 cursor-not-allowed":"hover:border-primary hover:text-primary cursor-pointer"}`,title:"Move down",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"keyboard_arrow_down"})}),(0,a.jsx)("button",{type:"button",onClick:()=>m(e.alias,l),disabled:j,className:`${b} ${j?"opacity-40 cursor-not-allowed":"hover:border-red-500 hover:text-red-500 cursor-pointer"}`,title:"Remove",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"close"})})]},`${e.alias}-${l}`)}):(0,a.jsx)("div",{className:"rounded-lg border border-dashed border-border px-3 py-2 text-[11px] text-text-muted",children:"No mapping — passthrough"}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2 pl-8",children:[(0,a.jsx)("button",{type:"button",onClick:()=>c(e.alias),disabled:!r,className:`${f} ${r?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"+ Add"}),(0,a.jsxs)("span",{className:"text-[10px] text-text-muted",children:[s.length,"/",5," mapped"]})]})]})]})},e.alias)})})]})}function V(e){return Array.isArray(e)?e.map(e=>"string"==typeof e?e.trim():"").filter(Boolean).slice(0,5):"string"==typeof e&&e.trim()?[e.trim()]:[]}function Z(e){return Object.fromEntries(Object.entries(e||{}).map(([e,t])=>[e,V(t)]).filter(([,e])=>e.length>0))}function Q(e,t,s){let a="string"==typeof s?s.trim():"";if(!t||!a)return e;let l=V(e?.[t]);return l.length>=5?e:{...e,[t]:[...l,a]}}function X(e,t,s,a){let l=Array.isArray(e?.[t])?[...e[t]]:[];return s<0||s>=l.length?e:(l[s]=a,{...e,[t]:l})}function ee(e){return"fallback"===(e||G)?"fallback":G}function et({tool:e,isExpanded:t,onToggle:s,baseUrl:n,apiKeys:o,activeProviders:d,cloudEnabled:c,initialStatus:m,tunnelEnabled:x,tunnelPublicUrl:u,tailscaleEnabled:p,tailscaleUrl:h}){let g,f,b,y,v,[N,w]=(0,l.useState)(m||null),[C,S]=(0,l.useState)(!1),[A,$]=(0,l.useState)(!1),[M,O]=(0,l.useState)(!1),[T,P]=(0,l.useState)(null),[R,I]=(0,l.useState)(!1),[U,D]=(0,l.useState)(""),[z,L]=(0,l.useState)(""),[F,K]=(0,l.useState)(""),[q,B]=(0,l.useState)(!1),[H,W]=(0,l.useState)(!1),[G,J]=(0,l.useState)({}),[Y,V]=(0,l.useState)(!1),[Z,Q]=(0,l.useState)(""),[X,ee]=(0,l.useState)([]),[es,ea]=(0,l.useState)(""),el=(0,l.useRef)([]);(0,l.useEffect)(()=>{el.current=X},[X]),(0,l.useEffect)(()=>{o?.length>0&&!U&&D(o[0].key)},[o,U]),(0,l.useEffect)(()=>{m&&w(m)},[m]),(0,l.useEffect)(()=>{t&&(N||ec(),er())},[t]),(0,l.useEffect)(()=>{N?.opencode?.models&&ee(N.opencode.models),N?.opencode?.activeModel&&ea(N.opencode.activeModel),N?.config?.agent?.explorer?.model?.startsWith("9router/")&&K(N.config.agent.explorer.model.replace("9router/",""))},[N]);let er=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&J(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}},ei=async e=>{try{let t=U&&U.trim()||c?U:"sk_9router",s=e.includes(es)?es:e[0]||"";await fetch("/api/cli-tools/opencode-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:ed(),apiKey:t,models:e,activeModel:s,subagentModel:F})})}catch(e){console.log("Error saving models:",e)}},en=N?.config?.provider?.["9router"]?.options?.baseURL||"",eo=N?.installed?N.config&&N.has9Router?E(N.config?.provider?.["9router"]?.options?.baseURL||"",{tunnelPublicUrl:u,tailscaleUrl:h})?"configured":"other":"not_configured":null,ed=()=>{let e=Z||n;return e.endsWith("/v1")?e:`${e}/v1`},ec=async()=>{S(!0);try{let e=await fetch("/api/cli-tools/opencode-settings"),t=await e.json();w(t)}catch(e){w({installed:!1,error:e.message})}finally{S(!1)}},em=async()=>{$(!0),P(null);try{let e=U&&U.trim()||c?U:"sk_9router",t=await fetch("/api/cli-tools/opencode-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:ed(),apiKey:e,models:X,activeModel:""===es?"":es||X[0],subagentModel:F})}),s=await t.json();t.ok?(j(ed(),{tunnelPublicUrl:u,tailscaleUrl:h}),P({type:"success",text:"Settings applied successfully!"}),ec()):P({type:"error",text:s.error||"Failed to apply settings"})}catch(e){P({type:"error",text:e.message})}finally{$(!1)}},ex=async()=>{O(!0),P(null);try{let e=await fetch("/api/cli-tools/opencode-settings",{method:"DELETE"}),t=await e.json();e.ok?(P({type:"success",text:"Settings reset successfully!"}),L(""),K(""),ee([]),ea(""),ec()):P({type:"error",text:t.error||"Failed to reset settings"})}catch(e){P({type:"error",text:e.message})}finally{O(!1)}};return(0,a.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3 hover:cursor-pointer sm:items-center",onClick:s,children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(i.A,{src:"/providers/opencode.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===eo&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===eo&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===eo&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[C&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,a.jsx)("span",{children:"Checking OpenCode CLI..."})]}),!C&&N&&!N.installed&&(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"OpenCode CLI not detected locally"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if 9router is deployed on a remote server."})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 pl-9",children:[(0,a.jsxs)(r.$n,{variant:"secondary",size:"sm",onClick:()=>V(!0),className:"!bg-yellow-500/20 !border-yellow-500/40 !text-yellow-700 dark:!text-yellow-300 hover:!bg-yellow-500/30",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:"content_copy"}),"Manual Config"]}),(0,a.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:()=>I(!R),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:R?"expand_less":"help"}),R?"Hide":"How to Install"]})]})]}),R&&(0,a.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,a.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,a.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-text-muted mb-1",children:"macOS / Linux:"}),(0,a.jsx)("code",{className:"block px-3 py-2 bg-black/5 dark:bg-white/5 rounded font-mono text-xs",children:"npm install -g opencode-ai"})]}),(0,a.jsxs)("p",{className:"text-text-muted",children:["After installation, run ",(0,a.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"opencode"})," to verify."]})]})]})]}),!C&&N?.installed&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Select Endpoint"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(k,{value:Z||Z||`${n}/v1`,onChange:Q,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:x,tunnelPublicUrl:u,tailscaleEnabled:p,tailscaleUrl:h,currentUrl:en})]}),N?.config?.provider?.["9router"]?.options?.baseURL&&(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Current"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)("span",{className:"min-w-0 truncate rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5",children:N.config.provider["9router"].options.baseURL})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(_,{value:U,onChange:D,apiKeys:o,cloudEnabled:c})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-start sm:gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right pt-1",children:"Models"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px] mt-1.5",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"flex-1 flex flex-col gap-2",children:[(0,a.jsx)("div",{className:"flex flex-wrap gap-1.5 min-h-[28px] px-2 py-1.5 bg-surface rounded border border-border",children:0===X.length?(0,a.jsx)("span",{className:"text-xs text-text-muted",children:"No models selected"}):X.map(e=>(0,a.jsxs)("span",{onClick:async()=>{if(e===es)try{(await fetch("/api/cli-tools/opencode-settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({clearActiveModel:!0})})).ok&&(ea(""),ec())}catch(e){console.log("Error clearing active model:",e)}else ea(e)},className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs cursor-pointer transition-colors ${e===es?"bg-primary/10 text-primary border border-primary":"bg-black/5 dark:bg-white/5 text-text-muted border border-transparent hover:border-border"}`,title:e===es?"Click to clear active model":"Click to set as active",children:[e===es&&(0,a.jsx)("span",{className:"material-symbols-outlined text-[10px]",children:"star"}),e,(0,a.jsx)("button",{onClick:async t=>{t.stopPropagation();try{if((await fetch(`/api/cli-tools/opencode-settings?model=${encodeURIComponent(e)}`,{method:"DELETE"})).ok){let t=X.filter(t=>t!==e);ee(t),es===e&&ea(""),ec()}}catch(e){console.log("Error removing model:",e)}},className:"ml-0.5 hover:text-red-500",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"close"})})]},e))}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("button",{onClick:()=>B(!0),disabled:!d?.length,className:`px-2 py-1 rounded border text-xs transition-colors ${d?.length?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Add Model"}),(0,a.jsx)("span",{className:"text-xs text-text-muted",children:X.length>0&&es?(0,a.jsxs)(a.Fragment,{children:["Active: ",(0,a.jsx)("span",{className:"text-primary",children:es})]}):X.length>0?(0,a.jsx)("span",{className:"text-yellow-500",children:"Click a model to set/clear active"}):"Select models to add"})]})]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Subagent Model"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)("input",{type:"text",value:F,onChange:e=>K(e.target.value),placeholder:z||"provider/model-id (defaults to main model)",className:"w-full min-w-0 px-2 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),(0,a.jsx)("button",{onClick:()=>W(!0),disabled:!d?.length,className:`w-full sm:w-auto rounded border px-2 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap sm:shrink-0 ${d?.length?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"}),F&&(0,a.jsx)("button",{onClick:()=>K(""),className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear (will use main model)",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]})]}),T&&(0,a.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===T.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===T.type?"check_circle":"error"}),(0,a.jsx)("span",{children:T.text})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,a.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:em,disabled:0===X.length,loading:A,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,a.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:ex,disabled:!N.has9Router,loading:M,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,a.jsxs)(r.$n,{variant:"ghost",size:"sm",onClick:()=>V(!0),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),q&&(0,a.jsx)(r.rq,{isOpen:q,onClose:()=>{B(!1),ei(el.current)},onSelect:e=>{!X.includes(e.value)&&(ee([...X,e.value]),es||ea(e.value))},onDeselect:e=>{let t=X.filter(t=>t!==e.value);ee(t),es===e.value&&ea(t[0]||"")},selectedModel:null,activeProviders:d,modelAliases:G,addedModelValues:X,closeOnSelect:!1,title:"Add Model for OpenCode"}),H&&(0,a.jsx)(r.rq,{isOpen:H,onClose:()=>W(!1),onSelect:e=>{K(e.value),W(!1)},selectedModel:F,activeProviders:d,modelAliases:G,title:"Select Subagent Model for OpenCode"}),(0,a.jsx)(r.uR,{isOpen:Y,onClose:()=>V(!1),title:"OpenCode - Manual Configuration",configs:(g=U&&U.trim()?U:c?"<API_KEY_FROM_DASHBOARD>":"sk_9router",f=X.length>0?X:["provider/model-id"],b=es||X[0]||f[0],y=F||b,v={},f.forEach(e=>{v[e]={name:e,modalities:{input:["text","image"],output:["text"]}}}),[{filename:"~/.config/opencode/opencode.json",content:JSON.stringify({provider:{"9router":{npm:"@ai-sdk/openai-compatible",options:{baseURL:ed(),apiKey:g},models:v}},model:`9router/${b}`,agent:{explorer:{description:"Fast explorer subagent for codebase exploration",mode:"subagent",model:`9router/${y}`}}},null,2)}])})]})}let es="/api/cli-tools/cowork-settings",ea=e=>(e||"").replace(/\/v1\/?$/,"");function el({tool:e,isExpanded:t,onToggle:s,baseUrl:n,apiKeys:o,activeProviders:d,hasActiveProviders:c,cloudEnabled:m,cloudUrl:x,tunnelEnabled:u,tunnelPublicUrl:p,tailscaleEnabled:h,tailscaleUrl:g,initialStatus:f}){let b,y,v,N,[w,C]=(0,l.useState)(f||null),[S,A]=(0,l.useState)(!1),[E,$]=(0,l.useState)(!1),[M,O]=(0,l.useState)(!1),[T,P]=(0,l.useState)(null),[R,I]=(0,l.useState)(""),[U,D]=(0,l.useState)([]),[z,L]=(0,l.useState)(!1),[F,K]=(0,l.useState)(""),[q,B]=(0,l.useState)([]),[H,W]=(0,l.useState)([]),[G,J]=(0,l.useState)([]),[Y,V]=(0,l.useState)({}),[Z,Q]=(0,l.useState)(!1),[X,ee]=(0,l.useState)(!1),[et,er]=(0,l.useState)(!1),[ei,en]=(0,l.useState)(!1),[eo,ed]=(0,l.useState)({name:"",url:""});(0,l.useEffect)(()=>{o?.length>0&&!R&&I(o[0].key)},[o,R]),(0,l.useEffect)(()=>{f&&C(f)},[f]),(0,l.useEffect)(()=>{t&&!w&&ec()},[t]),(0,l.useEffect)(()=>{t&&fetch("/api/models/alias").then(e=>e.ok?e.json():null).then(e=>{e&&V(e.aliases||{})}).catch(()=>{})},[t]),(0,l.useEffect)(()=>{w?.cowork?.models?.length&&D(w.cowork.models),w?.cowork?.baseUrl&&!F&&K(ea(w.cowork.baseUrl)),Array.isArray(w?.cowork?.plugins)&&w.cowork.plugins.length>0?B(w.cowork.plugins):0===q.length&&Array.isArray(w?.defaultPlugins)&&B(w.defaultPlugins),Array.isArray(w?.cowork?.localPlugins)&&W(w.cowork.localPlugins),Array.isArray(w?.cowork?.customPlugins)&&w.cowork.customPlugins.length>0&&J(w.cowork.customPlugins)},[w]);let ec=async()=>{A(!0);try{let e=await fetch(es),t=await e.json();C(t)}catch(e){C({installed:!1,error:e.message})}finally{A(!1)}},em=()=>{let e;return(e=(F||"").replace(/\/+$/,""))?/\/v1$/.test(e)?e:`${e}/v1`:""},ex=w?.cowork?.baseUrl||"",eu=w?.installed?w?.cowork?.baseUrl?w.has9Router?"configured":"other":"not_configured":null,ep=async()=>{P(null);let e=em();if(0===U.length)return void P({type:"error",text:"Please select at least one model"});$(!0);try{let t=R?.trim()||(o?.length>0?o[0].key:null)||(m?null:"sk_9router"),s=await fetch(es,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:e,apiKey:t,models:U,plugins:q,localPlugins:H,customPlugins:G})}),a=await s.json();s.ok?(j(em(),{tunnelPublicUrl:p,tailscaleUrl:g}),P({type:"success",text:"Settings applied. Quit & reopen Claude Desktop to load."}),ec()):P({type:"error",text:a.error||"Failed to apply settings"})}catch(e){P({type:"error",text:e.message})}finally{$(!1)}},eh=async({name:e,models:t})=>{try{let s=await fetch("/api/combos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,models:t})});if(!s.ok){let e=await s.json();P({type:"error",text:e.error||"Failed to create combo"});return}U.includes(e)||D([...U,e]),Q(!1),P({type:"success",text:`Combo "${e}" created and added.`})}catch(e){P({type:"error",text:e.message})}},eg=e=>{let t=e?.value||e?.name||e;D(e=>e.filter(e=>e!==t))},ef=async()=>{O(!0),P(null);try{let e=await fetch(es,{method:"DELETE"}),t=await e.json();e.ok?(P({type:"success",text:"Settings reset successfully"}),D([]),B(w?.defaultPlugins||[]),W([]),J([]),ec()):P({type:"error",text:t.error||"Failed to reset"})}catch(e){P({type:"error",text:e.message})}finally{O(!1)}};return(0,a.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3 hover:cursor-pointer sm:items-center",onClick:s,children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(i.A,{src:e.image,alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===eu&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===eu&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===eu&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[S&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,a.jsx)("span",{children:"Checking Claude Cowork..."})]}),!S&&w&&!w.installed&&(0,a.jsxs)("div",{className:"flex flex-col gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Claude Desktop (Cowork mode) not detected"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Open Claude Desktop → Help → Troubleshooting → Enable Developer mode → Configure third-party inference, then return here."})]})]}),(0,a.jsx)("div",{className:"pl-9",children:(0,a.jsxs)(r.$n,{variant:"secondary",size:"sm",onClick:()=>L(!0),className:"!bg-yellow-500/20 !border-yellow-500/40 !text-yellow-700 dark:!text-yellow-300 hover:!bg-yellow-500/30",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:"content_copy"}),"Manual Config"]})})]}),!S&&w?.installed&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Select Endpoint"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(k,{value:em(),onChange:e=>K(ea(e)),tunnelEnabled:u,tunnelPublicUrl:p,tailscaleEnabled:h,tailscaleUrl:g,cloudEnabled:m,cloudUrl:x,currentUrl:ex})]}),w?.cowork?.baseUrl&&(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Current"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)("span",{className:"min-w-0 truncate rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5",children:w.cowork.baseUrl})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(_,{value:R,onChange:I,apiKeys:o,cloudEnabled:m})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Models"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"flex-1 flex items-center gap-2",children:[(0,a.jsx)("div",{className:"flex-1 flex flex-wrap gap-1.5 min-h-[28px] px-2 py-1.5 bg-surface rounded border border-border",children:0===U.length?(0,a.jsx)("span",{className:"text-xs text-text-muted",children:"No models selected"}):U.map(e=>(0,a.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs bg-black/5 dark:bg-white/5 text-text-muted border border-transparent hover:border-border",children:[e,(0,a.jsx)("button",{onClick:()=>eg(e),className:"ml-0.5 hover:text-red-500",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"close"})})]},e))}),(0,a.jsx)("button",{onClick:()=>Q(!0),disabled:!c,className:`shrink-0 px-2 py-1.5 rounded border text-xs whitespace-nowrap transition-colors ${c?"bg-primary/10 border-primary/40 text-primary hover:bg-primary/20 cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"+ Combo"})]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-start sm:gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right pt-2",children:"MCP"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px] mt-2",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"flex-1 flex flex-col gap-1",children:[q.filter(e=>"exa"!==e.name).map(e=>(0,a.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1 bg-surface rounded border border-border",children:[(0,a.jsx)("span",{className:"text-xs font-medium min-w-0 truncate flex-shrink-0",children:e.title||e.name}),e.oauth&&(0,a.jsx)("span",{className:"text-[8px] text-amber-600 shrink-0",children:"OAuth"}),(0,a.jsxs)("div",{className:"flex-1 flex flex-wrap gap-1 overflow-hidden",style:{maxHeight:"1.5rem"},children:[Array.isArray(e.toolNames)&&e.toolNames.slice(0,6).map(e=>(0,a.jsx)("span",{className:"text-[9px] px-1 py-0.5 rounded bg-black/5 dark:bg-white/5 text-text-muted whitespace-nowrap",children:e},e)),Array.isArray(e.toolNames)&&e.toolNames.length>6&&(0,a.jsxs)("span",{className:"text-[9px] px-1 py-0.5 rounded bg-black/5 dark:bg-white/5 text-text-muted whitespace-nowrap",children:["+",e.toolNames.length-6]})]}),(0,a.jsx)("button",{onClick:()=>{var t;return t=e.name,void B(q.filter(e=>e.name!==t))},className:"shrink-0 hover:text-red-500 ml-auto",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"close"})})]},e.name)),G.map(e=>(0,a.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1 bg-surface rounded border border-border",children:[(0,a.jsx)("span",{className:"text-xs font-medium min-w-0 truncate flex-shrink-0",children:e.name}),(0,a.jsx)("span",{className:"text-[8px] px-1 py-0.5 rounded bg-blue-500/10 text-blue-500 shrink-0",children:"custom"}),(0,a.jsx)("span",{className:"flex-1 text-[9px] text-text-muted truncate",children:e.url}),(0,a.jsx)("button",{onClick:()=>J(G.filter(t=>t.name!==e.name)),className:"shrink-0 hover:text-red-500 ml-auto",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"close"})})]},e.name)),0===q.filter(e=>"exa"!==e.name).length&&0===G.length&&(0,a.jsx)("div",{className:"px-2 py-1.5 bg-surface rounded border border-border text-xs text-text-muted",children:"No MCPs added"}),(0,a.jsxs)("div",{className:"flex items-center gap-2 mt-0.5",children:[(0,a.jsx)("button",{onClick:()=>er(!0),className:"px-2 py-1 rounded border text-xs bg-primary/10 border-primary/40 text-primary hover:bg-primary/20 cursor-pointer whitespace-nowrap",children:"+ Browse"}),(0,a.jsx)("button",{onClick:()=>{ed({name:"",url:""}),en(!0)},className:"px-2 py-1 rounded border text-xs bg-surface border-border text-text-muted hover:border-primary hover:text-primary cursor-pointer whitespace-nowrap",children:"+ Custom"}),(0,a.jsx)("a",{href:"https://mcp.so",target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-text-muted hover:text-primary underline ml-auto",children:"Find MCPs →"})]})]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-start sm:gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right pt-1",children:"Tools"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px] mt-1.5",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"flex-1 flex flex-col gap-1.5",children:[(b=q.some(e=>"exa"===e.name),y=(w?.defaultPlugins||[]).find(e=>"exa"===e.name),(0,a.jsxs)("label",{className:"flex items-start gap-2 cursor-pointer px-2 py-1.5 bg-surface rounded border border-border",children:[(0,a.jsx)("input",{type:"checkbox",checked:b,onChange:e=>{e.target.checked&&y?B([...q.filter(e=>"exa"!==e.name),y]):B(q.filter(e=>"exa"!==e.name))},className:"mt-0.5"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("div",{className:"text-xs font-medium",children:"Web Search & Fetch (Exa)"}),(0,a.jsx)("p",{className:"text-[10px] text-text-muted leading-snug",children:"Replaces built-in WebSearch/WebFetch. Auto-strips duplicates from tool list."})]})]})),(()=>{let e=(w?.localStdioPlugins||[]).find(e=>"browsermcp"===e.name);if(!e)return null;let t=H.includes("browsermcp");return(0,a.jsxs)("label",{className:"flex items-start gap-2 cursor-pointer px-2 py-1.5 bg-surface rounded border border-border",children:[(0,a.jsx)("input",{type:"checkbox",checked:t,onChange:e=>W(e.target.checked?[...H,"browsermcp"]:H.filter(e=>"browsermcp"!==e)),className:"mt-0.5"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("div",{className:"text-xs font-medium",children:"Browser Control (Browser MCP)"}),(0,a.jsxs)("p",{className:"text-[10px] text-text-muted leading-snug",children:["Controls your running Chrome. Auto-strips Cowork's built-in browser tools."," ",(0,a.jsx)("a",{href:e.extensionUrl,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline",children:"Install Chrome extension"})]})]})]})})()]})]}),Array.isArray(w?.localStdioPlugins)&&w.localStdioPlugins.filter(e=>"browsermcp"!==e.name).length>0&&(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-start sm:gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right pt-1",children:"Local Plugins"}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px] mt-1.5",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"flex-1 flex flex-col gap-2",children:[(0,a.jsx)("div",{className:"flex flex-col gap-1.5 px-2 py-1.5 bg-surface rounded border border-border",children:w.localStdioPlugins.filter(e=>"browsermcp"!==e.name).map(e=>{let t=H.includes(e.name);return(0,a.jsxs)("label",{className:"flex items-start gap-2 cursor-pointer",children:[(0,a.jsx)("input",{type:"checkbox",checked:t,onChange:t=>W(t.target.checked?[...H,e.name]:H.filter(t=>t!==e.name)),className:"mt-0.5"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,a.jsx)("span",{className:"text-xs font-medium",children:e.title}),(0,a.jsx)("span",{className:"text-[8px] text-amber-600",children:"stdio"})]}),(0,a.jsx)("p",{className:"text-[10px] text-text-muted leading-snug",children:e.description}),e.extensionUrl&&(0,a.jsx)("a",{href:e.extensionUrl,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-primary underline",children:"Install Chrome extension"})]})]},e.name)})}),(0,a.jsxs)("p",{className:"text-[10px] text-text-muted leading-snug",children:["⚠️ Local plugins run as subprocess via ",(0,a.jsx)("code",{className:"px-1 py-0.5 rounded bg-black/5 dark:bg-white/5",children:"npx"}),". Requires Node.js installed."]})]})]})]}),T&&(0,a.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===T.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===T.type?"check_circle":"error"}),(0,a.jsx)("span",{children:T.text})]}),(0,a.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2",children:[(0,a.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:ep,disabled:0===U.length,loading:E,className:"w-full sm:w-auto",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,a.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:ef,disabled:!w.has9Router,loading:M,className:"w-full sm:w-auto",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,a.jsxs)(r.$n,{variant:"ghost",size:"sm",onClick:()=>L(!0),className:"w-full sm:w-auto",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),(0,a.jsx)(r.uR,{isOpen:z,onClose:()=>L(!1),title:"Claude Cowork - Manual Configuration",configs:(v=R&&R.trim()?R:m?"<API_KEY_FROM_DASHBOARD>":"sk_9router",N=U.length>0?U:["provider/model-id"],[{filename:"~/Library/Application Support/Claude-3p/configLibrary/<appliedId>.json",content:JSON.stringify({inferenceProvider:"gateway",inferenceGatewayBaseUrl:em()||"https://your-public-host/v1",inferenceGatewayApiKey:v,inferenceModels:N.map(e=>({name:e}))},null,2)}])}),Z&&(0,a.jsx)(r.CK,{isOpen:Z,combo:null,onClose:()=>Q(!1),onSave:eh,activeProviders:d,forcePrefix:"claude-",title:"Create Cowork Combo"}),X&&(0,a.jsx)(r.rq,{isOpen:X,onClose:()=>ee(!1),onSelect:e=>{let t=e?.value||e?.name||e;!t||U.includes(t)||D(e=>[...e,t])},onDeselect:eg,activeProviders:d,modelAliases:Y,title:"Select Cowork Model",addedModelValues:U,closeOnSelect:!1}),(0,a.jsx)(r.Nf,{isOpen:et,onClose:()=>er(!1),onAdd:e=>{q.some(t=>t.name===e.name)||B([...q,e])},addedNames:q.map(e=>e.name)}),ei&&(0,a.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40",onClick:()=>en(!1),children:(0,a.jsxs)("div",{className:"bg-surface border border-border rounded-xl shadow-xl w-full max-w-sm mx-4 p-5 flex flex-col gap-4",onClick:e=>e.stopPropagation(),children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("h3",{className:"font-semibold text-sm",children:"Add Custom MCP"}),(0,a.jsx)("button",{onClick:()=>en(!1),className:"text-text-muted hover:text-text-main",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"close"})})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,a.jsx)("label",{className:"text-[11px] text-text-muted font-medium",children:"Name"}),(0,a.jsx)("input",{type:"text",placeholder:"my-mcp",value:eo.name,onChange:e=>ed(t=>({...t,name:e.target.value.replace(/\s+/g,"-").toLowerCase()})),className:"px-2 py-1.5 rounded border border-border bg-surface text-xs outline-none focus:border-primary"})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,a.jsx)("label",{className:"text-[11px] text-text-muted font-medium",children:"SSE URL"}),(0,a.jsx)("input",{type:"text",placeholder:"https://your-mcp-server.com/sse",value:eo.url,onChange:e=>ed(t=>({...t,url:e.target.value})),className:"px-2 py-1.5 rounded border border-border bg-surface text-xs outline-none focus:border-primary"})]})]}),(0,a.jsxs)("div",{className:"flex gap-2 justify-end",children:[(0,a.jsx)("button",{onClick:()=>en(!1),className:"px-3 py-1.5 rounded border border-border text-xs text-text-muted hover:bg-surface cursor-pointer",children:"Cancel"}),(0,a.jsx)("button",{onClick:()=>{let e=eo.name.trim();e&&eo.url.trim()&&(J(t=>[...t.filter(t=>t.name!==e),{name:e,url:eo.url.trim(),transport:"sse",custom:!0}]),en(!1))},className:"px-3 py-1.5 rounded bg-primary text-white text-xs font-medium hover:opacity-90 cursor-pointer",children:"Add"})]})]})})]})}function er({tool:e,isExpanded:t,onToggle:s,baseUrl:n,apiKeys:o,activeProviders:d,cloudEnabled:c,initialStatus:m,tunnelEnabled:x,tunnelPublicUrl:u,tailscaleEnabled:p,tailscaleUrl:h}){let g,f,[b,y]=(0,l.useState)(m||null),[v,N]=(0,l.useState)(!1),[w,C]=(0,l.useState)(!1),[S,A]=(0,l.useState)(!1),[$,M]=(0,l.useState)(null),[O,T]=(0,l.useState)(!1),[P,R]=(0,l.useState)(""),[I,U]=(0,l.useState)(""),[D,z]=(0,l.useState)(!1),[L,F]=(0,l.useState)({}),[K,q]=(0,l.useState)(!1),[B,H]=(0,l.useState)("");(0,l.useEffect)(()=>{o?.length>0&&!P&&R(o[0].key)},[o,P]),(0,l.useEffect)(()=>{m&&y(m)},[m]),(0,l.useEffect)(()=>{t&&(b||V(),W())},[t]),(0,l.useEffect)(()=>{b?.settings?.openAiModelId&&U(b.settings.openAiModelId)},[b]);let W=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&F(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}},G=b?.settings?.openAiBaseUrl||"",J=b?.installed?b.has9Router?E(b.settings?.openAiBaseUrl||"",{tunnelPublicUrl:u,tailscaleUrl:h})?"configured":"other":"not_configured":null,Y=()=>{let e=B||`${n}/v1`;return e.endsWith("/v1")?e:`${e}/v1`},V=async()=>{N(!0);try{let e=await fetch("/api/cli-tools/cline-settings"),t=await e.json();y(t)}catch(e){y({installed:!1,error:e.message})}finally{N(!1)}},Z=async()=>{C(!0),M(null);try{let e=P&&P.trim()||c?P:"sk_9router",t=await fetch("/api/cli-tools/cline-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:Y(),apiKey:e,model:I})}),s=await t.json();t.ok?(j(Y(),{tunnelPublicUrl:u,tailscaleUrl:h}),M({type:"success",text:"Settings applied successfully!"}),V()):M({type:"error",text:s.error||"Failed to apply settings"})}catch(e){M({type:"error",text:e.message})}finally{C(!1)}},Q=async()=>{A(!0),M(null);try{let e=await fetch("/api/cli-tools/cline-settings",{method:"DELETE"}),t=await e.json();e.ok?(M({type:"success",text:"Settings reset successfully!"}),U(""),V()):M({type:"error",text:t.error||"Failed to reset settings"})}catch(e){M({type:"error",text:e.message})}finally{A(!1)}};return(0,a.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3 hover:cursor-pointer sm:items-center",onClick:s,children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(i.A,{src:"/providers/cline.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===J&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===J&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===J&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[v&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,a.jsx)("span",{children:"Checking Cline..."})]}),!v&&b&&!b.installed&&(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Cline not detected locally"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if 9router is deployed on a remote server."})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 pl-9",children:[(0,a.jsxs)(r.$n,{variant:"secondary",size:"sm",onClick:()=>q(!0),className:"!bg-yellow-500/20 !border-yellow-500/40 !text-yellow-700 dark:!text-yellow-300 hover:!bg-yellow-500/30",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:"content_copy"}),"Manual Config"]}),(0,a.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:()=>T(!O),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:O?"expand_less":"help"}),O?"Hide":"How to Install"]})]})]}),O&&(0,a.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,a.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,a.jsx)("div",{className:"space-y-3 text-sm",children:(0,a.jsxs)("p",{className:"text-text-muted",children:["Install Cline VS Code extension or CLI from ",(0,a.jsx)("a",{className:"text-primary underline",href:"https://docs.cline.bot/",target:"_blank",rel:"noreferrer",children:"docs.cline.bot"}),"."]})})]})]}),!v&&b?.installed&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Select Endpoint"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(k,{value:B||B||`${n}/v1`,onChange:H,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:x,tunnelPublicUrl:u,tailscaleEnabled:p,tailscaleUrl:h,currentUrl:G})]}),b?.settings?.openAiBaseUrl&&(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Current"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)("span",{className:"min-w-0 truncate rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5",children:b.settings.openAiBaseUrl})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(_,{value:P,onChange:R,apiKeys:o,cloudEnabled:c})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Model"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,a.jsx)("input",{type:"text",value:I,onChange:e=>U(e.target.value),placeholder:"provider/model-id",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),I&&(0,a.jsx)("button",{onClick:()=>U(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,a.jsx)("button",{onClick:()=>z(!0),disabled:!d?.length,className:`w-full sm:w-auto rounded border px-2 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap sm:shrink-0 ${d?.length?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"})]})]}),$&&(0,a.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===$.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===$.type?"check_circle":"error"}),(0,a.jsx)("span",{children:$.text})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,a.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:Z,disabled:!P&&c&&o.length>0||!I,loading:w,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,a.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:Q,disabled:S,loading:S,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,a.jsxs)(r.$n,{variant:"ghost",size:"sm",onClick:()=>q(!0),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),D&&(0,a.jsx)(r.rq,{isOpen:D,onClose:()=>z(!1),onSelect:e=>{U(e.value),z(!1)},selectedModel:I,activeProviders:d,modelAliases:L,title:"Select Model for Cline"}),(0,a.jsx)(r.uR,{isOpen:K,onClose:()=>q(!1),title:"Cline - Manual Configuration",configs:(g=P&&P.trim()?P:c?"<API_KEY_FROM_DASHBOARD>":"sk_9router",[{filename:"~/.cline/data/globalState.json",content:JSON.stringify({actModeApiProvider:"openai",planModeApiProvider:"openai",openAiBaseUrl:(f=Y()).endsWith("/v1")?f.slice(0,-3):f,openAiModelId:I||"provider/model-id",planModeOpenAiModelId:I||"provider/model-id"},null,2)},{filename:"~/.cline/data/secrets.json",content:JSON.stringify({openAiApiKey:g},null,2)}])})]})}function ei({tool:e,isExpanded:t,onToggle:s,baseUrl:n,apiKeys:o,activeProviders:d,cloudEnabled:c,initialStatus:m,tunnelEnabled:x,tunnelPublicUrl:u,tailscaleEnabled:p,tailscaleUrl:h}){let[g,f]=(0,l.useState)(m||null),[b,y]=(0,l.useState)(!1),[v,N]=(0,l.useState)(!1),[w,C]=(0,l.useState)(!1),[S,A]=(0,l.useState)(null),[E,$]=(0,l.useState)(!1),[M,O]=(0,l.useState)(""),[T,P]=(0,l.useState)(""),[R,I]=(0,l.useState)(!1),[U,D]=(0,l.useState)({}),[z,L]=(0,l.useState)(!1),[F,K]=(0,l.useState)("");(0,l.useEffect)(()=>{o?.length>0&&!M&&O(o[0].key)},[o,M]),(0,l.useEffect)(()=>{m&&f(m)},[m]),(0,l.useEffect)(()=>{t&&(g||W(),q())},[t]);let q=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&D(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}},B=g?.installed?g.has9Router?"configured":"not_configured":null,H=()=>{let e=F||`${n}/v1`;return e.endsWith("/v1")?e:`${e}/v1`},W=async()=>{y(!0);try{let e=await fetch("/api/cli-tools/kilo-settings"),t=await e.json();f(t)}catch(e){f({installed:!1,error:e.message})}finally{y(!1)}},G=async()=>{N(!0),A(null);try{let e=M&&M.trim()||c?M:"sk_9router",t=await fetch("/api/cli-tools/kilo-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:H(),apiKey:e,model:T})}),s=await t.json();t.ok?(j(H(),{tunnelPublicUrl:u,tailscaleUrl:h}),A({type:"success",text:"Settings applied successfully!"}),W()):A({type:"error",text:s.error||"Failed to apply settings"})}catch(e){A({type:"error",text:e.message})}finally{N(!1)}},J=async()=>{C(!0),A(null);try{let e=await fetch("/api/cli-tools/kilo-settings",{method:"DELETE"}),t=await e.json();e.ok?(A({type:"success",text:"Settings reset successfully!"}),P(""),W()):A({type:"error",text:t.error||"Failed to reset settings"})}catch(e){A({type:"error",text:e.message})}finally{C(!1)}};return(0,a.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3 hover:cursor-pointer sm:items-center",onClick:s,children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(i.A,{src:"/providers/kilocode.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===B&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===B&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[b&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,a.jsx)("span",{children:"Checking Kilo Code..."})]}),!b&&g&&!g.installed&&(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Kilo Code not detected locally"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if 9router is deployed on a remote server."})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 pl-9",children:[(0,a.jsxs)(r.$n,{variant:"secondary",size:"sm",onClick:()=>L(!0),className:"!bg-yellow-500/20 !border-yellow-500/40 !text-yellow-700 dark:!text-yellow-300 hover:!bg-yellow-500/30",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:"content_copy"}),"Manual Config"]}),(0,a.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:()=>$(!E),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:E?"expand_less":"help"}),E?"Hide":"How to Install"]})]})]}),E&&(0,a.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,a.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,a.jsxs)("p",{className:"text-sm text-text-muted",children:["Install Kilo Code from ",(0,a.jsx)("a",{className:"text-primary underline",href:"https://kilocode.ai",target:"_blank",rel:"noreferrer",children:"kilocode.ai"})," or VS Code extension marketplace."]})]})]}),!b&&g?.installed&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Select Endpoint"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(k,{value:F||F||`${n}/v1`,onChange:K,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:x,tunnelPublicUrl:u,tailscaleEnabled:p,tailscaleUrl:h})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(_,{value:M,onChange:O,apiKeys:o,cloudEnabled:c})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Model"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,a.jsx)("input",{type:"text",value:T,onChange:e=>P(e.target.value),placeholder:"provider/model-id",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),T&&(0,a.jsx)("button",{onClick:()=>P(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,a.jsx)("button",{onClick:()=>I(!0),disabled:!d?.length,className:`w-full sm:w-auto rounded border px-2 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap sm:shrink-0 ${d?.length?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"})]})]}),S&&(0,a.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===S.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===S.type?"check_circle":"error"}),(0,a.jsx)("span",{children:S.text})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,a.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:G,disabled:!M&&c&&o.length>0||!T,loading:v,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,a.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:J,disabled:w,loading:w,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,a.jsxs)(r.$n,{variant:"ghost",size:"sm",onClick:()=>L(!0),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),R&&(0,a.jsx)(r.rq,{isOpen:R,onClose:()=>I(!1),onSelect:e=>{P(e.value),I(!1)},selectedModel:T,activeProviders:d,modelAliases:U,title:"Select Model for Kilo Code"}),(0,a.jsx)(r.uR,{isOpen:z,onClose:()=>L(!1),title:"Kilo Code - Manual Configuration",configs:[{filename:"~/.local/share/kilo/auth.json",content:JSON.stringify({"openai-compatible":{type:"api-key",apiKey:M&&M.trim()?M:c?"<API_KEY_FROM_DASHBOARD>":"sk_9router",baseUrl:H(),model:T||"provider/model-id"}},null,2)}]})]})}let en="/api/cli-tools/deepseek-tui-settings";function eo({tool:e,isExpanded:t,onToggle:s,baseUrl:n,hasActiveProviders:o,apiKeys:d,activeProviders:c,cloudEnabled:m,initialStatus:x,tunnelEnabled:u,tunnelPublicUrl:p,tailscaleEnabled:h,tailscaleUrl:g}){let f,[b,y]=(0,l.useState)(x||null),[v,N]=(0,l.useState)(!1),[w,C]=(0,l.useState)(!1),[S,A]=(0,l.useState)(!1),[$,M]=(0,l.useState)(null),[O,T]=(0,l.useState)(""),[P,R]=(0,l.useState)(""),[I,U]=(0,l.useState)(!1),[D,z]=(0,l.useState)({}),[L,F]=(0,l.useState)(!1),[K,q]=(0,l.useState)(""),B=(0,l.useRef)(!1),H=b?.settings?.["providers.openai"]?.base_url||"",W=(()=>{if(!b?.installed)return null;let e=b.settings?.["providers.openai"];return e?.base_url?E(e.base_url,{tunnelPublicUrl:p,tailscaleUrl:g})?"configured":"other":"not_configured"})();(0,l.useEffect)(()=>{d?.length>0&&!O&&T(d[0].key)},[d,O]),(0,l.useEffect)(()=>{x&&y(x)},[x]),(0,l.useEffect)(()=>{t&&(b||J(),G())},[t]);let G=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&z(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}};(0,l.useEffect)(()=>{if(b?.installed&&!B.current){B.current=!0;let e=b.settings?.["providers.openai"];e?.model&&R(e.model)}},[b]);let J=async()=>{N(!0);try{let e=await fetch(en),t=await e.json();y(t)}catch(e){y({installed:!1,error:e.message})}finally{N(!1)}},Y=()=>{let e=K||window.location.origin.replace("://localhost","://127.0.0.1");return e.endsWith("/v1")?e:`${e}/v1`},V=async()=>{C(!0),M(null);try{let e=O?.trim()||(d?.length>0?d[0].key:null)||(m?null:"sk_9router"),t=await fetch(en,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:Y(),apiKey:e,model:P})}),s=await t.json();t.ok?(j(Y(),{tunnelPublicUrl:p,tailscaleUrl:g}),M({type:"success",text:"Settings applied successfully!"}),J()):M({type:"error",text:s.error||"Failed to apply settings"})}catch(e){M({type:"error",text:e.message})}finally{C(!1)}},Z=async()=>{A(!0),M(null);try{let e=await fetch(en,{method:"DELETE"}),t=await e.json();e.ok?(M({type:"success",text:"Settings reset successfully!"}),R(""),J()):M({type:"error",text:t.error||"Failed to reset settings"})}catch(e){M({type:"error",text:e.message})}finally{A(!1)}};return(0,a.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3 hover:cursor-pointer sm:items-center",onClick:s,children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(i.A,{src:e.image||"/providers/deepseek-tui.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===W&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===W&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===W&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[v&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,a.jsx)("span",{children:"Checking DeepSeek TUI..."})]}),!v&&b&&!b.installed&&(0,a.jsx)("div",{className:"flex flex-col gap-4",children:(0,a.jsxs)("div",{className:"flex flex-col gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"DeepSeek TUI not detected locally"}),(0,a.jsx)("p",{className:"text-sm text-text-muted mt-1",children:"Install via npm:"}),(0,a.jsx)("code",{className:"block mt-2 p-2 bg-black/20 rounded text-xs font-mono",children:"npm install -g deepseek-tui"}),(0,a.jsx)("p",{className:"text-sm text-text-muted mt-2",children:"Manual configuration is still available if 9router is deployed on a remote server."})]})]}),(0,a.jsx)("div",{className:"flex items-center gap-2 pl-9",children:(0,a.jsxs)(r.$n,{variant:"secondary",size:"sm",onClick:()=>F(!0),className:"!bg-yellow-500/20 !border-yellow-500/40 !text-yellow-700 dark:!text-yellow-300 hover:!bg-yellow-500/30",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:"content_copy"}),"Manual Config"]})})]})}),!v&&b?.installed&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[e.notes&&e.notes.length>0&&(0,a.jsx)("div",{className:"flex flex-col gap-2 mb-2",children:e.notes.map((e,t)=>(0,a.jsxs)("div",{className:`flex items-start gap-2 p-2 rounded text-xs ${"warning"===e.type?"bg-yellow-500/10 text-yellow-600 dark:text-yellow-400":"error"===e.type?"bg-red-500/10 text-red-600 dark:text-red-400":"bg-blue-500/10 text-blue-600 dark:text-blue-400"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mt-0.5",children:"warning"===e.type?"warning":"error"===e.type?"error":"info"}),(0,a.jsx)("span",{children:e.text})]},t))}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Select Endpoint"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(k,{value:K||Y(),onChange:q,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:u,tunnelPublicUrl:p,tailscaleEnabled:h,tailscaleUrl:g,currentUrl:H})]}),b?.settings?.["providers.openai"]?.base_url&&(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Current"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)("span",{className:"min-w-0 truncate rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5",children:b.settings["providers.openai"].base_url})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(_,{value:O,onChange:T,apiKeys:d,cloudEnabled:m})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Default Model"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,a.jsx)("input",{type:"text",value:P,onChange:e=>R(e.target.value),placeholder:"provider/model-id",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),P&&(0,a.jsx)("button",{onClick:()=>R(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,a.jsx)("button",{onClick:()=>U(!0),disabled:!o,className:`w-full sm:w-auto rounded border px-2 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap sm:shrink-0 ${o?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"})]})]}),$&&(0,a.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===$.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===$.type?"check_circle":"error"}),(0,a.jsx)("span",{children:$.text})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,a.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:V,disabled:!P,loading:w,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,a.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:Z,disabled:!b?.has9Router,loading:S,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,a.jsxs)(r.$n,{variant:"ghost",size:"sm",onClick:()=>F(!0),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),I&&(0,a.jsx)(r.rq,{isOpen:I,onClose:()=>U(!1),onSelect:e=>{R(e.value),U(!1)},selectedModel:P,activeProviders:c,modelAliases:D,title:"Select Model for DeepSeek TUI"}),(0,a.jsx)(r.uR,{isOpen:L,onClose:()=>F(!1),title:"DeepSeek TUI - Manual Configuration",configs:(f=O&&O.trim()?O:m?"<API_KEY_FROM_DASHBOARD>":"sk_9router",[{filename:"~/.deepseek/config.toml",content:`[providers.openai]
|
|
84
84
|
base_url = "${Y()}"
|
|
85
85
|
api_key = "${f}"
|
|
86
86
|
model = "${P||"provider/model-id"}"
|
|
87
|
-
`}])})]})}function ed({tool:e,isExpanded:t,onToggle:s,baseUrl:n,hasActiveProviders:o,apiKeys:d,activeProviders:c,cloudEnabled:m,initialStatus:x,tunnelEnabled:u,tunnelPublicUrl:p,tailscaleEnabled:h,tailscaleUrl:g}){let f,b,[y,v]=(0,l.useState)(x||null),[N,w]=(0,l.useState)(!1),[C,_]=(0,l.useState)(!1),[A,$]=(0,l.useState)(!1),[M,O]=(0,l.useState)(null),[T,P]=(0,l.useState)(""),[R,I]=(0,l.useState)(""),[U,D]=(0,l.useState)(!1),[z,L]=(0,l.useState)({}),[F,K]=(0,l.useState)(!1),[q,B]=(0,l.useState)(""),H=(0,l.useRef)(!1),W=y?.config?.providers?.["9router"]?.base_url||"",G=(()=>{if(!y?.installed)return null;if(!y?.has9Router)return"not_configured";let e=y.config?.providers?.["9router"];return e?E(e.base_url,{tunnelPublicUrl:p,tailscaleUrl:g})?"configured":"other":"not_configured"})();(0,l.useEffect)(()=>{d?.length>0&&!T&&P(d[0].key)},[d,T]),(0,l.useEffect)(()=>{x&&v(x)},[x]),(0,l.useEffect)(()=>{t&&(y||Y(),J())},[t]);let J=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&L(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}};(0,l.useEffect)(()=>{if(y?.installed&&!H.current){H.current=!0;let e=y.config?.providers?.["9router"];if(e){e.default_model&&I(e.default_model);let t=y.envApiKey;t&&d?.some(e=>e.key===t)&&P(t)}}},[y,d]);let Y=async()=>{w(!0);try{let e=await fetch("/api/cli-tools/jcode-settings"),t=await e.json();v(t)}catch(e){v({installed:!1,error:e.message})}finally{w(!1)}},V=()=>window.location.origin.replace("://localhost","://127.0.0.1"),Z=()=>{let e=q||V();return e.endsWith("/v1")?e:`${e}/v1`},Q=async()=>{_(!0),O(null);try{let e=T?.trim()||(d?.length>0?d[0].key:null)||(m?null:"sk_9router"),t=await fetch("/api/cli-tools/jcode-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:Z(),apiKey:e,models:R?[R]:[]})}),s=await t.json();t.ok?(j(Z(),{tunnelPublicUrl:p,tailscaleUrl:g}),O({type:"success",text:"Settings applied successfully!"}),Y()):O({type:"error",text:s.error||"Failed to apply settings"})}catch(e){O({type:"error",text:e.message})}finally{_(!1)}},X=async()=>{$(!0),O(null);try{let e=await fetch("/api/cli-tools/jcode-settings",{method:"DELETE"}),t=await e.json();e.ok?(O({type:"success",text:"Settings reset successfully!"}),I(""),P(""),Y()):O({type:"error",text:t.error||"Failed to reset settings"})}catch(e){O({type:"error",text:e.message})}finally{$(!1)}};return(0,a.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3 hover:cursor-pointer sm:items-center",onClick:s,children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(i.A,{src:e.image||"/providers/jcode.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===G&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===G&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===G&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[N&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,a.jsx)("span",{children:"Checking jcode CLI..."})]}),!N&&y&&!y.installed&&(0,a.jsx)("div",{className:"flex flex-col gap-4",children:(0,a.jsxs)("div",{className:"flex flex-col gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"jcode CLI not detected locally"}),(0,a.jsx)("p",{className:"text-sm text-text-muted mt-1",children:"Install jcode to enable automatic configuration:"}),(0,a.jsx)("code",{className:"block mt-2 p-2 bg-black/20 rounded text-xs font-mono",children:"curl -fsSL https://raw.githubusercontent.com/1jehuang/jcode/master/scripts/install.sh | bash"}),(0,a.jsx)("p",{className:"text-sm text-text-muted mt-2",children:"Manual configuration is still available if 9router is deployed on a remote server."})]})]}),(0,a.jsx)("div",{className:"flex items-center gap-2 pl-9",children:(0,a.jsxs)(r.$n,{variant:"secondary",size:"sm",onClick:()=>K(!0),className:"!bg-yellow-500/20 !border-yellow-500/40 !text-yellow-700 dark:!text-yellow-300 hover:!bg-yellow-500/30",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:"content_copy"}),"Manual Config"]})})]})}),!N&&y?.installed&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[e.notes&&e.notes.length>0&&(0,a.jsx)("div",{className:"flex flex-col gap-2 mb-2",children:e.notes.map((e,t)=>(0,a.jsxs)("div",{className:`flex items-start gap-2 p-2 rounded text-xs ${"info"===e.type?"bg-blue-500/10 text-blue-600 dark:text-blue-400":"warning"===e.type?"bg-yellow-500/10 text-yellow-600 dark:text-yellow-400":"bg-gray-500/10 text-text-muted"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mt-0.5",children:"info"===e.type?"info":"warning"===e.type?"warning":"help"}),(0,a.jsx)("span",{children:e.text})]},t))}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Select Endpoint"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(k,{value:q||((f=q||V()).endsWith("/v1")?f:`${f}/v1`),onChange:B,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:u,tunnelPublicUrl:p,tailscaleEnabled:h,tailscaleUrl:g,currentUrl:W})]}),y?.config?.providers?.["9router"]?.base_url&&(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Current"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)("span",{className:"min-w-0 truncate rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5",children:y.config.providers["9router"].base_url})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(S,{value:T,onChange:P,apiKeys:d,cloudEnabled:m})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Default Model"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,a.jsx)("input",{type:"text",value:R,onChange:e=>I(e.target.value),placeholder:"cc/claude-opus-4-7",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),R&&(0,a.jsx)("button",{onClick:()=>I(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,a.jsx)("button",{onClick:()=>D(!0),disabled:!o,className:`w-full sm:w-auto rounded border px-2 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap sm:shrink-0 ${o?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1 p-3 bg-blue-500/5 border border-blue-500/20 rounded-lg",children:[(0,a.jsx)("p",{className:"text-xs font-medium text-blue-600 dark:text-blue-400",children:"Usage:"}),(0,a.jsx)("code",{className:"text-xs font-mono text-text-muted",children:"jcode --provider-profile 9router"}),(0,a.jsxs)("code",{className:"text-xs font-mono text-text-muted",children:["jcode --provider-profile 9router --model ",R||"cc/claude-opus-4-7"]})]})]}),M&&(0,a.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===M.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===M.type?"check_circle":"error"}),(0,a.jsx)("span",{children:M.text})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,a.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:Q,disabled:!R,loading:C,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,a.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:X,disabled:!y?.has9Router,loading:A,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,a.jsxs)(r.$n,{variant:"ghost",size:"sm",onClick:()=>K(!0),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),U&&(0,a.jsx)(r.rq,{isOpen:U,onClose:()=>D(!1),onSelect:e=>{I(e.value),D(!1)},selectedModel:R,activeProviders:c,modelAliases:z,title:"Select Model for jcode"}),(0,a.jsx)(r.uR,{isOpen:F,onClose:()=>K(!1),title:"jcode - Manual Configuration",configs:(b=T&&T.trim()?T:m?"<API_KEY_FROM_DASHBOARD>":"sk_9router",[{filename:"~/.jcode/config.toml",content:`[providers.9router]
|
|
87
|
+
`}])})]})}function ed({tool:e,isExpanded:t,onToggle:s,baseUrl:n,hasActiveProviders:o,apiKeys:d,activeProviders:c,cloudEnabled:m,initialStatus:x,tunnelEnabled:u,tunnelPublicUrl:p,tailscaleEnabled:h,tailscaleUrl:g}){let f,b,[y,v]=(0,l.useState)(x||null),[N,w]=(0,l.useState)(!1),[C,S]=(0,l.useState)(!1),[A,$]=(0,l.useState)(!1),[M,O]=(0,l.useState)(null),[T,P]=(0,l.useState)(""),[R,I]=(0,l.useState)(""),[U,D]=(0,l.useState)(!1),[z,L]=(0,l.useState)({}),[F,K]=(0,l.useState)(!1),[q,B]=(0,l.useState)(""),H=(0,l.useRef)(!1),W=y?.config?.providers?.["9router"]?.base_url||"",G=(()=>{if(!y?.installed)return null;if(!y?.has9Router)return"not_configured";let e=y.config?.providers?.["9router"];return e?E(e.base_url,{tunnelPublicUrl:p,tailscaleUrl:g})?"configured":"other":"not_configured"})();(0,l.useEffect)(()=>{d?.length>0&&!T&&P(d[0].key)},[d,T]),(0,l.useEffect)(()=>{x&&v(x)},[x]),(0,l.useEffect)(()=>{t&&(y||Y(),J())},[t]);let J=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&L(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}};(0,l.useEffect)(()=>{if(y?.installed&&!H.current){H.current=!0;let e=y.config?.providers?.["9router"];if(e){e.default_model&&I(e.default_model);let t=y.envApiKey;t&&d?.some(e=>e.key===t)&&P(t)}}},[y,d]);let Y=async()=>{w(!0);try{let e=await fetch("/api/cli-tools/jcode-settings"),t=await e.json();v(t)}catch(e){v({installed:!1,error:e.message})}finally{w(!1)}},V=()=>window.location.origin.replace("://localhost","://127.0.0.1"),Z=()=>{let e=q||V();return e.endsWith("/v1")?e:`${e}/v1`},Q=async()=>{S(!0),O(null);try{let e=T?.trim()||(d?.length>0?d[0].key:null)||(m?null:"sk_9router"),t=await fetch("/api/cli-tools/jcode-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:Z(),apiKey:e,models:R?[R]:[]})}),s=await t.json();t.ok?(j(Z(),{tunnelPublicUrl:p,tailscaleUrl:g}),O({type:"success",text:"Settings applied successfully!"}),Y()):O({type:"error",text:s.error||"Failed to apply settings"})}catch(e){O({type:"error",text:e.message})}finally{S(!1)}},X=async()=>{$(!0),O(null);try{let e=await fetch("/api/cli-tools/jcode-settings",{method:"DELETE"}),t=await e.json();e.ok?(O({type:"success",text:"Settings reset successfully!"}),I(""),P(""),Y()):O({type:"error",text:t.error||"Failed to reset settings"})}catch(e){O({type:"error",text:e.message})}finally{$(!1)}};return(0,a.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3 hover:cursor-pointer sm:items-center",onClick:s,children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(i.A,{src:e.image||"/providers/jcode.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===G&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===G&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===G&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[N&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,a.jsx)("span",{children:"Checking jcode CLI..."})]}),!N&&y&&!y.installed&&(0,a.jsx)("div",{className:"flex flex-col gap-4",children:(0,a.jsxs)("div",{className:"flex flex-col gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"jcode CLI not detected locally"}),(0,a.jsx)("p",{className:"text-sm text-text-muted mt-1",children:"Install jcode to enable automatic configuration:"}),(0,a.jsx)("code",{className:"block mt-2 p-2 bg-black/20 rounded text-xs font-mono",children:"curl -fsSL https://raw.githubusercontent.com/1jehuang/jcode/master/scripts/install.sh | bash"}),(0,a.jsx)("p",{className:"text-sm text-text-muted mt-2",children:"Manual configuration is still available if 9router is deployed on a remote server."})]})]}),(0,a.jsx)("div",{className:"flex items-center gap-2 pl-9",children:(0,a.jsxs)(r.$n,{variant:"secondary",size:"sm",onClick:()=>K(!0),className:"!bg-yellow-500/20 !border-yellow-500/40 !text-yellow-700 dark:!text-yellow-300 hover:!bg-yellow-500/30",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:"content_copy"}),"Manual Config"]})})]})}),!N&&y?.installed&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[e.notes&&e.notes.length>0&&(0,a.jsx)("div",{className:"flex flex-col gap-2 mb-2",children:e.notes.map((e,t)=>(0,a.jsxs)("div",{className:`flex items-start gap-2 p-2 rounded text-xs ${"info"===e.type?"bg-blue-500/10 text-blue-600 dark:text-blue-400":"warning"===e.type?"bg-yellow-500/10 text-yellow-600 dark:text-yellow-400":"bg-gray-500/10 text-text-muted"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mt-0.5",children:"info"===e.type?"info":"warning"===e.type?"warning":"help"}),(0,a.jsx)("span",{children:e.text})]},t))}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Select Endpoint"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(k,{value:q||((f=q||V()).endsWith("/v1")?f:`${f}/v1`),onChange:B,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:u,tunnelPublicUrl:p,tailscaleEnabled:h,tailscaleUrl:g,currentUrl:W})]}),y?.config?.providers?.["9router"]?.base_url&&(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Current"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)("span",{className:"min-w-0 truncate rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5",children:y.config.providers["9router"].base_url})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(_,{value:T,onChange:P,apiKeys:d,cloudEnabled:m})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Default Model"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,a.jsx)("input",{type:"text",value:R,onChange:e=>I(e.target.value),placeholder:"cc/claude-opus-4-7",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),R&&(0,a.jsx)("button",{onClick:()=>I(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,a.jsx)("button",{onClick:()=>D(!0),disabled:!o,className:`w-full sm:w-auto rounded border px-2 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap sm:shrink-0 ${o?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1 p-3 bg-blue-500/5 border border-blue-500/20 rounded-lg",children:[(0,a.jsx)("p",{className:"text-xs font-medium text-blue-600 dark:text-blue-400",children:"Usage:"}),(0,a.jsx)("code",{className:"text-xs font-mono text-text-muted",children:"jcode --provider-profile 9router"}),(0,a.jsxs)("code",{className:"text-xs font-mono text-text-muted",children:["jcode --provider-profile 9router --model ",R||"cc/claude-opus-4-7"]})]})]}),M&&(0,a.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===M.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===M.type?"check_circle":"error"}),(0,a.jsx)("span",{children:M.text})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,a.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:Q,disabled:!R,loading:C,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,a.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:X,disabled:!y?.has9Router,loading:A,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,a.jsxs)(r.$n,{variant:"ghost",size:"sm",onClick:()=>K(!0),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),U&&(0,a.jsx)(r.rq,{isOpen:U,onClose:()=>D(!1),onSelect:e=>{I(e.value),D(!1)},selectedModel:R,activeProviders:c,modelAliases:z,title:"Select Model for jcode"}),(0,a.jsx)(r.uR,{isOpen:F,onClose:()=>K(!1),title:"jcode - Manual Configuration",configs:(b=T&&T.trim()?T:m?"<API_KEY_FROM_DASHBOARD>":"sk_9router",[{filename:"~/.jcode/config.toml",content:`[providers.9router]
|
|
88
88
|
type = "openai-compatible"
|
|
89
89
|
base_url = "${Z()}"
|
|
90
90
|
auth = "bearer"
|
|
@@ -94,7 +94,7 @@ default_model = "${R||"cc/claude-opus-4-7"}"
|
|
|
94
94
|
requires_api_key = true
|
|
95
95
|
|
|
96
96
|
[[providers.9router.models]]
|
|
97
|
-
id = "${R||"cc/claude-opus-4-7"}"`},{filename:"~/.config/jcode/provider-9router.env",content:`JCODE_9ROUTER_API_KEY="${b}"`}])})]})}let ec=new Set(["success","error"]),em={pending:{variant:"default",label:"Pending"},running:{variant:"info",label:"Running"},waiting:{variant:"warning",label:"Waiting"},success:{variant:"success",label:"Done"},error:{variant:"error",label:"Failed"}};function ex({status:e}){return e?e.platformSupported?e.installed?(0,a.jsx)(r.Ex,{variant:"success",size:"sm",children:"Installed"}):e.cursorDetected?(0,a.jsx)(r.Ex,{variant:"warning",size:"sm",children:"Ready"}):(0,a.jsx)(r.Ex,{variant:"default",size:"sm",children:"Cursor not found"}):(0,a.jsx)(r.Ex,{variant:"error",size:"sm",children:"Unsupported platform"}):(0,a.jsx)(r.Ex,{size:"sm",children:"Loading"})}function eu({step:e}){let t=em[e.status]||em.pending;return(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3 rounded-lg border border-border-subtle bg-bg px-3 py-2",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("div",{className:"text-sm font-medium text-text-main",children:e.label}),e.detail&&(0,a.jsx)("div",{className:"mt-0.5 text-xs text-text-muted",children:e.detail})]}),(0,a.jsx)(r.Ex,{variant:t.variant,size:"sm",children:t.label})]})}function ep({tool:e}){var t;let[s,i]=(0,l.useState)(null),[n,o]=(0,l.useState)(null),[d,c]=(0,l.useState)(null),[m,x]=(0,l.useState)(null),[u,p]=(0,l.useState)(!1),[h,g]=(0,l.useState)(""),[f,b]=(0,l.useState)(null),[y,j]=(0,l.useState)(!1),v=d&&!ec.has(d.status),N=s?.platformSupported&&s?.cursorDetected,w=!N||s?.cursorRunning,k=N&&!s?.cursorRunning&&s?.restoreAvailable,C=(0,l.useCallback)(async()=>{try{let e=await fetch("/api/cli-tools/cursor-byok"),t=await e.json();if(!e.ok)throw Error(t.error||"Failed to load Cursor BYOK status");i(t),o(null)}catch(e){o(e.message||"Failed to load Cursor BYOK status")}},[]);(0,l.useEffect)(()=>{C()},[C]),(0,l.useEffect)(()=>{if(!d?.id||ec.has(d.status))return;let e=new EventSource(`/api/cli-tools/cursor-byok/jobs/${d.id}/events`);return e.onmessage=t=>{let s=JSON.parse(t.data);if(s.error){c(e=>({...e||{},status:"error",error:s.error})),e.close();return}c(s),"waiting_sudo"===s.status&&(p(!0),b(null)),ec.has(s.status)&&(e.close(),C())},e.onerror=()=>{c(e=>e&&!ec.has(e.status)?{...e,status:"error",error:"Lost Cursor BYOK progress stream"}:e),e.close()},()=>e.close()},[C,d?.id,d?.status]);let _=async e=>{x(e),c(null),o(null),p(!1),g("");try{let t=await fetch("/api/cli-tools/cursor-byok/jobs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:e})}),s=await t.json();if(!t.ok)throw Error(s.error||"Failed to start Cursor BYOK job");c(s.job)}catch(e){o(e.message||"Failed to start Cursor BYOK job")}finally{x(null)}},S=async()=>{if(!h)return void b("Sudo password is required");j(!0),b(null);try{let e=await fetch(`/api/cli-tools/cursor-byok/jobs/${d.id}/sudo`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sudoPassword:h})}),t=await e.json();if(!e.ok)throw Error(t.error||"Failed to submit sudo password");c(t.job),p(!1),g("")}catch(e){b(e.message||"Failed to submit sudo password")}finally{j(!1)}},A=(0,l.useMemo)(()=>s?.repo?`${s.repo.owner}/${s.repo.name}@${s.repo.ref.slice(0,12)}`:"nightwalker89/cursor-byok",[s]);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(r.Zp,{padding:"sm",className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"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.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[20px] text-primary",children:"extension"}),(0,a.jsxs)("h2",{className:"text-base font-semibold text-text-main",children:[e.name," Installer"]}),(0,a.jsx)(ex,{status:s})]}),(0,a.jsx)("p",{className:"mt-1 text-sm text-text-muted",children:"Install or safely restore Cursor BYOK with every step and command result shown here."})]}),(0,a.jsx)(r.$n,{variant:"ghost",size:"sm",icon:"refresh",onClick:C,disabled:v,children:"Refresh"})]}),(0,a.jsxs)("div",{className:"grid gap-2 sm:grid-cols-3",children:[(0,a.jsxs)("div",{className:"rounded-lg border border-border-subtle bg-bg p-3",children:[(0,a.jsx)("div",{className:"text-xs font-semibold uppercase tracking-wide text-text-muted",children:"Cursor"}),(0,a.jsx)("div",{className:"mt-1 truncate text-sm text-text-main","data-i18n-skip":"true",children:s?.cursorPath||"Not detected"})]}),(0,a.jsxs)("div",{className:"rounded-lg border border-border-subtle bg-bg p-3",children:[(0,a.jsx)("div",{className:"text-xs font-semibold uppercase tracking-wide text-text-muted",children:"Source"}),(0,a.jsx)("div",{className:"mt-1 truncate text-sm text-text-main","data-i18n-skip":"true",children:A})]}),(0,a.jsxs)("div",{className:"rounded-lg border border-border-subtle bg-bg p-3",children:[(0,a.jsx)("div",{className:"text-xs font-semibold uppercase tracking-wide text-text-muted",children:"Permission"}),(0,a.jsx)("div",{className:"mt-1 text-sm text-text-main",children:s?.isWin?s?.needsUac?"Windows UAC required":"Direct write available":s?.needsSudoPassword?s?.hasCachedPassword?"Sudo cached for session":"Sudo required":"No sudo prompt"})]})]}),s?.isWin&&(0,a.jsx)("div",{className:`rounded-lg border p-3 text-xs leading-relaxed ${s.cursorRunning?"border-red-500/30 bg-red-500/10 text-red-600 dark:text-red-300":"border-blue-500/30 bg-blue-500/10 text-blue-700 dark:text-blue-300"}`,children:s.cursorRunning?"Cursor is running. Fully quit Cursor, including background processes, before Install or Restore.":s.needsUac?`Detected a protected ${s.installScope||"system"} installation. Windows will show one UAC confirmation dialog for file changes.`:`Detected a writable ${s.installScope||"user"} installation. n9router can update it directly without a password or UAC dialog.`}),!s?.platformSupported&&s?.supportReason&&(0,a.jsx)("div",{className:"rounded-lg border border-red-500/30 bg-red-500/10 p-3 text-xs text-red-500",children:s.supportReason}),(0,a.jsx)("div",{className:"rounded-lg border border-yellow-500/30 bg-yellow-500/10 p-3 text-xs leading-relaxed text-yellow-700 dark:text-yellow-300",children:"Advanced feature: installation patches the local Cursor app bundle. Run Prepare after every Cursor update. Restore is allowed only when the saved backup matches the current signed Cursor version."}),(0,a.jsxs)("div",{className:"grid gap-2 sm:grid-cols-2",children:[(0,a.jsxs)("div",{className:"rounded-lg border border-border-subtle bg-bg p-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"inline-flex size-5 shrink-0 items-center justify-center rounded-full bg-brand-500/15 text-[11px] font-bold text-brand-600 dark:text-brand-300",children:"1"}),(0,a.jsx)("div",{className:"text-sm font-semibold text-text-main",children:"Prepare"})]}),(0,a.jsx)("p",{className:"mt-1 text-xs leading-relaxed text-text-muted",children:"Downloads the pinned source, installs dependencies, and checks compatibility. It does not modify Cursor or request administrator permission."})]}),(0,a.jsxs)("div",{className:"rounded-lg border border-border-subtle bg-bg p-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"inline-flex size-5 shrink-0 items-center justify-center rounded-full bg-brand-500/15 text-[11px] font-bold text-brand-600 dark:text-brand-300",children:"2"}),(0,a.jsx)("div",{className:"text-sm font-semibold text-text-main",children:"Install"})]}),(0,a.jsx)("p",{className:"mt-1 text-xs leading-relaxed text-text-muted",children:"Installs the extension and patches Cursor after preflight. Writable Windows user installs are modified directly; protected installs use UAC."})]}),(0,a.jsxs)("div",{className:"rounded-lg border border-border-subtle bg-bg p-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"inline-flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-3 text-[11px] font-bold text-text-muted",children:"3"}),(0,a.jsx)("div",{className:"text-sm font-semibold text-text-main",children:"Restore Cursor Files"})]}),(0,a.jsx)("p",{className:"mt-1 text-xs leading-relaxed text-text-muted",children:"Rolls back the Cursor application patch from backup. The BYOK extension and its settings remain installed."})]})]}),s?.targets&&(0,a.jsxs)("details",{className:"rounded-lg border border-border-subtle bg-bg p-3 text-xs",children:[(0,a.jsx)("summary",{className:"cursor-pointer font-semibold text-text-main",children:"Detected Cursor targets"}),(0,a.jsxs)("div",{className:"mt-2 flex flex-col gap-1 break-all font-mono text-text-muted","data-i18n-skip":"true",children:[(0,a.jsxs)("span",{children:["Root: ",s.cursorRoot]}),(0,a.jsxs)("span",{children:["Workbench: ",s.targets.workbench]}),(0,a.jsxs)("span",{children:["Extension host: ",s.targets.extensionHost]})]})]}),(0,a.jsxs)("div",{className:"rounded-lg border border-border-subtle bg-surface-2/50 p-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] text-primary",children:"menu_book"}),(0,a.jsx)("h3",{className:"text-sm font-semibold text-text-main",children:"Quick Guide"})]}),(0,a.jsxs)("ol",{className:"mt-2 flex flex-col gap-1.5 text-xs leading-relaxed text-text-muted",children:[(0,a.jsxs)("li",{className:"flex gap-2",children:[(0,a.jsx)("span",{className:"font-semibold text-text-main",children:"1."}),(0,a.jsxs)("span",{children:[(0,a.jsx)("span",{className:"font-medium text-text-main",children:"Prepare"})," — downloads the source and verifies your Cursor version. Safe to re-run after any Cursor update."]})]}),(0,a.jsxs)("li",{className:"flex gap-2",children:[(0,a.jsx)("span",{className:"font-semibold text-text-main",children:"2."}),(0,a.jsxs)("span",{children:[(0,a.jsx)("span",{className:"font-medium text-text-main",children:"Install"})," — patches Cursor and adds the BYOK extension. Fully quit Cursor first, then restart it afterward."]})]}),(0,a.jsxs)("li",{className:"flex gap-2",children:[(0,a.jsx)("span",{className:"font-semibold text-text-main",children:"3."}),(0,a.jsxs)("span",{children:[(0,a.jsx)("span",{className:"font-medium text-text-main",children:"Restore Cursor Files"})," — optional. Rolls back the Cursor patch from a matching backup; the extension and settings stay."]})]})]}),(0,a.jsxs)("p",{className:"mt-2 text-[11px] text-text-muted/80",children:["Tip: Run ",(0,a.jsx)("span",{className:"font-medium",children:"Prepare"})," again after every Cursor update before re-installing."]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:flex-wrap",children:[(0,a.jsx)(r.$n,{variant:"secondary",icon:"fact_check",onClick:()=>_("prepare"),loading:"prepare"===m,disabled:v||!N,children:"1. Prepare"}),(0,a.jsx)(r.$n,{icon:"download",onClick:()=>_("install"),loading:"install"===m,disabled:v||w,children:"2. Install"}),(0,a.jsx)(r.$n,{variant:"outline",icon:"settings_backup_restore",onClick:()=>_("restore"),loading:"restore"===m,disabled:v||!k,title:k?void 0:"A workbench backup is required to restore Cursor files",children:"3. Restore Cursor Files"})]}),s?.backupFilesAvailable&&!s?.restoreAvailable&&(0,a.jsxs)("div",{className:"rounded-lg border border-red-500/30 bg-red-500/10 p-3 text-xs text-red-500",children:[s.restoreReason,". Restore is disabled because backup filenames alone do not identify their original Cursor targets. If Cursor BYOK is not installed and Cursor works normally, these are retained archival backups and no restore is needed."]}),n&&(0,a.jsx)("div",{className:"rounded-lg border border-red-500/30 bg-red-500/10 p-3 text-sm text-red-500",children:n}),d?.status==="success"&&(0,a.jsx)("div",{className:"rounded-lg border border-green-500/30 bg-green-500/10 p-3 text-sm text-green-700 dark:text-green-300",children:"prepare"===(t=d.action)?"Preparation passed. Cursor was not modified. You can proceed with Install.":"install"===t?"Cursor BYOK is installed. Fully quit and restart Cursor before using it.":"restore"===t?"Original Cursor files were restored. The Cursor BYOK extension and settings remain installed. Restart Cursor to apply the rollback.":"Cursor BYOK action completed."}),d?.status==="waiting_uac"&&(0,a.jsx)("div",{className:"rounded-lg border border-blue-500/30 bg-blue-500/10 p-3 text-sm text-blue-700 dark:text-blue-300",children:"Approve the Windows User Account Control dialog to continue. It may appear behind another window."}),d&&(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[(0,a.jsx)("span",{className:"font-semibold text-text-main",children:"Job:"}),(0,a.jsxs)(r.Ex,{variant:"success"===d.status?"success":"error"===d.status?"error":"info",size:"sm",children:[d.action," / ",d.status]}),d.error&&(0,a.jsx)("span",{className:"text-red-500",children:d.error})]}),(0,a.jsx)("div",{className:"flex flex-col gap-2",children:d.steps?.map(e=>(0,a.jsx)(eu,{step:e},e.id))}),(0,a.jsx)("div",{className:"max-h-72 overflow-auto rounded-lg bg-black p-3 font-mono text-[11px] leading-relaxed text-green-100","data-i18n-skip":"true",children:0===(d.logs||[]).length?(0,a.jsx)("div",{className:"text-green-100/60",children:"Waiting for installer output..."}):d.logs.map((e,t)=>(0,a.jsxs)("div",{className:"stderr"===e.stream?"text-red-200":"",children:["[",e.stream,"] ",e.message]},`${e.ts}-${t}`))})]})]}),u&&(0,a.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",children:(0,a.jsxs)("div",{className:"w-full max-w-md rounded-xl border border-border bg-surface p-6 shadow-xl",children:[(0,a.jsx)("h3",{className:"mb-2 text-lg font-semibold text-text-main",children:"Sudo Password Required"}),(0,a.jsx)("p",{className:"mb-4 text-sm text-text-muted",children:d?.action==="install"?"Required to patch the local Cursor app bundle. The password is kept only in this n9router process session.":"Required to restore the original Cursor app files from a verified matching backup. The extension and settings remain installed."}),(0,a.jsx)(r.pd,{type:"password",label:"macOS password",value:h,onChange:e=>g(e.target.value),error:f,autoFocus:!0,onKeyDown:e=>{"Enter"===e.key&&S()}}),(0,a.jsxs)("div",{className:"mt-5 flex justify-end gap-2",children:[(0,a.jsx)(r.$n,{variant:"ghost",onClick:()=>{p(!1),g("")},disabled:y,children:"Cancel"}),(0,a.jsx)(r.$n,{onClick:S,loading:y,children:"Continue"})]})]})})]})}var eh=s(929);let eg="/api/cli-tools/grok-build-settings",ef="9router",eb=[{id:"general-purpose",label:"General-purpose",help:"Implementation, testing, and full-capability delegated tasks"},{id:"explore",label:"Explore",help:"Read-only codebase research and investigation"},{id:"plan",label:"Plan",help:"Architecture and implementation planning"}];function ey({label:e,value:t,placeholder:s,onChange:l,onSelect:r,disabled:i,help:n}){return(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsxs)("div",{className:"sm:text-right",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-sm",children:e}),n&&(0,a.jsx)("p",{className:"mt-0.5 text-[10px] leading-tight text-text-muted",children:n})]}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,a.jsx)("input",{type:"text",value:t,onChange:e=>l(e.target.value),placeholder:s,className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),t&&(0,a.jsx)("button",{type:"button",onClick:()=>l(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear (inherit main model for subagents)",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,a.jsx)("button",{type:"button",onClick:r,disabled:i,className:`w-full sm:w-auto rounded border px-2 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap sm:shrink-0 ${!i?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"})]})}function ej({tool:e,isExpanded:t,onToggle:s,hasActiveProviders:n,apiKeys:o,activeProviders:d,cloudEnabled:c,initialStatus:m,tunnelEnabled:x,tunnelPublicUrl:u,tailscaleEnabled:p,tailscaleUrl:h}){let{getCaps:g}=(0,eh.y)(),f=e=>g(e)?.contextWindow||null,b=m?.settings?.model?.model||"",y=Object.fromEntries(eb.map(e=>[e.id,m?.settings?.subagentModels?.[e.id]?.model]).filter(([,e])=>!!e)),[v,N]=(0,l.useState)(m||null),[w,C]=(0,l.useState)(!1),[_,A]=(0,l.useState)(!1),[$,M]=(0,l.useState)(!1),[O,T]=(0,l.useState)(null),[P,R]=(0,l.useState)(o?.[0]?.key||""),[I,U]=(0,l.useState)(b),[D,z]=(0,l.useState)(y),[L,F]=(0,l.useState)(null),[K,q]=(0,l.useState)({}),[B,H]=(0,l.useState)(!1),[W,G]=(0,l.useState)(""),J=(0,l.useRef)(!!m),Y=v?.settings?.model,V=Y?.base_url||"",Z=v?.installed?Y?.base_url?E(Y.base_url,{tunnelPublicUrl:u,tailscaleUrl:h})?"configured":"other":"not_configured":null,Q=(0,l.useCallback)(e=>{let t=e?.settings?.model?.model||"",s=Object.fromEntries(eb.map(t=>[t.id,e?.settings?.subagentModels?.[t.id]?.model]).filter(([,e])=>!!e));U(t),z(s)},[]),X=(0,l.useCallback)(async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&q(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}},[]),ee=(0,l.useCallback)(async({hydrate:e=!1}={})=>{C(!0);try{let t=await fetch(eg),s=await t.json();N(s),J.current=!0,e&&Q(s)}catch(e){N({installed:!1,error:e.message})}finally{C(!1)}},[Q]);(0,l.useEffect)(()=>{if(!t)return;let e=!1;return(async()=>{J.current||await ee({hydrate:!0}),e||await X()})(),()=>{e=!0}},[t,ee,X]);let et=()=>{let e=W||window.location.origin.replace("://localhost","://127.0.0.1");return e.endsWith("/v1")?e:`${e}/v1`},es=async()=>{A(!0),T(null);try{let e=P?.trim()||(o?.length>0?o[0].key:null)||(c?null:"sk_9router"),t={};for(let e of eb){let s=D[e.id]?.trim();s&&(t[e.id]={model:s,contextWindow:f(s)})}let s=await fetch(eg,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:et(),apiKey:e,model:I,contextWindow:f(I),subagentModels:t})}),a=await s.json();s.ok?(j(et(),{tunnelPublicUrl:u,tailscaleUrl:h}),T({type:"success",text:"Main and subagent models applied successfully!"}),ee()):T({type:"error",text:a.error||"Failed to apply settings"})}catch(e){T({type:"error",text:e.message})}finally{A(!1)}},ea=async()=>{M(!0),T(null);try{let e=await fetch(eg,{method:"DELETE"}),t=await e.json();e.ok?(T({type:"success",text:"Settings reset successfully!"}),U(""),z({}),ee()):T({type:"error",text:t.error||"Failed to reset settings"})}catch(e){T({type:"error",text:e.message})}finally{M(!1)}};return(0,a.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3 hover:cursor-pointer sm:items-center",onClick:s,children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(i.A,{src:e.image||"/providers/grok-cli.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===Z&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===Z&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===Z&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[w&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,a.jsx)("span",{children:"Checking Grok Build..."})]}),!w&&v&&!v.installed&&(0,a.jsxs)("div",{className:"flex flex-col gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Grok Build not detected locally"}),(0,a.jsx)("code",{className:"block mt-2 p-2 bg-black/20 rounded text-xs font-mono",children:"curl -fsSL https://x.ai/cli/install.sh | bash"})]})]}),(0,a.jsxs)(r.$n,{variant:"secondary",size:"sm",onClick:()=>H(!0),className:"w-full sm:w-auto",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:"content_copy"}),"Manual Config"]})]}),!w&&v?.installed&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[e.notes?.length>0&&(0,a.jsx)("div",{className:"mb-2 flex flex-col gap-2",children:e.notes.map((e,t)=>(0,a.jsxs)("div",{className:`flex items-start gap-2 rounded p-2 text-xs ${"warning"===e.type?"bg-yellow-500/10 text-yellow-600 dark:text-yellow-400":"bg-blue-500/10 text-blue-600 dark:text-blue-400"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined mt-0.5 text-[14px]",children:"warning"===e.type?"warning":"info"}),(0,a.jsx)("span",{children:e.text})]},t))}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Select Endpoint"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(k,{value:W||et(),onChange:G,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:x,tunnelPublicUrl:u,tailscaleEnabled:p,tailscaleUrl:h,currentUrl:V})]}),Y?.base_url&&(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Current"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("span",{className:"min-w-0 truncate rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5",children:[Y.base_url," \xb7 ",Y.model,Y.context_window?` \xb7 ${(Y.context_window/1e3).toLocaleString()}K ctx`:""]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(S,{value:P,onChange:R,apiKeys:o,cloudEnabled:c})]}),(0,a.jsx)(ey,{label:"Main Model",value:I,onChange:U,placeholder:"provider/model-id",onSelect:()=>F("main"),disabled:!n}),(0,a.jsx)("div",{className:"my-1 border-t border-border pt-3",children:(0,a.jsxs)("div",{className:"mb-2 flex items-start gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-primary text-[16px]",children:"account_tree"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-xs font-semibold text-text-main",children:"Subagent model overrides"}),(0,a.jsx)("p",{className:"text-[10px] text-text-muted",children:"Leave blank to inherit Main Model. Each override keeps its own context window."})]})]})}),eb.map(e=>(0,a.jsx)(ey,{label:e.label,help:e.help,value:D[e.id]||"",onChange:t=>z(s=>({...s,[e.id]:t})),placeholder:`${I||"Main Model"} (inherit)`,onSelect:()=>F(e.id),disabled:!n},e.id))]}),O&&(0,a.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===O.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===O.type?"check_circle":"error"}),(0,a.jsx)("span",{children:O.text})]}),(0,a.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2",children:[(0,a.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:es,disabled:!I,loading:_,className:"w-full sm:w-auto",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,a.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:ea,disabled:!v?.has9Router,loading:$,className:"w-full sm:w-auto",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,a.jsxs)(r.$n,{variant:"ghost",size:"sm",onClick:()=>H(!0),className:"w-full sm:w-auto",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),L&&(0,a.jsx)(r.rq,{isOpen:!!L,onClose:()=>F(null),onSelect:e=>{"main"===L?U(e.value):L&&z(t=>({...t,[L]:e.value})),F(null)},selectedModel:"main"===L?I:D[L]||"",activeProviders:d,modelAliases:K,title:"main"===L?"Select Main Model for Grok Build":`Select ${eb.find(e=>e.id===L)?.label||"Subagent"} Model`}),(0,a.jsx)(r.uR,{isOpen:B,onClose:()=>H(!1),title:"Grok Build - Manual Configuration",configs:(()=>{let e=P?.trim()||(c?"<API_KEY_FROM_DASHBOARD>":"sk_9router"),t=et(),s=I||"provider/model-id",a=[`[models]
|
|
97
|
+
id = "${R||"cc/claude-opus-4-7"}"`},{filename:"~/.config/jcode/provider-9router.env",content:`JCODE_9ROUTER_API_KEY="${b}"`}])})]})}let ec=new Set(["success","error"]),em={pending:{variant:"default",label:"Pending"},running:{variant:"info",label:"Running"},waiting:{variant:"warning",label:"Waiting"},success:{variant:"success",label:"Done"},error:{variant:"error",label:"Failed"}};function ex({status:e}){return e?e.platformSupported?e.installed?(0,a.jsx)(r.Ex,{variant:"success",size:"sm",children:"Installed"}):e.cursorDetected?(0,a.jsx)(r.Ex,{variant:"warning",size:"sm",children:"Ready"}):(0,a.jsx)(r.Ex,{variant:"default",size:"sm",children:"Cursor not found"}):(0,a.jsx)(r.Ex,{variant:"error",size:"sm",children:"Unsupported platform"}):(0,a.jsx)(r.Ex,{size:"sm",children:"Loading"})}function eu({step:e}){let t=em[e.status]||em.pending;return(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3 rounded-lg border border-border-subtle bg-bg px-3 py-2",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("div",{className:"text-sm font-medium text-text-main",children:e.label}),e.detail&&(0,a.jsx)("div",{className:"mt-0.5 text-xs text-text-muted",children:e.detail})]}),(0,a.jsx)(r.Ex,{variant:t.variant,size:"sm",children:t.label})]})}function ep({tool:e}){var t;let[s,i]=(0,l.useState)(null),[n,o]=(0,l.useState)(null),[d,c]=(0,l.useState)(null),[m,x]=(0,l.useState)(null),[u,p]=(0,l.useState)(!1),[h,g]=(0,l.useState)(""),[f,b]=(0,l.useState)(null),[y,j]=(0,l.useState)(!1),v=d&&!ec.has(d.status),N=s?.platformSupported&&s?.cursorDetected,w=!N||s?.cursorRunning,k=N&&!s?.cursorRunning&&s?.restoreAvailable,C=(0,l.useCallback)(async()=>{try{let e=await fetch("/api/cli-tools/cursor-byok"),t=await e.json();if(!e.ok)throw Error(t.error||"Failed to load Cursor BYOK status");i(t),o(null)}catch(e){o(e.message||"Failed to load Cursor BYOK status")}},[]);(0,l.useEffect)(()=>{C()},[C]),(0,l.useEffect)(()=>{if(!d?.id||ec.has(d.status))return;let e=new EventSource(`/api/cli-tools/cursor-byok/jobs/${d.id}/events`);return e.onmessage=t=>{let s=JSON.parse(t.data);if(s.error){c(e=>({...e||{},status:"error",error:s.error})),e.close();return}c(s),"waiting_sudo"===s.status&&(p(!0),b(null)),ec.has(s.status)&&(e.close(),C())},e.onerror=()=>{c(e=>e&&!ec.has(e.status)?{...e,status:"error",error:"Lost Cursor BYOK progress stream"}:e),e.close()},()=>e.close()},[C,d?.id,d?.status]);let S=async e=>{x(e),c(null),o(null),p(!1),g("");try{let t=await fetch("/api/cli-tools/cursor-byok/jobs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:e})}),s=await t.json();if(!t.ok)throw Error(s.error||"Failed to start Cursor BYOK job");c(s.job)}catch(e){o(e.message||"Failed to start Cursor BYOK job")}finally{x(null)}},_=async()=>{if(!h)return void b("Sudo password is required");j(!0),b(null);try{let e=await fetch(`/api/cli-tools/cursor-byok/jobs/${d.id}/sudo`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sudoPassword:h})}),t=await e.json();if(!e.ok)throw Error(t.error||"Failed to submit sudo password");c(t.job),p(!1),g("")}catch(e){b(e.message||"Failed to submit sudo password")}finally{j(!1)}},A=(0,l.useMemo)(()=>s?.repo?`${s.repo.owner}/${s.repo.name}@${s.repo.ref.slice(0,12)}`:"nightwalker89/cursor-byok",[s]);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(r.Zp,{padding:"sm",className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"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.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[20px] text-primary",children:"extension"}),(0,a.jsxs)("h2",{className:"text-base font-semibold text-text-main",children:[e.name," Installer"]}),(0,a.jsx)(ex,{status:s})]}),(0,a.jsx)("p",{className:"mt-1 text-sm text-text-muted",children:"Install or safely restore Cursor BYOK with every step and command result shown here."})]}),(0,a.jsx)(r.$n,{variant:"ghost",size:"sm",icon:"refresh",onClick:C,disabled:v,children:"Refresh"})]}),(0,a.jsxs)("div",{className:"grid gap-2 sm:grid-cols-3",children:[(0,a.jsxs)("div",{className:"rounded-lg border border-border-subtle bg-bg p-3",children:[(0,a.jsx)("div",{className:"text-xs font-semibold uppercase tracking-wide text-text-muted",children:"Cursor"}),(0,a.jsx)("div",{className:"mt-1 truncate text-sm text-text-main","data-i18n-skip":"true",children:s?.cursorPath||"Not detected"})]}),(0,a.jsxs)("div",{className:"rounded-lg border border-border-subtle bg-bg p-3",children:[(0,a.jsx)("div",{className:"text-xs font-semibold uppercase tracking-wide text-text-muted",children:"Source"}),(0,a.jsx)("div",{className:"mt-1 truncate text-sm text-text-main","data-i18n-skip":"true",children:A})]}),(0,a.jsxs)("div",{className:"rounded-lg border border-border-subtle bg-bg p-3",children:[(0,a.jsx)("div",{className:"text-xs font-semibold uppercase tracking-wide text-text-muted",children:"Permission"}),(0,a.jsx)("div",{className:"mt-1 text-sm text-text-main",children:s?.isWin?s?.needsUac?"Windows UAC required":"Direct write available":s?.needsSudoPassword?s?.hasCachedPassword?"Sudo cached for session":"Sudo required":"No sudo prompt"})]})]}),s?.isWin&&(0,a.jsx)("div",{className:`rounded-lg border p-3 text-xs leading-relaxed ${s.cursorRunning?"border-red-500/30 bg-red-500/10 text-red-600 dark:text-red-300":"border-blue-500/30 bg-blue-500/10 text-blue-700 dark:text-blue-300"}`,children:s.cursorRunning?"Cursor is running. Fully quit Cursor, including background processes, before Install or Restore.":s.needsUac?`Detected a protected ${s.installScope||"system"} installation. Windows will show one UAC confirmation dialog for file changes.`:`Detected a writable ${s.installScope||"user"} installation. n9router can update it directly without a password or UAC dialog.`}),!s?.platformSupported&&s?.supportReason&&(0,a.jsx)("div",{className:"rounded-lg border border-red-500/30 bg-red-500/10 p-3 text-xs text-red-500",children:s.supportReason}),(0,a.jsx)("div",{className:"rounded-lg border border-yellow-500/30 bg-yellow-500/10 p-3 text-xs leading-relaxed text-yellow-700 dark:text-yellow-300",children:"Advanced feature: installation patches the local Cursor app bundle. Run Prepare after every Cursor update. Restore is allowed only when the saved backup matches the current signed Cursor version."}),(0,a.jsxs)("div",{className:"grid gap-2 sm:grid-cols-2",children:[(0,a.jsxs)("div",{className:"rounded-lg border border-border-subtle bg-bg p-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"inline-flex size-5 shrink-0 items-center justify-center rounded-full bg-brand-500/15 text-[11px] font-bold text-brand-600 dark:text-brand-300",children:"1"}),(0,a.jsx)("div",{className:"text-sm font-semibold text-text-main",children:"Prepare"})]}),(0,a.jsx)("p",{className:"mt-1 text-xs leading-relaxed text-text-muted",children:"Downloads the pinned source, installs dependencies, and checks compatibility. It does not modify Cursor or request administrator permission."})]}),(0,a.jsxs)("div",{className:"rounded-lg border border-border-subtle bg-bg p-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"inline-flex size-5 shrink-0 items-center justify-center rounded-full bg-brand-500/15 text-[11px] font-bold text-brand-600 dark:text-brand-300",children:"2"}),(0,a.jsx)("div",{className:"text-sm font-semibold text-text-main",children:"Install"})]}),(0,a.jsx)("p",{className:"mt-1 text-xs leading-relaxed text-text-muted",children:"Installs the extension and patches Cursor after preflight. Writable Windows user installs are modified directly; protected installs use UAC."})]}),(0,a.jsxs)("div",{className:"rounded-lg border border-border-subtle bg-bg p-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"inline-flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-3 text-[11px] font-bold text-text-muted",children:"3"}),(0,a.jsx)("div",{className:"text-sm font-semibold text-text-main",children:"Restore Cursor Files"})]}),(0,a.jsx)("p",{className:"mt-1 text-xs leading-relaxed text-text-muted",children:"Rolls back the Cursor application patch from backup. The BYOK extension and its settings remain installed."})]})]}),s?.targets&&(0,a.jsxs)("details",{className:"rounded-lg border border-border-subtle bg-bg p-3 text-xs",children:[(0,a.jsx)("summary",{className:"cursor-pointer font-semibold text-text-main",children:"Detected Cursor targets"}),(0,a.jsxs)("div",{className:"mt-2 flex flex-col gap-1 break-all font-mono text-text-muted","data-i18n-skip":"true",children:[(0,a.jsxs)("span",{children:["Root: ",s.cursorRoot]}),(0,a.jsxs)("span",{children:["Workbench: ",s.targets.workbench]}),(0,a.jsxs)("span",{children:["Extension host: ",s.targets.extensionHost]})]})]}),(0,a.jsxs)("div",{className:"rounded-lg border border-border-subtle bg-surface-2/50 p-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] text-primary",children:"menu_book"}),(0,a.jsx)("h3",{className:"text-sm font-semibold text-text-main",children:"Quick Guide"})]}),(0,a.jsxs)("ol",{className:"mt-2 flex flex-col gap-1.5 text-xs leading-relaxed text-text-muted",children:[(0,a.jsxs)("li",{className:"flex gap-2",children:[(0,a.jsx)("span",{className:"font-semibold text-text-main",children:"1."}),(0,a.jsxs)("span",{children:[(0,a.jsx)("span",{className:"font-medium text-text-main",children:"Prepare"})," — downloads the source and verifies your Cursor version. Safe to re-run after any Cursor update."]})]}),(0,a.jsxs)("li",{className:"flex gap-2",children:[(0,a.jsx)("span",{className:"font-semibold text-text-main",children:"2."}),(0,a.jsxs)("span",{children:[(0,a.jsx)("span",{className:"font-medium text-text-main",children:"Install"})," — patches Cursor and adds the BYOK extension. Fully quit Cursor first, then restart it afterward."]})]}),(0,a.jsxs)("li",{className:"flex gap-2",children:[(0,a.jsx)("span",{className:"font-semibold text-text-main",children:"3."}),(0,a.jsxs)("span",{children:[(0,a.jsx)("span",{className:"font-medium text-text-main",children:"Restore Cursor Files"})," — optional. Rolls back the Cursor patch from a matching backup; the extension and settings stay."]})]})]}),(0,a.jsxs)("p",{className:"mt-2 text-[11px] text-text-muted/80",children:["Tip: Run ",(0,a.jsx)("span",{className:"font-medium",children:"Prepare"})," again after every Cursor update before re-installing."]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:flex-wrap",children:[(0,a.jsx)(r.$n,{variant:"secondary",icon:"fact_check",onClick:()=>S("prepare"),loading:"prepare"===m,disabled:v||!N,children:"1. Prepare"}),(0,a.jsx)(r.$n,{icon:"download",onClick:()=>S("install"),loading:"install"===m,disabled:v||w,children:"2. Install"}),(0,a.jsx)(r.$n,{variant:"outline",icon:"settings_backup_restore",onClick:()=>S("restore"),loading:"restore"===m,disabled:v||!k,title:k?void 0:"A workbench backup is required to restore Cursor files",children:"3. Restore Cursor Files"})]}),s?.backupFilesAvailable&&!s?.restoreAvailable&&(0,a.jsxs)("div",{className:"rounded-lg border border-red-500/30 bg-red-500/10 p-3 text-xs text-red-500",children:[s.restoreReason,". Restore is disabled because backup filenames alone do not identify their original Cursor targets. If Cursor BYOK is not installed and Cursor works normally, these are retained archival backups and no restore is needed."]}),n&&(0,a.jsx)("div",{className:"rounded-lg border border-red-500/30 bg-red-500/10 p-3 text-sm text-red-500",children:n}),d?.status==="success"&&(0,a.jsx)("div",{className:"rounded-lg border border-green-500/30 bg-green-500/10 p-3 text-sm text-green-700 dark:text-green-300",children:"prepare"===(t=d.action)?"Preparation passed. Cursor was not modified. You can proceed with Install.":"install"===t?"Cursor BYOK is installed. Fully quit and restart Cursor before using it.":"restore"===t?"Original Cursor files were restored. The Cursor BYOK extension and settings remain installed. Restart Cursor to apply the rollback.":"Cursor BYOK action completed."}),d?.status==="waiting_uac"&&(0,a.jsx)("div",{className:"rounded-lg border border-blue-500/30 bg-blue-500/10 p-3 text-sm text-blue-700 dark:text-blue-300",children:"Approve the Windows User Account Control dialog to continue. It may appear behind another window."}),d&&(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[(0,a.jsx)("span",{className:"font-semibold text-text-main",children:"Job:"}),(0,a.jsxs)(r.Ex,{variant:"success"===d.status?"success":"error"===d.status?"error":"info",size:"sm",children:[d.action," / ",d.status]}),d.error&&(0,a.jsx)("span",{className:"text-red-500",children:d.error})]}),(0,a.jsx)("div",{className:"flex flex-col gap-2",children:d.steps?.map(e=>(0,a.jsx)(eu,{step:e},e.id))}),(0,a.jsx)("div",{className:"max-h-72 overflow-auto rounded-lg bg-black p-3 font-mono text-[11px] leading-relaxed text-green-100","data-i18n-skip":"true",children:0===(d.logs||[]).length?(0,a.jsx)("div",{className:"text-green-100/60",children:"Waiting for installer output..."}):d.logs.map((e,t)=>(0,a.jsxs)("div",{className:"stderr"===e.stream?"text-red-200":"",children:["[",e.stream,"] ",e.message]},`${e.ts}-${t}`))})]})]}),u&&(0,a.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",children:(0,a.jsxs)("div",{className:"w-full max-w-md rounded-xl border border-border bg-surface p-6 shadow-xl",children:[(0,a.jsx)("h3",{className:"mb-2 text-lg font-semibold text-text-main",children:"Sudo Password Required"}),(0,a.jsx)("p",{className:"mb-4 text-sm text-text-muted",children:d?.action==="install"?"Required to patch the local Cursor app bundle. The password is kept only in this n9router process session.":"Required to restore the original Cursor app files from a verified matching backup. The extension and settings remain installed."}),(0,a.jsx)(r.pd,{type:"password",label:"macOS password",value:h,onChange:e=>g(e.target.value),error:f,autoFocus:!0,onKeyDown:e=>{"Enter"===e.key&&_()}}),(0,a.jsxs)("div",{className:"mt-5 flex justify-end gap-2",children:[(0,a.jsx)(r.$n,{variant:"ghost",onClick:()=>{p(!1),g("")},disabled:y,children:"Cancel"}),(0,a.jsx)(r.$n,{onClick:_,loading:y,children:"Continue"})]})]})})]})}var eh=s(929);let eg="/api/cli-tools/grok-build-settings",ef="9router",eb=[{id:"general-purpose",label:"General-purpose",help:"Implementation, testing, and full-capability delegated tasks"},{id:"explore",label:"Explore",help:"Read-only codebase research and investigation"},{id:"plan",label:"Plan",help:"Architecture and implementation planning"}];function ey({label:e,value:t,placeholder:s,onChange:l,onSelect:r,disabled:i,help:n}){return(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsxs)("div",{className:"sm:text-right",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-sm",children:e}),n&&(0,a.jsx)("p",{className:"mt-0.5 text-[10px] leading-tight text-text-muted",children:n})]}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,a.jsx)("input",{type:"text",value:t,onChange:e=>l(e.target.value),placeholder:s,className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),t&&(0,a.jsx)("button",{type:"button",onClick:()=>l(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear (inherit main model for subagents)",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,a.jsx)("button",{type:"button",onClick:r,disabled:i,className:`w-full sm:w-auto rounded border px-2 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap sm:shrink-0 ${!i?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"})]})}function ej({tool:e,isExpanded:t,onToggle:s,hasActiveProviders:n,apiKeys:o,activeProviders:d,cloudEnabled:c,initialStatus:m,tunnelEnabled:x,tunnelPublicUrl:u,tailscaleEnabled:p,tailscaleUrl:h}){let{getCaps:g}=(0,eh.y)(),f=e=>g(e)?.contextWindow||null,b=m?.settings?.model?.model||"",y=Object.fromEntries(eb.map(e=>[e.id,m?.settings?.subagentModels?.[e.id]?.model]).filter(([,e])=>!!e)),[v,N]=(0,l.useState)(m||null),[w,C]=(0,l.useState)(!1),[S,A]=(0,l.useState)(!1),[$,M]=(0,l.useState)(!1),[O,T]=(0,l.useState)(null),[P,R]=(0,l.useState)(o?.[0]?.key||""),[I,U]=(0,l.useState)(b),[D,z]=(0,l.useState)(y),[L,F]=(0,l.useState)(null),[K,q]=(0,l.useState)({}),[B,H]=(0,l.useState)(!1),[W,G]=(0,l.useState)(""),J=(0,l.useRef)(!!m),Y=v?.settings?.model,V=Y?.base_url||"",Z=v?.installed?Y?.base_url?E(Y.base_url,{tunnelPublicUrl:u,tailscaleUrl:h})?"configured":"other":"not_configured":null,Q=(0,l.useCallback)(e=>{let t=e?.settings?.model?.model||"",s=Object.fromEntries(eb.map(t=>[t.id,e?.settings?.subagentModels?.[t.id]?.model]).filter(([,e])=>!!e));U(t),z(s)},[]),X=(0,l.useCallback)(async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&q(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}},[]),ee=(0,l.useCallback)(async({hydrate:e=!1}={})=>{C(!0);try{let t=await fetch(eg),s=await t.json();N(s),J.current=!0,e&&Q(s)}catch(e){N({installed:!1,error:e.message})}finally{C(!1)}},[Q]);(0,l.useEffect)(()=>{if(!t)return;let e=!1;return(async()=>{J.current||await ee({hydrate:!0}),e||await X()})(),()=>{e=!0}},[t,ee,X]);let et=()=>{let e=W||window.location.origin.replace("://localhost","://127.0.0.1");return e.endsWith("/v1")?e:`${e}/v1`},es=async()=>{A(!0),T(null);try{let e=P?.trim()||(o?.length>0?o[0].key:null)||(c?null:"sk_9router"),t={};for(let e of eb){let s=D[e.id]?.trim();s&&(t[e.id]={model:s,contextWindow:f(s)})}let s=await fetch(eg,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:et(),apiKey:e,model:I,contextWindow:f(I),subagentModels:t})}),a=await s.json();s.ok?(j(et(),{tunnelPublicUrl:u,tailscaleUrl:h}),T({type:"success",text:"Main and subagent models applied successfully!"}),ee()):T({type:"error",text:a.error||"Failed to apply settings"})}catch(e){T({type:"error",text:e.message})}finally{A(!1)}},ea=async()=>{M(!0),T(null);try{let e=await fetch(eg,{method:"DELETE"}),t=await e.json();e.ok?(T({type:"success",text:"Settings reset successfully!"}),U(""),z({}),ee()):T({type:"error",text:t.error||"Failed to reset settings"})}catch(e){T({type:"error",text:e.message})}finally{M(!1)}};return(0,a.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3 hover:cursor-pointer sm:items-center",onClick:s,children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(i.A,{src:e.image||"/providers/grok-cli.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===Z&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===Z&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===Z&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[w&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,a.jsx)("span",{children:"Checking Grok Build..."})]}),!w&&v&&!v.installed&&(0,a.jsxs)("div",{className:"flex flex-col gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Grok Build not detected locally"}),(0,a.jsx)("code",{className:"block mt-2 p-2 bg-black/20 rounded text-xs font-mono",children:"curl -fsSL https://x.ai/cli/install.sh | bash"})]})]}),(0,a.jsxs)(r.$n,{variant:"secondary",size:"sm",onClick:()=>H(!0),className:"w-full sm:w-auto",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:"content_copy"}),"Manual Config"]})]}),!w&&v?.installed&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[e.notes?.length>0&&(0,a.jsx)("div",{className:"mb-2 flex flex-col gap-2",children:e.notes.map((e,t)=>(0,a.jsxs)("div",{className:`flex items-start gap-2 rounded p-2 text-xs ${"warning"===e.type?"bg-yellow-500/10 text-yellow-600 dark:text-yellow-400":"bg-blue-500/10 text-blue-600 dark:text-blue-400"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined mt-0.5 text-[14px]",children:"warning"===e.type?"warning":"info"}),(0,a.jsx)("span",{children:e.text})]},t))}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Select Endpoint"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(k,{value:W||et(),onChange:G,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:x,tunnelPublicUrl:u,tailscaleEnabled:p,tailscaleUrl:h,currentUrl:V})]}),Y?.base_url&&(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Current"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("span",{className:"min-w-0 truncate rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5",children:[Y.base_url," \xb7 ",Y.model,Y.context_window?` \xb7 ${(Y.context_window/1e3).toLocaleString()}K ctx`:""]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(_,{value:P,onChange:R,apiKeys:o,cloudEnabled:c})]}),(0,a.jsx)(ey,{label:"Main Model",value:I,onChange:U,placeholder:"provider/model-id",onSelect:()=>F("main"),disabled:!n}),(0,a.jsx)("div",{className:"my-1 border-t border-border pt-3",children:(0,a.jsxs)("div",{className:"mb-2 flex items-start gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-primary text-[16px]",children:"account_tree"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-xs font-semibold text-text-main",children:"Subagent model overrides"}),(0,a.jsx)("p",{className:"text-[10px] text-text-muted",children:"Leave blank to inherit Main Model. Each override keeps its own context window."})]})]})}),eb.map(e=>(0,a.jsx)(ey,{label:e.label,help:e.help,value:D[e.id]||"",onChange:t=>z(s=>({...s,[e.id]:t})),placeholder:`${I||"Main Model"} (inherit)`,onSelect:()=>F(e.id),disabled:!n},e.id))]}),O&&(0,a.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===O.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===O.type?"check_circle":"error"}),(0,a.jsx)("span",{children:O.text})]}),(0,a.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2",children:[(0,a.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:es,disabled:!I,loading:S,className:"w-full sm:w-auto",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,a.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:ea,disabled:!v?.has9Router,loading:$,className:"w-full sm:w-auto",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,a.jsxs)(r.$n,{variant:"ghost",size:"sm",onClick:()=>H(!0),className:"w-full sm:w-auto",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),L&&(0,a.jsx)(r.rq,{isOpen:!!L,onClose:()=>F(null),onSelect:e=>{"main"===L?U(e.value):L&&z(t=>({...t,[L]:e.value})),F(null)},selectedModel:"main"===L?I:D[L]||"",activeProviders:d,modelAliases:K,title:"main"===L?"Select Main Model for Grok Build":`Select ${eb.find(e=>e.id===L)?.label||"Subagent"} Model`}),(0,a.jsx)(r.uR,{isOpen:B,onClose:()=>H(!1),title:"Grok Build - Manual Configuration",configs:(()=>{let e=P?.trim()||(c?"<API_KEY_FROM_DASHBOARD>":"sk_9router"),t=et(),s=I||"provider/model-id",a=[`[models]
|
|
98
98
|
default = "${ef}"`,`[model.${ef}]
|
|
99
99
|
model = "${s}"
|
|
100
100
|
base_url = "${t}"
|
|
@@ -111,7 +111,7 @@ api_backend = "chat_completions"
|
|
|
111
111
|
api_key = "${e}"
|
|
112
112
|
context_window = ${f(r)||2e5}`)}return l.length&&a.splice(1,0,`[subagents.models]
|
|
113
113
|
${l.join("\n")}`),[{filename:"~/.grok/config.toml",content:`${a.join("\n\n")}
|
|
114
|
-
`}]})()})]})}var ev=s(29281);let eN=[2e5,4e5,6e5,1e6],ew=[16e3,32e3,64e3,128e3],ek={contextWindow:2e5,maxTokens:64e3},eC={contextWindow:2e6,maxTokens:2e5},e_=e=>e>=1e6?`${+(e/1e6).toFixed(2)}M`:`${Math.round(e/1e3)}k`,eS=(e,t,s)=>{let a=Number(e);return Number.isFinite(a)&&a>0&&a<=s?a:t},eA=(e,t)=>e.includes(t)?e:[...e,t].sort((e,t)=>e-t),eE=e=>{let t=e?.providers?.["9router"]?.models;if(!Array.isArray(t)||0===t.length)return null;let s={};return{ids:t.map(e=>{let t="string"==typeof e?e:e.id;return"string"!=typeof e&&(s[t]={contextWindow:eS(e.contextWindow,ek.contextWindow,eC.contextWindow),maxTokens:eS(e.maxTokens,ek.maxTokens,eC.maxTokens)}),t}),caps:s}};function e$({tool:e,isExpanded:t,onToggle:s,baseUrl:n,apiKeys:o,activeProviders:d=[],cloudEnabled:c,initialStatus:m,tunnelEnabled:x,tunnelPublicUrl:u,tailscaleEnabled:p,tailscaleUrl:h}){let[g,f]=(0,l.useState)(()=>m||null),[b,y]=(0,l.useState)(!1),[v,N]=(0,l.useState)(!1),[w,C]=(0,l.useState)(!1),[_,A]=(0,l.useState)(null),[$,M]=(0,l.useState)(!1),[O,T]=(0,l.useState)(()=>o?.[0]?.key||""),[P,R]=(0,l.useState)(()=>{let e=m?.config;return e?.model||e?.openai?.model||e?.providers?.["9router"]?.models?.[0]?.id||""}),I=eE(m?.config),[U,D]=(0,l.useState)(()=>I?.ids||[]),[z,L]=(0,l.useState)(()=>I?.caps||{}),[F,K]=(0,l.useState)(!1),[q,B]=(0,l.useState)(!1),[H,W]=(0,l.useState)(!1),[G,J]=(0,l.useState)(""),Y=`/api/cli-tools/${e.id}-settings`;(0,l.useEffect)(()=>{let s=!0;return t&&!m&&fetch(Y).then(e=>e.json()).then(t=>{if(s){f(t);let s=t?.config;if("pi"===e.id){let e=eE(s);e&&(D(e.ids),L(e.caps))}else{let e=s?.model||s?.openai?.model||s?.providers?.["9router"]?.models?.[0]?.id;e&&R(t=>t||e)}}}).catch(e=>{s&&f({installed:!1,error:e.message})}),()=>{s=!1}},[t,m,Y,e.id]);let V=async()=>{y(!0);try{let t=await fetch(Y),s=await t.json();f(s);let a=s?.config;if("pi"===e.id){let e=eE(a);e&&(D(e.ids),L(e.caps))}else{let e=a?.model||a?.openai?.model||a?.providers?.["9router"]?.models?.[0]?.id;e&&!P&&R(e)}}catch(e){f({installed:!1,error:e.message})}finally{y(!1)}},Z=()=>{let e=G||`${n}/v1`;return e.endsWith("/v1")?e:`${e}/v1`},Q=(()=>{if(!g?.config)return"";let e=g.config;return"string"==typeof e.baseUrl?e.baseUrl:"string"==typeof e.openai?.base_url?e.openai.base_url:"string"==typeof e.providers?.["9router"]?.base_url?e.providers["9router"].base_url:"string"==typeof e.providers?.["9router"]?.baseUrl?e.providers["9router"].baseUrl:""})(),X=g?.installed?g.has9Router?(Q&&E(Q,{tunnelPublicUrl:u,tailscaleUrl:h}),"configured"):"not_configured":null,ee=async()=>{N(!0),A(null);try{let t=O&&O.trim()||c?O:"sk_9router",s={baseUrl:Z(),apiKey:t};"pi"===e.id?s.models=(U.length>0?U:["provider/model-id"]).map(e=>({id:e,name:e,...ek,...z[e]})):s.model=P;let a=await fetch(Y,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}),l=await a.json();a.ok?(j(Z()),A({type:"success",text:l.message||"Settings applied successfully!"}),await V()):A({type:"error",text:l.error?.message||"Failed to apply settings."})}catch(e){A({type:"error",text:e.message})}finally{N(!1)}},et=async()=>{C(!0),A(null);try{let e=await fetch(Y,{method:"DELETE"}),t=await e.json();e.ok?(A({type:"success",text:t.message||"Settings removed successfully."}),await V()):A({type:"error",text:t.error?.message||"Failed to reset settings."})}catch(e){A({type:"error",text:e.message})}finally{C(!1)}},es=async()=>{let e=async e=>{try{let t=await fetch(e,{cache:"no-store"});return t.ok?await t.json():null}catch{return null}},[t,s,a,l]=await Promise.all([e("/api/providers"),e("/api/models/alias"),e("/api/models/custom"),e("/api/models/disabled")]),r=t?.connections??d??[],i=r.filter(e=>e&&!1!==e.isActive),n={};return await Promise.all(ev.Q_.map(async t=>{let s=i.filter(e=>e.provider===t).map(e=>e.id);if(0===s.length)return;let a=await Promise.all(s.map(t=>e(`/api/providers/${t}/models`)));n[t]=a.flatMap(e=>Array.isArray(e?.models)?e.models:[])})),(0,ev.cd)((0,ev.mo)({connections:i,allConnections:r,modelAliases:s?.aliases||{},customModels:a?.models||[],disabledModels:l?.disabled||{},liveModels:n}))},ea=async()=>{K(!0),A(null);try{let e=await es();if(0===e.length)return void A({type:"error",text:"No active models found to add."});D(t=>Array.from(new Set([...t,...e]))),L(t=>{let s={...t};return e.forEach(e=>{s[e]||={...ek}}),s})}catch(e){A({type:"error",text:e.message})}finally{K(!1)}},el=(e,t,s)=>{L(a=>({...a,[e]:{...ek,...a[e],[t]:eS(s,ek[t],eC[t])}}))};return(0,a.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3 hover:cursor-pointer sm:items-center",onClick:s,children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:e.image?(0,a.jsx)(i.A,{src:e.image,alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"},loading:"lazy",decoding:"async"}):e.icon?(0,a.jsx)("span",{className:"material-symbols-outlined text-[28px]",style:{color:e.color},children:e.icon}):(0,a.jsx)("span",{className:"material-symbols-outlined text-[28px] text-primary",children:"terminal"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===X&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===X&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===X&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[b&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,a.jsxs)("span",{children:["Checking ",e.name,"..."]})]}),!b&&g&&!g.installed&&(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsxs)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:[e.name," not detected locally"]}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if 9router is deployed on a remote server."})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 pl-9",children:[(0,a.jsxs)(r.$n,{variant:"secondary",size:"sm",onClick:()=>W(!0),className:"!bg-yellow-500/20 !border-yellow-500/40 !text-yellow-700 dark:!text-yellow-300 hover:!bg-yellow-500/30",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:"content_copy"}),"Manual Config"]}),(0,a.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:()=>M(!$),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:$?"expand_less":"help"}),$?"Hide":"How to Install"]})]})]}),$&&(0,a.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,a.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,a.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-text-muted mb-1",children:"Install command:"}),(0,a.jsx)("code",{className:"block px-3 py-2 bg-black/5 dark:bg-white/5 rounded font-mono text-xs",children:(()=>{switch(e.id){case"pi":return"curl -fsSL https://pi.dev/install.sh | sh # or: npm install -g --ignore-scripts @earendil-works/pi-coding-agent";case"omp":return"npm install -g oh-my-pi";case"crush":return"brew install charmbracelet/tap/crush # or go install github.com/charmbracelet/crush@latest";case"forge":return"cargo install forgecode";case"smelt":return"cargo install smelt";case"codewhale":return"cargo install codewhale";default:return`npm install -g ${e.id}`}})()})]}),e.docsUrl&&(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["Docs: ",(0,a.jsx)("a",{href:e.docsUrl,target:"_blank",rel:"noreferrer",className:"text-primary hover:underline",children:e.docsUrl})]})]})]})]}),!b&&g?.installed&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Select Endpoint"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(k,{value:G||Z(),onChange:J,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:x,tunnelPublicUrl:u,tailscaleEnabled:p,tailscaleUrl:h,currentUrl:Q})]}),Q?(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Current"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)("span",{className:"min-w-0 truncate rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5",children:Q})]}):null,(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(S,{value:O,onChange:T,apiKeys:o,cloudEnabled:c})]}),"pi"===e.id&&(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-start sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm mt-1",children:"Models"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline mt-1.5",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"flex-1 flex flex-col gap-2",children:[(0,a.jsx)("div",{className:"flex flex-wrap gap-1.5 min-h-[36px] p-2 bg-surface rounded border border-border",children:0===U.length?(0,a.jsx)("span",{className:"text-xs text-text-muted italic",children:"No models selected. Add models to use in Pi."}):U.map(e=>{let t={...ek,...z[e]};return(0,a.jsxs)("div",{className:"flex w-full flex-wrap items-center gap-1.5 rounded border border-border bg-bg-secondary px-2 py-1 text-xs text-text-main",children:[(0,a.jsx)("span",{className:"min-w-0 flex-1 basis-40 truncate",children:e}),(0,a.jsx)("select",{value:t.contextWindow,onChange:t=>el(e,"contextWindow",t.target.value),title:"Context window",className:"shrink-0 rounded border border-border bg-surface px-1 py-0.5 text-[11px] focus:outline-none focus:ring-1 focus:ring-primary/50",children:eA(eN,t.contextWindow).map(e=>(0,a.jsxs)("option",{value:e,children:[e_(e)," ctx"]},e))}),(0,a.jsx)("select",{value:t.maxTokens,onChange:t=>el(e,"maxTokens",t.target.value),title:"Max output tokens",className:"rounded border border-border bg-surface px-1 py-0.5 text-[11px] focus:outline-none focus:ring-1 focus:ring-primary/50",children:eA(ew,t.maxTokens).map(e=>(0,a.jsxs)("option",{value:e,children:[e_(e)," out"]},e))}),(0,a.jsx)("button",{type:"button",onClick:()=>{D(t=>t.filter(t=>t!==e)),L(t=>{let s={...t};return delete s[e],s})},className:"text-text-muted hover:text-red-500 rounded p-0.5",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"close"})})]},e)})}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,a.jsxs)(r.$n,{type:"button",size:"sm",variant:"secondary",onClick:()=>B(!0),disabled:!d?.length,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"add"}),"Add Model"]}),(0,a.jsx)(r.$n,{type:"button",size:"sm",variant:"ghost",onClick:ea,disabled:F,className:"text-xs text-primary hover:text-primary-hover",children:F?"Adding...":"+ Add All Active Models"}),U.length>0&&(0,a.jsx)("button",{type:"button",onClick:()=>D([]),className:"text-xs text-text-muted hover:text-red-500 ml-auto",children:"Clear all"})]})]})]}),"omp"!==e.id&&"pi"!==e.id&&(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Model"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,a.jsx)("input",{type:"text",value:P,onChange:e=>R(e.target.value),placeholder:"provider/model-id",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),P&&(0,a.jsx)("button",{onClick:()=>R(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,a.jsx)("button",{onClick:()=>B(!0),disabled:!d?.length,className:`w-full sm:w-auto rounded border px-2 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap sm:shrink-0 ${d?.length?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"})]})]}),_&&(0,a.jsx)("div",{className:`p-3 rounded-lg text-sm ${"success"===_.type?"bg-green-500/10 text-green-600 dark:text-green-400 border border-green-500/20":"bg-red-500/10 text-red-600 dark:text-red-400 border border-red-500/20"}`,children:_.text}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3 pt-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(r.$n,{variant:"primary",size:"sm",onClick:ee,disabled:v||b,children:v?"Applying...":"Apply Settings"}),g?.has9Router&&(0,a.jsx)(r.$n,{variant:"outline",size:"sm",onClick:et,disabled:w||b,className:"text-red-500 hover:text-red-600 hover:border-red-500/50",children:w?"Removing...":"Remove from Tool"})]}),(0,a.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:()=>W(!0),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:"code"}),"Manual Config"]})]})]})]}),(0,a.jsx)(r.rq,{isOpen:q,onClose:()=>B(!1),onSelect:t=>{"pi"===e.id?U.includes(t.value)||(D(e=>[...e,t.value]),L(e=>({...e,[t.value]:{...ek,...e[t.value]}}))):R(t.value),B(!1)},activeProviders:d}),(0,a.jsx)(r.uR,{isOpen:H,onClose:()=>W(!1),title:`${e.name} Configuration`,configs:(()=>{let t=Z(),s=O||"sk_9router",a=P||"provider/model-id";switch(e.id){case"pi":return[{filename:"~/.pi/agent/models.json",content:JSON.stringify({providers:{"9router":{baseUrl:t,apiKey:s,api:"openai-completions",models:(U.length>0?U:[a]).map(e=>({id:e,name:e,...ek,...z[e]}))}}},null,2)}];case"omp":return[{filename:"~/.omp/agent/models.yml",content:`providers:
|
|
114
|
+
`}]})()})]})}var ev=s(29281);let eN=[2e5,4e5,6e5,1e6],ew=[16e3,32e3,64e3,128e3],ek={contextWindow:2e5,maxTokens:64e3},eC={contextWindow:2e6,maxTokens:2e5},eS=e=>e>=1e6?`${+(e/1e6).toFixed(2)}M`:`${Math.round(e/1e3)}k`,e_=(e,t,s)=>{let a=Number(e);return Number.isFinite(a)&&a>0&&a<=s?a:t},eA=(e,t)=>e.includes(t)?e:[...e,t].sort((e,t)=>e-t),eE=e=>{let t=e?.providers?.["9router"]?.models;if(!Array.isArray(t)||0===t.length)return null;let s={};return{ids:t.map(e=>{let t="string"==typeof e?e:e.id;return"string"!=typeof e&&(s[t]={contextWindow:e_(e.contextWindow,ek.contextWindow,eC.contextWindow),maxTokens:e_(e.maxTokens,ek.maxTokens,eC.maxTokens)}),t}),caps:s}};function e$({tool:e,isExpanded:t,onToggle:s,baseUrl:n,apiKeys:o,activeProviders:d=[],cloudEnabled:c,initialStatus:m,tunnelEnabled:x,tunnelPublicUrl:u,tailscaleEnabled:p,tailscaleUrl:h}){let[g,f]=(0,l.useState)(()=>m||null),[b,y]=(0,l.useState)(!1),[v,N]=(0,l.useState)(!1),[w,C]=(0,l.useState)(!1),[S,A]=(0,l.useState)(null),[$,M]=(0,l.useState)(!1),[O,T]=(0,l.useState)(()=>o?.[0]?.key||""),[P,R]=(0,l.useState)(()=>{let e=m?.config;return e?.model||e?.openai?.model||e?.providers?.["9router"]?.models?.[0]?.id||""}),I=eE(m?.config),[U,D]=(0,l.useState)(()=>I?.ids||[]),[z,L]=(0,l.useState)(()=>I?.caps||{}),[F,K]=(0,l.useState)(!1),[q,B]=(0,l.useState)(!1),[H,W]=(0,l.useState)(!1),[G,J]=(0,l.useState)(""),Y=`/api/cli-tools/${e.id}-settings`;(0,l.useEffect)(()=>{let s=!0;return t&&!m&&fetch(Y).then(e=>e.json()).then(t=>{if(s){f(t);let s=t?.config;if("pi"===e.id){let e=eE(s);e&&(D(e.ids),L(e.caps))}else{let e=s?.model||s?.openai?.model||s?.providers?.["9router"]?.models?.[0]?.id;e&&R(t=>t||e)}}}).catch(e=>{s&&f({installed:!1,error:e.message})}),()=>{s=!1}},[t,m,Y,e.id]);let V=async()=>{y(!0);try{let t=await fetch(Y),s=await t.json();f(s);let a=s?.config;if("pi"===e.id){let e=eE(a);e&&(D(e.ids),L(e.caps))}else{let e=a?.model||a?.openai?.model||a?.providers?.["9router"]?.models?.[0]?.id;e&&!P&&R(e)}}catch(e){f({installed:!1,error:e.message})}finally{y(!1)}},Z=()=>{let e=G||`${n}/v1`;return e.endsWith("/v1")?e:`${e}/v1`},Q=(()=>{if(!g?.config)return"";let e=g.config;return"string"==typeof e.baseUrl?e.baseUrl:"string"==typeof e.openai?.base_url?e.openai.base_url:"string"==typeof e.providers?.["9router"]?.base_url?e.providers["9router"].base_url:"string"==typeof e.providers?.["9router"]?.baseUrl?e.providers["9router"].baseUrl:""})(),X=g?.installed?g.has9Router?(Q&&E(Q,{tunnelPublicUrl:u,tailscaleUrl:h}),"configured"):"not_configured":null,ee=async()=>{N(!0),A(null);try{let t=O&&O.trim()||c?O:"sk_9router",s={baseUrl:Z(),apiKey:t};"pi"===e.id?s.models=(U.length>0?U:["provider/model-id"]).map(e=>({id:e,name:e,...ek,...z[e]})):s.model=P;let a=await fetch(Y,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}),l=await a.json();a.ok?(j(Z()),A({type:"success",text:l.message||"Settings applied successfully!"}),await V()):A({type:"error",text:l.error?.message||"Failed to apply settings."})}catch(e){A({type:"error",text:e.message})}finally{N(!1)}},et=async()=>{C(!0),A(null);try{let e=await fetch(Y,{method:"DELETE"}),t=await e.json();e.ok?(A({type:"success",text:t.message||"Settings removed successfully."}),await V()):A({type:"error",text:t.error?.message||"Failed to reset settings."})}catch(e){A({type:"error",text:e.message})}finally{C(!1)}},es=async()=>{let e=async e=>{try{let t=await fetch(e,{cache:"no-store"});return t.ok?await t.json():null}catch{return null}},[t,s,a,l]=await Promise.all([e("/api/providers"),e("/api/models/alias"),e("/api/models/custom"),e("/api/models/disabled")]),r=t?.connections??d??[],i=r.filter(e=>e&&!1!==e.isActive),n={};return await Promise.all(ev.Q_.map(async t=>{let s=i.filter(e=>e.provider===t).map(e=>e.id);if(0===s.length)return;let a=await Promise.all(s.map(t=>e(`/api/providers/${t}/models`)));n[t]=a.flatMap(e=>Array.isArray(e?.models)?e.models:[])})),(0,ev.cd)((0,ev.mo)({connections:i,allConnections:r,modelAliases:s?.aliases||{},customModels:a?.models||[],disabledModels:l?.disabled||{},liveModels:n}))},ea=async()=>{K(!0),A(null);try{let e=await es();if(0===e.length)return void A({type:"error",text:"No active models found to add."});D(t=>Array.from(new Set([...t,...e]))),L(t=>{let s={...t};return e.forEach(e=>{s[e]||={...ek}}),s})}catch(e){A({type:"error",text:e.message})}finally{K(!1)}},el=(e,t,s)=>{L(a=>({...a,[e]:{...ek,...a[e],[t]:e_(s,ek[t],eC[t])}}))};return(0,a.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3 hover:cursor-pointer sm:items-center",onClick:s,children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:e.image?(0,a.jsx)(i.A,{src:e.image,alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"},loading:"lazy",decoding:"async"}):e.icon?(0,a.jsx)("span",{className:"material-symbols-outlined text-[28px]",style:{color:e.color},children:e.icon}):(0,a.jsx)("span",{className:"material-symbols-outlined text-[28px] text-primary",children:"terminal"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===X&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===X&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===X&&(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other"})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[b&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,a.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,a.jsxs)("span",{children:["Checking ",e.name,"..."]})]}),!b&&g&&!g.installed&&(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsxs)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:[e.name," not detected locally"]}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if 9router is deployed on a remote server."})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 pl-9",children:[(0,a.jsxs)(r.$n,{variant:"secondary",size:"sm",onClick:()=>W(!0),className:"!bg-yellow-500/20 !border-yellow-500/40 !text-yellow-700 dark:!text-yellow-300 hover:!bg-yellow-500/30",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:"content_copy"}),"Manual Config"]}),(0,a.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:()=>M(!$),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:$?"expand_less":"help"}),$?"Hide":"How to Install"]})]})]}),$&&(0,a.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,a.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,a.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-text-muted mb-1",children:"Install command:"}),(0,a.jsx)("code",{className:"block px-3 py-2 bg-black/5 dark:bg-white/5 rounded font-mono text-xs",children:(()=>{switch(e.id){case"pi":return"curl -fsSL https://pi.dev/install.sh | sh # or: npm install -g --ignore-scripts @earendil-works/pi-coding-agent";case"omp":return"npm install -g oh-my-pi";case"crush":return"brew install charmbracelet/tap/crush # or go install github.com/charmbracelet/crush@latest";case"forge":return"cargo install forgecode";case"smelt":return"cargo install smelt";case"codewhale":return"cargo install codewhale";default:return`npm install -g ${e.id}`}})()})]}),e.docsUrl&&(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["Docs: ",(0,a.jsx)("a",{href:e.docsUrl,target:"_blank",rel:"noreferrer",className:"text-primary hover:underline",children:e.docsUrl})]})]})]})]}),!b&&g?.installed&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Select Endpoint"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(k,{value:G||Z(),onChange:J,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:x,tunnelPublicUrl:u,tailscaleEnabled:p,tailscaleUrl:h,currentUrl:Q})]}),Q?(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Current"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)("span",{className:"min-w-0 truncate rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5",children:Q})]}):null,(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(_,{value:O,onChange:T,apiKeys:o,cloudEnabled:c})]}),"pi"===e.id&&(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-start sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm mt-1",children:"Models"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline mt-1.5",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"flex-1 flex flex-col gap-2",children:[(0,a.jsx)("div",{className:"flex flex-wrap gap-1.5 min-h-[36px] p-2 bg-surface rounded border border-border",children:0===U.length?(0,a.jsx)("span",{className:"text-xs text-text-muted italic",children:"No models selected. Add models to use in Pi."}):U.map(e=>{let t={...ek,...z[e]};return(0,a.jsxs)("div",{className:"flex w-full flex-wrap items-center gap-1.5 rounded border border-border bg-bg-secondary px-2 py-1 text-xs text-text-main",children:[(0,a.jsx)("span",{className:"min-w-0 flex-1 basis-40 truncate",children:e}),(0,a.jsx)("select",{value:t.contextWindow,onChange:t=>el(e,"contextWindow",t.target.value),title:"Context window",className:"shrink-0 rounded border border-border bg-surface px-1 py-0.5 text-[11px] focus:outline-none focus:ring-1 focus:ring-primary/50",children:eA(eN,t.contextWindow).map(e=>(0,a.jsxs)("option",{value:e,children:[eS(e)," ctx"]},e))}),(0,a.jsx)("select",{value:t.maxTokens,onChange:t=>el(e,"maxTokens",t.target.value),title:"Max output tokens",className:"rounded border border-border bg-surface px-1 py-0.5 text-[11px] focus:outline-none focus:ring-1 focus:ring-primary/50",children:eA(ew,t.maxTokens).map(e=>(0,a.jsxs)("option",{value:e,children:[eS(e)," out"]},e))}),(0,a.jsx)("button",{type:"button",onClick:()=>{D(t=>t.filter(t=>t!==e)),L(t=>{let s={...t};return delete s[e],s})},className:"text-text-muted hover:text-red-500 rounded p-0.5",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"close"})})]},e)})}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,a.jsxs)(r.$n,{type:"button",size:"sm",variant:"secondary",onClick:()=>B(!0),disabled:!d?.length,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"add"}),"Add Model"]}),(0,a.jsx)(r.$n,{type:"button",size:"sm",variant:"ghost",onClick:ea,disabled:F,className:"text-xs text-primary hover:text-primary-hover",children:F?"Adding...":"+ Add All Active Models"}),U.length>0&&(0,a.jsx)("button",{type:"button",onClick:()=>D([]),className:"text-xs text-text-muted hover:text-red-500 ml-auto",children:"Clear all"})]})]})]}),"omp"!==e.id&&"pi"!==e.id&&(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Model"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,a.jsx)("input",{type:"text",value:P,onChange:e=>R(e.target.value),placeholder:"provider/model-id",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),P&&(0,a.jsx)("button",{onClick:()=>R(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,a.jsx)("button",{onClick:()=>B(!0),disabled:!d?.length,className:`w-full sm:w-auto rounded border px-2 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap sm:shrink-0 ${d?.length?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select Model"})]})]}),S&&(0,a.jsx)("div",{className:`p-3 rounded-lg text-sm ${"success"===S.type?"bg-green-500/10 text-green-600 dark:text-green-400 border border-green-500/20":"bg-red-500/10 text-red-600 dark:text-red-400 border border-red-500/20"}`,children:S.text}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3 pt-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(r.$n,{variant:"primary",size:"sm",onClick:ee,disabled:v||b,children:v?"Applying...":"Apply Settings"}),g?.has9Router&&(0,a.jsx)(r.$n,{variant:"outline",size:"sm",onClick:et,disabled:w||b,className:"text-red-500 hover:text-red-600 hover:border-red-500/50",children:w?"Removing...":"Remove from Tool"})]}),(0,a.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:()=>W(!0),children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:"code"}),"Manual Config"]})]})]})]}),(0,a.jsx)(r.rq,{isOpen:q,onClose:()=>B(!1),onSelect:t=>{"pi"===e.id?U.includes(t.value)||(D(e=>[...e,t.value]),L(e=>({...e,[t.value]:{...ek,...e[t.value]}}))):R(t.value),B(!1)},activeProviders:d}),(0,a.jsx)(r.uR,{isOpen:H,onClose:()=>W(!1),title:`${e.name} Configuration`,configs:(()=>{let t=Z(),s=O||"sk_9router",a=P||"provider/model-id";switch(e.id){case"pi":return[{filename:"~/.pi/agent/models.json",content:JSON.stringify({providers:{"9router":{baseUrl:t,apiKey:s,api:"openai-completions",models:(U.length>0?U:[a]).map(e=>({id:e,name:e,...ek,...z[e]}))}}},null,2)}];case"omp":return[{filename:"~/.omp/agent/models.yml",content:`providers:
|
|
115
115
|
9router:
|
|
116
116
|
baseUrl: ${t}
|
|
117
117
|
apiKey: ${s}
|
|
@@ -129,4 +129,6 @@ model = "${a}"`}];case"smelt":return[{filename:"~/.smelt/config.json",content:JS
|
|
|
129
129
|
[openai]
|
|
130
130
|
base_url = "${t}"
|
|
131
131
|
api_key = "${s}"
|
|
132
|
-
model = "${a}"`}];default:return[]}})()})]})}let eM="http://localhost:20128";function eO({apiKeys:e,cloudEnabled:t,onStatusChange:s}){let[i,n]=(0,l.useState)(null),[o,d]=(0,l.useState)(!1),[c,m]=(0,l.useState)(!1),[x,u]=(0,l.useState)(""),[p,h]=(0,l.useState)(()=>e?.[0]?.key||""),[g,f]=(0,l.useState)(null),[b,y]=(0,l.useState)(null),[j,v]=(0,l.useState)(null),[N,w]=(0,l.useState)(eM),[k,C]=(0,l.useState)(null),_=i?.isWin===!0,S=_||i?.hasCachedPassword||i?.needsSudoPassword===!1,A=i?.isAdmin!==!1;!A&&(_||i?.hasCachedPassword||i?.needsSudoPassword);let E=(0,l.useCallback)(async()=>{try{let e=await fetch("/api/cli-tools/antigravity-mitm"),t=await e.json().catch(()=>({}));if(!e.ok){let s=t.error||`Unable to load MITM status (HTTP ${e.status}).`,a=401===e.status||403===e.status?" Refresh the page or sign in again to restore local MITM access.":"";n(null),v(`${s}${a}`);return}v(null),n(t),t.mitmRouterBaseUrl&&w(t.mitmRouterBaseUrl),s?.(t)}catch(e){n(null),v(e?.message||"Unable to reach the MITM status endpoint.")}},[s]);(0,l.useEffect)(()=>{queueMicrotask(()=>{E()})},[E]);let $=e=>{v(null),i&&(S?M(e,""):(f(e),m(!0),y(null)))},M=async(s,a,l=!1)=>{d(!0),v(null);try{let r;if("trust-cert"===s)r=await fetch("/api/cli-tools/antigravity-mitm",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"trust-cert",sudoPassword:a})});else if("start"===s){let s=p?.trim()||(e?.length>0?e[0].key:null)||(t?null:"sk_9router");r=await fetch("/api/cli-tools/antigravity-mitm",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:s,sudoPassword:a,mitmRouterBaseUrl:N.trim()||eM,forceKillPort443:l})})}else r=await fetch("/api/cli-tools/antigravity-mitm",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({sudoPassword:a})});if(!r.ok){let e=await r.json().catch(()=>({}));if("PORT_443_BUSY"===e.code&&e.portOwner){m(!1),C({owner:e.portOwner,password:a});return}v(e.error||`Failed to ${s} MITM server`);return}m(!1),u(""),C(null),await E()}catch(e){v(e.message||"Network error")}finally{d(!1),f(null)}},O=()=>{x?M(g,x):y("Sudo password is required")},T=i?.running;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.Zp,{padding:"sm",className:"border-primary/20 bg-primary/5",children:(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-primary text-[20px]",children:"security"}),(0,a.jsx)("span",{className:"font-semibold text-sm text-text-main",children:"MITM Server"}),T?(0,a.jsx)(r.Ex,{variant:"success",size:"sm",children:"Running"}):(0,a.jsx)(r.Ex,{variant:"default",size:"sm",children:"Stopped"})]}),(0,a.jsx)("div",{className:"flex flex-wrap items-center gap-1 text-xs text-text-muted","data-i18n-skip":"true",children:[{label:"Cert",ok:i?.certExists},{label:"Trusted",ok:i?.certTrusted},{label:"Server",ok:T}].map(({label:e,ok:t})=>(0,a.jsxs)("span",{className:`flex items-center gap-0.5 px-1.5 py-0.5 rounded ${t?"text-green-600":"text-text-muted"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:t?"check_circle":"cancel"}),e]},e))})]}),(0,a.jsxs)("div",{className:"px-2 py-2 rounded-lg bg-surface/50 border border-border/50 flex flex-col gap-2",children:[(0,a.jsxs)("p",{className:"text-[11px] text-text-muted leading-relaxed",children:[(0,a.jsx)("span",{className:"font-medium text-text-main",children:"Purpose:"})," Use Antigravity IDE & GitHub Copilot → with ANY provider/model from 9Router"]}),(0,a.jsxs)("p",{className:"text-[11px] text-text-muted leading-relaxed",children:[(0,a.jsx)("span",{className:"font-medium text-text-main",children:"How it works:"})," Antigravity/Copilot IDE request → DNS redirect to localhost:443 → MITM proxy intercepts → 9Router → response to Antigravity/Copilot"]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"grid gap-1 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"9Router Base URL"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)("input",{type:"text",value:N,onChange:e=>w(e.target.value),placeholder:eM,disabled:T,className:"flex-1 min-w-0 px-2 py-1.5 bg-surface rounded border border-border text-xs text-text-main focus:outline-none focus:ring-1 focus:ring-primary/50 disabled:opacity-50"})]}),!T&&(0,a.jsxs)("div",{className:"grid gap-1 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)("input",{type:"text",list:"mitm-api-keys",value:p,onChange:e=>h(e.target.value),placeholder:t?"Enter or pick API key":"sk_9router (default)",className:"flex-1 min-w-0 px-2 py-1.5 bg-surface rounded border border-border text-xs text-text-main focus:outline-none focus:ring-1 focus:ring-primary/50"}),e?.length>0&&(0,a.jsx)("datalist",{id:"mitm-api-keys",children:e.map(e=>(0,a.jsx)("option",{value:e.key,children:e.name||e.key},e.id))})]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:flex-wrap sm:items-center","data-i18n-skip":"true",children:[i?.certExists&&!i?.certTrusted&&(0,a.jsxs)("button",{onClick:()=>$("trust-cert"),disabled:o,className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-yellow-500/30 bg-yellow-500/10 px-4 py-2 text-xs font-medium text-yellow-600 transition-colors hover:bg-yellow-500/20 disabled:opacity-50 sm:w-auto sm:py-1.5",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"verified_user"}),"Trust Cert"]}),T?(0,a.jsxs)("button",{onClick:()=>$("stop"),disabled:o,className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-red-500/30 bg-red-500/10 px-4 py-2 text-xs font-medium text-red-500 transition-colors hover:bg-red-500/20 disabled:opacity-50 sm:w-auto sm:py-1.5",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"stop_circle"}),"Stop Server"]}):(0,a.jsxs)("button",{onClick:()=>$("start"),disabled:o||!i||_&&!A,title:_&&!A?"Administrator required":void 0,className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-primary/30 bg-primary/10 px-4 py-2 text-xs font-medium text-primary transition-colors hover:bg-primary/20 disabled:opacity-50 sm:w-auto sm:py-1.5",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"play_circle"}),"Start Server"]}),T&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Enable DNS per tool below to activate interception"})]}),j&&(0,a.jsxs)("div",{className:"flex items-start gap-2 px-2 py-1.5 rounded text-xs bg-red-500/10 text-red-600 dark:text-red-400 border border-red-500/20",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mt-0.5 shrink-0",children:"error"}),(0,a.jsx)("span",{children:j})]}),_&&!A&&(0,a.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded text-xs bg-red-500/10 text-red-600 border border-red-500/20",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"shield_lock"}),(0,a.jsx)("span",{children:"Administrator required — restart 9Router as Administrator to use MITM"})]})]})}),c&&(0,a.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:(0,a.jsxs)("div",{className:"mx-4 flex w-full max-w-sm flex-col gap-4 rounded-xl border border-border bg-surface p-5 shadow-xl sm:p-6",children:[(0,a.jsx)("h3",{className:"font-semibold text-text-main",children:"Sudo Password Required"}),(0,a.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-yellow-500 text-[20px]",children:"warning"}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Required for SSL certificate and server startup"})]}),(0,a.jsx)(r.pd,{type:"password",placeholder:"Enter sudo password",value:x,onChange:e=>u(e.target.value),onKeyDown:e=>{"Enter"!==e.key||o||O()}}),b&&(0,a.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded text-xs bg-red-500/10 text-red-600",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"error"}),(0,a.jsx)("span",{children:b})]}),(0,a.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,a.jsx)(r.$n,{variant:"ghost",size:"sm",onClick:()=>{m(!1),u(""),y(null)},disabled:o,children:"Cancel"}),(0,a.jsx)(r.$n,{variant:"primary",size:"sm",onClick:O,loading:o,children:"Confirm"})]})]})}),k&&(0,a.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:(0,a.jsxs)("div",{className:"mx-4 flex w-full max-w-md flex-col gap-4 rounded-xl border border-border bg-surface p-5 shadow-xl sm:p-6",children:[(0,a.jsx)("h3",{className:"font-semibold text-text-main",children:"Port 443 Already In Use"}),(0,a.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-yellow-500 text-[20px]",children:"warning"}),(0,a.jsxs)("div",{className:"flex flex-col gap-1 text-xs text-text-muted",children:[(0,a.jsx)("p",{children:"Port 443 is currently used by another process:"}),(0,a.jsxs)("p",{className:"font-mono text-text-main","data-i18n-skip":"true",children:[k.owner.name," (PID ",k.owner.pid,")"]}),(0,a.jsx)("p",{children:"Kill this process to start MITM Server?"})]})]}),(0,a.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,a.jsx)(r.$n,{variant:"ghost",size:"sm",onClick:()=>{C(null),d(!1)},disabled:o,children:"Cancel"}),(0,a.jsx)(r.$n,{variant:"primary",size:"sm",onClick:()=>{M("start",k?.password||"",!0)},loading:o,children:"Kill & Start"})]})]})})]})}var eT=s(40295);function eP({tool:e,isExpanded:t,onToggle:s,serverRunning:n,dnsActive:o,hasCachedPassword:d,apiKeys:c,activeProviders:m,hasActiveProviders:x,modelAliases:u={},cloudEnabled:p,onDnsChange:h,tokenSwapActive:g=!1}){let[f,b]=(0,l.useState)(!1),[y,j]=(0,l.useState)(null),[v,N]=(0,l.useState)(null),[w,k]=(0,l.useState)(!1),[C,_]=(0,l.useState)(""),[S,A]=(0,l.useState)(null),[E,$]=(0,l.useState)(null),{currentEditingAlias:M,handleAddMapping:O,handleMappingBlur:T,handleModelMappingChange:P,handleModelSelect:R,handleRemoveMapping:I,handleReorderMapping:U,handleStrategyChange:D,loadSavedMappings:z,mappingFeedback:L,modalOpen:F,modelMappings:K,openModelSelector:q,selectedStrategy:B,setModalOpen:H}=function(e){let[t,s]=(0,l.useState)({}),[a,r]=(0,l.useState)("round-robin"),[i,n]=(0,l.useState)(!1),[o,d]=(0,l.useState)(null),[c,m]=(0,l.useState)(null),[x,u]=(0,l.useState)(null),p=(0,l.useCallback)(async()=>{try{let t=await fetch(`/api/cli-tools/antigravity-mitm/alias?tool=${e}`);if(!t.ok)return;let a=await t.json();s(Z(a.aliases)),r(ee(a.strategy))}catch{}},[e]),h=(0,l.useCallback)(async(t,s)=>{try{await fetch("/api/cli-tools/antigravity-mitm/alias",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:e,mappings:Z(t),strategy:ee(s)})})}catch{}},[e]),g=(0,l.useCallback)((e,t=null)=>{d(e),m(t),n(!0)},[]),f=(0,l.useCallback)((e,t="")=>{s(s=>Q(s,e,t))},[]),b=(0,l.useCallback)((e,t,a)=>{s(s=>X(s,e,t,a))},[]),y=(0,l.useCallback)((e,t,l)=>{s(s=>{let r=Array.isArray(s?.[e])?s[e].length:0,i=function(e,t,s,a){let l=Array.isArray(e?.[t])?[...e[t]]:[];if(s<0||s>=l.length)return e;let r=l.slice(0,s),i=l.slice(s+1),n=Math.max(0,5-r.length-i.length),o=[...r,...String(a||"").split(",").map(e=>e.trim()).filter(Boolean).slice(0,n),...i].slice(0,5);if(0===o.length){let{[t]:s,...a}=e||{};return a}return{...e,[t]:o}}(s,e,t,l),n=Array.isArray(i?.[e])?i[e].length:0,o=String(l||"").split(",").map(e=>e.trim()).filter(Boolean).length;return o>1||n<r?u(n<r?`Max 5 targets per alias. Extra models were ignored for ${e}.`:`Expanded ${o} targets for ${e}.`):u(null),h(i,a),i})},[h,a]),j=(0,l.useCallback)((e,t)=>{s(s=>{let l=function(e,t,s){let a=(Array.isArray(e?.[t])?e[t]:[]).filter((e,t)=>t!==s);if(0===a.length){let{[t]:s,...a}=e||{};return a}return{...e,[t]:a}}(s,e,t);return h(l,a),l})},[h,a]),v=(0,l.useCallback)((e,t,l)=>{s(s=>{let r=function(e,t,s,a){let l=Array.isArray(e?.[t])?[...e[t]]:[];if(s<0||a<0||s>=l.length||a>=l.length||s===a)return e;let[r]=l.splice(s,1);return l.splice(a,0,r),{...e,[t]:l}}(s,e,t,l);return h(r,a),r})},[h,a]),N=(0,l.useCallback)(e=>{o&&!e.isPlaceholder&&(s(t=>{let s=null===c?Q(t,o,e.value):X(t,o,c,e.value),l=Array.isArray(t?.[o])?t[o].length:0,r=Array.isArray(s?.[o])?s[o].length:0;return u(null===c&&r===l?`Max 5 targets per alias. Remove one before adding another for ${o}.`:null),h(s,a),s}),n(!1),m(null))},[o,c,h,a]);return{currentEditingAlias:o,currentEditingIndex:c,handleAddMapping:f,handleMappingBlur:y,handleModelMappingChange:b,handleModelSelect:N,handleRemoveMapping:j,handleReorderMapping:v,handleStrategyChange:(0,l.useCallback)(e=>{let t=ee(e);r(t),s(e=>(h(e,t),e))},[h]),loadSavedMappings:p,mappingFeedback:x,modalOpen:i,modelMappings:t,openModelSelector:g,selectedStrategy:a,setCurrentEditingIndex:m,setMappingFeedback:u,setModalOpen:n}}(e.id),W=eT.TOOL_HOSTS[e.id]??[],G="u">typeof navigator&&navigator.userAgent?.includes("Windows"),J="antigravity"===e.id&&!t;(0,l.useEffect)(()=>{t&&z()},[t,z]);let V=()=>{if(!n)return;let e=o?"disable":"enable";G||d?et(e,""):(A(e),k(!0),$(null))},et=async(t,s)=>{b(!0),j(null),N(null);try{let a=await fetch("/api/cli-tools/antigravity-mitm",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:e.id,action:t,sudoPassword:s})}),l=await a.json().catch(()=>({}));if(!a.ok)throw Error(l.error||`Failed to ${t} DNS`);"enable"===t&&j(`Restart ${e.name} to apply changes`),k(!1),_(""),h?.(l)}catch(e){N(e.message||`Failed to ${t} DNS`)}finally{b(!1),A(null)}},es=()=>{C?et(S,C):$("Sudo password is required")};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3 hover:cursor-pointer",onClick:s,children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(i.A,{src:e.image,alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),e.supportsTokenSwap&&(0,a.jsx)("span",{className:"text-[9px] uppercase tracking-wider text-text-muted bg-surface border border-border px-1.5 py-0.5 rounded font-semibold",children:"Mode A"}),n?g?(0,a.jsx)(r.Ex,{variant:"default",size:"sm",children:"Bypassed"}):o?(0,a.jsx)(r.Ex,{variant:"success",size:"sm",children:"Active"}):(0,a.jsx)(r.Ex,{variant:"warning",size:"sm",children:"DNS off"}):(0,a.jsx)(r.Ex,{variant:"default",size:"sm",children:"Server off"})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Model routing — remap model IDs in intercepted requests"})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[J&&(0,a.jsxs)("div",{className:"flex items-center gap-2",onClick:e=>e.stopPropagation(),children:[(0,a.jsx)(eU,{compact:!0}),(0,a.jsx)(eR,{dnsActive:o,loading:f,serverRunning:n,onClick:V,compact:!0})]}),(0,a.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]})]}),t&&(0,a.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[g&&(0,a.jsxs)("div",{className:"flex items-start gap-2 px-2 py-2 rounded-lg bg-violet-500/5 border border-violet-500/15",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] text-violet-400 mt-0.5 shrink-0",children:"info"}),(0,a.jsx)("p",{className:"text-[11px] text-violet-400",children:"Token Rotation (Mode B) is active — model routing is currently bypassed. Disable Token Rotation to use model routing."})]}),"antigravity"===e.id&&(0,a.jsx)(eU,{}),W.length>0&&(0,a.jsxs)("div",{className:"mt-2 rounded-md border border-border bg-surface/50 px-2 py-1.5",children:[(0,a.jsx)("p",{className:"text-[10px] font-medium tracking-wide text-text-main/80 mb-1",children:"Edit hosts file manually to add the following entries:"}),(0,a.jsx)("ul",{className:"list-none space-y-0.5 font-mono text-[10px] text-text-muted break-all",children:W.map(e=>(0,a.jsxs)("li",{children:["127.0.0.1 ",e]},e))})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-0.5 text-[11px] text-text-muted px-1",children:[(0,a.jsxs)("p",{children:["Toggle DNS to redirect ",e.name," traffic through 9Router via MITM."]}),!o&&(0,a.jsx)("p",{className:"text-amber-600 text-[10px] mt-1",children:"⚠️ Enable DNS to edit model mappings"})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2 items-start",children:[(0,a.jsx)(eR,{dnsActive:o,loading:f,serverRunning:n,onClick:V}),y&&(0,a.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded text-xs text-amber-500",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"warning"}),(0,a.jsx)("span",{children:y})]}),v&&(0,a.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded text-xs bg-red-500/10 text-red-600",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"error"}),(0,a.jsx)("span",{children:v})]})]}),e.defaultModels?.length>0&&(0,a.jsx)(Y,{tool:e,mappings:K,strategy:B,dnsActive:o,hasActiveProviders:x,onChangeEntry:P,onBlurEntry:T,onOpenSelector:q,onAddEntry:t=>O(t,`${e.id}/model-id`),onRemoveEntry:I,onReorderEntry:U,onChangeStrategy:D,feedback:L}),e.defaultModels?.length===0&&(0,a.jsx)("p",{className:"text-xs text-text-muted px-1",children:"Model mappings will be available soon."})]})]}),w&&(0,a.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:(0,a.jsxs)("div",{className:"mx-4 flex w-full max-w-sm flex-col gap-4 rounded-xl border border-border bg-surface p-5 shadow-xl sm:p-6",children:[(0,a.jsx)("h3",{className:"font-semibold text-text-main",children:"Sudo Password Required"}),(0,a.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-yellow-500 text-[20px]",children:"warning"}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Required to modify /etc/hosts and flush DNS cache"})]}),(0,a.jsx)(r.pd,{type:"password",placeholder:"Enter sudo password",value:C,onChange:e=>_(e.target.value),onKeyDown:e=>{"Enter"!==e.key||f||es()}}),E&&(0,a.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded text-xs bg-red-500/10 text-red-600",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"error"}),(0,a.jsx)("span",{children:E})]}),(0,a.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,a.jsx)(r.$n,{variant:"ghost",size:"sm",onClick:()=>{k(!1),_(""),$(null)},disabled:f,children:"Cancel"}),(0,a.jsx)(r.$n,{variant:"primary",size:"sm",onClick:es,loading:f,children:"Confirm"})]})]})}),(0,a.jsx)(r.rq,{isOpen:F,onClose:()=>H(!1),onSelect:R,selectedModel:M?K[M]?.[0]:null,activeProviders:m,modelAliases:u,title:`Add mapped model for ${M}`})]})}function eR({dnsActive:e,loading:t,serverRunning:s,onClick:l,compact:r=!1}){let i=e?"Stop DNS":"Start DNS";return(0,a.jsxs)("button",{type:"button",onClick:l,disabled:!s||t,className:`${r?"px-2.5 py-1.5":"px-4 py-1.5"} rounded-lg border font-medium text-xs flex items-center gap-1.5 transition-colors disabled:opacity-50 disabled:cursor-not-allowed ${e?"bg-red-500/10 border-red-500/30 text-red-500 hover:bg-red-500/20":"bg-primary/10 border-primary/30 text-primary hover:bg-primary/20"}`,title:s?i:"MITM server is not running",children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[16px] ${t?"animate-spin":""}`,children:t?"progress_activity":e?"stop_circle":"play_circle"}),(0,a.jsx)("span",{className:r?"hidden sm:inline":"",children:t?"Working...":i})]})}let eI=[{id:"antigravity-app",route:"/api/antigravity-app",label:"Close AGYv1",title:"Close Antigravity AGY processes",stoppedTitle:"Antigravity AGY is stopped"},{id:"antigravity-app-v2",route:"/api/antigravity-app-v2",label:"Close AGYv2",title:"Close Antigravity AGYv2 processes",stoppedTitle:"Antigravity AGYv2 is stopped"},{id:"antigravity-ide",route:"/api/antigravity-ide",label:"Close AGY-IDE",title:"Close Antigravity IDE processes",stoppedTitle:"Antigravity IDE is stopped"}];function eU({compact:e=!1}){return(0,a.jsx)("div",{className:`flex flex-wrap items-center gap-2 ${e?"":"px-1"}`,children:eI.map(t=>(0,a.jsx)(eD,{target:t,compact:e},t.id))})}function eD({target:e,compact:t=!1}){let[s,r]=(0,l.useState)(null),[i,n]=(0,l.useState)(!1),[o,d]=(0,l.useState)(null),c=(0,l.useCallback)(async({signal:t}={})=>{try{let s=await fetch(e.route,{signal:t});s.ok&&r(await s.json())}catch(e){if(e?.name==="AbortError")return}},[e.route]);(0,l.useEffect)(()=>{let e=new AbortController,t=window.setTimeout(()=>{c({signal:e.signal})},0),s=window.setInterval(()=>{c({signal:e.signal})},5e3);return()=>{e.abort(),window.clearTimeout(t),window.clearInterval(s)}},[c]);let m=async()=>{n(!0),d(null);try{let t=await fetch(e.route,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"close"})}),s=await t.json();d(s),setTimeout(c,1e3)}catch(e){d({success:!1,error:e.message})}n(!1)};return s?.installed?(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)("button",{type:"button",onClick:m,disabled:i||!s.running,className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs font-medium border border-red-500/30 text-red-500 bg-red-500/5 hover:bg-red-500/15 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:s.running?e.title:e.stoppedTitle,children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[14px] ${i?"animate-spin":""}`,children:i?"progress_activity":"close"}),(0,a.jsx)("span",{className:t?"hidden sm:inline":"",children:i?"Closing...":e.label})]}),s&&(0,a.jsxs)("span",{className:"flex items-center gap-1 text-[10px] text-text-muted whitespace-nowrap",children:[(0,a.jsx)("span",{className:`inline-block w-1.5 h-1.5 rounded-full ${s.running?"bg-green-500":"bg-red-400"}`}),(0,a.jsx)("span",{className:t?"hidden xl:inline":"",children:s.running?"Running":"Stopped"})]}),o&&!i&&!t&&(0,a.jsxs)("span",{className:`text-[10px] ${o.success?"text-green-500":"text-red-400"}`,children:[o.success?"✓":"✗"," ",o.message||o.error]})]}):null}var ez=s(98500),eL=s.n(ez),eF=s(11017),eK=s(57294);let eq=[{family:"Claude",session:["claude_gpt_session","claude"],weekly:["claude_gpt_weekly"]},{family:"Gemini",session:["gemini_session","gemini"],weekly:["gemini_weekly"]}];function eB(e){return e?void 0!==e.remainingPercentage?Math.round(e.remainingPercentage):e.total>0?Math.round((e.total-e.used)/e.total*100):null:null}function eH(e){if(!e||"string"!=typeof e)return e;let t=e.indexOf("@");if(t<=0||t===e.length-1)return e;let s=e.slice(0,t),a=e.slice(t+1);return 1===s.length?`${s[0]}**@${a}`:2===s.length?`${s[0]}**${s[1]}@${a}`:`${s[0]}**${s[s.length-1]}@${a}`}function eW(e,t=Date.now()){if(!e)return null;let s=[];e.rateLimitedUntil&&s.push({type:"account",until:e.rateLimitedUntil}),Object.entries(e).forEach(([e,t])=>{e.startsWith("modelLock_")&&t&&s.push({type:"model",until:t})});let a=s.map(e=>({...e,untilMs:new Date(e.until).getTime()})).filter(e=>Number.isFinite(e.untilMs)&&e.untilMs>t).sort((e,t)=>e.untilMs-t.untilMs)[0];if(!a)return null;let l=function(e,t=Date.now()){let s=e-t;if(!Number.isFinite(s)||s<=0)return null;let a=Math.ceil(s/1e3),l=Math.floor(a/3600),r=Math.floor(a%3600/60),i=a%60,n=[];return l&&n.push(`${l}h`),(r||l)&&n.push(`${r}m`),!l&&i&&n.push(`${i}s`),0===n.length&&n.push("0s"),n.join(" ")}(a.untilMs,t);return l?{duration:l,title:`${"model"===a.type?"Model":"Account"} cooldown until ${new Date(a.untilMs).toLocaleString()}`}:null}function eG({tool:e,connections:t=[],serverRunning:s,dnsActive:i,onToggle:n,onRefreshConnections:o}){let[d,c]=(0,l.useState)(!1),[m,x]=(0,l.useState)(!1),[u,p]=(0,l.useState)("round-robin"),[h,g]=(0,l.useState)(!1),[f,b]=(0,l.useState)(!1),[y,j]=(0,l.useState)(!1),[v,N]=(0,l.useState)(3),[w,k]=(0,l.useState)({}),[C,_]=(0,l.useState)(new Set),[S,A]=(0,l.useState)(new Set),[E,$]=(0,l.useState)(!1),[M,O]=(0,l.useState)({}),T=(0,l.useRef)({}),P=(0,l.useRef)(null),R=(0,l.useRef)({}),[I,U]=(0,l.useState)({}),[D,z]=(0,l.useState)(Date.now()),L=(0,l.useCallback)(async()=>{try{let e=await fetch("/api/settings");if(e.ok){let t=await e.json();c(!!t.tokenSwapEnabled),p(t.tokenSwapStrategy||"round-robin"),b(!!t.tokenSwapMaskEmails),N(t.antigravity503RetryCount??3)}}catch{}},[]);(0,l.useEffect)(()=>{L()},[L]),(0,l.useEffect)(()=>{k(e=>{let s={...e};return t.forEach(e=>{e.id in s||(s[e.id]=null!=e.antigravity503RetryCount?String(e.antigravity503RetryCount):"")}),s})},[t]);let F=(0,l.useCallback)(async()=>{try{let e=await fetch("/api/internal/account-health");if(!e.ok)return;let t=await e.json();U(t.accounts||{})}catch{}},[]),K=(0,l.useCallback)(async(t,s=!1)=>{if(!t||0===t.length)return;let a=Date.now(),l=[],r={};if(t.forEach(e=>{let t=T.current[e.id];!s&&t&&a-t.ts<12e4?r[e.id]={quotas:t.data,error:t.error,loading:!1,accountType:t.accountType||null}:l.push(e)}),Object.keys(r).length>0&&O(e=>({...e,...r})),0===l.length)return;let i={};l.forEach(e=>{i[e.id]={quotas:[],error:null,loading:!0}}),O(e=>({...e,...i})),await Promise.all(l.map(async t=>{try{let s=await fetch(`/api/usage/${t.id}`);if(!s.ok){let e=(await s.json().catch(()=>({}))).error||`HTTP ${s.status}`;T.current[t.id]={data:[],error:e,ts:Date.now(),accountType:null},O(s=>({...s,[t.id]:{quotas:[],error:e,loading:!1,accountType:null}}));return}let a=await s.json(),l=(0,eK.W_)(e.tokenSwapProvider||"antigravity",a),r=(0,eF._P)(a);T.current[t.id]={data:l,error:null,ts:Date.now(),accountType:r},O(e=>({...e,[t.id]:{quotas:l,error:null,loading:!1,accountType:r}}))}catch(s){let e=s.message||"Failed";T.current[t.id]={data:[],error:e,ts:Date.now(),accountType:null},O(s=>({...s,[t.id]:{quotas:[],error:e,loading:!1,accountType:null}}))}}))},[e.tokenSwapProvider]);if(!e?.supportsTokenSwap)return null;let q=async()=>{x(!0);let e=!d;try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tokenSwapEnabled:e})})).ok&&(c(e),n?.(e))}catch{}x(!1)},B=async e=>{if(e!==u&&!h){g(!0);try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tokenSwapStrategy:e})})).ok&&p(e)}catch{}g(!1)}},H=async()=>{if(y)return;j(!0);let e=!f;try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tokenSwapMaskEmails:e})})).ok&&b(e)}catch{}j(!1)},W=t.filter(t=>t.provider===e.tokenSwapProvider),G=W.filter(e=>!1!==e.isActive),J=G.length,Y=W.map(e=>e.id).join("|"),V=W.map(e=>{let t=Object.entries(e).filter(([e,t])=>e.startsWith("modelLock_")&&t).map(([e,t])=>`${e}:${t}`).sort().join(",");return`${e.id}:${e.rateLimitedUntil||""}:${t}`}).join("|"),Z=function(e,t){if(!e||0===e.length)return null;if(1===e.length)return e[0].id;let s=[...e].sort((e,t)=>e.lastUsedAt||t.lastUsedAt?e.lastUsedAt?t.lastUsedAt?new Date(t.lastUsedAt)-new Date(e.lastUsedAt):-1:1:(e.priority||999)-(t.priority||999));if("sticky"===t)return s[0]?.id||null;let a=[...e].sort((e,t)=>e.lastUsedAt||t.lastUsedAt?e.lastUsedAt?t.lastUsedAt?new Date(e.lastUsedAt)-new Date(t.lastUsedAt):1:-1:(e.priority||999)-(t.priority||999));return a[0]?.id||null}(G,u);(0,l.useEffect)(()=>{if(!W.some(e=>eW(e)))return;let e=setInterval(()=>z(Date.now()),1e3);return()=>clearInterval(e)},[V]),(0,l.useEffect)(()=>{d&&W.length>0&&K(W)},[d,W.length,Y,K]),(0,l.useEffect)(()=>{if(!d||0===J)return;F();let e=setInterval(F,1e4);return()=>clearInterval(e)},[d,J,F]);let Q=s&&i,X=d&&Q&&J>0,ee=async(e,t)=>{if(!(!e||C.has(e))){_(t=>new Set([...t,e]));try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&await o?.()}catch{}_(t=>{let s=new Set(t);return s.delete(e),s})}},et=async e=>{!e?.id||S.has(e.id)||E||C.has(e.id)||(A(t=>new Set([...t,e.id])),delete T.current[e.id],await K([e],!0),A(t=>{let s=new Set(t);return s.delete(e.id),s}))},es=async()=>{E||S.size>0||0===W.length||($(!0),W.forEach(e=>{delete T.current[e.id]}),await K(W,!0),$(!1))},ea=async e=>{let t=Math.max(0,Math.min(20,isNaN(e)?3:e));N(t),P.current&&clearTimeout(P.current),P.current=setTimeout(async()=>{try{await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({antigravity503RetryCount:t})})}catch{}},500)},el=(e,t)=>{if(t)k(t=>({...t,[e]:""})),R.current[e]&&clearTimeout(R.current[e]),fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({antigravity503RetryCount:null})}).catch(()=>{});else{let t=String(v);k(s=>({...s,[e]:t})),fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({antigravity503RetryCount:v})}).catch(()=>{})}};return(0,a.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0 rounded-lg bg-violet-500/10",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-violet-400 text-[18px]",children:"swap_horiz"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:"Token Rotation"}),(0,a.jsx)("span",{className:"text-[9px] uppercase tracking-wider text-text-muted bg-surface border border-border px-1.5 py-0.5 rounded font-semibold",children:"Mode B"}),X?(0,a.jsx)(r.Ex,{variant:"success",size:"sm",children:"Active"}):d?(0,a.jsx)(r.Ex,{variant:"warning",size:"sm",children:"Enabled"}):(0,a.jsx)(r.Ex,{variant:"default",size:"sm",children:"Off"})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Rotate auth tokens across pool accounts to bypass per-account quota"})]})]}),(0,a.jsx)("button",{onClick:q,disabled:m,className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors shrink-0 ${d?"bg-violet-500":"bg-surface-alt border border-border"} ${m?"opacity-50":"cursor-pointer"}`,title:d?"Disable Token Rotation":"Enable Token Rotation",children:(0,a.jsx)("span",{className:`inline-block h-3.5 w-3.5 transform rounded-full bg-white transition-transform shadow-sm ${d?"translate-x-4":"translate-x-0.5"}`})})]}),d&&(0,a.jsxs)("div",{className:"mt-3 pt-3 border-t border-border/50 flex flex-col gap-3",children:[(0,a.jsxs)("div",{className:"flex items-start gap-2 px-2 py-2 rounded-lg bg-violet-500/5 border border-violet-500/15",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] text-violet-400 mt-0.5 shrink-0",children:"info"}),(0,a.jsxs)("div",{className:"text-[11px] text-text-muted leading-relaxed",children:[(0,a.jsx)("p",{children:"Intercepts Antigravity requests → swaps IDE's auth token with a pool account → auto-retries on 429 quota error with next account in pool."}),(0,a.jsx)("p",{className:"mt-1 text-violet-400/80 font-medium",children:"⚠ When active, Model Routing (Mode A) is bypassed."})]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1.5 px-1",children:[(0,a.jsx)("p",{className:"text-[10px] uppercase tracking-wider text-text-muted font-semibold",children:"Rotation Strategy"}),(0,a.jsxs)("div",{className:"flex gap-1.5",children:[(0,a.jsxs)("button",{onClick:()=>B("round-robin"),disabled:h,className:`flex-1 flex flex-col items-center gap-0.5 px-2 py-2 rounded-lg border text-[11px] font-medium transition-colors ${"round-robin"===u?"border-violet-500/50 bg-violet-500/10 text-violet-400":"border-border bg-surface text-text-muted hover:border-border-alt"} disabled:opacity-50`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"autorenew"}),"Round Robin"]}),(0,a.jsxs)("button",{onClick:()=>B("sticky"),disabled:h,className:`flex-1 flex flex-col items-center gap-0.5 px-2 py-2 rounded-lg border text-[11px] font-medium transition-colors ${"sticky"===u?"border-violet-500/50 bg-violet-500/10 text-violet-400":"border-border bg-surface text-text-muted hover:border-border-alt"} disabled:opacity-50`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"push_pin"}),"Sticky"]})]}),(0,a.jsx)("p",{className:"text-[10px] text-text-muted px-0.5",children:"sticky"===u?"Stays on the same account until its quota is exhausted for the requested model, then switches. Optimizes session-level token cache.":"Chooses the least recently used eligible account first. Each successful request updates that account's last-used time."})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1 px-1",children:[(0,a.jsx)("p",{className:"text-[10px] uppercase tracking-wider text-text-muted font-semibold mb-0.5",children:"Prerequisites"}),(0,a.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[14px] ${s?"text-green-500":"text-red-400"}`,children:s?"check_circle":"cancel"}),(0,a.jsx)("span",{className:s?"text-text-main":"text-text-muted",children:"MITM Server"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[14px] ${i?"text-green-500":"text-red-400"}`,children:i?"check_circle":"cancel"}),(0,a.jsxs)("span",{className:i?"text-text-main":"text-text-muted",children:["DNS redirect",!i&&(0,a.jsx)("span",{className:"text-[10px] text-text-muted ml-1",children:"— enable via Antigravity card above"})]})]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1 px-1",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-0.5",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("p",{className:"text-[10px] uppercase tracking-wider text-text-muted font-semibold",children:"Pool Accounts"}),(0,a.jsx)("span",{className:"text-[10px] text-text-muted",children:W.length>0?`${J}/${W.length} active`:"none"}),J>1&&(0,a.jsx)("span",{className:"text-[9px] text-text-muted bg-surface border border-border px-1 py-0.5 rounded",children:"round-robin"})]}),W.length>0&&(0,a.jsxs)("button",{onClick:es,disabled:E||S.size>0,className:"inline-flex items-center gap-1 rounded-md border border-border bg-surface px-2 py-1 text-[10px] font-medium text-text-main hover:border-border-alt hover:bg-surface-alt disabled:opacity-50 disabled:cursor-not-allowed transition-colors",title:"Refresh quotas for all pool accounts, including disabled accounts",children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[12px] ${E?"animate-spin":""}`,children:"refresh"}),E?"Refreshing…":"Refresh All"]})]}),(0,a.jsx)("p",{className:"text-[10px] text-text-muted px-0.5",children:"Round robin uses least-recently-used ordering. Accounts with no usage timestamp are tried first, then older timestamps rotate ahead of newer ones."}),(0,a.jsxs)("div",{className:"flex items-center gap-2 px-1.5 py-1.5 rounded-lg border border-border bg-surface-alt/40",children:[(0,a.jsxs)("button",{onClick:H,disabled:y,title:`${f?"Disable":"Enable"} email masking — hides pool account emails in logs and this panel (e.g. ${eH("email@gmail.com")})`,className:`flex items-center gap-1.5 flex-1 min-w-0 px-1.5 py-1 rounded-md transition-colors text-left ${y?"opacity-50":"hover:bg-surface-alt cursor-pointer"}`,children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[13px] shrink-0 ${f?"text-violet-400":"text-text-muted"}`,children:"alternate_email"}),(0,a.jsx)("span",{className:`text-[11px] font-medium truncate ${f?"text-violet-300":"text-text-muted"}`,children:"Mask emails"}),(0,a.jsx)("span",{className:`relative inline-flex h-4 w-7 items-center rounded-full transition-colors shrink-0 ml-auto ${f?"bg-violet-500":"bg-surface-alt border border-border"}`,children:(0,a.jsx)("span",{className:`inline-block h-2.5 w-2.5 transform rounded-full bg-white transition-transform shadow-sm ${f?"translate-x-3.5":"translate-x-0.5"}`})})]}),(0,a.jsx)("div",{className:"w-px h-5 bg-border shrink-0"}),(0,a.jsxs)("div",{className:"flex items-center gap-1.5 shrink-0",title:'Global 503 retry count (0–20). Retry "high traffic" errors on same account before switching. Each account row can override this.',children:[(0,a.jsx)("span",{className:"text-[11px] text-text-muted whitespace-nowrap",children:"503 retries"}),(0,a.jsx)("input",{type:"number",min:"0",max:"20",step:"1",value:v,onChange:e=>ea(parseInt(e.target.value)),className:"w-10 rounded border border-border bg-surface px-1 py-0.5 text-[11px] text-text-main text-center focus:outline-none focus:border-violet-500 transition-colors",title:"Global 503 retry count (0-20). Each account can override this."})]})]}),W.length>0?(0,a.jsxs)(a.Fragment,{children:[W.map(e=>{let t,s,l=(0,eF.fd)(M[e.id]?.accountType)||(0,eF.fd)(e.accountType)||null,i=eW(e,D);return(0,a.jsxs)("div",{className:`rounded-xl border border-border bg-surface-alt/30 px-3 py-2.5 transition-colors ${!1===e.isActive?"opacity-65":"hover:bg-surface-alt/50"}`,children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[14px] shrink-0 ${!1===e.isActive?"text-text-muted":"text-green-500"}`,children:!1===e.isActive?"pause_circle":"check_circle"}),(0,a.jsx)("span",{className:"text-xs font-medium text-text-main truncate",children:e.email?f?eH(e.email):e.email:e.name||e.id.slice(0,16)}),l&&(0,a.jsx)(r.Ex,{variant:"Ultra"===l?"warning":"Pro"===l?"primary":"Plus"===l?"success":"Free"===l?"info":"default",size:"sm",children:l}),Z===e.id&&!1!==e.isActive&&(0,a.jsx)("span",{className:"text-[9px] text-violet-300 bg-violet-500/10 border border-violet-500/20 px-1 py-0.5 rounded shrink-0",children:"next"}),(0,a.jsx)("span",{title:!1===e.isActive?"Disabled - excluded from token rotation.":"Included in token rotation.",children:(0,a.jsx)(r.Ex,{variant:!1===e.isActive?"default":"success",size:"sm",children:!1===e.isActive?"disabled":"active"})}),i&&(0,a.jsxs)("span",{className:"text-[9px] font-medium text-amber-300 bg-amber-500/10 border border-amber-500/20 px-1.5 py-0.5 rounded shrink-0",title:i.title,children:["cooldown ",i.duration]})]}),(0,a.jsxs)("div",{className:"mt-1 flex items-center gap-2 flex-wrap text-[10px] text-text-muted",children:[(0,a.jsxs)("span",{children:["Priority #",e.priority??"-"]}),e.lastUsedAt&&(0,a.jsxs)("span",{children:["Last used ",new Date(e.lastUsedAt).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})]}),null!=(t=w[e.id])&&""!==t?(0,a.jsxs)("span",{className:"inline-flex items-center gap-1 rounded bg-violet-500/10 border border-violet-500/20 px-1.5 py-0.5",title:`Custom 503 retry count for this account. Global default: ${v}. Auto-saves. Click ↩ to revert.`,children:[(0,a.jsx)("span",{className:"text-violet-300",children:"503:"}),(0,a.jsx)("input",{type:"number",min:"0",max:"20",step:"1",value:t,onChange:t=>{var s,a;return s=e.id,a=t.target.value,void(k(e=>({...e,[s]:a})),R.current[s]&&clearTimeout(R.current[s]),R.current[s]=setTimeout(async()=>{let e=""===a?null:Math.max(0,Math.min(20,parseInt(a)||0));try{await fetch(`/api/providers/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({antigravity503RetryCount:e})})}catch{}},500))},className:"w-8 rounded border-none bg-transparent text-[10px] text-center text-violet-200 focus:outline-none [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none",title:`Custom 503 retry count for this account (global: ${v}). Auto-saves as you type.`,autoFocus:!0}),(0,a.jsx)("button",{onClick:()=>el(e.id,!0),className:"text-violet-400/70 hover:text-text-muted transition-colors leading-none",title:`Revert to global default (${v})`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[11px]",children:"undo"})})]}):(0,a.jsxs)("button",{onClick:()=>el(e.id,!1),className:"inline-flex items-center gap-0.5 rounded px-1.5 py-0.5 text-text-muted hover:bg-surface-alt hover:text-text-main transition-colors",title:`Using global 503 retry count (${v}). Click to set a custom value for this account only.`,children:[(0,a.jsxs)("span",{children:["503: ",v]}),(0,a.jsx)("span",{className:"text-[10px] opacity-60 leading-none",children:"✎"})]})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-3 shrink-0",children:[(0,a.jsxs)("button",{onClick:()=>et(e),disabled:S.has(e.id)||C.has(e.id),className:"inline-flex items-center gap-1 rounded-md border border-border bg-surface px-2 py-1 text-[10px] font-medium text-text-main hover:border-border-alt hover:bg-surface-alt disabled:opacity-50 disabled:cursor-not-allowed transition-colors",title:"Force-refresh quota for this account",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"refresh"}),S.has(e.id)?"…":"Refresh Quota"]}),(0,a.jsx)(r.lM,{size:"sm",checked:!1!==e.isActive,disabled:S.has(e.id)||C.has(e.id),onChange:t=>ee(e.id,t)})]})]}),(0,a.jsxs)("div",{className:"mt-2 pl-6",children:[(s=(e=>{let t=M[e];if(!t)return{state:"empty"};if(t.loading)return{state:"loading"};if(t.error)return{state:"error",error:t.error};if(!t.quotas||0===t.quotas.length)return{state:"no-data"};let s=function(e=[]){let t=new Map(e.map(e=>[e.modelKey,e])),s=e=>e.map(e=>t.get(e)).find(Boolean)||null;return eq.map(({family:e,session:t,weekly:a})=>({family:e,rows:[{window:"5h",quota:s(t)},{window:"Wk",quota:s(a)}]}))}(t.quotas);return s.some(({rows:e})=>e.some(({quota:e})=>null!==eB(e)))?{state:"ready",families:s}:{state:"no-data"}})(e.id))&&"empty"!==s.state?"loading"===s.state?(0,a.jsx)("span",{className:"text-[10px] text-text-muted animate-pulse",children:"Loading quota…"}):"error"===s.state?(0,a.jsx)("span",{className:"text-[10px] text-red-400",title:s.error,children:"Quota unavailable"}):"no-data"===s.state?(0,a.jsx)("span",{className:"text-[10px] text-text-muted",children:"No quota data"}):(0,a.jsx)("div",{className:"grid grid-cols-1 gap-x-4 gap-y-0.5 sm:grid-cols-2 min-w-0",children:s.families.map(({family:e,rows:t})=>(0,a.jsx)("div",{className:"grid grid-cols-[3.75rem_1fr_2.25rem_3.25rem] items-center gap-x-2 min-w-0",children:t.map(({window:t,quota:s})=>{let l=eB(s),r=s?.resetAt&&new Date(s.resetAt).getTime()>Date.now()?s.resetAt:null,i=s?[s.name,s.total>0&&`${s.used.toLocaleString()} / ${s.total.toLocaleString()} used`,r&&`resets ${(0,eK.sQ)(r)}`].filter(Boolean).join(" \xb7 "):`No ${e} ${t} quota for this account`;return(0,a.jsxs)("div",{className:"contents",title:i,children:[(0,a.jsxs)("span",{className:`text-[10px] truncate ${null===l?"text-text-muted/50":"text-text-muted"}`,children:[e," ",t]}),(0,a.jsx)("div",{className:"h-1 rounded-full bg-border/60 overflow-hidden",children:null!==l&&(0,a.jsx)("div",{className:`h-full rounded-full ${l>70?"bg-green-500":l>=30?"bg-yellow-500":"bg-red-500"}`,style:{width:`${Math.min(l,100)}%`}})}),(0,a.jsx)("span",{className:`text-[10px] font-medium text-right tabular-nums ${null===l?"text-text-muted/50":l>70?"text-green-500":l>=30?"text-yellow-500":"text-red-500"}`,children:null===l?"—":`${l}%`}),(0,a.jsx)("span",{className:"text-[9px] text-text-muted/70 tabular-nums truncate",children:r?`↺ ${(0,eK.mO)(r).split(" ").slice(0,2).join(" ")}`:""})]},t)})},e))}):(0,a.jsx)("span",{className:"text-[10px] text-text-muted",children:"Enable to load quota data"}),(e=>{let t=I[e];if(!t||0===t.length)return null;let s=t.filter(e=>"success"===e.status).length,l=t.filter(e=>"retry_success"===e.status).length,r=t.filter(e=>"fail"===e.status).length;return(0,a.jsxs)("div",{className:"mt-1.5",children:[(0,a.jsx)("div",{className:"flex flex-wrap gap-[2px]",title:`Last ${t.length} call${1!==t.length?"s":""}${s?` \xb7 ${s} ok`:""}${l?` \xb7 ${l} retry`:""}${r?` \xb7 ${r} fail`:""}`,children:t.map((e,t)=>{var s;let l,r,i,n,o=(s=e.ts,l=new Date,(r=new Date(s)).getFullYear()===l.getFullYear()&&r.getMonth()===l.getMonth()&&r.getDate()===l.getDate()),d="success"===e.status?"#22c55e":"fail"===e.status?"#ef4444":e.attempts<=2?"#fb923c":e.attempts<=3?"#f97316":"#ea580c";return(0,a.jsx)("div",{className:`shrink-0 rounded-[1px]${o?" animate-pulse":""}`,style:{width:o?"7px":"6px",height:o?"7px":"6px",backgroundColor:d,opacity:o?1:.45,boxShadow:o?`0 0 5px 1px ${d}`:void 0},title:(i=new Date(e.ts).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"}),n=Number(e.attempts)||1,"success"===e.status?`${i} — ✅ Success`:"fail"===e.status?`${i} — ❌ Failed`:`${i} — 🔄 Success after ${n} attempt${1!==n?"s":""}`)},t)})}),(0,a.jsxs)("div",{className:"flex items-center gap-2 mt-0.5",children:[(0,a.jsxs)("span",{className:"text-[9px] text-text-muted",children:["last ",t.length," call",1!==t.length?"s":""]}),s>0&&(0,a.jsxs)("span",{className:"text-[9px] text-green-500",children:[s," ok"]}),l>0&&(0,a.jsxs)("span",{className:"text-[9px] text-orange-400",children:[l," retry"]}),r>0&&(0,a.jsxs)("span",{className:"text-[9px] text-red-400",children:[r," fail"]})]})]})})(e.email||e.id)]})]},e.id)}),(0,a.jsxs)(eL(),{href:"/dashboard/providers",className:"text-[11px] text-primary hover:underline flex items-center gap-1 px-1 mt-1",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"open_in_new"}),"Manage accounts"]})]}):(0,a.jsx)("div",{className:"px-1",children:(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["No active ",e.name," accounts in pool."," ",(0,a.jsx)(eL(),{href:"/dashboard/providers",className:"text-primary hover:underline",children:"Add account →"})]})})]}),!Q&&(0,a.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded text-xs bg-amber-500/10 text-amber-600 border border-amber-500/20",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"warning"}),(0,a.jsx)("span",{children:"Start MITM server and enable DNS to activate token rotation"})]})]})]})}function eJ({tool:e}){return(0,a.jsx)(eL(),{href:"/dashboard/mitm",className:"block",children:(0,a.jsx)(r.Zp,{padding:"sm",className:"overflow-hidden hover:border-primary/50 transition-colors cursor-pointer",children:(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(i.A,{src:e.image,alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-purple-500/10 text-purple-600 dark:text-purple-400 rounded-full",children:"MITM"})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[20px]",children:"chevron_right"})]})})})}},40295:e=>{e.exports={TOOL_HOSTS:{antigravity:["daily-cloudcode-pa.googleapis.com","cloudcode-pa.googleapis.com"],copilot:["api.individual.githubcopilot.com"],kiro:["runtime.us-east-1.kiro.dev","q.us-east-1.amazonaws.com","codewhisperer.us-east-1.amazonaws.com"],cursor:["api2.cursor.sh"]}}}}]);
|
|
132
|
+
model = "${a}"`}];default:return[]}})()})]})}let eM="http://localhost:20128";function eO({apiKeys:e,cloudEnabled:t,onStatusChange:s}){let[i,n]=(0,l.useState)(null),[o,d]=(0,l.useState)(!1),[c,m]=(0,l.useState)(!1),[x,u]=(0,l.useState)(""),[p,h]=(0,l.useState)(()=>e?.[0]?.key||""),[g,f]=(0,l.useState)(null),[b,y]=(0,l.useState)(null),[j,v]=(0,l.useState)(null),[N,w]=(0,l.useState)(eM),[k,C]=(0,l.useState)(null),S=i?.isWin===!0,_=S||i?.hasCachedPassword||i?.needsSudoPassword===!1,A=i?.isAdmin!==!1;!A&&(S||i?.hasCachedPassword||i?.needsSudoPassword);let E=(0,l.useCallback)(async()=>{try{let e=await fetch("/api/cli-tools/antigravity-mitm"),t=await e.json().catch(()=>({}));if(!e.ok){let s=t.error||`Unable to load MITM status (HTTP ${e.status}).`,a=401===e.status||403===e.status?" Refresh the page or sign in again to restore local MITM access.":"";n(null),v(`${s}${a}`);return}v(null),n(t),t.mitmRouterBaseUrl&&w(t.mitmRouterBaseUrl),s?.(t)}catch(e){n(null),v(e?.message||"Unable to reach the MITM status endpoint.")}},[s]);(0,l.useEffect)(()=>{queueMicrotask(()=>{E()})},[E]);let $=e=>{v(null),i&&(_?M(e,""):(f(e),m(!0),y(null)))},M=async(s,a,l=!1)=>{d(!0),v(null);try{let r;if("trust-cert"===s)r=await fetch("/api/cli-tools/antigravity-mitm",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"trust-cert",sudoPassword:a})});else if("start"===s){let s=p?.trim()||(e?.length>0?e[0].key:null)||(t?null:"sk_9router");r=await fetch("/api/cli-tools/antigravity-mitm",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:s,sudoPassword:a,mitmRouterBaseUrl:N.trim()||eM,forceKillPort443:l})})}else r=await fetch("/api/cli-tools/antigravity-mitm",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({sudoPassword:a})});if(!r.ok){let e=await r.json().catch(()=>({}));if("PORT_443_BUSY"===e.code&&e.portOwner){m(!1),C({owner:e.portOwner,password:a});return}v(e.error||`Failed to ${s} MITM server`);return}m(!1),u(""),C(null),await E()}catch(e){v(e.message||"Network error")}finally{d(!1),f(null)}},O=()=>{x?M(g,x):y("Sudo password is required")},T=i?.running;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.Zp,{padding:"sm",className:"border-primary/20 bg-primary/5",children:(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-primary text-[20px]",children:"security"}),(0,a.jsx)("span",{className:"font-semibold text-sm text-text-main",children:"MITM Server"}),T?(0,a.jsx)(r.Ex,{variant:"success",size:"sm",children:"Running"}):(0,a.jsx)(r.Ex,{variant:"default",size:"sm",children:"Stopped"})]}),(0,a.jsx)("div",{className:"flex flex-wrap items-center gap-1 text-xs text-text-muted","data-i18n-skip":"true",children:[{label:"Cert",ok:i?.certExists},{label:"Trusted",ok:i?.certTrusted},{label:"Server",ok:T}].map(({label:e,ok:t})=>(0,a.jsxs)("span",{className:`flex items-center gap-0.5 px-1.5 py-0.5 rounded ${t?"text-green-600":"text-text-muted"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:t?"check_circle":"cancel"}),e]},e))})]}),(0,a.jsxs)("div",{className:"px-2 py-2 rounded-lg bg-surface/50 border border-border/50 flex flex-col gap-2",children:[(0,a.jsxs)("p",{className:"text-[11px] text-text-muted leading-relaxed",children:[(0,a.jsx)("span",{className:"font-medium text-text-main",children:"Purpose:"})," Use Antigravity IDE & GitHub Copilot → with ANY provider/model from 9Router"]}),(0,a.jsxs)("p",{className:"text-[11px] text-text-muted leading-relaxed",children:[(0,a.jsx)("span",{className:"font-medium text-text-main",children:"How it works:"})," Antigravity/Copilot IDE request → DNS redirect to localhost:443 → MITM proxy intercepts → 9Router → response to Antigravity/Copilot"]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"grid gap-1 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"9Router Base URL"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)("input",{type:"text",value:N,onChange:e=>w(e.target.value),placeholder:eM,disabled:T,className:"flex-1 min-w-0 px-2 py-1.5 bg-surface rounded border border-border text-xs text-text-main focus:outline-none focus:ring-1 focus:ring-primary/50 disabled:opacity-50"})]}),!T&&(0,a.jsxs)("div",{className:"grid gap-1 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)("input",{type:"text",list:"mitm-api-keys",value:p,onChange:e=>h(e.target.value),placeholder:t?"Enter or pick API key":"sk_9router (default)",className:"flex-1 min-w-0 px-2 py-1.5 bg-surface rounded border border-border text-xs text-text-main focus:outline-none focus:ring-1 focus:ring-primary/50"}),e?.length>0&&(0,a.jsx)("datalist",{id:"mitm-api-keys",children:e.map(e=>(0,a.jsx)("option",{value:e.key,children:e.name||e.key},e.id))})]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:flex-wrap sm:items-center","data-i18n-skip":"true",children:[i?.certExists&&!i?.certTrusted&&(0,a.jsxs)("button",{onClick:()=>$("trust-cert"),disabled:o,className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-yellow-500/30 bg-yellow-500/10 px-4 py-2 text-xs font-medium text-yellow-600 transition-colors hover:bg-yellow-500/20 disabled:opacity-50 sm:w-auto sm:py-1.5",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"verified_user"}),"Trust Cert"]}),T?(0,a.jsxs)("button",{onClick:()=>$("stop"),disabled:o,className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-red-500/30 bg-red-500/10 px-4 py-2 text-xs font-medium text-red-500 transition-colors hover:bg-red-500/20 disabled:opacity-50 sm:w-auto sm:py-1.5",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"stop_circle"}),"Stop Server"]}):(0,a.jsxs)("button",{onClick:()=>$("start"),disabled:o||!i||S&&!A,title:S&&!A?"Administrator required":void 0,className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-primary/30 bg-primary/10 px-4 py-2 text-xs font-medium text-primary transition-colors hover:bg-primary/20 disabled:opacity-50 sm:w-auto sm:py-1.5",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"play_circle"}),"Start Server"]}),T&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Enable DNS per tool below to activate interception"})]}),j&&(0,a.jsxs)("div",{className:"flex items-start gap-2 px-2 py-1.5 rounded text-xs bg-red-500/10 text-red-600 dark:text-red-400 border border-red-500/20",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] mt-0.5 shrink-0",children:"error"}),(0,a.jsx)("span",{children:j})]}),S&&!A&&(0,a.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded text-xs bg-red-500/10 text-red-600 border border-red-500/20",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"shield_lock"}),(0,a.jsx)("span",{children:"Administrator required — restart 9Router as Administrator to use MITM"})]})]})}),c&&(0,a.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:(0,a.jsxs)("div",{className:"mx-4 flex w-full max-w-sm flex-col gap-4 rounded-xl border border-border bg-surface p-5 shadow-xl sm:p-6",children:[(0,a.jsx)("h3",{className:"font-semibold text-text-main",children:"Sudo Password Required"}),(0,a.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-yellow-500 text-[20px]",children:"warning"}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Required for SSL certificate and server startup"})]}),(0,a.jsx)(r.pd,{type:"password",placeholder:"Enter sudo password",value:x,onChange:e=>u(e.target.value),onKeyDown:e=>{"Enter"!==e.key||o||O()}}),b&&(0,a.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded text-xs bg-red-500/10 text-red-600",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"error"}),(0,a.jsx)("span",{children:b})]}),(0,a.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,a.jsx)(r.$n,{variant:"ghost",size:"sm",onClick:()=>{m(!1),u(""),y(null)},disabled:o,children:"Cancel"}),(0,a.jsx)(r.$n,{variant:"primary",size:"sm",onClick:O,loading:o,children:"Confirm"})]})]})}),k&&(0,a.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:(0,a.jsxs)("div",{className:"mx-4 flex w-full max-w-md flex-col gap-4 rounded-xl border border-border bg-surface p-5 shadow-xl sm:p-6",children:[(0,a.jsx)("h3",{className:"font-semibold text-text-main",children:"Port 443 Already In Use"}),(0,a.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-yellow-500 text-[20px]",children:"warning"}),(0,a.jsxs)("div",{className:"flex flex-col gap-1 text-xs text-text-muted",children:[(0,a.jsx)("p",{children:"Port 443 is currently used by another process:"}),(0,a.jsxs)("p",{className:"font-mono text-text-main","data-i18n-skip":"true",children:[k.owner.name," (PID ",k.owner.pid,")"]}),(0,a.jsx)("p",{children:"Kill this process to start MITM Server?"})]})]}),(0,a.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,a.jsx)(r.$n,{variant:"ghost",size:"sm",onClick:()=>{C(null),d(!1)},disabled:o,children:"Cancel"}),(0,a.jsx)(r.$n,{variant:"primary",size:"sm",onClick:()=>{M("start",k?.password||"",!0)},loading:o,children:"Kill & Start"})]})]})})]})}var eT=s(40295);function eP({tool:e,isExpanded:t,onToggle:s,serverRunning:n,dnsActive:o,hasCachedPassword:d,apiKeys:c,activeProviders:m,hasActiveProviders:x,modelAliases:u={},cloudEnabled:p,onDnsChange:h,tokenSwapActive:g=!1}){let[f,b]=(0,l.useState)(!1),[y,j]=(0,l.useState)(null),[v,N]=(0,l.useState)(null),[w,k]=(0,l.useState)(!1),[C,S]=(0,l.useState)(""),[_,A]=(0,l.useState)(null),[E,$]=(0,l.useState)(null),{currentEditingAlias:M,handleAddMapping:O,handleMappingBlur:T,handleModelMappingChange:P,handleModelSelect:R,handleRemoveMapping:I,handleReorderMapping:U,handleStrategyChange:D,loadSavedMappings:z,mappingFeedback:L,modalOpen:F,modelMappings:K,openModelSelector:q,selectedStrategy:B,setModalOpen:H}=function(e){let[t,s]=(0,l.useState)({}),[a,r]=(0,l.useState)("round-robin"),[i,n]=(0,l.useState)(!1),[o,d]=(0,l.useState)(null),[c,m]=(0,l.useState)(null),[x,u]=(0,l.useState)(null),p=(0,l.useCallback)(async()=>{try{let t=await fetch(`/api/cli-tools/antigravity-mitm/alias?tool=${e}`);if(!t.ok)return;let a=await t.json();s(Z(a.aliases)),r(ee(a.strategy))}catch{}},[e]),h=(0,l.useCallback)(async(t,s)=>{try{await fetch("/api/cli-tools/antigravity-mitm/alias",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:e,mappings:Z(t),strategy:ee(s)})})}catch{}},[e]),g=(0,l.useCallback)((e,t=null)=>{d(e),m(t),n(!0)},[]),f=(0,l.useCallback)((e,t="")=>{s(s=>Q(s,e,t))},[]),b=(0,l.useCallback)((e,t,a)=>{s(s=>X(s,e,t,a))},[]),y=(0,l.useCallback)((e,t,l)=>{s(s=>{let r=Array.isArray(s?.[e])?s[e].length:0,i=function(e,t,s,a){let l=Array.isArray(e?.[t])?[...e[t]]:[];if(s<0||s>=l.length)return e;let r=l.slice(0,s),i=l.slice(s+1),n=Math.max(0,5-r.length-i.length),o=[...r,...String(a||"").split(",").map(e=>e.trim()).filter(Boolean).slice(0,n),...i].slice(0,5);if(0===o.length){let{[t]:s,...a}=e||{};return a}return{...e,[t]:o}}(s,e,t,l),n=Array.isArray(i?.[e])?i[e].length:0,o=String(l||"").split(",").map(e=>e.trim()).filter(Boolean).length;return o>1||n<r?u(n<r?`Max 5 targets per alias. Extra models were ignored for ${e}.`:`Expanded ${o} targets for ${e}.`):u(null),h(i,a),i})},[h,a]),j=(0,l.useCallback)((e,t)=>{s(s=>{let l=function(e,t,s){let a=(Array.isArray(e?.[t])?e[t]:[]).filter((e,t)=>t!==s);if(0===a.length){let{[t]:s,...a}=e||{};return a}return{...e,[t]:a}}(s,e,t);return h(l,a),l})},[h,a]),v=(0,l.useCallback)((e,t,l)=>{s(s=>{let r=function(e,t,s,a){let l=Array.isArray(e?.[t])?[...e[t]]:[];if(s<0||a<0||s>=l.length||a>=l.length||s===a)return e;let[r]=l.splice(s,1);return l.splice(a,0,r),{...e,[t]:l}}(s,e,t,l);return h(r,a),r})},[h,a]),N=(0,l.useCallback)(e=>{o&&!e.isPlaceholder&&(s(t=>{let s=null===c?Q(t,o,e.value):X(t,o,c,e.value),l=Array.isArray(t?.[o])?t[o].length:0,r=Array.isArray(s?.[o])?s[o].length:0;return u(null===c&&r===l?`Max 5 targets per alias. Remove one before adding another for ${o}.`:null),h(s,a),s}),n(!1),m(null))},[o,c,h,a]);return{currentEditingAlias:o,currentEditingIndex:c,handleAddMapping:f,handleMappingBlur:y,handleModelMappingChange:b,handleModelSelect:N,handleRemoveMapping:j,handleReorderMapping:v,handleStrategyChange:(0,l.useCallback)(e=>{let t=ee(e);r(t),s(e=>(h(e,t),e))},[h]),loadSavedMappings:p,mappingFeedback:x,modalOpen:i,modelMappings:t,openModelSelector:g,selectedStrategy:a,setCurrentEditingIndex:m,setMappingFeedback:u,setModalOpen:n}}(e.id),W=eT.TOOL_HOSTS[e.id]??[],G="u">typeof navigator&&navigator.userAgent?.includes("Windows"),J="antigravity"===e.id&&!t;(0,l.useEffect)(()=>{t&&z()},[t,z]);let V=()=>{if(!n)return;let e=o?"disable":"enable";G||d?et(e,""):(A(e),k(!0),$(null))},et=async(t,s)=>{b(!0),j(null),N(null);try{let a=await fetch("/api/cli-tools/antigravity-mitm",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:e.id,action:t,sudoPassword:s})}),l=await a.json().catch(()=>({}));if(!a.ok)throw Error(l.error||`Failed to ${t} DNS`);"enable"===t&&j(`Restart ${e.name} to apply changes`),k(!1),S(""),h?.(l)}catch(e){N(e.message||`Failed to ${t} DNS`)}finally{b(!1),A(null)}},es=()=>{C?et(_,C):$("Sudo password is required")};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3 hover:cursor-pointer",onClick:s,children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(i.A,{src:e.image,alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"}})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),e.supportsTokenSwap&&(0,a.jsx)("span",{className:"text-[9px] uppercase tracking-wider text-text-muted bg-surface border border-border px-1.5 py-0.5 rounded font-semibold",children:"Mode A"}),n?g?(0,a.jsx)(r.Ex,{variant:"default",size:"sm",children:"Bypassed"}):o?(0,a.jsx)(r.Ex,{variant:"success",size:"sm",children:"Active"}):(0,a.jsx)(r.Ex,{variant:"warning",size:"sm",children:"DNS off"}):(0,a.jsx)(r.Ex,{variant:"default",size:"sm",children:"Server off"})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Model routing — remap model IDs in intercepted requests"})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[J&&(0,a.jsxs)("div",{className:"flex items-center gap-2",onClick:e=>e.stopPropagation(),children:[(0,a.jsx)(eU,{compact:!0}),(0,a.jsx)(eR,{dnsActive:o,loading:f,serverRunning:n,onClick:V,compact:!0})]}),(0,a.jsx)("span",{className:`material-symbols-outlined text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]})]}),t&&(0,a.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[g&&(0,a.jsxs)("div",{className:"flex items-start gap-2 px-2 py-2 rounded-lg bg-violet-500/5 border border-violet-500/15",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] text-violet-400 mt-0.5 shrink-0",children:"info"}),(0,a.jsx)("p",{className:"text-[11px] text-violet-400",children:"Token Rotation (Mode B) is active — model routing is currently bypassed. Disable Token Rotation to use model routing."})]}),"antigravity"===e.id&&(0,a.jsx)(eU,{}),W.length>0&&(0,a.jsxs)("div",{className:"mt-2 rounded-md border border-border bg-surface/50 px-2 py-1.5",children:[(0,a.jsx)("p",{className:"text-[10px] font-medium tracking-wide text-text-main/80 mb-1",children:"Edit hosts file manually to add the following entries:"}),(0,a.jsx)("ul",{className:"list-none space-y-0.5 font-mono text-[10px] text-text-muted break-all",children:W.map(e=>(0,a.jsxs)("li",{children:["127.0.0.1 ",e]},e))})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-0.5 text-[11px] text-text-muted px-1",children:[(0,a.jsxs)("p",{children:["Toggle DNS to redirect ",e.name," traffic through 9Router via MITM."]}),!o&&(0,a.jsx)("p",{className:"text-amber-600 text-[10px] mt-1",children:"⚠️ Enable DNS to edit model mappings"})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2 items-start",children:[(0,a.jsx)(eR,{dnsActive:o,loading:f,serverRunning:n,onClick:V}),y&&(0,a.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded text-xs text-amber-500",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"warning"}),(0,a.jsx)("span",{children:y})]}),v&&(0,a.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded text-xs bg-red-500/10 text-red-600",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"error"}),(0,a.jsx)("span",{children:v})]})]}),e.defaultModels?.length>0&&(0,a.jsx)(Y,{tool:e,mappings:K,strategy:B,dnsActive:o,hasActiveProviders:x,onChangeEntry:P,onBlurEntry:T,onOpenSelector:q,onAddEntry:t=>O(t,`${e.id}/model-id`),onRemoveEntry:I,onReorderEntry:U,onChangeStrategy:D,feedback:L}),e.defaultModels?.length===0&&(0,a.jsx)("p",{className:"text-xs text-text-muted px-1",children:"Model mappings will be available soon."})]})]}),w&&(0,a.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:(0,a.jsxs)("div",{className:"mx-4 flex w-full max-w-sm flex-col gap-4 rounded-xl border border-border bg-surface p-5 shadow-xl sm:p-6",children:[(0,a.jsx)("h3",{className:"font-semibold text-text-main",children:"Sudo Password Required"}),(0,a.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-yellow-500 text-[20px]",children:"warning"}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Required to modify /etc/hosts and flush DNS cache"})]}),(0,a.jsx)(r.pd,{type:"password",placeholder:"Enter sudo password",value:C,onChange:e=>S(e.target.value),onKeyDown:e=>{"Enter"!==e.key||f||es()}}),E&&(0,a.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded text-xs bg-red-500/10 text-red-600",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"error"}),(0,a.jsx)("span",{children:E})]}),(0,a.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,a.jsx)(r.$n,{variant:"ghost",size:"sm",onClick:()=>{k(!1),S(""),$(null)},disabled:f,children:"Cancel"}),(0,a.jsx)(r.$n,{variant:"primary",size:"sm",onClick:es,loading:f,children:"Confirm"})]})]})}),(0,a.jsx)(r.rq,{isOpen:F,onClose:()=>H(!1),onSelect:R,selectedModel:M?K[M]?.[0]:null,activeProviders:m,modelAliases:u,title:`Add mapped model for ${M}`})]})}function eR({dnsActive:e,loading:t,serverRunning:s,onClick:l,compact:r=!1}){let i=e?"Stop DNS":"Start DNS";return(0,a.jsxs)("button",{type:"button",onClick:l,disabled:!s||t,className:`${r?"px-2.5 py-1.5":"px-4 py-1.5"} rounded-lg border font-medium text-xs flex items-center gap-1.5 transition-colors disabled:opacity-50 disabled:cursor-not-allowed ${e?"bg-red-500/10 border-red-500/30 text-red-500 hover:bg-red-500/20":"bg-primary/10 border-primary/30 text-primary hover:bg-primary/20"}`,title:s?i:"MITM server is not running",children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[16px] ${t?"animate-spin":""}`,children:t?"progress_activity":e?"stop_circle":"play_circle"}),(0,a.jsx)("span",{className:r?"hidden sm:inline":"",children:t?"Working...":i})]})}let eI=[{id:"antigravity-app",route:"/api/antigravity-app",label:"Close AGYv1",title:"Close Antigravity AGY processes",stoppedTitle:"Antigravity AGY is stopped"},{id:"antigravity-app-v2",route:"/api/antigravity-app-v2",label:"Close AGYv2",title:"Close Antigravity AGYv2 processes",stoppedTitle:"Antigravity AGYv2 is stopped"},{id:"antigravity-ide",route:"/api/antigravity-ide",label:"Close AGY-IDE",title:"Close Antigravity IDE processes",stoppedTitle:"Antigravity IDE is stopped"}];function eU({compact:e=!1}){return(0,a.jsx)("div",{className:`flex flex-wrap items-center gap-2 ${e?"":"px-1"}`,children:eI.map(t=>(0,a.jsx)(eD,{target:t,compact:e},t.id))})}function eD({target:e,compact:t=!1}){let[s,r]=(0,l.useState)(null),[i,n]=(0,l.useState)(!1),[o,d]=(0,l.useState)(null),c=(0,l.useCallback)(async({signal:t}={})=>{try{let s=await fetch(e.route,{signal:t});s.ok&&r(await s.json())}catch(e){if(e?.name==="AbortError")return}},[e.route]);(0,l.useEffect)(()=>{let e=new AbortController,t=window.setTimeout(()=>{c({signal:e.signal})},0),s=window.setInterval(()=>{c({signal:e.signal})},5e3);return()=>{e.abort(),window.clearTimeout(t),window.clearInterval(s)}},[c]);let m=async()=>{n(!0),d(null);try{let t=await fetch(e.route,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"close"})}),s=await t.json();d(s),setTimeout(c,1e3)}catch(e){d({success:!1,error:e.message})}n(!1)};return s?.installed?(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)("button",{type:"button",onClick:m,disabled:i||!s.running,className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs font-medium border border-red-500/30 text-red-500 bg-red-500/5 hover:bg-red-500/15 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:s.running?e.title:e.stoppedTitle,children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[14px] ${i?"animate-spin":""}`,children:i?"progress_activity":"close"}),(0,a.jsx)("span",{className:t?"hidden sm:inline":"",children:i?"Closing...":e.label})]}),s&&(0,a.jsxs)("span",{className:"flex items-center gap-1 text-[10px] text-text-muted whitespace-nowrap",children:[(0,a.jsx)("span",{className:`inline-block w-1.5 h-1.5 rounded-full ${s.running?"bg-green-500":"bg-red-400"}`}),(0,a.jsx)("span",{className:t?"hidden xl:inline":"",children:s.running?"Running":"Stopped"})]}),o&&!i&&!t&&(0,a.jsxs)("span",{className:`text-[10px] ${o.success?"text-green-500":"text-red-400"}`,children:[o.success?"✓":"✗"," ",o.message||o.error]})]}):null}var ez=s(98500),eL=s.n(ez),eF=s(11017),eK=s(57294);let eq=[{family:"Claude",session:["claude_gpt_session","claude"],weekly:["claude_gpt_weekly"]},{family:"Gemini",session:["gemini_session","gemini"],weekly:["gemini_weekly"]}];var eB=s(89386);function eH(e){return e?void 0!==e.remainingPercentage?Math.round(e.remainingPercentage):e.total>0?Math.round((e.total-e.used)/e.total*100):null:null}function eW(e){if(!e||"string"!=typeof e)return e;let t=e.indexOf("@");if(t<=0||t===e.length-1)return e;let s=e.slice(0,t),a=e.slice(t+1);return 1===s.length?`${s[0]}**@${a}`:2===s.length?`${s[0]}**${s[1]}@${a}`:`${s[0]}**${s[s.length-1]}@${a}`}function eG(e,t=Date.now()){if(!e)return null;let s=[];e.rateLimitedUntil&&s.push({type:"account",until:e.rateLimitedUntil}),Object.entries(e).forEach(([e,t])=>{e.startsWith("modelLock_")&&t&&s.push({type:"model",until:t})});let a=s.map(e=>({...e,untilMs:new Date(e.until).getTime()})).filter(e=>Number.isFinite(e.untilMs)&&e.untilMs>t).sort((e,t)=>e.untilMs-t.untilMs)[0];if(!a)return null;let l=function(e,t=Date.now()){let s=e-t;if(!Number.isFinite(s)||s<=0)return null;let a=Math.ceil(s/1e3),l=Math.floor(a/3600),r=Math.floor(a%3600/60),i=a%60,n=[];return l&&n.push(`${l}h`),(r||l)&&n.push(`${r}m`),!l&&i&&n.push(`${i}s`),0===n.length&&n.push("0s"),n.join(" ")}(a.untilMs,t);return l?{duration:l,title:`${"model"===a.type?"Model":"Account"} cooldown until ${new Date(a.untilMs).toLocaleString()}`}:null}function eJ({tool:e,connections:t=[],serverRunning:s,dnsActive:i,onToggle:n,onRefreshConnections:o}){let[d,c]=(0,l.useState)(!1),[m,x]=(0,l.useState)(!1),[u,p]=(0,l.useState)("round-robin"),[h,g]=(0,l.useState)(!1),[f,b]=(0,l.useState)(!1),[y,j]=(0,l.useState)(!1),[v,N]=(0,l.useState)(3),[w,k]=(0,l.useState)({}),[C,S]=(0,l.useState)(new Set),[_,A]=(0,l.useState)(new Set),[E,$]=(0,l.useState)(!1),[M,O]=(0,l.useState)({}),T=(0,l.useRef)({}),P=(0,l.useRef)(null),R=(0,l.useRef)({}),[I,U]=(0,l.useState)({}),[D,z]=(0,l.useState)(Date.now()),L=(0,l.useCallback)(async()=>{try{let e=await fetch("/api/settings");if(e.ok){let t=await e.json();c(!!t.tokenSwapEnabled),p(t.tokenSwapStrategy||"round-robin"),b(!!t.tokenSwapMaskEmails),N(t.antigravity503RetryCount??3)}}catch{}},[]);(0,l.useEffect)(()=>{L()},[L]),(0,l.useEffect)(()=>{k(e=>{let s={...e};return t.forEach(e=>{e.id in s||(s[e.id]=null!=e.antigravity503RetryCount?String(e.antigravity503RetryCount):"")}),s})},[t]);let F=(0,l.useCallback)(async()=>{try{let e=await fetch("/api/internal/account-health");if(!e.ok)return;let t=await e.json();U(t.accounts||{})}catch{}},[]),K=(0,l.useCallback)(async(t,s=!1)=>{if(!t||0===t.length)return;let a=Date.now(),l=[],r={};if(t.forEach(e=>{let t=T.current[e.id];!s&&t&&a-t.ts<12e4?r[e.id]={quotas:t.data,error:t.error,loading:!1,accountType:t.accountType||null}:l.push(e)}),Object.keys(r).length>0&&O(e=>({...e,...r})),0===l.length)return;let i={};l.forEach(e=>{i[e.id]={quotas:[],error:null,loading:!0}}),O(e=>({...e,...i})),await Promise.all(l.map(async t=>{try{let s=await fetch(`/api/usage/${t.id}`);if(!s.ok){let e=(await s.json().catch(()=>({}))).error||`HTTP ${s.status}`;T.current[t.id]={data:[],error:e,ts:Date.now(),accountType:null},O(s=>({...s,[t.id]:{quotas:[],error:e,loading:!1,accountType:null}}));return}let a=await s.json(),l=(0,eK.W_)(e.tokenSwapProvider||"antigravity",a),r=(0,eF._P)(a);T.current[t.id]={data:l,error:null,ts:Date.now(),accountType:r},O(e=>({...e,[t.id]:{quotas:l,error:null,loading:!1,accountType:r}}))}catch(s){let e=s.message||"Failed";T.current[t.id]={data:[],error:e,ts:Date.now(),accountType:null},O(s=>({...s,[t.id]:{quotas:[],error:e,loading:!1,accountType:null}}))}}))},[e.tokenSwapProvider]);if(!e?.supportsTokenSwap)return null;let q=async()=>{x(!0);let e=!d;try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tokenSwapEnabled:e})})).ok&&(c(e),n?.(e))}catch{}x(!1)},B=async e=>{if(e!==u&&!h){g(!0);try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tokenSwapStrategy:e})})).ok&&p(e)}catch{}g(!1)}},H=async()=>{if(y)return;j(!0);let e=!f;try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tokenSwapMaskEmails:e})})).ok&&b(e)}catch{}j(!1)},W=t.filter(t=>t.provider===e.tokenSwapProvider),G=W.filter(e=>!1!==e.isActive),J=G.length,Y=W.map(e=>e.id).join("|"),V=W.map(e=>{let t=Object.entries(e).filter(([e,t])=>e.startsWith("modelLock_")&&t).map(([e,t])=>`${e}:${t}`).sort().join(",");return`${e.id}:${e.rateLimitedUntil||""}:${t}`}).join("|"),Z=function(e,t){if(!e||0===e.length)return null;if(1===e.length)return e[0].id;let s=[...e].sort((e,t)=>e.lastUsedAt||t.lastUsedAt?e.lastUsedAt?t.lastUsedAt?new Date(t.lastUsedAt)-new Date(e.lastUsedAt):-1:1:(e.priority||999)-(t.priority||999));if("sticky"===t)return s[0]?.id||null;let a=[...e].sort((e,t)=>e.lastUsedAt||t.lastUsedAt?e.lastUsedAt?t.lastUsedAt?new Date(e.lastUsedAt)-new Date(t.lastUsedAt):1:-1:(e.priority||999)-(t.priority||999));return a[0]?.id||null}(G,u);(0,l.useEffect)(()=>{if(!W.some(e=>eG(e)))return;let e=setInterval(()=>z(Date.now()),1e3);return()=>clearInterval(e)},[V]),(0,l.useEffect)(()=>{d&&W.length>0&&K(W)},[d,W.length,Y,K]),(0,l.useEffect)(()=>{if(!d||0===J)return;F();let e=setInterval(F,1e4);return()=>clearInterval(e)},[d,J,F]);let Q=s&&i,X=d&&Q&&J>0,ee=async(e,t)=>{if(!(!e||C.has(e))){S(t=>new Set([...t,e]));try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&await o?.()}catch{}S(t=>{let s=new Set(t);return s.delete(e),s})}},et=async e=>{!e?.id||_.has(e.id)||E||C.has(e.id)||(A(t=>new Set([...t,e.id])),delete T.current[e.id],await K([e],!0),A(t=>{let s=new Set(t);return s.delete(e.id),s}))},es=async()=>{E||_.size>0||0===W.length||($(!0),W.forEach(e=>{delete T.current[e.id]}),await K(W,!0),$(!1))},ea=async e=>{let t=Math.max(0,Math.min(20,isNaN(e)?3:e));N(t),P.current&&clearTimeout(P.current),P.current=setTimeout(async()=>{try{await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({antigravity503RetryCount:t})})}catch{}},500)},el=(e,t)=>{if(t)k(t=>({...t,[e]:""})),R.current[e]&&clearTimeout(R.current[e]),fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({antigravity503RetryCount:null})}).catch(()=>{});else{let t=String(v);k(s=>({...s,[e]:t})),fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({antigravity503RetryCount:v})}).catch(()=>{})}};return(0,a.jsxs)(r.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0 rounded-lg bg-violet-500/10",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-violet-400 text-[18px]",children:"swap_horiz"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:"Token Rotation"}),(0,a.jsx)("span",{className:"text-[9px] uppercase tracking-wider text-text-muted bg-surface border border-border px-1.5 py-0.5 rounded font-semibold",children:"Mode B"}),X?(0,a.jsx)(r.Ex,{variant:"success",size:"sm",children:"Active"}):d?(0,a.jsx)(r.Ex,{variant:"warning",size:"sm",children:"Enabled"}):(0,a.jsx)(r.Ex,{variant:"default",size:"sm",children:"Off"})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Rotate auth tokens across pool accounts to bypass per-account quota"})]})]}),(0,a.jsx)("button",{onClick:q,disabled:m,className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors shrink-0 ${d?"bg-violet-500":"bg-surface-alt border border-border"} ${m?"opacity-50":"cursor-pointer"}`,title:d?"Disable Token Rotation":"Enable Token Rotation",children:(0,a.jsx)("span",{className:`inline-block h-3.5 w-3.5 transform rounded-full bg-white transition-transform shadow-sm ${d?"translate-x-4":"translate-x-0.5"}`})})]}),d&&(0,a.jsxs)("div",{className:"mt-3 pt-3 border-t border-border/50 flex flex-col gap-3",children:[(0,a.jsxs)("div",{className:"flex items-start gap-2 px-2 py-2 rounded-lg bg-violet-500/5 border border-violet-500/15",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] text-violet-400 mt-0.5 shrink-0",children:"info"}),(0,a.jsxs)("div",{className:"text-[11px] text-text-muted leading-relaxed",children:[(0,a.jsx)("p",{children:"Intercepts Antigravity requests → swaps IDE's auth token with a pool account → auto-retries on 429 quota error with next account in pool."}),(0,a.jsx)("p",{className:"mt-1 text-violet-400/80 font-medium",children:"⚠ When active, Model Routing (Mode A) is bypassed."})]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1.5 px-1",children:[(0,a.jsx)("p",{className:"text-[10px] uppercase tracking-wider text-text-muted font-semibold",children:"Rotation Strategy"}),(0,a.jsxs)("div",{className:"flex gap-1.5",children:[(0,a.jsxs)("button",{onClick:()=>B("round-robin"),disabled:h,className:`flex-1 flex flex-col items-center gap-0.5 px-2 py-2 rounded-lg border text-[11px] font-medium transition-colors ${"round-robin"===u?"border-violet-500/50 bg-violet-500/10 text-violet-400":"border-border bg-surface text-text-muted hover:border-border-alt"} disabled:opacity-50`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"autorenew"}),"Round Robin"]}),(0,a.jsxs)("button",{onClick:()=>B("sticky"),disabled:h,className:`flex-1 flex flex-col items-center gap-0.5 px-2 py-2 rounded-lg border text-[11px] font-medium transition-colors ${"sticky"===u?"border-violet-500/50 bg-violet-500/10 text-violet-400":"border-border bg-surface text-text-muted hover:border-border-alt"} disabled:opacity-50`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"push_pin"}),"Sticky"]})]}),(0,a.jsx)("p",{className:"text-[10px] text-text-muted px-0.5",children:"sticky"===u?"Stays on the same account until its quota is exhausted for the requested model, then switches. Optimizes session-level token cache.":"Chooses the least recently used eligible account first. Each successful request updates that account's last-used time."})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1 px-1",children:[(0,a.jsx)("p",{className:"text-[10px] uppercase tracking-wider text-text-muted font-semibold mb-0.5",children:"Prerequisites"}),(0,a.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[14px] ${s?"text-green-500":"text-red-400"}`,children:s?"check_circle":"cancel"}),(0,a.jsx)("span",{className:s?"text-text-main":"text-text-muted",children:"MITM Server"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[14px] ${i?"text-green-500":"text-red-400"}`,children:i?"check_circle":"cancel"}),(0,a.jsxs)("span",{className:i?"text-text-main":"text-text-muted",children:["DNS redirect",!i&&(0,a.jsx)("span",{className:"text-[10px] text-text-muted ml-1",children:"— enable via Antigravity card above"})]})]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1 px-1",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-0.5",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("p",{className:"text-[10px] uppercase tracking-wider text-text-muted font-semibold",children:"Pool Accounts"}),(0,a.jsx)("span",{className:"text-[10px] text-text-muted",children:W.length>0?`${J}/${W.length} active`:"none"}),J>1&&(0,a.jsx)("span",{className:"text-[9px] text-text-muted bg-surface border border-border px-1 py-0.5 rounded",children:"round-robin"})]}),W.length>0&&(0,a.jsxs)("button",{onClick:es,disabled:E||_.size>0,className:"inline-flex items-center gap-1 rounded-md border border-border bg-surface px-2 py-1 text-[10px] font-medium text-text-main hover:border-border-alt hover:bg-surface-alt disabled:opacity-50 disabled:cursor-not-allowed transition-colors",title:"Refresh quotas for all pool accounts, including disabled accounts",children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[12px] ${E?"animate-spin":""}`,children:"refresh"}),E?"Refreshing…":"Refresh All"]})]}),(0,a.jsx)("p",{className:"text-[10px] text-text-muted px-0.5",children:"Round robin uses least-recently-used ordering. Accounts with no usage timestamp are tried first, then older timestamps rotate ahead of newer ones."}),(0,a.jsxs)("div",{className:"flex items-center gap-2 px-1.5 py-1.5 rounded-lg border border-border bg-surface-alt/40",children:[(0,a.jsxs)("button",{onClick:H,disabled:y,title:`${f?"Disable":"Enable"} email masking — hides pool account emails in logs and this panel (e.g. ${eW("email@gmail.com")})`,className:`flex items-center gap-1.5 flex-1 min-w-0 px-1.5 py-1 rounded-md transition-colors text-left ${y?"opacity-50":"hover:bg-surface-alt cursor-pointer"}`,children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[13px] shrink-0 ${f?"text-violet-400":"text-text-muted"}`,children:"alternate_email"}),(0,a.jsx)("span",{className:`text-[11px] font-medium truncate ${f?"text-violet-300":"text-text-muted"}`,children:"Mask emails"}),(0,a.jsx)("span",{className:`relative inline-flex h-4 w-7 items-center rounded-full transition-colors shrink-0 ml-auto ${f?"bg-violet-500":"bg-surface-alt border border-border"}`,children:(0,a.jsx)("span",{className:`inline-block h-2.5 w-2.5 transform rounded-full bg-white transition-transform shadow-sm ${f?"translate-x-3.5":"translate-x-0.5"}`})})]}),(0,a.jsx)("div",{className:"w-px h-5 bg-border shrink-0"}),(0,a.jsxs)("div",{className:"flex items-center gap-1.5 shrink-0",title:'Global 503 retry count (0–20). Retry "high traffic" errors on same account before switching. Each account row can override this.',children:[(0,a.jsx)("span",{className:"text-[11px] text-text-muted whitespace-nowrap",children:"503 retries"}),(0,a.jsx)("input",{type:"number",min:"0",max:"20",step:"1",value:v,onChange:e=>ea(parseInt(e.target.value)),className:"w-10 rounded border border-border bg-surface px-1 py-0.5 text-[11px] text-text-main text-center focus:outline-none focus:border-violet-500 transition-colors",title:"Global 503 retry count (0-20). Each account can override this."})]})]}),W.length>0?(0,a.jsxs)(a.Fragment,{children:[W.map(e=>{let t,s,l=(0,eF.fd)(M[e.id]?.accountType)||(0,eF.fd)(e.accountType)||null,i=eG(e,D),n=function(e,t=Date.now()){let s=(0,eB.getActiveUnsupportedModels)(e.unsupportedModels,t);if(0===s.length)return null;let a=s.map(e=>`${e.model} (until ${new Date(e.until).toLocaleString()})`);return{label:`${s.length} model${s.length>1?"s":""} unsupported`,title:`Token swap skips this account for:
|
|
133
|
+
${a.join("\n")}
|
|
134
|
+
Cleared after 24h, on a successful request, or when a quota refresh lists the model.`}}(e,D);return(0,a.jsxs)("div",{className:`rounded-xl border border-border bg-surface-alt/30 px-3 py-2.5 transition-colors ${!1===e.isActive?"opacity-65":"hover:bg-surface-alt/50"}`,children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[14px] shrink-0 ${!1===e.isActive?"text-text-muted":"text-green-500"}`,children:!1===e.isActive?"pause_circle":"check_circle"}),(0,a.jsx)("span",{className:"text-xs font-medium text-text-main truncate",children:e.email?f?eW(e.email):e.email:e.name||e.id.slice(0,16)}),l&&(0,a.jsx)(r.Ex,{variant:"Ultra"===l?"warning":"Pro"===l?"primary":"Plus"===l?"success":"Free"===l?"info":"default",size:"sm",children:l}),Z===e.id&&!1!==e.isActive&&(0,a.jsx)("span",{className:"text-[9px] text-violet-300 bg-violet-500/10 border border-violet-500/20 px-1 py-0.5 rounded shrink-0",children:"next"}),(0,a.jsx)("span",{title:!1===e.isActive?"Disabled - excluded from token rotation.":"Included in token rotation.",children:(0,a.jsx)(r.Ex,{variant:!1===e.isActive?"default":"success",size:"sm",children:!1===e.isActive?"disabled":"active"})}),i&&(0,a.jsxs)("span",{className:"text-[9px] font-medium text-amber-300 bg-amber-500/10 border border-amber-500/20 px-1.5 py-0.5 rounded shrink-0",title:i.title,children:["cooldown ",i.duration]})]}),(0,a.jsxs)("div",{className:"mt-1 flex items-center gap-2 flex-wrap text-[10px] text-text-muted",children:[(0,a.jsxs)("span",{children:["Priority #",e.priority??"-"]}),e.lastUsedAt&&(0,a.jsxs)("span",{children:["Last used ",new Date(e.lastUsedAt).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})]}),n&&(0,a.jsx)("span",{className:"cursor-help",title:n.title,children:n.label}),null!=(t=w[e.id])&&""!==t?(0,a.jsxs)("span",{className:"inline-flex items-center gap-1 rounded bg-violet-500/10 border border-violet-500/20 px-1.5 py-0.5",title:`Custom 503 retry count for this account. Global default: ${v}. Auto-saves. Click ↩ to revert.`,children:[(0,a.jsx)("span",{className:"text-violet-300",children:"503:"}),(0,a.jsx)("input",{type:"number",min:"0",max:"20",step:"1",value:t,onChange:t=>{var s,a;return s=e.id,a=t.target.value,void(k(e=>({...e,[s]:a})),R.current[s]&&clearTimeout(R.current[s]),R.current[s]=setTimeout(async()=>{let e=""===a?null:Math.max(0,Math.min(20,parseInt(a)||0));try{await fetch(`/api/providers/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({antigravity503RetryCount:e})})}catch{}},500))},className:"w-8 rounded border-none bg-transparent text-[10px] text-center text-violet-200 focus:outline-none [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none",title:`Custom 503 retry count for this account (global: ${v}). Auto-saves as you type.`,autoFocus:!0}),(0,a.jsx)("button",{onClick:()=>el(e.id,!0),className:"text-violet-400/70 hover:text-text-muted transition-colors leading-none",title:`Revert to global default (${v})`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[11px]",children:"undo"})})]}):(0,a.jsxs)("button",{onClick:()=>el(e.id,!1),className:"inline-flex items-center gap-0.5 rounded px-1.5 py-0.5 text-text-muted hover:bg-surface-alt hover:text-text-main transition-colors",title:`Using global 503 retry count (${v}). Click to set a custom value for this account only.`,children:[(0,a.jsxs)("span",{children:["503: ",v]}),(0,a.jsx)("span",{className:"text-[10px] opacity-60 leading-none",children:"✎"})]})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-3 shrink-0",children:[(0,a.jsxs)("button",{onClick:()=>et(e),disabled:_.has(e.id)||C.has(e.id),className:"inline-flex items-center gap-1 rounded-md border border-border bg-surface px-2 py-1 text-[10px] font-medium text-text-main hover:border-border-alt hover:bg-surface-alt disabled:opacity-50 disabled:cursor-not-allowed transition-colors",title:"Force-refresh quota for this account",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"refresh"}),_.has(e.id)?"…":"Refresh Quota"]}),(0,a.jsx)(r.lM,{size:"sm",checked:!1!==e.isActive,disabled:_.has(e.id)||C.has(e.id),onChange:t=>ee(e.id,t)})]})]}),(0,a.jsxs)("div",{className:"mt-2 pl-6",children:[(s=(e=>{let t=M[e];if(!t)return{state:"empty"};if(t.loading)return{state:"loading"};if(t.error)return{state:"error",error:t.error};if(!t.quotas||0===t.quotas.length)return{state:"no-data"};let s=function(e=[]){let t=new Map(e.map(e=>[e.modelKey,e])),s=e=>e.map(e=>t.get(e)).find(Boolean)||null;return eq.map(({family:e,session:t,weekly:a})=>({family:e,rows:[{window:"5h",quota:s(t)},{window:"Wk",quota:s(a)}]}))}(t.quotas);return s.some(({rows:e})=>e.some(({quota:e})=>null!==eH(e)))?{state:"ready",families:s}:{state:"no-data"}})(e.id))&&"empty"!==s.state?"loading"===s.state?(0,a.jsx)("span",{className:"text-[10px] text-text-muted animate-pulse",children:"Loading quota…"}):"error"===s.state?(0,a.jsx)("span",{className:"text-[10px] text-red-400",title:s.error,children:"Quota unavailable"}):"no-data"===s.state?(0,a.jsx)("span",{className:"text-[10px] text-text-muted",children:"No quota data"}):(0,a.jsx)("div",{className:"grid grid-cols-1 gap-x-4 gap-y-0.5 sm:grid-cols-2 min-w-0",children:s.families.map(({family:e,rows:t})=>(0,a.jsx)("div",{className:"grid grid-cols-[3.75rem_1fr_2.25rem_3.25rem] items-center gap-x-2 min-w-0",children:t.map(({window:t,quota:s})=>{let l=eH(s),r=s?.resetAt&&new Date(s.resetAt).getTime()>Date.now()?s.resetAt:null,i=s?[s.name,s.total>0&&`${s.used.toLocaleString()} / ${s.total.toLocaleString()} used`,r&&`resets ${(0,eK.sQ)(r)}`].filter(Boolean).join(" \xb7 "):`No ${e} ${t} quota for this account`;return(0,a.jsxs)("div",{className:"contents",title:i,children:[(0,a.jsxs)("span",{className:`text-[10px] truncate ${null===l?"text-text-muted/50":"text-text-muted"}`,children:[e," ",t]}),(0,a.jsx)("div",{className:"h-1 rounded-full bg-border/60 overflow-hidden",children:null!==l&&(0,a.jsx)("div",{className:`h-full rounded-full ${l>70?"bg-green-500":l>=30?"bg-yellow-500":"bg-red-500"}`,style:{width:`${Math.min(l,100)}%`}})}),(0,a.jsx)("span",{className:`text-[10px] font-medium text-right tabular-nums ${null===l?"text-text-muted/50":l>70?"text-green-500":l>=30?"text-yellow-500":"text-red-500"}`,children:null===l?"—":`${l}%`}),(0,a.jsx)("span",{className:"text-[9px] text-text-muted/70 tabular-nums truncate",children:r?`↺ ${(0,eK.mO)(r).split(" ").slice(0,2).join(" ")}`:""})]},t)})},e))}):(0,a.jsx)("span",{className:"text-[10px] text-text-muted",children:"Enable to load quota data"}),(e=>{let t=I[e];if(!t||0===t.length)return null;let s=t.filter(e=>"success"===e.status).length,l=t.filter(e=>"retry_success"===e.status).length,r=t.filter(e=>"fail"===e.status).length;return(0,a.jsxs)("div",{className:"mt-1.5",children:[(0,a.jsx)("div",{className:"flex flex-wrap gap-[2px]",title:`Last ${t.length} call${1!==t.length?"s":""}${s?` \xb7 ${s} ok`:""}${l?` \xb7 ${l} retry`:""}${r?` \xb7 ${r} fail`:""}`,children:t.map((e,t)=>{var s;let l,r,i,n,o=(s=e.ts,l=new Date,(r=new Date(s)).getFullYear()===l.getFullYear()&&r.getMonth()===l.getMonth()&&r.getDate()===l.getDate()),d="success"===e.status?"#22c55e":"fail"===e.status?"#ef4444":e.attempts<=2?"#fb923c":e.attempts<=3?"#f97316":"#ea580c";return(0,a.jsx)("div",{className:`shrink-0 rounded-[1px]${o?" animate-pulse":""}`,style:{width:o?"7px":"6px",height:o?"7px":"6px",backgroundColor:d,opacity:o?1:.45,boxShadow:o?`0 0 5px 1px ${d}`:void 0},title:(i=new Date(e.ts).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"}),n=Number(e.attempts)||1,"success"===e.status?`${i} — ✅ Success`:"fail"===e.status?`${i} — ❌ Failed`:`${i} — 🔄 Success after ${n} attempt${1!==n?"s":""}`)},t)})}),(0,a.jsxs)("div",{className:"flex items-center gap-2 mt-0.5",children:[(0,a.jsxs)("span",{className:"text-[9px] text-text-muted",children:["last ",t.length," call",1!==t.length?"s":""]}),s>0&&(0,a.jsxs)("span",{className:"text-[9px] text-green-500",children:[s," ok"]}),l>0&&(0,a.jsxs)("span",{className:"text-[9px] text-orange-400",children:[l," retry"]}),r>0&&(0,a.jsxs)("span",{className:"text-[9px] text-red-400",children:[r," fail"]})]})]})})(e.email||e.id)]})]},e.id)}),(0,a.jsxs)(eL(),{href:"/dashboard/providers",className:"text-[11px] text-primary hover:underline flex items-center gap-1 px-1 mt-1",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"open_in_new"}),"Manage accounts"]})]}):(0,a.jsx)("div",{className:"px-1",children:(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["No active ",e.name," accounts in pool."," ",(0,a.jsx)(eL(),{href:"/dashboard/providers",className:"text-primary hover:underline",children:"Add account →"})]})})]}),!Q&&(0,a.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded text-xs bg-amber-500/10 text-amber-600 border border-amber-500/20",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"warning"}),(0,a.jsx)("span",{children:"Start MITM server and enable DNS to activate token rotation"})]})]})]})}function eY({tool:e}){return(0,a.jsx)(eL(),{href:"/dashboard/mitm",className:"block",children:(0,a.jsx)(r.Zp,{padding:"sm",className:"overflow-hidden hover:border-primary/50 transition-colors cursor-pointer",children:(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(i.A,{src:e.image,alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),(0,a.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-purple-500/10 text-purple-600 dark:text-purple-400 rounded-full",children:"MITM"})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[20px]",children:"chevron_right"})]})})})}},40295:e=>{e.exports={TOOL_HOSTS:{antigravity:["daily-cloudcode-pa.googleapis.com","cloudcode-pa.googleapis.com"],copilot:["api.individual.githubcopilot.com"],kiro:["runtime.us-east-1.kiro.dev","q.us-east-1.amazonaws.com","codewhisperer.us-east-1.amazonaws.com"],cursor:["api2.cursor.sh"]}}},89386:e=>{function t(e,t){let s=new Date(e?.until).getTime();return Number.isFinite(s)&&s>t}function s(e,a=Date.now()){return e&&"object"==typeof e?Object.entries(e).filter(([,e])=>t(e,a)).map(([e,t])=>({model:e,since:t.since,until:t.until})).sort((e,t)=>e.model.localeCompare(t.model)):[]}e.exports={UNSUPPORTED_MODEL_TTL_MS:864e5,getActiveUnsupportedModels:s,isModelUnsupported:function(e,s,a=Date.now()){return!!s&&t(e?.unsupportedModels?.[s],a)},markUnsupported:function(e,t,a=Date.now()){let l={};for(let{model:t,since:r,until:i}of s(e,a))l[t]={since:r,until:i};return l[t]={since:new Date(a).toISOString(),until:new Date(a+864e5).toISOString()},l},removeModels:function(e,t){if(!e||"object"!=typeof e)return{changed:!1,map:null};let s={...e},a=!1;for(let e of t)e in s&&(delete s[e],a=!0);return a?{changed:!0,map:Object.keys(s).length>0?s:null}:{changed:!1,map:e}}}}}]);
|