@synthever/jrouter 1.0.0 → 1.0.2

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.
Files changed (378) hide show
  1. package/app/.next-cli-build/BUILD_ID +1 -1
  2. package/app/.next-cli-build/app-path-routes-manifest.json +14 -14
  3. package/app/.next-cli-build/build-manifest.json +2 -2
  4. package/app/.next-cli-build/prerender-manifest.json +2 -2
  5. package/app/.next-cli-build/server/app/(dashboard)/dashboard/basic-chat/page_client-reference-manifest.js +1 -1
  6. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page.js +1 -1
  7. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page_client-reference-manifest.js +1 -1
  8. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page.js +1 -1
  9. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
  10. package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
  11. package/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page_client-reference-manifest.js +1 -1
  12. package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page.js +1 -1
  13. package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
  14. package/app/.next-cli-build/server/app/(dashboard)/dashboard/health/page_client-reference-manifest.js +1 -1
  15. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page_client-reference-manifest.js +1 -1
  16. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page_client-reference-manifest.js +1 -1
  17. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page_client-reference-manifest.js +1 -1
  18. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page_client-reference-manifest.js +1 -1
  19. package/app/.next-cli-build/server/app/(dashboard)/dashboard/mitm/page_client-reference-manifest.js +1 -1
  20. package/app/.next-cli-build/server/app/(dashboard)/dashboard/page.js +1 -1
  21. package/app/.next-cli-build/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
  22. package/app/.next-cli-build/server/app/(dashboard)/dashboard/playground/page_client-reference-manifest.js +1 -1
  23. package/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page.js +1 -1
  24. package/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
  25. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
  26. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
  27. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
  28. package/app/.next-cli-build/server/app/(dashboard)/dashboard/proxy-pools/page_client-reference-manifest.js +1 -1
  29. package/app/.next-cli-build/server/app/(dashboard)/dashboard/pxpipe/page_client-reference-manifest.js +1 -1
  30. package/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page_client-reference-manifest.js +1 -1
  31. package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/page.js +1 -1
  32. package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/page_client-reference-manifest.js +1 -1
  33. package/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page.js +1 -1
  34. package/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page_client-reference-manifest.js +1 -1
  35. package/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
  36. package/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
  37. package/app/.next-cli-build/server/app/_global-error/page_client-reference-manifest.js +1 -1
  38. package/app/.next-cli-build/server/app/_global-error.html +1 -1
  39. package/app/.next-cli-build/server/app/_global-error.rsc +1 -1
  40. package/app/.next-cli-build/server/app/_global-error.segments/_full.segment.rsc +1 -1
  41. package/app/.next-cli-build/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  42. package/app/.next-cli-build/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  43. package/app/.next-cli-build/server/app/_not-found/page_client-reference-manifest.js +1 -1
  44. package/app/.next-cli-build/server/app/_not-found.html +1 -1
  45. package/app/.next-cli-build/server/app/_not-found.rsc +5 -5
  46. package/app/.next-cli-build/server/app/_not-found.segments/_full.segment.rsc +5 -5
  47. package/app/.next-cli-build/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +4 -4
  48. package/app/.next-cli-build/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  49. package/app/.next-cli-build/server/app/api/auth/login/route.js +1 -1
  50. package/app/.next-cli-build/server/app/api/auth/logout/route.js +1 -1
  51. package/app/.next-cli-build/server/app/api/auth/oidc/callback/route.js +1 -1
  52. package/app/.next-cli-build/server/app/api/auth/oidc/start/route.js +1 -1
  53. package/app/.next-cli-build/server/app/api/auth/oidc/test/route.js +1 -1
  54. package/app/.next-cli-build/server/app/api/auth/reset-password/route.js +1 -1
  55. package/app/.next-cli-build/server/app/api/auth/saml/acs/route.js +1 -1
  56. package/app/.next-cli-build/server/app/api/auth/saml/metadata/route.js +1 -1
  57. package/app/.next-cli-build/server/app/api/auth/saml/start/route.js +1 -1
  58. package/app/.next-cli-build/server/app/api/auth/saml/test/route.js +1 -1
  59. package/app/.next-cli-build/server/app/api/auth/status/route.js +1 -1
  60. package/app/.next-cli-build/server/app/api/cli-tools/all-statuses/route.js +9 -9
  61. package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/alias/route.js +1 -1
  62. package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/route.js +1 -1
  63. package/app/.next-cli-build/server/app/api/cli-tools/claude-settings/route.js +1 -1
  64. package/app/.next-cli-build/server/app/api/cli-tools/cline-settings/route.js +1 -1
  65. package/app/.next-cli-build/server/app/api/cli-tools/codewhale-settings/route.js +1 -1
  66. package/app/.next-cli-build/server/app/api/cli-tools/codex-profiles/route.js +1 -1
  67. package/app/.next-cli-build/server/app/api/cli-tools/codex-settings/route.js +1 -1
  68. package/app/.next-cli-build/server/app/api/cli-tools/copilot-settings/route.js +2 -2
  69. package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-registry/route.js +1 -1
  70. package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-tools/route.js +1 -1
  71. package/app/.next-cli-build/server/app/api/cli-tools/crush-settings/route.js +2 -2
  72. package/app/.next-cli-build/server/app/api/cli-tools/deepseek-tui-settings/route.js +3 -3
  73. package/app/.next-cli-build/server/app/api/cli-tools/droid-settings/route.js +1 -1
  74. package/app/.next-cli-build/server/app/api/cli-tools/forge-settings/route.js +1 -1
  75. package/app/.next-cli-build/server/app/api/cli-tools/grok-build-settings/route.js +5 -5
  76. package/app/.next-cli-build/server/app/api/cli-tools/hermes-profiles/route.js +2 -2
  77. package/app/.next-cli-build/server/app/api/cli-tools/jcode-settings/route.js +2 -2
  78. package/app/.next-cli-build/server/app/api/cli-tools/kilo-settings/route.js +1 -1
  79. package/app/.next-cli-build/server/app/api/cli-tools/omp-settings/route.js +3 -3
  80. package/app/.next-cli-build/server/app/api/cli-tools/openclaw-settings/route.js +1 -1
  81. package/app/.next-cli-build/server/app/api/cli-tools/opencode-settings/route.js +1 -1
  82. package/app/.next-cli-build/server/app/api/cli-tools/pi-settings/route.js +1 -1
  83. package/app/.next-cli-build/server/app/api/cli-tools/smelt-settings/route.js +1 -1
  84. package/app/.next-cli-build/server/app/api/combos/[id]/route.js +1 -1
  85. package/app/.next-cli-build/server/app/api/combos/presets/route.js +1 -1
  86. package/app/.next-cli-build/server/app/api/combos/route.js +1 -1
  87. package/app/.next-cli-build/server/app/api/headroom/proxy/[...path]/route.js +1 -1
  88. package/app/.next-cli-build/server/app/api/headroom/restart/route.js +1 -1
  89. package/app/.next-cli-build/server/app/api/headroom/start/route.js +1 -1
  90. package/app/.next-cli-build/server/app/api/keys/[id]/route.js +1 -1
  91. package/app/.next-cli-build/server/app/api/keys/[id]/secret/route.js +1 -1
  92. package/app/.next-cli-build/server/app/api/keys/route.js +1 -1
  93. package/app/.next-cli-build/server/app/api/mcp/[plugin]/message/route.js +2 -2
  94. package/app/.next-cli-build/server/app/api/mcp/[plugin]/sse/route.js +2 -2
  95. package/app/.next-cli-build/server/app/api/media-providers/tts/deepgram/voices/route.js +1 -1
  96. package/app/.next-cli-build/server/app/api/media-providers/tts/elevenlabs/voices/route.js +1 -1
  97. package/app/.next-cli-build/server/app/api/media-providers/tts/inworld/voices/route.js +1 -1
  98. package/app/.next-cli-build/server/app/api/media-providers/tts/minimax/voices/route.js +1 -1
  99. package/app/.next-cli-build/server/app/api/model-health/check/route.js +1 -1
  100. package/app/.next-cli-build/server/app/api/model-health/check-all/route.js +1 -1
  101. package/app/.next-cli-build/server/app/api/model-health/config/route.js +1 -1
  102. package/app/.next-cli-build/server/app/api/model-health/history/route.js +1 -1
  103. package/app/.next-cli-build/server/app/api/model-health/model/route.js +1 -1
  104. package/app/.next-cli-build/server/app/api/model-health/models/route.js +1 -1
  105. package/app/.next-cli-build/server/app/api/model-health/route.js +1 -1
  106. package/app/.next-cli-build/server/app/api/model-health/run-scheduled/route.js +1 -1
  107. package/app/.next-cli-build/server/app/api/model-health/summary/route.js +1 -1
  108. package/app/.next-cli-build/server/app/api/models/alias/route.js +1 -1
  109. package/app/.next-cli-build/server/app/api/models/availability/route.js +1 -1
  110. package/app/.next-cli-build/server/app/api/models/catalog-sync/route.js +1 -1
  111. package/app/.next-cli-build/server/app/api/models/custom/route.js +1 -1
  112. package/app/.next-cli-build/server/app/api/models/disabled/route.js +1 -1
  113. package/app/.next-cli-build/server/app/api/models/limits/route.js +1 -1
  114. package/app/.next-cli-build/server/app/api/models/route.js +1 -1
  115. package/app/.next-cli-build/server/app/api/oauth/[provider]/[action]/route.js +1 -1
  116. package/app/.next-cli-build/server/app/api/oauth/codex/bulk-import/route.js +1 -1
  117. package/app/.next-cli-build/server/app/api/oauth/codex/import-token/route.js +1 -1
  118. package/app/.next-cli-build/server/app/api/oauth/cursor/import/route.js +1 -1
  119. package/app/.next-cli-build/server/app/api/oauth/gitlab/pat/route.js +1 -1
  120. package/app/.next-cli-build/server/app/api/oauth/grok-cli/bulk-import/route.js +1 -1
  121. package/app/.next-cli-build/server/app/api/oauth/iflow/cookie/route.js +1 -1
  122. package/app/.next-cli-build/server/app/api/oauth/kiro/api-key/route.js +1 -1
  123. package/app/.next-cli-build/server/app/api/oauth/kiro/import/route.js +1 -1
  124. package/app/.next-cli-build/server/app/api/oauth/kiro/import-cli-proxy/route.js +1 -1
  125. package/app/.next-cli-build/server/app/api/oauth/kiro/social-exchange/route.js +1 -1
  126. package/app/.next-cli-build/server/app/api/oauth/xiaomi-mimo/api-key/route.js +1 -1
  127. package/app/.next-cli-build/server/app/api/oauth/xiaomi-mimo/auto-import/route.js +1 -1
  128. package/app/.next-cli-build/server/app/api/oauth/zed/import/route.js +1 -1
  129. package/app/.next-cli-build/server/app/api/pricing/route.js +1 -1
  130. package/app/.next-cli-build/server/app/api/provider-nodes/[id]/route.js +1 -1
  131. package/app/.next-cli-build/server/app/api/provider-nodes/route.js +1 -1
  132. package/app/.next-cli-build/server/app/api/provider-nodes/validate/route.js +1 -1
  133. package/app/.next-cli-build/server/app/api/providers/[id]/connections/keys/route.js +1 -1
  134. package/app/.next-cli-build/server/app/api/providers/[id]/models/route.js +1 -1
  135. package/app/.next-cli-build/server/app/api/providers/[id]/overrides/route.js +1 -1
  136. package/app/.next-cli-build/server/app/api/providers/[id]/route.js +1 -1
  137. package/app/.next-cli-build/server/app/api/providers/client/route.js +1 -1
  138. package/app/.next-cli-build/server/app/api/providers/route.js +1 -1
  139. package/app/.next-cli-build/server/app/api/providers/validate/route.js +1 -1
  140. package/app/.next-cli-build/server/app/api/proxy-pools/[id]/route.js +1 -1
  141. package/app/.next-cli-build/server/app/api/proxy-pools/[id]/test/route.js +1 -1
  142. package/app/.next-cli-build/server/app/api/proxy-pools/cloudflare-deploy/route.js +1 -1
  143. package/app/.next-cli-build/server/app/api/proxy-pools/deno-deploy/route.js +2 -2
  144. package/app/.next-cli-build/server/app/api/proxy-pools/netlify-deploy/route.js +4 -4
  145. package/app/.next-cli-build/server/app/api/proxy-pools/route.js +1 -1
  146. package/app/.next-cli-build/server/app/api/proxy-pools/vercel-deploy/route.js +1 -1
  147. package/app/.next-cli-build/server/app/api/pxpipe/health/route.js +1 -1
  148. package/app/.next-cli-build/server/app/api/pxpipe/install/route.js +1 -1
  149. package/app/.next-cli-build/server/app/api/pxpipe/logs/route.js +1 -1
  150. package/app/.next-cli-build/server/app/api/pxpipe/restart/route.js +1 -1
  151. package/app/.next-cli-build/server/app/api/pxpipe/start/route.js +1 -1
  152. package/app/.next-cli-build/server/app/api/pxpipe/stats/route.js +1 -1
  153. package/app/.next-cli-build/server/app/api/pxpipe/status/route.js +1 -1
  154. package/app/.next-cli-build/server/app/api/pxpipe/stop/route.js +1 -1
  155. package/app/.next-cli-build/server/app/api/settings/database/route.js +1 -1
  156. package/app/.next-cli-build/server/app/api/settings/proxy-test/route.js +1 -1
  157. package/app/.next-cli-build/server/app/api/settings/require-login/route.js +1 -1
  158. package/app/.next-cli-build/server/app/api/settings/route.js +1 -1
  159. package/app/.next-cli-build/server/app/api/translator/console-logs/route.js +1 -1
  160. package/app/.next-cli-build/server/app/api/translator/console-logs/stream/route.js +1 -1
  161. package/app/.next-cli-build/server/app/api/translator/send/route.js +1 -1
  162. package/app/.next-cli-build/server/app/api/translator/translate/route.js +1 -1
  163. package/app/.next-cli-build/server/app/api/usage/[connectionId]/claude-reset/route.js +1 -1
  164. package/app/.next-cli-build/server/app/api/usage/[connectionId]/codex-reset-credits/route.js +1 -1
  165. package/app/.next-cli-build/server/app/api/usage/[connectionId]/route.js +1 -1
  166. package/app/.next-cli-build/server/app/api/usage/chart/route.js +1 -1
  167. package/app/.next-cli-build/server/app/api/usage/history/route.js +1 -1
  168. package/app/.next-cli-build/server/app/api/usage/logs/route.js +1 -1
  169. package/app/.next-cli-build/server/app/api/usage/providers/route.js +1 -1
  170. package/app/.next-cli-build/server/app/api/usage/request-details/route.js +1 -1
  171. package/app/.next-cli-build/server/app/api/usage/request-logs/route.js +1 -1
  172. package/app/.next-cli-build/server/app/api/usage/stats/route.js +1 -1
  173. package/app/.next-cli-build/server/app/api/usage/stream/route.js +1 -1
  174. package/app/.next-cli-build/server/app/api/v1/audio/voices/route.js +1 -1
  175. package/app/.next-cli-build/server/app/api/v1/messages/count_tokens/route.js +1 -1
  176. package/app/.next-cli-build/server/app/api/v1/models/info/route.js +1 -1
  177. package/app/.next-cli-build/server/app/api/version/route.js +1 -1
  178. package/app/.next-cli-build/server/app/callback/page_client-reference-manifest.js +1 -1
  179. package/app/.next-cli-build/server/app/callback.html +1 -1
  180. package/app/.next-cli-build/server/app/callback.rsc +5 -5
  181. package/app/.next-cli-build/server/app/callback.segments/_full.segment.rsc +5 -5
  182. package/app/.next-cli-build/server/app/callback.segments/_tree.segment.rsc +1 -1
  183. package/app/.next-cli-build/server/app/callback.segments/callback/__PAGE__.segment.rsc +4 -4
  184. package/app/.next-cli-build/server/app/dashboard/basic-chat.html +1 -1
  185. package/app/.next-cli-build/server/app/dashboard/basic-chat.rsc +7 -7
  186. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard/basic-chat/__PAGE__.segment.rsc +6 -6
  187. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_full.segment.rsc +7 -7
  188. package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_tree.segment.rsc +1 -1
  189. package/app/.next-cli-build/server/app/dashboard/cli-tools.html +1 -1
  190. package/app/.next-cli-build/server/app/dashboard/cli-tools.rsc +7 -7
  191. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools/__PAGE__.segment.rsc +6 -6
  192. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_full.segment.rsc +7 -7
  193. package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_tree.segment.rsc +1 -1
  194. package/app/.next-cli-build/server/app/dashboard/combos.html +1 -1
  195. package/app/.next-cli-build/server/app/dashboard/combos.rsc +7 -7
  196. package/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos/__PAGE__.segment.rsc +6 -6
  197. package/app/.next-cli-build/server/app/dashboard/combos.segments/_full.segment.rsc +7 -7
  198. package/app/.next-cli-build/server/app/dashboard/combos.segments/_tree.segment.rsc +1 -1
  199. package/app/.next-cli-build/server/app/dashboard/endpoint.html +1 -1
  200. package/app/.next-cli-build/server/app/dashboard/endpoint.rsc +7 -7
  201. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint/__PAGE__.segment.rsc +6 -6
  202. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_full.segment.rsc +7 -7
  203. package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_tree.segment.rsc +1 -1
  204. package/app/.next-cli-build/server/app/dashboard/health.html +1 -1
  205. package/app/.next-cli-build/server/app/dashboard/health.rsc +6 -6
  206. package/app/.next-cli-build/server/app/dashboard/health.segments/!KGRhc2hib2FyZCk/dashboard/health/__PAGE__.segment.rsc +5 -5
  207. package/app/.next-cli-build/server/app/dashboard/health.segments/_full.segment.rsc +6 -6
  208. package/app/.next-cli-build/server/app/dashboard/health.segments/_tree.segment.rsc +1 -1
  209. package/app/.next-cli-build/server/app/dashboard/media-providers/web.html +1 -1
  210. package/app/.next-cli-build/server/app/dashboard/media-providers/web.rsc +7 -7
  211. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers/web/__PAGE__.segment.rsc +6 -6
  212. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_full.segment.rsc +7 -7
  213. package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_tree.segment.rsc +1 -1
  214. package/app/.next-cli-build/server/app/dashboard/mitm.html +1 -1
  215. package/app/.next-cli-build/server/app/dashboard/mitm.rsc +7 -7
  216. package/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm/__PAGE__.segment.rsc +6 -6
  217. package/app/.next-cli-build/server/app/dashboard/mitm.segments/_full.segment.rsc +7 -7
  218. package/app/.next-cli-build/server/app/dashboard/mitm.segments/_tree.segment.rsc +1 -1
  219. package/app/.next-cli-build/server/app/dashboard/playground.html +1 -1
  220. package/app/.next-cli-build/server/app/dashboard/playground.rsc +7 -7
  221. package/app/.next-cli-build/server/app/dashboard/playground.segments/!KGRhc2hib2FyZCk/dashboard/playground/__PAGE__.segment.rsc +6 -6
  222. package/app/.next-cli-build/server/app/dashboard/playground.segments/_full.segment.rsc +7 -7
  223. package/app/.next-cli-build/server/app/dashboard/playground.segments/_tree.segment.rsc +1 -1
  224. package/app/.next-cli-build/server/app/dashboard/profile.html +1 -1
  225. package/app/.next-cli-build/server/app/dashboard/profile.rsc +7 -7
  226. package/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile/__PAGE__.segment.rsc +6 -6
  227. package/app/.next-cli-build/server/app/dashboard/profile.segments/_full.segment.rsc +7 -7
  228. package/app/.next-cli-build/server/app/dashboard/profile.segments/_tree.segment.rsc +1 -1
  229. package/app/.next-cli-build/server/app/dashboard/providers/new.html +1 -1
  230. package/app/.next-cli-build/server/app/dashboard/providers/new.rsc +7 -7
  231. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new/__PAGE__.segment.rsc +6 -6
  232. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_full.segment.rsc +7 -7
  233. package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_tree.segment.rsc +1 -1
  234. package/app/.next-cli-build/server/app/dashboard/providers.html +1 -1
  235. package/app/.next-cli-build/server/app/dashboard/providers.rsc +7 -7
  236. package/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers/__PAGE__.segment.rsc +6 -6
  237. package/app/.next-cli-build/server/app/dashboard/providers.segments/_full.segment.rsc +7 -7
  238. package/app/.next-cli-build/server/app/dashboard/providers.segments/_tree.segment.rsc +1 -1
  239. package/app/.next-cli-build/server/app/dashboard/proxy-pools.html +1 -1
  240. package/app/.next-cli-build/server/app/dashboard/proxy-pools.rsc +7 -7
  241. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools/__PAGE__.segment.rsc +6 -6
  242. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_full.segment.rsc +7 -7
  243. package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_tree.segment.rsc +1 -1
  244. package/app/.next-cli-build/server/app/dashboard/pxpipe.html +1 -1
  245. package/app/.next-cli-build/server/app/dashboard/pxpipe.rsc +7 -7
  246. package/app/.next-cli-build/server/app/dashboard/pxpipe.segments/!KGRhc2hib2FyZCk/dashboard/pxpipe/__PAGE__.segment.rsc +6 -6
  247. package/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_full.segment.rsc +7 -7
  248. package/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_tree.segment.rsc +1 -1
  249. package/app/.next-cli-build/server/app/dashboard/quota.html +1 -1
  250. package/app/.next-cli-build/server/app/dashboard/quota.rsc +8 -8
  251. package/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota/__PAGE__.segment.rsc +7 -7
  252. package/app/.next-cli-build/server/app/dashboard/quota.segments/_full.segment.rsc +8 -8
  253. package/app/.next-cli-build/server/app/dashboard/quota.segments/_tree.segment.rsc +1 -1
  254. package/app/.next-cli-build/server/app/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
  255. package/app/.next-cli-build/server/app/dashboard/settings/pricing.html +1 -1
  256. package/app/.next-cli-build/server/app/dashboard/settings/pricing.rsc +5 -5
  257. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_full.segment.rsc +5 -5
  258. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_tree.segment.rsc +1 -1
  259. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing/__PAGE__.segment.rsc +4 -4
  260. package/app/.next-cli-build/server/app/dashboard/skills.html +1 -1
  261. package/app/.next-cli-build/server/app/dashboard/skills.rsc +7 -7
  262. package/app/.next-cli-build/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk/dashboard/skills/__PAGE__.segment.rsc +6 -6
  263. package/app/.next-cli-build/server/app/dashboard/skills.segments/_full.segment.rsc +7 -7
  264. package/app/.next-cli-build/server/app/dashboard/skills.segments/_tree.segment.rsc +1 -1
  265. package/app/.next-cli-build/server/app/dashboard/token-saver.html +1 -1
  266. package/app/.next-cli-build/server/app/dashboard/token-saver.rsc +7 -7
  267. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk/dashboard/token-saver/__PAGE__.segment.rsc +6 -6
  268. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/_full.segment.rsc +7 -7
  269. package/app/.next-cli-build/server/app/dashboard/token-saver.segments/_tree.segment.rsc +1 -1
  270. package/app/.next-cli-build/server/app/dashboard/translator.html +1 -1
  271. package/app/.next-cli-build/server/app/dashboard/translator.rsc +7 -7
  272. package/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator/__PAGE__.segment.rsc +6 -6
  273. package/app/.next-cli-build/server/app/dashboard/translator.segments/_full.segment.rsc +7 -7
  274. package/app/.next-cli-build/server/app/dashboard/translator.segments/_tree.segment.rsc +1 -1
  275. package/app/.next-cli-build/server/app/dashboard/usage.html +1 -1
  276. package/app/.next-cli-build/server/app/dashboard/usage.rsc +7 -7
  277. package/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage/__PAGE__.segment.rsc +6 -6
  278. package/app/.next-cli-build/server/app/dashboard/usage.segments/_full.segment.rsc +7 -7
  279. package/app/.next-cli-build/server/app/dashboard/usage.segments/_tree.segment.rsc +1 -1
  280. package/app/.next-cli-build/server/app/dashboard.html +1 -1
  281. package/app/.next-cli-build/server/app/dashboard.rsc +6 -6
  282. package/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard/__PAGE__.segment.rsc +5 -5
  283. package/app/.next-cli-build/server/app/dashboard.segments/_full.segment.rsc +6 -6
  284. package/app/.next-cli-build/server/app/dashboard.segments/_tree.segment.rsc +1 -1
  285. package/app/.next-cli-build/server/app/index.html +1 -1
  286. package/app/.next-cli-build/server/app/index.rsc +5 -5
  287. package/app/.next-cli-build/server/app/index.segments/__PAGE__.segment.rsc +4 -4
  288. package/app/.next-cli-build/server/app/index.segments/_full.segment.rsc +5 -5
  289. package/app/.next-cli-build/server/app/index.segments/_tree.segment.rsc +1 -1
  290. package/app/.next-cli-build/server/app/landing/page.js +1 -1
  291. package/app/.next-cli-build/server/app/landing/page_client-reference-manifest.js +1 -1
  292. package/app/.next-cli-build/server/app/landing.html +1 -1
  293. package/app/.next-cli-build/server/app/landing.rsc +6 -6
  294. package/app/.next-cli-build/server/app/landing.segments/_full.segment.rsc +6 -6
  295. package/app/.next-cli-build/server/app/landing.segments/_tree.segment.rsc +1 -1
  296. package/app/.next-cli-build/server/app/landing.segments/landing/__PAGE__.segment.rsc +5 -5
  297. package/app/.next-cli-build/server/app/login/page.js +1 -1
  298. package/app/.next-cli-build/server/app/login/page_client-reference-manifest.js +1 -1
  299. package/app/.next-cli-build/server/app/login.html +1 -1
  300. package/app/.next-cli-build/server/app/login.rsc +6 -6
  301. package/app/.next-cli-build/server/app/login.segments/_full.segment.rsc +6 -6
  302. package/app/.next-cli-build/server/app/login.segments/_tree.segment.rsc +1 -1
  303. package/app/.next-cli-build/server/app/login.segments/login/__PAGE__.segment.rsc +5 -5
  304. package/app/.next-cli-build/server/app/manifest.webmanifest/route.js +1 -1
  305. package/app/.next-cli-build/server/app/manifest.webmanifest.body +1 -1
  306. package/app/.next-cli-build/server/app/page_client-reference-manifest.js +1 -1
  307. package/app/.next-cli-build/server/app-paths-manifest.json +14 -14
  308. package/app/.next-cli-build/server/chunks/1133.js +1 -1
  309. package/app/.next-cli-build/server/chunks/1757.js +2 -2
  310. package/app/.next-cli-build/server/chunks/2132.js +1 -1
  311. package/app/.next-cli-build/server/chunks/2524.js +1 -1
  312. package/app/.next-cli-build/server/chunks/2732.js +1 -1
  313. package/app/.next-cli-build/server/chunks/2760.js +1 -1
  314. package/app/.next-cli-build/server/chunks/3192.js +1 -1
  315. package/app/.next-cli-build/server/chunks/3360.js +1 -1
  316. package/app/.next-cli-build/server/chunks/3535.js +1 -1
  317. package/app/.next-cli-build/server/chunks/3966.js +6 -6
  318. package/app/.next-cli-build/server/chunks/412.js +1 -1
  319. package/app/.next-cli-build/server/chunks/4123.js +3 -3
  320. package/app/.next-cli-build/server/chunks/4152.js +1 -1
  321. package/app/.next-cli-build/server/chunks/436.js +1 -1
  322. package/app/.next-cli-build/server/chunks/455.js +1 -1
  323. package/app/.next-cli-build/server/chunks/4642.js +1 -1
  324. package/app/.next-cli-build/server/chunks/4746.js +1 -1
  325. package/app/.next-cli-build/server/chunks/4764.js +1 -1
  326. package/app/.next-cli-build/server/chunks/4827.js +1 -1
  327. package/app/.next-cli-build/server/chunks/4864.js +6 -6
  328. package/app/.next-cli-build/server/chunks/5299.js +25 -25
  329. package/app/.next-cli-build/server/chunks/5330.js +1 -1
  330. package/app/.next-cli-build/server/chunks/5615.js +2 -2
  331. package/app/.next-cli-build/server/chunks/6296.js +5 -5
  332. package/app/.next-cli-build/server/chunks/735.js +1 -1
  333. package/app/.next-cli-build/server/chunks/7373.js +1 -1
  334. package/app/.next-cli-build/server/chunks/7716.js +1 -1
  335. package/app/.next-cli-build/server/chunks/8126.js +1 -1
  336. package/app/.next-cli-build/server/chunks/8306.js +1 -1
  337. package/app/.next-cli-build/server/chunks/8432.js +1 -1
  338. package/app/.next-cli-build/server/chunks/8749.js +1 -1
  339. package/app/.next-cli-build/server/chunks/9032.js +1 -1
  340. package/app/.next-cli-build/server/chunks/9046.js +1 -1
  341. package/app/.next-cli-build/server/chunks/9128.js +1 -1
  342. package/app/.next-cli-build/server/chunks/9489.js +1 -1
  343. package/app/.next-cli-build/server/chunks/9609.js +1 -1
  344. package/app/.next-cli-build/server/middleware-build-manifest.js +1 -1
  345. package/app/.next-cli-build/server/middleware.js +2 -2
  346. package/app/.next-cli-build/server/pages/404.html +1 -1
  347. package/app/.next-cli-build/server/pages/500.html +1 -1
  348. package/app/.next-cli-build/static/chunks/{1321-b2785838003873e1.js → 1321-9eb7d54c5b900efb.js} +1 -1
  349. package/app/.next-cli-build/static/chunks/{5497-66e7c2a2b715a638.js → 5497-973a06c94a94aff7.js} +1 -1
  350. package/app/.next-cli-build/static/chunks/761-1bcb7334763d5645.js +132 -0
  351. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/cli-tools/{page-9f4426c30039c7d5.js → page-3960bffd1fddbbad.js} +1 -1
  352. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/endpoint/{page-0c7b45a45ba51753.js → page-61b17862582ff807.js} +1 -1
  353. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/profile/{page-de6dfc43c2687bd8.js → page-1a560f2b5cdf2e31.js} +1 -1
  354. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/skills/page-4c6b176d5c59d8a4.js +1 -0
  355. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/token-saver/{page-e631d28dd402dc1e.js → page-d0031965cf7eff51.js} +1 -1
  356. package/app/.next-cli-build/static/chunks/app/landing/{page-431f7e8093b8ca51.js → page-5bc39b166588b878.js} +1 -1
  357. package/app/.next-cli-build/static/chunks/app/login/{page-80c4e229a5f38a6b.js → page-f2b166590b653d36.js} +1 -1
  358. package/app/custom-server.js +2 -2
  359. package/app/package.json +1 -1
  360. package/app/src/lib/oauth/providers/xiaomi-mimo.js +2 -2
  361. package/app/src/lib/updater/updater.js +3 -3
  362. package/app/src/mitm/server.js +10 -10
  363. package/cli.js +6 -6
  364. package/hooks/postinstall.js +2 -2
  365. package/hooks/sqliteRuntime.js +2 -2
  366. package/hooks/trayRuntime.js +3 -3
  367. package/package.json +7 -3
  368. package/src/cli/api/client.js +3 -3
  369. package/src/cli/commands/connect.js +3 -3
  370. package/src/cli/commands/connectTools.js +12 -12
  371. package/src/cli/commands/xaiVideo.js +1 -1
  372. package/src/cli/menus/cliTools.js +18 -18
  373. package/src/cli/menus/settings.js +1 -1
  374. package/src/cli/tray/autostart.js +1 -1
  375. package/app/.next-cli-build/static/chunks/761-57ed45cdddcf32eb.js +0 -132
  376. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/skills/page-316b3186a841d862.js +0 -1
  377. /package/app/.next-cli-build/static/{fjLlI_-eBYMOp6J-a-q-6 → MDZXE-9g1sq006f6JNky9}/_buildManifest.js +0 -0
  378. /package/app/.next-cli-build/static/{fjLlI_-eBYMOp6J-a-q-6 → MDZXE-9g1sq006f6JNky9}/_ssgManifest.js +0 -0
@@ -1,18 +1,18 @@
1
- exports.id=5299,exports.ids=[5299],exports.modules={17914:(a,b,c)=>{var d=c(22004),e=c(30083);a.exports={page:"cli-tools_page__HS81E "+d.page+" "+e.formScope,grid:"cli-tools_grid__73M3b",group:"cli-tools_group___dLus",groupHeader:"cli-tools_groupHeader__X13aP",toolLink:"cli-tools_toolLink__oQEyr",tile:"cli-tools_tile__S5pg5",toolIcon:"cli-tools_toolIcon__xTTIE",identity:"cli-tools_identity__l_BsD",title:"cli-tools_title__qnVJY",titleLine:"cli-tools_titleLine___8FLb",description:"cli-tools_description__2ekMF "+d.description,status:"cli-tools_status__L6Iv5",infoStatus:"cli-tools_infoStatus__NqwPS cli-tools_status__L6Iv5",chevron:"cli-tools_chevron___INll",backLink:"cli-tools_backLink__vxK14",detailHeader:"cli-tools_detailHeader__dGO6q",panel:"cli-tools_panel__uhiwc "+d.section,panelHeader:"cli-tools_panelHeader__CSGch",body:"cli-tools_body__IrkV8",configuration:"cli-tools_configuration__vVb8p",fieldLabel:"cli-tools_fieldLabel__gRQoh",notice:"cli-tools_notice__nRQMp",warning:"cli-tools_warning__aYgWm",positive:"cli-tools_positive__D71K2",danger:"cli-tools_danger__K_df4",neutral:"cli-tools_neutral__tXP9j",selectButton:"cli-tools_selectButton__zkNoV",iconButton:"cli-tools_iconButton__HeYFU "+e.iconButton,modelPicker:"cli-tools_modelPicker__uXuDA "+e.modelPicker}},22004:a=>{a.exports={page:"usage_page__TfrVH",header:"usage_header__Pj5rE",sectionHeader:"usage_sectionHeader__ikyc_",description:"usage_description___N7_0",sectionDescription:"usage_sectionDescription__hUHjE",controls:"usage_controls__BDy3z",section:"usage_section__Q1FLM",dimension:"usage_dimension__25vsJ",filterSelect:"usage_filterSelect__amqM_",gridMetrics:"usage_gridMetrics__9oDcY",gridSplit:"usage_gridSplit__wz4rx",gridHalves:"usage_gridHalves__WbK2e",metric:"usage_metric__yHVf7",metricHead:"usage_metricHead__kAXr7",metricValue:"usage_metricValue__sJtV9",metricMeta:"usage_metricMeta__1cxTN",tableWrap:"usage_tableWrap__E0Juz",recentRequests:"usage_recentRequests__X3JVv",recentRequestsScroll:"usage_recentRequestsScroll__7dSK0",recentRequestsTable:"usage_recentRequestsTable__V5LMJ",recentRequestModel:"usage_recentRequestModel__A34Vd",table:"usage_table__nOZE_",sortable:"usage_sortable__vJl89",num:"usage_num__YYpAv",center:"usage_center__cPoHb",muted:"usage_muted__qSgnm",subtle:"usage_subtle__PDxKR",pending:"usage_pending__9txNi",total:"usage_total__bDiWP",empty:"usage_empty__fk44z",inset:"usage_inset__ua4iZ",insetHint:"usage_insetHint__kaPZI",insetCode:"usage_insetCode__s_Qk2",panelRow:"usage_panelRow__1yMBm",chartArea:"usage_chartArea__4tcwm",topology:"usage_topology__szXKT",codeBlock:"usage_codeBlock__4xHCm",collapsible:"usage_collapsible__pvjBb",collapsibleToggle:"usage_collapsibleToggle__4SxaT",collapsibleLabel:"usage_collapsibleLabel__UHyD3",collapsibleChevron:"usage_collapsibleChevron__bo1wQ",collapsibleChevronOpen:"usage_collapsibleChevronOpen__XPBdW",collapsibleBody:"usage_collapsibleBody__6tLPZ",fieldLabel:"usage_fieldLabel__QyUjE",detailGrid:"usage_detailGrid__o6iZ8"}},25299:(a,b,c)=>{"use strict";c.d(b,{Tk:()=>G,aG:()=>X,Ah:()=>K,Q6:()=>W,lF:()=>$,a7:()=>T,ZM:()=>L,WE:()=>ah,E_:()=>af,RF:()=>Q,mW:()=>_,c9:()=>Y,gY:()=>ao,tA:()=>aj,kn:()=>al,yZ:()=>M,qO:()=>U});var d=c(48249),e=c(21707),f=c(98153),g=c(17914),h=c.n(g),i=c(67484),j=c(50412),k=c(81220),l=c(12020);function m({storageKey:a,changeEvent:b,itemField:c,normalize:d=a=>a,defaultName:e=a=>a}){let f=()=>[],g=a=>{};return{read:f,subscribe:a=>()=>{},upsert:(a,b)=>{let h=d(a);if(!h)return null;let i=f(),j=i.find(a=>d(a[c])===h);if(j&&!b)return j.name;let k=(b||e(h)).trim();return k?(g([...i.filter(a=>a.name!==k&&d(a[c])!==h),{name:k,[c]:h}].sort((a,b)=>a.name.localeCompare(b.name))),k):null},remove:a=>g(f().filter(b=>b.name!==a))}}let n=a=>(a||"").replace(/\/+$/,""),o=m({storageKey:"9router.cliToolEndpointPresets",changeEvent:"9router:endpoint-presets-changed",itemField:"baseUrl",normalize:n,defaultName:a=>{try{return new URL(a).host}catch{return a}}}),p=m({storageKey:"9router.cliToolApiKeyPresets",changeEvent:"9router:api-key-presets-changed",itemField:"key"}),q=o.read;o.subscribe;let r=o.upsert,s=o.remove;p.read,p.subscribe;let t=p.upsert,u=p.remove;function v(a,{tunnelPublicUrl:b,tailscaleUrl:c,cloudUrl:d}={}){let e=n(a);return!e||[`http://127.0.0.1:${l.h0.appPort}`,b,c,d].filter(Boolean).flatMap(a=>[n(a),`${n(a)}/v1`]).includes(e)?null:r(e)}let w="__custom__",x="__save__";function y({value:a,onChange:b,requiresExternalUrl:c=!1,tunnelEnabled:f=!1,tunnelPublicUrl:g="",tailscaleEnabled:h=!1,tailscaleUrl:j="",cloudEnabled:k=!1,cloudUrl:m="",withV1:n=!0,currentUrl:o=""}){let[p,q]=(0,i.useState)([]),[t,u]=(0,i.useState)(!1),[v,z]=(0,i.useState)(""),[A,B]=(0,i.useState)("");(0,i.useRef)(!1),(0,i.useRef)("");let C=(0,i.useRef)(""),D=(0,i.useMemo)(()=>(({requiresExternalUrl:a,tunnelEnabled:b,tunnelPublicUrl:c,tailscaleEnabled:d,tailscaleUrl:e,cloudEnabled:f,cloudUrl:g,savedPresets:h,withV1:i})=>{let j=[],k=a=>{let b;return i?(b=(a||"").replace(/\/+$/,""))?/\/v1$/.test(b)?b:`${b}/v1`:"":(a||"").replace(/\/+$/,"")};if(!a){let a=k(`http://127.0.0.1:${l.h0.appPort}`);j.push({value:"local",label:a,url:a})}if(b&&c){let a=k(c);j.push({value:"tunnel",label:a,url:a})}if(d&&e){let a=k(e);j.push({value:"tailscale",label:a,url:a})}if(f&&g){let a=k(g);j.push({value:"cloud",label:a,url:a})}return h.forEach(a=>{j.push({value:`saved:${a.name}`,label:a.baseUrl,url:a.baseUrl,saved:!0})}),j.push({value:w,label:"Custom URL...",url:""}),j})({requiresExternalUrl:c,tunnelEnabled:f,tunnelPublicUrl:g,tailscaleEnabled:h,tailscaleUrl:j,cloudEnabled:k,cloudUrl:m,savedPresets:p,withV1:n}),[c,f,g,h,j,k,m,p,n]),E=v.startsWith("saved:"),F=v===w,G=F&&(A||"").trim().length>0;return(0,d.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsxs)("select",{"aria-label":"Endpoint",value:v,onChange:c=>{let d=c.target.value;if(d===x){let b=(a||"").trim();if(!b)return;let c=b;try{c=new URL(b).host}catch{}let d=window.prompt("Save endpoint as:",c),e=d?.trim()?r(b,d.trim()):null;e&&z(`saved:${e}`);return}if(z(d),d===w){B(""),b("");return}let e=D.find(a=>a.value===d);e&&b(e.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:[D.map(a=>(0,d.jsx)("option",{value:a.value,children:a.label},a.value)),G&&(0,d.jsx)("option",{value:x,children:"+ Save current as..."})]}),E&&(0,d.jsx)("button",{type:"button",onClick:()=>{if(!v.startsWith("saved:"))return;s(v.slice(6)),B("");let a=D.find(a=>a.value!==w&&a.value!==v);a?(z(a.value),b(a.url)):(z(w),b(""))},className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors shrink-0",title:"Delete saved endpoint",children:(0,d.jsx)(e.default,{className:"text-[14px]",children:"delete"})})]}),F&&(0,d.jsx)("input",{"aria-label":"Custom endpoint URL",type:"text",value:A,onChange:a=>{let c=a.target.value;C.current=c,B(c),b(c)},placeholder:n?"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 z="__custom__",A="__save_key__";function B({value:a,onChange:b,apiKeys:c=[],cloudEnabled:f=!1,className:g=""}){let[h,j]=(0,i.useState)([]),[k,l]=(0,i.useState)(!1),[m,n]=(0,i.useState)(""),o=(0,i.useMemo)(()=>[...c.map(a=>({value:a.key,label:a.key})),...h.map(a=>({value:`saved:${a.name}`,label:a.key,url:a.key,saved:!0})),{value:z,label:"Custom...",url:""}],[c,h]),p=a?o.find(b=>b.value===a||b.url===a):null,q=p?p.value:k||a?z:o[0]?.value??z,r=k?m:a||"",s="string"==typeof q&&q.startsWith("saved:"),v=q===z,w=v&&(a||"").trim().length>0&&!c.some(b=>b.key===a);return 0!==c.length||0!==h.length||k||a?(0,d.jsxs)("div",{className:`flex flex-col gap-1.5 ${g}`,children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsxs)("select",{"aria-label":"API key",value:q,onChange:c=>{let d=c.target.value;if(d===A)return void t((a||"").trim());if(d===z){l(!0),n(""),b("");return}l(!1),n("");let e=o.find(a=>a.value===d);e&&b(e.url??e.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:[o.map(a=>(0,d.jsx)("option",{value:a.value,children:a.label},a.value)),w&&(0,d.jsx)("option",{value:A,children:"+ Save current as..."})]}),s&&(0,d.jsx)("button",{type:"button",onClick:()=>{if(!s)return;u(q.slice(6)),l(!1),n("");let a=o.find(a=>a.value!==z&&a.value!==q);b(a?a.url??a.value:"")},className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors shrink-0",title:"Delete saved key",children:(0,d.jsx)(e.default,{className:"text-[14px]",children:"delete"})})]}),v&&(0,d.jsx)("input",{"aria-label":"Custom API key",type:"text",value:r,onChange:a=>{let c=a.target.value;l(!0),n(c),b(c)},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,d.jsx)("span",{className:`min-w-0 rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5 ${g}`,children:f?"No API keys - Create one in Keys page":"sk_9router (default)"})}let C=a=>(a||"").replace(/\/+$/,"");function D(a,b={}){if(!a)return!1;let c=C(a),{tunnelPublicUrl:d,tailscaleUrl:e,cloudUrl:f}=b;return!!(/localhost|127\.0\.0\.1|0\.0\.0\.0/.test(c)||d&&c.startsWith(C(d))||e&&c.startsWith(C(e))||f&&c.startsWith(C(f)))}let E=/\[1m\]$/i,F=[{label:"Default",value:""},{label:"200K",value:"198000"},{label:"300K",value:"298000"},{label:"500K",value:"498000"},{label:"700K",value:"698000"}];function G({tool:a,isExpanded:b,onToggle:c,activeProviders:g,modelMappings:l,onModelMappingChange:m,baseUrl:n,hasActiveProviders:o,apiKeys:p,cloudEnabled:q,initialStatus:r,tunnelEnabled:s,tunnelPublicUrl:t,tailscaleEnabled:u,tailscaleUrl:w}){let x,z,A,[C,H]=(0,i.useState)(r||null),[I,J]=(0,i.useState)(!1),[K,L]=(0,i.useState)(!1),[M,N]=(0,i.useState)(!1),[O,P]=(0,i.useState)(null),[Q,R]=(0,i.useState)(!1),[S,T]=(0,i.useState)(!1),[U,V]=(0,i.useState)(null),[W,X]=(0,i.useState)(""),[Y,Z]=(0,i.useState)({}),[$,_]=(0,i.useState)(!1),[aa,ab]=(0,i.useState)(""),[ac,ad]=(0,i.useState)(!1),[ae,af]=(0,i.useState)(!1),[ag,ah]=(0,i.useState)(""),[ai,aj]=(0,i.useState)(!1);(0,i.useRef)(!1);let ak=C?.settings?.env?.ANTHROPIC_BASE_URL||"",al=(()=>{if(!C?.installed)return null;let a=C.settings?.env?.ANTHROPIC_BASE_URL;return a?D(a,{tunnelPublicUrl:t,tailscaleUrl:w,cloudUrl:q?"https://9router.com":null})?"configured":"other":"not_configured"})(),am=async a=>{let b=a.target.checked;ad(b),await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({ccFilterNaming:b})}).catch(()=>{})},an=()=>{let a=aa||n;return a.endsWith("/v1")?a:`${a}/v1`},ao=async()=>{L(!0),P(null);try{let b={ANTHROPIC_BASE_URL:an()},c=W?.trim()||(p?.length>0?p[0].key:null)||(q?null:"sk_9router");c&&(b.ANTHROPIC_AUTH_TOKEN=c),a.defaultModels.forEach(a=>{let c=l[a.alias];c&&a.envKey&&(b[a.envKey]=c)}),ag&&(b.CLAUDE_CODE_AUTO_COMPACT_WINDOW=ag);let d=await fetch("/api/cli-tools/claude-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({env:b,exaMcpEnabled:ae,autoCompactWindow:ag})}),e=await d.json();d.ok?(v(an(),{tunnelPublicUrl:t,tailscaleUrl:w}),P({type:"success",text:"Settings applied successfully!"}),H(a=>({...a,hasBackup:!0,settings:{...a?.settings,env:b},exaMcpEnabled:ae}))):P({type:"error",text:e.error||"Failed to apply settings"})}catch(a){P({type:"error",text:a.message})}finally{L(!1)}},ap=async()=>{N(!0),P(null);try{let b=await fetch("/api/cli-tools/claude-settings",{method:"DELETE"}),c=await b.json();b.ok?(P({type:"success",text:"Settings reset successfully!"}),a.defaultModels.forEach(a=>m(a.alias,a.defaultValue||"")),X(""),af(!1),ah(""),aj(!1)):P({type:"error",text:c.error||"Failed to reset settings"})}catch(a){P({type:"error",text:a.message})}finally{N(!1)}};return(0,d.jsxs)(j.Zp,{padding:"none",className:h().panel,children:[(0,d.jsxs)("div",{className:h().panelHeader,onClick:c,children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,d.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,d.jsx)(k.default,{src:"/providers/claude.png",alt:a.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:a=>{a.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,d.jsx)("h3",{className:"font-medium text-sm",children:a.name}),"configured"===al&&(0,d.jsx)(f.A,{variant:"success",className:h().status,children:"Connected"}),"not_configured"===al&&(0,d.jsx)(f.A,{variant:"warning",className:h().status,children:"Not configured"}),"other"===al&&(0,d.jsx)(f.A,{variant:"default",dot:!1,className:h().status,children:"Other"})]}),(0,d.jsx)("p",{className:"text-xs text-text-muted truncate",children:a.description})]})]}),(0,d.jsx)(e.default,{className:`text-text-muted text-[20px] transition-transform ${b?"rotate-180":""}`,children:"expand_more"})]}),b&&(0,d.jsxs)("div",{className:h().body,children:[I&&(0,d.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,d.jsx)(e.default,{className:"animate-spin",children:"progress_activity"}),(0,d.jsx)("span",{children:"Checking Claude CLI..."})]}),!I&&C&&!C.installed&&(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,d.jsxs)("div",{className:`flex flex-col gap-3 p-4 border ${h().notice} ${h().warning}`,children:[(0,d.jsxs)("div",{className:"flex items-start gap-3",children:[(0,d.jsx)(e.default,{className:"text-[var(--warn)]",children:"warning"}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("p",{className:"font-medium text-[var(--warn)]",children:"Claude CLI not detected locally"}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if 9router is deployed on a remote server."})]})]}),(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2 sm:pl-9",children:[(0,d.jsxs)(j.$n,{variant:"secondary",size:"sm",onClick:()=>_(!0),children:[(0,d.jsx)(e.default,{className:"text-[18px] mr-1",children:"content_copy"}),"Manual Config"]}),(0,d.jsxs)(j.$n,{variant:"outline",size:"sm",onClick:()=>R(!Q),children:[(0,d.jsx)(e.default,{className:"text-[18px] mr-1",children:Q?"expand_less":"help"}),Q?"Hide":"How to Install"]})]})]}),Q&&(0,d.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,d.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,d.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-text-muted mb-1",children:"macOS / Linux / Windows:"}),(0,d.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,d.jsxs)("p",{className:"text-text-muted",children:["After installation, run ",(0,d.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"claude"})," to verify."]})]})]})]}),!I&&C?.installed&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Select Endpoint"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(y,{value:aa||((x=aa||n).endsWith("/v1")?x:`${x}/v1`),onChange:ab,requiresExternalUrl:a.requiresExternalUrl,tunnelEnabled:s,tunnelPublicUrl:t,tailscaleEnabled:u,tailscaleUrl:w,currentUrl:ak})]}),C?.settings?.env?.ANTHROPIC_BASE_URL&&(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Current"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.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:C.settings.env.ANTHROPIC_BASE_URL})]}),(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"API Key"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(B,{value:W,onChange:X,apiKeys:p,cloudEnabled:q})]}),a.defaultModels.map(a=>(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:a.name}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,d.jsxs)("div",{className:"relative flex-1 min-w-0",children:[(0,d.jsx)("input",{type:"text",value:l[a.alias]||"",onChange:b=>m(a.alias,b.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[a.alias]&&(0,d.jsx)("button",{onClick:()=>m(a.alias,""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-[var(--danger)] rounded transition-colors",title:"Clear",children:(0,d.jsx)(e.default,{className:"text-[14px]",children:"close"})})]}),(0,d.jsx)("button",{onClick:()=>{V(a.alias),T(!0)},disabled:!o,className:`rounded border px-2.5 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap shrink-0 ${o?"bg-surface border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${h().selectButton}`,children:"Select"})]})]},a.alias)),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Auto-compact"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)("select",{value:ag,onChange:a=>ah(a.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:F.map(a=>(0,d.jsx)("option",{value:a.value,children:a.label},a.label))})]}),(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"1M context"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsxs)("label",{className:"flex items-center gap-1.5 cursor-pointer select-none",children:[(0,d.jsx)("input",{type:"checkbox",checked:ai,onChange:b=>{var c;aj(c=b.target.checked),a.defaultModels.forEach(a=>{let b=l[a.alias];b&&m(a.alias,((a,b)=>{let{model:c}=function(a){if("string"!=typeof a)return{model:a,contextMarker:null};let b=a.trim(),c=b.match(E);return c?{model:b.slice(0,-c[0].length),contextMarker:c[0].slice(1,-1).toLowerCase()}:{model:a,contextMarker:null}}(a);return b?`${c}[1m]`:c})(b,c))})},className:"w-3.5 h-3.5 accent-primary cursor-pointer shrink-0"}),(0,d.jsx)("span",{className:"text-xs text-text-muted",children:"Append [1m] to the model name"}),(0,d.jsx)(j.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,d.jsx)(e.default,{className:"text-text-muted text-[14px] cursor-help",children:"info"})})]})]}),(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Filter naming"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsxs)("label",{className:"flex items-center gap-1.5 cursor-pointer select-none",children:[(0,d.jsx)("input",{type:"checkbox",checked:ac,onChange:am,className:"w-3.5 h-3.5 accent-primary cursor-pointer shrink-0"}),(0,d.jsx)("span",{className:"text-xs text-text-muted",children:"Filter naming requests"}),(0,d.jsx)(j.m_,{text:"Intercepts Claude Code's topic-naming requests and returns a fake response locally, saving API tokens.",children:(0,d.jsx)(e.default,{className:"text-text-muted text-[14px] cursor-help",children:"info"})})]})]}),(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Web Search"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsxs)("label",{className:"flex items-center gap-1.5 cursor-pointer select-none",children:[(0,d.jsx)("input",{type:"checkbox",checked:ae,onChange:a=>af(a.target.checked),className:"w-3.5 h-3.5 accent-primary cursor-pointer shrink-0"}),(0,d.jsx)("span",{className:"text-xs text-text-muted",children:"Exa MCP"}),(0,d.jsx)(j.m_,{text:"Injects Exa MCP into ~/.claude.json so non-Claude models gain web search. Restart Claude Code after Apply.",children:(0,d.jsx)(e.default,{className:"text-text-muted text-[14px] cursor-help",children:"info"})})]})]})]}),O&&(0,d.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===O.type?h().positive:h().danger}`,children:[(0,d.jsx)(e.default,{className:"text-[14px]",children:"success"===O.type?"check_circle":"error"}),(0,d.jsx)("span",{children:O.text})]}),(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,d.jsxs)(j.$n,{variant:"primary",size:"sm",onClick:ao,disabled:!o,loading:K,children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"save"}),"Apply"]}),(0,d.jsxs)(j.$n,{variant:"outline",size:"sm",onClick:ap,disabled:!C?.has9Router,loading:M,children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,d.jsxs)(j.$n,{variant:"ghost",size:"sm",onClick:()=>_(!0),children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),S&&(0,d.jsx)(j.rq,{isOpen:S,onClose:()=>T(!1),onSelect:a=>{U&&m(U,a.value)},selectedModel:U?l[U]:null,activeProviders:g,modelAliases:Y,title:`Select model for ${U}`}),(0,d.jsx)(j.uR,{isOpen:$,onClose:()=>_(!1),title:"Claude CLI - Manual Configuration",configs:(z=W&&W.trim()?W:q?"<API_KEY_FROM_DASHBOARD>":"sk_9router",A={ANTHROPIC_BASE_URL:an(),ANTHROPIC_AUTH_TOKEN:z},a.defaultModels.forEach(a=>{let b=l[a.alias];b&&a.envKey&&(A[a.envKey]=b)}),ag&&(A.CLAUDE_CODE_AUTO_COMPACT_WINDOW=ag),[{filename:"~/.claude/settings.json",content:JSON.stringify({hasCompletedOnboarding:!0,env:A},null,2)}])})]})}var H=c(72738);let I=(a,b)=>{let c=a.match(RegExp(`^\\s*${b}\\s*=\\s*(["'])([^\\n]*?)\\1\\s*(?:#.*)?$`));return c?c[2]:""};function J(a,b=[]){if(!a||"string"!=typeof a)return"model";let c="",d=a.trim();"config"===(c=(c=d.includes("/")?d.split("/")[0].toLowerCase().replace(/[^a-z0-9_-]/g,""):d.toLowerCase().replace(/[^a-z0-9_-]/g,"")).replace(/^[-_]+|[-_]+$/g,"")||"model")&&(c="model-config");let e=c,f=2;for(;b.includes(e);)e=`${c}-${f}`,f++;return e}function K({tool:a,isExpanded:b,onToggle:c,baseUrl:g,apiKeys:l,activeProviders:m,cloudEnabled:n,initialStatus:o,tunnelEnabled:p,tunnelPublicUrl:q,tailscaleEnabled:r,tailscaleUrl:s}){let t,u,[w,x]=(0,i.useState)(o||null),[z,A]=(0,i.useState)(!1),[C,E]=(0,i.useState)(!1),[F,G]=(0,i.useState)(!1),[L,M]=(0,i.useState)(null),[N,O]=(0,i.useState)(!1),[P,Q]=(0,i.useState)(""),[R,S]=(0,i.useState)(""),[T,U]=(0,i.useState)(""),[V,W]=(0,i.useState)(!1),[X,Y]=(0,i.useState)(!1),[Z,$]=(0,i.useState)({}),[_,aa]=(0,i.useState)(!1),[ab,ac]=(0,i.useState)(""),[ad,ae]=(0,i.useState)([]),[af,ag]=(0,i.useState)(""),[ah,ai]=(0,i.useState)(""),[aj,ak]=(0,i.useState)(!1),[al,am]=(0,i.useState)(!1),[an,ao]=(0,i.useState)(null),[ap,aq]=(0,i.useState)(""),ar=async()=>{try{let a=await fetch("/api/cli-tools/codex-profiles"),b=await a.json();a.ok&&ae(b.profiles||[])}catch(a){console.log("Error fetching codex profiles:",a)}},as=async()=>{let a=af.trim().toLowerCase().replace(/[^a-z0-9_-]/g,""),b=ah.trim();if(a&&b){am(!0);try{let c=await fetch("/api/cli-tools/codex-profiles",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:a,model:b})}),d=await c.json();c.ok?(ag(""),ai(""),ar()):M({type:"error",text:d.error||"Failed to add model"})}catch(a){M({type:"error",text:a.message})}finally{am(!1)}}},at=async a=>{ao(a);try{(await fetch("/api/cli-tools/codex-profiles",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:a})})).ok&&ar()}catch(a){console.log("Error deleting codex profile:",a)}finally{ao(null)}},au=async a=>{try{await navigator.clipboard.writeText(a),aq(a),setTimeout(()=>aq(""),2e3)}catch(a){console.log("Copy failed",a)}},av=function(a){if("string"!=typeof a)return{baseUrl:"",apiKey:""};let b=a.split(/\r?\n/),c="",d=!0;for(let a of b){if(/^\s*\[/.test(a)){d=!1;continue}d&&(c=I(a,"model_provider")||c)}if(!c)return{baseUrl:"",apiKey:""};let e=`model_providers.${c}`,f=!1,g=!1,h="",i="";for(let a of b){let b=a.match(/^\s*\[\s*([^\]]+?)\s*\]\s*(?:#.*)?$/);if(b){f=b[1]===e,g=b[1]===`${e}.http_headers`;continue}if(f&&(h=I(a,"base_url")||h),g){let b=I(a,"Authorization").match(/^Bearer\s+(.+)$/i);i=b?b[1]:i}}return{baseUrl:h,apiKey:i}}(w?.config).baseUrl,aw=w?.installed?w.config?D(av,{tunnelPublicUrl:q,tailscaleUrl:s})?"configured":"other":"not_configured":null,ax=()=>{let a=(ab||`${g}/v1`).replace(/\/+$/,"");return a.endsWith("/v1")?a:`${a}/v1`},ay=async()=>{A(!0);try{let a=await fetch("/api/cli-tools/codex-settings",{cache:"no-store"}),b=await a.json();x(b)}catch(a){x({installed:!1,error:a.message})}finally{A(!1)}},az=async()=>{E(!0),M(null);try{let a=P&&P.trim()||n?P:"sk_9router",b=await fetch("/api/cli-tools/codex-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:ax(),apiKey:a,model:R,subagentModel:T||R})}),c=await b.json();b.ok?(v(ax(),{tunnelPublicUrl:q,tailscaleUrl:s}),M({type:"success",text:"Settings applied successfully!"}),ay()):M({type:"error",text:c.error||"Failed to apply settings"})}catch(a){M({type:"error",text:a.message})}finally{E(!1)}},aA=async()=>{G(!0),M(null);try{let a=await fetch("/api/cli-tools/codex-settings",{method:"DELETE"}),b=await a.json();a.ok?(M({type:"success",text:"Settings reset successfully!"}),S(""),U(""),ay()):M({type:"error",text:b.error||"Failed to reset settings"})}catch(a){M({type:"error",text:a.message})}finally{G(!1)}};return(0,d.jsxs)(j.Zp,{padding:"none",className:h().panel,children:[(0,d.jsxs)("div",{className:h().panelHeader,onClick:c,children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,d.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,d.jsx)(k.default,{src:"/providers/codex.png",alt:a.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:a=>{a.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,d.jsx)("h3",{className:"font-medium text-sm",children:a.name}),"configured"===aw&&(0,d.jsx)(f.A,{variant:"success",className:h().status,children:"Connected"}),"not_configured"===aw&&(0,d.jsx)(f.A,{variant:"warning",className:h().status,children:"Not configured"}),"other"===aw&&(0,d.jsx)(f.A,{variant:"default",dot:!1,className:h().status,children:"Other"})]}),(0,d.jsx)("p",{className:"text-xs text-text-muted truncate",children:a.description})]})]}),(0,d.jsx)(e.default,{className:`text-text-muted text-[20px] transition-transform ${b?"rotate-180":""}`,children:"expand_more"})]}),b&&(0,d.jsxs)("div",{className:h().body,children:[z&&(0,d.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,d.jsx)(e.default,{className:"animate-spin",children:"progress_activity"}),(0,d.jsx)("span",{children:"Checking Codex CLI..."})]}),!z&&w&&!w.installed&&(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,d.jsxs)("div",{className:`flex flex-col gap-3 p-4 border ${h().notice} ${h().warning}`,children:[(0,d.jsxs)("div",{className:"flex items-start gap-3",children:[(0,d.jsx)(e.default,{className:"text-[var(--warn)]",children:"warning"}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("p",{className:"font-medium text-[var(--warn)]",children:"Codex CLI not detected locally"}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if 9router is deployed on a remote server."})]})]}),(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2 sm:pl-9",children:[(0,d.jsxs)(j.$n,{variant:"secondary",size:"sm",onClick:()=>aa(!0),children:[(0,d.jsx)(e.default,{className:"text-[18px] mr-1",children:"content_copy"}),"Manual Config"]}),(0,d.jsxs)(j.$n,{variant:"outline",size:"sm",onClick:()=>O(!N),children:[(0,d.jsx)(e.default,{className:"text-[18px] mr-1",children:N?"expand_less":"help"}),N?"Hide":"How to Install"]})]})]}),N&&(0,d.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,d.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,d.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-text-muted mb-1",children:"macOS / Linux / Windows:"}),(0,d.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,d.jsxs)("p",{className:"text-text-muted",children:["After installation, run ",(0,d.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"codex"})," to verify."]}),(0,d.jsx)("div",{className:"pt-2 border-t border-border",children:(0,d.jsxs)("p",{className:"text-text-muted text-xs",children:["Codex reads custom providers from ",(0,d.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"~/.codex/config.toml"}),'. Click "Apply" to auto-configure.']})})]})]})]}),!z&&w?.installed&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Select Endpoint"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(y,{value:ab||ab||`${g}/v1`,onChange:ac,requiresExternalUrl:a.requiresExternalUrl,tunnelEnabled:p,tunnelPublicUrl:q,tailscaleEnabled:r,tailscaleUrl:s,currentUrl:av})]}),w?.config&&(av?(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Current"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.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:av})]}):null),(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"API Key"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(B,{value:P,onChange:Q,apiKeys:l,cloudEnabled:n})]}),(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Model"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,d.jsx)("input",{type:"text",value:R,onChange:a=>S(a.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,d.jsx)("button",{onClick:()=>S(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-[var(--danger)] rounded transition-colors",title:"Clear",children:(0,d.jsx)(e.default,{className:"text-[14px]",children:"close"})})]}),(0,d.jsx)("button",{onClick:()=>W(!0),disabled:!m?.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 ${m?.length?"bg-surface border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${h().selectButton}`,children:"Select Model"})]}),(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Subagent Model"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,d.jsx)("input",{type:"text",value:T,onChange:a=>U(a.target.value),placeholder:R||"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"}),T&&(0,d.jsx)("button",{onClick:()=>U(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-[var(--danger)] rounded transition-colors",title:"Clear (will use main model)",children:(0,d.jsx)(e.default,{className:"text-[14px]",children:"close"})})]}),(0,d.jsx)("button",{onClick:()=>Y(!0),disabled:!m?.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 ${m?.length?"bg-surface border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${h().selectButton}`,children:"Select Model"})]})]}),L&&(0,d.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===L.type?h().positive:h().danger}`,children:[(0,d.jsx)(e.default,{className:"text-[14px]",children:"success"===L.type?"check_circle":"error"}),(0,d.jsx)("span",{children:L.text})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,d.jsxs)(j.$n,{variant:"primary",size:"sm",onClick:az,disabled:!P&&n&&l.length>0||!R,loading:C,children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"save"}),"Apply"]}),(0,d.jsxs)(j.$n,{variant:"outline",size:"sm",onClick:aA,disabled:F,loading:F,children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,d.jsxs)(j.$n,{variant:"ghost",size:"sm",onClick:()=>aa(!0),children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]}),(0,d.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-3",children:[(0,d.jsx)("div",{className:"flex items-center justify-between",children:(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsxs)("span",{className:"text-xs font-semibold text-text-main flex items-center gap-1.5",children:[(0,d.jsx)(e.default,{className:"text-[16px] text-text-main",children:"layers"}),"Additional Models"]}),ad.length>0&&(0,d.jsx)("span",{className:"badge-neutral",children:ad.length})]})}),(0,d.jsx)("div",{className:"flex flex-col gap-1.5 p-2.5 bg-surface/40 border border-border rounded-lg",children:(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-[10rem_1fr_auto_auto] sm:items-center",children:[(0,d.jsx)("input",{type:"text",value:af,onChange:a=>ag(a.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:a=>"Enter"===a.key&&as()}),(0,d.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,d.jsx)("input",{type:"text",value:ah,onChange:a=>{let b=a.target.value;ai(b),ag(J(b.includes("/")?b.split("/")[0]:b,ad.map(a=>a.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:a=>"Enter"===a.key&&as()}),ah&&(0,d.jsx)("button",{onClick:()=>ai(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-[var(--danger)] rounded transition-colors",title:"Clear",children:(0,d.jsx)(e.default,{className:"text-[14px]",children:"close"})})]}),(0,d.jsx)("button",{onClick:()=>ak(!0),disabled:!m?.length,className:`w-full sm:w-auto rounded border px-2.5 py-1.5 text-xs transition-colors whitespace-nowrap sm:shrink-0 ${m?.length?"bg-surface border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${h().selectButton}`,children:"Select Model"}),(0,d.jsxs)(j.$n,{variant:"primary",size:"sm",onClick:as,disabled:!af.trim()||!ah.trim()||al,loading:al,className:" whitespace-nowrap",children:[(0,d.jsx)(e.default,{className:"text-[15px] mr-1",children:"add"}),"Add"]})]})}),0===ad.length?(0,d.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,d.jsx)(e.default,{className:"text-[20px] text-text-muted mb-1 opacity-60",children:"terminal"}),(0,d.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,d.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:ad.map(a=>{let b=a.model.includes("/")?a.model.split("/")[0]:a.name,c=ap===a.command;return(0,d.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,d.jsxs)("div",{className:"flex items-center gap-2.5 min-w-0",children:[(0,d.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,d.jsx)(H.A,{providerId:b,size:18,fallbackText:a.name.slice(0,2).toUpperCase()})}),(0,d.jsxs)("div",{className:"min-w-0 flex flex-col",children:[(0,d.jsx)("span",{className:"font-medium text-xs text-text-main truncate",children:a.name}),(0,d.jsx)("span",{className:"text-[11px] text-text-muted truncate font-mono",children:a.model})]})]}),(0,d.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,d.jsxs)("button",{onClick:()=>au(a.command),className:`flex items-center gap-1 px-2 py-1 rounded text-[11px] font-mono border transition-all ${c?"bg-green-500/10 border-green-500/30 text-[var(--pos)]":"bg-surface border-border text-text-muted hover:text-text-main hover:border-[var(--text-2)] cursor-pointer"}`,title:"Click to copy command",children:[(0,d.jsx)(e.default,{className:"text-[13px]",children:c?"check":"terminal"}),(0,d.jsx)("span",{className:"hidden md:inline",children:a.command}),(0,d.jsx)("span",{className:"md:hidden",children:"copy"})]}),(0,d.jsx)("button",{onClick:()=>at(a.name),disabled:an===a.name,className:"p-1 text-text-muted hover:text-[var(--danger)] opacity-0 group-hover:opacity-100 focus-visible:opacity-100 transition-opacity rounded",title:"Delete model",children:(0,d.jsx)(e.default,{className:"text-[15px]",children:"close"})})]})]},a.name)})})]})]})]}),V&&(0,d.jsx)(j.rq,{className:h().modelPicker,isOpen:V,onClose:()=>W(!1),onSelect:a=>{S(a.value),T||U(a.value),W(!1)},selectedModel:R,activeProviders:m,modelAliases:Z,title:"Select Model for Codex"}),X&&(0,d.jsx)(j.rq,{className:h().modelPicker,isOpen:X,onClose:()=>Y(!1),onSelect:a=>{U(a.value),Y(!1)},selectedModel:T,activeProviders:m,modelAliases:Z,title:"Select Subagent Model for Codex"}),aj&&(0,d.jsx)(j.rq,{className:h().modelPicker,isOpen:aj,onClose:()=>ak(!1),onSelect:a=>{ak(!1);let b=a?.value||a?.id;b&&(ai(b),ag(J(a?.provider||(b.includes("/")?b.split("/")[0]:b),ad.map(a=>a.name))))},selectedModel:ah,activeProviders:m,modelAliases:Z,title:"Select Model for Codex CLI"}),(0,d.jsx)(j.uR,{isOpen:_,onClose:()=>aa(!1),title:"Codex CLI - Manual Configuration",configs:(t=P&&P.trim()?P:n?"<API_KEY_FROM_DASHBOARD>":"sk_9router",u=T||R,[{filename:"~/.codex/config.toml",content:`# 9Router Configuration for Codex CLI
1
+ exports.id=5299,exports.ids=[5299],exports.modules={17914:(a,b,c)=>{var d=c(22004),e=c(30083);a.exports={page:"cli-tools_page__HS81E "+d.page+" "+e.formScope,grid:"cli-tools_grid__73M3b",group:"cli-tools_group___dLus",groupHeader:"cli-tools_groupHeader__X13aP",toolLink:"cli-tools_toolLink__oQEyr",tile:"cli-tools_tile__S5pg5",toolIcon:"cli-tools_toolIcon__xTTIE",identity:"cli-tools_identity__l_BsD",title:"cli-tools_title__qnVJY",titleLine:"cli-tools_titleLine___8FLb",description:"cli-tools_description__2ekMF "+d.description,status:"cli-tools_status__L6Iv5",infoStatus:"cli-tools_infoStatus__NqwPS cli-tools_status__L6Iv5",chevron:"cli-tools_chevron___INll",backLink:"cli-tools_backLink__vxK14",detailHeader:"cli-tools_detailHeader__dGO6q",panel:"cli-tools_panel__uhiwc "+d.section,panelHeader:"cli-tools_panelHeader__CSGch",body:"cli-tools_body__IrkV8",configuration:"cli-tools_configuration__vVb8p",fieldLabel:"cli-tools_fieldLabel__gRQoh",notice:"cli-tools_notice__nRQMp",warning:"cli-tools_warning__aYgWm",positive:"cli-tools_positive__D71K2",danger:"cli-tools_danger__K_df4",neutral:"cli-tools_neutral__tXP9j",selectButton:"cli-tools_selectButton__zkNoV",iconButton:"cli-tools_iconButton__HeYFU "+e.iconButton,modelPicker:"cli-tools_modelPicker__uXuDA "+e.modelPicker}},22004:a=>{a.exports={page:"usage_page__TfrVH",header:"usage_header__Pj5rE",sectionHeader:"usage_sectionHeader__ikyc_",description:"usage_description___N7_0",sectionDescription:"usage_sectionDescription__hUHjE",controls:"usage_controls__BDy3z",section:"usage_section__Q1FLM",dimension:"usage_dimension__25vsJ",filterSelect:"usage_filterSelect__amqM_",gridMetrics:"usage_gridMetrics__9oDcY",gridSplit:"usage_gridSplit__wz4rx",gridHalves:"usage_gridHalves__WbK2e",metric:"usage_metric__yHVf7",metricHead:"usage_metricHead__kAXr7",metricValue:"usage_metricValue__sJtV9",metricMeta:"usage_metricMeta__1cxTN",tableWrap:"usage_tableWrap__E0Juz",recentRequests:"usage_recentRequests__X3JVv",recentRequestsScroll:"usage_recentRequestsScroll__7dSK0",recentRequestsTable:"usage_recentRequestsTable__V5LMJ",recentRequestModel:"usage_recentRequestModel__A34Vd",table:"usage_table__nOZE_",sortable:"usage_sortable__vJl89",num:"usage_num__YYpAv",center:"usage_center__cPoHb",muted:"usage_muted__qSgnm",subtle:"usage_subtle__PDxKR",pending:"usage_pending__9txNi",total:"usage_total__bDiWP",empty:"usage_empty__fk44z",inset:"usage_inset__ua4iZ",insetHint:"usage_insetHint__kaPZI",insetCode:"usage_insetCode__s_Qk2",panelRow:"usage_panelRow__1yMBm",chartArea:"usage_chartArea__4tcwm",topology:"usage_topology__szXKT",codeBlock:"usage_codeBlock__4xHCm",collapsible:"usage_collapsible__pvjBb",collapsibleToggle:"usage_collapsibleToggle__4SxaT",collapsibleLabel:"usage_collapsibleLabel__UHyD3",collapsibleChevron:"usage_collapsibleChevron__bo1wQ",collapsibleChevronOpen:"usage_collapsibleChevronOpen__XPBdW",collapsibleBody:"usage_collapsibleBody__6tLPZ",fieldLabel:"usage_fieldLabel__QyUjE",detailGrid:"usage_detailGrid__o6iZ8"}},25299:(a,b,c)=>{"use strict";c.d(b,{Tk:()=>G,aG:()=>X,Ah:()=>K,Q6:()=>W,lF:()=>$,a7:()=>T,ZM:()=>L,WE:()=>ah,E_:()=>af,RF:()=>Q,mW:()=>_,c9:()=>Y,gY:()=>ao,tA:()=>aj,kn:()=>al,yZ:()=>M,qO:()=>U});var d=c(48249),e=c(21707),f=c(98153),g=c(17914),h=c.n(g),i=c(67484),j=c(50412),k=c(81220),l=c(12020);function m({storageKey:a,changeEvent:b,itemField:c,normalize:d=a=>a,defaultName:e=a=>a}){let f=()=>[],g=a=>{};return{read:f,subscribe:a=>()=>{},upsert:(a,b)=>{let h=d(a);if(!h)return null;let i=f(),j=i.find(a=>d(a[c])===h);if(j&&!b)return j.name;let k=(b||e(h)).trim();return k?(g([...i.filter(a=>a.name!==k&&d(a[c])!==h),{name:k,[c]:h}].sort((a,b)=>a.name.localeCompare(b.name))),k):null},remove:a=>g(f().filter(b=>b.name!==a))}}let n=a=>(a||"").replace(/\/+$/,""),o=m({storageKey:"jrouter.cliToolEndpointPresets",changeEvent:"jrouter:endpoint-presets-changed",itemField:"baseUrl",normalize:n,defaultName:a=>{try{return new URL(a).host}catch{return a}}}),p=m({storageKey:"jrouter.cliToolApiKeyPresets",changeEvent:"jrouter:api-key-presets-changed",itemField:"key"}),q=o.read;o.subscribe;let r=o.upsert,s=o.remove;p.read,p.subscribe;let t=p.upsert,u=p.remove;function v(a,{tunnelPublicUrl:b,tailscaleUrl:c,cloudUrl:d}={}){let e=n(a);return!e||[`http://127.0.0.1:${l.h0.appPort}`,b,c,d].filter(Boolean).flatMap(a=>[n(a),`${n(a)}/v1`]).includes(e)?null:r(e)}let w="__custom__",x="__save__";function y({value:a,onChange:b,requiresExternalUrl:c=!1,tunnelEnabled:f=!1,tunnelPublicUrl:g="",tailscaleEnabled:h=!1,tailscaleUrl:j="",cloudEnabled:k=!1,cloudUrl:m="",withV1:n=!0,currentUrl:o=""}){let[p,q]=(0,i.useState)([]),[t,u]=(0,i.useState)(!1),[v,z]=(0,i.useState)(""),[A,B]=(0,i.useState)("");(0,i.useRef)(!1),(0,i.useRef)("");let C=(0,i.useRef)(""),D=(0,i.useMemo)(()=>(({requiresExternalUrl:a,tunnelEnabled:b,tunnelPublicUrl:c,tailscaleEnabled:d,tailscaleUrl:e,cloudEnabled:f,cloudUrl:g,savedPresets:h,withV1:i})=>{let j=[],k=a=>{let b;return i?(b=(a||"").replace(/\/+$/,""))?/\/v1$/.test(b)?b:`${b}/v1`:"":(a||"").replace(/\/+$/,"")};if(!a){let a=k(`http://127.0.0.1:${l.h0.appPort}`);j.push({value:"local",label:a,url:a})}if(b&&c){let a=k(c);j.push({value:"tunnel",label:a,url:a})}if(d&&e){let a=k(e);j.push({value:"tailscale",label:a,url:a})}if(f&&g){let a=k(g);j.push({value:"cloud",label:a,url:a})}return h.forEach(a=>{j.push({value:`saved:${a.name}`,label:a.baseUrl,url:a.baseUrl,saved:!0})}),j.push({value:w,label:"Custom URL...",url:""}),j})({requiresExternalUrl:c,tunnelEnabled:f,tunnelPublicUrl:g,tailscaleEnabled:h,tailscaleUrl:j,cloudEnabled:k,cloudUrl:m,savedPresets:p,withV1:n}),[c,f,g,h,j,k,m,p,n]),E=v.startsWith("saved:"),F=v===w,G=F&&(A||"").trim().length>0;return(0,d.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsxs)("select",{"aria-label":"Endpoint",value:v,onChange:c=>{let d=c.target.value;if(d===x){let b=(a||"").trim();if(!b)return;let c=b;try{c=new URL(b).host}catch{}let d=window.prompt("Save endpoint as:",c),e=d?.trim()?r(b,d.trim()):null;e&&z(`saved:${e}`);return}if(z(d),d===w){B(""),b("");return}let e=D.find(a=>a.value===d);e&&b(e.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:[D.map(a=>(0,d.jsx)("option",{value:a.value,children:a.label},a.value)),G&&(0,d.jsx)("option",{value:x,children:"+ Save current as..."})]}),E&&(0,d.jsx)("button",{type:"button",onClick:()=>{if(!v.startsWith("saved:"))return;s(v.slice(6)),B("");let a=D.find(a=>a.value!==w&&a.value!==v);a?(z(a.value),b(a.url)):(z(w),b(""))},className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors shrink-0",title:"Delete saved endpoint",children:(0,d.jsx)(e.default,{className:"text-[14px]",children:"delete"})})]}),F&&(0,d.jsx)("input",{"aria-label":"Custom endpoint URL",type:"text",value:A,onChange:a=>{let c=a.target.value;C.current=c,B(c),b(c)},placeholder:n?"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 z="__custom__",A="__save_key__";function B({value:a,onChange:b,apiKeys:c=[],cloudEnabled:f=!1,className:g=""}){let[h,j]=(0,i.useState)([]),[k,l]=(0,i.useState)(!1),[m,n]=(0,i.useState)(""),o=(0,i.useMemo)(()=>[...c.map(a=>({value:a.key,label:a.key})),...h.map(a=>({value:`saved:${a.name}`,label:a.key,url:a.key,saved:!0})),{value:z,label:"Custom...",url:""}],[c,h]),p=a?o.find(b=>b.value===a||b.url===a):null,q=p?p.value:k||a?z:o[0]?.value??z,r=k?m:a||"",s="string"==typeof q&&q.startsWith("saved:"),v=q===z,w=v&&(a||"").trim().length>0&&!c.some(b=>b.key===a);return 0!==c.length||0!==h.length||k||a?(0,d.jsxs)("div",{className:`flex flex-col gap-1.5 ${g}`,children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsxs)("select",{"aria-label":"API key",value:q,onChange:c=>{let d=c.target.value;if(d===A)return void t((a||"").trim());if(d===z){l(!0),n(""),b("");return}l(!1),n("");let e=o.find(a=>a.value===d);e&&b(e.url??e.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:[o.map(a=>(0,d.jsx)("option",{value:a.value,children:a.label},a.value)),w&&(0,d.jsx)("option",{value:A,children:"+ Save current as..."})]}),s&&(0,d.jsx)("button",{type:"button",onClick:()=>{if(!s)return;u(q.slice(6)),l(!1),n("");let a=o.find(a=>a.value!==z&&a.value!==q);b(a?a.url??a.value:"")},className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors shrink-0",title:"Delete saved key",children:(0,d.jsx)(e.default,{className:"text-[14px]",children:"delete"})})]}),v&&(0,d.jsx)("input",{"aria-label":"Custom API key",type:"text",value:r,onChange:a=>{let c=a.target.value;l(!0),n(c),b(c)},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,d.jsx)("span",{className:`min-w-0 rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5 ${g}`,children:f?"No API keys - Create one in Keys page":"sk_jrouter (default)"})}let C=a=>(a||"").replace(/\/+$/,"");function D(a,b={}){if(!a)return!1;let c=C(a),{tunnelPublicUrl:d,tailscaleUrl:e,cloudUrl:f}=b;return!!(/localhost|127\.0\.0\.1|0\.0\.0\.0/.test(c)||d&&c.startsWith(C(d))||e&&c.startsWith(C(e))||f&&c.startsWith(C(f)))}let E=/\[1m\]$/i,F=[{label:"Default",value:""},{label:"200K",value:"198000"},{label:"300K",value:"298000"},{label:"500K",value:"498000"},{label:"700K",value:"698000"}];function G({tool:a,isExpanded:b,onToggle:c,activeProviders:g,modelMappings:l,onModelMappingChange:m,baseUrl:n,hasActiveProviders:o,apiKeys:p,cloudEnabled:q,initialStatus:r,tunnelEnabled:s,tunnelPublicUrl:t,tailscaleEnabled:u,tailscaleUrl:w}){let x,z,A,[C,H]=(0,i.useState)(r||null),[I,J]=(0,i.useState)(!1),[K,L]=(0,i.useState)(!1),[M,N]=(0,i.useState)(!1),[O,P]=(0,i.useState)(null),[Q,R]=(0,i.useState)(!1),[S,T]=(0,i.useState)(!1),[U,V]=(0,i.useState)(null),[W,X]=(0,i.useState)(""),[Y,Z]=(0,i.useState)({}),[$,_]=(0,i.useState)(!1),[aa,ab]=(0,i.useState)(""),[ac,ad]=(0,i.useState)(!1),[ae,af]=(0,i.useState)(!1),[ag,ah]=(0,i.useState)(""),[ai,aj]=(0,i.useState)(!1);(0,i.useRef)(!1);let ak=C?.settings?.env?.ANTHROPIC_BASE_URL||"",al=(()=>{if(!C?.installed)return null;let a=C.settings?.env?.ANTHROPIC_BASE_URL;return a?D(a,{tunnelPublicUrl:t,tailscaleUrl:w,cloudUrl:q?"https://9router.com":null})?"configured":"other":"not_configured"})(),am=async a=>{let b=a.target.checked;ad(b),await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({ccFilterNaming:b})}).catch(()=>{})},an=()=>{let a=aa||n;return a.endsWith("/v1")?a:`${a}/v1`},ao=async()=>{L(!0),P(null);try{let b={ANTHROPIC_BASE_URL:an()},c=W?.trim()||(p?.length>0?p[0].key:null)||(q?null:"sk_jrouter");c&&(b.ANTHROPIC_AUTH_TOKEN=c),a.defaultModels.forEach(a=>{let c=l[a.alias];c&&a.envKey&&(b[a.envKey]=c)}),ag&&(b.CLAUDE_CODE_AUTO_COMPACT_WINDOW=ag);let d=await fetch("/api/cli-tools/claude-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({env:b,exaMcpEnabled:ae,autoCompactWindow:ag})}),e=await d.json();d.ok?(v(an(),{tunnelPublicUrl:t,tailscaleUrl:w}),P({type:"success",text:"Settings applied successfully!"}),H(a=>({...a,hasBackup:!0,settings:{...a?.settings,env:b},exaMcpEnabled:ae}))):P({type:"error",text:e.error||"Failed to apply settings"})}catch(a){P({type:"error",text:a.message})}finally{L(!1)}},ap=async()=>{N(!0),P(null);try{let b=await fetch("/api/cli-tools/claude-settings",{method:"DELETE"}),c=await b.json();b.ok?(P({type:"success",text:"Settings reset successfully!"}),a.defaultModels.forEach(a=>m(a.alias,a.defaultValue||"")),X(""),af(!1),ah(""),aj(!1)):P({type:"error",text:c.error||"Failed to reset settings"})}catch(a){P({type:"error",text:a.message})}finally{N(!1)}};return(0,d.jsxs)(j.Zp,{padding:"none",className:h().panel,children:[(0,d.jsxs)("div",{className:h().panelHeader,onClick:c,children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,d.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,d.jsx)(k.default,{src:"/providers/claude.png",alt:a.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:a=>{a.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,d.jsx)("h3",{className:"font-medium text-sm",children:a.name}),"configured"===al&&(0,d.jsx)(f.A,{variant:"success",className:h().status,children:"Connected"}),"not_configured"===al&&(0,d.jsx)(f.A,{variant:"warning",className:h().status,children:"Not configured"}),"other"===al&&(0,d.jsx)(f.A,{variant:"default",dot:!1,className:h().status,children:"Other"})]}),(0,d.jsx)("p",{className:"text-xs text-text-muted truncate",children:a.description})]})]}),(0,d.jsx)(e.default,{className:`text-text-muted text-[20px] transition-transform ${b?"rotate-180":""}`,children:"expand_more"})]}),b&&(0,d.jsxs)("div",{className:h().body,children:[I&&(0,d.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,d.jsx)(e.default,{className:"animate-spin",children:"progress_activity"}),(0,d.jsx)("span",{children:"Checking Claude CLI..."})]}),!I&&C&&!C.installed&&(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,d.jsxs)("div",{className:`flex flex-col gap-3 p-4 border ${h().notice} ${h().warning}`,children:[(0,d.jsxs)("div",{className:"flex items-start gap-3",children:[(0,d.jsx)(e.default,{className:"text-[var(--warn)]",children:"warning"}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("p",{className:"font-medium text-[var(--warn)]",children:"Claude CLI not detected locally"}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if JRouter is deployed on a remote server."})]})]}),(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2 sm:pl-9",children:[(0,d.jsxs)(j.$n,{variant:"secondary",size:"sm",onClick:()=>_(!0),children:[(0,d.jsx)(e.default,{className:"text-[18px] mr-1",children:"content_copy"}),"Manual Config"]}),(0,d.jsxs)(j.$n,{variant:"outline",size:"sm",onClick:()=>R(!Q),children:[(0,d.jsx)(e.default,{className:"text-[18px] mr-1",children:Q?"expand_less":"help"}),Q?"Hide":"How to Install"]})]})]}),Q&&(0,d.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,d.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,d.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-text-muted mb-1",children:"macOS / Linux / Windows:"}),(0,d.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,d.jsxs)("p",{className:"text-text-muted",children:["After installation, run ",(0,d.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"claude"})," to verify."]})]})]})]}),!I&&C?.installed&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Select Endpoint"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(y,{value:aa||((x=aa||n).endsWith("/v1")?x:`${x}/v1`),onChange:ab,requiresExternalUrl:a.requiresExternalUrl,tunnelEnabled:s,tunnelPublicUrl:t,tailscaleEnabled:u,tailscaleUrl:w,currentUrl:ak})]}),C?.settings?.env?.ANTHROPIC_BASE_URL&&(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Current"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.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:C.settings.env.ANTHROPIC_BASE_URL})]}),(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"API Key"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(B,{value:W,onChange:X,apiKeys:p,cloudEnabled:q})]}),a.defaultModels.map(a=>(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:a.name}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,d.jsxs)("div",{className:"relative flex-1 min-w-0",children:[(0,d.jsx)("input",{type:"text",value:l[a.alias]||"",onChange:b=>m(a.alias,b.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[a.alias]&&(0,d.jsx)("button",{onClick:()=>m(a.alias,""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-[var(--danger)] rounded transition-colors",title:"Clear",children:(0,d.jsx)(e.default,{className:"text-[14px]",children:"close"})})]}),(0,d.jsx)("button",{onClick:()=>{V(a.alias),T(!0)},disabled:!o,className:`rounded border px-2.5 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap shrink-0 ${o?"bg-surface border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${h().selectButton}`,children:"Select"})]})]},a.alias)),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Auto-compact"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)("select",{value:ag,onChange:a=>ah(a.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:F.map(a=>(0,d.jsx)("option",{value:a.value,children:a.label},a.label))})]}),(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"1M context"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsxs)("label",{className:"flex items-center gap-1.5 cursor-pointer select-none",children:[(0,d.jsx)("input",{type:"checkbox",checked:ai,onChange:b=>{var c;aj(c=b.target.checked),a.defaultModels.forEach(a=>{let b=l[a.alias];b&&m(a.alias,((a,b)=>{let{model:c}=function(a){if("string"!=typeof a)return{model:a,contextMarker:null};let b=a.trim(),c=b.match(E);return c?{model:b.slice(0,-c[0].length),contextMarker:c[0].slice(1,-1).toLowerCase()}:{model:a,contextMarker:null}}(a);return b?`${c}[1m]`:c})(b,c))})},className:"w-3.5 h-3.5 accent-primary cursor-pointer shrink-0"}),(0,d.jsx)("span",{className:"text-xs text-text-muted",children:"Append [1m] to the model name"}),(0,d.jsx)(j.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,d.jsx)(e.default,{className:"text-text-muted text-[14px] cursor-help",children:"info"})})]})]}),(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Filter naming"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsxs)("label",{className:"flex items-center gap-1.5 cursor-pointer select-none",children:[(0,d.jsx)("input",{type:"checkbox",checked:ac,onChange:am,className:"w-3.5 h-3.5 accent-primary cursor-pointer shrink-0"}),(0,d.jsx)("span",{className:"text-xs text-text-muted",children:"Filter naming requests"}),(0,d.jsx)(j.m_,{text:"Intercepts Claude Code's topic-naming requests and returns a fake response locally, saving API tokens.",children:(0,d.jsx)(e.default,{className:"text-text-muted text-[14px] cursor-help",children:"info"})})]})]}),(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Web Search"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsxs)("label",{className:"flex items-center gap-1.5 cursor-pointer select-none",children:[(0,d.jsx)("input",{type:"checkbox",checked:ae,onChange:a=>af(a.target.checked),className:"w-3.5 h-3.5 accent-primary cursor-pointer shrink-0"}),(0,d.jsx)("span",{className:"text-xs text-text-muted",children:"Exa MCP"}),(0,d.jsx)(j.m_,{text:"Injects Exa MCP into ~/.claude.json so non-Claude models gain web search. Restart Claude Code after Apply.",children:(0,d.jsx)(e.default,{className:"text-text-muted text-[14px] cursor-help",children:"info"})})]})]})]}),O&&(0,d.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===O.type?h().positive:h().danger}`,children:[(0,d.jsx)(e.default,{className:"text-[14px]",children:"success"===O.type?"check_circle":"error"}),(0,d.jsx)("span",{children:O.text})]}),(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,d.jsxs)(j.$n,{variant:"primary",size:"sm",onClick:ao,disabled:!o,loading:K,children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"save"}),"Apply"]}),(0,d.jsxs)(j.$n,{variant:"outline",size:"sm",onClick:ap,disabled:!C?.hasJRouter,loading:M,children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,d.jsxs)(j.$n,{variant:"ghost",size:"sm",onClick:()=>_(!0),children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),S&&(0,d.jsx)(j.rq,{isOpen:S,onClose:()=>T(!1),onSelect:a=>{U&&m(U,a.value)},selectedModel:U?l[U]:null,activeProviders:g,modelAliases:Y,title:`Select model for ${U}`}),(0,d.jsx)(j.uR,{isOpen:$,onClose:()=>_(!1),title:"Claude CLI - Manual Configuration",configs:(z=W&&W.trim()?W:q?"<API_KEY_FROM_DASHBOARD>":"sk_jrouter",A={ANTHROPIC_BASE_URL:an(),ANTHROPIC_AUTH_TOKEN:z},a.defaultModels.forEach(a=>{let b=l[a.alias];b&&a.envKey&&(A[a.envKey]=b)}),ag&&(A.CLAUDE_CODE_AUTO_COMPACT_WINDOW=ag),[{filename:"~/.claude/settings.json",content:JSON.stringify({hasCompletedOnboarding:!0,env:A},null,2)}])})]})}var H=c(72738);let I=(a,b)=>{let c=a.match(RegExp(`^\\s*${b}\\s*=\\s*(["'])([^\\n]*?)\\1\\s*(?:#.*)?$`));return c?c[2]:""};function J(a,b=[]){if(!a||"string"!=typeof a)return"model";let c="",d=a.trim();"config"===(c=(c=d.includes("/")?d.split("/")[0].toLowerCase().replace(/[^a-z0-9_-]/g,""):d.toLowerCase().replace(/[^a-z0-9_-]/g,"")).replace(/^[-_]+|[-_]+$/g,"")||"model")&&(c="model-config");let e=c,f=2;for(;b.includes(e);)e=`${c}-${f}`,f++;return e}function K({tool:a,isExpanded:b,onToggle:c,baseUrl:g,apiKeys:l,activeProviders:m,cloudEnabled:n,initialStatus:o,tunnelEnabled:p,tunnelPublicUrl:q,tailscaleEnabled:r,tailscaleUrl:s}){let t,u,[w,x]=(0,i.useState)(o||null),[z,A]=(0,i.useState)(!1),[C,E]=(0,i.useState)(!1),[F,G]=(0,i.useState)(!1),[L,M]=(0,i.useState)(null),[N,O]=(0,i.useState)(!1),[P,Q]=(0,i.useState)(""),[R,S]=(0,i.useState)(""),[T,U]=(0,i.useState)(""),[V,W]=(0,i.useState)(!1),[X,Y]=(0,i.useState)(!1),[Z,$]=(0,i.useState)({}),[_,aa]=(0,i.useState)(!1),[ab,ac]=(0,i.useState)(""),[ad,ae]=(0,i.useState)([]),[af,ag]=(0,i.useState)(""),[ah,ai]=(0,i.useState)(""),[aj,ak]=(0,i.useState)(!1),[al,am]=(0,i.useState)(!1),[an,ao]=(0,i.useState)(null),[ap,aq]=(0,i.useState)(""),ar=async()=>{try{let a=await fetch("/api/cli-tools/codex-profiles"),b=await a.json();a.ok&&ae(b.profiles||[])}catch(a){console.log("Error fetching codex profiles:",a)}},as=async()=>{let a=af.trim().toLowerCase().replace(/[^a-z0-9_-]/g,""),b=ah.trim();if(a&&b){am(!0);try{let c=await fetch("/api/cli-tools/codex-profiles",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:a,model:b})}),d=await c.json();c.ok?(ag(""),ai(""),ar()):M({type:"error",text:d.error||"Failed to add model"})}catch(a){M({type:"error",text:a.message})}finally{am(!1)}}},at=async a=>{ao(a);try{(await fetch("/api/cli-tools/codex-profiles",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:a})})).ok&&ar()}catch(a){console.log("Error deleting codex profile:",a)}finally{ao(null)}},au=async a=>{try{await navigator.clipboard.writeText(a),aq(a),setTimeout(()=>aq(""),2e3)}catch(a){console.log("Copy failed",a)}},av=function(a){if("string"!=typeof a)return{baseUrl:"",apiKey:""};let b=a.split(/\r?\n/),c="",d=!0;for(let a of b){if(/^\s*\[/.test(a)){d=!1;continue}d&&(c=I(a,"model_provider")||c)}if(!c)return{baseUrl:"",apiKey:""};let e=`model_providers.${c}`,f=!1,g=!1,h="",i="";for(let a of b){let b=a.match(/^\s*\[\s*([^\]]+?)\s*\]\s*(?:#.*)?$/);if(b){f=b[1]===e,g=b[1]===`${e}.http_headers`;continue}if(f&&(h=I(a,"base_url")||h),g){let b=I(a,"Authorization").match(/^Bearer\s+(.+)$/i);i=b?b[1]:i}}return{baseUrl:h,apiKey:i}}(w?.config).baseUrl,aw=w?.installed?w.config?D(av,{tunnelPublicUrl:q,tailscaleUrl:s})?"configured":"other":"not_configured":null,ax=()=>{let a=(ab||`${g}/v1`).replace(/\/+$/,"");return a.endsWith("/v1")?a:`${a}/v1`},ay=async()=>{A(!0);try{let a=await fetch("/api/cli-tools/codex-settings",{cache:"no-store"}),b=await a.json();x(b)}catch(a){x({installed:!1,error:a.message})}finally{A(!1)}},az=async()=>{E(!0),M(null);try{let a=P&&P.trim()||n?P:"sk_jrouter",b=await fetch("/api/cli-tools/codex-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:ax(),apiKey:a,model:R,subagentModel:T||R})}),c=await b.json();b.ok?(v(ax(),{tunnelPublicUrl:q,tailscaleUrl:s}),M({type:"success",text:"Settings applied successfully!"}),ay()):M({type:"error",text:c.error||"Failed to apply settings"})}catch(a){M({type:"error",text:a.message})}finally{E(!1)}},aA=async()=>{G(!0),M(null);try{let a=await fetch("/api/cli-tools/codex-settings",{method:"DELETE"}),b=await a.json();a.ok?(M({type:"success",text:"Settings reset successfully!"}),S(""),U(""),ay()):M({type:"error",text:b.error||"Failed to reset settings"})}catch(a){M({type:"error",text:a.message})}finally{G(!1)}};return(0,d.jsxs)(j.Zp,{padding:"none",className:h().panel,children:[(0,d.jsxs)("div",{className:h().panelHeader,onClick:c,children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,d.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,d.jsx)(k.default,{src:"/providers/codex.png",alt:a.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:a=>{a.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,d.jsx)("h3",{className:"font-medium text-sm",children:a.name}),"configured"===aw&&(0,d.jsx)(f.A,{variant:"success",className:h().status,children:"Connected"}),"not_configured"===aw&&(0,d.jsx)(f.A,{variant:"warning",className:h().status,children:"Not configured"}),"other"===aw&&(0,d.jsx)(f.A,{variant:"default",dot:!1,className:h().status,children:"Other"})]}),(0,d.jsx)("p",{className:"text-xs text-text-muted truncate",children:a.description})]})]}),(0,d.jsx)(e.default,{className:`text-text-muted text-[20px] transition-transform ${b?"rotate-180":""}`,children:"expand_more"})]}),b&&(0,d.jsxs)("div",{className:h().body,children:[z&&(0,d.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,d.jsx)(e.default,{className:"animate-spin",children:"progress_activity"}),(0,d.jsx)("span",{children:"Checking Codex CLI..."})]}),!z&&w&&!w.installed&&(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,d.jsxs)("div",{className:`flex flex-col gap-3 p-4 border ${h().notice} ${h().warning}`,children:[(0,d.jsxs)("div",{className:"flex items-start gap-3",children:[(0,d.jsx)(e.default,{className:"text-[var(--warn)]",children:"warning"}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("p",{className:"font-medium text-[var(--warn)]",children:"Codex CLI not detected locally"}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if JRouter is deployed on a remote server."})]})]}),(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2 sm:pl-9",children:[(0,d.jsxs)(j.$n,{variant:"secondary",size:"sm",onClick:()=>aa(!0),children:[(0,d.jsx)(e.default,{className:"text-[18px] mr-1",children:"content_copy"}),"Manual Config"]}),(0,d.jsxs)(j.$n,{variant:"outline",size:"sm",onClick:()=>O(!N),children:[(0,d.jsx)(e.default,{className:"text-[18px] mr-1",children:N?"expand_less":"help"}),N?"Hide":"How to Install"]})]})]}),N&&(0,d.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,d.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,d.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-text-muted mb-1",children:"macOS / Linux / Windows:"}),(0,d.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,d.jsxs)("p",{className:"text-text-muted",children:["After installation, run ",(0,d.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"codex"})," to verify."]}),(0,d.jsx)("div",{className:"pt-2 border-t border-border",children:(0,d.jsxs)("p",{className:"text-text-muted text-xs",children:["Codex reads custom providers from ",(0,d.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"~/.codex/config.toml"}),'. Click "Apply" to auto-configure.']})})]})]})]}),!z&&w?.installed&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Select Endpoint"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(y,{value:ab||ab||`${g}/v1`,onChange:ac,requiresExternalUrl:a.requiresExternalUrl,tunnelEnabled:p,tunnelPublicUrl:q,tailscaleEnabled:r,tailscaleUrl:s,currentUrl:av})]}),w?.config&&(av?(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Current"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.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:av})]}):null),(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"API Key"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(B,{value:P,onChange:Q,apiKeys:l,cloudEnabled:n})]}),(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Model"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,d.jsx)("input",{type:"text",value:R,onChange:a=>S(a.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,d.jsx)("button",{onClick:()=>S(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-[var(--danger)] rounded transition-colors",title:"Clear",children:(0,d.jsx)(e.default,{className:"text-[14px]",children:"close"})})]}),(0,d.jsx)("button",{onClick:()=>W(!0),disabled:!m?.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 ${m?.length?"bg-surface border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${h().selectButton}`,children:"Select Model"})]}),(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Subagent Model"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,d.jsx)("input",{type:"text",value:T,onChange:a=>U(a.target.value),placeholder:R||"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"}),T&&(0,d.jsx)("button",{onClick:()=>U(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-[var(--danger)] rounded transition-colors",title:"Clear (will use main model)",children:(0,d.jsx)(e.default,{className:"text-[14px]",children:"close"})})]}),(0,d.jsx)("button",{onClick:()=>Y(!0),disabled:!m?.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 ${m?.length?"bg-surface border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${h().selectButton}`,children:"Select Model"})]})]}),L&&(0,d.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===L.type?h().positive:h().danger}`,children:[(0,d.jsx)(e.default,{className:"text-[14px]",children:"success"===L.type?"check_circle":"error"}),(0,d.jsx)("span",{children:L.text})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,d.jsxs)(j.$n,{variant:"primary",size:"sm",onClick:az,disabled:!P&&n&&l.length>0||!R,loading:C,children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"save"}),"Apply"]}),(0,d.jsxs)(j.$n,{variant:"outline",size:"sm",onClick:aA,disabled:F,loading:F,children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,d.jsxs)(j.$n,{variant:"ghost",size:"sm",onClick:()=>aa(!0),children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]}),(0,d.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-3",children:[(0,d.jsx)("div",{className:"flex items-center justify-between",children:(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsxs)("span",{className:"text-xs font-semibold text-text-main flex items-center gap-1.5",children:[(0,d.jsx)(e.default,{className:"text-[16px] text-text-main",children:"layers"}),"Additional Models"]}),ad.length>0&&(0,d.jsx)("span",{className:"badge-neutral",children:ad.length})]})}),(0,d.jsx)("div",{className:"flex flex-col gap-1.5 p-2.5 bg-surface/40 border border-border rounded-lg",children:(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-[10rem_1fr_auto_auto] sm:items-center",children:[(0,d.jsx)("input",{type:"text",value:af,onChange:a=>ag(a.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:a=>"Enter"===a.key&&as()}),(0,d.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,d.jsx)("input",{type:"text",value:ah,onChange:a=>{let b=a.target.value;ai(b),ag(J(b.includes("/")?b.split("/")[0]:b,ad.map(a=>a.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:a=>"Enter"===a.key&&as()}),ah&&(0,d.jsx)("button",{onClick:()=>ai(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-[var(--danger)] rounded transition-colors",title:"Clear",children:(0,d.jsx)(e.default,{className:"text-[14px]",children:"close"})})]}),(0,d.jsx)("button",{onClick:()=>ak(!0),disabled:!m?.length,className:`w-full sm:w-auto rounded border px-2.5 py-1.5 text-xs transition-colors whitespace-nowrap sm:shrink-0 ${m?.length?"bg-surface border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${h().selectButton}`,children:"Select Model"}),(0,d.jsxs)(j.$n,{variant:"primary",size:"sm",onClick:as,disabled:!af.trim()||!ah.trim()||al,loading:al,className:" whitespace-nowrap",children:[(0,d.jsx)(e.default,{className:"text-[15px] mr-1",children:"add"}),"Add"]})]})}),0===ad.length?(0,d.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,d.jsx)(e.default,{className:"text-[20px] text-text-muted mb-1 opacity-60",children:"terminal"}),(0,d.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,d.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:ad.map(a=>{let b=a.model.includes("/")?a.model.split("/")[0]:a.name,c=ap===a.command;return(0,d.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,d.jsxs)("div",{className:"flex items-center gap-2.5 min-w-0",children:[(0,d.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,d.jsx)(H.A,{providerId:b,size:18,fallbackText:a.name.slice(0,2).toUpperCase()})}),(0,d.jsxs)("div",{className:"min-w-0 flex flex-col",children:[(0,d.jsx)("span",{className:"font-medium text-xs text-text-main truncate",children:a.name}),(0,d.jsx)("span",{className:"text-[11px] text-text-muted truncate font-mono",children:a.model})]})]}),(0,d.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,d.jsxs)("button",{onClick:()=>au(a.command),className:`flex items-center gap-1 px-2 py-1 rounded text-[11px] font-mono border transition-all ${c?"bg-green-500/10 border-green-500/30 text-[var(--pos)]":"bg-surface border-border text-text-muted hover:text-text-main hover:border-[var(--text-2)] cursor-pointer"}`,title:"Click to copy command",children:[(0,d.jsx)(e.default,{className:"text-[13px]",children:c?"check":"terminal"}),(0,d.jsx)("span",{className:"hidden md:inline",children:a.command}),(0,d.jsx)("span",{className:"md:hidden",children:"copy"})]}),(0,d.jsx)("button",{onClick:()=>at(a.name),disabled:an===a.name,className:"p-1 text-text-muted hover:text-[var(--danger)] opacity-0 group-hover:opacity-100 focus-visible:opacity-100 transition-opacity rounded",title:"Delete model",children:(0,d.jsx)(e.default,{className:"text-[15px]",children:"close"})})]})]},a.name)})})]})]})]}),V&&(0,d.jsx)(j.rq,{className:h().modelPicker,isOpen:V,onClose:()=>W(!1),onSelect:a=>{S(a.value),T||U(a.value),W(!1)},selectedModel:R,activeProviders:m,modelAliases:Z,title:"Select Model for Codex"}),X&&(0,d.jsx)(j.rq,{className:h().modelPicker,isOpen:X,onClose:()=>Y(!1),onSelect:a=>{U(a.value),Y(!1)},selectedModel:T,activeProviders:m,modelAliases:Z,title:"Select Subagent Model for Codex"}),aj&&(0,d.jsx)(j.rq,{className:h().modelPicker,isOpen:aj,onClose:()=>ak(!1),onSelect:a=>{ak(!1);let b=a?.value||a?.id;b&&(ai(b),ag(J(a?.provider||(b.includes("/")?b.split("/")[0]:b),ad.map(a=>a.name))))},selectedModel:ah,activeProviders:m,modelAliases:Z,title:"Select Model for Codex CLI"}),(0,d.jsx)(j.uR,{isOpen:_,onClose:()=>aa(!1),title:"Codex CLI - Manual Configuration",configs:(t=P&&P.trim()?P:n?"<API_KEY_FROM_DASHBOARD>":"sk_jrouter",u=T||R,[{filename:"~/.codex/config.toml",content:`# JRouter Configuration for Codex CLI
2
2
  model = "${R}"
3
- model_provider = "9router"
3
+ model_provider = "jrouter"
4
4
 
5
- [model_providers.9router]
6
- name = "9Router"
5
+ [model_providers.jrouter]
6
+ name = "JRouter"
7
7
  base_url = "${ax()}"
8
8
  wire_api = "responses"
9
9
 
10
- [model_providers.9router.http_headers]
10
+ [model_providers.jrouter.http_headers]
11
11
  Authorization = "Bearer ${t}"
12
12
 
13
13
  [agents]
14
14
  default_subagent_model = "${u}"
15
- `}])})]})}function L({tool:a,isExpanded:b,onToggle:c,baseUrl:g,hasActiveProviders:l,apiKeys:m,activeProviders:n,cloudEnabled:o,initialStatus:p,tunnelEnabled:q,tunnelPublicUrl:r,tailscaleEnabled:s,tailscaleUrl:t}){let u,w,x,z,[A,C]=(0,i.useState)(p||null),[E,F]=(0,i.useState)(!1),[G,H]=(0,i.useState)(!1),[I,J]=(0,i.useState)(!1),[K,M]=(0,i.useState)(null),[N,O]=(0,i.useState)(""),[P,Q]=(0,i.useState)([]),[R,S]=(0,i.useState)(""),[T,U]=(0,i.useState)(!1),[V,W]=(0,i.useState)({}),[X,Y]=(0,i.useState)(!1),[Z,$]=(0,i.useState)(!1),[_,aa]=(0,i.useState)("");(0,i.useRef)(!1);let ab=A?.settings?.customModels?.find(a=>a.id?.startsWith("custom:9Router"))?.baseUrl||"",ac=(()=>{if(!A?.installed)return null;let a=A.settings?.customModels?.find(a=>a.id?.startsWith("custom:9Router"));return a?D(a.baseUrl,{tunnelPublicUrl:r,tailscaleUrl:t,cloudUrl:o?"https://9router.com":null})?"configured":"other":"not_configured"})(),ad=async()=>{F(!0);try{let a=await fetch("/api/cli-tools/droid-settings"),b=await a.json();C(b)}catch(a){C({installed:!1,error:a.message})}finally{F(!1)}},ae=()=>{let a=_||g;return a.endsWith("/v1")?a:`${a}/v1`},af=()=>{let a=R.trim();!a||P.includes(a)||(Q(b=>[...b,a]),S(""))},ag=async()=>{H(!0),M(null);try{let a=N?.trim()||(m?.length>0?m[0].key:null)||(o?null:"sk_9router"),b=await fetch("/api/cli-tools/droid-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:ae(),apiKey:a,models:P,activeModel:P[0]||""})}),c=await b.json();b.ok?(v(ae(),{tunnelPublicUrl:r,tailscaleUrl:t}),M({type:"success",text:"Settings applied successfully!"}),ad()):M({type:"error",text:c.error||"Failed to apply settings"})}catch(a){M({type:"error",text:a.message})}finally{H(!1)}},ah=async()=>{J(!0),M(null);try{let a=await fetch("/api/cli-tools/droid-settings",{method:"DELETE"}),b=await a.json();a.ok?(M({type:"success",text:"Settings reset successfully!"}),Q([]),ad()):M({type:"error",text:b.error||"Failed to reset settings"})}catch(a){M({type:"error",text:a.message})}finally{J(!1)}};return(0,d.jsxs)(j.Zp,{padding:"none",className:h().panel,children:[(0,d.jsxs)("div",{className:h().panelHeader,onClick:c,children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,d.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,d.jsx)(k.default,{src:"/providers/droid.png",alt:a.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:a=>{a.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,d.jsx)("h3",{className:"font-medium text-sm",children:a.name}),"configured"===ac&&(0,d.jsx)(f.A,{variant:"success",className:h().status,children:"Connected"}),"not_configured"===ac&&(0,d.jsx)(f.A,{variant:"warning",className:h().status,children:"Not configured"}),"other"===ac&&(0,d.jsx)(f.A,{variant:"default",dot:!1,className:h().status,children:"Other"})]}),(0,d.jsx)("p",{className:"text-xs text-text-muted truncate",children:a.description})]})]}),(0,d.jsx)(e.default,{className:`text-text-muted text-[20px] transition-transform ${b?"rotate-180":""}`,children:"expand_more"})]}),b&&(0,d.jsxs)("div",{className:h().body,children:[E&&(0,d.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,d.jsx)(e.default,{className:"animate-spin",children:"progress_activity"}),(0,d.jsx)("span",{children:"Checking Factory Droid CLI..."})]}),!E&&A&&!A.installed&&(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,d.jsxs)("div",{className:`flex flex-col gap-3 p-4 border ${h().notice} ${h().warning}`,children:[(0,d.jsxs)("div",{className:"flex items-start gap-3",children:[(0,d.jsx)(e.default,{className:"text-[var(--warn)]",children:"warning"}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("p",{className:"font-medium text-[var(--warn)]",children:"Factory Droid CLI not detected locally"}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if 9router is deployed on a remote server."})]})]}),(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2 sm:pl-9",children:[(0,d.jsxs)(j.$n,{variant:"secondary",size:"sm",onClick:()=>Y(!0),children:[(0,d.jsx)(e.default,{className:"text-[18px] mr-1",children:"content_copy"}),"Manual Config"]}),(0,d.jsxs)(j.$n,{variant:"outline",size:"sm",onClick:()=>$(!Z),children:[(0,d.jsx)(e.default,{className:"text-[18px] mr-1",children:Z?"expand_less":"help"}),Z?"Hide":"How to Install"]})]})]}),Z&&(0,d.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,d.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,d.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-text-muted mb-1",children:"macOS / Linux / Windows:"}),(0,d.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,d.jsxs)("p",{className:"text-text-muted",children:["After installation, run ",(0,d.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"droid"})," to verify."]})]})]})]}),!E&&A?.installed&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Select Endpoint"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(y,{value:_||((u=_||g).endsWith("/v1")?u:`${u}/v1`),onChange:aa,requiresExternalUrl:a.requiresExternalUrl,tunnelEnabled:q,tunnelPublicUrl:r,tailscaleEnabled:s,tailscaleUrl:t,currentUrl:ab})]}),A?.settings?.customModels?.find(a=>a.id?.startsWith("custom:9Router"))?.baseUrl&&(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Current"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.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:A.settings.customModels.find(a=>a.id?.startsWith("custom:9Router")).baseUrl})]}),(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"API Key"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(B,{value:N,onChange:O,apiKeys:m,cloudEnabled:o})]}),(0,d.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,d.jsxs)("span",{className:`sm:text-right ${h().fieldLabel}`,children:["Models ",P.length>0&&(0,d.jsxs)("span",{className:"text-text-main",children:["(",P.length,")"]})]}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsxs)("div",{className:"flex-1 flex flex-col gap-1",children:[P.length>0&&(0,d.jsx)("div",{className:"flex flex-col gap-0.5 mb-1",children:P.map(a=>(0,d.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 bg-bg-secondary rounded border border-border",children:[(0,d.jsx)("span",{className:"flex-1 text-xs font-mono truncate",children:a}),(0,d.jsx)("button",{onClick:()=>Q(b=>b.filter(b=>b!==a)),className:"text-text-muted hover:text-[var(--danger)] transition-colors shrink-0",title:"Remove",children:(0,d.jsx)(e.default,{className:"text-[12px]",children:"close"})})]},a))}),(0,d.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,d.jsx)("input",{type:"text",value:R,onChange:a=>S(a.target.value),onKeyDown:a=>{"Enter"===a.key&&(a.preventDefault(),af())},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,d.jsx)("button",{onClick:()=>U(!0),disabled:!l,className:`px-2 py-1.5 rounded border text-xs shrink-0 ${l?"bg-surface border-border hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${h().selectButton}`,children:"Select"}),(0,d.jsx)("button",{onClick:af,disabled:!R.trim(),className:"px-2 py-1.5 rounded border bg-surface border-border hover:border-[var(--text-2)] text-xs shrink-0 disabled:opacity-50",title:"Add model",children:(0,d.jsx)(e.default,{className:"text-[14px]",children:"add"})})]})]})]})]}),K&&(0,d.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===K.type?h().positive:h().danger}`,children:[(0,d.jsx)(e.default,{className:"text-[14px]",children:"success"===K.type?"check_circle":"error"}),(0,d.jsx)("span",{children:K.text})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,d.jsxs)(j.$n,{variant:"primary",size:"sm",onClick:ag,disabled:0===P.length,loading:G,children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"save"}),"Apply"]}),(0,d.jsxs)(j.$n,{variant:"outline",size:"sm",onClick:ah,disabled:!A?.has9Router,loading:I,children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,d.jsxs)(j.$n,{variant:"ghost",size:"sm",onClick:()=>Y(!0),children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),T&&(0,d.jsx)(j.rq,{className:h().modelPicker,isOpen:T,onClose:()=>U(!1),onSelect:a=>{!a.value||P.includes(a.value)||(Q(b=>[...b,a.value]),U(!1))},selectedModel:null,activeProviders:n,modelAliases:V,title:"Select Model for Factory Droid"}),(0,d.jsx)(j.uR,{isOpen:X,onClose:()=>Y(!1),title:"Factory Droid - Manual Configuration",configs:(w=N&&N.trim()?N:o?"<API_KEY_FROM_DASHBOARD>":"sk_9router",x={customModels:P.map((a,b)=>({model:a,id:`custom:9Router-${b}`,index:b,baseUrl:ae(),apiKey:w,displayName:a,maxOutputTokens:131072,noImageSupport:!1,provider:"openai"}))},z="u">typeof navigator&&navigator.platform,[{filename:z?.toLowerCase().includes("win")?"%USERPROFILE%\\.factory\\settings.json":"~/.factory/settings.json",content:JSON.stringify(x,null,2)}])})]})}function M({tool:a,isExpanded:b,onToggle:c,baseUrl:g,hasActiveProviders:l,apiKeys:m,activeProviders:n,cloudEnabled:o,initialStatus:p,tunnelEnabled:q,tunnelPublicUrl:r,tailscaleEnabled:s,tailscaleUrl:t}){let u,w,[x,z]=(0,i.useState)(p||null),[A,C]=(0,i.useState)(!1),[E,F]=(0,i.useState)(!1),[G,H]=(0,i.useState)(!1),[I,J]=(0,i.useState)(null),[K,L]=(0,i.useState)(""),[N,O]=(0,i.useState)(""),[P,Q]=(0,i.useState)({}),[R,S]=(0,i.useState)(null),[T,U]=(0,i.useState)(!1),[V,W]=(0,i.useState)({}),[X,Y]=(0,i.useState)(!1),[Z,$]=(0,i.useState)("");(0,i.useRef)(!1);let _=x?.settings?.models?.providers?.["9router"]?.baseUrl||"",aa=(()=>{if(!x?.installed)return null;let a=x.settings?.models?.providers?.["9router"];return a?D(a.baseUrl,{tunnelPublicUrl:r,tailscaleUrl:t})?"configured":"other":"not_configured"})(),ab=async()=>{C(!0);try{let a=await fetch("/api/cli-tools/openclaw-settings"),b=await a.json();z(b)}catch(a){z({installed:!1,error:a.message})}finally{C(!1)}},ac=()=>{let a=Z||"http://127.0.0.1:20128";return a.endsWith("/v1")?a:`${a}/v1`},ad=async()=>{F(!0),J(null);try{let a=K?.trim()||(m?.length>0?m[0].key:null)||(o?null:"sk_9router"),b=await fetch("/api/cli-tools/openclaw-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:ac(),apiKey:a,model:N,agentModels:P})}),c=await b.json();b.ok?(v(ac(),{tunnelPublicUrl:r,tailscaleUrl:t}),J({type:"success",text:"Settings applied successfully!"}),ab()):J({type:"error",text:c.error||"Failed to apply settings"})}catch(a){J({type:"error",text:a.message})}finally{F(!1)}},ae=async()=>{H(!0),J(null);try{let a=await fetch("/api/cli-tools/openclaw-settings",{method:"DELETE"}),b=await a.json();a.ok?(J({type:"success",text:"Settings reset successfully!"}),O(""),L(""),ab()):J({type:"error",text:b.error||"Failed to reset settings"})}catch(a){J({type:"error",text:a.message})}finally{H(!1)}};return(0,d.jsxs)(j.Zp,{padding:"none",className:h().panel,children:[(0,d.jsxs)("div",{className:h().panelHeader,onClick:c,children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,d.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,d.jsx)(k.default,{src:"/providers/openclaw.png",alt:a.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:a=>{a.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,d.jsx)("h3",{className:"font-medium text-sm",children:a.name}),"configured"===aa&&(0,d.jsx)(f.A,{variant:"success",className:h().status,children:"Connected"}),"not_configured"===aa&&(0,d.jsx)(f.A,{variant:"warning",className:h().status,children:"Not configured"}),"other"===aa&&(0,d.jsx)(f.A,{variant:"default",dot:!1,className:h().status,children:"Other"})]}),(0,d.jsx)("p",{className:"text-xs text-text-muted truncate",children:a.description})]})]}),(0,d.jsx)(e.default,{className:`text-text-muted text-[20px] transition-transform ${b?"rotate-180":""}`,children:"expand_more"})]}),b&&(0,d.jsxs)("div",{className:h().body,children:[A&&(0,d.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,d.jsx)(e.default,{className:"animate-spin",children:"progress_activity"}),(0,d.jsx)("span",{children:"Checking Open Claw CLI..."})]}),!A&&x&&!x.installed&&(0,d.jsx)("div",{className:"flex flex-col gap-4",children:(0,d.jsxs)("div",{className:`flex flex-col gap-3 p-4 border ${h().notice} ${h().warning}`,children:[(0,d.jsxs)("div",{className:"flex items-start gap-3",children:[(0,d.jsx)(e.default,{className:"text-[var(--warn)]",children:"warning"}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("p",{className:"font-medium text-[var(--warn)]",children:"Open Claw CLI not detected locally"}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if 9router is deployed on a remote server."})]})]}),(0,d.jsx)("div",{className:"flex flex-wrap items-center gap-2 sm:pl-9",children:(0,d.jsxs)(j.$n,{variant:"secondary",size:"sm",onClick:()=>Y(!0),children:[(0,d.jsx)(e.default,{className:"text-[18px] mr-1",children:"content_copy"}),"Manual Config"]})})]})}),!A&&x?.installed&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Select Endpoint"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(y,{value:Z||((u=Z||"http://127.0.0.1:20128").endsWith("/v1")?u:`${u}/v1`),onChange:$,requiresExternalUrl:a.requiresExternalUrl,tunnelEnabled:q,tunnelPublicUrl:r,tailscaleEnabled:s,tailscaleUrl:t,currentUrl:_})]}),x?.settings?.models?.providers?.["9router"]?.baseUrl&&(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Current"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.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:x.settings.models.providers["9router"].baseUrl})]}),(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"API Key"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(B,{value:K,onChange:L,apiKeys:m,cloudEnabled:o})]}),(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Default Model"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,d.jsx)("input",{type:"text",value:N,onChange:a=>O(a.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"}),N&&(0,d.jsx)("button",{onClick:()=>O(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-[var(--danger)] rounded transition-colors",title:"Clear",children:(0,d.jsx)(e.default,{className:"text-[14px]",children:"close"})})]}),(0,d.jsx)("button",{onClick:()=>{S(null),U(!0)},disabled:!l,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 ${l?"bg-surface border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${h().selectButton}`,children:"Select"})]}),(x.agents||[]).filter(a=>a.agentDir).map(a=>(0,d.jsxs)("div",{className:"flex items-center gap-2 pl-4",children:[(0,d.jsxs)("span",{className:"w-32 shrink-0 text-xs text-text-main text-right truncate",title:a.name||a.id,children:["Agent ",a.name||a.id]}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,d.jsx)("input",{type:"text",value:P[a.id]||"",onChange:b=>Q(c=>({...c,[a.id]:b.target.value})),placeholder:`default (${N||"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[a.id]&&(0,d.jsx)("button",{onClick:()=>Q(b=>({...b,[a.id]:""})),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-[var(--danger)] rounded transition-colors",title:"Clear",children:(0,d.jsx)(e.default,{className:"text-[14px]",children:"close"})})]}),(0,d.jsx)("button",{onClick:()=>{S(a.id),U(!0)},disabled:!l,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 ${l?"bg-surface border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${h().selectButton}`,children:"Select"})]},a.id))]}),I&&(0,d.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===I.type?h().positive:h().danger}`,children:[(0,d.jsx)(e.default,{className:"text-[14px]",children:"success"===I.type?"check_circle":"error"}),(0,d.jsx)("span",{children:I.text})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,d.jsxs)(j.$n,{variant:"primary",size:"sm",onClick:ad,disabled:!N,loading:E,children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"save"}),"Apply"]}),(0,d.jsxs)(j.$n,{variant:"outline",size:"sm",onClick:ae,disabled:!x?.has9Router,loading:G,children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,d.jsxs)(j.$n,{variant:"ghost",size:"sm",onClick:()=>Y(!0),children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),T&&(0,d.jsx)(j.rq,{className:h().modelPicker,isOpen:T,onClose:()=>U(!1),onSelect:a=>{R?(Q(b=>({...b,[R]:a.value})),S(null)):O(a.value),U(!1)},selectedModel:N,activeProviders:n,modelAliases:V,title:"Select Model for Open Claw"}),(0,d.jsx)(j.uR,{isOpen:X,onClose:()=>Y(!1),title:"Open Claw - Manual Configuration",configs:(w=K&&K.trim()?K:o?"<API_KEY_FROM_DASHBOARD>":"sk_9router",[{filename:"~/.openclaw/openclaw.json",content:JSON.stringify({agents:{defaults:{model:{primary:`9router/${N||"provider/model-id"}`}}},models:{providers:{"9router":{baseUrl:ac(),apiKey:w,api:"openai-completions",models:[{id:N||"provider/model-id",name:(N||"provider/model-id").split("/").pop()}]}}}},null,2)}])})]})}var N=c(62911);let O="/api/cli-tools/hermes-settings",P=N.dM.hermes?.roles||[];function Q({tool:a,isExpanded:b,onToggle:c,baseUrl:g,hasActiveProviders:l,apiKeys:m,activeProviders:n,cloudEnabled:o,initialStatus:p,tunnelEnabled:r,tunnelPublicUrl:s,tailscaleEnabled:t,tailscaleUrl:u}){let w,x,z,A,C,E,[F,G]=(0,i.useState)(p||null),[H,I]=(0,i.useState)(!1),[J,K]=(0,i.useState)(!1),[L,M]=(0,i.useState)(!1),[N,R]=(0,i.useState)(null),[S,T]=(0,i.useState)(""),[U,V]=(0,i.useState)(""),[W,X]=(0,i.useState)({}),[Y,Z]=(0,i.useState)("default"),[$,_]=(0,i.useState)(!1),[aa,ab]=(0,i.useState)({}),[ac,ad]=(0,i.useState)(!1),[ae,af]=(0,i.useState)(""),[ag,ah]=(0,i.useState)([]),[ai,aj]=(0,i.useState)("default"),[ak,al]=(0,i.useState)(!1),[am,an]=(0,i.useState)(""),[ao,ap]=(0,i.useState)(!1),[aq,ar]=(0,i.useState)(""),as=(0,i.useRef)(!1),at=F?.settings?.model?.base_url||"",au=(()=>{if(!F?.installed)return null;let a=F.settings?.model;return a?.base_url?D(a.base_url,{tunnelPublicUrl:s,tailscaleUrl:u})?"configured":"other":"not_configured"})(),av={configured:"bg-[var(--pos)]",other:"bg-[var(--text-2)]",not_configured:"bg-[var(--warn)]"},aw={configured:"Connected",other:"Other endpoint",not_configured:"Not configured"},ax=async()=>{try{let a=await fetch("/api/cli-tools/hermes-profiles"),b=await a.json();a.ok&&ah(b.profiles||[])}catch(a){console.log("Error fetching hermes profiles:",a)}},ay=async a=>{try{await navigator.clipboard.writeText(a),an(a),setTimeout(()=>an(""),2e3)}catch(a){console.log("Copy failed",a)}},az=async(a=ai)=>{I(!0);try{let b=await fetch(`${O}?profile=${encodeURIComponent(a)}`),c=await b.json();b.ok?G(c):(R({type:"error",text:c.error||"Failed to load Hermes settings"}),404===b.status&&"default"!==a&&(ax(),aj("default"),as.current=!1,await az("default")))}catch(a){G({installed:!1,error:a.message})}finally{I(!1)}},aA=()=>{let a=ae||"http://127.0.0.1:20128";return a.endsWith("/v1")?a:`${a}/v1`},aB=()=>S?.trim()||(m?.length>0?m[0].key:null)||(o?null:"sk_9router"),aC=a=>"default"===a?"default profile":`profile "${a}"`,aD=async()=>{K(!0),R(null);try{let a=await fetch(O,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({profile:ai,baseUrl:aA(),apiKey:aB(),selections:[{role:"default",model:U},...Object.entries(W).filter(([,a])=>a?.trim()).map(([a,b])=>({role:a,model:b.trim()}))],audio:{enabled:ao,model:aq.trim()}})}),b=await a.json();a.ok?(v(aA(),{tunnelPublicUrl:s,tailscaleUrl:u}),R({type:"success",text:`Settings applied to ${aC(ai)}!`}),az(),ax()):R({type:"error",text:b.error||"Failed to apply settings"})}catch(a){R({type:"error",text:a.message})}finally{K(!1)}},aE=async()=>{let a=aA();if(!(D(a,{tunnelPublicUrl:s,tailscaleUrl:u})||q().some(b=>(b.baseUrl||"").replace(/\/+$/,"")===a.replace(/\/+$/,""))))return void R({type:"error",text:`"${a}" is not a 9router endpoint. Select the local, tunnel, Tailscale or a saved 9router endpoint before applying to all profiles.`});al(!0),R(null);try{let b=await fetch(O,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({applyToAll:!0,baseUrl:a,apiKey:aB(),model:U})}),c=await b.json();if(b.ok&&c.bulk){v(a,{tunnelPublicUrl:s,tailscaleUrl:u});let b=(c.results||[]).filter(a=>"updated"!==a.status);if(0===b.length)R({type:"success",text:`Endpoint and API key applied to ${c.updated} profile(s).`});else{let a=b.map(a=>`${a.profile} — ${a.reason||a.status}`).join("; ");R({type:c.updated>0?"success":"error",text:`Updated ${c.updated} profile(s), skipped ${b.length}: ${a}`})}ax(),az()}else R({type:"error",text:c.error||"Failed to apply settings"})}catch(a){R({type:"error",text:a.message})}finally{al(!1)}},aF=async()=>{M(!0),R(null);try{let a=await fetch(O,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({profile:ai})}),b=await a.json();a.ok?(R({type:"success",text:`Settings reset for ${aC(ai)}!`}),V(""),X({}),ap(!1),ar(""),az(),ax()):R({type:"error",text:b.error||"Failed to reset settings"})}catch(a){R({type:"error",text:a.message})}finally{M(!1)}},aG=a=>{Z(a),_(!0)};return(0,d.jsxs)(j.Zp,{padding:"none",className:h().panel,children:[(0,d.jsxs)("div",{className:h().panelHeader,onClick:c,children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,d.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,d.jsx)(k.default,{src:"/providers/hermes.png",alt:a.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:a=>{a.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,d.jsx)("h3",{className:"font-medium text-sm",children:a.name}),"configured"===au&&(0,d.jsx)(f.A,{variant:"success",className:h().status,children:"Connected"}),"not_configured"===au&&(0,d.jsx)(f.A,{variant:"warning",className:h().status,children:"Not configured"}),"other"===au&&(0,d.jsx)(f.A,{variant:"default",dot:!1,className:h().status,children:"Other"}),"default"!==ai&&(0,d.jsx)(f.A,{variant:"default",dot:!1,className:`${h().status} font-mono`,title:"Hermes profile shown below",children:ai})]}),(0,d.jsx)("p",{className:"text-xs text-text-muted truncate",children:a.description})]})]}),(0,d.jsx)(e.default,{className:`text-text-muted text-[20px] transition-transform ${b?"rotate-180":""}`,children:"expand_more"})]}),b&&(0,d.jsxs)("div",{className:h().body,children:[H&&(0,d.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,d.jsx)(e.default,{className:"animate-spin",children:"progress_activity"}),(0,d.jsx)("span",{children:"Checking Hermes Agent..."})]}),!H&&F&&!F.installed&&(0,d.jsx)("div",{className:"flex flex-col gap-4",children:(0,d.jsxs)("div",{className:`flex flex-col gap-3 p-4 border ${h().notice} ${h().warning}`,children:[(0,d.jsxs)("div",{className:"flex items-start gap-3",children:[(0,d.jsx)(e.default,{className:"text-[var(--warn)]",children:"warning"}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("p",{className:"font-medium text-[var(--warn)]",children:"Hermes Agent not detected locally"}),(0,d.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,d.jsx)("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 pl-0 sm:pl-9",children:(0,d.jsxs)(j.$n,{variant:"secondary",size:"sm",onClick:()=>ad(!0),className:"w-full sm:w-auto",children:[(0,d.jsx)(e.default,{className:"text-[18px] mr-1",children:"content_copy"}),"Manual Config"]})})]})}),!H&&F?.installed&&(0,d.jsxs)(d.Fragment,{children:[ag.length>1&&(0,d.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,d.jsx)("span",{className:`${h().fieldLabel} mr-1`,children:"Profile"}),ag.map(a=>{let b=a.name===ai,c=a.has9Router||a.baseUrl&&D(a.baseUrl,{tunnelPublicUrl:s,tailscaleUrl:u})?"configured":a.baseUrl?"other":"not_configured";return(0,d.jsxs)("button",{onClick:()=>{var b;(b=a.name)!==ai&&(aj(b),as.current=!1,R(null),af(""),ap(!1),ar(""),az(b))},"aria-pressed":b,title:a.isDefault?`Default profile: ${aw[c]}`:`${a.command}: ${aw[c]}`,className:`flex items-center gap-1.5 px-2 py-1 rounded border text-xs transition-colors ${h().selectButton} ${b?"border-[var(--accent-line)] bg-surface-2 text-text-main cursor-pointer":"bg-surface border-border text-text-muted hover:text-text-main hover:border-border-hover cursor-pointer"}`,children:[(0,d.jsx)("span",{className:`size-1.5 rounded-full shrink-0 ${av[c]}`}),(0,d.jsx)("span",{className:"font-medium",children:a.displayName||a.name}),a.displayName&&!a.isDefault&&(0,d.jsx)("span",{className:"font-mono text-[10px] opacity-60",children:a.name})]},a.name)})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[(0,d.jsx)(e.default,{className:"text-[14px] shrink-0",children:"terminal"}),(0,d.jsx)("code",{className:"px-1.5 py-0.5 bg-surface/60 rounded font-mono text-[11px]",children:ag.find(a=>a.name===ai)?.command||"hermes"}),(0,d.jsx)("button",{onClick:()=>ay(ag.find(a=>a.name===ai)?.command||"hermes"),className:`p-0.5 rounded transition-colors ${am===(ag.find(a=>a.name===ai)?.command||"hermes")?"text-[var(--pos)]":"text-text-muted hover:text-text-main"}`,title:"Copy command",children:(0,d.jsx)(e.default,{className:"text-[14px]",children:am===(ag.find(a=>a.name===ai)?.command||"hermes")?"check":"content_copy"})}),(0,d.jsx)("span",{className:"hidden sm:inline",children:"Every profile runs as its own agent with its own model."})]})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Select Endpoint"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(y,{value:ae||aA(),onChange:af,requiresExternalUrl:a.requiresExternalUrl,tunnelEnabled:r,tunnelPublicUrl:s,tailscaleEnabled:t,tailscaleUrl:u,currentUrl:at})]}),F?.settings?.model?.base_url&&(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Current"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.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:F.settings.model.base_url})]}),(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"API Key"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(B,{value:S,onChange:T,apiKeys:m,cloudEnabled:o})]}),(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Default Model"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,d.jsx)("input",{type:"text",value:U,onChange:a=>V(a.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"}),U&&(0,d.jsx)("button",{onClick:()=>V(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-[var(--danger)] rounded transition-colors",title:"Clear",children:(0,d.jsx)(e.default,{className:"text-[14px]",children:"close"})})]}),(0,d.jsx)("button",{onClick:()=>aG("default"),disabled:!l,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 ${l?"bg-surface border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${h().selectButton}`,children:"Select"})]}),(0,d.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,d.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Audio STT"}),(0,d.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.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,d.jsx)("input",{type:"checkbox",checked:ao,onChange:a=>ap(a.target.checked),className:"w-3.5 h-3.5 accent-primary cursor-pointer shrink-0"}),(0,d.jsx)("span",{children:"Transcribe voice & audio via 9router (per-profile)"})]}),(0,d.jsx)("span",{})]}),ao&&(0,d.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,d.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"STT Model"}),(0,d.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,d.jsx)("input",{type:"text",value:aq,onChange:a=>ar(a.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"}),aq&&(0,d.jsx)("button",{onClick:()=>ar(""),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,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,d.jsx)("button",{onClick:()=>aG("stt"),disabled:!l,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 ${l?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"})]}),(0,d.jsxs)("details",{className:"group",children:[(0,d.jsxs)("summary",{className:"cursor-pointer select-none text-xs font-semibold text-text-main hover:text-text-main transition-colors",children:[(0,d.jsx)(e.default,{className:"align-middle text-[16px] text-text-muted group-open:rotate-90 transition-transform",children:"chevron_right"}),"Model Roles (optional)"]}),(0,d.jsxs)("div",{className:"mt-2 flex flex-col gap-1.5",children:[P.map(a=>(0,d.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,d.jsx)("span",{className:`truncate sm:text-right ${h().fieldLabel}`,title:a.label,children:a.label}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,d.jsx)("input",{type:"text",value:W[a.id]||"",onChange:b=>X(c=>({...c,[a.id]:b.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"}),W[a.id]&&(0,d.jsx)("button",{onClick:()=>X(b=>({...b,[a.id]:""})),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-[var(--danger)] rounded transition-colors",title:"Clear",children:(0,d.jsx)(e.default,{className:"text-[14px]",children:"close"})})]}),(0,d.jsx)("button",{onClick:()=>aG(a.id),disabled:!l,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 ${l?"bg-surface border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${h().selectButton}`,children:"Select"})]},a.id)),(0,d.jsx)("p",{className:"text-xs text-text-muted",children:"Empty roles inherit the default model."})]})]})]}),N&&(0,d.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===N.type?h().positive:h().danger}`,children:[(0,d.jsx)(e.default,{className:"text-[14px]",children:"success"===N.type?"check_circle":"error"}),(0,d.jsx)("span",{children:N.text})]}),(0,d.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2",children:[(0,d.jsxs)(j.$n,{variant:"primary",size:"sm",onClick:aD,disabled:!U||ao&&!aq.trim(),title:ao&&!aq.trim()?"Select an STT model first":void 0,loading:J,className:"w-full sm:w-auto",children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"save"}),"Apply"]}),ag.length>1&&(0,d.jsxs)(j.$n,{variant:"secondary",size:"sm",onClick:aE,loading:ak,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,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"groups"}),"Apply to All Profiles"]}),(0,d.jsxs)(j.$n,{variant:"outline",size:"sm",onClick:aF,disabled:!F?.has9Router&&!F?.has9RouterStt,loading:L,className:"w-full sm:w-auto",children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,d.jsxs)(j.$n,{variant:"ghost",size:"sm",onClick:()=>ad(!0),className:"w-full sm:w-auto",children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),$&&(0,d.jsx)(j.rq,{catalogContext:"invocation",className:h().modelPicker,isOpen:$,onClose:()=>_(!1),onSelect:a=>{"stt"===Y?ar(a.value):"default"===Y?V(a.value):X(b=>({...b,[Y]:a.value})),_(!1)},selectedModel:"stt"===Y?aq:"default"===Y?U:W[Y]||"",activeProviders:n,modelAliases:aa,kindFilter:"stt"===Y?"stt":void 0,title:"stt"===Y?"Select STT Model — audio transcription via 9router":`Select Model for Hermes Agent${"default"!==Y?` — ${P.find(a=>a.id===Y)?.label||Y}`:""}`}),(0,d.jsx)(j.uR,{isOpen:ac,onClose:()=>ad(!1),title:"Hermes Agent - Manual Configuration",configs:(w=S&&S.trim()?S:o?"<API_KEY_FROM_DASHBOARD>":"sk_9router",x=aA(),z="default"===ai?"~/.hermes":`~/.hermes/profiles/${ai}`,A=ag.find(a=>a.name===ai)?.command||"hermes",C=`# Run this profile: ${A}
15
+ `}])})]})}function L({tool:a,isExpanded:b,onToggle:c,baseUrl:g,hasActiveProviders:l,apiKeys:m,activeProviders:n,cloudEnabled:o,initialStatus:p,tunnelEnabled:q,tunnelPublicUrl:r,tailscaleEnabled:s,tailscaleUrl:t}){let u,w,x,z,[A,C]=(0,i.useState)(p||null),[E,F]=(0,i.useState)(!1),[G,H]=(0,i.useState)(!1),[I,J]=(0,i.useState)(!1),[K,M]=(0,i.useState)(null),[N,O]=(0,i.useState)(""),[P,Q]=(0,i.useState)([]),[R,S]=(0,i.useState)(""),[T,U]=(0,i.useState)(!1),[V,W]=(0,i.useState)({}),[X,Y]=(0,i.useState)(!1),[Z,$]=(0,i.useState)(!1),[_,aa]=(0,i.useState)("");(0,i.useRef)(!1);let ab=A?.settings?.customModels?.find(a=>a.id?.startsWith("custom:9Router"))?.baseUrl||"",ac=(()=>{if(!A?.installed)return null;let a=A.settings?.customModels?.find(a=>a.id?.startsWith("custom:9Router"));return a?D(a.baseUrl,{tunnelPublicUrl:r,tailscaleUrl:t,cloudUrl:o?"https://9router.com":null})?"configured":"other":"not_configured"})(),ad=async()=>{F(!0);try{let a=await fetch("/api/cli-tools/droid-settings"),b=await a.json();C(b)}catch(a){C({installed:!1,error:a.message})}finally{F(!1)}},ae=()=>{let a=_||g;return a.endsWith("/v1")?a:`${a}/v1`},af=()=>{let a=R.trim();!a||P.includes(a)||(Q(b=>[...b,a]),S(""))},ag=async()=>{H(!0),M(null);try{let a=N?.trim()||(m?.length>0?m[0].key:null)||(o?null:"sk_jrouter"),b=await fetch("/api/cli-tools/droid-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:ae(),apiKey:a,models:P,activeModel:P[0]||""})}),c=await b.json();b.ok?(v(ae(),{tunnelPublicUrl:r,tailscaleUrl:t}),M({type:"success",text:"Settings applied successfully!"}),ad()):M({type:"error",text:c.error||"Failed to apply settings"})}catch(a){M({type:"error",text:a.message})}finally{H(!1)}},ah=async()=>{J(!0),M(null);try{let a=await fetch("/api/cli-tools/droid-settings",{method:"DELETE"}),b=await a.json();a.ok?(M({type:"success",text:"Settings reset successfully!"}),Q([]),ad()):M({type:"error",text:b.error||"Failed to reset settings"})}catch(a){M({type:"error",text:a.message})}finally{J(!1)}};return(0,d.jsxs)(j.Zp,{padding:"none",className:h().panel,children:[(0,d.jsxs)("div",{className:h().panelHeader,onClick:c,children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,d.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,d.jsx)(k.default,{src:"/providers/droid.png",alt:a.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:a=>{a.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,d.jsx)("h3",{className:"font-medium text-sm",children:a.name}),"configured"===ac&&(0,d.jsx)(f.A,{variant:"success",className:h().status,children:"Connected"}),"not_configured"===ac&&(0,d.jsx)(f.A,{variant:"warning",className:h().status,children:"Not configured"}),"other"===ac&&(0,d.jsx)(f.A,{variant:"default",dot:!1,className:h().status,children:"Other"})]}),(0,d.jsx)("p",{className:"text-xs text-text-muted truncate",children:a.description})]})]}),(0,d.jsx)(e.default,{className:`text-text-muted text-[20px] transition-transform ${b?"rotate-180":""}`,children:"expand_more"})]}),b&&(0,d.jsxs)("div",{className:h().body,children:[E&&(0,d.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,d.jsx)(e.default,{className:"animate-spin",children:"progress_activity"}),(0,d.jsx)("span",{children:"Checking Factory Droid CLI..."})]}),!E&&A&&!A.installed&&(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,d.jsxs)("div",{className:`flex flex-col gap-3 p-4 border ${h().notice} ${h().warning}`,children:[(0,d.jsxs)("div",{className:"flex items-start gap-3",children:[(0,d.jsx)(e.default,{className:"text-[var(--warn)]",children:"warning"}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("p",{className:"font-medium text-[var(--warn)]",children:"Factory Droid CLI not detected locally"}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if JRouter is deployed on a remote server."})]})]}),(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2 sm:pl-9",children:[(0,d.jsxs)(j.$n,{variant:"secondary",size:"sm",onClick:()=>Y(!0),children:[(0,d.jsx)(e.default,{className:"text-[18px] mr-1",children:"content_copy"}),"Manual Config"]}),(0,d.jsxs)(j.$n,{variant:"outline",size:"sm",onClick:()=>$(!Z),children:[(0,d.jsx)(e.default,{className:"text-[18px] mr-1",children:Z?"expand_less":"help"}),Z?"Hide":"How to Install"]})]})]}),Z&&(0,d.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,d.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,d.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-text-muted mb-1",children:"macOS / Linux / Windows:"}),(0,d.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,d.jsxs)("p",{className:"text-text-muted",children:["After installation, run ",(0,d.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"droid"})," to verify."]})]})]})]}),!E&&A?.installed&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Select Endpoint"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(y,{value:_||((u=_||g).endsWith("/v1")?u:`${u}/v1`),onChange:aa,requiresExternalUrl:a.requiresExternalUrl,tunnelEnabled:q,tunnelPublicUrl:r,tailscaleEnabled:s,tailscaleUrl:t,currentUrl:ab})]}),A?.settings?.customModels?.find(a=>a.id?.startsWith("custom:9Router"))?.baseUrl&&(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Current"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.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:A.settings.customModels.find(a=>a.id?.startsWith("custom:9Router")).baseUrl})]}),(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"API Key"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(B,{value:N,onChange:O,apiKeys:m,cloudEnabled:o})]}),(0,d.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,d.jsxs)("span",{className:`sm:text-right ${h().fieldLabel}`,children:["Models ",P.length>0&&(0,d.jsxs)("span",{className:"text-text-main",children:["(",P.length,")"]})]}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsxs)("div",{className:"flex-1 flex flex-col gap-1",children:[P.length>0&&(0,d.jsx)("div",{className:"flex flex-col gap-0.5 mb-1",children:P.map(a=>(0,d.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 bg-bg-secondary rounded border border-border",children:[(0,d.jsx)("span",{className:"flex-1 text-xs font-mono truncate",children:a}),(0,d.jsx)("button",{onClick:()=>Q(b=>b.filter(b=>b!==a)),className:"text-text-muted hover:text-[var(--danger)] transition-colors shrink-0",title:"Remove",children:(0,d.jsx)(e.default,{className:"text-[12px]",children:"close"})})]},a))}),(0,d.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,d.jsx)("input",{type:"text",value:R,onChange:a=>S(a.target.value),onKeyDown:a=>{"Enter"===a.key&&(a.preventDefault(),af())},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,d.jsx)("button",{onClick:()=>U(!0),disabled:!l,className:`px-2 py-1.5 rounded border text-xs shrink-0 ${l?"bg-surface border-border hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${h().selectButton}`,children:"Select"}),(0,d.jsx)("button",{onClick:af,disabled:!R.trim(),className:"px-2 py-1.5 rounded border bg-surface border-border hover:border-[var(--text-2)] text-xs shrink-0 disabled:opacity-50",title:"Add model",children:(0,d.jsx)(e.default,{className:"text-[14px]",children:"add"})})]})]})]})]}),K&&(0,d.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===K.type?h().positive:h().danger}`,children:[(0,d.jsx)(e.default,{className:"text-[14px]",children:"success"===K.type?"check_circle":"error"}),(0,d.jsx)("span",{children:K.text})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,d.jsxs)(j.$n,{variant:"primary",size:"sm",onClick:ag,disabled:0===P.length,loading:G,children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"save"}),"Apply"]}),(0,d.jsxs)(j.$n,{variant:"outline",size:"sm",onClick:ah,disabled:!A?.hasJRouter,loading:I,children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,d.jsxs)(j.$n,{variant:"ghost",size:"sm",onClick:()=>Y(!0),children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),T&&(0,d.jsx)(j.rq,{className:h().modelPicker,isOpen:T,onClose:()=>U(!1),onSelect:a=>{!a.value||P.includes(a.value)||(Q(b=>[...b,a.value]),U(!1))},selectedModel:null,activeProviders:n,modelAliases:V,title:"Select Model for Factory Droid"}),(0,d.jsx)(j.uR,{isOpen:X,onClose:()=>Y(!1),title:"Factory Droid - Manual Configuration",configs:(w=N&&N.trim()?N:o?"<API_KEY_FROM_DASHBOARD>":"sk_jrouter",x={customModels:P.map((a,b)=>({model:a,id:`custom:JRouter-${b}`,index:b,baseUrl:ae(),apiKey:w,displayName:a,maxOutputTokens:131072,noImageSupport:!1,provider:"openai"}))},z="u">typeof navigator&&navigator.platform,[{filename:z?.toLowerCase().includes("win")?"%USERPROFILE%\\.factory\\settings.json":"~/.factory/settings.json",content:JSON.stringify(x,null,2)}])})]})}function M({tool:a,isExpanded:b,onToggle:c,baseUrl:g,hasActiveProviders:l,apiKeys:m,activeProviders:n,cloudEnabled:o,initialStatus:p,tunnelEnabled:q,tunnelPublicUrl:r,tailscaleEnabled:s,tailscaleUrl:t}){let u,w,[x,z]=(0,i.useState)(p||null),[A,C]=(0,i.useState)(!1),[E,F]=(0,i.useState)(!1),[G,H]=(0,i.useState)(!1),[I,J]=(0,i.useState)(null),[K,L]=(0,i.useState)(""),[N,O]=(0,i.useState)(""),[P,Q]=(0,i.useState)({}),[R,S]=(0,i.useState)(null),[T,U]=(0,i.useState)(!1),[V,W]=(0,i.useState)({}),[X,Y]=(0,i.useState)(!1),[Z,$]=(0,i.useState)("");(0,i.useRef)(!1);let _=x?.settings?.models?.providers?.jrouter?.baseUrl||"",aa=(()=>{if(!x?.installed)return null;let a=x.settings?.models?.providers?.jrouter;return a?D(a.baseUrl,{tunnelPublicUrl:r,tailscaleUrl:t})?"configured":"other":"not_configured"})(),ab=async()=>{C(!0);try{let a=await fetch("/api/cli-tools/openclaw-settings"),b=await a.json();z(b)}catch(a){z({installed:!1,error:a.message})}finally{C(!1)}},ac=()=>{let a=Z||"http://127.0.0.1:20128";return a.endsWith("/v1")?a:`${a}/v1`},ad=async()=>{F(!0),J(null);try{let a=K?.trim()||(m?.length>0?m[0].key:null)||(o?null:"sk_jrouter"),b=await fetch("/api/cli-tools/openclaw-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:ac(),apiKey:a,model:N,agentModels:P})}),c=await b.json();b.ok?(v(ac(),{tunnelPublicUrl:r,tailscaleUrl:t}),J({type:"success",text:"Settings applied successfully!"}),ab()):J({type:"error",text:c.error||"Failed to apply settings"})}catch(a){J({type:"error",text:a.message})}finally{F(!1)}},ae=async()=>{H(!0),J(null);try{let a=await fetch("/api/cli-tools/openclaw-settings",{method:"DELETE"}),b=await a.json();a.ok?(J({type:"success",text:"Settings reset successfully!"}),O(""),L(""),ab()):J({type:"error",text:b.error||"Failed to reset settings"})}catch(a){J({type:"error",text:a.message})}finally{H(!1)}};return(0,d.jsxs)(j.Zp,{padding:"none",className:h().panel,children:[(0,d.jsxs)("div",{className:h().panelHeader,onClick:c,children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,d.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,d.jsx)(k.default,{src:"/providers/openclaw.png",alt:a.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:a=>{a.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,d.jsx)("h3",{className:"font-medium text-sm",children:a.name}),"configured"===aa&&(0,d.jsx)(f.A,{variant:"success",className:h().status,children:"Connected"}),"not_configured"===aa&&(0,d.jsx)(f.A,{variant:"warning",className:h().status,children:"Not configured"}),"other"===aa&&(0,d.jsx)(f.A,{variant:"default",dot:!1,className:h().status,children:"Other"})]}),(0,d.jsx)("p",{className:"text-xs text-text-muted truncate",children:a.description})]})]}),(0,d.jsx)(e.default,{className:`text-text-muted text-[20px] transition-transform ${b?"rotate-180":""}`,children:"expand_more"})]}),b&&(0,d.jsxs)("div",{className:h().body,children:[A&&(0,d.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,d.jsx)(e.default,{className:"animate-spin",children:"progress_activity"}),(0,d.jsx)("span",{children:"Checking Open Claw CLI..."})]}),!A&&x&&!x.installed&&(0,d.jsx)("div",{className:"flex flex-col gap-4",children:(0,d.jsxs)("div",{className:`flex flex-col gap-3 p-4 border ${h().notice} ${h().warning}`,children:[(0,d.jsxs)("div",{className:"flex items-start gap-3",children:[(0,d.jsx)(e.default,{className:"text-[var(--warn)]",children:"warning"}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("p",{className:"font-medium text-[var(--warn)]",children:"Open Claw CLI not detected locally"}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if JRouter is deployed on a remote server."})]})]}),(0,d.jsx)("div",{className:"flex flex-wrap items-center gap-2 sm:pl-9",children:(0,d.jsxs)(j.$n,{variant:"secondary",size:"sm",onClick:()=>Y(!0),children:[(0,d.jsx)(e.default,{className:"text-[18px] mr-1",children:"content_copy"}),"Manual Config"]})})]})}),!A&&x?.installed&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Select Endpoint"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(y,{value:Z||((u=Z||"http://127.0.0.1:20128").endsWith("/v1")?u:`${u}/v1`),onChange:$,requiresExternalUrl:a.requiresExternalUrl,tunnelEnabled:q,tunnelPublicUrl:r,tailscaleEnabled:s,tailscaleUrl:t,currentUrl:_})]}),x?.settings?.models?.providers?.jrouter?.baseUrl&&(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Current"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.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:x.settings.models.providers.jrouter.baseUrl})]}),(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"API Key"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(B,{value:K,onChange:L,apiKeys:m,cloudEnabled:o})]}),(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Default Model"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,d.jsx)("input",{type:"text",value:N,onChange:a=>O(a.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"}),N&&(0,d.jsx)("button",{onClick:()=>O(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-[var(--danger)] rounded transition-colors",title:"Clear",children:(0,d.jsx)(e.default,{className:"text-[14px]",children:"close"})})]}),(0,d.jsx)("button",{onClick:()=>{S(null),U(!0)},disabled:!l,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 ${l?"bg-surface border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${h().selectButton}`,children:"Select"})]}),(x.agents||[]).filter(a=>a.agentDir).map(a=>(0,d.jsxs)("div",{className:"flex items-center gap-2 pl-4",children:[(0,d.jsxs)("span",{className:"w-32 shrink-0 text-xs text-text-main text-right truncate",title:a.name||a.id,children:["Agent ",a.name||a.id]}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,d.jsx)("input",{type:"text",value:P[a.id]||"",onChange:b=>Q(c=>({...c,[a.id]:b.target.value})),placeholder:`default (${N||"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[a.id]&&(0,d.jsx)("button",{onClick:()=>Q(b=>({...b,[a.id]:""})),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-[var(--danger)] rounded transition-colors",title:"Clear",children:(0,d.jsx)(e.default,{className:"text-[14px]",children:"close"})})]}),(0,d.jsx)("button",{onClick:()=>{S(a.id),U(!0)},disabled:!l,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 ${l?"bg-surface border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${h().selectButton}`,children:"Select"})]},a.id))]}),I&&(0,d.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===I.type?h().positive:h().danger}`,children:[(0,d.jsx)(e.default,{className:"text-[14px]",children:"success"===I.type?"check_circle":"error"}),(0,d.jsx)("span",{children:I.text})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,d.jsxs)(j.$n,{variant:"primary",size:"sm",onClick:ad,disabled:!N,loading:E,children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"save"}),"Apply"]}),(0,d.jsxs)(j.$n,{variant:"outline",size:"sm",onClick:ae,disabled:!x?.hasJRouter,loading:G,children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,d.jsxs)(j.$n,{variant:"ghost",size:"sm",onClick:()=>Y(!0),children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),T&&(0,d.jsx)(j.rq,{className:h().modelPicker,isOpen:T,onClose:()=>U(!1),onSelect:a=>{R?(Q(b=>({...b,[R]:a.value})),S(null)):O(a.value),U(!1)},selectedModel:N,activeProviders:n,modelAliases:V,title:"Select Model for Open Claw"}),(0,d.jsx)(j.uR,{isOpen:X,onClose:()=>Y(!1),title:"Open Claw - Manual Configuration",configs:(w=K&&K.trim()?K:o?"<API_KEY_FROM_DASHBOARD>":"sk_jrouter",[{filename:"~/.openclaw/openclaw.json",content:JSON.stringify({agents:{defaults:{model:{primary:`jrouter/${N||"provider/model-id"}`}}},models:{providers:{jrouter:{baseUrl:ac(),apiKey:w,api:"openai-completions",models:[{id:N||"provider/model-id",name:(N||"provider/model-id").split("/").pop()}]}}}},null,2)}])})]})}var N=c(62911);let O="/api/cli-tools/hermes-settings",P=N.dM.hermes?.roles||[];function Q({tool:a,isExpanded:b,onToggle:c,baseUrl:g,hasActiveProviders:l,apiKeys:m,activeProviders:n,cloudEnabled:o,initialStatus:p,tunnelEnabled:r,tunnelPublicUrl:s,tailscaleEnabled:t,tailscaleUrl:u}){let w,x,z,A,C,E,[F,G]=(0,i.useState)(p||null),[H,I]=(0,i.useState)(!1),[J,K]=(0,i.useState)(!1),[L,M]=(0,i.useState)(!1),[N,R]=(0,i.useState)(null),[S,T]=(0,i.useState)(""),[U,V]=(0,i.useState)(""),[W,X]=(0,i.useState)({}),[Y,Z]=(0,i.useState)("default"),[$,_]=(0,i.useState)(!1),[aa,ab]=(0,i.useState)({}),[ac,ad]=(0,i.useState)(!1),[ae,af]=(0,i.useState)(""),[ag,ah]=(0,i.useState)([]),[ai,aj]=(0,i.useState)("default"),[ak,al]=(0,i.useState)(!1),[am,an]=(0,i.useState)(""),[ao,ap]=(0,i.useState)(!1),[aq,ar]=(0,i.useState)(""),as=(0,i.useRef)(!1),at=F?.settings?.model?.base_url||"",au=(()=>{if(!F?.installed)return null;let a=F.settings?.model;return a?.base_url?D(a.base_url,{tunnelPublicUrl:s,tailscaleUrl:u})?"configured":"other":"not_configured"})(),av={configured:"bg-[var(--pos)]",other:"bg-[var(--text-2)]",not_configured:"bg-[var(--warn)]"},aw={configured:"Connected",other:"Other endpoint",not_configured:"Not configured"},ax=async()=>{try{let a=await fetch("/api/cli-tools/hermes-profiles"),b=await a.json();a.ok&&ah(b.profiles||[])}catch(a){console.log("Error fetching hermes profiles:",a)}},ay=async a=>{try{await navigator.clipboard.writeText(a),an(a),setTimeout(()=>an(""),2e3)}catch(a){console.log("Copy failed",a)}},az=async(a=ai)=>{I(!0);try{let b=await fetch(`${O}?profile=${encodeURIComponent(a)}`),c=await b.json();b.ok?G(c):(R({type:"error",text:c.error||"Failed to load Hermes settings"}),404===b.status&&"default"!==a&&(ax(),aj("default"),as.current=!1,await az("default")))}catch(a){G({installed:!1,error:a.message})}finally{I(!1)}},aA=()=>{let a=ae||"http://127.0.0.1:20128";return a.endsWith("/v1")?a:`${a}/v1`},aB=()=>S?.trim()||(m?.length>0?m[0].key:null)||(o?null:"sk_jrouter"),aC=a=>"default"===a?"default profile":`profile "${a}"`,aD=async()=>{K(!0),R(null);try{let a=await fetch(O,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({profile:ai,baseUrl:aA(),apiKey:aB(),selections:[{role:"default",model:U},...Object.entries(W).filter(([,a])=>a?.trim()).map(([a,b])=>({role:a,model:b.trim()}))],audio:{enabled:ao,model:aq.trim()}})}),b=await a.json();a.ok?(v(aA(),{tunnelPublicUrl:s,tailscaleUrl:u}),R({type:"success",text:`Settings applied to ${aC(ai)}!`}),az(),ax()):R({type:"error",text:b.error||"Failed to apply settings"})}catch(a){R({type:"error",text:a.message})}finally{K(!1)}},aE=async()=>{let a=aA();if(!(D(a,{tunnelPublicUrl:s,tailscaleUrl:u})||q().some(b=>(b.baseUrl||"").replace(/\/+$/,"")===a.replace(/\/+$/,""))))return void R({type:"error",text:`"${a}" is not a jrouter endpoint. Select the local, tunnel, Tailscale or a saved jrouter endpoint before applying to all profiles.`});al(!0),R(null);try{let b=await fetch(O,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({applyToAll:!0,baseUrl:a,apiKey:aB(),model:U})}),c=await b.json();if(b.ok&&c.bulk){v(a,{tunnelPublicUrl:s,tailscaleUrl:u});let b=(c.results||[]).filter(a=>"updated"!==a.status);if(0===b.length)R({type:"success",text:`Endpoint and API key applied to ${c.updated} profile(s).`});else{let a=b.map(a=>`${a.profile} — ${a.reason||a.status}`).join("; ");R({type:c.updated>0?"success":"error",text:`Updated ${c.updated} profile(s), skipped ${b.length}: ${a}`})}ax(),az()}else R({type:"error",text:c.error||"Failed to apply settings"})}catch(a){R({type:"error",text:a.message})}finally{al(!1)}},aF=async()=>{M(!0),R(null);try{let a=await fetch(O,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({profile:ai})}),b=await a.json();a.ok?(R({type:"success",text:`Settings reset for ${aC(ai)}!`}),V(""),X({}),ap(!1),ar(""),az(),ax()):R({type:"error",text:b.error||"Failed to reset settings"})}catch(a){R({type:"error",text:a.message})}finally{M(!1)}},aG=a=>{Z(a),_(!0)};return(0,d.jsxs)(j.Zp,{padding:"none",className:h().panel,children:[(0,d.jsxs)("div",{className:h().panelHeader,onClick:c,children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,d.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,d.jsx)(k.default,{src:"/providers/hermes.png",alt:a.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:a=>{a.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,d.jsx)("h3",{className:"font-medium text-sm",children:a.name}),"configured"===au&&(0,d.jsx)(f.A,{variant:"success",className:h().status,children:"Connected"}),"not_configured"===au&&(0,d.jsx)(f.A,{variant:"warning",className:h().status,children:"Not configured"}),"other"===au&&(0,d.jsx)(f.A,{variant:"default",dot:!1,className:h().status,children:"Other"}),"default"!==ai&&(0,d.jsx)(f.A,{variant:"default",dot:!1,className:`${h().status} font-mono`,title:"Hermes profile shown below",children:ai})]}),(0,d.jsx)("p",{className:"text-xs text-text-muted truncate",children:a.description})]})]}),(0,d.jsx)(e.default,{className:`text-text-muted text-[20px] transition-transform ${b?"rotate-180":""}`,children:"expand_more"})]}),b&&(0,d.jsxs)("div",{className:h().body,children:[H&&(0,d.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,d.jsx)(e.default,{className:"animate-spin",children:"progress_activity"}),(0,d.jsx)("span",{children:"Checking Hermes Agent..."})]}),!H&&F&&!F.installed&&(0,d.jsx)("div",{className:"flex flex-col gap-4",children:(0,d.jsxs)("div",{className:`flex flex-col gap-3 p-4 border ${h().notice} ${h().warning}`,children:[(0,d.jsxs)("div",{className:"flex items-start gap-3",children:[(0,d.jsx)(e.default,{className:"text-[var(--warn)]",children:"warning"}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("p",{className:"font-medium text-[var(--warn)]",children:"Hermes Agent not detected locally"}),(0,d.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,d.jsx)("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 pl-0 sm:pl-9",children:(0,d.jsxs)(j.$n,{variant:"secondary",size:"sm",onClick:()=>ad(!0),className:"w-full sm:w-auto",children:[(0,d.jsx)(e.default,{className:"text-[18px] mr-1",children:"content_copy"}),"Manual Config"]})})]})}),!H&&F?.installed&&(0,d.jsxs)(d.Fragment,{children:[ag.length>1&&(0,d.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,d.jsx)("span",{className:`${h().fieldLabel} mr-1`,children:"Profile"}),ag.map(a=>{let b=a.name===ai,c=a.hasJRouter||a.baseUrl&&D(a.baseUrl,{tunnelPublicUrl:s,tailscaleUrl:u})?"configured":a.baseUrl?"other":"not_configured";return(0,d.jsxs)("button",{onClick:()=>{var b;(b=a.name)!==ai&&(aj(b),as.current=!1,R(null),af(""),ap(!1),ar(""),az(b))},"aria-pressed":b,title:a.isDefault?`Default profile: ${aw[c]}`:`${a.command}: ${aw[c]}`,className:`flex items-center gap-1.5 px-2 py-1 rounded border text-xs transition-colors ${h().selectButton} ${b?"border-[var(--accent-line)] bg-surface-2 text-text-main cursor-pointer":"bg-surface border-border text-text-muted hover:text-text-main hover:border-border-hover cursor-pointer"}`,children:[(0,d.jsx)("span",{className:`size-1.5 rounded-full shrink-0 ${av[c]}`}),(0,d.jsx)("span",{className:"font-medium",children:a.displayName||a.name}),a.displayName&&!a.isDefault&&(0,d.jsx)("span",{className:"font-mono text-[10px] opacity-60",children:a.name})]},a.name)})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[(0,d.jsx)(e.default,{className:"text-[14px] shrink-0",children:"terminal"}),(0,d.jsx)("code",{className:"px-1.5 py-0.5 bg-surface/60 rounded font-mono text-[11px]",children:ag.find(a=>a.name===ai)?.command||"hermes"}),(0,d.jsx)("button",{onClick:()=>ay(ag.find(a=>a.name===ai)?.command||"hermes"),className:`p-0.5 rounded transition-colors ${am===(ag.find(a=>a.name===ai)?.command||"hermes")?"text-[var(--pos)]":"text-text-muted hover:text-text-main"}`,title:"Copy command",children:(0,d.jsx)(e.default,{className:"text-[14px]",children:am===(ag.find(a=>a.name===ai)?.command||"hermes")?"check":"content_copy"})}),(0,d.jsx)("span",{className:"hidden sm:inline",children:"Every profile runs as its own agent with its own model."})]})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Select Endpoint"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(y,{value:ae||aA(),onChange:af,requiresExternalUrl:a.requiresExternalUrl,tunnelEnabled:r,tunnelPublicUrl:s,tailscaleEnabled:t,tailscaleUrl:u,currentUrl:at})]}),F?.settings?.model?.base_url&&(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Current"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.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:F.settings.model.base_url})]}),(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"API Key"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(B,{value:S,onChange:T,apiKeys:m,cloudEnabled:o})]}),(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Default Model"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,d.jsx)("input",{type:"text",value:U,onChange:a=>V(a.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"}),U&&(0,d.jsx)("button",{onClick:()=>V(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-[var(--danger)] rounded transition-colors",title:"Clear",children:(0,d.jsx)(e.default,{className:"text-[14px]",children:"close"})})]}),(0,d.jsx)("button",{onClick:()=>aG("default"),disabled:!l,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 ${l?"bg-surface border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${h().selectButton}`,children:"Select"})]}),(0,d.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,d.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Audio STT"}),(0,d.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsxs)("label",{className:"flex items-center gap-2 text-xs text-text-muted cursor-pointer",title:"Route Hermes voice & audio transcription through jrouter's /v1/audio/transcriptions — usage is tracked on this instance",children:[(0,d.jsx)("input",{type:"checkbox",checked:ao,onChange:a=>ap(a.target.checked),className:"w-3.5 h-3.5 accent-primary cursor-pointer shrink-0"}),(0,d.jsx)("span",{children:"Transcribe voice & audio via jrouter (per-profile)"})]}),(0,d.jsx)("span",{})]}),ao&&(0,d.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,d.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"STT Model"}),(0,d.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,d.jsx)("input",{type:"text",value:aq,onChange:a=>ar(a.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"}),aq&&(0,d.jsx)("button",{onClick:()=>ar(""),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,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,d.jsx)("button",{onClick:()=>aG("stt"),disabled:!l,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 ${l?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"})]}),(0,d.jsxs)("details",{className:"group",children:[(0,d.jsxs)("summary",{className:"cursor-pointer select-none text-xs font-semibold text-text-main hover:text-text-main transition-colors",children:[(0,d.jsx)(e.default,{className:"align-middle text-[16px] text-text-muted group-open:rotate-90 transition-transform",children:"chevron_right"}),"Model Roles (optional)"]}),(0,d.jsxs)("div",{className:"mt-2 flex flex-col gap-1.5",children:[P.map(a=>(0,d.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,d.jsx)("span",{className:`truncate sm:text-right ${h().fieldLabel}`,title:a.label,children:a.label}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,d.jsx)("input",{type:"text",value:W[a.id]||"",onChange:b=>X(c=>({...c,[a.id]:b.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"}),W[a.id]&&(0,d.jsx)("button",{onClick:()=>X(b=>({...b,[a.id]:""})),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-[var(--danger)] rounded transition-colors",title:"Clear",children:(0,d.jsx)(e.default,{className:"text-[14px]",children:"close"})})]}),(0,d.jsx)("button",{onClick:()=>aG(a.id),disabled:!l,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 ${l?"bg-surface border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${h().selectButton}`,children:"Select"})]},a.id)),(0,d.jsx)("p",{className:"text-xs text-text-muted",children:"Empty roles inherit the default model."})]})]})]}),N&&(0,d.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===N.type?h().positive:h().danger}`,children:[(0,d.jsx)(e.default,{className:"text-[14px]",children:"success"===N.type?"check_circle":"error"}),(0,d.jsx)("span",{children:N.text})]}),(0,d.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2",children:[(0,d.jsxs)(j.$n,{variant:"primary",size:"sm",onClick:aD,disabled:!U||ao&&!aq.trim(),title:ao&&!aq.trim()?"Select an STT model first":void 0,loading:J,className:"w-full sm:w-auto",children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"save"}),"Apply"]}),ag.length>1&&(0,d.jsxs)(j.$n,{variant:"secondary",size:"sm",onClick:aE,loading:ak,title:"Set the endpoint and API key on every profile that routes through jrouter. Each profile keeps its own model.",className:"w-full sm:w-auto",children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"groups"}),"Apply to All Profiles"]}),(0,d.jsxs)(j.$n,{variant:"outline",size:"sm",onClick:aF,disabled:!F?.hasJRouter&&!F?.hasJRouterStt,loading:L,className:"w-full sm:w-auto",children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,d.jsxs)(j.$n,{variant:"ghost",size:"sm",onClick:()=>ad(!0),className:"w-full sm:w-auto",children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),$&&(0,d.jsx)(j.rq,{catalogContext:"invocation",className:h().modelPicker,isOpen:$,onClose:()=>_(!1),onSelect:a=>{"stt"===Y?ar(a.value):"default"===Y?V(a.value):X(b=>({...b,[Y]:a.value})),_(!1)},selectedModel:"stt"===Y?aq:"default"===Y?U:W[Y]||"",activeProviders:n,modelAliases:aa,kindFilter:"stt"===Y?"stt":void 0,title:"stt"===Y?"Select STT Model — audio transcription via jrouter":`Select Model for Hermes Agent${"default"!==Y?` — ${P.find(a=>a.id===Y)?.label||Y}`:""}`}),(0,d.jsx)(j.uR,{isOpen:ac,onClose:()=>ad(!1),title:"Hermes Agent - Manual Configuration",configs:(w=S&&S.trim()?S:o?"<API_KEY_FROM_DASHBOARD>":"sk_jrouter",x=aA(),z="default"===ai?"~/.hermes":`~/.hermes/profiles/${ai}`,A=ag.find(a=>a.name===ai)?.command||"hermes",C=`# Run this profile: ${A}
16
16
  model:
17
17
  default: "${U||"provider/model-id"}"
18
18
  provider: "custom"
@@ -37,67 +37,67 @@ ${E.map(([a,b])=>` ${a}:
37
37
  base_url: "${x}"
38
38
  api_key: \${OPENAI_API_KEY}
39
39
  `),[{filename:`${z}/config.yaml`,content:C},{filename:`${z}/.env`,content:`OPENAI_API_KEY=${w}
40
- `}])})]})}var R=c(29225),S=c(50377);function T({toolId:a,tool:b,isExpanded:c,onToggle:f,baseUrl:g,apiKeys:l,activeProviders:m=[],cloudEnabled:n=!1,tunnelEnabled:o=!1}){let[p,q]=(0,i.useState)(null),[r,s]=(0,i.useState)(!1),[t,u]=(0,i.useState)(""),[v,w]=(0,i.useState)(()=>l?.length>0?l[0].key:""),x=a=>{let b=v&&v.trim()?v:n?"your-api-key":"sk_9router",c=g||"http://localhost:20128",d=c.endsWith("/v1")?c:`${c}/v1`;return a.replace(/\{\{baseUrl\}\}/g,d).replace(/\{\{apiKey\}\}/g,b).replace(/\{\{model\}\}/g,t||"provider/model-id")},{copy:y}=(0,S.C)(),z=async(a,b)=>{await y(x(a),`toolcard-${b}`),q(b),setTimeout(()=>q(null),2e3)},A=m.length>0,C=()=>(!b.requiresExternalUrl||!!n||!!o)&&(!b.requiresCloud||!!n);return(0,d.jsxs)(j.Zp,{padding:"none",className:h().panel,children:[(0,d.jsxs)("div",{className:h().panelHeader,onClick:f,children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,d.jsx)("div",{className:"size-8 rounded-lg flex items-center justify-center shrink-0",children:(()=>{if(b.image)return(0,d.jsx)(k.default,{src:b.image,alt:b.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:a=>{a.target.style.display="none"},loading:"lazy",decoding:"async"});if(b.icon)return(0,d.jsx)(e.default,{className:"text-xl",style:{color:b.color},children:b.icon});let c=(0,R.HY)(a);return c?(0,d.jsx)(k.default,{src:c,alt:b.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:b=>{(0,R.Kw)(a),b.target.style.display="none"},loading:"lazy",decoding:"async"}):(0,d.jsx)("span",{className:"text-xs font-bold",style:{color:b.color},children:(a||"?").slice(0,2).toUpperCase()})})()}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("h3",{className:"font-medium text-sm",children:b.name}),(0,d.jsx)("p",{className:"text-xs text-text-muted truncate",children:b.description})]})]}),(0,d.jsx)(e.default,{className:`text-text-muted text-[20px] transition-transform ${c?"rotate-180":""}`,children:"expand_more"})]}),c&&(0,d.jsx)("div",{className:h().body,children:b.guideSteps?(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:[b.notes&&0!==b.notes.length?(0,d.jsx)("div",{className:"flex flex-col gap-2 mb-4",children:b.notes.map((a,b)=>{if("cloudCheck"===a.type&&(n||o))return null;let c="warning"===a.type,f="cloudCheck"===a.type&&!n&&!o,g=h().neutral,i="text-text-muted",j="text-text-muted",k="info";return c?(g=h().warning,i="text-[var(--warn)]",j="text-[var(--warn)]",k="warning"):f&&(g=h().danger,i="text-[var(--danger)]",j="text-[var(--danger)]",k="error"),(0,d.jsxs)("div",{className:`flex items-start gap-3 p-3 rounded-lg border ${g}`,children:[(0,d.jsx)(e.default,{className:`text-lg ${j}`,children:k}),(0,d.jsx)("p",{className:`text-xs ${i}`,children:a.text})]},b)})}):null,C()&&b.guideSteps.map(a=>(0,d.jsxs)("div",{className:"flex items-start gap-4",children:[(0,d.jsx)("div",{className:"size-8 rounded-full flex items-center justify-center shrink-0 text-sm font-semibold text-white",style:{backgroundColor:b.color},children:a.step}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("p",{className:"font-medium text-text",children:a.title}),a.desc&&(0,d.jsx)("p",{className:"text-xs text-text-muted mt-0.5",children:a.desc}),"apiKeySelector"===a.type&&(0,d.jsx)("div",{className:"mt-2 flex flex-col sm:flex-row sm:items-center gap-2",children:(0,d.jsx)(B,{value:v,onChange:w,apiKeys:l,cloudEnabled:n,className:"flex-1"})}),"modelSelector"===a.type&&(0,d.jsxs)("div",{className:"mt-2 flex flex-col sm:flex-row sm:items-center gap-2",children:[(0,d.jsx)("input",{type:"text",value:t,onChange:a=>u(a.target.value),placeholder:"provider/model-id",className:"w-full min-w-0 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,d.jsx)("button",{onClick:()=>s(!0),disabled:!A,className:`shrink-0 px-3 py-2 rounded-lg border text-sm transition-colors ${A?"bg-bg-secondary border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${h().selectButton}`,children:"Select Model"}),t&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("button",{onClick:()=>z(t,"model"),className:h().iconButton,"aria-label":"Copy model",children:(0,d.jsx)(e.default,{className:"text-lg",children:"model"===p?"check":"content_copy"})}),(0,d.jsx)("button",{onClick:()=>u(""),className:"p-2 text-text-muted hover:text-[var(--danger)] rounded transition-colors",title:"Clear",children:(0,d.jsx)(e.default,{className:"text-lg",children:"close"})})]})]}),a.value&&(0,d.jsxs)("div",{className:"mt-2 flex flex-col sm:flex-row sm:items-center gap-2",children:[(0,d.jsx)("code",{className:"w-full min-w-0 sm:w-auto flex-1 px-3 py-2 bg-bg-secondary rounded-lg text-sm font-mono border border-border truncate",children:x(a.value)}),a.copyable&&(0,d.jsx)("button",{onClick:()=>z(a.value,`${a.step}-${a.title}`),className:h().iconButton,"aria-label":"Copy value",children:(0,d.jsx)(e.default,{className:"text-lg",children:p===`${a.step}-${a.title}`?"check":"content_copy"})})]})]})]},a.step)),C()&&b.codeBlock&&(0,d.jsxs)("div",{className:"mt-2",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,d.jsx)("span",{className:"text-xs text-text-muted uppercase tracking-wide",children:b.codeBlock.language}),(0,d.jsxs)("button",{onClick:()=>z(b.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,d.jsx)(e.default,{className:"text-sm",children:"codeblock"===p?"check":"content_copy"}),"codeblock"===p?"Copied!":"Copy"]})]}),(0,d.jsx)("pre",{className:"p-4 bg-bg-secondary rounded-lg border border-border overflow-x-auto",children:(0,d.jsx)("code",{className:"whitespace-pre",children:x(b.codeBlock.code)})})]})]}):(0,d.jsx)("p",{className:"text-text-muted text-sm",children:"Coming soon..."})}),r&&(0,d.jsx)(j.rq,{className:h().modelPicker,isOpen:r,onClose:()=>s(!1),onSelect:a=>{u(a.value)},selectedModel:t,activeProviders:m,title:"Select Model"})]})}function U({tool:a,isExpanded:b,onToggle:c,baseUrl:g,apiKeys:l,activeProviders:m,cloudEnabled:n,initialStatus:o,tunnelEnabled:p,tunnelPublicUrl:q,tailscaleEnabled:r,tailscaleUrl:s}){let t,u,w,x,z,[A,C]=(0,i.useState)(o||null),[E,F]=(0,i.useState)(!1),[G,H]=(0,i.useState)(!1),[I,J]=(0,i.useState)(!1),[K,L]=(0,i.useState)(null),[M,N]=(0,i.useState)(!1),[O,P]=(0,i.useState)(""),[Q,R]=(0,i.useState)(""),[S,T]=(0,i.useState)(""),[V,W]=(0,i.useState)(!1),[X,Y]=(0,i.useState)(!1),[Z,$]=(0,i.useState)({}),[_,aa]=(0,i.useState)(!1),[ab,ac]=(0,i.useState)(""),[ad,ae]=(0,i.useState)([]),[af,ag]=(0,i.useState)(""),ah=(0,i.useRef)([]),ai=async a=>{try{let b=O&&O.trim()||n?O:"sk_9router",c=a.includes(af)?af:a[0]||"";await fetch("/api/cli-tools/opencode-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:al(),apiKey:b,models:a,activeModel:c,subagentModel:S})})}catch(a){console.log("Error saving models:",a)}},aj=A?.config?.provider?.["9router"]?.options?.baseURL||"",ak=A?.installed?A.config&&A.has9Router?D(A.config?.provider?.["9router"]?.options?.baseURL||"",{tunnelPublicUrl:q,tailscaleUrl:s})?"configured":"other":"not_configured":null,al=()=>{let a=ab||g;return a.endsWith("/v1")?a:`${a}/v1`},am=async()=>{F(!0);try{let a=await fetch("/api/cli-tools/opencode-settings"),b=await a.json();C(b)}catch(a){C({installed:!1,error:a.message})}finally{F(!1)}},an=async()=>{H(!0),L(null);try{let a=O&&O.trim()||n?O:"sk_9router",b=await fetch("/api/cli-tools/opencode-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:al(),apiKey:a,models:ad,activeModel:""===af?"":af||ad[0],subagentModel:S})}),c=await b.json();b.ok?(v(al(),{tunnelPublicUrl:q,tailscaleUrl:s}),L({type:"success",text:"Settings applied successfully!"}),am()):L({type:"error",text:c.error||"Failed to apply settings"})}catch(a){L({type:"error",text:a.message})}finally{H(!1)}},ao=async()=>{J(!0),L(null);try{let a=await fetch("/api/cli-tools/opencode-settings",{method:"DELETE"}),b=await a.json();a.ok?(L({type:"success",text:"Settings reset successfully!"}),R(""),T(""),ae([]),ag(""),am()):L({type:"error",text:b.error||"Failed to reset settings"})}catch(a){L({type:"error",text:a.message})}finally{J(!1)}};return(0,d.jsxs)(j.Zp,{padding:"none",className:h().panel,children:[(0,d.jsxs)("div",{className:h().panelHeader,onClick:c,children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,d.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,d.jsx)(k.default,{src:"/providers/opencode.png",alt:a.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:a=>{a.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,d.jsx)("h3",{className:"font-medium text-sm",children:a.name}),"configured"===ak&&(0,d.jsx)(f.A,{variant:"success",className:h().status,children:"Connected"}),"not_configured"===ak&&(0,d.jsx)(f.A,{variant:"warning",className:h().status,children:"Not configured"}),"other"===ak&&(0,d.jsx)(f.A,{variant:"default",dot:!1,className:h().status,children:"Other"})]}),(0,d.jsx)("p",{className:"text-xs text-text-muted truncate",children:a.description})]})]}),(0,d.jsx)(e.default,{className:`text-text-muted text-[20px] transition-transform ${b?"rotate-180":""}`,children:"expand_more"})]}),b&&(0,d.jsxs)("div",{className:h().body,children:[E&&(0,d.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,d.jsx)(e.default,{className:"animate-spin",children:"progress_activity"}),(0,d.jsx)("span",{children:"Checking OpenCode CLI..."})]}),!E&&A&&!A.installed&&(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,d.jsxs)("div",{className:`flex flex-col gap-3 p-4 border ${h().notice} ${h().warning}`,children:[(0,d.jsxs)("div",{className:"flex items-start gap-3",children:[(0,d.jsx)(e.default,{className:"text-[var(--warn)]",children:"warning"}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("p",{className:"font-medium text-[var(--warn)]",children:"OpenCode CLI not detected locally"}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if 9router is deployed on a remote server."})]})]}),(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2 sm:pl-9",children:[(0,d.jsxs)(j.$n,{variant:"secondary",size:"sm",onClick:()=>aa(!0),children:[(0,d.jsx)(e.default,{className:"text-[18px] mr-1",children:"content_copy"}),"Manual Config"]}),(0,d.jsxs)(j.$n,{variant:"outline",size:"sm",onClick:()=>N(!M),children:[(0,d.jsx)(e.default,{className:"text-[18px] mr-1",children:M?"expand_less":"help"}),M?"Hide":"How to Install"]})]})]}),M&&(0,d.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,d.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,d.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-text-muted mb-1",children:"macOS / Linux:"}),(0,d.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,d.jsxs)("p",{className:"text-text-muted",children:["After installation, run ",(0,d.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"opencode"})," to verify."]})]})]})]}),!E&&A?.installed&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Select Endpoint"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(y,{value:ab||ab||`${g}/v1`,onChange:ac,requiresExternalUrl:a.requiresExternalUrl,tunnelEnabled:p,tunnelPublicUrl:q,tailscaleEnabled:r,tailscaleUrl:s,currentUrl:aj})]}),A?.config?.provider?.["9router"]?.options?.baseURL&&(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Current"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.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:A.config.provider["9router"].options.baseURL})]}),(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"API Key"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(B,{value:O,onChange:P,apiKeys:l,cloudEnabled:n})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-start sm:gap-2",children:[(0,d.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right pt-1",children:"Models"}),(0,d.jsx)(e.default,{className:"text-text-muted text-[14px] mt-1.5",children:"arrow_forward"}),(0,d.jsxs)("div",{className:"flex-1 flex flex-col gap-2",children:[(0,d.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===ad.length?(0,d.jsx)("span",{className:"text-xs text-text-muted",children:"No models selected"}):ad.map(a=>(0,d.jsxs)("span",{onClick:async()=>{if(a===af)try{(await fetch("/api/cli-tools/opencode-settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({clearActiveModel:!0})})).ok&&(ag(""),am())}catch(a){console.log("Error clearing active model:",a)}else ag(a)},className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs cursor-pointer transition-colors ${a===af?"bg-[var(--text)] text-[var(--bg)] border border-[var(--text)]":"bg-black/5 dark:bg-white/5 text-text-muted border border-transparent hover:border-border"}`,title:a===af?"Click to clear active model":"Click to set as active",children:[a===af&&(0,d.jsx)(e.default,{className:"text-[10px]",children:"star"}),a,(0,d.jsx)("button",{onClick:async b=>{b.stopPropagation();try{if((await fetch(`/api/cli-tools/opencode-settings?model=${encodeURIComponent(a)}`,{method:"DELETE"})).ok){let b=ad.filter(b=>b!==a);ae(b),af===a&&ag(""),am()}}catch(a){console.log("Error removing model:",a)}},className:"ml-0.5 hover:text-[var(--danger)]",children:(0,d.jsx)(e.default,{className:"text-[12px]",children:"close"})})]},a))}),(0,d.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,d.jsx)("button",{onClick:()=>W(!0),disabled:!m?.length,className:`px-2 py-1 rounded border text-xs transition-colors ${m?.length?"bg-surface border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${h().selectButton}`,children:"Add Model"}),(0,d.jsx)("span",{className:"text-xs text-text-muted",children:ad.length>0&&af?(0,d.jsxs)(d.Fragment,{children:["Active: ",(0,d.jsx)("span",{className:"text-text-main",children:af})]}):ad.length>0?(0,d.jsx)("span",{className:"text-[var(--warn)]",children:"Click a model to set/clear active"}):"Select models to add"})]})]})]}),(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Subagent Model"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)("input",{type:"text",value:S,onChange:a=>T(a.target.value),placeholder:Q||"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,d.jsx)("button",{onClick:()=>Y(!0),disabled:!m?.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 ${m?.length?"bg-surface border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${h().selectButton}`,children:"Select Model"}),S&&(0,d.jsx)("button",{onClick:()=>T(""),className:"p-1 text-text-muted hover:text-[var(--danger)] rounded transition-colors",title:"Clear (will use main model)",children:(0,d.jsx)(e.default,{className:"text-[14px]",children:"close"})})]})]}),K&&(0,d.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===K.type?h().positive:h().danger}`,children:[(0,d.jsx)(e.default,{className:"text-[14px]",children:"success"===K.type?"check_circle":"error"}),(0,d.jsx)("span",{children:K.text})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,d.jsxs)(j.$n,{variant:"primary",size:"sm",onClick:an,disabled:0===ad.length,loading:G,children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"save"}),"Apply"]}),(0,d.jsxs)(j.$n,{variant:"outline",size:"sm",onClick:ao,disabled:!A.has9Router,loading:I,children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,d.jsxs)(j.$n,{variant:"ghost",size:"sm",onClick:()=>aa(!0),children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),V&&(0,d.jsx)(j.rq,{className:h().modelPicker,isOpen:V,onClose:()=>{W(!1),ai(ah.current)},onSelect:a=>{!ad.includes(a.value)&&(ae([...ad,a.value]),af||ag(a.value))},onDeselect:a=>{let b=ad.filter(b=>b!==a.value);ae(b),af===a.value&&ag(b[0]||"")},selectedModel:null,activeProviders:m,modelAliases:Z,addedModelValues:ad,closeOnSelect:!1,title:"Add Model for OpenCode"}),X&&(0,d.jsx)(j.rq,{className:h().modelPicker,isOpen:X,onClose:()=>Y(!1),onSelect:a=>{T(a.value),Y(!1)},selectedModel:S,activeProviders:m,modelAliases:Z,title:"Select Subagent Model for OpenCode"}),(0,d.jsx)(j.uR,{isOpen:_,onClose:()=>aa(!1),title:"OpenCode - Manual Configuration",configs:(t=O&&O.trim()?O:n?"<API_KEY_FROM_DASHBOARD>":"sk_9router",u=ad.length>0?ad:["provider/model-id"],w=af||ad[0]||u[0],x=S||w,z={},u.forEach(a=>{z[a]={name:a,modalities:{input:["text","image"],output:["text"]}}}),[{filename:"~/.config/opencode/opencode.json",content:JSON.stringify({provider:{"9router":{npm:"@ai-sdk/openai-compatible",options:{baseURL:al(),apiKey:t},models:z}},model:`9router/${w}`,agent:{explorer:{description:"Fast explorer subagent for codebase exploration",mode:"subagent",model:`9router/${x}`}}},null,2)}])})]})}let V="/api/cli-tools/cowork-settings";function W({tool:a,isExpanded:b,onToggle:c,baseUrl:g,apiKeys:l,activeProviders:m,hasActiveProviders:n,cloudEnabled:o,cloudUrl:p,tunnelEnabled:q,tunnelPublicUrl:r,tailscaleEnabled:s,tailscaleUrl:t,initialStatus:u}){let w,x,z,A,[C,D]=(0,i.useState)(u||null),[E,F]=(0,i.useState)(!1),[G,H]=(0,i.useState)(!1),[I,J]=(0,i.useState)(!1),[K,L]=(0,i.useState)(null),[M,N]=(0,i.useState)(""),[O,P]=(0,i.useState)([]),[Q,R]=(0,i.useState)(!1),[S,T]=(0,i.useState)(""),[U,X]=(0,i.useState)([]),[Y,Z]=(0,i.useState)([]),[$,_]=(0,i.useState)([]),[aa,ab]=(0,i.useState)({}),[ac,ad]=(0,i.useState)(!1),[ae,af]=(0,i.useState)(!1),[ag,ah]=(0,i.useState)(!1),[ai,aj]=(0,i.useState)(!1),[ak,al]=(0,i.useState)({name:"",url:""}),am=async()=>{F(!0);try{let a=await fetch(V),b=await a.json();D(b)}catch(a){D({installed:!1,error:a.message})}finally{F(!1)}},an=()=>{let a;return(a=(S||"").replace(/\/+$/,""))?/\/v1$/.test(a)?a:`${a}/v1`:""},ao=C?.cowork?.baseUrl||"",ap=C?.installed?C?.cowork?.baseUrl?C.has9Router?"configured":"other":"not_configured":null,aq=async()=>{L(null);let a=an();if(0===O.length)return void L({type:"error",text:"Please select at least one model"});H(!0);try{let b=M?.trim()||(l?.length>0?l[0].key:null)||(o?null:"sk_9router"),c=await fetch(V,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:a,apiKey:b,models:O,plugins:U,localPlugins:Y,customPlugins:$})}),d=await c.json();c.ok?(v(an(),{tunnelPublicUrl:r,tailscaleUrl:t}),L({type:"success",text:"Settings applied. Quit & reopen Claude Desktop to load."}),am()):L({type:"error",text:d.error||"Failed to apply settings"})}catch(a){L({type:"error",text:a.message})}finally{H(!1)}},ar=async({name:a,models:b})=>{try{let c=await fetch("/api/combos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:a,models:b})});if(!c.ok){let a=await c.json();L({type:"error",text:a.error||"Failed to create combo"});return}O.includes(a)||P([...O,a]),ad(!1),L({type:"success",text:`Combo "${a}" created and added.`})}catch(a){L({type:"error",text:a.message})}},as=a=>{let b=a?.value||a?.name||a;P(a=>a.filter(a=>a!==b))},at=async()=>{J(!0),L(null);try{let a=await fetch(V,{method:"DELETE"}),b=await a.json();a.ok?(L({type:"success",text:"Settings reset successfully"}),P([]),X(C?.defaultPlugins||[]),Z([]),_([]),am()):L({type:"error",text:b.error||"Failed to reset"})}catch(a){L({type:"error",text:a.message})}finally{J(!1)}};return(0,d.jsxs)(j.Zp,{padding:"none",className:h().panel,children:[(0,d.jsxs)("div",{className:h().panelHeader,onClick:c,children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,d.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,d.jsx)(k.default,{src:a.image,alt:a.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:a=>{a.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,d.jsx)("h3",{className:"font-medium text-sm",children:a.name}),"configured"===ap&&(0,d.jsx)(f.A,{variant:"success",className:h().status,children:"Connected"}),"not_configured"===ap&&(0,d.jsx)(f.A,{variant:"warning",className:h().status,children:"Not configured"}),"other"===ap&&(0,d.jsx)(f.A,{variant:"default",dot:!1,className:h().status,children:"Other"})]}),(0,d.jsx)("p",{className:"text-xs text-text-muted truncate",children:a.description})]})]}),(0,d.jsx)(e.default,{className:`text-text-muted text-[20px] transition-transform ${b?"rotate-180":""}`,children:"expand_more"})]}),b&&(0,d.jsxs)("div",{className:h().body,children:[E&&(0,d.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,d.jsx)(e.default,{className:"animate-spin",children:"progress_activity"}),(0,d.jsx)("span",{children:"Checking Claude Cowork..."})]}),!E&&C&&!C.installed&&(0,d.jsxs)("div",{className:`flex flex-col gap-3 p-4 border ${h().notice} ${h().warning}`,children:[(0,d.jsxs)("div",{className:"flex items-start gap-3",children:[(0,d.jsx)(e.default,{className:"text-[var(--warn)]",children:"warning"}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("p",{className:"font-medium text-[var(--warn)]",children:"Claude Desktop (Cowork mode) not detected"}),(0,d.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,d.jsx)("div",{className:"pl-9",children:(0,d.jsxs)(j.$n,{variant:"secondary",size:"sm",onClick:()=>R(!0),children:[(0,d.jsx)(e.default,{className:"text-[18px] mr-1",children:"content_copy"}),"Manual Config"]})})]}),!E&&C?.installed&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Select Endpoint"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(y,{value:an(),onChange:a=>T((a||"").replace(/\/v1\/?$/,"")),tunnelEnabled:q,tunnelPublicUrl:r,tailscaleEnabled:s,tailscaleUrl:t,cloudEnabled:o,cloudUrl:p,currentUrl:ao})]}),C?.cowork?.baseUrl&&(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Current"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.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:C.cowork.baseUrl})]}),(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"API Key"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(B,{value:M,onChange:N,apiKeys:l,cloudEnabled:o})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,d.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Models"}),(0,d.jsx)(e.default,{className:"text-text-muted text-[14px]",children:"arrow_forward"}),(0,d.jsxs)("div",{className:"flex-1 flex items-center gap-2",children:[(0,d.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===O.length?(0,d.jsx)("span",{className:"text-xs text-text-muted",children:"No models selected"}):O.map(a=>(0,d.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:[a,(0,d.jsx)("button",{onClick:()=>as(a),className:"ml-0.5 hover:text-[var(--danger)]",children:(0,d.jsx)(e.default,{className:"text-[12px]",children:"close"})})]},a))}),(0,d.jsx)("button",{onClick:()=>ad(!0),disabled:!n,className:`shrink-0 px-2 py-1.5 rounded border text-xs whitespace-nowrap transition-colors ${n?"bg-surface-2 border-border text-text-main hover:bg-surface-2 cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${h().selectButton}`,children:"+ Combo"})]})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-start sm:gap-2",children:[(0,d.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right pt-2",children:"MCP"}),(0,d.jsx)(e.default,{className:"text-text-muted text-[14px] mt-2",children:"arrow_forward"}),(0,d.jsxs)("div",{className:"flex-1 flex flex-col gap-1",children:[U.filter(a=>"exa"!==a.name).map(a=>(0,d.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1 bg-surface rounded border border-border",children:[(0,d.jsx)("span",{className:"text-xs font-medium min-w-0 truncate flex-shrink-0",children:a.title||a.name}),a.oauth&&(0,d.jsx)("span",{className:"text-[8px] text-amber-600 shrink-0",children:"OAuth"}),(0,d.jsxs)("div",{className:"flex-1 flex flex-wrap gap-1 overflow-hidden",style:{maxHeight:"1.5rem"},children:[Array.isArray(a.toolNames)&&a.toolNames.slice(0,6).map(a=>(0,d.jsx)("span",{className:"text-[9px] px-1 py-0.5 rounded bg-black/5 dark:bg-white/5 text-text-muted whitespace-nowrap",children:a},a)),Array.isArray(a.toolNames)&&a.toolNames.length>6&&(0,d.jsxs)("span",{className:"text-[9px] px-1 py-0.5 rounded bg-black/5 dark:bg-white/5 text-text-muted whitespace-nowrap",children:["+",a.toolNames.length-6]})]}),(0,d.jsx)("button",{onClick:()=>{var b;return b=a.name,void X(U.filter(a=>a.name!==b))},className:"shrink-0 hover:text-[var(--danger)] ml-auto",children:(0,d.jsx)(e.default,{className:"text-[12px]",children:"close"})})]},a.name)),$.map(a=>(0,d.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1 bg-surface rounded border border-border",children:[(0,d.jsx)("span",{className:"text-xs font-medium min-w-0 truncate flex-shrink-0",children:a.name}),(0,d.jsx)("span",{className:"badge-neutral shrink-0",children:"custom"}),(0,d.jsx)("span",{className:"flex-1 text-[9px] text-text-muted truncate",children:a.url}),(0,d.jsx)("button",{onClick:()=>_($.filter(b=>b.name!==a.name)),className:"shrink-0 hover:text-[var(--danger)] ml-auto",children:(0,d.jsx)(e.default,{className:"text-[12px]",children:"close"})})]},a.name)),0===U.filter(a=>"exa"!==a.name).length&&0===$.length&&(0,d.jsx)("div",{className:"px-2 py-1.5 bg-surface rounded border border-border text-xs text-text-muted",children:"No MCPs added"}),(0,d.jsxs)("div",{className:"flex items-center gap-2 mt-0.5",children:[(0,d.jsx)("button",{onClick:()=>ah(!0),className:"px-2 py-1 rounded border text-xs bg-surface-2 border-border text-text-main hover:bg-surface-2 cursor-pointer whitespace-nowrap",children:"+ Browse"}),(0,d.jsx)("button",{onClick:()=>{al({name:"",url:""}),aj(!0)},className:"px-2 py-1 rounded border text-xs bg-surface border-border text-text-muted hover:border-[var(--text-2)] hover:text-text-main cursor-pointer whitespace-nowrap",children:"+ Custom"}),(0,d.jsx)("a",{href:"https://mcp.so",target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-text-muted hover:text-text-main underline ml-auto",children:"Find MCPs →"})]})]})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-start sm:gap-2",children:[(0,d.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right pt-1",children:"Tools"}),(0,d.jsx)(e.default,{className:"text-text-muted text-[14px] mt-1.5",children:"arrow_forward"}),(0,d.jsxs)("div",{className:"flex-1 flex flex-col gap-1.5",children:[(w=U.some(a=>"exa"===a.name),x=(C?.defaultPlugins||[]).find(a=>"exa"===a.name),(0,d.jsxs)("label",{className:"flex items-start gap-2 cursor-pointer px-2 py-1.5 bg-surface rounded border border-border",children:[(0,d.jsx)("input",{type:"checkbox",checked:w,onChange:a=>{a.target.checked&&x?X([...U.filter(a=>"exa"!==a.name),x]):X(U.filter(a=>"exa"!==a.name))},className:"mt-0.5"}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("div",{className:"text-xs font-medium",children:"Web Search & Fetch (Exa)"}),(0,d.jsx)("p",{className:"text-[10px] text-text-muted leading-snug",children:"Replaces built-in WebSearch/WebFetch. Auto-strips duplicates from tool list."})]})]})),(()=>{let a=(C?.localStdioPlugins||[]).find(a=>"browsermcp"===a.name);if(!a)return null;let b=Y.includes("browsermcp");return(0,d.jsxs)("label",{className:"flex items-start gap-2 cursor-pointer px-2 py-1.5 bg-surface rounded border border-border",children:[(0,d.jsx)("input",{type:"checkbox",checked:b,onChange:a=>Z(a.target.checked?[...Y,"browsermcp"]:Y.filter(a=>"browsermcp"!==a)),className:"mt-0.5"}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("div",{className:"text-xs font-medium",children:"Browser Control (Browser MCP)"}),(0,d.jsxs)("p",{className:"text-[10px] text-text-muted leading-snug",children:["Controls your running Chrome. Auto-strips Cowork's built-in browser tools."," ",(0,d.jsx)("a",{href:a.extensionUrl,target:"_blank",rel:"noopener noreferrer",className:"text-text-main underline",children:"Install Chrome extension"})]})]})]})})()]})]}),Array.isArray(C?.localStdioPlugins)&&C.localStdioPlugins.filter(a=>"browsermcp"!==a.name).length>0&&(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-start sm:gap-2",children:[(0,d.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right pt-1",children:"Local Plugins"}),(0,d.jsx)(e.default,{className:"text-text-muted text-[14px] mt-1.5",children:"arrow_forward"}),(0,d.jsxs)("div",{className:"flex-1 flex flex-col gap-2",children:[(0,d.jsx)("div",{className:"flex flex-col gap-1.5 px-2 py-1.5 bg-surface rounded border border-border",children:C.localStdioPlugins.filter(a=>"browsermcp"!==a.name).map(a=>{let b=Y.includes(a.name);return(0,d.jsxs)("label",{className:"flex items-start gap-2 cursor-pointer",children:[(0,d.jsx)("input",{type:"checkbox",checked:b,onChange:b=>Z(b.target.checked?[...Y,a.name]:Y.filter(b=>b!==a.name)),className:"mt-0.5"}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,d.jsx)("span",{className:"text-xs font-medium",children:a.title}),(0,d.jsx)("span",{className:"text-[8px] text-amber-600",children:"stdio"})]}),(0,d.jsx)("p",{className:"text-[10px] text-text-muted leading-snug",children:a.description}),a.extensionUrl&&(0,d.jsx)("a",{href:a.extensionUrl,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-text-main underline",children:"Install Chrome extension"})]})]},a.name)})}),(0,d.jsxs)("p",{className:"text-[10px] text-text-muted leading-snug",children:["⚠️ Local plugins run as subprocess via ",(0,d.jsx)("code",{className:"px-1 py-0.5 rounded bg-black/5 dark:bg-white/5",children:"npx"}),". Requires Node.js installed."]})]})]})]}),K&&(0,d.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===K.type?h().positive:h().danger}`,children:[(0,d.jsx)(e.default,{className:"text-[14px]",children:"success"===K.type?"check_circle":"error"}),(0,d.jsx)("span",{children:K.text})]}),(0,d.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2",children:[(0,d.jsxs)(j.$n,{variant:"primary",size:"sm",onClick:aq,disabled:0===O.length,loading:G,className:"w-full sm:w-auto",children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"save"}),"Apply"]}),(0,d.jsxs)(j.$n,{variant:"outline",size:"sm",onClick:at,disabled:!C.has9Router,loading:I,className:"w-full sm:w-auto",children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,d.jsxs)(j.$n,{variant:"ghost",size:"sm",onClick:()=>R(!0),className:"w-full sm:w-auto",children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),(0,d.jsx)(j.uR,{isOpen:Q,onClose:()=>R(!1),title:"Claude Cowork - Manual Configuration",configs:(z=M&&M.trim()?M:o?"<API_KEY_FROM_DASHBOARD>":"sk_9router",A=O.length>0?O:["provider/model-id"],[{filename:"~/Library/Application Support/Claude-3p/configLibrary/<appliedId>.json",content:JSON.stringify({inferenceProvider:"gateway",inferenceGatewayBaseUrl:an()||"https://your-public-host/v1",inferenceGatewayApiKey:z,inferenceModels:A.map(a=>({name:a}))},null,2)}])}),ac&&(0,d.jsx)(j.CK,{isOpen:ac,combo:null,onClose:()=>ad(!1),onSave:ar,activeProviders:m,forcePrefix:"claude-",title:"Create Cowork Combo"}),ae&&(0,d.jsx)(j.rq,{className:h().modelPicker,isOpen:ae,onClose:()=>af(!1),onSelect:a=>{let b=a?.value||a?.name||a;!b||O.includes(b)||P(a=>[...a,b])},onDeselect:as,activeProviders:m,modelAliases:aa,title:"Select Cowork Model",addedModelValues:O,closeOnSelect:!1}),(0,d.jsx)(j.Nf,{isOpen:ag,onClose:()=>ah(!1),onAdd:a=>{U.some(b=>b.name===a.name)||X([...U,a])},addedNames:U.map(a=>a.name)}),ai&&(0,d.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40",onClick:()=>aj(!1),children:(0,d.jsxs)("div",{className:"bg-surface border border-border rounded-[var(--r3)] shadow-[var(--shadow-pop)] w-full max-w-sm mx-4 p-5 flex flex-col gap-4",onClick:a=>a.stopPropagation(),children:[(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsx)("h3",{className:"font-semibold text-sm",children:"Add Custom MCP"}),(0,d.jsx)("button",{onClick:()=>aj(!1),className:"text-text-muted hover:text-text-main",children:(0,d.jsx)(e.default,{className:"text-[18px]",children:"close"})})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,d.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,d.jsx)("label",{className:"text-[11px] text-text-muted font-medium",children:"Name"}),(0,d.jsx)("input",{type:"text",placeholder:"my-mcp",value:ak.name,onChange:a=>al(b=>({...b,name:a.target.value.replace(/\s+/g,"-").toLowerCase()})),className:"px-2 py-1.5 rounded border border-border bg-surface text-xs"})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,d.jsx)("label",{className:"text-[11px] text-text-muted font-medium",children:"SSE URL"}),(0,d.jsx)("input",{type:"text",placeholder:"https://your-mcp-server.com/sse",value:ak.url,onChange:a=>al(b=>({...b,url:a.target.value})),className:"px-2 py-1.5 rounded border border-border bg-surface text-xs"})]})]}),(0,d.jsxs)("div",{className:"flex gap-2 justify-end",children:[(0,d.jsx)("button",{onClick:()=>aj(!1),className:"px-3 py-1.5 rounded border border-border text-xs text-text-muted hover:bg-surface cursor-pointer",children:"Cancel"}),(0,d.jsx)("button",{onClick:()=>{let a=ak.name.trim();a&&ak.url.trim()&&(_(b=>[...b.filter(b=>b.name!==a),{name:a,url:ak.url.trim(),transport:"sse",custom:!0}]),aj(!1))},className:"px-3 py-1.5 rounded bg-[var(--text)] text-[var(--bg)] text-xs font-medium hover:opacity-90 cursor-pointer",children:"Add"})]})]})})]})}function X({tool:a,isExpanded:b,onToggle:c,baseUrl:g,apiKeys:l,activeProviders:m,cloudEnabled:n,initialStatus:o,tunnelEnabled:p,tunnelPublicUrl:q,tailscaleEnabled:r,tailscaleUrl:s}){let t,u,[w,x]=(0,i.useState)(o||null),[z,A]=(0,i.useState)(!1),[C,E]=(0,i.useState)(!1),[F,G]=(0,i.useState)(!1),[H,I]=(0,i.useState)(null),[J,K]=(0,i.useState)(!1),[L,M]=(0,i.useState)(""),[N,O]=(0,i.useState)(""),[P,Q]=(0,i.useState)(!1),[R,S]=(0,i.useState)({}),[T,U]=(0,i.useState)(!1),[V,W]=(0,i.useState)(""),Y=w?.settings?.openAiBaseUrl||"",Z=w?.installed?w.has9Router?D(w.settings?.openAiBaseUrl||"",{tunnelPublicUrl:q,tailscaleUrl:s})?"configured":"other":"not_configured":null,$=()=>{let a=V||`${g}/v1`;return a.endsWith("/v1")?a:`${a}/v1`},_=async()=>{A(!0);try{let a=await fetch("/api/cli-tools/cline-settings"),b=await a.json();x(b)}catch(a){x({installed:!1,error:a.message})}finally{A(!1)}},aa=async()=>{E(!0),I(null);try{let a=L&&L.trim()||n?L:"sk_9router",b=await fetch("/api/cli-tools/cline-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:$(),apiKey:a,model:N})}),c=await b.json();b.ok?(v($(),{tunnelPublicUrl:q,tailscaleUrl:s}),I({type:"success",text:"Settings applied successfully!"}),_()):I({type:"error",text:c.error||"Failed to apply settings"})}catch(a){I({type:"error",text:a.message})}finally{E(!1)}},ab=async()=>{G(!0),I(null);try{let a=await fetch("/api/cli-tools/cline-settings",{method:"DELETE"}),b=await a.json();a.ok?(I({type:"success",text:"Settings reset successfully!"}),O(""),_()):I({type:"error",text:b.error||"Failed to reset settings"})}catch(a){I({type:"error",text:a.message})}finally{G(!1)}};return(0,d.jsxs)(j.Zp,{padding:"none",className:h().panel,children:[(0,d.jsxs)("div",{className:h().panelHeader,onClick:c,children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,d.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,d.jsx)(k.default,{src:"/providers/cline.png",alt:a.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:a=>{a.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,d.jsx)("h3",{className:"font-medium text-sm",children:a.name}),"configured"===Z&&(0,d.jsx)(f.A,{variant:"success",className:h().status,children:"Connected"}),"not_configured"===Z&&(0,d.jsx)(f.A,{variant:"warning",className:h().status,children:"Not configured"}),"other"===Z&&(0,d.jsx)(f.A,{variant:"default",dot:!1,className:h().status,children:"Other"})]}),(0,d.jsx)("p",{className:"text-xs text-text-muted truncate",children:a.description})]})]}),(0,d.jsx)(e.default,{className:`text-text-muted text-[20px] transition-transform ${b?"rotate-180":""}`,children:"expand_more"})]}),b&&(0,d.jsxs)("div",{className:h().body,children:[z&&(0,d.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,d.jsx)(e.default,{className:"animate-spin",children:"progress_activity"}),(0,d.jsx)("span",{children:"Checking Cline..."})]}),!z&&w&&!w.installed&&(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,d.jsxs)("div",{className:`flex flex-col gap-3 p-4 border ${h().notice} ${h().warning}`,children:[(0,d.jsxs)("div",{className:"flex items-start gap-3",children:[(0,d.jsx)(e.default,{className:"text-[var(--warn)]",children:"warning"}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("p",{className:"font-medium text-[var(--warn)]",children:"Cline not detected locally"}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if 9router is deployed on a remote server."})]})]}),(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2 sm:pl-9",children:[(0,d.jsxs)(j.$n,{variant:"secondary",size:"sm",onClick:()=>U(!0),children:[(0,d.jsx)(e.default,{className:"text-[18px] mr-1",children:"content_copy"}),"Manual Config"]}),(0,d.jsxs)(j.$n,{variant:"outline",size:"sm",onClick:()=>K(!J),children:[(0,d.jsx)(e.default,{className:"text-[18px] mr-1",children:J?"expand_less":"help"}),J?"Hide":"How to Install"]})]})]}),J&&(0,d.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,d.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,d.jsx)("div",{className:"space-y-3 text-sm",children:(0,d.jsxs)("p",{className:"text-text-muted",children:["Install Cline VS Code extension or CLI from ",(0,d.jsx)("a",{className:"text-text-main underline",href:"https://docs.cline.bot/",target:"_blank",rel:"noreferrer",children:"docs.cline.bot"}),"."]})})]})]}),!z&&w?.installed&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Select Endpoint"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(y,{value:V||V||`${g}/v1`,onChange:W,requiresExternalUrl:a.requiresExternalUrl,tunnelEnabled:p,tunnelPublicUrl:q,tailscaleEnabled:r,tailscaleUrl:s,currentUrl:Y})]}),w?.settings?.openAiBaseUrl&&(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Current"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.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.openAiBaseUrl})]}),(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"API Key"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(B,{value:L,onChange:M,apiKeys:l,cloudEnabled:n})]}),(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Model"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,d.jsx)("input",{type:"text",value:N,onChange:a=>O(a.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"}),N&&(0,d.jsx)("button",{onClick:()=>O(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-[var(--danger)] rounded transition-colors",title:"Clear",children:(0,d.jsx)(e.default,{className:"text-[14px]",children:"close"})})]}),(0,d.jsx)("button",{onClick:()=>Q(!0),disabled:!m?.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 ${m?.length?"bg-surface border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${h().selectButton}`,children:"Select Model"})]})]}),H&&(0,d.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===H.type?h().positive:h().danger}`,children:[(0,d.jsx)(e.default,{className:"text-[14px]",children:"success"===H.type?"check_circle":"error"}),(0,d.jsx)("span",{children:H.text})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,d.jsxs)(j.$n,{variant:"primary",size:"sm",onClick:aa,disabled:!L&&n&&l.length>0||!N,loading:C,children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"save"}),"Apply"]}),(0,d.jsxs)(j.$n,{variant:"outline",size:"sm",onClick:ab,disabled:F,loading:F,children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,d.jsxs)(j.$n,{variant:"ghost",size:"sm",onClick:()=>U(!0),children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),P&&(0,d.jsx)(j.rq,{className:h().modelPicker,isOpen:P,onClose:()=>Q(!1),onSelect:a=>{O(a.value),Q(!1)},selectedModel:N,activeProviders:m,modelAliases:R,title:"Select Model for Cline"}),(0,d.jsx)(j.uR,{isOpen:T,onClose:()=>U(!1),title:"Cline - Manual Configuration",configs:(t=L&&L.trim()?L:n?"<API_KEY_FROM_DASHBOARD>":"sk_9router",[{filename:"~/.cline/data/globalState.json",content:JSON.stringify({actModeApiProvider:"openai",planModeApiProvider:"openai",openAiBaseUrl:(u=$()).endsWith("/v1")?u.slice(0,-3):u,openAiModelId:N||"provider/model-id",planModeOpenAiModelId:N||"provider/model-id"},null,2)},{filename:"~/.cline/data/secrets.json",content:JSON.stringify({openAiApiKey:t},null,2)}])})]})}function Y({tool:a,isExpanded:b,onToggle:c,baseUrl:g,apiKeys:l,activeProviders:m,cloudEnabled:n,initialStatus:o,tunnelEnabled:p,tunnelPublicUrl:q,tailscaleEnabled:r,tailscaleUrl:s}){let[t,u]=(0,i.useState)(o||null),[w,x]=(0,i.useState)(!1),[z,A]=(0,i.useState)(!1),[C,D]=(0,i.useState)(!1),[E,F]=(0,i.useState)(null),[G,H]=(0,i.useState)(!1),[I,J]=(0,i.useState)(""),[K,L]=(0,i.useState)(""),[M,N]=(0,i.useState)(!1),[O,P]=(0,i.useState)({}),[Q,R]=(0,i.useState)(!1),[S,T]=(0,i.useState)(""),U=t?.installed?t.has9Router?"configured":"not_configured":null,V=()=>{let a=S||`${g}/v1`;return a.endsWith("/v1")?a:`${a}/v1`},W=async()=>{x(!0);try{let a=await fetch("/api/cli-tools/kilo-settings"),b=await a.json();u(b)}catch(a){u({installed:!1,error:a.message})}finally{x(!1)}},X=async()=>{A(!0),F(null);try{let a=I&&I.trim()||n?I:"sk_9router",b=await fetch("/api/cli-tools/kilo-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:V(),apiKey:a,model:K})}),c=await b.json();b.ok?(v(V(),{tunnelPublicUrl:q,tailscaleUrl:s}),F({type:"success",text:"Settings applied successfully!"}),W()):F({type:"error",text:c.error||"Failed to apply settings"})}catch(a){F({type:"error",text:a.message})}finally{A(!1)}},Z=async()=>{D(!0),F(null);try{let a=await fetch("/api/cli-tools/kilo-settings",{method:"DELETE"}),b=await a.json();a.ok?(F({type:"success",text:"Settings reset successfully!"}),L(""),W()):F({type:"error",text:b.error||"Failed to reset settings"})}catch(a){F({type:"error",text:a.message})}finally{D(!1)}};return(0,d.jsxs)(j.Zp,{padding:"none",className:h().panel,children:[(0,d.jsxs)("div",{className:h().panelHeader,onClick:c,children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,d.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,d.jsx)(k.default,{src:"/providers/kilocode.png",alt:a.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:a=>{a.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,d.jsx)("h3",{className:"font-medium text-sm",children:a.name}),"configured"===U&&(0,d.jsx)(f.A,{variant:"success",className:h().status,children:"Connected"}),"not_configured"===U&&(0,d.jsx)(f.A,{variant:"warning",className:h().status,children:"Not configured"})]}),(0,d.jsx)("p",{className:"text-xs text-text-muted truncate",children:a.description})]})]}),(0,d.jsx)(e.default,{className:`text-text-muted text-[20px] transition-transform ${b?"rotate-180":""}`,children:"expand_more"})]}),b&&(0,d.jsxs)("div",{className:h().body,children:[w&&(0,d.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,d.jsx)(e.default,{className:"animate-spin",children:"progress_activity"}),(0,d.jsx)("span",{children:"Checking Kilo Code..."})]}),!w&&t&&!t.installed&&(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,d.jsxs)("div",{className:`flex flex-col gap-3 p-4 border ${h().notice} ${h().warning}`,children:[(0,d.jsxs)("div",{className:"flex items-start gap-3",children:[(0,d.jsx)(e.default,{className:"text-[var(--warn)]",children:"warning"}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("p",{className:"font-medium text-[var(--warn)]",children:"Kilo Code not detected locally"}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if 9router is deployed on a remote server."})]})]}),(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2 sm:pl-9",children:[(0,d.jsxs)(j.$n,{variant:"secondary",size:"sm",onClick:()=>R(!0),children:[(0,d.jsx)(e.default,{className:"text-[18px] mr-1",children:"content_copy"}),"Manual Config"]}),(0,d.jsxs)(j.$n,{variant:"outline",size:"sm",onClick:()=>H(!G),children:[(0,d.jsx)(e.default,{className:"text-[18px] mr-1",children:G?"expand_less":"help"}),G?"Hide":"How to Install"]})]})]}),G&&(0,d.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,d.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,d.jsxs)("p",{className:"text-sm text-text-muted",children:["Install Kilo Code from ",(0,d.jsx)("a",{className:"text-text-main underline",href:"https://kilocode.ai",target:"_blank",rel:"noreferrer",children:"kilocode.ai"})," or VS Code extension marketplace."]})]})]}),!w&&t?.installed&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Select Endpoint"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(y,{value:S||S||`${g}/v1`,onChange:T,requiresExternalUrl:a.requiresExternalUrl,tunnelEnabled:p,tunnelPublicUrl:q,tailscaleEnabled:r,tailscaleUrl:s})]}),(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"API Key"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(B,{value:I,onChange:J,apiKeys:l,cloudEnabled:n})]}),(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Model"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,d.jsx)("input",{type:"text",value:K,onChange:a=>L(a.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"}),K&&(0,d.jsx)("button",{onClick:()=>L(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-[var(--danger)] rounded transition-colors",title:"Clear",children:(0,d.jsx)(e.default,{className:"text-[14px]",children:"close"})})]}),(0,d.jsx)("button",{onClick:()=>N(!0),disabled:!m?.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 ${m?.length?"bg-surface border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${h().selectButton}`,children:"Select Model"})]})]}),E&&(0,d.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===E.type?h().positive:h().danger}`,children:[(0,d.jsx)(e.default,{className:"text-[14px]",children:"success"===E.type?"check_circle":"error"}),(0,d.jsx)("span",{children:E.text})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,d.jsxs)(j.$n,{variant:"primary",size:"sm",onClick:X,disabled:!I&&n&&l.length>0||!K,loading:z,children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"save"}),"Apply"]}),(0,d.jsxs)(j.$n,{variant:"outline",size:"sm",onClick:Z,disabled:C,loading:C,children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,d.jsxs)(j.$n,{variant:"ghost",size:"sm",onClick:()=>R(!0),children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),M&&(0,d.jsx)(j.rq,{className:h().modelPicker,isOpen:M,onClose:()=>N(!1),onSelect:a=>{L(a.value),N(!1)},selectedModel:K,activeProviders:m,modelAliases:O,title:"Select Model for Kilo Code"}),(0,d.jsx)(j.uR,{isOpen:Q,onClose:()=>R(!1),title:"Kilo Code - Manual Configuration",configs:[{filename:"~/.local/share/kilo/auth.json",content:JSON.stringify({"openai-compatible":{type:"api-key",apiKey:I&&I.trim()?I:n?"<API_KEY_FROM_DASHBOARD>":"sk_9router",baseUrl:V(),model:K||"provider/model-id"}},null,2)}]})]})}let Z="/api/cli-tools/deepseek-tui-settings";function $({tool:a,isExpanded:b,onToggle:c,baseUrl:g,hasActiveProviders:l,apiKeys:m,activeProviders:n,cloudEnabled:o,initialStatus:p,tunnelEnabled:q,tunnelPublicUrl:r,tailscaleEnabled:s,tailscaleUrl:t}){let u,[w,x]=(0,i.useState)(p||null),[z,A]=(0,i.useState)(!1),[C,E]=(0,i.useState)(!1),[F,G]=(0,i.useState)(!1),[H,I]=(0,i.useState)(null),[J,K]=(0,i.useState)(""),[L,M]=(0,i.useState)(""),[N,O]=(0,i.useState)(!1),[P,Q]=(0,i.useState)({}),[R,S]=(0,i.useState)(!1),[T,U]=(0,i.useState)("");(0,i.useRef)(!1);let V=w?.settings?.["providers.openai"]?.base_url||"",W=(()=>{if(!w?.installed)return null;let a=w.settings?.["providers.openai"];return a?.base_url?D(a.base_url,{tunnelPublicUrl:r,tailscaleUrl:t})?"configured":"other":"not_configured"})(),X=async()=>{A(!0);try{let a=await fetch(Z),b=await a.json();x(b)}catch(a){x({installed:!1,error:a.message})}finally{A(!1)}},Y=()=>{let a=T||"http://127.0.0.1:20128";return a.endsWith("/v1")?a:`${a}/v1`},_=async()=>{E(!0),I(null);try{let a=J?.trim()||(m?.length>0?m[0].key:null)||(o?null:"sk_9router"),b=await fetch(Z,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:Y(),apiKey:a,model:L})}),c=await b.json();b.ok?(v(Y(),{tunnelPublicUrl:r,tailscaleUrl:t}),I({type:"success",text:"Settings applied successfully!"}),X()):I({type:"error",text:c.error||"Failed to apply settings"})}catch(a){I({type:"error",text:a.message})}finally{E(!1)}},aa=async()=>{G(!0),I(null);try{let a=await fetch(Z,{method:"DELETE"}),b=await a.json();a.ok?(I({type:"success",text:"Settings reset successfully!"}),M(""),X()):I({type:"error",text:b.error||"Failed to reset settings"})}catch(a){I({type:"error",text:a.message})}finally{G(!1)}};return(0,d.jsxs)(j.Zp,{padding:"none",className:h().panel,children:[(0,d.jsxs)("div",{className:h().panelHeader,onClick:c,children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,d.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,d.jsx)(k.default,{src:a.image||"/providers/deepseek-tui.png",alt:a.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:a=>{a.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,d.jsx)("h3",{className:"font-medium text-sm",children:a.name}),"configured"===W&&(0,d.jsx)(f.A,{variant:"success",className:h().status,children:"Connected"}),"not_configured"===W&&(0,d.jsx)(f.A,{variant:"warning",className:h().status,children:"Not configured"}),"other"===W&&(0,d.jsx)(f.A,{variant:"default",dot:!1,className:h().status,children:"Other"})]}),(0,d.jsx)("p",{className:"text-xs text-text-muted truncate",children:a.description})]})]}),(0,d.jsx)(e.default,{className:`text-text-muted text-[20px] transition-transform ${b?"rotate-180":""}`,children:"expand_more"})]}),b&&(0,d.jsxs)("div",{className:h().body,children:[z&&(0,d.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,d.jsx)(e.default,{className:"animate-spin",children:"progress_activity"}),(0,d.jsx)("span",{children:"Checking DeepSeek TUI..."})]}),!z&&w&&!w.installed&&(0,d.jsx)("div",{className:"flex flex-col gap-4",children:(0,d.jsxs)("div",{className:`flex flex-col gap-3 p-4 border ${h().notice} ${h().warning}`,children:[(0,d.jsxs)("div",{className:"flex items-start gap-3",children:[(0,d.jsx)(e.default,{className:"text-[var(--warn)]",children:"warning"}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("p",{className:"font-medium text-[var(--warn)]",children:"DeepSeek TUI not detected locally"}),(0,d.jsx)("p",{className:"text-sm text-text-muted mt-1",children:"Install via npm:"}),(0,d.jsx)("code",{className:"block mt-2 p-2 bg-black/20 rounded text-xs font-mono",children:"npm install -g deepseek-tui"}),(0,d.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,d.jsx)("div",{className:"flex flex-wrap items-center gap-2 sm:pl-9",children:(0,d.jsxs)(j.$n,{variant:"secondary",size:"sm",onClick:()=>S(!0),children:[(0,d.jsx)(e.default,{className:"text-[18px] mr-1",children:"content_copy"}),"Manual Config"]})})]})}),!z&&w?.installed&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[a.notes&&a.notes.length>0&&(0,d.jsx)("div",{className:"flex flex-col gap-2 mb-2",children:a.notes.map((a,b)=>(0,d.jsxs)("div",{className:`flex items-start gap-2 p-2 rounded text-xs ${"warning"===a.type?h().warning:"error"===a.type?h().danger:h().neutral}`,children:[(0,d.jsx)(e.default,{className:"text-[14px] mt-0.5",children:"warning"===a.type?"warning":"error"===a.type?"error":"info"}),(0,d.jsx)("span",{children:a.text})]},b))}),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Select Endpoint"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(y,{value:T||Y(),onChange:U,requiresExternalUrl:a.requiresExternalUrl,tunnelEnabled:q,tunnelPublicUrl:r,tailscaleEnabled:s,tailscaleUrl:t,currentUrl:V})]}),w?.settings?.["providers.openai"]?.base_url&&(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Current"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.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["providers.openai"].base_url})]}),(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"API Key"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(B,{value:J,onChange:K,apiKeys:m,cloudEnabled:o})]}),(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Default Model"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,d.jsx)("input",{type:"text",value:L,onChange:a=>M(a.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,d.jsx)("button",{onClick:()=>M(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-[var(--danger)] rounded transition-colors",title:"Clear",children:(0,d.jsx)(e.default,{className:"text-[14px]",children:"close"})})]}),(0,d.jsx)("button",{onClick:()=>O(!0),disabled:!l,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 ${l?"bg-surface border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${h().selectButton}`,children:"Select"})]})]}),H&&(0,d.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===H.type?h().positive:h().danger}`,children:[(0,d.jsx)(e.default,{className:"text-[14px]",children:"success"===H.type?"check_circle":"error"}),(0,d.jsx)("span",{children:H.text})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,d.jsxs)(j.$n,{variant:"primary",size:"sm",onClick:_,disabled:!L,loading:C,children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"save"}),"Apply"]}),(0,d.jsxs)(j.$n,{variant:"outline",size:"sm",onClick:aa,disabled:!w?.has9Router,loading:F,children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,d.jsxs)(j.$n,{variant:"ghost",size:"sm",onClick:()=>S(!0),children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),N&&(0,d.jsx)(j.rq,{className:h().modelPicker,isOpen:N,onClose:()=>O(!1),onSelect:a=>{M(a.value),O(!1)},selectedModel:L,activeProviders:n,modelAliases:P,title:"Select Model for DeepSeek TUI"}),(0,d.jsx)(j.uR,{isOpen:R,onClose:()=>S(!1),title:"DeepSeek TUI - Manual Configuration",configs:(u=J&&J.trim()?J:o?"<API_KEY_FROM_DASHBOARD>":"sk_9router",[{filename:"~/.deepseek/config.toml",content:`[providers.openai]
40
+ `}])})]})}var R=c(29225),S=c(50377);function T({toolId:a,tool:b,isExpanded:c,onToggle:f,baseUrl:g,apiKeys:l,activeProviders:m=[],cloudEnabled:n=!1,tunnelEnabled:o=!1}){let[p,q]=(0,i.useState)(null),[r,s]=(0,i.useState)(!1),[t,u]=(0,i.useState)(""),[v,w]=(0,i.useState)(()=>l?.length>0?l[0].key:""),x=a=>{let b=v&&v.trim()?v:n?"your-api-key":"sk_jrouter",c=g||"http://localhost:20128",d=c.endsWith("/v1")?c:`${c}/v1`;return a.replace(/\{\{baseUrl\}\}/g,d).replace(/\{\{apiKey\}\}/g,b).replace(/\{\{model\}\}/g,t||"provider/model-id")},{copy:y}=(0,S.C)(),z=async(a,b)=>{await y(x(a),`toolcard-${b}`),q(b),setTimeout(()=>q(null),2e3)},A=m.length>0,C=()=>(!b.requiresExternalUrl||!!n||!!o)&&(!b.requiresCloud||!!n);return(0,d.jsxs)(j.Zp,{padding:"none",className:h().panel,children:[(0,d.jsxs)("div",{className:h().panelHeader,onClick:f,children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,d.jsx)("div",{className:"size-8 rounded-lg flex items-center justify-center shrink-0",children:(()=>{if(b.image)return(0,d.jsx)(k.default,{src:b.image,alt:b.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:a=>{a.target.style.display="none"},loading:"lazy",decoding:"async"});if(b.icon)return(0,d.jsx)(e.default,{className:"text-xl",style:{color:b.color},children:b.icon});let c=(0,R.HY)(a);return c?(0,d.jsx)(k.default,{src:c,alt:b.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:b=>{(0,R.Kw)(a),b.target.style.display="none"},loading:"lazy",decoding:"async"}):(0,d.jsx)("span",{className:"text-xs font-bold",style:{color:b.color},children:(a||"?").slice(0,2).toUpperCase()})})()}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("h3",{className:"font-medium text-sm",children:b.name}),(0,d.jsx)("p",{className:"text-xs text-text-muted truncate",children:b.description})]})]}),(0,d.jsx)(e.default,{className:`text-text-muted text-[20px] transition-transform ${c?"rotate-180":""}`,children:"expand_more"})]}),c&&(0,d.jsx)("div",{className:h().body,children:b.guideSteps?(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:[b.notes&&0!==b.notes.length?(0,d.jsx)("div",{className:"flex flex-col gap-2 mb-4",children:b.notes.map((a,b)=>{if("cloudCheck"===a.type&&(n||o))return null;let c="warning"===a.type,f="cloudCheck"===a.type&&!n&&!o,g=h().neutral,i="text-text-muted",j="text-text-muted",k="info";return c?(g=h().warning,i="text-[var(--warn)]",j="text-[var(--warn)]",k="warning"):f&&(g=h().danger,i="text-[var(--danger)]",j="text-[var(--danger)]",k="error"),(0,d.jsxs)("div",{className:`flex items-start gap-3 p-3 rounded-lg border ${g}`,children:[(0,d.jsx)(e.default,{className:`text-lg ${j}`,children:k}),(0,d.jsx)("p",{className:`text-xs ${i}`,children:a.text})]},b)})}):null,C()&&b.guideSteps.map(a=>(0,d.jsxs)("div",{className:"flex items-start gap-4",children:[(0,d.jsx)("div",{className:"size-8 rounded-full flex items-center justify-center shrink-0 text-sm font-semibold text-white",style:{backgroundColor:b.color},children:a.step}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("p",{className:"font-medium text-text",children:a.title}),a.desc&&(0,d.jsx)("p",{className:"text-xs text-text-muted mt-0.5",children:a.desc}),"apiKeySelector"===a.type&&(0,d.jsx)("div",{className:"mt-2 flex flex-col sm:flex-row sm:items-center gap-2",children:(0,d.jsx)(B,{value:v,onChange:w,apiKeys:l,cloudEnabled:n,className:"flex-1"})}),"modelSelector"===a.type&&(0,d.jsxs)("div",{className:"mt-2 flex flex-col sm:flex-row sm:items-center gap-2",children:[(0,d.jsx)("input",{type:"text",value:t,onChange:a=>u(a.target.value),placeholder:"provider/model-id",className:"w-full min-w-0 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,d.jsx)("button",{onClick:()=>s(!0),disabled:!A,className:`shrink-0 px-3 py-2 rounded-lg border text-sm transition-colors ${A?"bg-bg-secondary border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${h().selectButton}`,children:"Select Model"}),t&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("button",{onClick:()=>z(t,"model"),className:h().iconButton,"aria-label":"Copy model",children:(0,d.jsx)(e.default,{className:"text-lg",children:"model"===p?"check":"content_copy"})}),(0,d.jsx)("button",{onClick:()=>u(""),className:"p-2 text-text-muted hover:text-[var(--danger)] rounded transition-colors",title:"Clear",children:(0,d.jsx)(e.default,{className:"text-lg",children:"close"})})]})]}),a.value&&(0,d.jsxs)("div",{className:"mt-2 flex flex-col sm:flex-row sm:items-center gap-2",children:[(0,d.jsx)("code",{className:"w-full min-w-0 sm:w-auto flex-1 px-3 py-2 bg-bg-secondary rounded-lg text-sm font-mono border border-border truncate",children:x(a.value)}),a.copyable&&(0,d.jsx)("button",{onClick:()=>z(a.value,`${a.step}-${a.title}`),className:h().iconButton,"aria-label":"Copy value",children:(0,d.jsx)(e.default,{className:"text-lg",children:p===`${a.step}-${a.title}`?"check":"content_copy"})})]})]})]},a.step)),C()&&b.codeBlock&&(0,d.jsxs)("div",{className:"mt-2",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,d.jsx)("span",{className:"text-xs text-text-muted uppercase tracking-wide",children:b.codeBlock.language}),(0,d.jsxs)("button",{onClick:()=>z(b.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,d.jsx)(e.default,{className:"text-sm",children:"codeblock"===p?"check":"content_copy"}),"codeblock"===p?"Copied!":"Copy"]})]}),(0,d.jsx)("pre",{className:"p-4 bg-bg-secondary rounded-lg border border-border overflow-x-auto",children:(0,d.jsx)("code",{className:"whitespace-pre",children:x(b.codeBlock.code)})})]})]}):(0,d.jsx)("p",{className:"text-text-muted text-sm",children:"Coming soon..."})}),r&&(0,d.jsx)(j.rq,{className:h().modelPicker,isOpen:r,onClose:()=>s(!1),onSelect:a=>{u(a.value)},selectedModel:t,activeProviders:m,title:"Select Model"})]})}function U({tool:a,isExpanded:b,onToggle:c,baseUrl:g,apiKeys:l,activeProviders:m,cloudEnabled:n,initialStatus:o,tunnelEnabled:p,tunnelPublicUrl:q,tailscaleEnabled:r,tailscaleUrl:s}){let t,u,w,x,z,[A,C]=(0,i.useState)(o||null),[E,F]=(0,i.useState)(!1),[G,H]=(0,i.useState)(!1),[I,J]=(0,i.useState)(!1),[K,L]=(0,i.useState)(null),[M,N]=(0,i.useState)(!1),[O,P]=(0,i.useState)(""),[Q,R]=(0,i.useState)(""),[S,T]=(0,i.useState)(""),[V,W]=(0,i.useState)(!1),[X,Y]=(0,i.useState)(!1),[Z,$]=(0,i.useState)({}),[_,aa]=(0,i.useState)(!1),[ab,ac]=(0,i.useState)(""),[ad,ae]=(0,i.useState)([]),[af,ag]=(0,i.useState)(""),ah=(0,i.useRef)([]),ai=async a=>{try{let b=O&&O.trim()||n?O:"sk_jrouter",c=a.includes(af)?af:a[0]||"";await fetch("/api/cli-tools/opencode-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:al(),apiKey:b,models:a,activeModel:c,subagentModel:S})})}catch(a){console.log("Error saving models:",a)}},aj=A?.config?.provider?.jrouter?.options?.baseURL||"",ak=A?.installed?A.config&&A.hasJRouter?D(A.config?.provider?.jrouter?.options?.baseURL||"",{tunnelPublicUrl:q,tailscaleUrl:s})?"configured":"other":"not_configured":null,al=()=>{let a=ab||g;return a.endsWith("/v1")?a:`${a}/v1`},am=async()=>{F(!0);try{let a=await fetch("/api/cli-tools/opencode-settings"),b=await a.json();C(b)}catch(a){C({installed:!1,error:a.message})}finally{F(!1)}},an=async()=>{H(!0),L(null);try{let a=O&&O.trim()||n?O:"sk_jrouter",b=await fetch("/api/cli-tools/opencode-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:al(),apiKey:a,models:ad,activeModel:""===af?"":af||ad[0],subagentModel:S})}),c=await b.json();b.ok?(v(al(),{tunnelPublicUrl:q,tailscaleUrl:s}),L({type:"success",text:"Settings applied successfully!"}),am()):L({type:"error",text:c.error||"Failed to apply settings"})}catch(a){L({type:"error",text:a.message})}finally{H(!1)}},ao=async()=>{J(!0),L(null);try{let a=await fetch("/api/cli-tools/opencode-settings",{method:"DELETE"}),b=await a.json();a.ok?(L({type:"success",text:"Settings reset successfully!"}),R(""),T(""),ae([]),ag(""),am()):L({type:"error",text:b.error||"Failed to reset settings"})}catch(a){L({type:"error",text:a.message})}finally{J(!1)}};return(0,d.jsxs)(j.Zp,{padding:"none",className:h().panel,children:[(0,d.jsxs)("div",{className:h().panelHeader,onClick:c,children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,d.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,d.jsx)(k.default,{src:"/providers/opencode.png",alt:a.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:a=>{a.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,d.jsx)("h3",{className:"font-medium text-sm",children:a.name}),"configured"===ak&&(0,d.jsx)(f.A,{variant:"success",className:h().status,children:"Connected"}),"not_configured"===ak&&(0,d.jsx)(f.A,{variant:"warning",className:h().status,children:"Not configured"}),"other"===ak&&(0,d.jsx)(f.A,{variant:"default",dot:!1,className:h().status,children:"Other"})]}),(0,d.jsx)("p",{className:"text-xs text-text-muted truncate",children:a.description})]})]}),(0,d.jsx)(e.default,{className:`text-text-muted text-[20px] transition-transform ${b?"rotate-180":""}`,children:"expand_more"})]}),b&&(0,d.jsxs)("div",{className:h().body,children:[E&&(0,d.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,d.jsx)(e.default,{className:"animate-spin",children:"progress_activity"}),(0,d.jsx)("span",{children:"Checking OpenCode CLI..."})]}),!E&&A&&!A.installed&&(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,d.jsxs)("div",{className:`flex flex-col gap-3 p-4 border ${h().notice} ${h().warning}`,children:[(0,d.jsxs)("div",{className:"flex items-start gap-3",children:[(0,d.jsx)(e.default,{className:"text-[var(--warn)]",children:"warning"}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("p",{className:"font-medium text-[var(--warn)]",children:"OpenCode CLI not detected locally"}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if JRouter is deployed on a remote server."})]})]}),(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2 sm:pl-9",children:[(0,d.jsxs)(j.$n,{variant:"secondary",size:"sm",onClick:()=>aa(!0),children:[(0,d.jsx)(e.default,{className:"text-[18px] mr-1",children:"content_copy"}),"Manual Config"]}),(0,d.jsxs)(j.$n,{variant:"outline",size:"sm",onClick:()=>N(!M),children:[(0,d.jsx)(e.default,{className:"text-[18px] mr-1",children:M?"expand_less":"help"}),M?"Hide":"How to Install"]})]})]}),M&&(0,d.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,d.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,d.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-text-muted mb-1",children:"macOS / Linux:"}),(0,d.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,d.jsxs)("p",{className:"text-text-muted",children:["After installation, run ",(0,d.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"opencode"})," to verify."]})]})]})]}),!E&&A?.installed&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Select Endpoint"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(y,{value:ab||ab||`${g}/v1`,onChange:ac,requiresExternalUrl:a.requiresExternalUrl,tunnelEnabled:p,tunnelPublicUrl:q,tailscaleEnabled:r,tailscaleUrl:s,currentUrl:aj})]}),A?.config?.provider?.jrouter?.options?.baseURL&&(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Current"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.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:A.config.provider.jrouter.options.baseURL})]}),(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"API Key"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(B,{value:O,onChange:P,apiKeys:l,cloudEnabled:n})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-start sm:gap-2",children:[(0,d.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right pt-1",children:"Models"}),(0,d.jsx)(e.default,{className:"text-text-muted text-[14px] mt-1.5",children:"arrow_forward"}),(0,d.jsxs)("div",{className:"flex-1 flex flex-col gap-2",children:[(0,d.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===ad.length?(0,d.jsx)("span",{className:"text-xs text-text-muted",children:"No models selected"}):ad.map(a=>(0,d.jsxs)("span",{onClick:async()=>{if(a===af)try{(await fetch("/api/cli-tools/opencode-settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({clearActiveModel:!0})})).ok&&(ag(""),am())}catch(a){console.log("Error clearing active model:",a)}else ag(a)},className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs cursor-pointer transition-colors ${a===af?"bg-[var(--text)] text-[var(--bg)] border border-[var(--text)]":"bg-black/5 dark:bg-white/5 text-text-muted border border-transparent hover:border-border"}`,title:a===af?"Click to clear active model":"Click to set as active",children:[a===af&&(0,d.jsx)(e.default,{className:"text-[10px]",children:"star"}),a,(0,d.jsx)("button",{onClick:async b=>{b.stopPropagation();try{if((await fetch(`/api/cli-tools/opencode-settings?model=${encodeURIComponent(a)}`,{method:"DELETE"})).ok){let b=ad.filter(b=>b!==a);ae(b),af===a&&ag(""),am()}}catch(a){console.log("Error removing model:",a)}},className:"ml-0.5 hover:text-[var(--danger)]",children:(0,d.jsx)(e.default,{className:"text-[12px]",children:"close"})})]},a))}),(0,d.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,d.jsx)("button",{onClick:()=>W(!0),disabled:!m?.length,className:`px-2 py-1 rounded border text-xs transition-colors ${m?.length?"bg-surface border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${h().selectButton}`,children:"Add Model"}),(0,d.jsx)("span",{className:"text-xs text-text-muted",children:ad.length>0&&af?(0,d.jsxs)(d.Fragment,{children:["Active: ",(0,d.jsx)("span",{className:"text-text-main",children:af})]}):ad.length>0?(0,d.jsx)("span",{className:"text-[var(--warn)]",children:"Click a model to set/clear active"}):"Select models to add"})]})]})]}),(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Subagent Model"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)("input",{type:"text",value:S,onChange:a=>T(a.target.value),placeholder:Q||"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,d.jsx)("button",{onClick:()=>Y(!0),disabled:!m?.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 ${m?.length?"bg-surface border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${h().selectButton}`,children:"Select Model"}),S&&(0,d.jsx)("button",{onClick:()=>T(""),className:"p-1 text-text-muted hover:text-[var(--danger)] rounded transition-colors",title:"Clear (will use main model)",children:(0,d.jsx)(e.default,{className:"text-[14px]",children:"close"})})]})]}),K&&(0,d.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===K.type?h().positive:h().danger}`,children:[(0,d.jsx)(e.default,{className:"text-[14px]",children:"success"===K.type?"check_circle":"error"}),(0,d.jsx)("span",{children:K.text})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,d.jsxs)(j.$n,{variant:"primary",size:"sm",onClick:an,disabled:0===ad.length,loading:G,children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"save"}),"Apply"]}),(0,d.jsxs)(j.$n,{variant:"outline",size:"sm",onClick:ao,disabled:!A.hasJRouter,loading:I,children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,d.jsxs)(j.$n,{variant:"ghost",size:"sm",onClick:()=>aa(!0),children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),V&&(0,d.jsx)(j.rq,{className:h().modelPicker,isOpen:V,onClose:()=>{W(!1),ai(ah.current)},onSelect:a=>{!ad.includes(a.value)&&(ae([...ad,a.value]),af||ag(a.value))},onDeselect:a=>{let b=ad.filter(b=>b!==a.value);ae(b),af===a.value&&ag(b[0]||"")},selectedModel:null,activeProviders:m,modelAliases:Z,addedModelValues:ad,closeOnSelect:!1,title:"Add Model for OpenCode"}),X&&(0,d.jsx)(j.rq,{className:h().modelPicker,isOpen:X,onClose:()=>Y(!1),onSelect:a=>{T(a.value),Y(!1)},selectedModel:S,activeProviders:m,modelAliases:Z,title:"Select Subagent Model for OpenCode"}),(0,d.jsx)(j.uR,{isOpen:_,onClose:()=>aa(!1),title:"OpenCode - Manual Configuration",configs:(t=O&&O.trim()?O:n?"<API_KEY_FROM_DASHBOARD>":"sk_jrouter",u=ad.length>0?ad:["provider/model-id"],w=af||ad[0]||u[0],x=S||w,z={},u.forEach(a=>{z[a]={name:a,modalities:{input:["text","image"],output:["text"]}}}),[{filename:"~/.config/opencode/opencode.json",content:JSON.stringify({provider:{jrouter:{npm:"@ai-sdk/openai-compatible",options:{baseURL:al(),apiKey:t},models:z}},model:`jrouter/${w}`,agent:{explorer:{description:"Fast explorer subagent for codebase exploration",mode:"subagent",model:`jrouter/${x}`}}},null,2)}])})]})}let V="/api/cli-tools/cowork-settings";function W({tool:a,isExpanded:b,onToggle:c,baseUrl:g,apiKeys:l,activeProviders:m,hasActiveProviders:n,cloudEnabled:o,cloudUrl:p,tunnelEnabled:q,tunnelPublicUrl:r,tailscaleEnabled:s,tailscaleUrl:t,initialStatus:u}){let w,x,z,A,[C,D]=(0,i.useState)(u||null),[E,F]=(0,i.useState)(!1),[G,H]=(0,i.useState)(!1),[I,J]=(0,i.useState)(!1),[K,L]=(0,i.useState)(null),[M,N]=(0,i.useState)(""),[O,P]=(0,i.useState)([]),[Q,R]=(0,i.useState)(!1),[S,T]=(0,i.useState)(""),[U,X]=(0,i.useState)([]),[Y,Z]=(0,i.useState)([]),[$,_]=(0,i.useState)([]),[aa,ab]=(0,i.useState)({}),[ac,ad]=(0,i.useState)(!1),[ae,af]=(0,i.useState)(!1),[ag,ah]=(0,i.useState)(!1),[ai,aj]=(0,i.useState)(!1),[ak,al]=(0,i.useState)({name:"",url:""}),am=async()=>{F(!0);try{let a=await fetch(V),b=await a.json();D(b)}catch(a){D({installed:!1,error:a.message})}finally{F(!1)}},an=()=>{let a;return(a=(S||"").replace(/\/+$/,""))?/\/v1$/.test(a)?a:`${a}/v1`:""},ao=C?.cowork?.baseUrl||"",ap=C?.installed?C?.cowork?.baseUrl?C.hasJRouter?"configured":"other":"not_configured":null,aq=async()=>{L(null);let a=an();if(0===O.length)return void L({type:"error",text:"Please select at least one model"});H(!0);try{let b=M?.trim()||(l?.length>0?l[0].key:null)||(o?null:"sk_jrouter"),c=await fetch(V,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:a,apiKey:b,models:O,plugins:U,localPlugins:Y,customPlugins:$})}),d=await c.json();c.ok?(v(an(),{tunnelPublicUrl:r,tailscaleUrl:t}),L({type:"success",text:"Settings applied. Quit & reopen Claude Desktop to load."}),am()):L({type:"error",text:d.error||"Failed to apply settings"})}catch(a){L({type:"error",text:a.message})}finally{H(!1)}},ar=async({name:a,models:b})=>{try{let c=await fetch("/api/combos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:a,models:b})});if(!c.ok){let a=await c.json();L({type:"error",text:a.error||"Failed to create combo"});return}O.includes(a)||P([...O,a]),ad(!1),L({type:"success",text:`Combo "${a}" created and added.`})}catch(a){L({type:"error",text:a.message})}},as=a=>{let b=a?.value||a?.name||a;P(a=>a.filter(a=>a!==b))},at=async()=>{J(!0),L(null);try{let a=await fetch(V,{method:"DELETE"}),b=await a.json();a.ok?(L({type:"success",text:"Settings reset successfully"}),P([]),X(C?.defaultPlugins||[]),Z([]),_([]),am()):L({type:"error",text:b.error||"Failed to reset"})}catch(a){L({type:"error",text:a.message})}finally{J(!1)}};return(0,d.jsxs)(j.Zp,{padding:"none",className:h().panel,children:[(0,d.jsxs)("div",{className:h().panelHeader,onClick:c,children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,d.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,d.jsx)(k.default,{src:a.image,alt:a.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:a=>{a.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,d.jsx)("h3",{className:"font-medium text-sm",children:a.name}),"configured"===ap&&(0,d.jsx)(f.A,{variant:"success",className:h().status,children:"Connected"}),"not_configured"===ap&&(0,d.jsx)(f.A,{variant:"warning",className:h().status,children:"Not configured"}),"other"===ap&&(0,d.jsx)(f.A,{variant:"default",dot:!1,className:h().status,children:"Other"})]}),(0,d.jsx)("p",{className:"text-xs text-text-muted truncate",children:a.description})]})]}),(0,d.jsx)(e.default,{className:`text-text-muted text-[20px] transition-transform ${b?"rotate-180":""}`,children:"expand_more"})]}),b&&(0,d.jsxs)("div",{className:h().body,children:[E&&(0,d.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,d.jsx)(e.default,{className:"animate-spin",children:"progress_activity"}),(0,d.jsx)("span",{children:"Checking Claude Cowork..."})]}),!E&&C&&!C.installed&&(0,d.jsxs)("div",{className:`flex flex-col gap-3 p-4 border ${h().notice} ${h().warning}`,children:[(0,d.jsxs)("div",{className:"flex items-start gap-3",children:[(0,d.jsx)(e.default,{className:"text-[var(--warn)]",children:"warning"}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("p",{className:"font-medium text-[var(--warn)]",children:"Claude Desktop (Cowork mode) not detected"}),(0,d.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,d.jsx)("div",{className:"pl-9",children:(0,d.jsxs)(j.$n,{variant:"secondary",size:"sm",onClick:()=>R(!0),children:[(0,d.jsx)(e.default,{className:"text-[18px] mr-1",children:"content_copy"}),"Manual Config"]})})]}),!E&&C?.installed&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Select Endpoint"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(y,{value:an(),onChange:a=>T((a||"").replace(/\/v1\/?$/,"")),tunnelEnabled:q,tunnelPublicUrl:r,tailscaleEnabled:s,tailscaleUrl:t,cloudEnabled:o,cloudUrl:p,currentUrl:ao})]}),C?.cowork?.baseUrl&&(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Current"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.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:C.cowork.baseUrl})]}),(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"API Key"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(B,{value:M,onChange:N,apiKeys:l,cloudEnabled:o})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,d.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Models"}),(0,d.jsx)(e.default,{className:"text-text-muted text-[14px]",children:"arrow_forward"}),(0,d.jsxs)("div",{className:"flex-1 flex items-center gap-2",children:[(0,d.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===O.length?(0,d.jsx)("span",{className:"text-xs text-text-muted",children:"No models selected"}):O.map(a=>(0,d.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:[a,(0,d.jsx)("button",{onClick:()=>as(a),className:"ml-0.5 hover:text-[var(--danger)]",children:(0,d.jsx)(e.default,{className:"text-[12px]",children:"close"})})]},a))}),(0,d.jsx)("button",{onClick:()=>ad(!0),disabled:!n,className:`shrink-0 px-2 py-1.5 rounded border text-xs whitespace-nowrap transition-colors ${n?"bg-surface-2 border-border text-text-main hover:bg-surface-2 cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${h().selectButton}`,children:"+ Combo"})]})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-start sm:gap-2",children:[(0,d.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right pt-2",children:"MCP"}),(0,d.jsx)(e.default,{className:"text-text-muted text-[14px] mt-2",children:"arrow_forward"}),(0,d.jsxs)("div",{className:"flex-1 flex flex-col gap-1",children:[U.filter(a=>"exa"!==a.name).map(a=>(0,d.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1 bg-surface rounded border border-border",children:[(0,d.jsx)("span",{className:"text-xs font-medium min-w-0 truncate flex-shrink-0",children:a.title||a.name}),a.oauth&&(0,d.jsx)("span",{className:"text-[8px] text-amber-600 shrink-0",children:"OAuth"}),(0,d.jsxs)("div",{className:"flex-1 flex flex-wrap gap-1 overflow-hidden",style:{maxHeight:"1.5rem"},children:[Array.isArray(a.toolNames)&&a.toolNames.slice(0,6).map(a=>(0,d.jsx)("span",{className:"text-[9px] px-1 py-0.5 rounded bg-black/5 dark:bg-white/5 text-text-muted whitespace-nowrap",children:a},a)),Array.isArray(a.toolNames)&&a.toolNames.length>6&&(0,d.jsxs)("span",{className:"text-[9px] px-1 py-0.5 rounded bg-black/5 dark:bg-white/5 text-text-muted whitespace-nowrap",children:["+",a.toolNames.length-6]})]}),(0,d.jsx)("button",{onClick:()=>{var b;return b=a.name,void X(U.filter(a=>a.name!==b))},className:"shrink-0 hover:text-[var(--danger)] ml-auto",children:(0,d.jsx)(e.default,{className:"text-[12px]",children:"close"})})]},a.name)),$.map(a=>(0,d.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1 bg-surface rounded border border-border",children:[(0,d.jsx)("span",{className:"text-xs font-medium min-w-0 truncate flex-shrink-0",children:a.name}),(0,d.jsx)("span",{className:"badge-neutral shrink-0",children:"custom"}),(0,d.jsx)("span",{className:"flex-1 text-[9px] text-text-muted truncate",children:a.url}),(0,d.jsx)("button",{onClick:()=>_($.filter(b=>b.name!==a.name)),className:"shrink-0 hover:text-[var(--danger)] ml-auto",children:(0,d.jsx)(e.default,{className:"text-[12px]",children:"close"})})]},a.name)),0===U.filter(a=>"exa"!==a.name).length&&0===$.length&&(0,d.jsx)("div",{className:"px-2 py-1.5 bg-surface rounded border border-border text-xs text-text-muted",children:"No MCPs added"}),(0,d.jsxs)("div",{className:"flex items-center gap-2 mt-0.5",children:[(0,d.jsx)("button",{onClick:()=>ah(!0),className:"px-2 py-1 rounded border text-xs bg-surface-2 border-border text-text-main hover:bg-surface-2 cursor-pointer whitespace-nowrap",children:"+ Browse"}),(0,d.jsx)("button",{onClick:()=>{al({name:"",url:""}),aj(!0)},className:"px-2 py-1 rounded border text-xs bg-surface border-border text-text-muted hover:border-[var(--text-2)] hover:text-text-main cursor-pointer whitespace-nowrap",children:"+ Custom"}),(0,d.jsx)("a",{href:"https://mcp.so",target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-text-muted hover:text-text-main underline ml-auto",children:"Find MCPs →"})]})]})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-start sm:gap-2",children:[(0,d.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right pt-1",children:"Tools"}),(0,d.jsx)(e.default,{className:"text-text-muted text-[14px] mt-1.5",children:"arrow_forward"}),(0,d.jsxs)("div",{className:"flex-1 flex flex-col gap-1.5",children:[(w=U.some(a=>"exa"===a.name),x=(C?.defaultPlugins||[]).find(a=>"exa"===a.name),(0,d.jsxs)("label",{className:"flex items-start gap-2 cursor-pointer px-2 py-1.5 bg-surface rounded border border-border",children:[(0,d.jsx)("input",{type:"checkbox",checked:w,onChange:a=>{a.target.checked&&x?X([...U.filter(a=>"exa"!==a.name),x]):X(U.filter(a=>"exa"!==a.name))},className:"mt-0.5"}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("div",{className:"text-xs font-medium",children:"Web Search & Fetch (Exa)"}),(0,d.jsx)("p",{className:"text-[10px] text-text-muted leading-snug",children:"Replaces built-in WebSearch/WebFetch. Auto-strips duplicates from tool list."})]})]})),(()=>{let a=(C?.localStdioPlugins||[]).find(a=>"browsermcp"===a.name);if(!a)return null;let b=Y.includes("browsermcp");return(0,d.jsxs)("label",{className:"flex items-start gap-2 cursor-pointer px-2 py-1.5 bg-surface rounded border border-border",children:[(0,d.jsx)("input",{type:"checkbox",checked:b,onChange:a=>Z(a.target.checked?[...Y,"browsermcp"]:Y.filter(a=>"browsermcp"!==a)),className:"mt-0.5"}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("div",{className:"text-xs font-medium",children:"Browser Control (Browser MCP)"}),(0,d.jsxs)("p",{className:"text-[10px] text-text-muted leading-snug",children:["Controls your running Chrome. Auto-strips Cowork's built-in browser tools."," ",(0,d.jsx)("a",{href:a.extensionUrl,target:"_blank",rel:"noopener noreferrer",className:"text-text-main underline",children:"Install Chrome extension"})]})]})]})})()]})]}),Array.isArray(C?.localStdioPlugins)&&C.localStdioPlugins.filter(a=>"browsermcp"!==a.name).length>0&&(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-start sm:gap-2",children:[(0,d.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right pt-1",children:"Local Plugins"}),(0,d.jsx)(e.default,{className:"text-text-muted text-[14px] mt-1.5",children:"arrow_forward"}),(0,d.jsxs)("div",{className:"flex-1 flex flex-col gap-2",children:[(0,d.jsx)("div",{className:"flex flex-col gap-1.5 px-2 py-1.5 bg-surface rounded border border-border",children:C.localStdioPlugins.filter(a=>"browsermcp"!==a.name).map(a=>{let b=Y.includes(a.name);return(0,d.jsxs)("label",{className:"flex items-start gap-2 cursor-pointer",children:[(0,d.jsx)("input",{type:"checkbox",checked:b,onChange:b=>Z(b.target.checked?[...Y,a.name]:Y.filter(b=>b!==a.name)),className:"mt-0.5"}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,d.jsx)("span",{className:"text-xs font-medium",children:a.title}),(0,d.jsx)("span",{className:"text-[8px] text-amber-600",children:"stdio"})]}),(0,d.jsx)("p",{className:"text-[10px] text-text-muted leading-snug",children:a.description}),a.extensionUrl&&(0,d.jsx)("a",{href:a.extensionUrl,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-text-main underline",children:"Install Chrome extension"})]})]},a.name)})}),(0,d.jsxs)("p",{className:"text-[10px] text-text-muted leading-snug",children:["⚠️ Local plugins run as subprocess via ",(0,d.jsx)("code",{className:"px-1 py-0.5 rounded bg-black/5 dark:bg-white/5",children:"npx"}),". Requires Node.js installed."]})]})]})]}),K&&(0,d.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===K.type?h().positive:h().danger}`,children:[(0,d.jsx)(e.default,{className:"text-[14px]",children:"success"===K.type?"check_circle":"error"}),(0,d.jsx)("span",{children:K.text})]}),(0,d.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2",children:[(0,d.jsxs)(j.$n,{variant:"primary",size:"sm",onClick:aq,disabled:0===O.length,loading:G,className:"w-full sm:w-auto",children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"save"}),"Apply"]}),(0,d.jsxs)(j.$n,{variant:"outline",size:"sm",onClick:at,disabled:!C.hasJRouter,loading:I,className:"w-full sm:w-auto",children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,d.jsxs)(j.$n,{variant:"ghost",size:"sm",onClick:()=>R(!0),className:"w-full sm:w-auto",children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),(0,d.jsx)(j.uR,{isOpen:Q,onClose:()=>R(!1),title:"Claude Cowork - Manual Configuration",configs:(z=M&&M.trim()?M:o?"<API_KEY_FROM_DASHBOARD>":"sk_jrouter",A=O.length>0?O:["provider/model-id"],[{filename:"~/Library/Application Support/Claude-3p/configLibrary/<appliedId>.json",content:JSON.stringify({inferenceProvider:"gateway",inferenceGatewayBaseUrl:an()||"https://your-public-host/v1",inferenceGatewayApiKey:z,inferenceModels:A.map(a=>({name:a}))},null,2)}])}),ac&&(0,d.jsx)(j.CK,{isOpen:ac,combo:null,onClose:()=>ad(!1),onSave:ar,activeProviders:m,forcePrefix:"claude-",title:"Create Cowork Combo"}),ae&&(0,d.jsx)(j.rq,{className:h().modelPicker,isOpen:ae,onClose:()=>af(!1),onSelect:a=>{let b=a?.value||a?.name||a;!b||O.includes(b)||P(a=>[...a,b])},onDeselect:as,activeProviders:m,modelAliases:aa,title:"Select Cowork Model",addedModelValues:O,closeOnSelect:!1}),(0,d.jsx)(j.Nf,{isOpen:ag,onClose:()=>ah(!1),onAdd:a=>{U.some(b=>b.name===a.name)||X([...U,a])},addedNames:U.map(a=>a.name)}),ai&&(0,d.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40",onClick:()=>aj(!1),children:(0,d.jsxs)("div",{className:"bg-surface border border-border rounded-[var(--r3)] shadow-[var(--shadow-pop)] w-full max-w-sm mx-4 p-5 flex flex-col gap-4",onClick:a=>a.stopPropagation(),children:[(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsx)("h3",{className:"font-semibold text-sm",children:"Add Custom MCP"}),(0,d.jsx)("button",{onClick:()=>aj(!1),className:"text-text-muted hover:text-text-main",children:(0,d.jsx)(e.default,{className:"text-[18px]",children:"close"})})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,d.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,d.jsx)("label",{className:"text-[11px] text-text-muted font-medium",children:"Name"}),(0,d.jsx)("input",{type:"text",placeholder:"my-mcp",value:ak.name,onChange:a=>al(b=>({...b,name:a.target.value.replace(/\s+/g,"-").toLowerCase()})),className:"px-2 py-1.5 rounded border border-border bg-surface text-xs"})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,d.jsx)("label",{className:"text-[11px] text-text-muted font-medium",children:"SSE URL"}),(0,d.jsx)("input",{type:"text",placeholder:"https://your-mcp-server.com/sse",value:ak.url,onChange:a=>al(b=>({...b,url:a.target.value})),className:"px-2 py-1.5 rounded border border-border bg-surface text-xs"})]})]}),(0,d.jsxs)("div",{className:"flex gap-2 justify-end",children:[(0,d.jsx)("button",{onClick:()=>aj(!1),className:"px-3 py-1.5 rounded border border-border text-xs text-text-muted hover:bg-surface cursor-pointer",children:"Cancel"}),(0,d.jsx)("button",{onClick:()=>{let a=ak.name.trim();a&&ak.url.trim()&&(_(b=>[...b.filter(b=>b.name!==a),{name:a,url:ak.url.trim(),transport:"sse",custom:!0}]),aj(!1))},className:"px-3 py-1.5 rounded bg-[var(--text)] text-[var(--bg)] text-xs font-medium hover:opacity-90 cursor-pointer",children:"Add"})]})]})})]})}function X({tool:a,isExpanded:b,onToggle:c,baseUrl:g,apiKeys:l,activeProviders:m,cloudEnabled:n,initialStatus:o,tunnelEnabled:p,tunnelPublicUrl:q,tailscaleEnabled:r,tailscaleUrl:s}){let t,u,[w,x]=(0,i.useState)(o||null),[z,A]=(0,i.useState)(!1),[C,E]=(0,i.useState)(!1),[F,G]=(0,i.useState)(!1),[H,I]=(0,i.useState)(null),[J,K]=(0,i.useState)(!1),[L,M]=(0,i.useState)(""),[N,O]=(0,i.useState)(""),[P,Q]=(0,i.useState)(!1),[R,S]=(0,i.useState)({}),[T,U]=(0,i.useState)(!1),[V,W]=(0,i.useState)(""),Y=w?.settings?.openAiBaseUrl||"",Z=w?.installed?w.hasJRouter?D(w.settings?.openAiBaseUrl||"",{tunnelPublicUrl:q,tailscaleUrl:s})?"configured":"other":"not_configured":null,$=()=>{let a=V||`${g}/v1`;return a.endsWith("/v1")?a:`${a}/v1`},_=async()=>{A(!0);try{let a=await fetch("/api/cli-tools/cline-settings"),b=await a.json();x(b)}catch(a){x({installed:!1,error:a.message})}finally{A(!1)}},aa=async()=>{E(!0),I(null);try{let a=L&&L.trim()||n?L:"sk_jrouter",b=await fetch("/api/cli-tools/cline-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:$(),apiKey:a,model:N})}),c=await b.json();b.ok?(v($(),{tunnelPublicUrl:q,tailscaleUrl:s}),I({type:"success",text:"Settings applied successfully!"}),_()):I({type:"error",text:c.error||"Failed to apply settings"})}catch(a){I({type:"error",text:a.message})}finally{E(!1)}},ab=async()=>{G(!0),I(null);try{let a=await fetch("/api/cli-tools/cline-settings",{method:"DELETE"}),b=await a.json();a.ok?(I({type:"success",text:"Settings reset successfully!"}),O(""),_()):I({type:"error",text:b.error||"Failed to reset settings"})}catch(a){I({type:"error",text:a.message})}finally{G(!1)}};return(0,d.jsxs)(j.Zp,{padding:"none",className:h().panel,children:[(0,d.jsxs)("div",{className:h().panelHeader,onClick:c,children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,d.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,d.jsx)(k.default,{src:"/providers/cline.png",alt:a.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:a=>{a.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,d.jsx)("h3",{className:"font-medium text-sm",children:a.name}),"configured"===Z&&(0,d.jsx)(f.A,{variant:"success",className:h().status,children:"Connected"}),"not_configured"===Z&&(0,d.jsx)(f.A,{variant:"warning",className:h().status,children:"Not configured"}),"other"===Z&&(0,d.jsx)(f.A,{variant:"default",dot:!1,className:h().status,children:"Other"})]}),(0,d.jsx)("p",{className:"text-xs text-text-muted truncate",children:a.description})]})]}),(0,d.jsx)(e.default,{className:`text-text-muted text-[20px] transition-transform ${b?"rotate-180":""}`,children:"expand_more"})]}),b&&(0,d.jsxs)("div",{className:h().body,children:[z&&(0,d.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,d.jsx)(e.default,{className:"animate-spin",children:"progress_activity"}),(0,d.jsx)("span",{children:"Checking Cline..."})]}),!z&&w&&!w.installed&&(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,d.jsxs)("div",{className:`flex flex-col gap-3 p-4 border ${h().notice} ${h().warning}`,children:[(0,d.jsxs)("div",{className:"flex items-start gap-3",children:[(0,d.jsx)(e.default,{className:"text-[var(--warn)]",children:"warning"}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("p",{className:"font-medium text-[var(--warn)]",children:"Cline not detected locally"}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if JRouter is deployed on a remote server."})]})]}),(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2 sm:pl-9",children:[(0,d.jsxs)(j.$n,{variant:"secondary",size:"sm",onClick:()=>U(!0),children:[(0,d.jsx)(e.default,{className:"text-[18px] mr-1",children:"content_copy"}),"Manual Config"]}),(0,d.jsxs)(j.$n,{variant:"outline",size:"sm",onClick:()=>K(!J),children:[(0,d.jsx)(e.default,{className:"text-[18px] mr-1",children:J?"expand_less":"help"}),J?"Hide":"How to Install"]})]})]}),J&&(0,d.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,d.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,d.jsx)("div",{className:"space-y-3 text-sm",children:(0,d.jsxs)("p",{className:"text-text-muted",children:["Install Cline VS Code extension or CLI from ",(0,d.jsx)("a",{className:"text-text-main underline",href:"https://docs.cline.bot/",target:"_blank",rel:"noreferrer",children:"docs.cline.bot"}),"."]})})]})]}),!z&&w?.installed&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Select Endpoint"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(y,{value:V||V||`${g}/v1`,onChange:W,requiresExternalUrl:a.requiresExternalUrl,tunnelEnabled:p,tunnelPublicUrl:q,tailscaleEnabled:r,tailscaleUrl:s,currentUrl:Y})]}),w?.settings?.openAiBaseUrl&&(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Current"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.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.openAiBaseUrl})]}),(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"API Key"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(B,{value:L,onChange:M,apiKeys:l,cloudEnabled:n})]}),(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Model"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,d.jsx)("input",{type:"text",value:N,onChange:a=>O(a.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"}),N&&(0,d.jsx)("button",{onClick:()=>O(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-[var(--danger)] rounded transition-colors",title:"Clear",children:(0,d.jsx)(e.default,{className:"text-[14px]",children:"close"})})]}),(0,d.jsx)("button",{onClick:()=>Q(!0),disabled:!m?.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 ${m?.length?"bg-surface border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${h().selectButton}`,children:"Select Model"})]})]}),H&&(0,d.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===H.type?h().positive:h().danger}`,children:[(0,d.jsx)(e.default,{className:"text-[14px]",children:"success"===H.type?"check_circle":"error"}),(0,d.jsx)("span",{children:H.text})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,d.jsxs)(j.$n,{variant:"primary",size:"sm",onClick:aa,disabled:!L&&n&&l.length>0||!N,loading:C,children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"save"}),"Apply"]}),(0,d.jsxs)(j.$n,{variant:"outline",size:"sm",onClick:ab,disabled:F,loading:F,children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,d.jsxs)(j.$n,{variant:"ghost",size:"sm",onClick:()=>U(!0),children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),P&&(0,d.jsx)(j.rq,{className:h().modelPicker,isOpen:P,onClose:()=>Q(!1),onSelect:a=>{O(a.value),Q(!1)},selectedModel:N,activeProviders:m,modelAliases:R,title:"Select Model for Cline"}),(0,d.jsx)(j.uR,{isOpen:T,onClose:()=>U(!1),title:"Cline - Manual Configuration",configs:(t=L&&L.trim()?L:n?"<API_KEY_FROM_DASHBOARD>":"sk_jrouter",[{filename:"~/.cline/data/globalState.json",content:JSON.stringify({actModeApiProvider:"openai",planModeApiProvider:"openai",openAiBaseUrl:(u=$()).endsWith("/v1")?u.slice(0,-3):u,openAiModelId:N||"provider/model-id",planModeOpenAiModelId:N||"provider/model-id"},null,2)},{filename:"~/.cline/data/secrets.json",content:JSON.stringify({openAiApiKey:t},null,2)}])})]})}function Y({tool:a,isExpanded:b,onToggle:c,baseUrl:g,apiKeys:l,activeProviders:m,cloudEnabled:n,initialStatus:o,tunnelEnabled:p,tunnelPublicUrl:q,tailscaleEnabled:r,tailscaleUrl:s}){let[t,u]=(0,i.useState)(o||null),[w,x]=(0,i.useState)(!1),[z,A]=(0,i.useState)(!1),[C,D]=(0,i.useState)(!1),[E,F]=(0,i.useState)(null),[G,H]=(0,i.useState)(!1),[I,J]=(0,i.useState)(""),[K,L]=(0,i.useState)(""),[M,N]=(0,i.useState)(!1),[O,P]=(0,i.useState)({}),[Q,R]=(0,i.useState)(!1),[S,T]=(0,i.useState)(""),U=t?.installed?t.hasJRouter?"configured":"not_configured":null,V=()=>{let a=S||`${g}/v1`;return a.endsWith("/v1")?a:`${a}/v1`},W=async()=>{x(!0);try{let a=await fetch("/api/cli-tools/kilo-settings"),b=await a.json();u(b)}catch(a){u({installed:!1,error:a.message})}finally{x(!1)}},X=async()=>{A(!0),F(null);try{let a=I&&I.trim()||n?I:"sk_jrouter",b=await fetch("/api/cli-tools/kilo-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:V(),apiKey:a,model:K})}),c=await b.json();b.ok?(v(V(),{tunnelPublicUrl:q,tailscaleUrl:s}),F({type:"success",text:"Settings applied successfully!"}),W()):F({type:"error",text:c.error||"Failed to apply settings"})}catch(a){F({type:"error",text:a.message})}finally{A(!1)}},Z=async()=>{D(!0),F(null);try{let a=await fetch("/api/cli-tools/kilo-settings",{method:"DELETE"}),b=await a.json();a.ok?(F({type:"success",text:"Settings reset successfully!"}),L(""),W()):F({type:"error",text:b.error||"Failed to reset settings"})}catch(a){F({type:"error",text:a.message})}finally{D(!1)}};return(0,d.jsxs)(j.Zp,{padding:"none",className:h().panel,children:[(0,d.jsxs)("div",{className:h().panelHeader,onClick:c,children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,d.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,d.jsx)(k.default,{src:"/providers/kilocode.png",alt:a.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:a=>{a.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,d.jsx)("h3",{className:"font-medium text-sm",children:a.name}),"configured"===U&&(0,d.jsx)(f.A,{variant:"success",className:h().status,children:"Connected"}),"not_configured"===U&&(0,d.jsx)(f.A,{variant:"warning",className:h().status,children:"Not configured"})]}),(0,d.jsx)("p",{className:"text-xs text-text-muted truncate",children:a.description})]})]}),(0,d.jsx)(e.default,{className:`text-text-muted text-[20px] transition-transform ${b?"rotate-180":""}`,children:"expand_more"})]}),b&&(0,d.jsxs)("div",{className:h().body,children:[w&&(0,d.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,d.jsx)(e.default,{className:"animate-spin",children:"progress_activity"}),(0,d.jsx)("span",{children:"Checking Kilo Code..."})]}),!w&&t&&!t.installed&&(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,d.jsxs)("div",{className:`flex flex-col gap-3 p-4 border ${h().notice} ${h().warning}`,children:[(0,d.jsxs)("div",{className:"flex items-start gap-3",children:[(0,d.jsx)(e.default,{className:"text-[var(--warn)]",children:"warning"}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("p",{className:"font-medium text-[var(--warn)]",children:"Kilo Code not detected locally"}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if JRouter is deployed on a remote server."})]})]}),(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2 sm:pl-9",children:[(0,d.jsxs)(j.$n,{variant:"secondary",size:"sm",onClick:()=>R(!0),children:[(0,d.jsx)(e.default,{className:"text-[18px] mr-1",children:"content_copy"}),"Manual Config"]}),(0,d.jsxs)(j.$n,{variant:"outline",size:"sm",onClick:()=>H(!G),children:[(0,d.jsx)(e.default,{className:"text-[18px] mr-1",children:G?"expand_less":"help"}),G?"Hide":"How to Install"]})]})]}),G&&(0,d.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,d.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,d.jsxs)("p",{className:"text-sm text-text-muted",children:["Install Kilo Code from ",(0,d.jsx)("a",{className:"text-text-main underline",href:"https://kilocode.ai",target:"_blank",rel:"noreferrer",children:"kilocode.ai"})," or VS Code extension marketplace."]})]})]}),!w&&t?.installed&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Select Endpoint"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(y,{value:S||S||`${g}/v1`,onChange:T,requiresExternalUrl:a.requiresExternalUrl,tunnelEnabled:p,tunnelPublicUrl:q,tailscaleEnabled:r,tailscaleUrl:s})]}),(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"API Key"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(B,{value:I,onChange:J,apiKeys:l,cloudEnabled:n})]}),(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Model"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,d.jsx)("input",{type:"text",value:K,onChange:a=>L(a.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"}),K&&(0,d.jsx)("button",{onClick:()=>L(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-[var(--danger)] rounded transition-colors",title:"Clear",children:(0,d.jsx)(e.default,{className:"text-[14px]",children:"close"})})]}),(0,d.jsx)("button",{onClick:()=>N(!0),disabled:!m?.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 ${m?.length?"bg-surface border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${h().selectButton}`,children:"Select Model"})]})]}),E&&(0,d.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===E.type?h().positive:h().danger}`,children:[(0,d.jsx)(e.default,{className:"text-[14px]",children:"success"===E.type?"check_circle":"error"}),(0,d.jsx)("span",{children:E.text})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,d.jsxs)(j.$n,{variant:"primary",size:"sm",onClick:X,disabled:!I&&n&&l.length>0||!K,loading:z,children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"save"}),"Apply"]}),(0,d.jsxs)(j.$n,{variant:"outline",size:"sm",onClick:Z,disabled:C,loading:C,children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,d.jsxs)(j.$n,{variant:"ghost",size:"sm",onClick:()=>R(!0),children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),M&&(0,d.jsx)(j.rq,{className:h().modelPicker,isOpen:M,onClose:()=>N(!1),onSelect:a=>{L(a.value),N(!1)},selectedModel:K,activeProviders:m,modelAliases:O,title:"Select Model for Kilo Code"}),(0,d.jsx)(j.uR,{isOpen:Q,onClose:()=>R(!1),title:"Kilo Code - Manual Configuration",configs:[{filename:"~/.local/share/kilo/auth.json",content:JSON.stringify({"openai-compatible":{type:"api-key",apiKey:I&&I.trim()?I:n?"<API_KEY_FROM_DASHBOARD>":"sk_jrouter",baseUrl:V(),model:K||"provider/model-id"}},null,2)}]})]})}let Z="/api/cli-tools/deepseek-tui-settings";function $({tool:a,isExpanded:b,onToggle:c,baseUrl:g,hasActiveProviders:l,apiKeys:m,activeProviders:n,cloudEnabled:o,initialStatus:p,tunnelEnabled:q,tunnelPublicUrl:r,tailscaleEnabled:s,tailscaleUrl:t}){let u,[w,x]=(0,i.useState)(p||null),[z,A]=(0,i.useState)(!1),[C,E]=(0,i.useState)(!1),[F,G]=(0,i.useState)(!1),[H,I]=(0,i.useState)(null),[J,K]=(0,i.useState)(""),[L,M]=(0,i.useState)(""),[N,O]=(0,i.useState)(!1),[P,Q]=(0,i.useState)({}),[R,S]=(0,i.useState)(!1),[T,U]=(0,i.useState)("");(0,i.useRef)(!1);let V=w?.settings?.["providers.openai"]?.base_url||"",W=(()=>{if(!w?.installed)return null;let a=w.settings?.["providers.openai"];return a?.base_url?D(a.base_url,{tunnelPublicUrl:r,tailscaleUrl:t})?"configured":"other":"not_configured"})(),X=async()=>{A(!0);try{let a=await fetch(Z),b=await a.json();x(b)}catch(a){x({installed:!1,error:a.message})}finally{A(!1)}},Y=()=>{let a=T||"http://127.0.0.1:20128";return a.endsWith("/v1")?a:`${a}/v1`},_=async()=>{E(!0),I(null);try{let a=J?.trim()||(m?.length>0?m[0].key:null)||(o?null:"sk_jrouter"),b=await fetch(Z,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:Y(),apiKey:a,model:L})}),c=await b.json();b.ok?(v(Y(),{tunnelPublicUrl:r,tailscaleUrl:t}),I({type:"success",text:"Settings applied successfully!"}),X()):I({type:"error",text:c.error||"Failed to apply settings"})}catch(a){I({type:"error",text:a.message})}finally{E(!1)}},aa=async()=>{G(!0),I(null);try{let a=await fetch(Z,{method:"DELETE"}),b=await a.json();a.ok?(I({type:"success",text:"Settings reset successfully!"}),M(""),X()):I({type:"error",text:b.error||"Failed to reset settings"})}catch(a){I({type:"error",text:a.message})}finally{G(!1)}};return(0,d.jsxs)(j.Zp,{padding:"none",className:h().panel,children:[(0,d.jsxs)("div",{className:h().panelHeader,onClick:c,children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,d.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,d.jsx)(k.default,{src:a.image||"/providers/deepseek-tui.png",alt:a.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:a=>{a.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,d.jsx)("h3",{className:"font-medium text-sm",children:a.name}),"configured"===W&&(0,d.jsx)(f.A,{variant:"success",className:h().status,children:"Connected"}),"not_configured"===W&&(0,d.jsx)(f.A,{variant:"warning",className:h().status,children:"Not configured"}),"other"===W&&(0,d.jsx)(f.A,{variant:"default",dot:!1,className:h().status,children:"Other"})]}),(0,d.jsx)("p",{className:"text-xs text-text-muted truncate",children:a.description})]})]}),(0,d.jsx)(e.default,{className:`text-text-muted text-[20px] transition-transform ${b?"rotate-180":""}`,children:"expand_more"})]}),b&&(0,d.jsxs)("div",{className:h().body,children:[z&&(0,d.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,d.jsx)(e.default,{className:"animate-spin",children:"progress_activity"}),(0,d.jsx)("span",{children:"Checking DeepSeek TUI..."})]}),!z&&w&&!w.installed&&(0,d.jsx)("div",{className:"flex flex-col gap-4",children:(0,d.jsxs)("div",{className:`flex flex-col gap-3 p-4 border ${h().notice} ${h().warning}`,children:[(0,d.jsxs)("div",{className:"flex items-start gap-3",children:[(0,d.jsx)(e.default,{className:"text-[var(--warn)]",children:"warning"}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("p",{className:"font-medium text-[var(--warn)]",children:"DeepSeek TUI not detected locally"}),(0,d.jsx)("p",{className:"text-sm text-text-muted mt-1",children:"Install via npm:"}),(0,d.jsx)("code",{className:"block mt-2 p-2 bg-black/20 rounded text-xs font-mono",children:"npm install -g deepseek-tui"}),(0,d.jsx)("p",{className:"text-sm text-text-muted mt-2",children:"Manual configuration is still available if JRouter is deployed on a remote server."})]})]}),(0,d.jsx)("div",{className:"flex flex-wrap items-center gap-2 sm:pl-9",children:(0,d.jsxs)(j.$n,{variant:"secondary",size:"sm",onClick:()=>S(!0),children:[(0,d.jsx)(e.default,{className:"text-[18px] mr-1",children:"content_copy"}),"Manual Config"]})})]})}),!z&&w?.installed&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[a.notes&&a.notes.length>0&&(0,d.jsx)("div",{className:"flex flex-col gap-2 mb-2",children:a.notes.map((a,b)=>(0,d.jsxs)("div",{className:`flex items-start gap-2 p-2 rounded text-xs ${"warning"===a.type?h().warning:"error"===a.type?h().danger:h().neutral}`,children:[(0,d.jsx)(e.default,{className:"text-[14px] mt-0.5",children:"warning"===a.type?"warning":"error"===a.type?"error":"info"}),(0,d.jsx)("span",{children:a.text})]},b))}),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Select Endpoint"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(y,{value:T||Y(),onChange:U,requiresExternalUrl:a.requiresExternalUrl,tunnelEnabled:q,tunnelPublicUrl:r,tailscaleEnabled:s,tailscaleUrl:t,currentUrl:V})]}),w?.settings?.["providers.openai"]?.base_url&&(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Current"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.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["providers.openai"].base_url})]}),(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"API Key"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(B,{value:J,onChange:K,apiKeys:m,cloudEnabled:o})]}),(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Default Model"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,d.jsx)("input",{type:"text",value:L,onChange:a=>M(a.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,d.jsx)("button",{onClick:()=>M(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-[var(--danger)] rounded transition-colors",title:"Clear",children:(0,d.jsx)(e.default,{className:"text-[14px]",children:"close"})})]}),(0,d.jsx)("button",{onClick:()=>O(!0),disabled:!l,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 ${l?"bg-surface border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${h().selectButton}`,children:"Select"})]})]}),H&&(0,d.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===H.type?h().positive:h().danger}`,children:[(0,d.jsx)(e.default,{className:"text-[14px]",children:"success"===H.type?"check_circle":"error"}),(0,d.jsx)("span",{children:H.text})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,d.jsxs)(j.$n,{variant:"primary",size:"sm",onClick:_,disabled:!L,loading:C,children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"save"}),"Apply"]}),(0,d.jsxs)(j.$n,{variant:"outline",size:"sm",onClick:aa,disabled:!w?.hasJRouter,loading:F,children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,d.jsxs)(j.$n,{variant:"ghost",size:"sm",onClick:()=>S(!0),children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),N&&(0,d.jsx)(j.rq,{className:h().modelPicker,isOpen:N,onClose:()=>O(!1),onSelect:a=>{M(a.value),O(!1)},selectedModel:L,activeProviders:n,modelAliases:P,title:"Select Model for DeepSeek TUI"}),(0,d.jsx)(j.uR,{isOpen:R,onClose:()=>S(!1),title:"DeepSeek TUI - Manual Configuration",configs:(u=J&&J.trim()?J:o?"<API_KEY_FROM_DASHBOARD>":"sk_jrouter",[{filename:"~/.deepseek/config.toml",content:`[providers.openai]
41
41
  base_url = "${Y()}"
42
42
  api_key = "${u}"
43
43
  model = "${L||"provider/model-id"}"
44
- `}])})]})}function _({tool:a,isExpanded:b,onToggle:c,baseUrl:g,hasActiveProviders:l,apiKeys:m,activeProviders:n,cloudEnabled:o,initialStatus:p,tunnelEnabled:q,tunnelPublicUrl:r,tailscaleEnabled:s,tailscaleUrl:t}){let u,w,[x,z]=(0,i.useState)(p||null),[A,C]=(0,i.useState)(!1),[E,F]=(0,i.useState)(!1),[G,H]=(0,i.useState)(!1),[I,J]=(0,i.useState)(null),[K,L]=(0,i.useState)(""),[M,N]=(0,i.useState)(""),[O,P]=(0,i.useState)(!1),[Q,R]=(0,i.useState)({}),[S,T]=(0,i.useState)(!1),[U,V]=(0,i.useState)("");(0,i.useRef)(!1);let W=x?.config?.providers?.["9router"]?.base_url||"",X=(()=>{if(!x?.installed)return null;if(!x?.has9Router)return"not_configured";let a=x.config?.providers?.["9router"];return a?D(a.base_url,{tunnelPublicUrl:r,tailscaleUrl:t})?"configured":"other":"not_configured"})(),Y=async()=>{C(!0);try{let a=await fetch("/api/cli-tools/jcode-settings"),b=await a.json();z(b)}catch(a){z({installed:!1,error:a.message})}finally{C(!1)}},Z=()=>{let a=U||"http://127.0.0.1:20128";return a.endsWith("/v1")?a:`${a}/v1`},$=async()=>{F(!0),J(null);try{let a=K?.trim()||(m?.length>0?m[0].key:null)||(o?null:"sk_9router"),b=await fetch("/api/cli-tools/jcode-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:Z(),apiKey:a,models:M?[M]:[]})}),c=await b.json();b.ok?(v(Z(),{tunnelPublicUrl:r,tailscaleUrl:t}),J({type:"success",text:"Settings applied successfully!"}),Y()):J({type:"error",text:c.error||"Failed to apply settings"})}catch(a){J({type:"error",text:a.message})}finally{F(!1)}},aa=async()=>{H(!0),J(null);try{let a=await fetch("/api/cli-tools/jcode-settings",{method:"DELETE"}),b=await a.json();a.ok?(J({type:"success",text:"Settings reset successfully!"}),N(""),L(""),Y()):J({type:"error",text:b.error||"Failed to reset settings"})}catch(a){J({type:"error",text:a.message})}finally{H(!1)}};return(0,d.jsxs)(j.Zp,{padding:"none",className:h().panel,children:[(0,d.jsxs)("div",{className:h().panelHeader,onClick:c,children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,d.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,d.jsx)(k.default,{src:a.image||"/providers/jcode.png",alt:a.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:a=>{a.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,d.jsx)("h3",{className:"font-medium text-sm",children:a.name}),"configured"===X&&(0,d.jsx)(f.A,{variant:"success",className:h().status,children:"Connected"}),"not_configured"===X&&(0,d.jsx)(f.A,{variant:"warning",className:h().status,children:"Not configured"}),"other"===X&&(0,d.jsx)(f.A,{variant:"default",dot:!1,className:h().status,children:"Other"})]}),(0,d.jsx)("p",{className:"text-xs text-text-muted truncate",children:a.description})]})]}),(0,d.jsx)(e.default,{className:`text-text-muted text-[20px] transition-transform ${b?"rotate-180":""}`,children:"expand_more"})]}),b&&(0,d.jsxs)("div",{className:h().body,children:[A&&(0,d.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,d.jsx)(e.default,{className:"animate-spin",children:"progress_activity"}),(0,d.jsx)("span",{children:"Checking jcode CLI..."})]}),!A&&x&&!x.installed&&(0,d.jsx)("div",{className:"flex flex-col gap-4",children:(0,d.jsxs)("div",{className:`flex flex-col gap-3 p-4 border ${h().notice} ${h().warning}`,children:[(0,d.jsxs)("div",{className:"flex items-start gap-3",children:[(0,d.jsx)(e.default,{className:"text-[var(--warn)]",children:"warning"}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("p",{className:"font-medium text-[var(--warn)]",children:"jcode CLI not detected locally"}),(0,d.jsx)("p",{className:"text-sm text-text-muted mt-1",children:"Install jcode to enable automatic configuration:"}),(0,d.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,d.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,d.jsx)("div",{className:"flex flex-wrap items-center gap-2 sm:pl-9",children:(0,d.jsxs)(j.$n,{variant:"secondary",size:"sm",onClick:()=>T(!0),children:[(0,d.jsx)(e.default,{className:"text-[18px] mr-1",children:"content_copy"}),"Manual Config"]})})]})}),!A&&x?.installed&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[a.notes&&a.notes.length>0&&(0,d.jsx)("div",{className:"flex flex-col gap-2 mb-2",children:a.notes.map((a,b)=>(0,d.jsxs)("div",{className:`flex items-start gap-2 p-2 rounded text-xs ${"info"===a.type?h().neutral:"warning"===a.type?h().warning:h().neutral}`,children:[(0,d.jsx)(e.default,{className:"text-[14px] mt-0.5",children:"info"===a.type?"info":"warning"===a.type?"warning":"help"}),(0,d.jsx)("span",{children:a.text})]},b))}),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Select Endpoint"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(y,{value:U||((u=U||"http://127.0.0.1:20128").endsWith("/v1")?u:`${u}/v1`),onChange:V,requiresExternalUrl:a.requiresExternalUrl,tunnelEnabled:q,tunnelPublicUrl:r,tailscaleEnabled:s,tailscaleUrl:t,currentUrl:W})]}),x?.config?.providers?.["9router"]?.base_url&&(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Current"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.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:x.config.providers["9router"].base_url})]}),(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"API Key"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(B,{value:K,onChange:L,apiKeys:m,cloudEnabled:o})]}),(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Default Model"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,d.jsx)("input",{type:"text",value:M,onChange:a=>N(a.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"}),M&&(0,d.jsx)("button",{onClick:()=>N(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-[var(--danger)] rounded transition-colors",title:"Clear",children:(0,d.jsx)(e.default,{className:"text-[14px]",children:"close"})})]}),(0,d.jsx)("button",{onClick:()=>P(!0),disabled:!l,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 ${l?"bg-surface border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${h().selectButton}`,children:"Select"})]}),(0,d.jsxs)("div",{className:`flex flex-col gap-1 p-3 border ${h().notice} ${h().neutral}`,children:[(0,d.jsx)("p",{className:"text-xs font-medium text-text-muted",children:"Usage:"}),(0,d.jsx)("code",{className:"text-xs font-mono text-text-muted",children:"jcode --provider-profile 9router"}),(0,d.jsxs)("code",{className:"text-xs font-mono text-text-muted",children:["jcode --provider-profile 9router --model ",M||"cc/claude-opus-4-7"]})]})]}),I&&(0,d.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===I.type?h().positive:h().danger}`,children:[(0,d.jsx)(e.default,{className:"text-[14px]",children:"success"===I.type?"check_circle":"error"}),(0,d.jsx)("span",{children:I.text})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,d.jsxs)(j.$n,{variant:"primary",size:"sm",onClick:$,disabled:!M,loading:E,children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"save"}),"Apply"]}),(0,d.jsxs)(j.$n,{variant:"outline",size:"sm",onClick:aa,disabled:!x?.has9Router,loading:G,children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,d.jsxs)(j.$n,{variant:"ghost",size:"sm",onClick:()=>T(!0),children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),O&&(0,d.jsx)(j.rq,{className:h().modelPicker,isOpen:O,onClose:()=>P(!1),onSelect:a=>{N(a.value),P(!1)},selectedModel:M,activeProviders:n,modelAliases:Q,title:"Select Model for jcode"}),(0,d.jsx)(j.uR,{isOpen:S,onClose:()=>T(!1),title:"jcode - Manual Configuration",configs:(w=K&&K.trim()?K:o?"<API_KEY_FROM_DASHBOARD>":"sk_9router",[{filename:"~/.jcode/config.toml",content:`[providers.9router]
44
+ `}])})]})}function _({tool:a,isExpanded:b,onToggle:c,baseUrl:g,hasActiveProviders:l,apiKeys:m,activeProviders:n,cloudEnabled:o,initialStatus:p,tunnelEnabled:q,tunnelPublicUrl:r,tailscaleEnabled:s,tailscaleUrl:t}){let u,w,[x,z]=(0,i.useState)(p||null),[A,C]=(0,i.useState)(!1),[E,F]=(0,i.useState)(!1),[G,H]=(0,i.useState)(!1),[I,J]=(0,i.useState)(null),[K,L]=(0,i.useState)(""),[M,N]=(0,i.useState)(""),[O,P]=(0,i.useState)(!1),[Q,R]=(0,i.useState)({}),[S,T]=(0,i.useState)(!1),[U,V]=(0,i.useState)("");(0,i.useRef)(!1);let W=x?.config?.providers?.jrouter?.base_url||"",X=(()=>{if(!x?.installed)return null;if(!x?.hasJRouter)return"not_configured";let a=x.config?.providers?.jrouter;return a?D(a.base_url,{tunnelPublicUrl:r,tailscaleUrl:t})?"configured":"other":"not_configured"})(),Y=async()=>{C(!0);try{let a=await fetch("/api/cli-tools/jcode-settings"),b=await a.json();z(b)}catch(a){z({installed:!1,error:a.message})}finally{C(!1)}},Z=()=>{let a=U||"http://127.0.0.1:20128";return a.endsWith("/v1")?a:`${a}/v1`},$=async()=>{F(!0),J(null);try{let a=K?.trim()||(m?.length>0?m[0].key:null)||(o?null:"sk_jrouter"),b=await fetch("/api/cli-tools/jcode-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:Z(),apiKey:a,models:M?[M]:[]})}),c=await b.json();b.ok?(v(Z(),{tunnelPublicUrl:r,tailscaleUrl:t}),J({type:"success",text:"Settings applied successfully!"}),Y()):J({type:"error",text:c.error||"Failed to apply settings"})}catch(a){J({type:"error",text:a.message})}finally{F(!1)}},aa=async()=>{H(!0),J(null);try{let a=await fetch("/api/cli-tools/jcode-settings",{method:"DELETE"}),b=await a.json();a.ok?(J({type:"success",text:"Settings reset successfully!"}),N(""),L(""),Y()):J({type:"error",text:b.error||"Failed to reset settings"})}catch(a){J({type:"error",text:a.message})}finally{H(!1)}};return(0,d.jsxs)(j.Zp,{padding:"none",className:h().panel,children:[(0,d.jsxs)("div",{className:h().panelHeader,onClick:c,children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,d.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,d.jsx)(k.default,{src:a.image||"/providers/jcode.png",alt:a.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:a=>{a.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,d.jsx)("h3",{className:"font-medium text-sm",children:a.name}),"configured"===X&&(0,d.jsx)(f.A,{variant:"success",className:h().status,children:"Connected"}),"not_configured"===X&&(0,d.jsx)(f.A,{variant:"warning",className:h().status,children:"Not configured"}),"other"===X&&(0,d.jsx)(f.A,{variant:"default",dot:!1,className:h().status,children:"Other"})]}),(0,d.jsx)("p",{className:"text-xs text-text-muted truncate",children:a.description})]})]}),(0,d.jsx)(e.default,{className:`text-text-muted text-[20px] transition-transform ${b?"rotate-180":""}`,children:"expand_more"})]}),b&&(0,d.jsxs)("div",{className:h().body,children:[A&&(0,d.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,d.jsx)(e.default,{className:"animate-spin",children:"progress_activity"}),(0,d.jsx)("span",{children:"Checking jcode CLI..."})]}),!A&&x&&!x.installed&&(0,d.jsx)("div",{className:"flex flex-col gap-4",children:(0,d.jsxs)("div",{className:`flex flex-col gap-3 p-4 border ${h().notice} ${h().warning}`,children:[(0,d.jsxs)("div",{className:"flex items-start gap-3",children:[(0,d.jsx)(e.default,{className:"text-[var(--warn)]",children:"warning"}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("p",{className:"font-medium text-[var(--warn)]",children:"jcode CLI not detected locally"}),(0,d.jsx)("p",{className:"text-sm text-text-muted mt-1",children:"Install jcode to enable automatic configuration:"}),(0,d.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,d.jsx)("p",{className:"text-sm text-text-muted mt-2",children:"Manual configuration is still available if JRouter is deployed on a remote server."})]})]}),(0,d.jsx)("div",{className:"flex flex-wrap items-center gap-2 sm:pl-9",children:(0,d.jsxs)(j.$n,{variant:"secondary",size:"sm",onClick:()=>T(!0),children:[(0,d.jsx)(e.default,{className:"text-[18px] mr-1",children:"content_copy"}),"Manual Config"]})})]})}),!A&&x?.installed&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[a.notes&&a.notes.length>0&&(0,d.jsx)("div",{className:"flex flex-col gap-2 mb-2",children:a.notes.map((a,b)=>(0,d.jsxs)("div",{className:`flex items-start gap-2 p-2 rounded text-xs ${"info"===a.type?h().neutral:"warning"===a.type?h().warning:h().neutral}`,children:[(0,d.jsx)(e.default,{className:"text-[14px] mt-0.5",children:"info"===a.type?"info":"warning"===a.type?"warning":"help"}),(0,d.jsx)("span",{children:a.text})]},b))}),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Select Endpoint"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(y,{value:U||((u=U||"http://127.0.0.1:20128").endsWith("/v1")?u:`${u}/v1`),onChange:V,requiresExternalUrl:a.requiresExternalUrl,tunnelEnabled:q,tunnelPublicUrl:r,tailscaleEnabled:s,tailscaleUrl:t,currentUrl:W})]}),x?.config?.providers?.jrouter?.base_url&&(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Current"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.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:x.config.providers.jrouter.base_url})]}),(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"API Key"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(B,{value:K,onChange:L,apiKeys:m,cloudEnabled:o})]}),(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Default Model"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,d.jsx)("input",{type:"text",value:M,onChange:a=>N(a.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"}),M&&(0,d.jsx)("button",{onClick:()=>N(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-[var(--danger)] rounded transition-colors",title:"Clear",children:(0,d.jsx)(e.default,{className:"text-[14px]",children:"close"})})]}),(0,d.jsx)("button",{onClick:()=>P(!0),disabled:!l,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 ${l?"bg-surface border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${h().selectButton}`,children:"Select"})]}),(0,d.jsxs)("div",{className:`flex flex-col gap-1 p-3 border ${h().notice} ${h().neutral}`,children:[(0,d.jsx)("p",{className:"text-xs font-medium text-text-muted",children:"Usage:"}),(0,d.jsx)("code",{className:"text-xs font-mono text-text-muted",children:"jcode --provider-profile jrouter"}),(0,d.jsxs)("code",{className:"text-xs font-mono text-text-muted",children:["jcode --provider-profile jrouter --model ",M||"cc/claude-opus-4-7"]})]})]}),I&&(0,d.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===I.type?h().positive:h().danger}`,children:[(0,d.jsx)(e.default,{className:"text-[14px]",children:"success"===I.type?"check_circle":"error"}),(0,d.jsx)("span",{children:I.text})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,d.jsxs)(j.$n,{variant:"primary",size:"sm",onClick:$,disabled:!M,loading:E,children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"save"}),"Apply"]}),(0,d.jsxs)(j.$n,{variant:"outline",size:"sm",onClick:aa,disabled:!x?.hasJRouter,loading:G,children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,d.jsxs)(j.$n,{variant:"ghost",size:"sm",onClick:()=>T(!0),children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),O&&(0,d.jsx)(j.rq,{className:h().modelPicker,isOpen:O,onClose:()=>P(!1),onSelect:a=>{N(a.value),P(!1)},selectedModel:M,activeProviders:n,modelAliases:Q,title:"Select Model for jcode"}),(0,d.jsx)(j.uR,{isOpen:S,onClose:()=>T(!1),title:"jcode - Manual Configuration",configs:(w=K&&K.trim()?K:o?"<API_KEY_FROM_DASHBOARD>":"sk_jrouter",[{filename:"~/.jcode/config.toml",content:`[providers.jrouter]
45
45
  type = "openai-compatible"
46
46
  base_url = "${Z()}"
47
47
  auth = "bearer"
48
48
  api_key_env = "JCODE_9ROUTER_API_KEY"
49
- env_file = "provider-9router.env"
49
+ env_file = "provider-jrouter.env"
50
50
  default_model = "${M||"cc/claude-opus-4-7"}"
51
51
  requires_api_key = true
52
52
 
53
- [[providers.9router.models]]
54
- id = "${M||"cc/claude-opus-4-7"}"`},{filename:"~/.config/jcode/provider-9router.env",content:`JCODE_9ROUTER_API_KEY="${w}"`}])})]})}var aa=c(29476);let ab="/api/cli-tools/grok-build-settings",ac="9router",ad=[{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 ae({label:a,value:b,placeholder:c,onChange:f,onSelect:g,disabled:h,help:i}){return(0,d.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,d.jsxs)("div",{className:"sm:text-right",children:[(0,d.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-sm",children:a}),i&&(0,d.jsx)("p",{className:"mt-0.5 text-[10px] leading-tight text-text-muted",children:i})]}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,d.jsx)("input",{type:"text",value:b,onChange:a=>f(a.target.value),placeholder:c,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"}),b&&(0,d.jsx)("button",{type:"button",onClick:()=>f(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-[var(--danger)] rounded transition-colors",title:"Clear (inherit main model for subagents)",children:(0,d.jsx)(e.default,{className:"text-[14px]",children:"close"})})]}),(0,d.jsx)("button",{type:"button",onClick:g,disabled:h,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 ${!h?"bg-surface border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"})]})}function af({tool:a,isExpanded:b,onToggle:c,hasActiveProviders:g,apiKeys:l,activeProviders:m,cloudEnabled:n,initialStatus:o,tunnelEnabled:p,tunnelPublicUrl:q,tailscaleEnabled:r,tailscaleUrl:s}){let{getCaps:t}=(0,aa.y)(),u=a=>t(a)?.contextWindow||null,w=o?.settings?.model?.model||"",x=Object.fromEntries(ad.map(a=>[a.id,o?.settings?.subagentModels?.[a.id]?.model]).filter(([,a])=>!!a)),[z,A]=(0,i.useState)(o||null),[C,E]=(0,i.useState)(!1),[F,G]=(0,i.useState)(!1),[H,I]=(0,i.useState)(!1),[J,K]=(0,i.useState)(null),[L,M]=(0,i.useState)(l?.[0]?.key||""),[N,O]=(0,i.useState)(w),[P,Q]=(0,i.useState)(x),[R,S]=(0,i.useState)(null),[T,U]=(0,i.useState)({}),[V,W]=(0,i.useState)(!1),[X,Y]=(0,i.useState)(""),Z=(0,i.useRef)(!!o),$=z?.settings?.model,_=$?.base_url||"",ag=z?.installed?$?.base_url?D($.base_url,{tunnelPublicUrl:q,tailscaleUrl:s})?"configured":"other":"not_configured":null,ah=(0,i.useCallback)(a=>{let b=a?.settings?.model?.model||"",c=Object.fromEntries(ad.map(b=>[b.id,a?.settings?.subagentModels?.[b.id]?.model]).filter(([,a])=>!!a));O(b),Q(c)},[]);(0,i.useCallback)(async()=>{try{let a=await fetch("/api/models/alias"),b=await a.json();a.ok&&U(b.aliases||{})}catch(a){console.log("Error fetching model aliases:",a)}},[]);let ai=(0,i.useCallback)(async({hydrate:a=!1}={})=>{E(!0);try{let b=await fetch(ab),c=await b.json();A(c),Z.current=!0,a&&ah(c)}catch(a){A({installed:!1,error:a.message})}finally{E(!1)}},[ah]),aj=()=>{let a=X||"http://127.0.0.1:20128";return a.endsWith("/v1")?a:`${a}/v1`},ak=async()=>{G(!0),K(null);try{let a=L?.trim()||(l?.length>0?l[0].key:null)||(n?null:"sk_9router"),b={};for(let a of ad){let c=P[a.id]?.trim();c&&(b[a.id]={model:c,contextWindow:u(c)})}let c=await fetch(ab,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:aj(),apiKey:a,model:N,contextWindow:u(N),subagentModels:b})}),d=await c.json();c.ok?(v(aj(),{tunnelPublicUrl:q,tailscaleUrl:s}),K({type:"success",text:"Main and subagent models applied successfully!"}),ai()):K({type:"error",text:d.error||"Failed to apply settings"})}catch(a){K({type:"error",text:a.message})}finally{G(!1)}},al=async()=>{I(!0),K(null);try{let a=await fetch(ab,{method:"DELETE"}),b=await a.json();a.ok?(K({type:"success",text:"Settings reset successfully!"}),O(""),Q({}),ai()):K({type:"error",text:b.error||"Failed to reset settings"})}catch(a){K({type:"error",text:a.message})}finally{I(!1)}};return(0,d.jsxs)(j.Zp,{padding:"none",className:h().panel,children:[(0,d.jsxs)("div",{className:h().panelHeader,onClick:c,children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,d.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,d.jsx)(k.default,{src:a.image||"/providers/grok-cli.png",alt:a.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:a=>{a.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,d.jsx)("h3",{className:"font-medium text-sm",children:a.name}),"configured"===ag&&(0,d.jsx)(f.A,{variant:"success",className:h().status,children:"Connected"}),"not_configured"===ag&&(0,d.jsx)(f.A,{variant:"warning",className:h().status,children:"Not configured"}),"other"===ag&&(0,d.jsx)(f.A,{variant:"default",dot:!1,className:h().status,children:"Other"})]}),(0,d.jsx)("p",{className:"text-xs text-text-muted truncate",children:a.description})]})]}),(0,d.jsx)(e.default,{className:`text-text-muted text-[20px] transition-transform ${b?"rotate-180":""}`,children:"expand_more"})]}),b&&(0,d.jsxs)("div",{className:h().body,children:[C&&(0,d.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,d.jsx)(e.default,{className:"animate-spin",children:"progress_activity"}),(0,d.jsx)("span",{children:"Checking Grok Build..."})]}),!C&&z&&!z.installed&&(0,d.jsxs)("div",{className:`flex flex-col gap-3 p-4 border ${h().notice} ${h().warning}`,children:[(0,d.jsxs)("div",{className:"flex items-start gap-3",children:[(0,d.jsx)(e.default,{className:"text-[var(--warn)]",children:"warning"}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("p",{className:"font-medium text-[var(--warn)]",children:"Grok Build not detected locally"}),(0,d.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,d.jsxs)(j.$n,{variant:"secondary",size:"sm",onClick:()=>W(!0),className:"w-full sm:w-auto",children:[(0,d.jsx)(e.default,{className:"text-[18px] mr-1",children:"content_copy"}),"Manual Config"]})]}),!C&&z?.installed&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[a.notes?.length>0&&(0,d.jsx)("div",{className:"mb-2 flex flex-col gap-2",children:a.notes.map((a,b)=>(0,d.jsxs)("div",{className:`flex items-start gap-2 p-2 ${h().notice} ${"warning"===a.type?h().warning:h().neutral}`,children:[(0,d.jsx)(e.default,{className:"mt-0.5 text-[14px]",children:"warning"===a.type?"warning":"info"}),(0,d.jsx)("span",{children:a.text})]},b))}),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Select Endpoint"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(y,{value:X||aj(),onChange:Y,requiresExternalUrl:a.requiresExternalUrl,tunnelEnabled:p,tunnelPublicUrl:q,tailscaleEnabled:r,tailscaleUrl:s,currentUrl:_})]}),$?.base_url&&(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Current"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.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:[$.base_url," \xb7 ",$.model,$.context_window?` \xb7 ${($.context_window/1e3).toLocaleString()}K ctx`:""]})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"API Key"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(B,{value:L,onChange:M,apiKeys:l,cloudEnabled:n})]}),(0,d.jsx)(ae,{label:"Main Model",value:N,onChange:O,placeholder:"provider/model-id",onSelect:()=>S("main"),disabled:!g}),(0,d.jsx)("div",{className:"my-1 border-t border-border pt-3",children:(0,d.jsxs)("div",{className:"mb-2 flex items-start gap-2",children:[(0,d.jsx)(e.default,{className:"text-text-main text-[16px]",children:"account_tree"}),(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-xs font-semibold text-text-main",children:"Subagent model overrides"}),(0,d.jsx)("p",{className:"text-[10px] text-text-muted",children:"Leave blank to inherit Main Model. Each override keeps its own context window."})]})]})}),ad.map(a=>(0,d.jsx)(ae,{label:a.label,help:a.help,value:P[a.id]||"",onChange:b=>Q(c=>({...c,[a.id]:b})),placeholder:`${N||"Main Model"} (inherit)`,onSelect:()=>S(a.id),disabled:!g},a.id))]}),J&&(0,d.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===J.type?h().positive:h().danger}`,children:[(0,d.jsx)(e.default,{className:"text-[14px]",children:"success"===J.type?"check_circle":"error"}),(0,d.jsx)("span",{children:J.text})]}),(0,d.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2",children:[(0,d.jsxs)(j.$n,{variant:"primary",size:"sm",onClick:ak,disabled:!N,loading:F,className:"w-full sm:w-auto",children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"save"}),"Apply"]}),(0,d.jsxs)(j.$n,{variant:"outline",size:"sm",onClick:al,disabled:!z?.has9Router,loading:H,className:"w-full sm:w-auto",children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,d.jsxs)(j.$n,{variant:"ghost",size:"sm",onClick:()=>W(!0),className:"w-full sm:w-auto",children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),R&&(0,d.jsx)(j.rq,{className:h().modelPicker,isOpen:!!R,onClose:()=>S(null),onSelect:a=>{"main"===R?O(a.value):R&&Q(b=>({...b,[R]:a.value})),S(null)},selectedModel:"main"===R?N:P[R]||"",activeProviders:m,modelAliases:T,title:"main"===R?"Select Main Model for Grok Build":`Select ${ad.find(a=>a.id===R)?.label||"Subagent"} Model`}),(0,d.jsx)(j.uR,{isOpen:V,onClose:()=>W(!1),title:"Grok Build - Manual Configuration",configs:(()=>{let a=L?.trim()||(n?"<API_KEY_FROM_DASHBOARD>":"sk_9router"),b=aj(),c=N||"provider/model-id",d=[`[models]
53
+ [[providers.jrouter.models]]
54
+ id = "${M||"cc/claude-opus-4-7"}"`},{filename:"~/.config/jcode/provider-jrouter.env",content:`JCODE_9ROUTER_API_KEY="${w}"`}])})]})}var aa=c(29476);let ab="/api/cli-tools/grok-build-settings",ac="jrouter",ad=[{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 ae({label:a,value:b,placeholder:c,onChange:f,onSelect:g,disabled:h,help:i}){return(0,d.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,d.jsxs)("div",{className:"sm:text-right",children:[(0,d.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-sm",children:a}),i&&(0,d.jsx)("p",{className:"mt-0.5 text-[10px] leading-tight text-text-muted",children:i})]}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,d.jsx)("input",{type:"text",value:b,onChange:a=>f(a.target.value),placeholder:c,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"}),b&&(0,d.jsx)("button",{type:"button",onClick:()=>f(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-[var(--danger)] rounded transition-colors",title:"Clear (inherit main model for subagents)",children:(0,d.jsx)(e.default,{className:"text-[14px]",children:"close"})})]}),(0,d.jsx)("button",{type:"button",onClick:g,disabled:h,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 ${!h?"bg-surface border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"})]})}function af({tool:a,isExpanded:b,onToggle:c,hasActiveProviders:g,apiKeys:l,activeProviders:m,cloudEnabled:n,initialStatus:o,tunnelEnabled:p,tunnelPublicUrl:q,tailscaleEnabled:r,tailscaleUrl:s}){let{getCaps:t}=(0,aa.y)(),u=a=>t(a)?.contextWindow||null,w=o?.settings?.model?.model||"",x=Object.fromEntries(ad.map(a=>[a.id,o?.settings?.subagentModels?.[a.id]?.model]).filter(([,a])=>!!a)),[z,A]=(0,i.useState)(o||null),[C,E]=(0,i.useState)(!1),[F,G]=(0,i.useState)(!1),[H,I]=(0,i.useState)(!1),[J,K]=(0,i.useState)(null),[L,M]=(0,i.useState)(l?.[0]?.key||""),[N,O]=(0,i.useState)(w),[P,Q]=(0,i.useState)(x),[R,S]=(0,i.useState)(null),[T,U]=(0,i.useState)({}),[V,W]=(0,i.useState)(!1),[X,Y]=(0,i.useState)(""),Z=(0,i.useRef)(!!o),$=z?.settings?.model,_=$?.base_url||"",ag=z?.installed?$?.base_url?D($.base_url,{tunnelPublicUrl:q,tailscaleUrl:s})?"configured":"other":"not_configured":null,ah=(0,i.useCallback)(a=>{let b=a?.settings?.model?.model||"",c=Object.fromEntries(ad.map(b=>[b.id,a?.settings?.subagentModels?.[b.id]?.model]).filter(([,a])=>!!a));O(b),Q(c)},[]);(0,i.useCallback)(async()=>{try{let a=await fetch("/api/models/alias"),b=await a.json();a.ok&&U(b.aliases||{})}catch(a){console.log("Error fetching model aliases:",a)}},[]);let ai=(0,i.useCallback)(async({hydrate:a=!1}={})=>{E(!0);try{let b=await fetch(ab),c=await b.json();A(c),Z.current=!0,a&&ah(c)}catch(a){A({installed:!1,error:a.message})}finally{E(!1)}},[ah]),aj=()=>{let a=X||"http://127.0.0.1:20128";return a.endsWith("/v1")?a:`${a}/v1`},ak=async()=>{G(!0),K(null);try{let a=L?.trim()||(l?.length>0?l[0].key:null)||(n?null:"sk_jrouter"),b={};for(let a of ad){let c=P[a.id]?.trim();c&&(b[a.id]={model:c,contextWindow:u(c)})}let c=await fetch(ab,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:aj(),apiKey:a,model:N,contextWindow:u(N),subagentModels:b})}),d=await c.json();c.ok?(v(aj(),{tunnelPublicUrl:q,tailscaleUrl:s}),K({type:"success",text:"Main and subagent models applied successfully!"}),ai()):K({type:"error",text:d.error||"Failed to apply settings"})}catch(a){K({type:"error",text:a.message})}finally{G(!1)}},al=async()=>{I(!0),K(null);try{let a=await fetch(ab,{method:"DELETE"}),b=await a.json();a.ok?(K({type:"success",text:"Settings reset successfully!"}),O(""),Q({}),ai()):K({type:"error",text:b.error||"Failed to reset settings"})}catch(a){K({type:"error",text:a.message})}finally{I(!1)}};return(0,d.jsxs)(j.Zp,{padding:"none",className:h().panel,children:[(0,d.jsxs)("div",{className:h().panelHeader,onClick:c,children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,d.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,d.jsx)(k.default,{src:a.image||"/providers/grok-cli.png",alt:a.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:a=>{a.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,d.jsx)("h3",{className:"font-medium text-sm",children:a.name}),"configured"===ag&&(0,d.jsx)(f.A,{variant:"success",className:h().status,children:"Connected"}),"not_configured"===ag&&(0,d.jsx)(f.A,{variant:"warning",className:h().status,children:"Not configured"}),"other"===ag&&(0,d.jsx)(f.A,{variant:"default",dot:!1,className:h().status,children:"Other"})]}),(0,d.jsx)("p",{className:"text-xs text-text-muted truncate",children:a.description})]})]}),(0,d.jsx)(e.default,{className:`text-text-muted text-[20px] transition-transform ${b?"rotate-180":""}`,children:"expand_more"})]}),b&&(0,d.jsxs)("div",{className:h().body,children:[C&&(0,d.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,d.jsx)(e.default,{className:"animate-spin",children:"progress_activity"}),(0,d.jsx)("span",{children:"Checking Grok Build..."})]}),!C&&z&&!z.installed&&(0,d.jsxs)("div",{className:`flex flex-col gap-3 p-4 border ${h().notice} ${h().warning}`,children:[(0,d.jsxs)("div",{className:"flex items-start gap-3",children:[(0,d.jsx)(e.default,{className:"text-[var(--warn)]",children:"warning"}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("p",{className:"font-medium text-[var(--warn)]",children:"Grok Build not detected locally"}),(0,d.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,d.jsxs)(j.$n,{variant:"secondary",size:"sm",onClick:()=>W(!0),className:"w-full sm:w-auto",children:[(0,d.jsx)(e.default,{className:"text-[18px] mr-1",children:"content_copy"}),"Manual Config"]})]}),!C&&z?.installed&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[a.notes?.length>0&&(0,d.jsx)("div",{className:"mb-2 flex flex-col gap-2",children:a.notes.map((a,b)=>(0,d.jsxs)("div",{className:`flex items-start gap-2 p-2 ${h().notice} ${"warning"===a.type?h().warning:h().neutral}`,children:[(0,d.jsx)(e.default,{className:"mt-0.5 text-[14px]",children:"warning"===a.type?"warning":"info"}),(0,d.jsx)("span",{children:a.text})]},b))}),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Select Endpoint"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(y,{value:X||aj(),onChange:Y,requiresExternalUrl:a.requiresExternalUrl,tunnelEnabled:p,tunnelPublicUrl:q,tailscaleEnabled:r,tailscaleUrl:s,currentUrl:_})]}),$?.base_url&&(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Current"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.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:[$.base_url," \xb7 ",$.model,$.context_window?` \xb7 ${($.context_window/1e3).toLocaleString()}K ctx`:""]})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"API Key"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(B,{value:L,onChange:M,apiKeys:l,cloudEnabled:n})]}),(0,d.jsx)(ae,{label:"Main Model",value:N,onChange:O,placeholder:"provider/model-id",onSelect:()=>S("main"),disabled:!g}),(0,d.jsx)("div",{className:"my-1 border-t border-border pt-3",children:(0,d.jsxs)("div",{className:"mb-2 flex items-start gap-2",children:[(0,d.jsx)(e.default,{className:"text-text-main text-[16px]",children:"account_tree"}),(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-xs font-semibold text-text-main",children:"Subagent model overrides"}),(0,d.jsx)("p",{className:"text-[10px] text-text-muted",children:"Leave blank to inherit Main Model. Each override keeps its own context window."})]})]})}),ad.map(a=>(0,d.jsx)(ae,{label:a.label,help:a.help,value:P[a.id]||"",onChange:b=>Q(c=>({...c,[a.id]:b})),placeholder:`${N||"Main Model"} (inherit)`,onSelect:()=>S(a.id),disabled:!g},a.id))]}),J&&(0,d.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===J.type?h().positive:h().danger}`,children:[(0,d.jsx)(e.default,{className:"text-[14px]",children:"success"===J.type?"check_circle":"error"}),(0,d.jsx)("span",{children:J.text})]}),(0,d.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2",children:[(0,d.jsxs)(j.$n,{variant:"primary",size:"sm",onClick:ak,disabled:!N,loading:F,className:"w-full sm:w-auto",children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"save"}),"Apply"]}),(0,d.jsxs)(j.$n,{variant:"outline",size:"sm",onClick:al,disabled:!z?.hasJRouter,loading:H,className:"w-full sm:w-auto",children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,d.jsxs)(j.$n,{variant:"ghost",size:"sm",onClick:()=>W(!0),className:"w-full sm:w-auto",children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),R&&(0,d.jsx)(j.rq,{className:h().modelPicker,isOpen:!!R,onClose:()=>S(null),onSelect:a=>{"main"===R?O(a.value):R&&Q(b=>({...b,[R]:a.value})),S(null)},selectedModel:"main"===R?N:P[R]||"",activeProviders:m,modelAliases:T,title:"main"===R?"Select Main Model for Grok Build":`Select ${ad.find(a=>a.id===R)?.label||"Subagent"} Model`}),(0,d.jsx)(j.uR,{isOpen:V,onClose:()=>W(!1),title:"Grok Build - Manual Configuration",configs:(()=>{let a=L?.trim()||(n?"<API_KEY_FROM_DASHBOARD>":"sk_jrouter"),b=aj(),c=N||"provider/model-id",d=[`[models]
55
55
  default = "${ac}"`,`[model.${ac}]
56
56
  model = "${c}"
57
57
  base_url = "${b}"
58
- name = "9Router"
59
- description = "Routed via 9Router gateway"
58
+ name = "JRouter"
59
+ description = "Routed via JRouter gateway"
60
60
  api_backend = "chat_completions"
61
61
  api_key = "${a}"
62
62
  context_window = ${u(c)||2e5}`],e=[];for(let c of ad){let f=P[c.id]?.trim();if(!f)continue;let g=`${ac}-${c.id}`;e.push(`${c.id} = "${g}"`),d.push(`[model.${g}]
63
63
  model = "${f}"
64
64
  base_url = "${b}"
65
- name = "9Router ${c.id}"
66
- description = "Routed via 9Router gateway"
65
+ name = "JRouter ${c.id}"
66
+ description = "Routed via JRouter gateway"
67
67
  api_backend = "chat_completions"
68
68
  api_key = "${a}"
69
69
  context_window = ${u(f)||2e5}`)}return e.length&&d.splice(1,0,`[subagents.models]
70
70
  ${e.join("\n")}`),[{filename:"~/.grok/config.toml",content:`${d.join("\n\n")}
71
- `}]})()})]})}var ag=c(91431);function ah({tool:a,isExpanded:b,onToggle:c,baseUrl:g,apiKeys:l,activeProviders:m=[],cloudEnabled:n,initialStatus:o,tunnelEnabled:p,tunnelPublicUrl:q,tailscaleEnabled:r,tailscaleUrl:s}){let[t,u]=(0,i.useState)(()=>o||null),[w,x]=(0,i.useState)(!1),[z,A]=(0,i.useState)(!1),[C,E]=(0,i.useState)(!1),[F,G]=(0,i.useState)(null),[H,I]=(0,i.useState)(!1),[J,K]=(0,i.useState)(()=>l?.[0]?.key||""),[L,M]=(0,i.useState)(()=>{let a=o?.config;return a?.model||a?.openai?.model||a?.providers?.["9router"]?.models?.[0]?.id||""}),[N,O]=(0,i.useState)(()=>{let a=o?.config,b=a?.providers?.["9router"]?.models;return Array.isArray(b)&&b.length>0?b.map(a=>"string"==typeof a?a:a.id):[]}),[P,Q]=(0,i.useState)(!1),[R,S]=(0,i.useState)(!1),[T,U]=(0,i.useState)(""),V=`/api/cli-tools/${a.id}-settings`,W=async()=>{x(!0);try{let b=await fetch(V),c=await b.json();u(c);let d=c?.config;if("pi"===a.id){let a=d?.providers?.["9router"]?.models;if(Array.isArray(a)&&a.length>0){let b=a.map(a=>"string"==typeof a?a:a.id);O(b)}}else{let a=d?.model||d?.openai?.model||d?.providers?.["9router"]?.models?.[0]?.id;a&&!L&&M(a)}}catch(a){u({installed:!1,error:a.message})}finally{x(!1)}},X=()=>{let a=T||`${g}/v1`;return a.endsWith("/v1")?a:`${a}/v1`},Y=(()=>{if(!t?.config)return"";let a=t.config;return"string"==typeof a.baseUrl?a.baseUrl:"string"==typeof a.openai?.base_url?a.openai.base_url:"string"==typeof a.providers?.["9router"]?.base_url?a.providers["9router"].base_url:"string"==typeof a.providers?.["9router"]?.baseUrl?a.providers["9router"].baseUrl:""})(),Z=t?.installed?t.has9Router?(Y&&D(Y,{tunnelPublicUrl:q,tailscaleUrl:s}),"configured"):"not_configured":null,$=async()=>{A(!0),G(null);try{let b=J&&J.trim()||n?J:"sk_9router",c={baseUrl:X(),apiKey:b};"pi"===a.id?c.models=N.length>0?N:["provider/model-id"]:c.model=L;let d=await fetch(V,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)}),e=await d.json();d.ok?(v(X()),G({type:"success",text:e.message||"Settings applied successfully!"}),await W()):G({type:"error",text:e.error?.message||"Failed to apply settings."})}catch(a){G({type:"error",text:a.message})}finally{A(!1)}},_=async()=>{E(!0),G(null);try{let a=await fetch(V,{method:"DELETE"}),b=await a.json();a.ok?(G({type:"success",text:b.message||"Settings removed successfully."}),await W()):G({type:"error",text:b.error?.message||"Failed to reset settings."})}catch(a){G({type:"error",text:a.message})}finally{E(!1)}};return(0,d.jsxs)(j.Zp,{padding:"none",className:h().panel,children:[(0,d.jsxs)("div",{className:h().panelHeader,onClick:c,children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,d.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:a.image?(0,d.jsx)(k.default,{src:a.image,alt:a.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:a=>{a.target.style.display="none"},loading:"lazy",decoding:"async"}):a.icon?(0,d.jsx)(e.default,{className:"text-[28px]",style:{color:a.color},children:a.icon}):(0,d.jsx)(e.default,{className:"text-[28px] text-text-main",children:"terminal"})}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,d.jsx)("h3",{className:"font-medium text-sm",children:a.name}),"configured"===Z&&(0,d.jsx)(f.A,{variant:"success",className:h().status,children:"Connected"}),"not_configured"===Z&&(0,d.jsx)(f.A,{variant:"warning",className:h().status,children:"Not configured"}),"other"===Z&&(0,d.jsx)(f.A,{variant:"default",dot:!1,className:h().status,children:"Other"})]}),(0,d.jsx)("p",{className:"text-xs text-text-muted truncate",children:a.description})]})]}),(0,d.jsx)(e.default,{className:`text-text-muted text-[20px] transition-transform ${b?"rotate-180":""}`,children:"expand_more"})]}),b&&(0,d.jsxs)("div",{className:h().body,children:[w&&(0,d.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,d.jsx)(e.default,{className:"animate-spin",children:"progress_activity"}),(0,d.jsxs)("span",{children:["Checking ",a.name,"..."]})]}),!w&&t&&!t.installed&&(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,d.jsxs)("div",{className:`flex flex-col gap-3 p-4 border ${h().notice} ${h().warning}`,children:[(0,d.jsxs)("div",{className:"flex items-start gap-3",children:[(0,d.jsx)(e.default,{className:"text-[var(--warn)]",children:"warning"}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsxs)("p",{className:"font-medium text-[var(--warn)]",children:[a.name," not detected locally"]}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if 9router is deployed on a remote server."})]})]}),(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2 sm:pl-9",children:[(0,d.jsxs)(j.$n,{variant:"secondary",size:"sm",onClick:()=>S(!0),children:[(0,d.jsx)(e.default,{className:"text-[18px] mr-1",children:"content_copy"}),"Manual Config"]}),(0,d.jsxs)(j.$n,{variant:"outline",size:"sm",onClick:()=>I(!H),children:[(0,d.jsx)(e.default,{className:"text-[18px] mr-1",children:H?"expand_less":"help"}),H?"Hide":"How to Install"]})]})]}),H&&(0,d.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,d.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,d.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-text-muted mb-1",children:"Install command:"}),(0,d.jsx)("code",{className:"block px-3 py-2 bg-black/5 dark:bg-white/5 rounded font-mono text-xs",children:(()=>{switch(a.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 ${a.id}`}})()})]}),a.docsUrl&&(0,d.jsxs)("p",{className:"text-xs text-text-muted",children:["Docs: ",(0,d.jsx)("a",{href:a.docsUrl,target:"_blank",rel:"noreferrer",className:"text-text-main hover:underline",children:a.docsUrl})]})]})]})]}),!w&&t?.installed&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Select Endpoint"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(y,{value:T||X(),onChange:U,requiresExternalUrl:a.requiresExternalUrl,tunnelEnabled:p,tunnelPublicUrl:q,tailscaleEnabled:r,tailscaleUrl:s,currentUrl:Y})]}),Y?(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Current"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.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})]}):null,(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"API Key"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(B,{value:J,onChange:K,apiKeys:l,cloudEnabled:n})]}),"pi"===a.id&&(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-start sm:gap-2",children:[(0,d.jsx)("span",{className:`sm:text-right mt-1 ${h().fieldLabel}`,children:"Models"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline mt-1.5",children:"arrow_forward"}),(0,d.jsxs)("div",{className:"flex-1 flex flex-col gap-2",children:[(0,d.jsx)("div",{className:"flex flex-wrap gap-1.5 min-h-[36px] p-2 bg-surface rounded border border-border",children:0===N.length?(0,d.jsx)("span",{className:"text-xs text-text-muted italic",children:"No models selected. Add models to use in Pi."}):N.map(a=>(0,d.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2 py-1 rounded bg-bg-secondary text-xs text-text-main border border-border",children:[(0,d.jsx)("span",{children:a}),(0,d.jsx)("button",{type:"button",onClick:()=>{O(b=>b.filter(b=>b!==a))},className:"text-text-muted hover:text-[var(--danger)] rounded p-0.5",children:(0,d.jsx)(e.default,{className:"text-[12px]",children:"close"})})]},a))}),(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,d.jsxs)(j.$n,{type:"button",size:"sm",variant:"secondary",onClick:()=>Q(!0),disabled:!m?.length,children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"add"}),"Add Model"]}),m?.length>0&&(0,d.jsx)(j.$n,{type:"button",size:"sm",variant:"ghost",onClick:()=>{let a=[];m.forEach(b=>{let c=ag.Xg[b.provider]||b.provider;(0,ag.KC)(b.provider).forEach(b=>{let d=`${c}/${b.id}`;a.includes(d)||a.push(d)})}),a.length>0&&O(b=>Array.from(new Set([...b,...a])))},className:"text-xs text-text-main hover:text-text-main",children:"+ Add All Active Models"}),N.length>0&&(0,d.jsx)("button",{type:"button",onClick:()=>O([]),className:"text-xs text-text-muted hover:text-[var(--danger)] ml-auto",children:"Clear all"})]})]})]}),"omp"!==a.id&&"pi"!==a.id&&(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Model"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,d.jsx)("input",{type:"text",value:L,onChange:a=>M(a.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,d.jsx)("button",{onClick:()=>M(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-[var(--danger)] rounded transition-colors",title:"Clear",children:(0,d.jsx)(e.default,{className:"text-[14px]",children:"close"})})]}),(0,d.jsx)("button",{onClick:()=>Q(!0),disabled:!m?.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 ${m?.length?"bg-surface border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${h().selectButton}`,children:"Select Model"})]})]}),F&&(0,d.jsx)("div",{className:`p-3 rounded-lg text-sm ${"success"===F.type?`border ${h().positive}`:`border ${h().danger}`}`,children:F.text}),(0,d.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3 pt-2",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,d.jsx)(j.$n,{variant:"primary",size:"sm",onClick:$,disabled:z||w,children:z?"Applying...":"Apply Settings"}),t?.has9Router&&(0,d.jsx)(j.$n,{variant:"outline",size:"sm",onClick:_,disabled:C||w,className:"text-red-500 hover:text-[var(--danger)] hover:border-red-500/50",children:C?"Removing...":"Remove from Tool"})]}),(0,d.jsxs)(j.$n,{variant:"outline",size:"sm",onClick:()=>S(!0),children:[(0,d.jsx)(e.default,{className:"text-[18px] mr-1",children:"code"}),"Manual Config"]})]})]})]}),(0,d.jsx)(j.rq,{className:h().modelPicker,isOpen:P,onClose:()=>Q(!1),onSelect:b=>{"pi"===a.id?N.includes(b.value)||O(a=>[...a,b.value]):M(b.value),Q(!1)},activeProviders:m}),(0,d.jsx)(j.uR,{isOpen:R,onClose:()=>S(!1),title:`${a.name} Configuration`,configs:(()=>{let b=X(),c=J||"sk_9router",d=L||"provider/model-id";switch(a.id){case"pi":return[{filename:"~/.pi/agent/models.json",content:JSON.stringify({providers:{"9router":{baseUrl:b,apiKey:c,api:"openai-completions",models:(N.length>0?N:[d]).map(a=>({id:a,name:a,contextWindow:128e3,maxTokens:16384}))}}},null,2)}];case"omp":return[{filename:"~/.omp/agent/models.yml",content:`providers:
72
- 9router:
71
+ `}]})()})]})}var ag=c(91431);function ah({tool:a,isExpanded:b,onToggle:c,baseUrl:g,apiKeys:l,activeProviders:m=[],cloudEnabled:n,initialStatus:o,tunnelEnabled:p,tunnelPublicUrl:q,tailscaleEnabled:r,tailscaleUrl:s}){let[t,u]=(0,i.useState)(()=>o||null),[w,x]=(0,i.useState)(!1),[z,A]=(0,i.useState)(!1),[C,E]=(0,i.useState)(!1),[F,G]=(0,i.useState)(null),[H,I]=(0,i.useState)(!1),[J,K]=(0,i.useState)(()=>l?.[0]?.key||""),[L,M]=(0,i.useState)(()=>{let a=o?.config;return a?.model||a?.openai?.model||a?.providers?.jrouter?.models?.[0]?.id||""}),[N,O]=(0,i.useState)(()=>{let a=o?.config,b=a?.providers?.jrouter?.models;return Array.isArray(b)&&b.length>0?b.map(a=>"string"==typeof a?a:a.id):[]}),[P,Q]=(0,i.useState)(!1),[R,S]=(0,i.useState)(!1),[T,U]=(0,i.useState)(""),V=`/api/cli-tools/${a.id}-settings`,W=async()=>{x(!0);try{let b=await fetch(V),c=await b.json();u(c);let d=c?.config;if("pi"===a.id){let a=d?.providers?.jrouter?.models;if(Array.isArray(a)&&a.length>0){let b=a.map(a=>"string"==typeof a?a:a.id);O(b)}}else{let a=d?.model||d?.openai?.model||d?.providers?.jrouter?.models?.[0]?.id;a&&!L&&M(a)}}catch(a){u({installed:!1,error:a.message})}finally{x(!1)}},X=()=>{let a=T||`${g}/v1`;return a.endsWith("/v1")?a:`${a}/v1`},Y=(()=>{if(!t?.config)return"";let a=t.config;return"string"==typeof a.baseUrl?a.baseUrl:"string"==typeof a.openai?.base_url?a.openai.base_url:"string"==typeof a.providers?.jrouter?.base_url?a.providers.jrouter.base_url:"string"==typeof a.providers?.jrouter?.baseUrl?a.providers.jrouter.baseUrl:""})(),Z=t?.installed?t.hasJRouter?(Y&&D(Y,{tunnelPublicUrl:q,tailscaleUrl:s}),"configured"):"not_configured":null,$=async()=>{A(!0),G(null);try{let b=J&&J.trim()||n?J:"sk_jrouter",c={baseUrl:X(),apiKey:b};"pi"===a.id?c.models=N.length>0?N:["provider/model-id"]:c.model=L;let d=await fetch(V,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)}),e=await d.json();d.ok?(v(X()),G({type:"success",text:e.message||"Settings applied successfully!"}),await W()):G({type:"error",text:e.error?.message||"Failed to apply settings."})}catch(a){G({type:"error",text:a.message})}finally{A(!1)}},_=async()=>{E(!0),G(null);try{let a=await fetch(V,{method:"DELETE"}),b=await a.json();a.ok?(G({type:"success",text:b.message||"Settings removed successfully."}),await W()):G({type:"error",text:b.error?.message||"Failed to reset settings."})}catch(a){G({type:"error",text:a.message})}finally{E(!1)}};return(0,d.jsxs)(j.Zp,{padding:"none",className:h().panel,children:[(0,d.jsxs)("div",{className:h().panelHeader,onClick:c,children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,d.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:a.image?(0,d.jsx)(k.default,{src:a.image,alt:a.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:a=>{a.target.style.display="none"},loading:"lazy",decoding:"async"}):a.icon?(0,d.jsx)(e.default,{className:"text-[28px]",style:{color:a.color},children:a.icon}):(0,d.jsx)(e.default,{className:"text-[28px] text-text-main",children:"terminal"})}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,d.jsx)("h3",{className:"font-medium text-sm",children:a.name}),"configured"===Z&&(0,d.jsx)(f.A,{variant:"success",className:h().status,children:"Connected"}),"not_configured"===Z&&(0,d.jsx)(f.A,{variant:"warning",className:h().status,children:"Not configured"}),"other"===Z&&(0,d.jsx)(f.A,{variant:"default",dot:!1,className:h().status,children:"Other"})]}),(0,d.jsx)("p",{className:"text-xs text-text-muted truncate",children:a.description})]})]}),(0,d.jsx)(e.default,{className:`text-text-muted text-[20px] transition-transform ${b?"rotate-180":""}`,children:"expand_more"})]}),b&&(0,d.jsxs)("div",{className:h().body,children:[w&&(0,d.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,d.jsx)(e.default,{className:"animate-spin",children:"progress_activity"}),(0,d.jsxs)("span",{children:["Checking ",a.name,"..."]})]}),!w&&t&&!t.installed&&(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,d.jsxs)("div",{className:`flex flex-col gap-3 p-4 border ${h().notice} ${h().warning}`,children:[(0,d.jsxs)("div",{className:"flex items-start gap-3",children:[(0,d.jsx)(e.default,{className:"text-[var(--warn)]",children:"warning"}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsxs)("p",{className:"font-medium text-[var(--warn)]",children:[a.name," not detected locally"]}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if JRouter is deployed on a remote server."})]})]}),(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2 sm:pl-9",children:[(0,d.jsxs)(j.$n,{variant:"secondary",size:"sm",onClick:()=>S(!0),children:[(0,d.jsx)(e.default,{className:"text-[18px] mr-1",children:"content_copy"}),"Manual Config"]}),(0,d.jsxs)(j.$n,{variant:"outline",size:"sm",onClick:()=>I(!H),children:[(0,d.jsx)(e.default,{className:"text-[18px] mr-1",children:H?"expand_less":"help"}),H?"Hide":"How to Install"]})]})]}),H&&(0,d.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,d.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,d.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-text-muted mb-1",children:"Install command:"}),(0,d.jsx)("code",{className:"block px-3 py-2 bg-black/5 dark:bg-white/5 rounded font-mono text-xs",children:(()=>{switch(a.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 ${a.id}`}})()})]}),a.docsUrl&&(0,d.jsxs)("p",{className:"text-xs text-text-muted",children:["Docs: ",(0,d.jsx)("a",{href:a.docsUrl,target:"_blank",rel:"noreferrer",className:"text-text-main hover:underline",children:a.docsUrl})]})]})]})]}),!w&&t?.installed&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Select Endpoint"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(y,{value:T||X(),onChange:U,requiresExternalUrl:a.requiresExternalUrl,tunnelEnabled:p,tunnelPublicUrl:q,tailscaleEnabled:r,tailscaleUrl:s,currentUrl:Y})]}),Y?(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Current"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.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})]}):null,(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"API Key"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)(B,{value:J,onChange:K,apiKeys:l,cloudEnabled:n})]}),"pi"===a.id&&(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-start sm:gap-2",children:[(0,d.jsx)("span",{className:`sm:text-right mt-1 ${h().fieldLabel}`,children:"Models"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline mt-1.5",children:"arrow_forward"}),(0,d.jsxs)("div",{className:"flex-1 flex flex-col gap-2",children:[(0,d.jsx)("div",{className:"flex flex-wrap gap-1.5 min-h-[36px] p-2 bg-surface rounded border border-border",children:0===N.length?(0,d.jsx)("span",{className:"text-xs text-text-muted italic",children:"No models selected. Add models to use in Pi."}):N.map(a=>(0,d.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2 py-1 rounded bg-bg-secondary text-xs text-text-main border border-border",children:[(0,d.jsx)("span",{children:a}),(0,d.jsx)("button",{type:"button",onClick:()=>{O(b=>b.filter(b=>b!==a))},className:"text-text-muted hover:text-[var(--danger)] rounded p-0.5",children:(0,d.jsx)(e.default,{className:"text-[12px]",children:"close"})})]},a))}),(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,d.jsxs)(j.$n,{type:"button",size:"sm",variant:"secondary",onClick:()=>Q(!0),disabled:!m?.length,children:[(0,d.jsx)(e.default,{className:"text-[14px] mr-1",children:"add"}),"Add Model"]}),m?.length>0&&(0,d.jsx)(j.$n,{type:"button",size:"sm",variant:"ghost",onClick:()=>{let a=[];m.forEach(b=>{let c=ag.Xg[b.provider]||b.provider;(0,ag.KC)(b.provider).forEach(b=>{let d=`${c}/${b.id}`;a.includes(d)||a.push(d)})}),a.length>0&&O(b=>Array.from(new Set([...b,...a])))},className:"text-xs text-text-main hover:text-text-main",children:"+ Add All Active Models"}),N.length>0&&(0,d.jsx)("button",{type:"button",onClick:()=>O([]),className:"text-xs text-text-muted hover:text-[var(--danger)] ml-auto",children:"Clear all"})]})]})]}),"omp"!==a.id&&"pi"!==a.id&&(0,d.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,d.jsx)("span",{className:`sm:text-right ${h().fieldLabel}`,children:"Model"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,d.jsx)("input",{type:"text",value:L,onChange:a=>M(a.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,d.jsx)("button",{onClick:()=>M(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-[var(--danger)] rounded transition-colors",title:"Clear",children:(0,d.jsx)(e.default,{className:"text-[14px]",children:"close"})})]}),(0,d.jsx)("button",{onClick:()=>Q(!0),disabled:!m?.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 ${m?.length?"bg-surface border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${h().selectButton}`,children:"Select Model"})]})]}),F&&(0,d.jsx)("div",{className:`p-3 rounded-lg text-sm ${"success"===F.type?`border ${h().positive}`:`border ${h().danger}`}`,children:F.text}),(0,d.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3 pt-2",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,d.jsx)(j.$n,{variant:"primary",size:"sm",onClick:$,disabled:z||w,children:z?"Applying...":"Apply Settings"}),t?.hasJRouter&&(0,d.jsx)(j.$n,{variant:"outline",size:"sm",onClick:_,disabled:C||w,className:"text-red-500 hover:text-[var(--danger)] hover:border-red-500/50",children:C?"Removing...":"Remove from Tool"})]}),(0,d.jsxs)(j.$n,{variant:"outline",size:"sm",onClick:()=>S(!0),children:[(0,d.jsx)(e.default,{className:"text-[18px] mr-1",children:"code"}),"Manual Config"]})]})]})]}),(0,d.jsx)(j.rq,{className:h().modelPicker,isOpen:P,onClose:()=>Q(!1),onSelect:b=>{"pi"===a.id?N.includes(b.value)||O(a=>[...a,b.value]):M(b.value),Q(!1)},activeProviders:m}),(0,d.jsx)(j.uR,{isOpen:R,onClose:()=>S(!1),title:`${a.name} Configuration`,configs:(()=>{let b=X(),c=J||"sk_jrouter",d=L||"provider/model-id";switch(a.id){case"pi":return[{filename:"~/.pi/agent/models.json",content:JSON.stringify({providers:{jrouter:{baseUrl:b,apiKey:c,api:"openai-completions",models:(N.length>0?N:[d]).map(a=>({id:a,name:a,contextWindow:128e3,maxTokens:16384}))}}},null,2)}];case"omp":return[{filename:"~/.omp/agent/models.yml",content:`providers:
72
+ jrouter:
73
73
  baseUrl: ${b}
74
74
  apiKey: ${c}
75
75
  api: openai-completions
76
76
  authHeader: true
77
77
  disableStrictTools: true
78
78
  discovery:
79
- type: proxy`}];case"crush":return[{filename:"~/.config/crush/crush.json",content:JSON.stringify({providers:{"9router":{type:"openai-compat",base_url:b,api_key:c,models:[{id:d,name:d,context_window:128e3}]}}},null,2)}];case"forge":return[{filename:"~/.forge/config.toml",content:`# Forge config — managed by 9Router
79
+ type: proxy`}];case"crush":return[{filename:"~/.config/crush/crush.json",content:JSON.stringify({providers:{jrouter:{type:"openai-compat",base_url:b,api_key:c,models:[{id:d,name:d,context_window:128e3}]}}},null,2)}];case"forge":return[{filename:"~/.forge/config.toml",content:`# Forge config — managed by JRouter
80
80
 
81
81
  [openai]
82
82
  api_key = "${c}"
83
83
  base_url = "${b}"
84
- model = "${d}"`}];case"smelt":return[{filename:"~/.smelt/config.json",content:JSON.stringify({baseUrl:b,apiKey:c,model:d,_managedBy:"9router"},null,2)}];case"codewhale":return[{filename:"~/.codewhale/config.toml",content:`# CodeWhale config — managed by 9Router
84
+ model = "${d}"`}];case"smelt":return[{filename:"~/.smelt/config.json",content:JSON.stringify({baseUrl:b,apiKey:c,model:d,_managedBy:"jrouter"},null,2)}];case"codewhale":return[{filename:"~/.codewhale/config.toml",content:`# CodeWhale config — managed by JRouter
85
85
 
86
86
  [openai]
87
87
  base_url = "${b}"
88
88
  api_key = "${c}"
89
- model = "${d}"`}];default:return[]}})()})]})}let ai="http://localhost:20128";function aj({apiKeys:a,cloudEnabled:b,onStatusChange:c}){let[f,g]=(0,i.useState)(null),[h,k]=(0,i.useState)(!1),[l,m]=(0,i.useState)(!1),[n,o]=(0,i.useState)(""),[p,q]=(0,i.useState)(()=>a?.[0]?.key||""),[r,s]=(0,i.useState)(null),[t,u]=(0,i.useState)(null),[v,w]=(0,i.useState)(null),[x,y]=(0,i.useState)(ai),[z,A]=(0,i.useState)(null),B=f?.isWin===!0,C=B||f?.hasCachedPassword||f?.needsSudoPassword===!1,D=f?.isAdmin!==!1;!D&&(B||f?.hasCachedPassword||f?.needsSudoPassword);let E=(0,i.useCallback)(async()=>{try{let a=await fetch("/api/cli-tools/antigravity-mitm");if(a.ok){let b=await a.json();g(b),b.mitmRouterBaseUrl&&y(b.mitmRouterBaseUrl),c?.(b)}}catch{g({running:!1,certExists:!1,dnsStatus:{}})}},[c]),F=a=>{w(null),f&&(C?G(a,""):(s(a),m(!0),u(null)))},G=async(c,d,e=!1)=>{k(!0),w(null);try{let f;if("trust-cert"===c)f=await fetch("/api/cli-tools/antigravity-mitm",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"trust-cert",sudoPassword:d})});else if("start"===c){let c=p?.trim()||(a?.length>0?a[0].key:null)||(b?null:"sk_9router");f=await fetch("/api/cli-tools/antigravity-mitm",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:c,sudoPassword:d,mitmRouterBaseUrl:x.trim()||ai,forceKillPort443:e})})}else f=await fetch("/api/cli-tools/antigravity-mitm",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({sudoPassword:d})});if(!f.ok){let a=await f.json().catch(()=>({}));if("PORT_443_BUSY"===a.code&&a.portOwner){m(!1),A({owner:a.portOwner,password:d});return}w(a.error||`Failed to ${c} MITM server`);return}m(!1),o(""),A(null),await E()}catch(a){w(a.message||"Network error")}finally{k(!1),s(null)}},H=()=>{n.trim()?G(r,n):u("Sudo password is required")},I=f?.running;return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(j.Zp,{padding:"sm",className:"border-primary/20 bg-primary/5",children:(0,d.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,d.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[(0,d.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,d.jsx)(e.default,{className:"text-primary text-[20px]",children:"security"}),(0,d.jsx)("span",{className:"font-semibold text-sm text-text-main",children:"MITM Server"}),I?(0,d.jsx)(j.Ex,{variant:"success",size:"sm",children:"Running"}):(0,d.jsx)(j.Ex,{variant:"default",size:"sm",children:"Stopped"})]}),(0,d.jsx)("div",{className:"flex flex-wrap items-center gap-1 text-xs text-text-muted","data-i18n-skip":"true",children:[{label:"Cert",ok:f?.certExists},{label:"Trusted",ok:f?.certTrusted},{label:"Server",ok:I}].map(({label:a,ok:b})=>(0,d.jsxs)("span",{className:`flex items-center gap-0.5 px-1.5 py-0.5 rounded ${b?"text-green-600":"text-text-muted"}`,children:[(0,d.jsx)(e.default,{className:"text-[12px]",children:b?"check_circle":"cancel"}),a]},a))})]}),(0,d.jsxs)("div",{className:"px-2 py-2 rounded-lg bg-surface/50 border border-border/50 flex flex-col gap-2",children:[(0,d.jsxs)("p",{className:"text-[11px] text-text-muted leading-relaxed",children:[(0,d.jsx)("span",{className:"font-medium text-text-main",children:"Purpose:"})," Use Antigravity IDE & GitHub Copilot → with ANY provider/model from 9Router"]}),(0,d.jsxs)("p",{className:"text-[11px] text-text-muted leading-relaxed",children:[(0,d.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,d.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,d.jsxs)("div",{className:"grid gap-1 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,d.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"9Router Base URL"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)("input",{type:"text",value:x,onChange:a=>y(a.target.value),placeholder:ai,disabled:I,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"})]}),!I&&(0,d.jsxs)("div",{className:"grid gap-1 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,d.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)("input",{type:"text",list:"mitm-api-keys",value:p,onChange:a=>q(a.target.value),placeholder:b?"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"}),a?.length>0&&(0,d.jsx)("datalist",{id:"mitm-api-keys",children:a.map(a=>(0,d.jsx)("option",{value:a.key,children:a.name||a.key},a.id))})]})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:flex-wrap sm:items-center","data-i18n-skip":"true",children:[f?.certExists&&!f?.certTrusted&&(0,d.jsxs)("button",{onClick:()=>F("trust-cert"),disabled:h,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,d.jsx)(e.default,{className:"text-[16px]",children:"verified_user"}),"Trust Cert"]}),I?(0,d.jsxs)("button",{onClick:()=>F("stop"),disabled:h,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,d.jsx)(e.default,{className:"text-[16px]",children:"stop_circle"}),"Stop Server"]}):(0,d.jsxs)("button",{onClick:()=>F("start"),disabled:h||!f||B&&!D,title:B&&!D?"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,d.jsx)(e.default,{className:"text-[16px]",children:"play_circle"}),"Start Server"]}),I&&(0,d.jsx)("p",{className:"text-xs text-text-muted",children:"Enable DNS per tool below to activate interception"})]}),v&&(0,d.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,d.jsx)(e.default,{className:"text-[14px] mt-0.5 shrink-0",children:"error"}),(0,d.jsx)("span",{children:v})]}),B&&!D&&(0,d.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,d.jsx)(e.default,{className:"text-[14px]",children:"shield_lock"}),(0,d.jsx)("span",{children:"Administrator required — restart 9Router as Administrator to use MITM"})]})]})}),l&&(0,d.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:(0,d.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,d.jsx)("h3",{className:"font-semibold text-text-main",children:"Sudo Password Required"}),(0,d.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,d.jsx)(e.default,{className:"text-yellow-500 text-[20px]",children:"warning"}),(0,d.jsx)("p",{className:"text-xs text-text-muted",children:"Required for SSL certificate and server startup"})]}),(0,d.jsx)(j.pd,{type:"password",placeholder:"Enter sudo password",value:n,onChange:a=>o(a.target.value),onKeyDown:a=>{"Enter"!==a.key||h||H()}}),t&&(0,d.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,d.jsx)(e.default,{className:"text-[14px]",children:"error"}),(0,d.jsx)("span",{children:t})]}),(0,d.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,d.jsx)(j.$n,{variant:"ghost",size:"sm",onClick:()=>{m(!1),o(""),u(null)},disabled:h,children:"Cancel"}),(0,d.jsx)(j.$n,{variant:"primary",size:"sm",onClick:H,loading:h,children:"Confirm"})]})]})}),z&&(0,d.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:(0,d.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,d.jsx)("h3",{className:"font-semibold text-text-main",children:"Port 443 Already In Use"}),(0,d.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,d.jsx)(e.default,{className:"text-yellow-500 text-[20px]",children:"warning"}),(0,d.jsxs)("div",{className:"flex flex-col gap-1 text-xs text-text-muted",children:[(0,d.jsx)("p",{children:"Port 443 is currently used by another process:"}),(0,d.jsxs)("p",{className:"font-mono text-text-main","data-i18n-skip":"true",children:[z.owner.name," (PID ",z.owner.pid,")"]}),(0,d.jsx)("p",{children:"Kill this process to start MITM Server?"})]})]}),(0,d.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,d.jsx)(j.$n,{variant:"ghost",size:"sm",onClick:()=>{A(null),k(!1)},disabled:h,children:"Cancel"}),(0,d.jsx)(j.$n,{variant:"primary",size:"sm",onClick:()=>{G("start",z?.password||"",!0)},loading:h,children:"Kill & Start"})]})]})})]})}var ak=c(36811);function al({tool:a,isExpanded:b,onToggle:c,serverRunning:f,dnsActive:g,hasCachedPassword:h,needsSudoPassword:l,isWin:m,apiKeys:n,activeProviders:o,hasActiveProviders:p,modelAliases:q={},cloudEnabled:r,onDnsChange:s}){let[t,u]=(0,i.useState)(!1),[v,w]=(0,i.useState)(null),[x,y]=(0,i.useState)(!1),[z,A]=(0,i.useState)(""),[B,C]=(0,i.useState)(null),[D,E]=(0,i.useState)(null),[F,G]=(0,i.useState)({}),[H,I]=(0,i.useState)(!1),[J,K]=(0,i.useState)(null),L=ak.TOOL_HOSTS[a.id]??[],M=m||h||!1===l,N=(0,i.useCallback)(async b=>{try{await fetch("/api/cli-tools/antigravity-mitm/alias",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:a.id,mappings:b})})}catch{}},[a.id]),O=(a,b)=>{G(c=>({...c,[a]:b}))},P=()=>{if(!f)return;let a=g?"disable":"enable";M?Q(a,""):(C(a),y(!0),E(null))},Q=async(b,c)=>{u(!0),w(null);try{let d=await fetch("/api/cli-tools/antigravity-mitm",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:a.id,action:b,sudoPassword:c})}),e=await d.json();if(!d.ok)throw Error(e.error||"Failed to toggle DNS");"enable"===b&&w(`Restart ${a.name} to apply changes`),y(!1),A(""),s?.(e)}catch{}finally{u(!1),C(null)}},R=()=>{z.trim()?Q(B,z):E("Sudo password is required")};return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(j.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,d.jsxs)("div",{className:"flex items-start justify-between gap-3 hover:cursor-pointer sm:items-center",onClick:c,children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,d.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,d.jsx)(k.default,{src:a.image,alt:a.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:a=>{a.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,d.jsx)("h3",{className:"font-medium text-sm",children:a.name}),f?g?(0,d.jsx)(j.Ex,{variant:"success",size:"sm",children:"Active"}):(0,d.jsx)(j.Ex,{variant:"warning",size:"sm",children:"DNS off"}):(0,d.jsx)(j.Ex,{variant:"default",size:"sm",children:"Server off"})]}),(0,d.jsxs)("p",{className:"text-xs text-text-muted sm:truncate",children:["Intercept ",a.name," requests via MITM proxy"]})]})]}),(0,d.jsx)(e.default,{className:`text-text-muted text-[20px] transition-transform ${b?"rotate-180":""}`,children:"expand_more"})]}),b&&(0,d.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[L.length>0&&(0,d.jsxs)("div",{className:"mt-2 rounded-md border border-border bg-surface/50 px-2 py-1.5",children:[(0,d.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,d.jsx)("ul",{className:"list-none space-y-0.5 font-mono text-[10px] text-text-muted break-all",children:L.map(a=>(0,d.jsxs)("li",{children:["127.0.0.1 ",a]},a))})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-0.5 text-[11px] text-text-muted px-1",children:[(0,d.jsxs)("p",{children:["Toggle DNS to redirect ",a.name," traffic through 9Router via MITM."]}),!g&&(0,d.jsx)("p",{className:"text-amber-600 text-[10px] mt-1",children:"⚠️ Enable DNS to edit model mappings"})]}),a.defaultModels?.length>0&&(0,d.jsx)("div",{className:"flex flex-col gap-2",children:a.defaultModels.map(a=>(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[9rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,d.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right",children:a.name}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,d.jsx)("input",{type:"text",value:F[a.alias]||"",onChange:b=>O(a.alias,b.target.value),onBlur:b=>{var c,d;return c=a.alias,d=b.target.value,void N({...F,[c]:d})},placeholder:"provider/model-id",disabled:!g,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 ${!g?"opacity-50 cursor-not-allowed":""}`}),F[a.alias]&&(0,d.jsx)("button",{onClick:()=>{O(a.alias,""),N({...F,[a.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,d.jsx)(e.default,{className:"text-[14px]",children:"close"})})]}),(0,d.jsx)("button",{onClick:()=>{K(a.alias),I(!0)},disabled:!p||!g,className:`rounded border px-2 py-2 text-xs transition-colors sm:py-1.5 ${p&&g?"bg-surface border-border hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"})]},a.alias))}),a.defaultModels?.length===0&&(0,d.jsx)("p",{className:"text-xs text-text-muted px-1",children:"Model mappings will be available soon."}),(0,d.jsxs)("div",{className:"flex flex-col gap-2 sm:items-start",children:[g?(0,d.jsxs)("button",{onClick:P,disabled:!f||t,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:cursor-not-allowed disabled:opacity-50 sm:w-auto sm:py-1.5",children:[(0,d.jsx)(e.default,{className:"text-[16px]",children:"stop_circle"}),"Stop DNS"]}):(0,d.jsxs)("button",{onClick:P,disabled:!f||t,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:cursor-not-allowed disabled:opacity-50 sm:w-auto sm:py-1.5",children:[(0,d.jsx)(e.default,{className:"text-[16px]",children:"play_circle"}),"Start DNS"]}),v&&(0,d.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded text-xs text-amber-500",children:[(0,d.jsx)(e.default,{className:"text-[14px]",children:"warning"}),(0,d.jsx)("span",{children:v})]})]})]})]}),x&&(0,d.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:(0,d.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,d.jsx)("h3",{className:"font-semibold text-text-main",children:"Sudo Password Required"}),(0,d.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,d.jsx)(e.default,{className:"text-yellow-500 text-[20px]",children:"warning"}),(0,d.jsx)("p",{className:"text-xs text-text-muted",children:"Required to modify /etc/hosts and flush DNS cache"})]}),(0,d.jsx)(j.pd,{type:"password",placeholder:"Enter sudo password",value:z,onChange:a=>A(a.target.value),onKeyDown:a=>{"Enter"!==a.key||t||R()}}),D&&(0,d.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,d.jsx)(e.default,{className:"text-[14px]",children:"error"}),(0,d.jsx)("span",{children:D})]}),(0,d.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,d.jsx)(j.$n,{variant:"ghost",size:"sm",onClick:()=>{y(!1),A(""),E(null)},disabled:t,children:"Cancel"}),(0,d.jsx)(j.$n,{variant:"primary",size:"sm",onClick:R,loading:t,children:"Confirm"})]})]})}),H&&(0,d.jsx)(j.rq,{isOpen:H,onClose:()=>I(!1),onSelect:a=>{if(!J||a.isPlaceholder)return;let b={...F,[J]:a.value};G(b),N(b)},selectedModel:J?F[J]:null,activeProviders:o,modelAliases:q,title:`Select model for ${J}`})]})}var am=c(2116),an=c.n(am);function ao({tool:a}){return(0,d.jsx)(an(),{href:"/dashboard/mitm",className:h().toolLink,children:(0,d.jsxs)(j.Zp,{padding:"none",className:h().tile,children:[(0,d.jsx)("div",{className:h().toolIcon,children:(0,d.jsx)(k.default,{src:a.image,alt:a.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:a=>{a.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,d.jsxs)("div",{className:h().identity,children:[(0,d.jsxs)("div",{className:h().titleLine,children:[(0,d.jsx)("h3",{className:h().title,title:a.name,children:a.name}),(0,d.jsx)(f.A,{dot:!1,className:h().status,children:"MITM"})]}),(0,d.jsx)("p",{className:h().description,title:a.description,children:a.description})]}),(0,d.jsx)(e.default,{className:h().chevron,size:18,children:"chevron_right"})]})})}},30083:a=>{a.exports={dialog:"DashboardControls_dialog__YyPS4",formScope:"DashboardControls_formScope__ID02o",fields:"DashboardControls_fields__IY485",iconButton:"DashboardControls_iconButton__v_EJw",modelPicker:"DashboardControls_modelPicker__BheYV DashboardControls_dialog__YyPS4"}},36811:a=>{"use strict";a.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"]}}},62911:(a,b,c)=>{"use strict";c.d(b,{dM:()=>e,wn:()=>d});let d={antigravity:{id:"antigravity",name:"Antigravity",image:"/providers/antigravity.png",color:"#4285F4",description:"Google Antigravity IDE with MITM",configType:"mitm",mitmDomain:"daily-cloudcode-pa.googleapis.com",modelAliases:["gemini-3.8-flash-high","gemini-3.8-flash-medium","gemini-3.8-flash-low","gemini-3.7-flash-high","gemini-3.7-flash-medium","gemini-3.7-flash-low","gemini-3.6-flash-high","gemini-3.6-flash-medium","gemini-3.6-flash-low","gemini-3.1-pro-high","gemini-3.1-pro-low","gemini-pro-agent","claude-sonnet-5-5","claude-sonnet-5-5-low","claude-sonnet-5-5-medium","claude-sonnet-5-5-high","claude-opus-5-5","claude-opus-5-5-low","claude-opus-5-5-medium","claude-opus-5-5-high","claude-sonnet-4-6","claude-opus-4-6-thinking","gpt-oss-120b-medium"],defaultModels:[{id:"gemini-3.8-flash-high",name:"Gemini 3.8 Flash (High)",alias:"gemini-3.8-flash-high"},{id:"gemini-3.8-flash-medium",name:"Gemini 3.8 Flash (Medium) / Default",alias:"gemini-3.8-flash-medium",mandatory:!0},{id:"gemini-3.8-flash-low",name:"Gemini 3.8 Flash (Low)",alias:"gemini-3.8-flash-low"},{id:"gemini-3.7-flash-high",name:"Gemini 3.7 Flash (High)",alias:"gemini-3.7-flash-high"},{id:"gemini-3.7-flash-medium",name:"Gemini 3.7 Flash (Medium)",alias:"gemini-3.7-flash-medium"},{id:"gemini-3.7-flash-low",name:"Gemini 3.7 Flash (Low)",alias:"gemini-3.7-flash-low"},{id:"gemini-3.6-flash-high",name:"Gemini 3.6 Flash (High)",alias:"gemini-3.6-flash-high"},{id:"gemini-3.6-flash-medium",name:"Gemini 3.6 Flash (Medium)",alias:"gemini-3.6-flash-medium"},{id:"gemini-3.6-flash-low",name:"Gemini 3.6 Flash (Low)",alias:"gemini-3.6-flash-low"},{id:"gemini-3.1-pro-high",name:"Gemini 3.1 Pro (High)",alias:"gemini-3.1-pro-high"},{id:"gemini-3.1-pro-low",name:"Gemini 3.1 Pro (Low)",alias:"gemini-3.1-pro-low"},{id:"gemini-pro-agent",name:"Gemini 3.1 Pro (High) / Legacy",alias:"gemini-pro-agent"},{id:"claude-sonnet-5-5",name:"Claude Sonnet 5.5 (Thinking)",alias:"claude-sonnet-5-5"},{id:"claude-sonnet-5-5-low",name:"Claude Sonnet 5.5 (Low)",alias:"claude-sonnet-5-5-low"},{id:"claude-sonnet-5-5-medium",name:"Claude Sonnet 5.5 (Medium)",alias:"claude-sonnet-5-5-medium"},{id:"claude-sonnet-5-5-high",name:"Claude Sonnet 5.5 (High)",alias:"claude-sonnet-5-5-high"},{id:"claude-opus-5-5",name:"Claude Opus 5.5 (Thinking)",alias:"claude-opus-5-5"},{id:"claude-opus-5-5-low",name:"Claude Opus 5.5 (Low)",alias:"claude-opus-5-5-low"},{id:"claude-opus-5-5-medium",name:"Claude Opus 5.5 (Medium)",alias:"claude-opus-5-5-medium"},{id:"claude-opus-5-5-high",name:"Claude Opus 5.5 (High)",alias:"claude-opus-5-5-high"},{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6 (Thinking)",alias:"claude-sonnet-4-6"},{id:"claude-opus-4-6-thinking",name:"Claude Opus 4.6 (Thinking)",alias:"claude-opus-4-6-thinking"},{id:"gpt-oss-120b-medium",name:"GPT-OSS 120B (Medium)",alias:"gpt-oss-120b-medium"}]},kiro:{id:"kiro",name:"Kiro",image:"/providers/kiro.png",color:"#FF6B00",description:"Kiro IDE with MITM",configType:"mitm",mitmDomain:"runtime.us-east-1.kiro.dev",defaultModels:[{id:"auto",name:"Auto (Kiro Agent)",alias:"auto"},{id:"claude-sonnet-5",name:"Claude Sonnet 5",alias:"claude-sonnet-5"},{id:"claude-sonnet-4.5",name:"Claude Sonnet 4.5",alias:"claude-sonnet-4.5"},{id:"claude-sonnet-4",name:"Claude Sonnet 4",alias:"claude-sonnet-4"},{id:"claude-haiku-4.5",name:"Claude Haiku 4.5",alias:"claude-haiku-4.5"},{id:"deepseek-3.2",name:"DeepSeek 3.2",alias:"deepseek-3.2"},{id:"minimax-m2.1",name:"MiniMax M2.1",alias:"minimax-m2.1"},{id:"gpt-5.6-sol",name:"GPT 5.6 Sol",alias:"gpt-5.6-sol",contextLength:272e3,rateMultiplier:2.4},{id:"gpt-5.6-terra",name:"GPT 5.6 Terra",alias:"gpt-5.6-terra",contextLength:272e3,rateMultiplier:1.2},{id:"gpt-5.6-luna",name:"GPT 5.6 Luna",alias:"gpt-5.6-luna",contextLength:272e3,rateMultiplier:.6},{id:"simple-task",name:"Qwen3 Coder Next",alias:"simple-task"}]}},e={claude:{id:"claude",name:"Claude Code",image:"/providers/claude.png",color:"#D97757",description:"Anthropic Claude Code CLI",configType:"env",envVars:{baseUrl:"ANTHROPIC_BASE_URL",model:"ANTHROPIC_MODEL",opusModel:"ANTHROPIC_DEFAULT_OPUS_MODEL",sonnetModel:"ANTHROPIC_DEFAULT_SONNET_MODEL",fableModel:"ANTHROPIC_DEFAULT_FABLE_MODEL",haikuModel:"ANTHROPIC_DEFAULT_HAIKU_MODEL"},modelAliases:["default","sonnet","opus","fable","haiku","opusplan"],settingsFile:"~/.claude/settings.json",defaultModels:[{id:"fable",name:"Claude Fable",alias:"fable",envKey:"ANTHROPIC_DEFAULT_FABLE_MODEL",defaultValue:"cc/claude-fable-5"},{id:"opus",name:"Claude Opus",alias:"opus",envKey:"ANTHROPIC_DEFAULT_OPUS_MODEL",defaultValue:"cc/claude-opus-5"},{id:"sonnet",name:"Claude Sonnet",alias:"sonnet",envKey:"ANTHROPIC_DEFAULT_SONNET_MODEL",defaultValue:"cc/claude-sonnet-5"},{id:"haiku",name:"Claude Haiku",alias:"haiku",envKey:"ANTHROPIC_DEFAULT_HAIKU_MODEL",defaultValue:"cc/claude-haiku-4-5-20251001"}]},openclaw:{id:"openclaw",name:"Open Claw",image:"/providers/openclaw.png",color:"#FF6B35",description:"Open Claw AI Assistant",configType:"custom"},codex:{id:"codex",name:"OpenAI Codex CLI / App",image:"/providers/codex.png",color:"#10A37F",description:"OpenAI Codex CLI",configType:"custom"},copilot:{id:"copilot",name:"GitHub Copilot",image:"/providers/copilot.png",color:"#1F6FEB",description:"GitHub Copilot in VS Code via 9Router extension",configType:"guide",docsUrl:"https://marketplace.visualstudio.com/items?itemName=hotrungnhan.9router-for-github-copilot",guideSteps:[{step:1,title:"Install Extension",desc:"In VS Code, open Extensions (Ctrl+Shift+X or Cmd+Shift+X), search for '9Router for Github Copilot' and click Install."},{step:2,title:"Configure Server",desc:"Press Cmd+Shift+P (or Ctrl+Shift+P), run '9Router: Configure Server', then enter your Server URL and API Key:",value:"{{baseUrl}}",copyable:!0},{step:3,title:"Select Model in Copilot Chat",desc:"Open Copilot Chat, click the model picker at the bottom → 'Manage Models...' → check the 9Router models to use."}]},opencode:{id:"opencode",name:"OpenCode",image:"/providers/opencode.png",color:"#E87040",description:"OpenCode AI Terminal Assistant",configType:"custom"},cowork:{id:"cowork",name:"Claude Cowork",image:"/providers/claude.png",color:"#D97757",description:"Claude Desktop Cowork (third-party inference)",configType:"custom"},hermes:{id:"hermes",name:"Hermes Agent",image:"/providers/hermes.png",color:"#8B5CF6",description:"Nous Research self-improving AI agent",configType:"custom",roles:[{id:"delegation",label:"Delegation (subagents)"},{id:"vision",label:"Vision"},{id:"compression",label:"Compression"},{id:"title_generation",label:"Title Generation"},{id:"approval",label:"Approval"},{id:"skills_hub",label:"Skills Hub"},{id:"mcp",label:"MCP"},{id:"review",label:"Review (/review subagent)"},{id:"memory_query_rewrite",label:"Memory Query Rewrite"},{id:"background_review",label:"Background Review"},{id:"curator",label:"Curator"},{id:"monitor",label:"Monitor"},{id:"tts_audio_tags",label:"TTS Audio Tags"},{id:"triage_specifier",label:"Triage Specifier"},{id:"kanban_decomposer",label:"Kanban Decomposer"},{id:"profile_describer",label:"Profile Describer"},{id:"goal_judge",label:"Goal Judge"}]},droid:{id:"droid",name:"Factory Droid",image:"/providers/droid.png",color:"#00D4FF",description:"Factory Droid AI Assistant",configType:"custom"},cursor:{id:"cursor",name:"Cursor",image:"/providers/cursor.png",color:"#000000",description:"Cursor AI Code Editor",configType:"guide",requiresExternalUrl:!0,notes:[{type:"warning",text:"Requires Cursor Pro account to use this feature."},{type:"cloudCheck",text:"Cursor routes requests through its own server, so local endpoint is not supported. Please enable Tunnel or Cloud Endpoint in Settings."}],guideSteps:[{step:1,title:"Open Settings",desc:"Go to Settings → Models"},{step:2,title:"Enable OpenAI API",desc:'Enable "OpenAI API key" option'},{step:3,title:"Base URL",value:"{{baseUrl}}",copyable:!0},{step:4,title:"API Key",type:"apiKeySelector"},{step:5,title:"Add Custom Model",desc:'Click "View All Model" → "Add Custom Model"'},{step:6,title:"Select Model",type:"modelSelector"}]},cline:{id:"cline",name:"Cline",image:"/providers/cline.png",color:"#5B9BD5",description:"Cline AI Coding Assistant",configType:"custom"},kilo:{id:"kilo",name:"Kilo Code",image:"/providers/kilocode.png",color:"#FF6B6B",description:"Kilo Code AI Assistant",configType:"custom"},roo:{id:"roo",name:"Roo",image:"/providers/roo.png",color:"#FF6B6B",description:"Roo AI Assistant",configType:"guide",guideSteps:[{step:1,title:"Open Settings",desc:"Go to Roo Settings panel"},{step:2,title:"Select Provider",desc:"Choose API Provider → Ollama"},{step:3,title:"Base URL",value:"{{baseUrl}}",copyable:!0},{step:4,title:"API Key",type:"apiKeySelector"},{step:5,title:"Select Model",type:"modelSelector"}]},continue:{id:"continue",name:"Continue",image:"/providers/continue.png",color:"#7C3AED",description:"Continue AI Assistant",configType:"guide",guideSteps:[{step:1,title:"Open Config",desc:"Open Continue configuration file"},{step:2,title:"API Key",type:"apiKeySelector"},{step:3,title:"Select Model",type:"modelSelector"},{step:4,title:"Add Model Config",desc:"Add the following configuration to your models array:"}],codeBlock:{language:"json",code:`{
89
+ model = "${d}"`}];default:return[]}})()})]})}let ai="http://localhost:20128";function aj({apiKeys:a,cloudEnabled:b,onStatusChange:c}){let[f,g]=(0,i.useState)(null),[h,k]=(0,i.useState)(!1),[l,m]=(0,i.useState)(!1),[n,o]=(0,i.useState)(""),[p,q]=(0,i.useState)(()=>a?.[0]?.key||""),[r,s]=(0,i.useState)(null),[t,u]=(0,i.useState)(null),[v,w]=(0,i.useState)(null),[x,y]=(0,i.useState)(ai),[z,A]=(0,i.useState)(null),B=f?.isWin===!0,C=B||f?.hasCachedPassword||f?.needsSudoPassword===!1,D=f?.isAdmin!==!1;!D&&(B||f?.hasCachedPassword||f?.needsSudoPassword);let E=(0,i.useCallback)(async()=>{try{let a=await fetch("/api/cli-tools/antigravity-mitm");if(a.ok){let b=await a.json();g(b),b.mitmRouterBaseUrl&&y(b.mitmRouterBaseUrl),c?.(b)}}catch{g({running:!1,certExists:!1,dnsStatus:{}})}},[c]),F=a=>{w(null),f&&(C?G(a,""):(s(a),m(!0),u(null)))},G=async(c,d,e=!1)=>{k(!0),w(null);try{let f;if("trust-cert"===c)f=await fetch("/api/cli-tools/antigravity-mitm",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"trust-cert",sudoPassword:d})});else if("start"===c){let c=p?.trim()||(a?.length>0?a[0].key:null)||(b?null:"sk_jrouter");f=await fetch("/api/cli-tools/antigravity-mitm",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:c,sudoPassword:d,mitmRouterBaseUrl:x.trim()||ai,forceKillPort443:e})})}else f=await fetch("/api/cli-tools/antigravity-mitm",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({sudoPassword:d})});if(!f.ok){let a=await f.json().catch(()=>({}));if("PORT_443_BUSY"===a.code&&a.portOwner){m(!1),A({owner:a.portOwner,password:d});return}w(a.error||`Failed to ${c} MITM server`);return}m(!1),o(""),A(null),await E()}catch(a){w(a.message||"Network error")}finally{k(!1),s(null)}},H=()=>{n.trim()?G(r,n):u("Sudo password is required")},I=f?.running;return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(j.Zp,{padding:"sm",className:"border-primary/20 bg-primary/5",children:(0,d.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,d.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[(0,d.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,d.jsx)(e.default,{className:"text-primary text-[20px]",children:"security"}),(0,d.jsx)("span",{className:"font-semibold text-sm text-text-main",children:"MITM Server"}),I?(0,d.jsx)(j.Ex,{variant:"success",size:"sm",children:"Running"}):(0,d.jsx)(j.Ex,{variant:"default",size:"sm",children:"Stopped"})]}),(0,d.jsx)("div",{className:"flex flex-wrap items-center gap-1 text-xs text-text-muted","data-i18n-skip":"true",children:[{label:"Cert",ok:f?.certExists},{label:"Trusted",ok:f?.certTrusted},{label:"Server",ok:I}].map(({label:a,ok:b})=>(0,d.jsxs)("span",{className:`flex items-center gap-0.5 px-1.5 py-0.5 rounded ${b?"text-green-600":"text-text-muted"}`,children:[(0,d.jsx)(e.default,{className:"text-[12px]",children:b?"check_circle":"cancel"}),a]},a))})]}),(0,d.jsxs)("div",{className:"px-2 py-2 rounded-lg bg-surface/50 border border-border/50 flex flex-col gap-2",children:[(0,d.jsxs)("p",{className:"text-[11px] text-text-muted leading-relaxed",children:[(0,d.jsx)("span",{className:"font-medium text-text-main",children:"Purpose:"})," Use Antigravity IDE & GitHub Copilot → with ANY provider/model from JRouter"]}),(0,d.jsxs)("p",{className:"text-[11px] text-text-muted leading-relaxed",children:[(0,d.jsx)("span",{className:"font-medium text-text-main",children:"How it works:"})," Antigravity/Copilot IDE request → DNS redirect to localhost:443 → MITM proxy intercepts → JRouter → response to Antigravity/Copilot"]})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,d.jsxs)("div",{className:"grid gap-1 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,d.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"JRouter Base URL"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)("input",{type:"text",value:x,onChange:a=>y(a.target.value),placeholder:ai,disabled:I,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"})]}),!I&&(0,d.jsxs)("div",{className:"grid gap-1 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,d.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsx)("input",{type:"text",list:"mitm-api-keys",value:p,onChange:a=>q(a.target.value),placeholder:b?"Enter or pick API key":"sk_jrouter (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"}),a?.length>0&&(0,d.jsx)("datalist",{id:"mitm-api-keys",children:a.map(a=>(0,d.jsx)("option",{value:a.key,children:a.name||a.key},a.id))})]})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:flex-wrap sm:items-center","data-i18n-skip":"true",children:[f?.certExists&&!f?.certTrusted&&(0,d.jsxs)("button",{onClick:()=>F("trust-cert"),disabled:h,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,d.jsx)(e.default,{className:"text-[16px]",children:"verified_user"}),"Trust Cert"]}),I?(0,d.jsxs)("button",{onClick:()=>F("stop"),disabled:h,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,d.jsx)(e.default,{className:"text-[16px]",children:"stop_circle"}),"Stop Server"]}):(0,d.jsxs)("button",{onClick:()=>F("start"),disabled:h||!f||B&&!D,title:B&&!D?"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,d.jsx)(e.default,{className:"text-[16px]",children:"play_circle"}),"Start Server"]}),I&&(0,d.jsx)("p",{className:"text-xs text-text-muted",children:"Enable DNS per tool below to activate interception"})]}),v&&(0,d.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,d.jsx)(e.default,{className:"text-[14px] mt-0.5 shrink-0",children:"error"}),(0,d.jsx)("span",{children:v})]}),B&&!D&&(0,d.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,d.jsx)(e.default,{className:"text-[14px]",children:"shield_lock"}),(0,d.jsx)("span",{children:"Administrator required — restart JRouter as Administrator to use MITM"})]})]})}),l&&(0,d.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:(0,d.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,d.jsx)("h3",{className:"font-semibold text-text-main",children:"Sudo Password Required"}),(0,d.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,d.jsx)(e.default,{className:"text-yellow-500 text-[20px]",children:"warning"}),(0,d.jsx)("p",{className:"text-xs text-text-muted",children:"Required for SSL certificate and server startup"})]}),(0,d.jsx)(j.pd,{type:"password",placeholder:"Enter sudo password",value:n,onChange:a=>o(a.target.value),onKeyDown:a=>{"Enter"!==a.key||h||H()}}),t&&(0,d.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,d.jsx)(e.default,{className:"text-[14px]",children:"error"}),(0,d.jsx)("span",{children:t})]}),(0,d.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,d.jsx)(j.$n,{variant:"ghost",size:"sm",onClick:()=>{m(!1),o(""),u(null)},disabled:h,children:"Cancel"}),(0,d.jsx)(j.$n,{variant:"primary",size:"sm",onClick:H,loading:h,children:"Confirm"})]})]})}),z&&(0,d.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:(0,d.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,d.jsx)("h3",{className:"font-semibold text-text-main",children:"Port 443 Already In Use"}),(0,d.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,d.jsx)(e.default,{className:"text-yellow-500 text-[20px]",children:"warning"}),(0,d.jsxs)("div",{className:"flex flex-col gap-1 text-xs text-text-muted",children:[(0,d.jsx)("p",{children:"Port 443 is currently used by another process:"}),(0,d.jsxs)("p",{className:"font-mono text-text-main","data-i18n-skip":"true",children:[z.owner.name," (PID ",z.owner.pid,")"]}),(0,d.jsx)("p",{children:"Kill this process to start MITM Server?"})]})]}),(0,d.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,d.jsx)(j.$n,{variant:"ghost",size:"sm",onClick:()=>{A(null),k(!1)},disabled:h,children:"Cancel"}),(0,d.jsx)(j.$n,{variant:"primary",size:"sm",onClick:()=>{G("start",z?.password||"",!0)},loading:h,children:"Kill & Start"})]})]})})]})}var ak=c(36811);function al({tool:a,isExpanded:b,onToggle:c,serverRunning:f,dnsActive:g,hasCachedPassword:h,needsSudoPassword:l,isWin:m,apiKeys:n,activeProviders:o,hasActiveProviders:p,modelAliases:q={},cloudEnabled:r,onDnsChange:s}){let[t,u]=(0,i.useState)(!1),[v,w]=(0,i.useState)(null),[x,y]=(0,i.useState)(!1),[z,A]=(0,i.useState)(""),[B,C]=(0,i.useState)(null),[D,E]=(0,i.useState)(null),[F,G]=(0,i.useState)({}),[H,I]=(0,i.useState)(!1),[J,K]=(0,i.useState)(null),L=ak.TOOL_HOSTS[a.id]??[],M=m||h||!1===l,N=(0,i.useCallback)(async b=>{try{await fetch("/api/cli-tools/antigravity-mitm/alias",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:a.id,mappings:b})})}catch{}},[a.id]),O=(a,b)=>{G(c=>({...c,[a]:b}))},P=()=>{if(!f)return;let a=g?"disable":"enable";M?Q(a,""):(C(a),y(!0),E(null))},Q=async(b,c)=>{u(!0),w(null);try{let d=await fetch("/api/cli-tools/antigravity-mitm",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:a.id,action:b,sudoPassword:c})}),e=await d.json();if(!d.ok)throw Error(e.error||"Failed to toggle DNS");"enable"===b&&w(`Restart ${a.name} to apply changes`),y(!1),A(""),s?.(e)}catch{}finally{u(!1),C(null)}},R=()=>{z.trim()?Q(B,z):E("Sudo password is required")};return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(j.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,d.jsxs)("div",{className:"flex items-start justify-between gap-3 hover:cursor-pointer sm:items-center",onClick:c,children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,d.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,d.jsx)(k.default,{src:a.image,alt:a.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:a=>{a.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,d.jsx)("h3",{className:"font-medium text-sm",children:a.name}),f?g?(0,d.jsx)(j.Ex,{variant:"success",size:"sm",children:"Active"}):(0,d.jsx)(j.Ex,{variant:"warning",size:"sm",children:"DNS off"}):(0,d.jsx)(j.Ex,{variant:"default",size:"sm",children:"Server off"})]}),(0,d.jsxs)("p",{className:"text-xs text-text-muted sm:truncate",children:["Intercept ",a.name," requests via MITM proxy"]})]})]}),(0,d.jsx)(e.default,{className:`text-text-muted text-[20px] transition-transform ${b?"rotate-180":""}`,children:"expand_more"})]}),b&&(0,d.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[L.length>0&&(0,d.jsxs)("div",{className:"mt-2 rounded-md border border-border bg-surface/50 px-2 py-1.5",children:[(0,d.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,d.jsx)("ul",{className:"list-none space-y-0.5 font-mono text-[10px] text-text-muted break-all",children:L.map(a=>(0,d.jsxs)("li",{children:["127.0.0.1 ",a]},a))})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-0.5 text-[11px] text-text-muted px-1",children:[(0,d.jsxs)("p",{children:["Toggle DNS to redirect ",a.name," traffic through JRouter via MITM."]}),!g&&(0,d.jsx)("p",{className:"text-amber-600 text-[10px] mt-1",children:"⚠️ Enable DNS to edit model mappings"})]}),a.defaultModels?.length>0&&(0,d.jsx)("div",{className:"flex flex-col gap-2",children:a.defaultModels.map(a=>(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[9rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,d.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right",children:a.name}),(0,d.jsx)(e.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,d.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,d.jsx)("input",{type:"text",value:F[a.alias]||"",onChange:b=>O(a.alias,b.target.value),onBlur:b=>{var c,d;return c=a.alias,d=b.target.value,void N({...F,[c]:d})},placeholder:"provider/model-id",disabled:!g,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 ${!g?"opacity-50 cursor-not-allowed":""}`}),F[a.alias]&&(0,d.jsx)("button",{onClick:()=>{O(a.alias,""),N({...F,[a.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,d.jsx)(e.default,{className:"text-[14px]",children:"close"})})]}),(0,d.jsx)("button",{onClick:()=>{K(a.alias),I(!0)},disabled:!p||!g,className:`rounded border px-2 py-2 text-xs transition-colors sm:py-1.5 ${p&&g?"bg-surface border-border hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"})]},a.alias))}),a.defaultModels?.length===0&&(0,d.jsx)("p",{className:"text-xs text-text-muted px-1",children:"Model mappings will be available soon."}),(0,d.jsxs)("div",{className:"flex flex-col gap-2 sm:items-start",children:[g?(0,d.jsxs)("button",{onClick:P,disabled:!f||t,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:cursor-not-allowed disabled:opacity-50 sm:w-auto sm:py-1.5",children:[(0,d.jsx)(e.default,{className:"text-[16px]",children:"stop_circle"}),"Stop DNS"]}):(0,d.jsxs)("button",{onClick:P,disabled:!f||t,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:cursor-not-allowed disabled:opacity-50 sm:w-auto sm:py-1.5",children:[(0,d.jsx)(e.default,{className:"text-[16px]",children:"play_circle"}),"Start DNS"]}),v&&(0,d.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded text-xs text-amber-500",children:[(0,d.jsx)(e.default,{className:"text-[14px]",children:"warning"}),(0,d.jsx)("span",{children:v})]})]})]})]}),x&&(0,d.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:(0,d.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,d.jsx)("h3",{className:"font-semibold text-text-main",children:"Sudo Password Required"}),(0,d.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,d.jsx)(e.default,{className:"text-yellow-500 text-[20px]",children:"warning"}),(0,d.jsx)("p",{className:"text-xs text-text-muted",children:"Required to modify /etc/hosts and flush DNS cache"})]}),(0,d.jsx)(j.pd,{type:"password",placeholder:"Enter sudo password",value:z,onChange:a=>A(a.target.value),onKeyDown:a=>{"Enter"!==a.key||t||R()}}),D&&(0,d.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,d.jsx)(e.default,{className:"text-[14px]",children:"error"}),(0,d.jsx)("span",{children:D})]}),(0,d.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,d.jsx)(j.$n,{variant:"ghost",size:"sm",onClick:()=>{y(!1),A(""),E(null)},disabled:t,children:"Cancel"}),(0,d.jsx)(j.$n,{variant:"primary",size:"sm",onClick:R,loading:t,children:"Confirm"})]})]})}),H&&(0,d.jsx)(j.rq,{isOpen:H,onClose:()=>I(!1),onSelect:a=>{if(!J||a.isPlaceholder)return;let b={...F,[J]:a.value};G(b),N(b)},selectedModel:J?F[J]:null,activeProviders:o,modelAliases:q,title:`Select model for ${J}`})]})}var am=c(2116),an=c.n(am);function ao({tool:a}){return(0,d.jsx)(an(),{href:"/dashboard/mitm",className:h().toolLink,children:(0,d.jsxs)(j.Zp,{padding:"none",className:h().tile,children:[(0,d.jsx)("div",{className:h().toolIcon,children:(0,d.jsx)(k.default,{src:a.image,alt:a.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:a=>{a.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,d.jsxs)("div",{className:h().identity,children:[(0,d.jsxs)("div",{className:h().titleLine,children:[(0,d.jsx)("h3",{className:h().title,title:a.name,children:a.name}),(0,d.jsx)(f.A,{dot:!1,className:h().status,children:"MITM"})]}),(0,d.jsx)("p",{className:h().description,title:a.description,children:a.description})]}),(0,d.jsx)(e.default,{className:h().chevron,size:18,children:"chevron_right"})]})})}},30083:a=>{a.exports={dialog:"DashboardControls_dialog__YyPS4",formScope:"DashboardControls_formScope__ID02o",fields:"DashboardControls_fields__IY485",iconButton:"DashboardControls_iconButton__v_EJw",modelPicker:"DashboardControls_modelPicker__BheYV DashboardControls_dialog__YyPS4"}},36811:a=>{"use strict";a.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"]}}},62911:(a,b,c)=>{"use strict";c.d(b,{dM:()=>e,wn:()=>d});let d={antigravity:{id:"antigravity",name:"Antigravity",image:"/providers/antigravity.png",color:"#4285F4",description:"Google Antigravity IDE with MITM",configType:"mitm",mitmDomain:"daily-cloudcode-pa.googleapis.com",modelAliases:["gemini-3.8-flash-high","gemini-3.8-flash-medium","gemini-3.8-flash-low","gemini-3.7-flash-high","gemini-3.7-flash-medium","gemini-3.7-flash-low","gemini-3.6-flash-high","gemini-3.6-flash-medium","gemini-3.6-flash-low","gemini-3.1-pro-high","gemini-3.1-pro-low","gemini-pro-agent","claude-sonnet-5-5","claude-sonnet-5-5-low","claude-sonnet-5-5-medium","claude-sonnet-5-5-high","claude-opus-5-5","claude-opus-5-5-low","claude-opus-5-5-medium","claude-opus-5-5-high","claude-sonnet-4-6","claude-opus-4-6-thinking","gpt-oss-120b-medium"],defaultModels:[{id:"gemini-3.8-flash-high",name:"Gemini 3.8 Flash (High)",alias:"gemini-3.8-flash-high"},{id:"gemini-3.8-flash-medium",name:"Gemini 3.8 Flash (Medium) / Default",alias:"gemini-3.8-flash-medium",mandatory:!0},{id:"gemini-3.8-flash-low",name:"Gemini 3.8 Flash (Low)",alias:"gemini-3.8-flash-low"},{id:"gemini-3.7-flash-high",name:"Gemini 3.7 Flash (High)",alias:"gemini-3.7-flash-high"},{id:"gemini-3.7-flash-medium",name:"Gemini 3.7 Flash (Medium)",alias:"gemini-3.7-flash-medium"},{id:"gemini-3.7-flash-low",name:"Gemini 3.7 Flash (Low)",alias:"gemini-3.7-flash-low"},{id:"gemini-3.6-flash-high",name:"Gemini 3.6 Flash (High)",alias:"gemini-3.6-flash-high"},{id:"gemini-3.6-flash-medium",name:"Gemini 3.6 Flash (Medium)",alias:"gemini-3.6-flash-medium"},{id:"gemini-3.6-flash-low",name:"Gemini 3.6 Flash (Low)",alias:"gemini-3.6-flash-low"},{id:"gemini-3.1-pro-high",name:"Gemini 3.1 Pro (High)",alias:"gemini-3.1-pro-high"},{id:"gemini-3.1-pro-low",name:"Gemini 3.1 Pro (Low)",alias:"gemini-3.1-pro-low"},{id:"gemini-pro-agent",name:"Gemini 3.1 Pro (High) / Legacy",alias:"gemini-pro-agent"},{id:"claude-sonnet-5-5",name:"Claude Sonnet 5.5 (Thinking)",alias:"claude-sonnet-5-5"},{id:"claude-sonnet-5-5-low",name:"Claude Sonnet 5.5 (Low)",alias:"claude-sonnet-5-5-low"},{id:"claude-sonnet-5-5-medium",name:"Claude Sonnet 5.5 (Medium)",alias:"claude-sonnet-5-5-medium"},{id:"claude-sonnet-5-5-high",name:"Claude Sonnet 5.5 (High)",alias:"claude-sonnet-5-5-high"},{id:"claude-opus-5-5",name:"Claude Opus 5.5 (Thinking)",alias:"claude-opus-5-5"},{id:"claude-opus-5-5-low",name:"Claude Opus 5.5 (Low)",alias:"claude-opus-5-5-low"},{id:"claude-opus-5-5-medium",name:"Claude Opus 5.5 (Medium)",alias:"claude-opus-5-5-medium"},{id:"claude-opus-5-5-high",name:"Claude Opus 5.5 (High)",alias:"claude-opus-5-5-high"},{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6 (Thinking)",alias:"claude-sonnet-4-6"},{id:"claude-opus-4-6-thinking",name:"Claude Opus 4.6 (Thinking)",alias:"claude-opus-4-6-thinking"},{id:"gpt-oss-120b-medium",name:"GPT-OSS 120B (Medium)",alias:"gpt-oss-120b-medium"}]},kiro:{id:"kiro",name:"Kiro",image:"/providers/kiro.png",color:"#FF6B00",description:"Kiro IDE with MITM",configType:"mitm",mitmDomain:"runtime.us-east-1.kiro.dev",defaultModels:[{id:"auto",name:"Auto (Kiro Agent)",alias:"auto"},{id:"claude-sonnet-5",name:"Claude Sonnet 5",alias:"claude-sonnet-5"},{id:"claude-sonnet-4.5",name:"Claude Sonnet 4.5",alias:"claude-sonnet-4.5"},{id:"claude-sonnet-4",name:"Claude Sonnet 4",alias:"claude-sonnet-4"},{id:"claude-haiku-4.5",name:"Claude Haiku 4.5",alias:"claude-haiku-4.5"},{id:"deepseek-3.2",name:"DeepSeek 3.2",alias:"deepseek-3.2"},{id:"minimax-m2.1",name:"MiniMax M2.1",alias:"minimax-m2.1"},{id:"gpt-5.6-sol",name:"GPT 5.6 Sol",alias:"gpt-5.6-sol",contextLength:272e3,rateMultiplier:2.4},{id:"gpt-5.6-terra",name:"GPT 5.6 Terra",alias:"gpt-5.6-terra",contextLength:272e3,rateMultiplier:1.2},{id:"gpt-5.6-luna",name:"GPT 5.6 Luna",alias:"gpt-5.6-luna",contextLength:272e3,rateMultiplier:.6},{id:"simple-task",name:"Qwen3 Coder Next",alias:"simple-task"}]}},e={claude:{id:"claude",name:"Claude Code",image:"/providers/claude.png",color:"#D97757",description:"Anthropic Claude Code CLI",configType:"env",envVars:{baseUrl:"ANTHROPIC_BASE_URL",model:"ANTHROPIC_MODEL",opusModel:"ANTHROPIC_DEFAULT_OPUS_MODEL",sonnetModel:"ANTHROPIC_DEFAULT_SONNET_MODEL",fableModel:"ANTHROPIC_DEFAULT_FABLE_MODEL",haikuModel:"ANTHROPIC_DEFAULT_HAIKU_MODEL"},modelAliases:["default","sonnet","opus","fable","haiku","opusplan"],settingsFile:"~/.claude/settings.json",defaultModels:[{id:"fable",name:"Claude Fable",alias:"fable",envKey:"ANTHROPIC_DEFAULT_FABLE_MODEL",defaultValue:"cc/claude-fable-5"},{id:"opus",name:"Claude Opus",alias:"opus",envKey:"ANTHROPIC_DEFAULT_OPUS_MODEL",defaultValue:"cc/claude-opus-5"},{id:"sonnet",name:"Claude Sonnet",alias:"sonnet",envKey:"ANTHROPIC_DEFAULT_SONNET_MODEL",defaultValue:"cc/claude-sonnet-5"},{id:"haiku",name:"Claude Haiku",alias:"haiku",envKey:"ANTHROPIC_DEFAULT_HAIKU_MODEL",defaultValue:"cc/claude-haiku-4-5-20251001"}]},openclaw:{id:"openclaw",name:"Open Claw",image:"/providers/openclaw.png",color:"#FF6B35",description:"Open Claw AI Assistant",configType:"custom"},codex:{id:"codex",name:"OpenAI Codex CLI / App",image:"/providers/codex.png",color:"#10A37F",description:"OpenAI Codex CLI",configType:"custom"},copilot:{id:"copilot",name:"GitHub Copilot",image:"/providers/copilot.png",color:"#1F6FEB",description:"GitHub Copilot in VS Code via JRouter",configType:"guide",docsUrl:"https://marketplace.visualstudio.com/items?itemName=hotrungnhan.9router-for-github-copilot",guideSteps:[{step:1,title:"Install Extension",desc:"In VS Code, open Extensions (Ctrl+Shift+X or Cmd+Shift+X), search for '9Router for Github Copilot' (extension name, unmodified) and click Install."},{step:2,title:"Configure Server",desc:"Press Cmd+Shift+P (or Ctrl+Shift+P), run '9Router: Configure Server' (extension command name), then enter your Server URL and API Key:",value:"{{baseUrl}}",copyable:!0},{step:3,title:"Select Model in Copilot Chat",desc:"Open Copilot Chat, click the model picker at the bottom → 'Manage Models...' → check the JRouter models to use."}]},opencode:{id:"opencode",name:"OpenCode",image:"/providers/opencode.png",color:"#E87040",description:"OpenCode AI Terminal Assistant",configType:"custom"},cowork:{id:"cowork",name:"Claude Cowork",image:"/providers/claude.png",color:"#D97757",description:"Claude Desktop Cowork (third-party inference)",configType:"custom"},hermes:{id:"hermes",name:"Hermes Agent",image:"/providers/hermes.png",color:"#8B5CF6",description:"Nous Research self-improving AI agent",configType:"custom",roles:[{id:"delegation",label:"Delegation (subagents)"},{id:"vision",label:"Vision"},{id:"compression",label:"Compression"},{id:"title_generation",label:"Title Generation"},{id:"approval",label:"Approval"},{id:"skills_hub",label:"Skills Hub"},{id:"mcp",label:"MCP"},{id:"review",label:"Review (/review subagent)"},{id:"memory_query_rewrite",label:"Memory Query Rewrite"},{id:"background_review",label:"Background Review"},{id:"curator",label:"Curator"},{id:"monitor",label:"Monitor"},{id:"tts_audio_tags",label:"TTS Audio Tags"},{id:"triage_specifier",label:"Triage Specifier"},{id:"kanban_decomposer",label:"Kanban Decomposer"},{id:"profile_describer",label:"Profile Describer"},{id:"goal_judge",label:"Goal Judge"}]},droid:{id:"droid",name:"Factory Droid",image:"/providers/droid.png",color:"#00D4FF",description:"Factory Droid AI Assistant",configType:"custom"},cursor:{id:"cursor",name:"Cursor",image:"/providers/cursor.png",color:"#000000",description:"Cursor AI Code Editor",configType:"guide",requiresExternalUrl:!0,notes:[{type:"warning",text:"Requires Cursor Pro account to use this feature."},{type:"cloudCheck",text:"Cursor routes requests through its own server, so local endpoint is not supported. Please enable Tunnel or Cloud Endpoint in Settings."}],guideSteps:[{step:1,title:"Open Settings",desc:"Go to Settings → Models"},{step:2,title:"Enable OpenAI API",desc:'Enable "OpenAI API key" option'},{step:3,title:"Base URL",value:"{{baseUrl}}",copyable:!0},{step:4,title:"API Key",type:"apiKeySelector"},{step:5,title:"Add Custom Model",desc:'Click "View All Model" → "Add Custom Model"'},{step:6,title:"Select Model",type:"modelSelector"}]},cline:{id:"cline",name:"Cline",image:"/providers/cline.png",color:"#5B9BD5",description:"Cline AI Coding Assistant",configType:"custom"},kilo:{id:"kilo",name:"Kilo Code",image:"/providers/kilocode.png",color:"#FF6B6B",description:"Kilo Code AI Assistant",configType:"custom"},roo:{id:"roo",name:"Roo",image:"/providers/roo.png",color:"#FF6B6B",description:"Roo AI Assistant",configType:"guide",guideSteps:[{step:1,title:"Open Settings",desc:"Go to Roo Settings panel"},{step:2,title:"Select Provider",desc:"Choose API Provider → Ollama"},{step:3,title:"Base URL",value:"{{baseUrl}}",copyable:!0},{step:4,title:"API Key",type:"apiKeySelector"},{step:5,title:"Select Model",type:"modelSelector"}]},continue:{id:"continue",name:"Continue",image:"/providers/continue.png",color:"#7C3AED",description:"Continue AI Assistant",configType:"guide",guideSteps:[{step:1,title:"Open Config",desc:"Open Continue configuration file"},{step:2,title:"API Key",type:"apiKeySelector"},{step:3,title:"Select Model",type:"modelSelector"},{step:4,title:"Add Model Config",desc:"Add the following configuration to your models array:"}],codeBlock:{language:"json",code:`{
90
90
  "apiBase": "{{baseUrl}}",
91
91
  "title": "{{model}}",
92
92
  "model": "{{model}}",
93
93
  "provider": "openai",
94
94
  "apiKey": "{{apiKey}}"
95
- }`}},amp:{id:"amp",name:"Amp CLI",image:"/providers/amp.png",color:"#F97316",description:"Sourcegraph Amp coding assistant CLI",docsUrl:"/docs?section=cli-tools&tool=amp",configType:"guide",defaultCommand:"amp",modelAliases:["g25p","g25f","cs45","g54"],notes:[{type:"info",text:"Use 9Router model aliases to keep Amp shorthand mappings stable across provider updates."},{type:"warning",text:"Suggested shorthand examples: g25p → gemini/gemini-2.5-pro, g25f → gemini/gemini-2.5-flash, cs45 → cc/claude-sonnet-4-5-20250929."}],guideSteps:[{step:1,title:"Install Amp",desc:"Install the Amp CLI using the package manager supported by your environment."},{step:2,title:"API Key",type:"apiKeySelector"},{step:3,title:"Base URL",value:"{{baseUrl}}",copyable:!0},{step:4,title:"Select Model",type:"modelSelector"},{step:5,title:"Add Shorthands",desc:"Map Amp shorthand names such as g25p or cs45 to 9Router aliases in your local config."}],codeBlock:{language:"bash",code:`export OPENAI_API_KEY="{{apiKey}}"
95
+ }`}},amp:{id:"amp",name:"Amp CLI",image:"/providers/amp.png",color:"#F97316",description:"Sourcegraph Amp coding assistant CLI",docsUrl:"/docs?section=cli-tools&tool=amp",configType:"guide",defaultCommand:"amp",modelAliases:["g25p","g25f","cs45","g54"],notes:[{type:"info",text:"Use JRouter model aliases to keep Amp shorthand mappings stable across provider updates."},{type:"warning",text:"Suggested shorthand examples: g25p → gemini/gemini-2.5-pro, g25f → gemini/gemini-2.5-flash, cs45 → cc/claude-sonnet-4-5-20250929."}],guideSteps:[{step:1,title:"Install Amp",desc:"Install the Amp CLI using the package manager supported by your environment."},{step:2,title:"API Key",type:"apiKeySelector"},{step:3,title:"Base URL",value:"{{baseUrl}}",copyable:!0},{step:4,title:"Select Model",type:"modelSelector"},{step:5,title:"Add Shorthands",desc:"Map Amp shorthand names such as g25p or cs45 to JRouter aliases in your local config."}],codeBlock:{language:"bash",code:`export OPENAI_API_KEY="{{apiKey}}"
96
96
  export OPENAI_BASE_URL="{{baseUrl}}"
97
97
  amp --model "{{model}}"
98
98
  # Example shorthand aliases you can map locally:
99
99
  # g25p -> gemini/gemini-2.5-pro
100
- # cs45 -> cc/claude-sonnet-4-5-20250929`}},qwen:{id:"qwen",name:"Qwen Code",image:"/providers/qwen.png",color:"#10B981",description:"Alibaba Qwen Code CLI — supports OpenAI, Anthropic & Gemini providers via 9Router",docsUrl:"https://qwenlm.github.io/qwen-code-docs/en/users/configuration/model-providers/",configType:"guide",defaultCommand:"qwen",notes:[{type:"info",text:"Qwen Code supports multiple provider types (openai, anthropic, gemini) via modelProviders in settings.json. 9Router works as an OpenAI-compatible endpoint."},{type:"info",text:"Any model available in 9Router can be used — not just Qwen models. Select from Qwen, Claude, Gemini, GPT, and more."},{type:"warning",text:"Config path: Linux/macOS ~/.qwen/settings.json • Windows %USERPROFILE%\\.qwen\\settings.json"},{type:"error",text:"Qwen OAuth free tier was discontinued on 2026-04-15. Use 9Router with alicode/openrouter/anthropic/gemini providers instead."}],modelAliases:["coder-model","qwen3-coder-plus","qwen3-coder-flash","vision-model","claude-sonnet-4-6","claude-opus-4-6-thinking","gemini-3-flash","gemini-3.1-pro-high"],defaultModels:[{id:"coder-model",name:"Coder Model (Qwen 3.6 Plus)",alias:"coder-model",envKey:"OPENAI_MODEL",defaultValue:"coder-model",isTopLevel:!0},{id:"qwen3-coder-plus",name:"Qwen 3 Coder Plus",alias:"qwen3-coder-plus",envKey:"OPENAI_MODEL",defaultValue:"qwen3-coder-plus"},{id:"qwen3-coder-flash",name:"Qwen 3 Coder Flash",alias:"qwen3-coder-flash",envKey:"OPENAI_MODEL",defaultValue:"qwen3-coder-flash"},{id:"vision-model",name:"Vision Model (Multimodal)",alias:"vision-model",envKey:"OPENAI_MODEL",defaultValue:"vision-model"},{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",alias:"claude-sonnet-4-6",envKey:"OPENAI_MODEL",defaultValue:"claude-sonnet-4-6"},{id:"claude-opus-4-6-thinking",name:"Claude Opus 4.6 Thinking",alias:"claude-opus-4-6-thinking",envKey:"OPENAI_MODEL",defaultValue:"claude-opus-4-6-thinking"},{id:"gemini-3.1-pro-high",name:"Gemini 3.1 Pro High",alias:"gemini-3.1-pro-high",envKey:"OPENAI_MODEL",defaultValue:"gemini-3.1-pro-high"},{id:"gemini-3-flash",name:"Gemini 3 Flash",alias:"gemini-3-flash",envKey:"OPENAI_MODEL",defaultValue:"gemini-3-flash"}],guideSteps:[{step:1,title:"Install Qwen Code",desc:"npm install -g @qwen-code/qwen-code"},{step:2,title:"API Key",type:"apiKeySelector"},{step:3,title:"Base URL",value:"{{baseUrl}}",copyable:!0},{step:4,title:"Select Model",type:"modelSelector"},{step:5,title:"Save Config",desc:"Copy the JSON below to your ~/.qwen/settings.json file."}],codeBlock:{language:"json",code:`{
100
+ # cs45 -> cc/claude-sonnet-4-5-20250929`}},qwen:{id:"qwen",name:"Qwen Code",image:"/providers/qwen.png",color:"#10B981",description:"Alibaba Qwen Code CLI — supports OpenAI, Anthropic & Gemini providers via JRouter",docsUrl:"https://qwenlm.github.io/qwen-code-docs/en/users/configuration/model-providers/",configType:"guide",defaultCommand:"qwen",notes:[{type:"info",text:"Qwen Code supports multiple provider types (openai, anthropic, gemini) via modelProviders in settings.json. JRouter works as an OpenAI-compatible endpoint."},{type:"info",text:"Any model available in JRouter can be used — not just Qwen models. Select from Qwen, Claude, Gemini, GPT, and more."},{type:"warning",text:"Config path: Linux/macOS ~/.qwen/settings.json • Windows %USERPROFILE%\\.qwen\\settings.json"},{type:"error",text:"Qwen OAuth free tier was discontinued on 2026-04-15. Use JRouter with alicode/openrouter/anthropic/gemini providers instead."}],modelAliases:["coder-model","qwen3-coder-plus","qwen3-coder-flash","vision-model","claude-sonnet-4-6","claude-opus-4-6-thinking","gemini-3-flash","gemini-3.1-pro-high"],defaultModels:[{id:"coder-model",name:"Coder Model (Qwen 3.6 Plus)",alias:"coder-model",envKey:"OPENAI_MODEL",defaultValue:"coder-model",isTopLevel:!0},{id:"qwen3-coder-plus",name:"Qwen 3 Coder Plus",alias:"qwen3-coder-plus",envKey:"OPENAI_MODEL",defaultValue:"qwen3-coder-plus"},{id:"qwen3-coder-flash",name:"Qwen 3 Coder Flash",alias:"qwen3-coder-flash",envKey:"OPENAI_MODEL",defaultValue:"qwen3-coder-flash"},{id:"vision-model",name:"Vision Model (Multimodal)",alias:"vision-model",envKey:"OPENAI_MODEL",defaultValue:"vision-model"},{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",alias:"claude-sonnet-4-6",envKey:"OPENAI_MODEL",defaultValue:"claude-sonnet-4-6"},{id:"claude-opus-4-6-thinking",name:"Claude Opus 4.6 Thinking",alias:"claude-opus-4-6-thinking",envKey:"OPENAI_MODEL",defaultValue:"claude-opus-4-6-thinking"},{id:"gemini-3.1-pro-high",name:"Gemini 3.1 Pro High",alias:"gemini-3.1-pro-high",envKey:"OPENAI_MODEL",defaultValue:"gemini-3.1-pro-high"},{id:"gemini-3-flash",name:"Gemini 3 Flash",alias:"gemini-3-flash",envKey:"OPENAI_MODEL",defaultValue:"gemini-3-flash"}],guideSteps:[{step:1,title:"Install Qwen Code",desc:"npm install -g @qwen-code/qwen-code"},{step:2,title:"API Key",type:"apiKeySelector"},{step:3,title:"Base URL",value:"{{baseUrl}}",copyable:!0},{step:4,title:"Select Model",type:"modelSelector"},{step:5,title:"Save Config",desc:"Copy the JSON below to your ~/.qwen/settings.json file."}],codeBlock:{language:"json",code:`{
101
101
  "security": {
102
102
  "auth": {
103
103
  "selectedType": "openai",
@@ -108,11 +108,11 @@ amp --model "{{model}}"
108
108
  "model": {
109
109
  "name": "{{model}}"
110
110
  }
111
- }`}},"deepseek-tui":{id:"deepseek-tui",name:"DeepSeek TUI",image:"/providers/deepseek-tui.png",color:"#4D6BFE",description:"DeepSeek Terminal Coding Agent (Rust TUI)",docsUrl:"https://github.com/DeepSeek-TUI/DeepSeek-TUI",configType:"custom",defaultCommand:"deepseek",modelAliases:["deepseek-v4-pro","deepseek-v4-flash","deepseek-chat","deepseek-reasoner"],defaultModels:[{id:"deepseek-v4-pro",name:"DeepSeek V4 Pro",alias:"deepseek-v4-pro"},{id:"deepseek-v4-flash",name:"DeepSeek V4 Flash",alias:"deepseek-v4-flash"},{id:"deepseek-chat",name:"DeepSeek V3 Chat",alias:"deepseek-chat"}],notes:[{type:"info",text:"DeepSeek TUI uses ~/.deepseek/config.toml for configuration. 9Router will update the provider to 'openai' mode with your base_url, api_key, and model."},{type:"warning",text:"Config path: Linux/macOS ~/.deepseek/config.toml • Windows %USERPROFILE%\\.deepseek\\config.toml"}]},jcode:{id:"jcode",name:"jcode",image:"/providers/jcode.png",color:"#FF6B35",description:"High-performance Rust-based coding agent harness",configType:"custom",docsUrl:"https://github.com/1jehuang/jcode",notes:[{type:"info",text:"jcode is a Rust-based coding agent with semantic memory, multi-agent swarms, and extreme performance (27.8 MB RAM, 14ms boot)."},{type:"info",text:"Configure 9router as an OpenAI-compatible provider to route all jcode requests through 9router's optimization layer."},{type:"warning",text:"Requires jcode installed. Install via: curl -fsSL https://raw.githubusercontent.com/1jehuang/jcode/master/scripts/install.sh | bash"}],defaultModels:[{id:"claude-opus-5",name:"Claude Opus 5",alias:"opus",defaultValue:"cc/claude-opus-5"},{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",alias:"sonnet",defaultValue:"cc/claude-sonnet-4-6"},{id:"gpt-6.1-sol",name:"GPT 6.1 Sol",alias:"gpt6",defaultValue:"cx/gpt-6.1-sol"},{id:"gemini-3.1-pro",name:"Gemini 3.1 Pro",alias:"gemini",defaultValue:"gemini/gemini-3.1-pro"}]},"grok-build":{id:"grok-build",name:"Grok Build",image:"/providers/grok-cli.png",color:"#1DA1F2",description:"xAI Grok Build TUI coding agent",configType:"custom",docsUrl:"https://x.ai/cli",defaultCommand:"grok",notes:[{type:"info",text:"Grok Build uses ~/.grok/config.toml. 9Router writes a [model.9router] custom model and sets it as the default."},{type:"info",text:"After Apply, run grok (or /model 9router) to use the routed model. Switch back anytime with /model grok-build."},{type:"warning",text:"Config path: Linux/macOS ~/.grok/config.toml • Windows %USERPROFILE%\\.grok\\config.toml"}]},devin:{id:"devin",name:"Devin CLI",image:"/providers/devin-cli.png",color:"#6366F1",description:"Cognition Devin CLI — local binary called by the Devin CLI provider via ACP/stdio",configType:"guide",installUrl:"https://cli.devin.ai",notes:[{type:"info",text:"This is a local dependency, not a routed CLI. The Devin CLI provider spawns `devin acp --agent-type summarizer` and relays its output."},{type:"warning",text:"Install the Devin CLI and run `devin auth login` — without it, the provider returns a spawn error on first request."}],guideSteps:[{step:1,title:"Install Devin CLI",desc:"Install via the official installer at cli.devin.ai.",docsUrl:"https://cli.devin.ai"},{step:2,title:"Authenticate",desc:"Log in once so the binary stores its own credentials."},{step:3,title:"Use the provider",desc:"Pick any Devin CLI model under the Providers tab — no API key field needed."}],codeBlock:{language:"bash",code:`# Install Devin CLI (see https://cli.devin.ai for options)
111
+ }`}},"deepseek-tui":{id:"deepseek-tui",name:"DeepSeek TUI",image:"/providers/deepseek-tui.png",color:"#4D6BFE",description:"DeepSeek Terminal Coding Agent (Rust TUI)",docsUrl:"https://github.com/DeepSeek-TUI/DeepSeek-TUI",configType:"custom",defaultCommand:"deepseek",modelAliases:["deepseek-v4-pro","deepseek-v4-flash","deepseek-chat","deepseek-reasoner"],defaultModels:[{id:"deepseek-v4-pro",name:"DeepSeek V4 Pro",alias:"deepseek-v4-pro"},{id:"deepseek-v4-flash",name:"DeepSeek V4 Flash",alias:"deepseek-v4-flash"},{id:"deepseek-chat",name:"DeepSeek V3 Chat",alias:"deepseek-chat"}],notes:[{type:"info",text:"DeepSeek TUI uses ~/.deepseek/config.toml for configuration. JRouter will update the provider to 'openai' mode with your base_url, api_key, and model."},{type:"warning",text:"Config path: Linux/macOS ~/.deepseek/config.toml • Windows %USERPROFILE%\\.deepseek\\config.toml"}]},jcode:{id:"jcode",name:"jcode",image:"/providers/jcode.png",color:"#FF6B35",description:"High-performance Rust-based coding agent harness",configType:"custom",docsUrl:"https://github.com/1jehuang/jcode",notes:[{type:"info",text:"jcode is a Rust-based coding agent with semantic memory, multi-agent swarms, and extreme performance (27.8 MB RAM, 14ms boot)."},{type:"info",text:"Configure JRouter as an OpenAI-compatible provider to route all jcode requests through JRouter's optimization layer."},{type:"warning",text:"Requires jcode installed. Install via: curl -fsSL https://raw.githubusercontent.com/1jehuang/jcode/master/scripts/install.sh | bash"}],defaultModels:[{id:"claude-opus-5",name:"Claude Opus 5",alias:"opus",defaultValue:"cc/claude-opus-5"},{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",alias:"sonnet",defaultValue:"cc/claude-sonnet-4-6"},{id:"gpt-6.1-sol",name:"GPT 6.1 Sol",alias:"gpt6",defaultValue:"cx/gpt-6.1-sol"},{id:"gemini-3.1-pro",name:"Gemini 3.1 Pro",alias:"gemini",defaultValue:"gemini/gemini-3.1-pro"}]},"grok-build":{id:"grok-build",name:"Grok Build",image:"/providers/grok-cli.png",color:"#1DA1F2",description:"xAI Grok Build TUI coding agent",configType:"custom",docsUrl:"https://x.ai/cli",defaultCommand:"grok",notes:[{type:"info",text:"Grok Build uses ~/.grok/config.toml. JRouter writes a [model.jrouter] custom model and sets it as the default."},{type:"info",text:"After Apply, run grok (or /model jrouter) to use the routed model. Switch back anytime with /model grok-build."},{type:"warning",text:"Config path: Linux/macOS ~/.grok/config.toml • Windows %USERPROFILE%\\.grok\\config.toml"}]},devin:{id:"devin",name:"Devin CLI",image:"/providers/devin-cli.png",color:"#6366F1",description:"Cognition Devin CLI — local binary called by the Devin CLI provider via ACP/stdio",configType:"guide",installUrl:"https://cli.devin.ai",notes:[{type:"info",text:"This is a local dependency, not a routed CLI. The Devin CLI provider spawns `devin acp --agent-type summarizer` and relays its output."},{type:"warning",text:"Install the Devin CLI and run `devin auth login` — without it, the provider returns a spawn error on first request."}],guideSteps:[{step:1,title:"Install Devin CLI",desc:"Install via the official installer at cli.devin.ai.",docsUrl:"https://cli.devin.ai"},{step:2,title:"Authenticate",desc:"Log in once so the binary stores its own credentials."},{step:3,title:"Use the provider",desc:"Pick any Devin CLI model under the Providers tab — no API key field needed."}],codeBlock:{language:"bash",code:`# Install Devin CLI (see https://cli.devin.ai for options)
112
112
  devin auth login
113
113
 
114
114
  # Verify detection (optional)
115
- devin --version`}},opendesign:{id:"opendesign",name:"OpenDesign",image:"/providers/opendesign.png",color:"#7C3AED",description:"OpenDesign — claude.ai/design open-sourced! Agent-native design skills pack",docsUrl:"https://github.com/manalkaff/opendesign",configType:"guide",notes:[{type:"info",text:"OpenDesign ships as a plugin/skills pack installed into Claude Code, Cursor, OpenAI Codex, Gemini CLI, or OpenCode. It inherits the host agent's model config, so once your host points at 9Router, /opendesign design sessions route through 9Router automatically — no extra env vars needed."},{type:"info",text:"Invoke with /opendesign <brief>. Covers decks, wireframes, interactive prototypes, design-system extraction, and brand systems, with a verifier subagent that checks output against the brief."}],guideSteps:[{step:1,title:"Install the plugin",desc:"Pick your host below and run the matching install command from the matrix."},{step:2,title:"No config needed",desc:"OpenDesign runs inside your host agent and uses its model config. If the host already routes through 9Router, /opendesign traffic does too."},{step:3,title:"Start designing",desc:"Invoke OpenDesign from your agent:",value:"/opendesign make a pitch deck for a seed-stage AI company, 10 slides",copyable:!0}],codeBlock:{language:"bash",code:`# Claude Code
115
+ devin --version`}},opendesign:{id:"opendesign",name:"OpenDesign",image:"/providers/opendesign.png",color:"#7C3AED",description:"OpenDesign — claude.ai/design open-sourced! Agent-native design skills pack",docsUrl:"https://github.com/manalkaff/opendesign",configType:"guide",notes:[{type:"info",text:"OpenDesign ships as a plugin/skills pack installed into Claude Code, Cursor, OpenAI Codex, Gemini CLI, or OpenCode. It inherits the host agent's model config, so once your host points at JRouter, /opendesign design sessions route through JRouter automatically — no extra env vars needed."},{type:"info",text:"Invoke with /opendesign <brief>. Covers decks, wireframes, interactive prototypes, design-system extraction, and brand systems, with a verifier subagent that checks output against the brief."}],guideSteps:[{step:1,title:"Install the plugin",desc:"Pick your host below and run the matching install command from the matrix."},{step:2,title:"No config needed",desc:"OpenDesign runs inside your host agent and uses its model config. If the host already routes through JRouter, /opendesign traffic does too."},{step:3,title:"Start designing",desc:"Invoke OpenDesign from your agent:",value:"/opendesign make a pitch deck for a seed-stage AI company, 10 slides",copyable:!0}],codeBlock:{language:"bash",code:`# Claude Code
116
116
  /plugin marketplace add manalkaff/opendesign
117
117
  /plugin install opendesign@opendesign
118
118
 
@@ -129,4 +129,4 @@ devin --version`}},opendesign:{id:"opendesign",name:"OpenDesign",image:"/provide
129
129
  gemini extensions install https://github.com/manalkaff/opendesign
130
130
 
131
131
  # OpenCode
132
- # 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."}]}}}};
132
+ # 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. JRouter is configured under providers.jrouter 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. JRouter 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. JRouter 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. JRouter 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. JRouter configures the [openai] provider with your base_url, api_key, and model."}]}}}};