@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
@@ -0,0 +1,132 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[761],{3534:(e,t,s)=>{"use strict";s.d(t,{dM:()=>l,wn:()=>a});let a={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"}]}},l={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:`{
2
+ "apiBase": "{{baseUrl}}",
3
+ "title": "{{model}}",
4
+ "model": "{{model}}",
5
+ "provider": "openai",
6
+ "apiKey": "{{apiKey}}"
7
+ }`}},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}}"
8
+ export OPENAI_BASE_URL="{{baseUrl}}"
9
+ amp --model "{{model}}"
10
+ # Example shorthand aliases you can map locally:
11
+ # g25p -> gemini/gemini-2.5-pro
12
+ # 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:`{
13
+ "security": {
14
+ "auth": {
15
+ "selectedType": "openai",
16
+ "apiKey": "{{apiKey}}",
17
+ "baseUrl": "{{baseUrl}}"
18
+ }
19
+ },
20
+ "model": {
21
+ "name": "{{model}}"
22
+ }
23
+ }`}},"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)
24
+ devin auth login
25
+
26
+ # Verify detection (optional)
27
+ 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
28
+ /plugin marketplace add manalkaff/opendesign
29
+ /plugin install opendesign@opendesign
30
+
31
+ # Cursor
32
+ /add-plugin opendesign
33
+
34
+ # OpenAI Codex CLI
35
+ /plugins # search "opendesign" -> Install Plugin
36
+
37
+ # OpenAI Codex App
38
+ # Plugins sidebar -> OpenDesign (Design section) -> +
39
+
40
+ # Gemini CLI
41
+ gemini extensions install https://github.com/manalkaff/opendesign
42
+
43
+ # OpenCode
44
+ # Fetch and follow .opencode/INSTALL.md from the repo`}},pi:{id:"pi",name:"Pi (pi-coding-agent)",image:"/providers/pi.svg",color:"#6366F1",description:"Pi coding agent — minimal, extensible agent harness (pi.dev)",configType:"custom",docsUrl:"https://pi.dev",notes:[{type:"info",text:"Pi uses ~/.pi/agent/models.json. 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."}]}}},10761:(e,t,s)=>{"use strict";s.d(t,{Tk:()=>L,aG:()=>et,Ah:()=>K,Q6:()=>ee,lF:()=>el,a7:()=>Y,ZM:()=>F,WE:()=>eu,E_:()=>em,RF:()=>W,mW:()=>er,c9:()=>es,gY:()=>ev,tA:()=>eh,kn:()=>ef,yZ:()=>J,qO:()=>Q});var a=s(95155),l=s(96439),r=s(66119),i=s(30535),n=s.n(i),o=s(12115),d=s(35497),c=s(5772),m=s(90620);function x({storageKey:e,changeEvent:t,itemField:s,normalize:a=e=>e,defaultName:l=e=>e}){let r=()=>{try{let t=JSON.parse(window.localStorage.getItem(e)||"[]");if(!Array.isArray(t))return[];return t.filter(e=>e?.name&&e?.[s])}catch{return[]}},i=s=>{window.localStorage.setItem(e,JSON.stringify(s)),window.dispatchEvent(new CustomEvent(t))};return{read:r,subscribe:e=>(window.addEventListener(t,e),()=>window.removeEventListener(t,e)),upsert:(e,t)=>{let n=a(e);if(!n)return null;let o=r(),d=o.find(e=>a(e[s])===n);if(d&&!t)return d.name;let c=(t||l(n)).trim();return c?(i([...o.filter(e=>e.name!==c&&a(e[s])!==n),{name:c,[s]:n}].sort((e,t)=>e.name.localeCompare(t.name))),c):null},remove:e=>i(r().filter(t=>t.name!==e))}}let u=e=>(e||"").replace(/\/+$/,""),p=x({storageKey:"jrouter.cliToolEndpointPresets",changeEvent:"jrouter:endpoint-presets-changed",itemField:"baseUrl",normalize:u,defaultName:e=>{try{return new URL(e).host}catch{return e}}}),h=x({storageKey:"jrouter.cliToolApiKeyPresets",changeEvent:"jrouter:api-key-presets-changed",itemField:"key"}),g=p.read,f=p.subscribe,j=p.upsert,y=p.remove,v=h.read,b=h.subscribe,N=h.upsert,w=h.remove;function _(e,{tunnelPublicUrl:t,tailscaleUrl:s,cloudUrl:a}={}){let l=u(e);return!l||[`http://127.0.0.1:${m.h0.appPort}`,t,s,a].filter(Boolean).flatMap(e=>[u(e),`${u(e)}/v1`]).includes(l)?null:j(l)}let k="__custom__",C="__save__",S=e=>{let t=(e||"").replace(/\/+$/,"");return t?/\/v1$/.test(t)?t:`${t}/v1`:""};function E({value:e,onChange:t,requiresExternalUrl:s=!1,tunnelEnabled:r=!1,tunnelPublicUrl:i="",tailscaleEnabled:n=!1,tailscaleUrl:d="",cloudEnabled:c=!1,cloudUrl:x="",withV1:p=!0,currentUrl:h=""}){let[v,b]=(0,o.useState)([]),[N,w]=(0,o.useState)(!1),[_,$]=(0,o.useState)(""),[A,O]=(0,o.useState)(""),M=(0,o.useRef)(!1),P=(0,o.useRef)(""),I=(0,o.useRef)("");(0,o.useEffect)(()=>{let e=()=>{let e=g();b(e),$(t=>{if(t!==k)return t;let s=u(I.current);if(!s)return t;let a=e.find(e=>{let t=u(e.baseUrl);return t===s||t===S(s)});return a?`saved:${a.name}`:t})};return e(),w(!0),f(e)},[]);let U=(0,o.useMemo)(()=>(({requiresExternalUrl:e,tunnelEnabled:t,tunnelPublicUrl:s,tailscaleEnabled:a,tailscaleUrl:l,cloudEnabled:r,cloudUrl:i,savedPresets:n,withV1:o})=>{let d=[],c=e=>o?S(e):(e||"").replace(/\/+$/,"");if(!e){let e=c(`http://127.0.0.1:${m.h0.appPort}`);d.push({value:"local",label:e,url:e})}if(t&&s){let e=c(s);d.push({value:"tunnel",label:e,url:e})}if(a&&l){let e=c(l);d.push({value:"tailscale",label:e,url:e})}if(r&&i){let e=c(i);d.push({value:"cloud",label:e,url:e})}return n.forEach(e=>{d.push({value:`saved:${e.name}`,label:e.baseUrl,url:e.baseUrl,saved:!0})}),d.push({value:k,label:"Custom URL...",url:""}),d})({requiresExternalUrl:s,tunnelEnabled:r,tunnelPublicUrl:i,tailscaleEnabled:n,tailscaleUrl:d,cloudEnabled:c,cloudUrl:x,savedPresets:v,withV1:p}),[s,r,i,n,d,c,x,v,p]);(0,o.useEffect)(()=>{if(!N||0===U.length)return;let e=e=>p?S(e):u(e),s=e(h);if(M.current&&P.current===s)return;M.current=!0,P.current=s;let a=s?U.find(t=>t.value!==k&&e(t.url)===s):null;if(a)O(""),I.current="",$(a.value),t(a.url);else if(s)O(s),I.current=s,$(k),t(s);else{let e=U.find(e=>e.value!==k);if(!e)return;$(e.value),t(e.url)}},[N,U,t,h,p]);let L=_.startsWith("saved:"),R=_===k,T=R&&(A||"").trim().length>0;return(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)("select",{"aria-label":"Endpoint",value:_,onChange:s=>{let a=s.target.value;if(a===C){let t=(e||"").trim();if(!t)return;let s=t;try{s=new URL(t).host}catch{}let a=window.prompt("Save endpoint as:",s),l=a?.trim()?j(t,a.trim()):null;l&&$(`saved:${l}`);return}if($(a),a===k){O(""),t("");return}let l=U.find(e=>e.value===a);l&&t(l.url)},className:"flex-1 min-w-0 px-2 py-2 bg-surface rounded text-xs border border-border focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5",children:[U.map(e=>(0,a.jsx)("option",{value:e.value,children:e.label},e.value)),T&&(0,a.jsx)("option",{value:C,children:"+ Save current as..."})]}),L&&(0,a.jsx)("button",{type:"button",onClick:()=>{if(!_.startsWith("saved:"))return;y(_.slice(6)),O("");let e=U.find(e=>e.value!==k&&e.value!==_);e?($(e.value),t(e.url)):($(k),t(""))},className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors shrink-0",title:"Delete saved endpoint",children:(0,a.jsx)(l.default,{className:"text-[14px]",children:"delete"})})]}),R&&(0,a.jsx)("input",{"aria-label":"Custom endpoint URL",type:"text",value:A,onChange:e=>{let s=e.target.value;I.current=s,O(s),t(s)},placeholder:p?"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 $="__custom__",A="__save_key__";function O({value:e,onChange:t,apiKeys:s=[],cloudEnabled:r=!1,className:i=""}){let[n,d]=(0,o.useState)([]),[c,m]=(0,o.useState)(!1),[x,u]=(0,o.useState)("");(0,o.useEffect)(()=>{let e=()=>d(v());return e(),b(e)},[]);let p=(0,o.useMemo)(()=>[...s.map(e=>({value:e.key,label:e.key})),...n.map(e=>({value:`saved:${e.name}`,label:e.key,url:e.key,saved:!0})),{value:$,label:"Custom...",url:""}],[s,n]),h=e?p.find(t=>t.value===e||t.url===e):null,g=h?h.value:c||e?$:p[0]?.value??$,f=c?x:e||"",j="string"==typeof g&&g.startsWith("saved:"),y=g===$,_=y&&(e||"").trim().length>0&&!s.some(t=>t.key===e);return 0!==s.length||0!==n.length||c||e?(0,a.jsxs)("div",{className:`flex flex-col gap-1.5 ${i}`,children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)("select",{"aria-label":"API key",value:g,onChange:s=>{let a=s.target.value;if(a===A)return void N((e||"").trim());if(a===$){m(!0),u(""),t("");return}m(!1),u("");let l=p.find(e=>e.value===a);l&&t(l.url??l.value)},className:"flex-1 min-w-0 px-2 py-2 bg-surface rounded text-xs border border-border focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5",children:[p.map(e=>(0,a.jsx)("option",{value:e.value,children:e.label},e.value)),_&&(0,a.jsx)("option",{value:A,children:"+ Save current as..."})]}),j&&(0,a.jsx)("button",{type:"button",onClick:()=>{if(!j)return;w(g.slice(6)),m(!1),u("");let e=p.find(e=>e.value!==$&&e.value!==g);t(e?e.url??e.value:"")},className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors shrink-0",title:"Delete saved key",children:(0,a.jsx)(l.default,{className:"text-[14px]",children:"delete"})})]}),y&&(0,a.jsx)("input",{"aria-label":"Custom API key",type:"text",value:f,onChange:e=>{let s=e.target.value;m(!0),u(s),t(s)},placeholder:"sk-...",className:"w-full min-w-0 px-2 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"})]}):(0,a.jsx)("span",{className:`min-w-0 rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5 ${i}`,children:r?"No API keys - Create one in Keys page":"sk_jrouter (default)"})}let M=e=>(e||"").replace(/\/+$/,"");function P(e,t={}){if(!e)return!1;let s=M(e),{tunnelPublicUrl:a,tailscaleUrl:l,cloudUrl:r}=t;return!!(/localhost|127\.0\.0\.1|0\.0\.0\.0/.test(s)||a&&s.startsWith(M(a))||l&&s.startsWith(M(l))||r&&s.startsWith(M(r)))}let I=/\[1m\]$/i,U=[{label:"Default",value:""},{label:"200K",value:"198000"},{label:"300K",value:"298000"},{label:"500K",value:"498000"},{label:"700K",value:"698000"}];function L({tool:e,isExpanded:t,onToggle:s,activeProviders:i,modelMappings:m,onModelMappingChange:x,baseUrl:u,hasActiveProviders:p,apiKeys:h,cloudEnabled:g,initialStatus:f,tunnelEnabled:j,tunnelPublicUrl:y,tailscaleEnabled:v,tailscaleUrl:b}){let N,w,k,[C,S]=(0,o.useState)(f||null),[$,A]=(0,o.useState)(!1),[M,R]=(0,o.useState)(!1),[T,D]=(0,o.useState)(!1),[z,K]=(0,o.useState)(null),[F,J]=(0,o.useState)(!1),[B,H]=(0,o.useState)(!1),[q,W]=(0,o.useState)(null),[G,V]=(0,o.useState)(""),[Y,Q]=(0,o.useState)({}),[Z,X]=(0,o.useState)(!1),[ee,et]=(0,o.useState)(""),[es,ea]=(0,o.useState)(!1),[el,er]=(0,o.useState)(!1),[ei,en]=(0,o.useState)(""),[eo,ed]=(0,o.useState)(!1),ec=(0,o.useRef)(!1),em=C?.settings?.env?.ANTHROPIC_BASE_URL||"",ex=(()=>{if(!C?.installed)return null;let e=C.settings?.env?.ANTHROPIC_BASE_URL;return e?P(e,{tunnelPublicUrl:y,tailscaleUrl:b,cloudUrl:g?"https://9router.com":null})?"configured":"other":"not_configured"})();(0,o.useEffect)(()=>{h?.length>0&&!G&&V(h[0].key)},[h,G]),(0,o.useEffect)(()=>{f&&(S(f),er(!!f.exaMcpEnabled))},[f]),(0,o.useEffect)(()=>{en(C?.settings?.env?.CLAUDE_CODE_AUTO_COMPACT_WINDOW||"")},[C?.settings?.env?.CLAUDE_CODE_AUTO_COMPACT_WINDOW]),(0,o.useEffect)(()=>{let t=C?.settings?.env;t&&ed(e.defaultModels.some(e=>t[e.envKey]?.endsWith("[1m]")))},[C?.settings?.env,e.defaultModels]),(0,o.useEffect)(()=>{t&&(C||eh(),ep())},[t]),(0,o.useEffect)(()=>{fetch("/api/settings").then(e=>e.json()).then(e=>{ea(!!e.ccFilterNaming)}).catch(()=>{})},[]);let eu=async e=>{let t=e.target.checked;ea(t),await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({ccFilterNaming:t})}).catch(()=>{})},ep=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&Q(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}};(0,o.useEffect)(()=>{if(C?.installed&&!ec.current){ec.current=!0;let t=C.settings?.env||{};e.defaultModels.forEach(e=>{if(e.envKey){let s=t[e.envKey]||e.defaultValue||"";s&&x(e.alias,s)}});let s=t.ANTHROPIC_AUTH_TOKEN;s&&V(s)}},[C,h,e.defaultModels,x]);let eh=async()=>{A(!0);try{let e=await fetch("/api/cli-tools/claude-settings"),t=await e.json();S(t),er(!!t.exaMcpEnabled)}catch(e){S({installed:!1,error:e.message})}finally{A(!1)}},eg=()=>{let e=ee||u;return e.endsWith("/v1")?e:`${e}/v1`},ef=async()=>{R(!0),K(null);try{let t={ANTHROPIC_BASE_URL:eg()},s=G?.trim()||(h?.length>0?h[0].key:null)||(g?null:"sk_jrouter");s&&(t.ANTHROPIC_AUTH_TOKEN=s),e.defaultModels.forEach(e=>{let s=m[e.alias];s&&e.envKey&&(t[e.envKey]=s)}),ei&&(t.CLAUDE_CODE_AUTO_COMPACT_WINDOW=ei);let a=await fetch("/api/cli-tools/claude-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({env:t,exaMcpEnabled:el,autoCompactWindow:ei})}),l=await a.json();a.ok?(_(eg(),{tunnelPublicUrl:y,tailscaleUrl:b}),K({type:"success",text:"Settings applied successfully!"}),S(e=>({...e,hasBackup:!0,settings:{...e?.settings,env:t},exaMcpEnabled:el}))):K({type:"error",text:l.error||"Failed to apply settings"})}catch(e){K({type:"error",text:e.message})}finally{R(!1)}},ej=async()=>{D(!0),K(null);try{let t=await fetch("/api/cli-tools/claude-settings",{method:"DELETE"}),s=await t.json();t.ok?(K({type:"success",text:"Settings reset successfully!"}),e.defaultModels.forEach(e=>x(e.alias,e.defaultValue||"")),V(""),er(!1),en(""),ed(!1)):K({type:"error",text:s.error||"Failed to reset settings"})}catch(e){K({type:"error",text:e.message})}finally{D(!1)}};return(0,a.jsxs)(d.Zp,{padding:"none",className:n().panel,children:[(0,a.jsxs)("div",{className:n().panelHeader,onClick:s,children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(c.default,{src:"/providers/claude.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===ex&&(0,a.jsx)(r.A,{variant:"success",className:n().status,children:"Connected"}),"not_configured"===ex&&(0,a.jsx)(r.A,{variant:"warning",className:n().status,children:"Not configured"}),"other"===ex&&(0,a.jsx)(r.A,{variant:"default",dot:!1,className:n().status,children:"Other"})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)(l.default,{className:`text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:n().body,children:[$&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,a.jsx)(l.default,{className:"animate-spin",children:"progress_activity"}),(0,a.jsx)("span",{children:"Checking Claude CLI..."})]}),!$&&C&&!C.installed&&(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:`flex flex-col gap-3 p-4 border ${n().notice} ${n().warning}`,children:[(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)(l.default,{className:"text-[var(--warn)]",children:"warning"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"font-medium text-[var(--warn)]",children:"Claude CLI not detected locally"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if JRouter is deployed on a remote server."})]})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2 sm:pl-9",children:[(0,a.jsxs)(d.$n,{variant:"secondary",size:"sm",onClick:()=>X(!0),children:[(0,a.jsx)(l.default,{className:"text-[18px] mr-1",children:"content_copy"}),"Manual Config"]}),(0,a.jsxs)(d.$n,{variant:"outline",size:"sm",onClick:()=>J(!F),children:[(0,a.jsx)(l.default,{className:"text-[18px] mr-1",children:F?"expand_less":"help"}),F?"Hide":"How to Install"]})]})]}),F&&(0,a.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,a.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,a.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-text-muted mb-1",children:"macOS / Linux / Windows:"}),(0,a.jsx)("code",{className:"block px-3 py-2 bg-black/5 dark:bg-white/5 rounded font-mono text-xs",children:"npm install -g @anthropic-ai/claude-code"})]}),(0,a.jsxs)("p",{className:"text-text-muted",children:["After installation, run ",(0,a.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"claude"})," to verify."]})]})]})]}),!$&&C?.installed&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"Select Endpoint"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(E,{value:ee||((N=ee||u).endsWith("/v1")?N:`${N}/v1`),onChange:et,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:j,tunnelPublicUrl:y,tailscaleEnabled:v,tailscaleUrl:b,currentUrl:em})]}),C?.settings?.env?.ANTHROPIC_BASE_URL&&(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"Current"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)("span",{className:"min-w-0 truncate rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5",children:C.settings.env.ANTHROPIC_BASE_URL})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"API Key"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(O,{value:G,onChange:V,apiKeys:h,cloudEnabled:g})]}),e.defaultModels.map(e=>(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:e.name}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,a.jsxs)("div",{className:"relative flex-1 min-w-0",children:[(0,a.jsx)("input",{type:"text",value:m[e.alias]||"",onChange:t=>x(e.alias,t.target.value),placeholder:"provider/model-id",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),m[e.alias]&&(0,a.jsx)("button",{onClick:()=>x(e.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,a.jsx)(l.default,{className:"text-[14px]",children:"close"})})]}),(0,a.jsx)("button",{onClick:()=>{W(e.alias),H(!0)},disabled:!p,className:`rounded border px-2.5 py-2 text-xs transition-colors sm:py-1.5 whitespace-nowrap shrink-0 ${p?"bg-surface border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${n().selectButton}`,children:"Select"})]})]},e.alias)),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"Auto-compact"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)("select",{value:ei,onChange:e=>en(e.target.value),className:"w-full min-w-0 px-2 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5",children:U.map(e=>(0,a.jsx)("option",{value:e.value,children:e.label},e.label))})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-1.5 sm:grid sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"1M context"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("label",{className:"flex items-center gap-1.5 cursor-pointer select-none",children:[(0,a.jsx)("input",{type:"checkbox",checked:eo,onChange:t=>{var s;ed(s=t.target.checked),e.defaultModels.forEach(e=>{let t=m[e.alias];t&&x(e.alias,((e,t)=>{let{model:s}=function(e){if("string"!=typeof e)return{model:e,contextMarker:null};let t=e.trim(),s=t.match(I);return s?{model:t.slice(0,-s[0].length),contextMarker:s[0].slice(1,-1).toLowerCase()}:{model:e,contextMarker:null}}(e);return t?`${s}[1m]`:s})(t,s))})},className:"w-3.5 h-3.5 accent-primary cursor-pointer shrink-0"}),(0,a.jsx)("span",{className:"text-xs text-text-muted",children:"Append [1m] to the model name"}),(0,a.jsx)(d.m_,{text:"Claude Code otherwise assumes a 200K window, which clamps the auto-compact window above. Applied to every mapped model — only enable it for models that really accept 1M.",children:(0,a.jsx)(l.default,{className:"text-text-muted text-[14px] cursor-help",children:"info"})})]})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-1.5 sm:grid sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"Filter naming"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("label",{className:"flex items-center gap-1.5 cursor-pointer select-none",children:[(0,a.jsx)("input",{type:"checkbox",checked:es,onChange:eu,className:"w-3.5 h-3.5 accent-primary cursor-pointer shrink-0"}),(0,a.jsx)("span",{className:"text-xs text-text-muted",children:"Filter naming requests"}),(0,a.jsx)(d.m_,{text:"Intercepts Claude Code's topic-naming requests and returns a fake response locally, saving API tokens.",children:(0,a.jsx)(l.default,{className:"text-text-muted text-[14px] cursor-help",children:"info"})})]})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-1.5 sm:grid sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"Web Search"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("label",{className:"flex items-center gap-1.5 cursor-pointer select-none",children:[(0,a.jsx)("input",{type:"checkbox",checked:el,onChange:e=>er(e.target.checked),className:"w-3.5 h-3.5 accent-primary cursor-pointer shrink-0"}),(0,a.jsx)("span",{className:"text-xs text-text-muted",children:"Exa MCP"}),(0,a.jsx)(d.m_,{text:"Injects Exa MCP into ~/.claude.json so non-Claude models gain web search. Restart Claude Code after Apply.",children:(0,a.jsx)(l.default,{className:"text-text-muted text-[14px] cursor-help",children:"info"})})]})]})]}),z&&(0,a.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===z.type?n().positive:n().danger}`,children:[(0,a.jsx)(l.default,{className:"text-[14px]",children:"success"===z.type?"check_circle":"error"}),(0,a.jsx)("span",{children:z.text})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,a.jsxs)(d.$n,{variant:"primary",size:"sm",onClick:ef,disabled:!p,loading:M,children:[(0,a.jsx)(l.default,{className:"text-[14px] mr-1",children:"save"}),"Apply"]}),(0,a.jsxs)(d.$n,{variant:"outline",size:"sm",onClick:ej,disabled:!C?.hasJRouter,loading:T,children:[(0,a.jsx)(l.default,{className:"text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,a.jsxs)(d.$n,{variant:"ghost",size:"sm",onClick:()=>X(!0),children:[(0,a.jsx)(l.default,{className:"text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),B&&(0,a.jsx)(d.rq,{isOpen:B,onClose:()=>H(!1),onSelect:e=>{q&&x(q,e.value)},selectedModel:q?m[q]:null,activeProviders:i,modelAliases:Y,title:`Select model for ${q}`}),(0,a.jsx)(d.uR,{isOpen:Z,onClose:()=>X(!1),title:"Claude CLI - Manual Configuration",configs:(w=G&&G.trim()?G:g?"<API_KEY_FROM_DASHBOARD>":"sk_jrouter",k={ANTHROPIC_BASE_URL:eg(),ANTHROPIC_AUTH_TOKEN:w},e.defaultModels.forEach(e=>{let t=m[e.alias];t&&e.envKey&&(k[e.envKey]=t)}),ei&&(k.CLAUDE_CODE_AUTO_COMPACT_WINDOW=ei),[{filename:"~/.claude/settings.json",content:JSON.stringify({hasCompletedOnboarding:!0,env:k},null,2)}])})]})}var R=s(57250);let T=(e,t)=>{let s=e.match(RegExp(`^\\s*${t}\\s*=\\s*(["'])([^\\n]*?)\\1\\s*(?:#.*)?$`));return s?s[2]:""};function D(e){if("string"!=typeof e)return{baseUrl:"",apiKey:""};let t=e.split(/\r?\n/),s="",a=!0;for(let e of t){if(/^\s*\[/.test(e)){a=!1;continue}a&&(s=T(e,"model_provider")||s)}if(!s)return{baseUrl:"",apiKey:""};let l=`model_providers.${s}`,r=!1,i=!1,n="",o="";for(let e of t){let t=e.match(/^\s*\[\s*([^\]]+?)\s*\]\s*(?:#.*)?$/);if(t){r=t[1]===l,i=t[1]===`${l}.http_headers`;continue}if(r&&(n=T(e,"base_url")||n),i){let t=T(e,"Authorization").match(/^Bearer\s+(.+)$/i);o=t?t[1]:o}}return{baseUrl:n,apiKey:o}}function z(e,t=[]){if(!e||"string"!=typeof e)return"model";let s="",a=e.trim();"config"===(s=(s=a.includes("/")?a.split("/")[0].toLowerCase().replace(/[^a-z0-9_-]/g,""):a.toLowerCase().replace(/[^a-z0-9_-]/g,"")).replace(/^[-_]+|[-_]+$/g,"")||"model")&&(s="model-config");let l=s,r=2;for(;t.includes(l);)l=`${s}-${r}`,r++;return l}function K({tool:e,isExpanded:t,onToggle:s,baseUrl:i,apiKeys:m,activeProviders:x,cloudEnabled:u,initialStatus:p,tunnelEnabled:h,tunnelPublicUrl:g,tailscaleEnabled:f,tailscaleUrl:j}){let y,v,[b,N]=(0,o.useState)(p||null),[w,k]=(0,o.useState)(!1),[C,S]=(0,o.useState)(!1),[$,A]=(0,o.useState)(!1),[M,I]=(0,o.useState)(null),[U,L]=(0,o.useState)(!1),[T,F]=(0,o.useState)(""),[J,B]=(0,o.useState)(""),[H,q]=(0,o.useState)(""),[W,G]=(0,o.useState)(!1),[V,Y]=(0,o.useState)(!1),[Q,Z]=(0,o.useState)({}),[X,ee]=(0,o.useState)(!1),[et,es]=(0,o.useState)(""),[ea,el]=(0,o.useState)([]),[er,ei]=(0,o.useState)(""),[en,eo]=(0,o.useState)(""),[ed,ec]=(0,o.useState)(!1),[em,ex]=(0,o.useState)(!1),[eu,ep]=(0,o.useState)(null),[eh,eg]=(0,o.useState)("");(0,o.useEffect)(()=>{ej()},[]),(0,o.useEffect)(()=>{!(m?.length>0)||T||b?.config||F(m[0].key)},[m,T,b?.config]),(0,o.useEffect)(()=>{p&&N(p)},[p]),(0,o.useEffect)(()=>{t&&(b||ek(),ef(),ej())},[t]);let ef=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&Z(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}},ej=async()=>{try{let e=await fetch("/api/cli-tools/codex-profiles"),t=await e.json();e.ok&&el(t.profiles||[])}catch(e){console.log("Error fetching codex profiles:",e)}},ey=async()=>{let e=er.trim().toLowerCase().replace(/[^a-z0-9_-]/g,""),t=en.trim();if(e&&t){ex(!0);try{let s=await fetch("/api/cli-tools/codex-profiles",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,model:t})}),a=await s.json();s.ok?(ei(""),eo(""),ej()):I({type:"error",text:a.error||"Failed to add model"})}catch(e){I({type:"error",text:e.message})}finally{ex(!1)}}},ev=async e=>{ep(e);try{(await fetch("/api/cli-tools/codex-profiles",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e})})).ok&&ej()}catch(e){console.log("Error deleting codex profile:",e)}finally{ep(null)}},eb=async e=>{try{await navigator.clipboard.writeText(e),eg(e),setTimeout(()=>eg(""),2e3)}catch(e){console.log("Copy failed",e)}};(0,o.useEffect)(()=>{let e=b?.config;if(e){let{baseUrl:t,apiKey:s}=D(e);es(t),F(s);let a=e.match(/^model\s*=\s*"([^"]+)"/m);a&&B(a[1]);let l=e.match(/^default_subagent_model\s*=\s*"([^"]+)"/m);l&&q(l[1])}},[b?.config]);let eN=D(b?.config).baseUrl,ew=b?.installed?b.config?P(eN,{tunnelPublicUrl:g,tailscaleUrl:j})?"configured":"other":"not_configured":null,e_=()=>{let e=(et||`${i}/v1`).replace(/\/+$/,"");return e.endsWith("/v1")?e:`${e}/v1`},ek=async()=>{k(!0);try{let e=await fetch("/api/cli-tools/codex-settings",{cache:"no-store"}),t=await e.json();N(t)}catch(e){N({installed:!1,error:e.message})}finally{k(!1)}},eC=async()=>{S(!0),I(null);try{let e=T&&T.trim()||u?T:"sk_jrouter",t=await fetch("/api/cli-tools/codex-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:e_(),apiKey:e,model:J,subagentModel:H||J})}),s=await t.json();t.ok?(_(e_(),{tunnelPublicUrl:g,tailscaleUrl:j}),I({type:"success",text:"Settings applied successfully!"}),ek()):I({type:"error",text:s.error||"Failed to apply settings"})}catch(e){I({type:"error",text:e.message})}finally{S(!1)}},eS=async()=>{A(!0),I(null);try{let e=await fetch("/api/cli-tools/codex-settings",{method:"DELETE"}),t=await e.json();e.ok?(I({type:"success",text:"Settings reset successfully!"}),B(""),q(""),ek()):I({type:"error",text:t.error||"Failed to reset settings"})}catch(e){I({type:"error",text:e.message})}finally{A(!1)}};return(0,a.jsxs)(d.Zp,{padding:"none",className:n().panel,children:[(0,a.jsxs)("div",{className:n().panelHeader,onClick:s,children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(c.default,{src:"/providers/codex.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===ew&&(0,a.jsx)(r.A,{variant:"success",className:n().status,children:"Connected"}),"not_configured"===ew&&(0,a.jsx)(r.A,{variant:"warning",className:n().status,children:"Not configured"}),"other"===ew&&(0,a.jsx)(r.A,{variant:"default",dot:!1,className:n().status,children:"Other"})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)(l.default,{className:`text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:n().body,children:[w&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,a.jsx)(l.default,{className:"animate-spin",children:"progress_activity"}),(0,a.jsx)("span",{children:"Checking Codex CLI..."})]}),!w&&b&&!b.installed&&(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:`flex flex-col gap-3 p-4 border ${n().notice} ${n().warning}`,children:[(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)(l.default,{className:"text-[var(--warn)]",children:"warning"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"font-medium text-[var(--warn)]",children:"Codex CLI not detected locally"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if JRouter is deployed on a remote server."})]})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2 sm:pl-9",children:[(0,a.jsxs)(d.$n,{variant:"secondary",size:"sm",onClick:()=>ee(!0),children:[(0,a.jsx)(l.default,{className:"text-[18px] mr-1",children:"content_copy"}),"Manual Config"]}),(0,a.jsxs)(d.$n,{variant:"outline",size:"sm",onClick:()=>L(!U),children:[(0,a.jsx)(l.default,{className:"text-[18px] mr-1",children:U?"expand_less":"help"}),U?"Hide":"How to Install"]})]})]}),U&&(0,a.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,a.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,a.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-text-muted mb-1",children:"macOS / Linux / Windows:"}),(0,a.jsx)("code",{className:"block px-3 py-2 bg-black/5 dark:bg-white/5 rounded font-mono text-xs",children:"npm install -g @openai/codex"})]}),(0,a.jsxs)("p",{className:"text-text-muted",children:["After installation, run ",(0,a.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"codex"})," to verify."]}),(0,a.jsx)("div",{className:"pt-2 border-t border-border",children:(0,a.jsxs)("p",{className:"text-text-muted text-xs",children:["Codex reads custom providers from ",(0,a.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"~/.codex/config.toml"}),'. Click "Apply" to auto-configure.']})})]})]})]}),!w&&b?.installed&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"Select Endpoint"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(E,{value:et||et||`${i}/v1`,onChange:es,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:h,tunnelPublicUrl:g,tailscaleEnabled:f,tailscaleUrl:j,currentUrl:eN})]}),b?.config&&(eN?(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"Current"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)("span",{className:"min-w-0 truncate rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5",children:eN})]}):null),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"API Key"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(O,{value:T,onChange:F,apiKeys:m,cloudEnabled:u})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"Model"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,a.jsx)("input",{type:"text",value:J,onChange:e=>B(e.target.value),placeholder:"provider/model-id",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),J&&(0,a.jsx)("button",{onClick:()=>B(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-[var(--danger)] rounded transition-colors",title:"Clear",children:(0,a.jsx)(l.default,{className:"text-[14px]",children:"close"})})]}),(0,a.jsx)("button",{onClick:()=>G(!0),disabled:!x?.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 ${x?.length?"bg-surface border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${n().selectButton}`,children:"Select Model"})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"Subagent Model"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,a.jsx)("input",{type:"text",value:H,onChange:e=>q(e.target.value),placeholder:J||"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"}),H&&(0,a.jsx)("button",{onClick:()=>q(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-[var(--danger)] rounded transition-colors",title:"Clear (will use main model)",children:(0,a.jsx)(l.default,{className:"text-[14px]",children:"close"})})]}),(0,a.jsx)("button",{onClick:()=>Y(!0),disabled:!x?.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 ${x?.length?"bg-surface border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${n().selectButton}`,children:"Select Model"})]})]}),M&&(0,a.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===M.type?n().positive:n().danger}`,children:[(0,a.jsx)(l.default,{className:"text-[14px]",children:"success"===M.type?"check_circle":"error"}),(0,a.jsx)("span",{children:M.text})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,a.jsxs)(d.$n,{variant:"primary",size:"sm",onClick:eC,disabled:!T&&u&&m.length>0||!J,loading:C,children:[(0,a.jsx)(l.default,{className:"text-[14px] mr-1",children:"save"}),"Apply"]}),(0,a.jsxs)(d.$n,{variant:"outline",size:"sm",onClick:eS,disabled:$,loading:$,children:[(0,a.jsx)(l.default,{className:"text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,a.jsxs)(d.$n,{variant:"ghost",size:"sm",onClick:()=>ee(!0),children:[(0,a.jsx)(l.default,{className:"text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]}),(0,a.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-3",children:[(0,a.jsx)("div",{className:"flex items-center justify-between",children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)("span",{className:"text-xs font-semibold text-text-main flex items-center gap-1.5",children:[(0,a.jsx)(l.default,{className:"text-[16px] text-text-main",children:"layers"}),"Additional Models"]}),ea.length>0&&(0,a.jsx)("span",{className:"badge-neutral",children:ea.length})]})}),(0,a.jsx)("div",{className:"flex flex-col gap-1.5 p-2.5 bg-surface/40 border border-border rounded-lg",children:(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-[10rem_1fr_auto_auto] sm:items-center",children:[(0,a.jsx)("input",{type:"text",value:er,onChange:e=>ei(e.target.value.toLowerCase().replace(/[^a-z0-9_-]/g,"")),placeholder:"Alias (e.g. claude)",className:"w-full min-w-0 px-2.5 py-1.5 bg-surface rounded border border-border text-xs font-mono focus:outline-none focus:ring-1 focus:ring-primary/50",onKeyDown:e=>"Enter"===e.key&&ey()}),(0,a.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,a.jsx)("input",{type:"text",value:en,onChange:e=>{let t=e.target.value;eo(t),ei(z(t.includes("/")?t.split("/")[0]:t,ea.map(e=>e.name)))},placeholder:"provider/model-id",className:"w-full min-w-0 pl-2.5 pr-7 py-1.5 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50",onKeyDown:e=>"Enter"===e.key&&ey()}),en&&(0,a.jsx)("button",{onClick:()=>eo(""),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,a.jsx)(l.default,{className:"text-[14px]",children:"close"})})]}),(0,a.jsx)("button",{onClick:()=>ec(!0),disabled:!x?.length,className:`w-full sm:w-auto rounded border px-2.5 py-1.5 text-xs transition-colors whitespace-nowrap sm:shrink-0 ${x?.length?"bg-surface border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${n().selectButton}`,children:"Select Model"}),(0,a.jsxs)(d.$n,{variant:"primary",size:"sm",onClick:ey,disabled:!er.trim()||!en.trim()||em,loading:em,className:" whitespace-nowrap",children:[(0,a.jsx)(l.default,{className:"text-[15px] mr-1",children:"add"}),"Add"]})]})}),0===ea.length?(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center p-4 border border-dashed border-border rounded-lg text-center bg-surface/30",children:[(0,a.jsx)(l.default,{className:"text-[20px] text-text-muted mb-1 opacity-60",children:"terminal"}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Only the main model is active. Add an alias above to configure more models for Codex CLI."})]}):(0,a.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:ea.map(e=>{let t=e.model.includes("/")?e.model.split("/")[0]:e.name,s=eh===e.command;return(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2 p-2.5 bg-surface/50 border border-border hover:border-border-hover rounded-lg transition-colors group",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2.5 min-w-0",children:[(0,a.jsx)("div",{className:"size-6 flex items-center justify-center shrink-0 rounded bg-black/5 dark:bg-white/5 p-0.5",children:(0,a.jsx)(R.A,{providerId:t,size:18,fallbackText:e.name.slice(0,2).toUpperCase()})}),(0,a.jsxs)("div",{className:"min-w-0 flex flex-col",children:[(0,a.jsx)("span",{className:"font-medium text-xs text-text-main truncate",children:e.name}),(0,a.jsx)("span",{className:"text-[11px] text-text-muted truncate font-mono",children:e.model})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,a.jsxs)("button",{onClick:()=>eb(e.command),className:`flex items-center gap-1 px-2 py-1 rounded text-[11px] font-mono border transition-all ${s?"bg-green-500/10 border-green-500/30 text-[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,a.jsx)(l.default,{className:"text-[13px]",children:s?"check":"terminal"}),(0,a.jsx)("span",{className:"hidden md:inline",children:e.command}),(0,a.jsx)("span",{className:"md:hidden",children:"copy"})]}),(0,a.jsx)("button",{onClick:()=>ev(e.name),disabled:eu===e.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,a.jsx)(l.default,{className:"text-[15px]",children:"close"})})]})]},e.name)})})]})]})]}),W&&(0,a.jsx)(d.rq,{className:n().modelPicker,isOpen:W,onClose:()=>G(!1),onSelect:e=>{B(e.value),H||q(e.value),G(!1)},selectedModel:J,activeProviders:x,modelAliases:Q,title:"Select Model for Codex"}),V&&(0,a.jsx)(d.rq,{className:n().modelPicker,isOpen:V,onClose:()=>Y(!1),onSelect:e=>{q(e.value),Y(!1)},selectedModel:H,activeProviders:x,modelAliases:Q,title:"Select Subagent Model for Codex"}),ed&&(0,a.jsx)(d.rq,{className:n().modelPicker,isOpen:ed,onClose:()=>ec(!1),onSelect:e=>{ec(!1);let t=e?.value||e?.id;t&&(eo(t),ei(z(e?.provider||(t.includes("/")?t.split("/")[0]:t),ea.map(e=>e.name))))},selectedModel:en,activeProviders:x,modelAliases:Q,title:"Select Model for Codex CLI"}),(0,a.jsx)(d.uR,{isOpen:X,onClose:()=>ee(!1),title:"Codex CLI - Manual Configuration",configs:(y=T&&T.trim()?T:u?"<API_KEY_FROM_DASHBOARD>":"sk_jrouter",v=H||J,[{filename:"~/.codex/config.toml",content:`# JRouter Configuration for Codex CLI
45
+ model = "${J}"
46
+ model_provider = "jrouter"
47
+
48
+ [model_providers.jrouter]
49
+ name = "JRouter"
50
+ base_url = "${e_()}"
51
+ wire_api = "responses"
52
+
53
+ [model_providers.jrouter.http_headers]
54
+ Authorization = "Bearer ${y}"
55
+
56
+ [agents]
57
+ default_subagent_model = "${v}"
58
+ `}])})]})}function F({tool:e,isExpanded:t,onToggle:s,baseUrl:i,hasActiveProviders:m,apiKeys:x,activeProviders:u,cloudEnabled:p,initialStatus:h,tunnelEnabled:g,tunnelPublicUrl:f,tailscaleEnabled:j,tailscaleUrl:y}){let v,b,N,w,[k,C]=(0,o.useState)(h||null),[S,$]=(0,o.useState)(!1),[A,M]=(0,o.useState)(!1),[I,U]=(0,o.useState)(!1),[L,R]=(0,o.useState)(null),[T,D]=(0,o.useState)(""),[z,K]=(0,o.useState)([]),[J,B]=(0,o.useState)(""),[H,q]=(0,o.useState)(!1),[W,G]=(0,o.useState)({}),[V,Y]=(0,o.useState)(!1),[Q,Z]=(0,o.useState)(!1),[X,ee]=(0,o.useState)(""),et=(0,o.useRef)(!1),es=k?.settings?.customModels?.find(e=>e.id?.startsWith("custom:9Router"))?.baseUrl||"",ea=(()=>{if(!k?.installed)return null;let e=k.settings?.customModels?.find(e=>e.id?.startsWith("custom:9Router"));return e?P(e.baseUrl,{tunnelPublicUrl:f,tailscaleUrl:y,cloudUrl:p?"https://9router.com":null})?"configured":"other":"not_configured"})();(0,o.useEffect)(()=>{x?.length>0&&!T&&D(x[0].key)},[x,T]),(0,o.useEffect)(()=>{h&&C(h)},[h]),(0,o.useEffect)(()=>{t&&(k||er(),el())},[t]);let el=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&G(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}};(0,o.useEffect)(()=>{if(k?.installed&&!et.current){et.current=!0;let e=(k.settings?.customModels||[]).filter(e=>e.id?.startsWith("custom:9Router")).sort((e,t)=>(e.index||0)-(t.index||0)).map(e=>e.model);if(e.length>0)K(e);else{let e=k.settings?.customModels?.find(e=>"custom:JRouter-0"===e.id);e?.model&&K([e.model])}}},[k]);let er=async()=>{$(!0);try{let e=await fetch("/api/cli-tools/droid-settings"),t=await e.json();C(t)}catch(e){C({installed:!1,error:e.message})}finally{$(!1)}},ei=()=>{let e=X||i;return e.endsWith("/v1")?e:`${e}/v1`},en=()=>{let e=J.trim();!e||z.includes(e)||(K(t=>[...t,e]),B(""))},eo=async()=>{M(!0),R(null);try{let e=T?.trim()||(x?.length>0?x[0].key:null)||(p?null:"sk_jrouter"),t=await fetch("/api/cli-tools/droid-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:ei(),apiKey:e,models:z,activeModel:z[0]||""})}),s=await t.json();t.ok?(_(ei(),{tunnelPublicUrl:f,tailscaleUrl:y}),R({type:"success",text:"Settings applied successfully!"}),er()):R({type:"error",text:s.error||"Failed to apply settings"})}catch(e){R({type:"error",text:e.message})}finally{M(!1)}},ed=async()=>{U(!0),R(null);try{let e=await fetch("/api/cli-tools/droid-settings",{method:"DELETE"}),t=await e.json();e.ok?(R({type:"success",text:"Settings reset successfully!"}),K([]),er()):R({type:"error",text:t.error||"Failed to reset settings"})}catch(e){R({type:"error",text:e.message})}finally{U(!1)}};return(0,a.jsxs)(d.Zp,{padding:"none",className:n().panel,children:[(0,a.jsxs)("div",{className:n().panelHeader,onClick:s,children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(c.default,{src:"/providers/droid.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===ea&&(0,a.jsx)(r.A,{variant:"success",className:n().status,children:"Connected"}),"not_configured"===ea&&(0,a.jsx)(r.A,{variant:"warning",className:n().status,children:"Not configured"}),"other"===ea&&(0,a.jsx)(r.A,{variant:"default",dot:!1,className:n().status,children:"Other"})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)(l.default,{className:`text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:n().body,children:[S&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,a.jsx)(l.default,{className:"animate-spin",children:"progress_activity"}),(0,a.jsx)("span",{children:"Checking Factory Droid CLI..."})]}),!S&&k&&!k.installed&&(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:`flex flex-col gap-3 p-4 border ${n().notice} ${n().warning}`,children:[(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)(l.default,{className:"text-[var(--warn)]",children:"warning"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"font-medium text-[var(--warn)]",children:"Factory Droid CLI not detected locally"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if JRouter is deployed on a remote server."})]})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2 sm:pl-9",children:[(0,a.jsxs)(d.$n,{variant:"secondary",size:"sm",onClick:()=>Y(!0),children:[(0,a.jsx)(l.default,{className:"text-[18px] mr-1",children:"content_copy"}),"Manual Config"]}),(0,a.jsxs)(d.$n,{variant:"outline",size:"sm",onClick:()=>Z(!Q),children:[(0,a.jsx)(l.default,{className:"text-[18px] mr-1",children:Q?"expand_less":"help"}),Q?"Hide":"How to Install"]})]})]}),Q&&(0,a.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,a.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,a.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-text-muted mb-1",children:"macOS / Linux / Windows:"}),(0,a.jsx)("code",{className:"block px-3 py-2 bg-black/5 dark:bg-white/5 rounded font-mono text-xs",children:"curl -fsSL https://app.factory.ai/cli | sh"})]}),(0,a.jsxs)("p",{className:"text-text-muted",children:["After installation, run ",(0,a.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"droid"})," to verify."]})]})]})]}),!S&&k?.installed&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"Select Endpoint"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(E,{value:X||((v=X||i).endsWith("/v1")?v:`${v}/v1`),onChange:ee,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:g,tunnelPublicUrl:f,tailscaleEnabled:j,tailscaleUrl:y,currentUrl:es})]}),k?.settings?.customModels?.find(e=>e.id?.startsWith("custom:9Router"))?.baseUrl&&(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"Current"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)("span",{className:"min-w-0 truncate rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5",children:k.settings.customModels.find(e=>e.id?.startsWith("custom:9Router")).baseUrl})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"API Key"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(O,{value:T,onChange:D,apiKeys:x,cloudEnabled:p})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsxs)("span",{className:`sm:text-right ${n().fieldLabel}`,children:["Models ",z.length>0&&(0,a.jsxs)("span",{className:"text-text-main",children:["(",z.length,")"]})]}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"flex-1 flex flex-col gap-1",children:[z.length>0&&(0,a.jsx)("div",{className:"flex flex-col gap-0.5 mb-1",children:z.map(e=>(0,a.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 bg-bg-secondary rounded border border-border",children:[(0,a.jsx)("span",{className:"flex-1 text-xs font-mono truncate",children:e}),(0,a.jsx)("button",{onClick:()=>K(t=>t.filter(t=>t!==e)),className:"text-text-muted hover:text-[var(--danger)] transition-colors shrink-0",title:"Remove",children:(0,a.jsx)(l.default,{className:"text-[12px]",children:"close"})})]},e))}),(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("input",{type:"text",value:J,onChange:e=>B(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),en())},placeholder:"provider/model-id",className:"w-full min-w-0 px-2 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),(0,a.jsx)("button",{onClick:()=>q(!0),disabled:!m,className:`px-2 py-1.5 rounded border text-xs shrink-0 ${m?"bg-surface border-border hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${n().selectButton}`,children:"Select"}),(0,a.jsx)("button",{onClick:en,disabled:!J.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,a.jsx)(l.default,{className:"text-[14px]",children:"add"})})]})]})]})]}),L&&(0,a.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===L.type?n().positive:n().danger}`,children:[(0,a.jsx)(l.default,{className:"text-[14px]",children:"success"===L.type?"check_circle":"error"}),(0,a.jsx)("span",{children:L.text})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,a.jsxs)(d.$n,{variant:"primary",size:"sm",onClick:eo,disabled:0===z.length,loading:A,children:[(0,a.jsx)(l.default,{className:"text-[14px] mr-1",children:"save"}),"Apply"]}),(0,a.jsxs)(d.$n,{variant:"outline",size:"sm",onClick:ed,disabled:!k?.hasJRouter,loading:I,children:[(0,a.jsx)(l.default,{className:"text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,a.jsxs)(d.$n,{variant:"ghost",size:"sm",onClick:()=>Y(!0),children:[(0,a.jsx)(l.default,{className:"text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),H&&(0,a.jsx)(d.rq,{className:n().modelPicker,isOpen:H,onClose:()=>q(!1),onSelect:e=>{!e.value||z.includes(e.value)||(K(t=>[...t,e.value]),q(!1))},selectedModel:null,activeProviders:u,modelAliases:W,title:"Select Model for Factory Droid"}),(0,a.jsx)(d.uR,{isOpen:V,onClose:()=>Y(!1),title:"Factory Droid - Manual Configuration",configs:(b=T&&T.trim()?T:p?"<API_KEY_FROM_DASHBOARD>":"sk_jrouter",N={customModels:z.map((e,t)=>({model:e,id:`custom:JRouter-${t}`,index:t,baseUrl:ei(),apiKey:b,displayName:e,maxOutputTokens:131072,noImageSupport:!1,provider:"openai"}))},w="u">typeof navigator&&navigator.platform,[{filename:w?.toLowerCase().includes("win")?"%USERPROFILE%\\.factory\\settings.json":"~/.factory/settings.json",content:JSON.stringify(N,null,2)}])})]})}function J({tool:e,isExpanded:t,onToggle:s,baseUrl:i,hasActiveProviders:m,apiKeys:x,activeProviders:u,cloudEnabled:p,initialStatus:h,tunnelEnabled:g,tunnelPublicUrl:f,tailscaleEnabled:j,tailscaleUrl:y}){let v,b,[N,w]=(0,o.useState)(h||null),[k,C]=(0,o.useState)(!1),[S,$]=(0,o.useState)(!1),[A,M]=(0,o.useState)(!1),[I,U]=(0,o.useState)(null),[L,R]=(0,o.useState)(""),[T,D]=(0,o.useState)(""),[z,K]=(0,o.useState)({}),[F,B]=(0,o.useState)(null),[H,q]=(0,o.useState)(!1),[W,G]=(0,o.useState)({}),[V,Y]=(0,o.useState)(!1),[Q,Z]=(0,o.useState)(""),X=(0,o.useRef)(!1),ee=N?.settings?.models?.providers?.jrouter?.baseUrl||"",et=(()=>{if(!N?.installed)return null;let e=N.settings?.models?.providers?.jrouter;return e?P(e.baseUrl,{tunnelPublicUrl:f,tailscaleUrl:y})?"configured":"other":"not_configured"})();(0,o.useEffect)(()=>{x?.length>0&&!L&&R(x[0].key)},[x,L]),(0,o.useEffect)(()=>{h&&w(h)},[h]),(0,o.useEffect)(()=>{t&&(N||ea(),es())},[t]);let es=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&G(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}};(0,o.useEffect)(()=>{if(N?.installed&&!X.current){X.current=!0;let e=N.settings?.models?.providers?.jrouter;if(e){let t=N.settings?.agents?.defaults?.model?.primary;t&&D(t.replace("jrouter/","")),e.apiKey&&x?.some(t=>t.key===e.apiKey)&&R(e.apiKey)}let t=N.agents||[],s={};t.forEach(e=>{e.currentModel&&(s[e.id]=e.currentModel)}),K(s)}},[N,x]);let ea=async()=>{C(!0);try{let e=await fetch("/api/cli-tools/openclaw-settings"),t=await e.json();w(t)}catch(e){w({installed:!1,error:e.message})}finally{C(!1)}},el=()=>window.location.origin.replace("://localhost","://127.0.0.1"),er=()=>{let e=Q||el();return e.endsWith("/v1")?e:`${e}/v1`},ei=async()=>{$(!0),U(null);try{let e=L?.trim()||(x?.length>0?x[0].key:null)||(p?null:"sk_jrouter"),t=await fetch("/api/cli-tools/openclaw-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:er(),apiKey:e,model:T,agentModels:z})}),s=await t.json();t.ok?(_(er(),{tunnelPublicUrl:f,tailscaleUrl:y}),U({type:"success",text:"Settings applied successfully!"}),ea()):U({type:"error",text:s.error||"Failed to apply settings"})}catch(e){U({type:"error",text:e.message})}finally{$(!1)}},en=async()=>{M(!0),U(null);try{let e=await fetch("/api/cli-tools/openclaw-settings",{method:"DELETE"}),t=await e.json();e.ok?(U({type:"success",text:"Settings reset successfully!"}),D(""),R(""),ea()):U({type:"error",text:t.error||"Failed to reset settings"})}catch(e){U({type:"error",text:e.message})}finally{M(!1)}};return(0,a.jsxs)(d.Zp,{padding:"none",className:n().panel,children:[(0,a.jsxs)("div",{className:n().panelHeader,onClick:s,children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(c.default,{src:"/providers/openclaw.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===et&&(0,a.jsx)(r.A,{variant:"success",className:n().status,children:"Connected"}),"not_configured"===et&&(0,a.jsx)(r.A,{variant:"warning",className:n().status,children:"Not configured"}),"other"===et&&(0,a.jsx)(r.A,{variant:"default",dot:!1,className:n().status,children:"Other"})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)(l.default,{className:`text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:n().body,children:[k&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,a.jsx)(l.default,{className:"animate-spin",children:"progress_activity"}),(0,a.jsx)("span",{children:"Checking Open Claw CLI..."})]}),!k&&N&&!N.installed&&(0,a.jsx)("div",{className:"flex flex-col gap-4",children:(0,a.jsxs)("div",{className:`flex flex-col gap-3 p-4 border ${n().notice} ${n().warning}`,children:[(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)(l.default,{className:"text-[var(--warn)]",children:"warning"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"font-medium text-[var(--warn)]",children:"Open Claw CLI not detected locally"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if JRouter is deployed on a remote server."})]})]}),(0,a.jsx)("div",{className:"flex flex-wrap items-center gap-2 sm:pl-9",children:(0,a.jsxs)(d.$n,{variant:"secondary",size:"sm",onClick:()=>Y(!0),children:[(0,a.jsx)(l.default,{className:"text-[18px] mr-1",children:"content_copy"}),"Manual Config"]})})]})}),!k&&N?.installed&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"Select Endpoint"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(E,{value:Q||((v=Q||el()).endsWith("/v1")?v:`${v}/v1`),onChange:Z,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:g,tunnelPublicUrl:f,tailscaleEnabled:j,tailscaleUrl:y,currentUrl:ee})]}),N?.settings?.models?.providers?.jrouter?.baseUrl&&(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"Current"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)("span",{className:"min-w-0 truncate rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5",children:N.settings.models.providers.jrouter.baseUrl})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"API Key"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(O,{value:L,onChange:R,apiKeys:x,cloudEnabled:p})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"Default Model"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,a.jsx)("input",{type:"text",value:T,onChange:e=>D(e.target.value),placeholder:"provider/model-id",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),T&&(0,a.jsx)("button",{onClick:()=>D(""),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,a.jsx)(l.default,{className:"text-[14px]",children:"close"})})]}),(0,a.jsx)("button",{onClick:()=>{B(null),q(!0)},disabled:!m,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?"bg-surface border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${n().selectButton}`,children:"Select"})]}),(N.agents||[]).filter(e=>e.agentDir).map(e=>(0,a.jsxs)("div",{className:"flex items-center gap-2 pl-4",children:[(0,a.jsxs)("span",{className:"w-32 shrink-0 text-xs text-text-main text-right truncate",title:e.name||e.id,children:["Agent ",e.name||e.id]}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,a.jsx)("input",{type:"text",value:z[e.id]||"",onChange:t=>K(s=>({...s,[e.id]:t.target.value})),placeholder:`default (${T||"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"}),z[e.id]&&(0,a.jsx)("button",{onClick:()=>K(t=>({...t,[e.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,a.jsx)(l.default,{className:"text-[14px]",children:"close"})})]}),(0,a.jsx)("button",{onClick:()=>{B(e.id),q(!0)},disabled:!m,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?"bg-surface border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${n().selectButton}`,children:"Select"})]},e.id))]}),I&&(0,a.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===I.type?n().positive:n().danger}`,children:[(0,a.jsx)(l.default,{className:"text-[14px]",children:"success"===I.type?"check_circle":"error"}),(0,a.jsx)("span",{children:I.text})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,a.jsxs)(d.$n,{variant:"primary",size:"sm",onClick:ei,disabled:!T,loading:S,children:[(0,a.jsx)(l.default,{className:"text-[14px] mr-1",children:"save"}),"Apply"]}),(0,a.jsxs)(d.$n,{variant:"outline",size:"sm",onClick:en,disabled:!N?.hasJRouter,loading:A,children:[(0,a.jsx)(l.default,{className:"text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,a.jsxs)(d.$n,{variant:"ghost",size:"sm",onClick:()=>Y(!0),children:[(0,a.jsx)(l.default,{className:"text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),H&&(0,a.jsx)(d.rq,{className:n().modelPicker,isOpen:H,onClose:()=>q(!1),onSelect:e=>{F?(K(t=>({...t,[F]:e.value})),B(null)):D(e.value),q(!1)},selectedModel:T,activeProviders:u,modelAliases:W,title:"Select Model for Open Claw"}),(0,a.jsx)(d.uR,{isOpen:V,onClose:()=>Y(!1),title:"Open Claw - Manual Configuration",configs:(b=L&&L.trim()?L:p?"<API_KEY_FROM_DASHBOARD>":"sk_jrouter",[{filename:"~/.openclaw/openclaw.json",content:JSON.stringify({agents:{defaults:{model:{primary:`jrouter/${T||"provider/model-id"}`}}},models:{providers:{jrouter:{baseUrl:er(),apiKey:b,api:"openai-completions",models:[{id:T||"provider/model-id",name:(T||"provider/model-id").split("/").pop()}]}}}},null,2)}])})]})}var B=s(3534);let H="/api/cli-tools/hermes-settings",q=B.dM.hermes?.roles||[];function W({tool:e,isExpanded:t,onToggle:s,baseUrl:i,hasActiveProviders:m,apiKeys:x,activeProviders:u,cloudEnabled:p,initialStatus:h,tunnelEnabled:f,tunnelPublicUrl:j,tailscaleEnabled:y,tailscaleUrl:v}){let b,N,w,k,C,S,[$,A]=(0,o.useState)(h||null),[M,I]=(0,o.useState)(!1),[U,L]=(0,o.useState)(!1),[R,T]=(0,o.useState)(!1),[D,z]=(0,o.useState)(null),[K,F]=(0,o.useState)(""),[J,B]=(0,o.useState)(""),[G,V]=(0,o.useState)({}),[Y,Q]=(0,o.useState)("default"),[Z,X]=(0,o.useState)(!1),[ee,et]=(0,o.useState)({}),[es,ea]=(0,o.useState)(!1),[el,er]=(0,o.useState)(""),[ei,en]=(0,o.useState)([]),[eo,ed]=(0,o.useState)("default"),[ec,em]=(0,o.useState)(!1),[ex,eu]=(0,o.useState)(""),[ep,eh]=(0,o.useState)(!1),[eg,ef]=(0,o.useState)(""),ej=(0,o.useRef)(!1),ey=$?.settings?.model?.base_url||"",ev=(()=>{if(!$?.installed)return null;let e=$.settings?.model;return e?.base_url?P(e.base_url,{tunnelPublicUrl:j,tailscaleUrl:v})?"configured":"other":"not_configured"})(),eb={configured:"bg-[var(--pos)]",other:"bg-[var(--text-2)]",not_configured:"bg-[var(--warn)]"},eN={configured:"Connected",other:"Other endpoint",not_configured:"Not configured"};(0,o.useEffect)(()=>{x?.length>0&&!K&&F(x[0].key)},[x,K]),(0,o.useEffect)(()=>{h&&A(h)},[h]);let ew=async()=>{try{let e=await fetch("/api/cli-tools/hermes-profiles"),t=await e.json();e.ok&&en(t.profiles||[])}catch(e){console.log("Error fetching hermes profiles:",e)}};(0,o.useEffect)(()=>{t&&($||eC(),e_(),ew())},[t]);let e_=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&et(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}};(0,o.useEffect)(()=>{if($?.installed&&!ej.current){ej.current=!0;let e=$.settings?.model;B(e?.default||"");let t={};for(let[e,s]of($.settings?.delegation?.model&&(t.delegation=$.settings.delegation.model),Object.entries($.settings?.auxiliary||{})))s?.model&&(t[e]=s.model);V(t),eh(!!$.hasJRouterStt),ef($.hasJRouterStt&&$.settings?.stt?.model||"")}},[$]);let ek=async e=>{try{await navigator.clipboard.writeText(e),eu(e),setTimeout(()=>eu(""),2e3)}catch(e){console.log("Copy failed",e)}},eC=async(e=eo)=>{I(!0);try{let t=await fetch(`${H}?profile=${encodeURIComponent(e)}`),s=await t.json();t.ok?A(s):(z({type:"error",text:s.error||"Failed to load Hermes settings"}),404===t.status&&"default"!==e&&(ew(),ed("default"),ej.current=!1,await eC("default")))}catch(e){A({installed:!1,error:e.message})}finally{I(!1)}},eS=()=>{let e=el||window.location.origin.replace("://localhost","://127.0.0.1");return e.endsWith("/v1")?e:`${e}/v1`},eE=()=>K?.trim()||(x?.length>0?x[0].key:null)||(p?null:"sk_jrouter"),e$=e=>"default"===e?"default profile":`profile "${e}"`,eA=async()=>{L(!0),z(null);try{let e=await fetch(H,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({profile:eo,baseUrl:eS(),apiKey:eE(),selections:[{role:"default",model:J},...Object.entries(G).filter(([,e])=>e?.trim()).map(([e,t])=>({role:e,model:t.trim()}))],audio:{enabled:ep,model:eg.trim()}})}),t=await e.json();e.ok?(_(eS(),{tunnelPublicUrl:j,tailscaleUrl:v}),z({type:"success",text:`Settings applied to ${e$(eo)}!`}),eC(),ew()):z({type:"error",text:t.error||"Failed to apply settings"})}catch(e){z({type:"error",text:e.message})}finally{L(!1)}},eO=async()=>{let e=eS();if(!(P(e,{tunnelPublicUrl:j,tailscaleUrl:v})||g().some(t=>(t.baseUrl||"").replace(/\/+$/,"")===e.replace(/\/+$/,""))))return void z({type:"error",text:`"${e}" is not a jrouter endpoint. Select the local, tunnel, Tailscale or a saved jrouter endpoint before applying to all profiles.`});em(!0),z(null);try{let t=await fetch(H,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({applyToAll:!0,baseUrl:e,apiKey:eE(),model:J})}),s=await t.json();if(t.ok&&s.bulk){_(e,{tunnelPublicUrl:j,tailscaleUrl:v});let t=(s.results||[]).filter(e=>"updated"!==e.status);if(0===t.length)z({type:"success",text:`Endpoint and API key applied to ${s.updated} profile(s).`});else{let e=t.map(e=>`${e.profile} — ${e.reason||e.status}`).join("; ");z({type:s.updated>0?"success":"error",text:`Updated ${s.updated} profile(s), skipped ${t.length}: ${e}`})}ew(),eC()}else z({type:"error",text:s.error||"Failed to apply settings"})}catch(e){z({type:"error",text:e.message})}finally{em(!1)}},eM=async()=>{T(!0),z(null);try{let e=await fetch(H,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({profile:eo})}),t=await e.json();e.ok?(z({type:"success",text:`Settings reset for ${e$(eo)}!`}),B(""),V({}),eh(!1),ef(""),eC(),ew()):z({type:"error",text:t.error||"Failed to reset settings"})}catch(e){z({type:"error",text:e.message})}finally{T(!1)}},eP=e=>{Q(e),X(!0)};return(0,a.jsxs)(d.Zp,{padding:"none",className:n().panel,children:[(0,a.jsxs)("div",{className:n().panelHeader,onClick:s,children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(c.default,{src:"/providers/hermes.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===ev&&(0,a.jsx)(r.A,{variant:"success",className:n().status,children:"Connected"}),"not_configured"===ev&&(0,a.jsx)(r.A,{variant:"warning",className:n().status,children:"Not configured"}),"other"===ev&&(0,a.jsx)(r.A,{variant:"default",dot:!1,className:n().status,children:"Other"}),"default"!==eo&&(0,a.jsx)(r.A,{variant:"default",dot:!1,className:`${n().status} font-mono`,title:"Hermes profile shown below",children:eo})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)(l.default,{className:`text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:n().body,children:[M&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,a.jsx)(l.default,{className:"animate-spin",children:"progress_activity"}),(0,a.jsx)("span",{children:"Checking Hermes Agent..."})]}),!M&&$&&!$.installed&&(0,a.jsx)("div",{className:"flex flex-col gap-4",children:(0,a.jsxs)("div",{className:`flex flex-col gap-3 p-4 border ${n().notice} ${n().warning}`,children:[(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)(l.default,{className:"text-[var(--warn)]",children:"warning"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"font-medium text-[var(--warn)]",children:"Hermes Agent not detected locally"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Install: curl -fsSL https://raw.githubusercontent.com/NousResearch/hermes-agent/main/scripts/install.sh | bash"})]})]}),(0,a.jsx)("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 pl-0 sm:pl-9",children:(0,a.jsxs)(d.$n,{variant:"secondary",size:"sm",onClick:()=>ea(!0),className:"w-full sm:w-auto",children:[(0,a.jsx)(l.default,{className:"text-[18px] mr-1",children:"content_copy"}),"Manual Config"]})})]})}),!M&&$?.installed&&(0,a.jsxs)(a.Fragment,{children:[ei.length>1&&(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,a.jsx)("span",{className:`${n().fieldLabel} mr-1`,children:"Profile"}),ei.map(e=>{let t=e.name===eo,s=e.hasJRouter||e.baseUrl&&P(e.baseUrl,{tunnelPublicUrl:j,tailscaleUrl:v})?"configured":e.baseUrl?"other":"not_configured";return(0,a.jsxs)("button",{onClick:()=>{var t;(t=e.name)!==eo&&(ed(t),ej.current=!1,z(null),er(""),eh(!1),ef(""),eC(t))},"aria-pressed":t,title:e.isDefault?`Default profile: ${eN[s]}`:`${e.command}: ${eN[s]}`,className:`flex items-center gap-1.5 px-2 py-1 rounded border text-xs transition-colors ${n().selectButton} ${t?"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,a.jsx)("span",{className:`size-1.5 rounded-full shrink-0 ${eb[s]}`}),(0,a.jsx)("span",{className:"font-medium",children:e.displayName||e.name}),e.displayName&&!e.isDefault&&(0,a.jsx)("span",{className:"font-mono text-[10px] opacity-60",children:e.name})]},e.name)})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[(0,a.jsx)(l.default,{className:"text-[14px] shrink-0",children:"terminal"}),(0,a.jsx)("code",{className:"px-1.5 py-0.5 bg-surface/60 rounded font-mono text-[11px]",children:ei.find(e=>e.name===eo)?.command||"hermes"}),(0,a.jsx)("button",{onClick:()=>ek(ei.find(e=>e.name===eo)?.command||"hermes"),className:`p-0.5 rounded transition-colors ${ex===(ei.find(e=>e.name===eo)?.command||"hermes")?"text-[var(--pos)]":"text-text-muted hover:text-text-main"}`,title:"Copy command",children:(0,a.jsx)(l.default,{className:"text-[14px]",children:ex===(ei.find(e=>e.name===eo)?.command||"hermes")?"check":"content_copy"})}),(0,a.jsx)("span",{className:"hidden sm:inline",children:"Every profile runs as its own agent with its own model."})]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"Select Endpoint"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(E,{value:el||eS(),onChange:er,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:f,tunnelPublicUrl:j,tailscaleEnabled:y,tailscaleUrl:v,currentUrl:ey})]}),$?.settings?.model?.base_url&&(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"Current"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)("span",{className:"min-w-0 truncate rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5",children:$.settings.model.base_url})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"API Key"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(O,{value:K,onChange:F,apiKeys:x,cloudEnabled:p})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"Default Model"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,a.jsx)("input",{type:"text",value:J,onChange:e=>B(e.target.value),placeholder:"provider/model-id",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),J&&(0,a.jsx)("button",{onClick:()=>B(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-[var(--danger)] rounded transition-colors",title:"Clear",children:(0,a.jsx)(l.default,{className:"text-[14px]",children:"close"})})]}),(0,a.jsx)("button",{onClick:()=>eP("default"),disabled:!m,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?"bg-surface border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${n().selectButton}`,children:"Select"})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"Audio STT"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("label",{className:"flex items-center gap-2 text-xs text-text-muted cursor-pointer",title:"Route Hermes voice & audio transcription through jrouter's /v1/audio/transcriptions — usage is tracked on this instance",children:[(0,a.jsx)("input",{type:"checkbox",checked:ep,onChange:e=>eh(e.target.checked),className:"w-3.5 h-3.5 accent-primary cursor-pointer shrink-0"}),(0,a.jsx)("span",{children:"Transcribe voice & audio via jrouter (per-profile)"})]}),(0,a.jsx)("span",{})]}),ep&&(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"STT Model"}),(0,a.jsx)("span",{className:"material-symbols-outlined hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,a.jsx)("input",{type:"text",value:eg,onChange:e=>ef(e.target.value),placeholder:"provider/whisper-model-id",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),eg&&(0,a.jsx)("button",{onClick:()=>ef(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),(0,a.jsx)("button",{onClick:()=>eP("stt"),disabled:!m,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?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"})]}),(0,a.jsxs)("details",{className:"group",children:[(0,a.jsxs)("summary",{className:"cursor-pointer select-none text-xs font-semibold text-text-main hover:text-text-main transition-colors",children:[(0,a.jsx)(l.default,{className:"align-middle text-[16px] text-text-muted group-open:rotate-90 transition-transform",children:"chevron_right"}),"Model Roles (optional)"]}),(0,a.jsxs)("div",{className:"mt-2 flex flex-col gap-1.5",children:[q.map(e=>(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`truncate sm:text-right ${n().fieldLabel}`,title:e.label,children:e.label}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,a.jsx)("input",{type:"text",value:G[e.id]||"",onChange:t=>V(s=>({...s,[e.id]:t.target.value})),placeholder:"inherit default",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),G[e.id]&&(0,a.jsx)("button",{onClick:()=>V(t=>({...t,[e.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,a.jsx)(l.default,{className:"text-[14px]",children:"close"})})]}),(0,a.jsx)("button",{onClick:()=>eP(e.id),disabled:!m,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?"bg-surface border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${n().selectButton}`,children:"Select"})]},e.id)),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Empty roles inherit the default model."})]})]})]}),D&&(0,a.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===D.type?n().positive:n().danger}`,children:[(0,a.jsx)(l.default,{className:"text-[14px]",children:"success"===D.type?"check_circle":"error"}),(0,a.jsx)("span",{children:D.text})]}),(0,a.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2",children:[(0,a.jsxs)(d.$n,{variant:"primary",size:"sm",onClick:eA,disabled:!J||ep&&!eg.trim(),title:ep&&!eg.trim()?"Select an STT model first":void 0,loading:U,className:"w-full sm:w-auto",children:[(0,a.jsx)(l.default,{className:"text-[14px] mr-1",children:"save"}),"Apply"]}),ei.length>1&&(0,a.jsxs)(d.$n,{variant:"secondary",size:"sm",onClick:eO,loading:ec,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,a.jsx)(l.default,{className:"text-[14px] mr-1",children:"groups"}),"Apply to All Profiles"]}),(0,a.jsxs)(d.$n,{variant:"outline",size:"sm",onClick:eM,disabled:!$?.hasJRouter&&!$?.hasJRouterStt,loading:R,className:"w-full sm:w-auto",children:[(0,a.jsx)(l.default,{className:"text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,a.jsxs)(d.$n,{variant:"ghost",size:"sm",onClick:()=>ea(!0),className:"w-full sm:w-auto",children:[(0,a.jsx)(l.default,{className:"text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),Z&&(0,a.jsx)(d.rq,{catalogContext:"invocation",className:n().modelPicker,isOpen:Z,onClose:()=>X(!1),onSelect:e=>{"stt"===Y?ef(e.value):"default"===Y?B(e.value):V(t=>({...t,[Y]:e.value})),X(!1)},selectedModel:"stt"===Y?eg:"default"===Y?J:G[Y]||"",activeProviders:u,modelAliases:ee,kindFilter:"stt"===Y?"stt":void 0,title:"stt"===Y?"Select STT Model — audio transcription via jrouter":`Select Model for Hermes Agent${"default"!==Y?` — ${q.find(e=>e.id===Y)?.label||Y}`:""}`}),(0,a.jsx)(d.uR,{isOpen:es,onClose:()=>ea(!1),title:"Hermes Agent - Manual Configuration",configs:(b=K&&K.trim()?K:p?"<API_KEY_FROM_DASHBOARD>":"sk_jrouter",N=eS(),w="default"===eo?"~/.hermes":`~/.hermes/profiles/${eo}`,k=ei.find(e=>e.name===eo)?.command||"hermes",C=`# Run this profile: ${k}
59
+ model:
60
+ default: "${J||"provider/model-id"}"
61
+ provider: "custom"
62
+ base_url: "${N}"
63
+ api_key: \${OPENAI_API_KEY}
64
+ `,G.delegation?.trim()&&(C+=`delegation:
65
+ model: "${G.delegation.trim()}"
66
+ provider: "custom"
67
+ base_url: "${N}"
68
+ api_key: \${OPENAI_API_KEY}
69
+ `),(S=Object.entries(G).filter(([e,t])=>"delegation"!==e&&t?.trim())).length>0&&(C+=`auxiliary:
70
+ ${S.map(([e,t])=>` ${e}:
71
+ provider: "custom"
72
+ model: "${t.trim()}"
73
+ base_url: "${N}"
74
+ api_key: \${OPENAI_API_KEY}
75
+ `).join("")}`),ep&&eg.trim()&&(C+=`stt:
76
+ enabled: true
77
+ provider: "openai"
78
+ openai:
79
+ model: "${eg.trim()}"
80
+ base_url: "${N}"
81
+ api_key: \${OPENAI_API_KEY}
82
+ `),[{filename:`${w}/config.yaml`,content:C},{filename:`${w}/.env`,content:`OPENAI_API_KEY=${b}
83
+ `}])})]})}var G=s(8247),V=s(11059);function Y({toolId:e,tool:t,isExpanded:s,onToggle:r,baseUrl:i,apiKeys:m,activeProviders:x=[],cloudEnabled:u=!1,tunnelEnabled:p=!1}){let[h,g]=(0,o.useState)(null),[f,j]=(0,o.useState)(!1),[y,v]=(0,o.useState)(""),[b,N]=(0,o.useState)(()=>m?.length>0?m[0].key:""),w=e=>{let t=b&&b.trim()?b:u?"your-api-key":"sk_jrouter",s=i||"http://localhost:20128",a=s.endsWith("/v1")?s:`${s}/v1`;return e.replace(/\{\{baseUrl\}\}/g,a).replace(/\{\{apiKey\}\}/g,t).replace(/\{\{model\}\}/g,y||"provider/model-id")},{copy:_}=(0,V.C)(),k=async(e,t)=>{await _(w(e),`toolcard-${t}`),g(t),setTimeout(()=>g(null),2e3)},C=x.length>0,S=()=>(!t.requiresExternalUrl||!!u||!!p)&&(!t.requiresCloud||!!u);return(0,a.jsxs)(d.Zp,{padding:"none",className:n().panel,children:[(0,a.jsxs)("div",{className:n().panelHeader,onClick:r,children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 rounded-lg flex items-center justify-center shrink-0",children:(()=>{if(t.image)return(0,a.jsx)(c.default,{src:t.image,alt:t.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"},loading:"lazy",decoding:"async"});if(t.icon)return(0,a.jsx)(l.default,{className:"text-xl",style:{color:t.color},children:t.icon});let s=(0,G.HY)(e);return s?(0,a.jsx)(c.default,{src:s,alt:t.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:t=>{(0,G.Kw)(e),t.target.style.display="none"},loading:"lazy",decoding:"async"}):(0,a.jsx)("span",{className:"text-xs font-bold",style:{color:t.color},children:(e||"?").slice(0,2).toUpperCase()})})()}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:t.name}),(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:t.description})]})]}),(0,a.jsx)(l.default,{className:`text-text-muted text-[20px] transition-transform ${s?"rotate-180":""}`,children:"expand_more"})]}),s&&(0,a.jsx)("div",{className:n().body,children:t.guideSteps?(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[t.notes&&0!==t.notes.length?(0,a.jsx)("div",{className:"flex flex-col gap-2 mb-4",children:t.notes.map((e,t)=>{if("cloudCheck"===e.type&&(u||p))return null;let s="warning"===e.type,r="cloudCheck"===e.type&&!u&&!p,i=n().neutral,o="text-text-muted",d="text-text-muted",c="info";return s?(i=n().warning,o="text-[var(--warn)]",d="text-[var(--warn)]",c="warning"):r&&(i=n().danger,o="text-[var(--danger)]",d="text-[var(--danger)]",c="error"),(0,a.jsxs)("div",{className:`flex items-start gap-3 p-3 rounded-lg border ${i}`,children:[(0,a.jsx)(l.default,{className:`text-lg ${d}`,children:c}),(0,a.jsx)("p",{className:`text-xs ${o}`,children:e.text})]},t)})}):null,S()&&t.guideSteps.map(e=>(0,a.jsxs)("div",{className:"flex items-start gap-4",children:[(0,a.jsx)("div",{className:"size-8 rounded-full flex items-center justify-center shrink-0 text-sm font-semibold text-white",style:{backgroundColor:t.color},children:e.step}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"font-medium text-text",children:e.title}),e.desc&&(0,a.jsx)("p",{className:"text-xs text-text-muted mt-0.5",children:e.desc}),"apiKeySelector"===e.type&&(0,a.jsx)("div",{className:"mt-2 flex flex-col sm:flex-row sm:items-center gap-2",children:(0,a.jsx)(O,{value:b,onChange:N,apiKeys:m,cloudEnabled:u,className:"flex-1"})}),"modelSelector"===e.type&&(0,a.jsxs)("div",{className:"mt-2 flex flex-col sm:flex-row sm:items-center gap-2",children:[(0,a.jsx)("input",{type:"text",value:y,onChange:e=>v(e.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,a.jsx)("button",{onClick:()=>j(!0),disabled:!C,className:`shrink-0 px-3 py-2 rounded-lg border text-sm transition-colors ${C?"bg-bg-secondary border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${n().selectButton}`,children:"Select Model"}),y&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("button",{onClick:()=>k(y,"model"),className:n().iconButton,"aria-label":"Copy model",children:(0,a.jsx)(l.default,{className:"text-lg",children:"model"===h?"check":"content_copy"})}),(0,a.jsx)("button",{onClick:()=>v(""),className:"p-2 text-text-muted hover:text-[var(--danger)] rounded transition-colors",title:"Clear",children:(0,a.jsx)(l.default,{className:"text-lg",children:"close"})})]})]}),e.value&&(0,a.jsxs)("div",{className:"mt-2 flex flex-col sm:flex-row sm:items-center gap-2",children:[(0,a.jsx)("code",{className:"w-full 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:w(e.value)}),e.copyable&&(0,a.jsx)("button",{onClick:()=>k(e.value,`${e.step}-${e.title}`),className:n().iconButton,"aria-label":"Copy value",children:(0,a.jsx)(l.default,{className:"text-lg",children:h===`${e.step}-${e.title}`?"check":"content_copy"})})]})]})]},e.step)),S()&&t.codeBlock&&(0,a.jsxs)("div",{className:"mt-2",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,a.jsx)("span",{className:"text-xs text-text-muted uppercase tracking-wide",children:t.codeBlock.language}),(0,a.jsxs)("button",{onClick:()=>k(t.codeBlock.code,"codeblock"),className:"flex items-center gap-1 px-2 py-1 text-xs bg-bg-secondary hover:bg-bg-tertiary rounded border border-border transition-colors",children:[(0,a.jsx)(l.default,{className:"text-sm",children:"codeblock"===h?"check":"content_copy"}),"codeblock"===h?"Copied!":"Copy"]})]}),(0,a.jsx)("pre",{className:"p-4 bg-bg-secondary rounded-lg border border-border overflow-x-auto",children:(0,a.jsx)("code",{className:"whitespace-pre",children:w(t.codeBlock.code)})})]})]}):(0,a.jsx)("p",{className:"text-text-muted text-sm",children:"Coming soon..."})}),f&&(0,a.jsx)(d.rq,{className:n().modelPicker,isOpen:f,onClose:()=>j(!1),onSelect:e=>{v(e.value)},selectedModel:y,activeProviders:x,title:"Select Model"})]})}function Q({tool:e,isExpanded:t,onToggle:s,baseUrl:i,apiKeys:m,activeProviders:x,cloudEnabled:u,initialStatus:p,tunnelEnabled:h,tunnelPublicUrl:g,tailscaleEnabled:f,tailscaleUrl:j}){let y,v,b,N,w,[k,C]=(0,o.useState)(p||null),[S,$]=(0,o.useState)(!1),[A,M]=(0,o.useState)(!1),[I,U]=(0,o.useState)(!1),[L,R]=(0,o.useState)(null),[T,D]=(0,o.useState)(!1),[z,K]=(0,o.useState)(""),[F,J]=(0,o.useState)(""),[B,H]=(0,o.useState)(""),[q,W]=(0,o.useState)(!1),[G,V]=(0,o.useState)(!1),[Y,Z]=(0,o.useState)({}),[X,ee]=(0,o.useState)(!1),[et,es]=(0,o.useState)(""),[ea,el]=(0,o.useState)([]),[er,ei]=(0,o.useState)(""),en=(0,o.useRef)([]);(0,o.useEffect)(()=>{en.current=ea},[ea]),(0,o.useEffect)(()=>{m?.length>0&&!z&&K(m[0].key)},[m,z]),(0,o.useEffect)(()=>{p&&C(p)},[p]),(0,o.useEffect)(()=>{t&&(k||eu(),eo())},[t]),(0,o.useEffect)(()=>{k?.opencode?.models&&el(k.opencode.models),k?.opencode?.activeModel&&ei(k.opencode.activeModel),k?.config?.agent?.explorer?.model?.startsWith("jrouter/")&&H(k.config.agent.explorer.model.replace("jrouter/",""))},[k]);let eo=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&Z(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}},ed=async e=>{try{let t=z&&z.trim()||u?z:"sk_jrouter",s=e.includes(er)?er:e[0]||"";await fetch("/api/cli-tools/opencode-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:ex(),apiKey:t,models:e,activeModel:s,subagentModel:B})})}catch(e){console.log("Error saving models:",e)}},ec=k?.config?.provider?.jrouter?.options?.baseURL||"",em=k?.installed?k.config&&k.hasJRouter?P(k.config?.provider?.jrouter?.options?.baseURL||"",{tunnelPublicUrl:g,tailscaleUrl:j})?"configured":"other":"not_configured":null,ex=()=>{let e=et||i;return e.endsWith("/v1")?e:`${e}/v1`},eu=async()=>{$(!0);try{let e=await fetch("/api/cli-tools/opencode-settings"),t=await e.json();C(t)}catch(e){C({installed:!1,error:e.message})}finally{$(!1)}},ep=async()=>{M(!0),R(null);try{let e=z&&z.trim()||u?z:"sk_jrouter",t=await fetch("/api/cli-tools/opencode-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:ex(),apiKey:e,models:ea,activeModel:""===er?"":er||ea[0],subagentModel:B})}),s=await t.json();t.ok?(_(ex(),{tunnelPublicUrl:g,tailscaleUrl:j}),R({type:"success",text:"Settings applied successfully!"}),eu()):R({type:"error",text:s.error||"Failed to apply settings"})}catch(e){R({type:"error",text:e.message})}finally{M(!1)}},eh=async()=>{U(!0),R(null);try{let e=await fetch("/api/cli-tools/opencode-settings",{method:"DELETE"}),t=await e.json();e.ok?(R({type:"success",text:"Settings reset successfully!"}),J(""),H(""),el([]),ei(""),eu()):R({type:"error",text:t.error||"Failed to reset settings"})}catch(e){R({type:"error",text:e.message})}finally{U(!1)}};return(0,a.jsxs)(d.Zp,{padding:"none",className:n().panel,children:[(0,a.jsxs)("div",{className:n().panelHeader,onClick:s,children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(c.default,{src:"/providers/opencode.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===em&&(0,a.jsx)(r.A,{variant:"success",className:n().status,children:"Connected"}),"not_configured"===em&&(0,a.jsx)(r.A,{variant:"warning",className:n().status,children:"Not configured"}),"other"===em&&(0,a.jsx)(r.A,{variant:"default",dot:!1,className:n().status,children:"Other"})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)(l.default,{className:`text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:n().body,children:[S&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,a.jsx)(l.default,{className:"animate-spin",children:"progress_activity"}),(0,a.jsx)("span",{children:"Checking OpenCode CLI..."})]}),!S&&k&&!k.installed&&(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:`flex flex-col gap-3 p-4 border ${n().notice} ${n().warning}`,children:[(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)(l.default,{className:"text-[var(--warn)]",children:"warning"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"font-medium text-[var(--warn)]",children:"OpenCode CLI not detected locally"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if JRouter is deployed on a remote server."})]})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2 sm:pl-9",children:[(0,a.jsxs)(d.$n,{variant:"secondary",size:"sm",onClick:()=>ee(!0),children:[(0,a.jsx)(l.default,{className:"text-[18px] mr-1",children:"content_copy"}),"Manual Config"]}),(0,a.jsxs)(d.$n,{variant:"outline",size:"sm",onClick:()=>D(!T),children:[(0,a.jsx)(l.default,{className:"text-[18px] mr-1",children:T?"expand_less":"help"}),T?"Hide":"How to Install"]})]})]}),T&&(0,a.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,a.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,a.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-text-muted mb-1",children:"macOS / Linux:"}),(0,a.jsx)("code",{className:"block px-3 py-2 bg-black/5 dark:bg-white/5 rounded font-mono text-xs",children:"npm install -g opencode-ai"})]}),(0,a.jsxs)("p",{className:"text-text-muted",children:["After installation, run ",(0,a.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"opencode"})," to verify."]})]})]})]}),!S&&k?.installed&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"Select Endpoint"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(E,{value:et||et||`${i}/v1`,onChange:es,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:h,tunnelPublicUrl:g,tailscaleEnabled:f,tailscaleUrl:j,currentUrl:ec})]}),k?.config?.provider?.jrouter?.options?.baseURL&&(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"Current"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)("span",{className:"min-w-0 truncate rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5",children:k.config.provider.jrouter.options.baseURL})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"API Key"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(O,{value:z,onChange:K,apiKeys:m,cloudEnabled:u})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-start sm:gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right pt-1",children:"Models"}),(0,a.jsx)(l.default,{className:"text-text-muted text-[14px] mt-1.5",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"flex-1 flex flex-col gap-2",children:[(0,a.jsx)("div",{className:"flex flex-wrap gap-1.5 min-h-[28px] px-2 py-1.5 bg-surface rounded border border-border",children:0===ea.length?(0,a.jsx)("span",{className:"text-xs text-text-muted",children:"No models selected"}):ea.map(e=>(0,a.jsxs)("span",{onClick:async()=>{if(e===er)try{(await fetch("/api/cli-tools/opencode-settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({clearActiveModel:!0})})).ok&&(ei(""),eu())}catch(e){console.log("Error clearing active model:",e)}else ei(e)},className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs cursor-pointer transition-colors ${e===er?"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:e===er?"Click to clear active model":"Click to set as active",children:[e===er&&(0,a.jsx)(l.default,{className:"text-[10px]",children:"star"}),e,(0,a.jsx)("button",{onClick:async t=>{t.stopPropagation();try{if((await fetch(`/api/cli-tools/opencode-settings?model=${encodeURIComponent(e)}`,{method:"DELETE"})).ok){let t=ea.filter(t=>t!==e);el(t),er===e&&ei(""),eu()}}catch(e){console.log("Error removing model:",e)}},className:"ml-0.5 hover:text-[var(--danger)]",children:(0,a.jsx)(l.default,{className:"text-[12px]",children:"close"})})]},e))}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("button",{onClick:()=>W(!0),disabled:!x?.length,className:`px-2 py-1 rounded border text-xs transition-colors ${x?.length?"bg-surface border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${n().selectButton}`,children:"Add Model"}),(0,a.jsx)("span",{className:"text-xs text-text-muted",children:ea.length>0&&er?(0,a.jsxs)(a.Fragment,{children:["Active: ",(0,a.jsx)("span",{className:"text-text-main",children:er})]}):ea.length>0?(0,a.jsx)("span",{className:"text-[var(--warn)]",children:"Click a model to set/clear active"}):"Select models to add"})]})]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"Subagent Model"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)("input",{type:"text",value:B,onChange:e=>H(e.target.value),placeholder:F||"provider/model-id (defaults to main model)",className:"w-full min-w-0 px-2 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),(0,a.jsx)("button",{onClick:()=>V(!0),disabled:!x?.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 ${x?.length?"bg-surface border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${n().selectButton}`,children:"Select Model"}),B&&(0,a.jsx)("button",{onClick:()=>H(""),className:"p-1 text-text-muted hover:text-[var(--danger)] rounded transition-colors",title:"Clear (will use main model)",children:(0,a.jsx)(l.default,{className:"text-[14px]",children:"close"})})]})]}),L&&(0,a.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===L.type?n().positive:n().danger}`,children:[(0,a.jsx)(l.default,{className:"text-[14px]",children:"success"===L.type?"check_circle":"error"}),(0,a.jsx)("span",{children:L.text})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,a.jsxs)(d.$n,{variant:"primary",size:"sm",onClick:ep,disabled:0===ea.length,loading:A,children:[(0,a.jsx)(l.default,{className:"text-[14px] mr-1",children:"save"}),"Apply"]}),(0,a.jsxs)(d.$n,{variant:"outline",size:"sm",onClick:eh,disabled:!k.hasJRouter,loading:I,children:[(0,a.jsx)(l.default,{className:"text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,a.jsxs)(d.$n,{variant:"ghost",size:"sm",onClick:()=>ee(!0),children:[(0,a.jsx)(l.default,{className:"text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),q&&(0,a.jsx)(d.rq,{className:n().modelPicker,isOpen:q,onClose:()=>{W(!1),ed(en.current)},onSelect:e=>{!ea.includes(e.value)&&(el([...ea,e.value]),er||ei(e.value))},onDeselect:e=>{let t=ea.filter(t=>t!==e.value);el(t),er===e.value&&ei(t[0]||"")},selectedModel:null,activeProviders:x,modelAliases:Y,addedModelValues:ea,closeOnSelect:!1,title:"Add Model for OpenCode"}),G&&(0,a.jsx)(d.rq,{className:n().modelPicker,isOpen:G,onClose:()=>V(!1),onSelect:e=>{H(e.value),V(!1)},selectedModel:B,activeProviders:x,modelAliases:Y,title:"Select Subagent Model for OpenCode"}),(0,a.jsx)(d.uR,{isOpen:X,onClose:()=>ee(!1),title:"OpenCode - Manual Configuration",configs:(y=z&&z.trim()?z:u?"<API_KEY_FROM_DASHBOARD>":"sk_jrouter",v=ea.length>0?ea:["provider/model-id"],b=er||ea[0]||v[0],N=B||b,w={},v.forEach(e=>{w[e]={name:e,modalities:{input:["text","image"],output:["text"]}}}),[{filename:"~/.config/opencode/opencode.json",content:JSON.stringify({provider:{jrouter:{npm:"@ai-sdk/openai-compatible",options:{baseURL:ex(),apiKey:y},models:w}},model:`jrouter/${b}`,agent:{explorer:{description:"Fast explorer subagent for codebase exploration",mode:"subagent",model:`jrouter/${N}`}}},null,2)}])})]})}let Z="/api/cli-tools/cowork-settings",X=e=>(e||"").replace(/\/v1\/?$/,"");function ee({tool:e,isExpanded:t,onToggle:s,baseUrl:i,apiKeys:m,activeProviders:x,hasActiveProviders:u,cloudEnabled:p,cloudUrl:h,tunnelEnabled:g,tunnelPublicUrl:f,tailscaleEnabled:j,tailscaleUrl:y,initialStatus:v}){let b,N,w,k,[C,S]=(0,o.useState)(v||null),[$,A]=(0,o.useState)(!1),[M,P]=(0,o.useState)(!1),[I,U]=(0,o.useState)(!1),[L,R]=(0,o.useState)(null),[T,D]=(0,o.useState)(""),[z,K]=(0,o.useState)([]),[F,J]=(0,o.useState)(!1),[B,H]=(0,o.useState)(""),[q,W]=(0,o.useState)([]),[G,V]=(0,o.useState)([]),[Y,Q]=(0,o.useState)([]),[et,es]=(0,o.useState)({}),[ea,el]=(0,o.useState)(!1),[er,ei]=(0,o.useState)(!1),[en,eo]=(0,o.useState)(!1),[ed,ec]=(0,o.useState)(!1),[em,ex]=(0,o.useState)({name:"",url:""});(0,o.useEffect)(()=>{m?.length>0&&!T&&D(m[0].key)},[m,T]),(0,o.useEffect)(()=>{v&&S(v)},[v]),(0,o.useEffect)(()=>{t&&!C&&eu()},[t]),(0,o.useEffect)(()=>{t&&fetch("/api/models/alias").then(e=>e.ok?e.json():null).then(e=>{e&&es(e.aliases||{})}).catch(()=>{})},[t]),(0,o.useEffect)(()=>{C?.cowork?.models?.length&&K(C.cowork.models),C?.cowork?.baseUrl&&!B&&H(X(C.cowork.baseUrl)),Array.isArray(C?.cowork?.plugins)&&C.cowork.plugins.length>0?W(C.cowork.plugins):0===q.length&&Array.isArray(C?.defaultPlugins)&&W(C.defaultPlugins),Array.isArray(C?.cowork?.localPlugins)&&V(C.cowork.localPlugins),Array.isArray(C?.cowork?.customPlugins)&&C.cowork.customPlugins.length>0&&Q(C.cowork.customPlugins)},[C]);let eu=async()=>{A(!0);try{let e=await fetch(Z),t=await e.json();S(t)}catch(e){S({installed:!1,error:e.message})}finally{A(!1)}},ep=()=>{let e;return(e=(B||"").replace(/\/+$/,""))?/\/v1$/.test(e)?e:`${e}/v1`:""},eh=C?.cowork?.baseUrl||"",eg=C?.installed?C?.cowork?.baseUrl?C.hasJRouter?"configured":"other":"not_configured":null,ef=async()=>{R(null);let e=ep();if(0===z.length)return void R({type:"error",text:"Please select at least one model"});P(!0);try{let t=T?.trim()||(m?.length>0?m[0].key:null)||(p?null:"sk_jrouter"),s=await fetch(Z,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:e,apiKey:t,models:z,plugins:q,localPlugins:G,customPlugins:Y})}),a=await s.json();s.ok?(_(ep(),{tunnelPublicUrl:f,tailscaleUrl:y}),R({type:"success",text:"Settings applied. Quit & reopen Claude Desktop to load."}),eu()):R({type:"error",text:a.error||"Failed to apply settings"})}catch(e){R({type:"error",text:e.message})}finally{P(!1)}},ej=async({name:e,models:t})=>{try{let s=await fetch("/api/combos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,models:t})});if(!s.ok){let e=await s.json();R({type:"error",text:e.error||"Failed to create combo"});return}z.includes(e)||K([...z,e]),el(!1),R({type:"success",text:`Combo "${e}" created and added.`})}catch(e){R({type:"error",text:e.message})}},ey=e=>{let t=e?.value||e?.name||e;K(e=>e.filter(e=>e!==t))},ev=async()=>{U(!0),R(null);try{let e=await fetch(Z,{method:"DELETE"}),t=await e.json();e.ok?(R({type:"success",text:"Settings reset successfully"}),K([]),W(C?.defaultPlugins||[]),V([]),Q([]),eu()):R({type:"error",text:t.error||"Failed to reset"})}catch(e){R({type:"error",text:e.message})}finally{U(!1)}};return(0,a.jsxs)(d.Zp,{padding:"none",className:n().panel,children:[(0,a.jsxs)("div",{className:n().panelHeader,onClick:s,children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(c.default,{src:e.image,alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===eg&&(0,a.jsx)(r.A,{variant:"success",className:n().status,children:"Connected"}),"not_configured"===eg&&(0,a.jsx)(r.A,{variant:"warning",className:n().status,children:"Not configured"}),"other"===eg&&(0,a.jsx)(r.A,{variant:"default",dot:!1,className:n().status,children:"Other"})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)(l.default,{className:`text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:n().body,children:[$&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,a.jsx)(l.default,{className:"animate-spin",children:"progress_activity"}),(0,a.jsx)("span",{children:"Checking Claude Cowork..."})]}),!$&&C&&!C.installed&&(0,a.jsxs)("div",{className:`flex flex-col gap-3 p-4 border ${n().notice} ${n().warning}`,children:[(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)(l.default,{className:"text-[var(--warn)]",children:"warning"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"font-medium text-[var(--warn)]",children:"Claude Desktop (Cowork mode) not detected"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Open Claude Desktop → Help → Troubleshooting → Enable Developer mode → Configure third-party inference, then return here."})]})]}),(0,a.jsx)("div",{className:"pl-9",children:(0,a.jsxs)(d.$n,{variant:"secondary",size:"sm",onClick:()=>J(!0),children:[(0,a.jsx)(l.default,{className:"text-[18px] mr-1",children:"content_copy"}),"Manual Config"]})})]}),!$&&C?.installed&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"Select Endpoint"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(E,{value:ep(),onChange:e=>H(X(e)),tunnelEnabled:g,tunnelPublicUrl:f,tailscaleEnabled:j,tailscaleUrl:y,cloudEnabled:p,cloudUrl:h,currentUrl:eh})]}),C?.cowork?.baseUrl&&(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"Current"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)("span",{className:"min-w-0 truncate rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5",children:C.cowork.baseUrl})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"API Key"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(O,{value:T,onChange:D,apiKeys:m,cloudEnabled:p})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:"Models"}),(0,a.jsx)(l.default,{className:"text-text-muted text-[14px]",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"flex-1 flex items-center gap-2",children:[(0,a.jsx)("div",{className:"flex-1 flex flex-wrap gap-1.5 min-h-[28px] px-2 py-1.5 bg-surface rounded border border-border",children:0===z.length?(0,a.jsx)("span",{className:"text-xs text-text-muted",children:"No models selected"}):z.map(e=>(0,a.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs bg-black/5 dark:bg-white/5 text-text-muted border border-transparent hover:border-border",children:[e,(0,a.jsx)("button",{onClick:()=>ey(e),className:"ml-0.5 hover:text-[var(--danger)]",children:(0,a.jsx)(l.default,{className:"text-[12px]",children:"close"})})]},e))}),(0,a.jsx)("button",{onClick:()=>el(!0),disabled:!u,className:`shrink-0 px-2 py-1.5 rounded border text-xs whitespace-nowrap transition-colors ${u?"bg-surface-2 border-border text-text-main hover:bg-surface-2 cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${n().selectButton}`,children:"+ Combo"})]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-start sm:gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right pt-2",children:"MCP"}),(0,a.jsx)(l.default,{className:"text-text-muted text-[14px] mt-2",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"flex-1 flex flex-col gap-1",children:[q.filter(e=>"exa"!==e.name).map(e=>(0,a.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1 bg-surface rounded border border-border",children:[(0,a.jsx)("span",{className:"text-xs font-medium min-w-0 truncate flex-shrink-0",children:e.title||e.name}),e.oauth&&(0,a.jsx)("span",{className:"text-[8px] text-amber-600 shrink-0",children:"OAuth"}),(0,a.jsxs)("div",{className:"flex-1 flex flex-wrap gap-1 overflow-hidden",style:{maxHeight:"1.5rem"},children:[Array.isArray(e.toolNames)&&e.toolNames.slice(0,6).map(e=>(0,a.jsx)("span",{className:"text-[9px] px-1 py-0.5 rounded bg-black/5 dark:bg-white/5 text-text-muted whitespace-nowrap",children:e},e)),Array.isArray(e.toolNames)&&e.toolNames.length>6&&(0,a.jsxs)("span",{className:"text-[9px] px-1 py-0.5 rounded bg-black/5 dark:bg-white/5 text-text-muted whitespace-nowrap",children:["+",e.toolNames.length-6]})]}),(0,a.jsx)("button",{onClick:()=>{var t;return t=e.name,void W(q.filter(e=>e.name!==t))},className:"shrink-0 hover:text-[var(--danger)] ml-auto",children:(0,a.jsx)(l.default,{className:"text-[12px]",children:"close"})})]},e.name)),Y.map(e=>(0,a.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1 bg-surface rounded border border-border",children:[(0,a.jsx)("span",{className:"text-xs font-medium min-w-0 truncate flex-shrink-0",children:e.name}),(0,a.jsx)("span",{className:"badge-neutral shrink-0",children:"custom"}),(0,a.jsx)("span",{className:"flex-1 text-[9px] text-text-muted truncate",children:e.url}),(0,a.jsx)("button",{onClick:()=>Q(Y.filter(t=>t.name!==e.name)),className:"shrink-0 hover:text-[var(--danger)] ml-auto",children:(0,a.jsx)(l.default,{className:"text-[12px]",children:"close"})})]},e.name)),0===q.filter(e=>"exa"!==e.name).length&&0===Y.length&&(0,a.jsx)("div",{className:"px-2 py-1.5 bg-surface rounded border border-border text-xs text-text-muted",children:"No MCPs added"}),(0,a.jsxs)("div",{className:"flex items-center gap-2 mt-0.5",children:[(0,a.jsx)("button",{onClick:()=>eo(!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,a.jsx)("button",{onClick:()=>{ex({name:"",url:""}),ec(!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,a.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,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-start sm:gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right pt-1",children:"Tools"}),(0,a.jsx)(l.default,{className:"text-text-muted text-[14px] mt-1.5",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"flex-1 flex flex-col gap-1.5",children:[(b=q.some(e=>"exa"===e.name),N=(C?.defaultPlugins||[]).find(e=>"exa"===e.name),(0,a.jsxs)("label",{className:"flex items-start gap-2 cursor-pointer px-2 py-1.5 bg-surface rounded border border-border",children:[(0,a.jsx)("input",{type:"checkbox",checked:b,onChange:e=>{e.target.checked&&N?W([...q.filter(e=>"exa"!==e.name),N]):W(q.filter(e=>"exa"!==e.name))},className:"mt-0.5"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("div",{className:"text-xs font-medium",children:"Web Search & Fetch (Exa)"}),(0,a.jsx)("p",{className:"text-[10px] text-text-muted leading-snug",children:"Replaces built-in WebSearch/WebFetch. Auto-strips duplicates from tool list."})]})]})),(()=>{let e=(C?.localStdioPlugins||[]).find(e=>"browsermcp"===e.name);if(!e)return null;let t=G.includes("browsermcp");return(0,a.jsxs)("label",{className:"flex items-start gap-2 cursor-pointer px-2 py-1.5 bg-surface rounded border border-border",children:[(0,a.jsx)("input",{type:"checkbox",checked:t,onChange:e=>V(e.target.checked?[...G,"browsermcp"]:G.filter(e=>"browsermcp"!==e)),className:"mt-0.5"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("div",{className:"text-xs font-medium",children:"Browser Control (Browser MCP)"}),(0,a.jsxs)("p",{className:"text-[10px] text-text-muted leading-snug",children:["Controls your running Chrome. Auto-strips Cowork's built-in browser tools."," ",(0,a.jsx)("a",{href:e.extensionUrl,target:"_blank",rel:"noopener noreferrer",className:"text-text-main underline",children:"Install Chrome extension"})]})]})]})})()]})]}),Array.isArray(C?.localStdioPlugins)&&C.localStdioPlugins.filter(e=>"browsermcp"!==e.name).length>0&&(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-start sm:gap-2",children:[(0,a.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right pt-1",children:"Local Plugins"}),(0,a.jsx)(l.default,{className:"text-text-muted text-[14px] mt-1.5",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"flex-1 flex flex-col gap-2",children:[(0,a.jsx)("div",{className:"flex flex-col gap-1.5 px-2 py-1.5 bg-surface rounded border border-border",children:C.localStdioPlugins.filter(e=>"browsermcp"!==e.name).map(e=>{let t=G.includes(e.name);return(0,a.jsxs)("label",{className:"flex items-start gap-2 cursor-pointer",children:[(0,a.jsx)("input",{type:"checkbox",checked:t,onChange:t=>V(t.target.checked?[...G,e.name]:G.filter(t=>t!==e.name)),className:"mt-0.5"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,a.jsx)("span",{className:"text-xs font-medium",children:e.title}),(0,a.jsx)("span",{className:"text-[8px] text-amber-600",children:"stdio"})]}),(0,a.jsx)("p",{className:"text-[10px] text-text-muted leading-snug",children:e.description}),e.extensionUrl&&(0,a.jsx)("a",{href:e.extensionUrl,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-text-main underline",children:"Install Chrome extension"})]})]},e.name)})}),(0,a.jsxs)("p",{className:"text-[10px] text-text-muted leading-snug",children:["⚠️ Local plugins run as subprocess via ",(0,a.jsx)("code",{className:"px-1 py-0.5 rounded bg-black/5 dark:bg-white/5",children:"npx"}),". Requires Node.js installed."]})]})]})]}),L&&(0,a.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===L.type?n().positive:n().danger}`,children:[(0,a.jsx)(l.default,{className:"text-[14px]",children:"success"===L.type?"check_circle":"error"}),(0,a.jsx)("span",{children:L.text})]}),(0,a.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2",children:[(0,a.jsxs)(d.$n,{variant:"primary",size:"sm",onClick:ef,disabled:0===z.length,loading:M,className:"w-full sm:w-auto",children:[(0,a.jsx)(l.default,{className:"text-[14px] mr-1",children:"save"}),"Apply"]}),(0,a.jsxs)(d.$n,{variant:"outline",size:"sm",onClick:ev,disabled:!C.hasJRouter,loading:I,className:"w-full sm:w-auto",children:[(0,a.jsx)(l.default,{className:"text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,a.jsxs)(d.$n,{variant:"ghost",size:"sm",onClick:()=>J(!0),className:"w-full sm:w-auto",children:[(0,a.jsx)(l.default,{className:"text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),(0,a.jsx)(d.uR,{isOpen:F,onClose:()=>J(!1),title:"Claude Cowork - Manual Configuration",configs:(w=T&&T.trim()?T:p?"<API_KEY_FROM_DASHBOARD>":"sk_jrouter",k=z.length>0?z:["provider/model-id"],[{filename:"~/Library/Application Support/Claude-3p/configLibrary/<appliedId>.json",content:JSON.stringify({inferenceProvider:"gateway",inferenceGatewayBaseUrl:ep()||"https://your-public-host/v1",inferenceGatewayApiKey:w,inferenceModels:k.map(e=>({name:e}))},null,2)}])}),ea&&(0,a.jsx)(d.CK,{isOpen:ea,combo:null,onClose:()=>el(!1),onSave:ej,activeProviders:x,forcePrefix:"claude-",title:"Create Cowork Combo"}),er&&(0,a.jsx)(d.rq,{className:n().modelPicker,isOpen:er,onClose:()=>ei(!1),onSelect:e=>{let t=e?.value||e?.name||e;!t||z.includes(t)||K(e=>[...e,t])},onDeselect:ey,activeProviders:x,modelAliases:et,title:"Select Cowork Model",addedModelValues:z,closeOnSelect:!1}),(0,a.jsx)(d.Nf,{isOpen:en,onClose:()=>eo(!1),onAdd:e=>{q.some(t=>t.name===e.name)||W([...q,e])},addedNames:q.map(e=>e.name)}),ed&&(0,a.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40",onClick:()=>ec(!1),children:(0,a.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:e=>e.stopPropagation(),children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("h3",{className:"font-semibold text-sm",children:"Add Custom MCP"}),(0,a.jsx)("button",{onClick:()=>ec(!1),className:"text-text-muted hover:text-text-main",children:(0,a.jsx)(l.default,{className:"text-[18px]",children:"close"})})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,a.jsx)("label",{className:"text-[11px] text-text-muted font-medium",children:"Name"}),(0,a.jsx)("input",{type:"text",placeholder:"my-mcp",value:em.name,onChange:e=>ex(t=>({...t,name:e.target.value.replace(/\s+/g,"-").toLowerCase()})),className:"px-2 py-1.5 rounded border border-border bg-surface text-xs"})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,a.jsx)("label",{className:"text-[11px] text-text-muted font-medium",children:"SSE URL"}),(0,a.jsx)("input",{type:"text",placeholder:"https://your-mcp-server.com/sse",value:em.url,onChange:e=>ex(t=>({...t,url:e.target.value})),className:"px-2 py-1.5 rounded border border-border bg-surface text-xs"})]})]}),(0,a.jsxs)("div",{className:"flex gap-2 justify-end",children:[(0,a.jsx)("button",{onClick:()=>ec(!1),className:"px-3 py-1.5 rounded border border-border text-xs text-text-muted hover:bg-surface cursor-pointer",children:"Cancel"}),(0,a.jsx)("button",{onClick:()=>{let e=em.name.trim();e&&em.url.trim()&&(Q(t=>[...t.filter(t=>t.name!==e),{name:e,url:em.url.trim(),transport:"sse",custom:!0}]),ec(!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 et({tool:e,isExpanded:t,onToggle:s,baseUrl:i,apiKeys:m,activeProviders:x,cloudEnabled:u,initialStatus:p,tunnelEnabled:h,tunnelPublicUrl:g,tailscaleEnabled:f,tailscaleUrl:j}){let y,v,[b,N]=(0,o.useState)(p||null),[w,k]=(0,o.useState)(!1),[C,S]=(0,o.useState)(!1),[$,A]=(0,o.useState)(!1),[M,I]=(0,o.useState)(null),[U,L]=(0,o.useState)(!1),[R,T]=(0,o.useState)(""),[D,z]=(0,o.useState)(""),[K,F]=(0,o.useState)(!1),[J,B]=(0,o.useState)({}),[H,q]=(0,o.useState)(!1),[W,G]=(0,o.useState)("");(0,o.useEffect)(()=>{m?.length>0&&!R&&T(m[0].key)},[m,R]),(0,o.useEffect)(()=>{p&&N(p)},[p]),(0,o.useEffect)(()=>{t&&(b||X(),V())},[t]),(0,o.useEffect)(()=>{b?.settings?.openAiModelId&&z(b.settings.openAiModelId)},[b]);let V=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&B(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}},Y=b?.settings?.openAiBaseUrl||"",Q=b?.installed?b.hasJRouter?P(b.settings?.openAiBaseUrl||"",{tunnelPublicUrl:g,tailscaleUrl:j})?"configured":"other":"not_configured":null,Z=()=>{let e=W||`${i}/v1`;return e.endsWith("/v1")?e:`${e}/v1`},X=async()=>{k(!0);try{let e=await fetch("/api/cli-tools/cline-settings"),t=await e.json();N(t)}catch(e){N({installed:!1,error:e.message})}finally{k(!1)}},ee=async()=>{S(!0),I(null);try{let e=R&&R.trim()||u?R:"sk_jrouter",t=await fetch("/api/cli-tools/cline-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:Z(),apiKey:e,model:D})}),s=await t.json();t.ok?(_(Z(),{tunnelPublicUrl:g,tailscaleUrl:j}),I({type:"success",text:"Settings applied successfully!"}),X()):I({type:"error",text:s.error||"Failed to apply settings"})}catch(e){I({type:"error",text:e.message})}finally{S(!1)}},es=async()=>{A(!0),I(null);try{let e=await fetch("/api/cli-tools/cline-settings",{method:"DELETE"}),t=await e.json();e.ok?(I({type:"success",text:"Settings reset successfully!"}),z(""),X()):I({type:"error",text:t.error||"Failed to reset settings"})}catch(e){I({type:"error",text:e.message})}finally{A(!1)}};return(0,a.jsxs)(d.Zp,{padding:"none",className:n().panel,children:[(0,a.jsxs)("div",{className:n().panelHeader,onClick:s,children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(c.default,{src:"/providers/cline.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===Q&&(0,a.jsx)(r.A,{variant:"success",className:n().status,children:"Connected"}),"not_configured"===Q&&(0,a.jsx)(r.A,{variant:"warning",className:n().status,children:"Not configured"}),"other"===Q&&(0,a.jsx)(r.A,{variant:"default",dot:!1,className:n().status,children:"Other"})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)(l.default,{className:`text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:n().body,children:[w&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,a.jsx)(l.default,{className:"animate-spin",children:"progress_activity"}),(0,a.jsx)("span",{children:"Checking Cline..."})]}),!w&&b&&!b.installed&&(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:`flex flex-col gap-3 p-4 border ${n().notice} ${n().warning}`,children:[(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)(l.default,{className:"text-[var(--warn)]",children:"warning"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"font-medium text-[var(--warn)]",children:"Cline not detected locally"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if JRouter is deployed on a remote server."})]})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2 sm:pl-9",children:[(0,a.jsxs)(d.$n,{variant:"secondary",size:"sm",onClick:()=>q(!0),children:[(0,a.jsx)(l.default,{className:"text-[18px] mr-1",children:"content_copy"}),"Manual Config"]}),(0,a.jsxs)(d.$n,{variant:"outline",size:"sm",onClick:()=>L(!U),children:[(0,a.jsx)(l.default,{className:"text-[18px] mr-1",children:U?"expand_less":"help"}),U?"Hide":"How to Install"]})]})]}),U&&(0,a.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,a.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,a.jsx)("div",{className:"space-y-3 text-sm",children:(0,a.jsxs)("p",{className:"text-text-muted",children:["Install Cline VS Code extension or CLI from ",(0,a.jsx)("a",{className:"text-text-main underline",href:"https://docs.cline.bot/",target:"_blank",rel:"noreferrer",children:"docs.cline.bot"}),"."]})})]})]}),!w&&b?.installed&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"Select Endpoint"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(E,{value:W||W||`${i}/v1`,onChange:G,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:h,tunnelPublicUrl:g,tailscaleEnabled:f,tailscaleUrl:j,currentUrl:Y})]}),b?.settings?.openAiBaseUrl&&(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"Current"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)("span",{className:"min-w-0 truncate rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5",children:b.settings.openAiBaseUrl})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"API Key"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(O,{value:R,onChange:T,apiKeys:m,cloudEnabled:u})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"Model"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,a.jsx)("input",{type:"text",value:D,onChange:e=>z(e.target.value),placeholder:"provider/model-id",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),D&&(0,a.jsx)("button",{onClick:()=>z(""),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,a.jsx)(l.default,{className:"text-[14px]",children:"close"})})]}),(0,a.jsx)("button",{onClick:()=>F(!0),disabled:!x?.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 ${x?.length?"bg-surface border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${n().selectButton}`,children:"Select Model"})]})]}),M&&(0,a.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===M.type?n().positive:n().danger}`,children:[(0,a.jsx)(l.default,{className:"text-[14px]",children:"success"===M.type?"check_circle":"error"}),(0,a.jsx)("span",{children:M.text})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,a.jsxs)(d.$n,{variant:"primary",size:"sm",onClick:ee,disabled:!R&&u&&m.length>0||!D,loading:C,children:[(0,a.jsx)(l.default,{className:"text-[14px] mr-1",children:"save"}),"Apply"]}),(0,a.jsxs)(d.$n,{variant:"outline",size:"sm",onClick:es,disabled:$,loading:$,children:[(0,a.jsx)(l.default,{className:"text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,a.jsxs)(d.$n,{variant:"ghost",size:"sm",onClick:()=>q(!0),children:[(0,a.jsx)(l.default,{className:"text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),K&&(0,a.jsx)(d.rq,{className:n().modelPicker,isOpen:K,onClose:()=>F(!1),onSelect:e=>{z(e.value),F(!1)},selectedModel:D,activeProviders:x,modelAliases:J,title:"Select Model for Cline"}),(0,a.jsx)(d.uR,{isOpen:H,onClose:()=>q(!1),title:"Cline - Manual Configuration",configs:(y=R&&R.trim()?R:u?"<API_KEY_FROM_DASHBOARD>":"sk_jrouter",[{filename:"~/.cline/data/globalState.json",content:JSON.stringify({actModeApiProvider:"openai",planModeApiProvider:"openai",openAiBaseUrl:(v=Z()).endsWith("/v1")?v.slice(0,-3):v,openAiModelId:D||"provider/model-id",planModeOpenAiModelId:D||"provider/model-id"},null,2)},{filename:"~/.cline/data/secrets.json",content:JSON.stringify({openAiApiKey:y},null,2)}])})]})}function es({tool:e,isExpanded:t,onToggle:s,baseUrl:i,apiKeys:m,activeProviders:x,cloudEnabled:u,initialStatus:p,tunnelEnabled:h,tunnelPublicUrl:g,tailscaleEnabled:f,tailscaleUrl:j}){let[y,v]=(0,o.useState)(p||null),[b,N]=(0,o.useState)(!1),[w,k]=(0,o.useState)(!1),[C,S]=(0,o.useState)(!1),[$,A]=(0,o.useState)(null),[M,P]=(0,o.useState)(!1),[I,U]=(0,o.useState)(""),[L,R]=(0,o.useState)(""),[T,D]=(0,o.useState)(!1),[z,K]=(0,o.useState)({}),[F,J]=(0,o.useState)(!1),[B,H]=(0,o.useState)("");(0,o.useEffect)(()=>{m?.length>0&&!I&&U(m[0].key)},[m,I]),(0,o.useEffect)(()=>{p&&v(p)},[p]),(0,o.useEffect)(()=>{t&&(y||V(),q())},[t]);let q=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&K(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}},W=y?.installed?y.hasJRouter?"configured":"not_configured":null,G=()=>{let e=B||`${i}/v1`;return e.endsWith("/v1")?e:`${e}/v1`},V=async()=>{N(!0);try{let e=await fetch("/api/cli-tools/kilo-settings"),t=await e.json();v(t)}catch(e){v({installed:!1,error:e.message})}finally{N(!1)}},Y=async()=>{k(!0),A(null);try{let e=I&&I.trim()||u?I:"sk_jrouter",t=await fetch("/api/cli-tools/kilo-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:G(),apiKey:e,model:L})}),s=await t.json();t.ok?(_(G(),{tunnelPublicUrl:g,tailscaleUrl:j}),A({type:"success",text:"Settings applied successfully!"}),V()):A({type:"error",text:s.error||"Failed to apply settings"})}catch(e){A({type:"error",text:e.message})}finally{k(!1)}},Q=async()=>{S(!0),A(null);try{let e=await fetch("/api/cli-tools/kilo-settings",{method:"DELETE"}),t=await e.json();e.ok?(A({type:"success",text:"Settings reset successfully!"}),R(""),V()):A({type:"error",text:t.error||"Failed to reset settings"})}catch(e){A({type:"error",text:e.message})}finally{S(!1)}};return(0,a.jsxs)(d.Zp,{padding:"none",className:n().panel,children:[(0,a.jsxs)("div",{className:n().panelHeader,onClick:s,children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(c.default,{src:"/providers/kilocode.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===W&&(0,a.jsx)(r.A,{variant:"success",className:n().status,children:"Connected"}),"not_configured"===W&&(0,a.jsx)(r.A,{variant:"warning",className:n().status,children:"Not configured"})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)(l.default,{className:`text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:n().body,children:[b&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,a.jsx)(l.default,{className:"animate-spin",children:"progress_activity"}),(0,a.jsx)("span",{children:"Checking Kilo Code..."})]}),!b&&y&&!y.installed&&(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:`flex flex-col gap-3 p-4 border ${n().notice} ${n().warning}`,children:[(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)(l.default,{className:"text-[var(--warn)]",children:"warning"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"font-medium text-[var(--warn)]",children:"Kilo Code not detected locally"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if JRouter is deployed on a remote server."})]})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2 sm:pl-9",children:[(0,a.jsxs)(d.$n,{variant:"secondary",size:"sm",onClick:()=>J(!0),children:[(0,a.jsx)(l.default,{className:"text-[18px] mr-1",children:"content_copy"}),"Manual Config"]}),(0,a.jsxs)(d.$n,{variant:"outline",size:"sm",onClick:()=>P(!M),children:[(0,a.jsx)(l.default,{className:"text-[18px] mr-1",children:M?"expand_less":"help"}),M?"Hide":"How to Install"]})]})]}),M&&(0,a.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,a.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,a.jsxs)("p",{className:"text-sm text-text-muted",children:["Install Kilo Code from ",(0,a.jsx)("a",{className:"text-text-main underline",href:"https://kilocode.ai",target:"_blank",rel:"noreferrer",children:"kilocode.ai"})," or VS Code extension marketplace."]})]})]}),!b&&y?.installed&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"Select Endpoint"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(E,{value:B||B||`${i}/v1`,onChange:H,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:h,tunnelPublicUrl:g,tailscaleEnabled:f,tailscaleUrl:j})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"API Key"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(O,{value:I,onChange:U,apiKeys:m,cloudEnabled:u})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"Model"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,a.jsx)("input",{type:"text",value:L,onChange:e=>R(e.target.value),placeholder:"provider/model-id",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),L&&(0,a.jsx)("button",{onClick:()=>R(""),className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-[var(--danger)] rounded transition-colors",title:"Clear",children:(0,a.jsx)(l.default,{className:"text-[14px]",children:"close"})})]}),(0,a.jsx)("button",{onClick:()=>D(!0),disabled:!x?.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 ${x?.length?"bg-surface border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${n().selectButton}`,children:"Select Model"})]})]}),$&&(0,a.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===$.type?n().positive:n().danger}`,children:[(0,a.jsx)(l.default,{className:"text-[14px]",children:"success"===$.type?"check_circle":"error"}),(0,a.jsx)("span",{children:$.text})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,a.jsxs)(d.$n,{variant:"primary",size:"sm",onClick:Y,disabled:!I&&u&&m.length>0||!L,loading:w,children:[(0,a.jsx)(l.default,{className:"text-[14px] mr-1",children:"save"}),"Apply"]}),(0,a.jsxs)(d.$n,{variant:"outline",size:"sm",onClick:Q,disabled:C,loading:C,children:[(0,a.jsx)(l.default,{className:"text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,a.jsxs)(d.$n,{variant:"ghost",size:"sm",onClick:()=>J(!0),children:[(0,a.jsx)(l.default,{className:"text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),T&&(0,a.jsx)(d.rq,{className:n().modelPicker,isOpen:T,onClose:()=>D(!1),onSelect:e=>{R(e.value),D(!1)},selectedModel:L,activeProviders:x,modelAliases:z,title:"Select Model for Kilo Code"}),(0,a.jsx)(d.uR,{isOpen:F,onClose:()=>J(!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:u?"<API_KEY_FROM_DASHBOARD>":"sk_jrouter",baseUrl:G(),model:L||"provider/model-id"}},null,2)}]})]})}let ea="/api/cli-tools/deepseek-tui-settings";function el({tool:e,isExpanded:t,onToggle:s,baseUrl:i,hasActiveProviders:m,apiKeys:x,activeProviders:u,cloudEnabled:p,initialStatus:h,tunnelEnabled:g,tunnelPublicUrl:f,tailscaleEnabled:j,tailscaleUrl:y}){let v,[b,N]=(0,o.useState)(h||null),[w,k]=(0,o.useState)(!1),[C,S]=(0,o.useState)(!1),[$,A]=(0,o.useState)(!1),[M,I]=(0,o.useState)(null),[U,L]=(0,o.useState)(""),[R,T]=(0,o.useState)(""),[D,z]=(0,o.useState)(!1),[K,F]=(0,o.useState)({}),[J,B]=(0,o.useState)(!1),[H,q]=(0,o.useState)(""),W=(0,o.useRef)(!1),G=b?.settings?.["providers.openai"]?.base_url||"",V=(()=>{if(!b?.installed)return null;let e=b.settings?.["providers.openai"];return e?.base_url?P(e.base_url,{tunnelPublicUrl:f,tailscaleUrl:y})?"configured":"other":"not_configured"})();(0,o.useEffect)(()=>{x?.length>0&&!U&&L(x[0].key)},[x,U]),(0,o.useEffect)(()=>{h&&N(h)},[h]),(0,o.useEffect)(()=>{t&&(b||Q(),Y())},[t]);let Y=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&F(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}};(0,o.useEffect)(()=>{if(b?.installed&&!W.current){W.current=!0;let e=b.settings?.["providers.openai"];e?.model&&T(e.model)}},[b]);let Q=async()=>{k(!0);try{let e=await fetch(ea),t=await e.json();N(t)}catch(e){N({installed:!1,error:e.message})}finally{k(!1)}},Z=()=>{let e=H||window.location.origin.replace("://localhost","://127.0.0.1");return e.endsWith("/v1")?e:`${e}/v1`},X=async()=>{S(!0),I(null);try{let e=U?.trim()||(x?.length>0?x[0].key:null)||(p?null:"sk_jrouter"),t=await fetch(ea,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:Z(),apiKey:e,model:R})}),s=await t.json();t.ok?(_(Z(),{tunnelPublicUrl:f,tailscaleUrl:y}),I({type:"success",text:"Settings applied successfully!"}),Q()):I({type:"error",text:s.error||"Failed to apply settings"})}catch(e){I({type:"error",text:e.message})}finally{S(!1)}},ee=async()=>{A(!0),I(null);try{let e=await fetch(ea,{method:"DELETE"}),t=await e.json();e.ok?(I({type:"success",text:"Settings reset successfully!"}),T(""),Q()):I({type:"error",text:t.error||"Failed to reset settings"})}catch(e){I({type:"error",text:e.message})}finally{A(!1)}};return(0,a.jsxs)(d.Zp,{padding:"none",className:n().panel,children:[(0,a.jsxs)("div",{className:n().panelHeader,onClick:s,children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(c.default,{src:e.image||"/providers/deepseek-tui.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===V&&(0,a.jsx)(r.A,{variant:"success",className:n().status,children:"Connected"}),"not_configured"===V&&(0,a.jsx)(r.A,{variant:"warning",className:n().status,children:"Not configured"}),"other"===V&&(0,a.jsx)(r.A,{variant:"default",dot:!1,className:n().status,children:"Other"})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)(l.default,{className:`text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:n().body,children:[w&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,a.jsx)(l.default,{className:"animate-spin",children:"progress_activity"}),(0,a.jsx)("span",{children:"Checking DeepSeek TUI..."})]}),!w&&b&&!b.installed&&(0,a.jsx)("div",{className:"flex flex-col gap-4",children:(0,a.jsxs)("div",{className:`flex flex-col gap-3 p-4 border ${n().notice} ${n().warning}`,children:[(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)(l.default,{className:"text-[var(--warn)]",children:"warning"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"font-medium text-[var(--warn)]",children:"DeepSeek TUI not detected locally"}),(0,a.jsx)("p",{className:"text-sm text-text-muted mt-1",children:"Install via npm:"}),(0,a.jsx)("code",{className:"block mt-2 p-2 bg-black/20 rounded text-xs font-mono",children:"npm install -g deepseek-tui"}),(0,a.jsx)("p",{className:"text-sm text-text-muted mt-2",children:"Manual configuration is still available if JRouter is deployed on a remote server."})]})]}),(0,a.jsx)("div",{className:"flex flex-wrap items-center gap-2 sm:pl-9",children:(0,a.jsxs)(d.$n,{variant:"secondary",size:"sm",onClick:()=>B(!0),children:[(0,a.jsx)(l.default,{className:"text-[18px] mr-1",children:"content_copy"}),"Manual Config"]})})]})}),!w&&b?.installed&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[e.notes&&e.notes.length>0&&(0,a.jsx)("div",{className:"flex flex-col gap-2 mb-2",children:e.notes.map((e,t)=>(0,a.jsxs)("div",{className:`flex items-start gap-2 p-2 rounded text-xs ${"warning"===e.type?n().warning:"error"===e.type?n().danger:n().neutral}`,children:[(0,a.jsx)(l.default,{className:"text-[14px] mt-0.5",children:"warning"===e.type?"warning":"error"===e.type?"error":"info"}),(0,a.jsx)("span",{children:e.text})]},t))}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"Select Endpoint"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(E,{value:H||Z(),onChange:q,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:g,tunnelPublicUrl:f,tailscaleEnabled:j,tailscaleUrl:y,currentUrl:G})]}),b?.settings?.["providers.openai"]?.base_url&&(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"Current"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)("span",{className:"min-w-0 truncate rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5",children:b.settings["providers.openai"].base_url})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"API Key"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(O,{value:U,onChange:L,apiKeys:x,cloudEnabled:p})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"Default Model"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,a.jsx)("input",{type:"text",value:R,onChange:e=>T(e.target.value),placeholder:"provider/model-id",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),R&&(0,a.jsx)("button",{onClick:()=>T(""),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,a.jsx)(l.default,{className:"text-[14px]",children:"close"})})]}),(0,a.jsx)("button",{onClick:()=>z(!0),disabled:!m,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?"bg-surface border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${n().selectButton}`,children:"Select"})]})]}),M&&(0,a.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===M.type?n().positive:n().danger}`,children:[(0,a.jsx)(l.default,{className:"text-[14px]",children:"success"===M.type?"check_circle":"error"}),(0,a.jsx)("span",{children:M.text})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,a.jsxs)(d.$n,{variant:"primary",size:"sm",onClick:X,disabled:!R,loading:C,children:[(0,a.jsx)(l.default,{className:"text-[14px] mr-1",children:"save"}),"Apply"]}),(0,a.jsxs)(d.$n,{variant:"outline",size:"sm",onClick:ee,disabled:!b?.hasJRouter,loading:$,children:[(0,a.jsx)(l.default,{className:"text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,a.jsxs)(d.$n,{variant:"ghost",size:"sm",onClick:()=>B(!0),children:[(0,a.jsx)(l.default,{className:"text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),D&&(0,a.jsx)(d.rq,{className:n().modelPicker,isOpen:D,onClose:()=>z(!1),onSelect:e=>{T(e.value),z(!1)},selectedModel:R,activeProviders:u,modelAliases:K,title:"Select Model for DeepSeek TUI"}),(0,a.jsx)(d.uR,{isOpen:J,onClose:()=>B(!1),title:"DeepSeek TUI - Manual Configuration",configs:(v=U&&U.trim()?U:p?"<API_KEY_FROM_DASHBOARD>":"sk_jrouter",[{filename:"~/.deepseek/config.toml",content:`[providers.openai]
84
+ base_url = "${Z()}"
85
+ api_key = "${v}"
86
+ model = "${R||"provider/model-id"}"
87
+ `}])})]})}function er({tool:e,isExpanded:t,onToggle:s,baseUrl:i,hasActiveProviders:m,apiKeys:x,activeProviders:u,cloudEnabled:p,initialStatus:h,tunnelEnabled:g,tunnelPublicUrl:f,tailscaleEnabled:j,tailscaleUrl:y}){let v,b,[N,w]=(0,o.useState)(h||null),[k,C]=(0,o.useState)(!1),[S,$]=(0,o.useState)(!1),[A,M]=(0,o.useState)(!1),[I,U]=(0,o.useState)(null),[L,R]=(0,o.useState)(""),[T,D]=(0,o.useState)(""),[z,K]=(0,o.useState)(!1),[F,J]=(0,o.useState)({}),[B,H]=(0,o.useState)(!1),[q,W]=(0,o.useState)(""),G=(0,o.useRef)(!1),V=N?.config?.providers?.jrouter?.base_url||"",Y=(()=>{if(!N?.installed)return null;if(!N?.hasJRouter)return"not_configured";let e=N.config?.providers?.jrouter;return e?P(e.base_url,{tunnelPublicUrl:f,tailscaleUrl:y})?"configured":"other":"not_configured"})();(0,o.useEffect)(()=>{x?.length>0&&!L&&R(x[0].key)},[x,L]),(0,o.useEffect)(()=>{h&&w(h)},[h]),(0,o.useEffect)(()=>{t&&(N||Z(),Q())},[t]);let Q=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&J(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}};(0,o.useEffect)(()=>{if(N?.installed&&!G.current){G.current=!0;let e=N.config?.providers?.jrouter;if(e){e.default_model&&D(e.default_model);let t=N.envApiKey;t&&x?.some(e=>e.key===t)&&R(t)}}},[N,x]);let Z=async()=>{C(!0);try{let e=await fetch("/api/cli-tools/jcode-settings"),t=await e.json();w(t)}catch(e){w({installed:!1,error:e.message})}finally{C(!1)}},X=()=>window.location.origin.replace("://localhost","://127.0.0.1"),ee=()=>{let e=q||X();return e.endsWith("/v1")?e:`${e}/v1`},et=async()=>{$(!0),U(null);try{let e=L?.trim()||(x?.length>0?x[0].key:null)||(p?null:"sk_jrouter"),t=await fetch("/api/cli-tools/jcode-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:ee(),apiKey:e,models:T?[T]:[]})}),s=await t.json();t.ok?(_(ee(),{tunnelPublicUrl:f,tailscaleUrl:y}),U({type:"success",text:"Settings applied successfully!"}),Z()):U({type:"error",text:s.error||"Failed to apply settings"})}catch(e){U({type:"error",text:e.message})}finally{$(!1)}},es=async()=>{M(!0),U(null);try{let e=await fetch("/api/cli-tools/jcode-settings",{method:"DELETE"}),t=await e.json();e.ok?(U({type:"success",text:"Settings reset successfully!"}),D(""),R(""),Z()):U({type:"error",text:t.error||"Failed to reset settings"})}catch(e){U({type:"error",text:e.message})}finally{M(!1)}};return(0,a.jsxs)(d.Zp,{padding:"none",className:n().panel,children:[(0,a.jsxs)("div",{className:n().panelHeader,onClick:s,children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(c.default,{src:e.image||"/providers/jcode.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===Y&&(0,a.jsx)(r.A,{variant:"success",className:n().status,children:"Connected"}),"not_configured"===Y&&(0,a.jsx)(r.A,{variant:"warning",className:n().status,children:"Not configured"}),"other"===Y&&(0,a.jsx)(r.A,{variant:"default",dot:!1,className:n().status,children:"Other"})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)(l.default,{className:`text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:n().body,children:[k&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,a.jsx)(l.default,{className:"animate-spin",children:"progress_activity"}),(0,a.jsx)("span",{children:"Checking jcode CLI..."})]}),!k&&N&&!N.installed&&(0,a.jsx)("div",{className:"flex flex-col gap-4",children:(0,a.jsxs)("div",{className:`flex flex-col gap-3 p-4 border ${n().notice} ${n().warning}`,children:[(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)(l.default,{className:"text-[var(--warn)]",children:"warning"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"font-medium text-[var(--warn)]",children:"jcode CLI not detected locally"}),(0,a.jsx)("p",{className:"text-sm text-text-muted mt-1",children:"Install jcode to enable automatic configuration:"}),(0,a.jsx)("code",{className:"block mt-2 p-2 bg-black/20 rounded text-xs font-mono",children:"curl -fsSL https://raw.githubusercontent.com/1jehuang/jcode/master/scripts/install.sh | bash"}),(0,a.jsx)("p",{className:"text-sm text-text-muted mt-2",children:"Manual configuration is still available if JRouter is deployed on a remote server."})]})]}),(0,a.jsx)("div",{className:"flex flex-wrap items-center gap-2 sm:pl-9",children:(0,a.jsxs)(d.$n,{variant:"secondary",size:"sm",onClick:()=>H(!0),children:[(0,a.jsx)(l.default,{className:"text-[18px] mr-1",children:"content_copy"}),"Manual Config"]})})]})}),!k&&N?.installed&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[e.notes&&e.notes.length>0&&(0,a.jsx)("div",{className:"flex flex-col gap-2 mb-2",children:e.notes.map((e,t)=>(0,a.jsxs)("div",{className:`flex items-start gap-2 p-2 rounded text-xs ${"info"===e.type?n().neutral:"warning"===e.type?n().warning:n().neutral}`,children:[(0,a.jsx)(l.default,{className:"text-[14px] mt-0.5",children:"info"===e.type?"info":"warning"===e.type?"warning":"help"}),(0,a.jsx)("span",{children:e.text})]},t))}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"Select Endpoint"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(E,{value:q||((v=q||X()).endsWith("/v1")?v:`${v}/v1`),onChange:W,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:g,tunnelPublicUrl:f,tailscaleEnabled:j,tailscaleUrl:y,currentUrl:V})]}),N?.config?.providers?.jrouter?.base_url&&(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"Current"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)("span",{className:"min-w-0 truncate rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5",children:N.config.providers.jrouter.base_url})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"API Key"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(O,{value:L,onChange:R,apiKeys:x,cloudEnabled:p})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"Default Model"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,a.jsx)("input",{type:"text",value:T,onChange:e=>D(e.target.value),placeholder:"cc/claude-opus-4-7",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),T&&(0,a.jsx)("button",{onClick:()=>D(""),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,a.jsx)(l.default,{className:"text-[14px]",children:"close"})})]}),(0,a.jsx)("button",{onClick:()=>K(!0),disabled:!m,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?"bg-surface border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${n().selectButton}`,children:"Select"})]}),(0,a.jsxs)("div",{className:`flex flex-col gap-1 p-3 border ${n().notice} ${n().neutral}`,children:[(0,a.jsx)("p",{className:"text-xs font-medium text-text-muted",children:"Usage:"}),(0,a.jsx)("code",{className:"text-xs font-mono text-text-muted",children:"jcode --provider-profile jrouter"}),(0,a.jsxs)("code",{className:"text-xs font-mono text-text-muted",children:["jcode --provider-profile jrouter --model ",T||"cc/claude-opus-4-7"]})]})]}),I&&(0,a.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===I.type?n().positive:n().danger}`,children:[(0,a.jsx)(l.default,{className:"text-[14px]",children:"success"===I.type?"check_circle":"error"}),(0,a.jsx)("span",{children:I.text})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,a.jsxs)(d.$n,{variant:"primary",size:"sm",onClick:et,disabled:!T,loading:S,children:[(0,a.jsx)(l.default,{className:"text-[14px] mr-1",children:"save"}),"Apply"]}),(0,a.jsxs)(d.$n,{variant:"outline",size:"sm",onClick:es,disabled:!N?.hasJRouter,loading:A,children:[(0,a.jsx)(l.default,{className:"text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,a.jsxs)(d.$n,{variant:"ghost",size:"sm",onClick:()=>H(!0),children:[(0,a.jsx)(l.default,{className:"text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),z&&(0,a.jsx)(d.rq,{className:n().modelPicker,isOpen:z,onClose:()=>K(!1),onSelect:e=>{D(e.value),K(!1)},selectedModel:T,activeProviders:u,modelAliases:F,title:"Select Model for jcode"}),(0,a.jsx)(d.uR,{isOpen:B,onClose:()=>H(!1),title:"jcode - Manual Configuration",configs:(b=L&&L.trim()?L:p?"<API_KEY_FROM_DASHBOARD>":"sk_jrouter",[{filename:"~/.jcode/config.toml",content:`[providers.jrouter]
88
+ type = "openai-compatible"
89
+ base_url = "${ee()}"
90
+ auth = "bearer"
91
+ api_key_env = "JCODE_9ROUTER_API_KEY"
92
+ env_file = "provider-jrouter.env"
93
+ default_model = "${T||"cc/claude-opus-4-7"}"
94
+ requires_api_key = true
95
+
96
+ [[providers.jrouter.models]]
97
+ id = "${T||"cc/claude-opus-4-7"}"`},{filename:"~/.config/jcode/provider-jrouter.env",content:`JCODE_9ROUTER_API_KEY="${b}"`}])})]})}var ei=s(929);let en="/api/cli-tools/grok-build-settings",eo="jrouter",ed=[{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 ec({label:e,value:t,placeholder:s,onChange:r,onSelect:i,disabled:n,help:o}){return(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsxs)("div",{className:"sm:text-right",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-sm",children:e}),o&&(0,a.jsx)("p",{className:"mt-0.5 text-[10px] leading-tight text-text-muted",children:o})]}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,a.jsx)("input",{type:"text",value:t,onChange:e=>r(e.target.value),placeholder:s,className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),t&&(0,a.jsx)("button",{type:"button",onClick:()=>r(""),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,a.jsx)(l.default,{className:"text-[14px]",children:"close"})})]}),(0,a.jsx)("button",{type:"button",onClick:i,disabled:n,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 ${!n?"bg-surface border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"})]})}function em({tool:e,isExpanded:t,onToggle:s,hasActiveProviders:i,apiKeys:m,activeProviders:x,cloudEnabled:u,initialStatus:p,tunnelEnabled:h,tunnelPublicUrl:g,tailscaleEnabled:f,tailscaleUrl:j}){let{getCaps:y}=(0,ei.y)(),v=e=>y(e)?.contextWindow||null,b=p?.settings?.model?.model||"",N=Object.fromEntries(ed.map(e=>[e.id,p?.settings?.subagentModels?.[e.id]?.model]).filter(([,e])=>!!e)),[w,k]=(0,o.useState)(p||null),[C,S]=(0,o.useState)(!1),[$,A]=(0,o.useState)(!1),[M,I]=(0,o.useState)(!1),[U,L]=(0,o.useState)(null),[R,T]=(0,o.useState)(m?.[0]?.key||""),[D,z]=(0,o.useState)(b),[K,F]=(0,o.useState)(N),[J,B]=(0,o.useState)(null),[H,q]=(0,o.useState)({}),[W,G]=(0,o.useState)(!1),[V,Y]=(0,o.useState)(""),Q=(0,o.useRef)(!!p),Z=w?.settings?.model,X=Z?.base_url||"",ee=w?.installed?Z?.base_url?P(Z.base_url,{tunnelPublicUrl:g,tailscaleUrl:j})?"configured":"other":"not_configured":null,et=(0,o.useCallback)(e=>{let t=e?.settings?.model?.model||"",s=Object.fromEntries(ed.map(t=>[t.id,e?.settings?.subagentModels?.[t.id]?.model]).filter(([,e])=>!!e));z(t),F(s)},[]),es=(0,o.useCallback)(async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&q(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}},[]),ea=(0,o.useCallback)(async({hydrate:e=!1}={})=>{S(!0);try{let t=await fetch(en),s=await t.json();k(s),Q.current=!0,e&&et(s)}catch(e){k({installed:!1,error:e.message})}finally{S(!1)}},[et]);(0,o.useEffect)(()=>{if(!t)return;let e=!1;return(async()=>{Q.current||await ea({hydrate:!0}),e||await es()})(),()=>{e=!0}},[t,ea,es]);let el=()=>{let e=V||window.location.origin.replace("://localhost","://127.0.0.1");return e.endsWith("/v1")?e:`${e}/v1`},er=async()=>{A(!0),L(null);try{let e=R?.trim()||(m?.length>0?m[0].key:null)||(u?null:"sk_jrouter"),t={};for(let e of ed){let s=K[e.id]?.trim();s&&(t[e.id]={model:s,contextWindow:v(s)})}let s=await fetch(en,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:el(),apiKey:e,model:D,contextWindow:v(D),subagentModels:t})}),a=await s.json();s.ok?(_(el(),{tunnelPublicUrl:g,tailscaleUrl:j}),L({type:"success",text:"Main and subagent models applied successfully!"}),ea()):L({type:"error",text:a.error||"Failed to apply settings"})}catch(e){L({type:"error",text:e.message})}finally{A(!1)}},ex=async()=>{I(!0),L(null);try{let e=await fetch(en,{method:"DELETE"}),t=await e.json();e.ok?(L({type:"success",text:"Settings reset successfully!"}),z(""),F({}),ea()):L({type:"error",text:t.error||"Failed to reset settings"})}catch(e){L({type:"error",text:e.message})}finally{I(!1)}};return(0,a.jsxs)(d.Zp,{padding:"none",className:n().panel,children:[(0,a.jsxs)("div",{className:n().panelHeader,onClick:s,children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(c.default,{src:e.image||"/providers/grok-cli.png",alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===ee&&(0,a.jsx)(r.A,{variant:"success",className:n().status,children:"Connected"}),"not_configured"===ee&&(0,a.jsx)(r.A,{variant:"warning",className:n().status,children:"Not configured"}),"other"===ee&&(0,a.jsx)(r.A,{variant:"default",dot:!1,className:n().status,children:"Other"})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)(l.default,{className:`text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:n().body,children:[C&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,a.jsx)(l.default,{className:"animate-spin",children:"progress_activity"}),(0,a.jsx)("span",{children:"Checking Grok Build..."})]}),!C&&w&&!w.installed&&(0,a.jsxs)("div",{className:`flex flex-col gap-3 p-4 border ${n().notice} ${n().warning}`,children:[(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)(l.default,{className:"text-[var(--warn)]",children:"warning"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"font-medium text-[var(--warn)]",children:"Grok Build not detected locally"}),(0,a.jsx)("code",{className:"block mt-2 p-2 bg-black/20 rounded text-xs font-mono",children:"curl -fsSL https://x.ai/cli/install.sh | bash"})]})]}),(0,a.jsxs)(d.$n,{variant:"secondary",size:"sm",onClick:()=>G(!0),className:"w-full sm:w-auto",children:[(0,a.jsx)(l.default,{className:"text-[18px] mr-1",children:"content_copy"}),"Manual Config"]})]}),!C&&w?.installed&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[e.notes?.length>0&&(0,a.jsx)("div",{className:"mb-2 flex flex-col gap-2",children:e.notes.map((e,t)=>(0,a.jsxs)("div",{className:`flex items-start gap-2 p-2 ${n().notice} ${"warning"===e.type?n().warning:n().neutral}`,children:[(0,a.jsx)(l.default,{className:"mt-0.5 text-[14px]",children:"warning"===e.type?"warning":"info"}),(0,a.jsx)("span",{children:e.text})]},t))}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"Select Endpoint"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(E,{value:V||el(),onChange:Y,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:h,tunnelPublicUrl:g,tailscaleEnabled:f,tailscaleUrl:j,currentUrl:X})]}),Z?.base_url&&(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"Current"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("span",{className:"min-w-0 truncate rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5",children:[Z.base_url," \xb7 ",Z.model,Z.context_window?` \xb7 ${(Z.context_window/1e3).toLocaleString()}K ctx`:""]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"API Key"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(O,{value:R,onChange:T,apiKeys:m,cloudEnabled:u})]}),(0,a.jsx)(ec,{label:"Main Model",value:D,onChange:z,placeholder:"provider/model-id",onSelect:()=>B("main"),disabled:!i}),(0,a.jsx)("div",{className:"my-1 border-t border-border pt-3",children:(0,a.jsxs)("div",{className:"mb-2 flex items-start gap-2",children:[(0,a.jsx)(l.default,{className:"text-text-main text-[16px]",children:"account_tree"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-xs font-semibold text-text-main",children:"Subagent model overrides"}),(0,a.jsx)("p",{className:"text-[10px] text-text-muted",children:"Leave blank to inherit Main Model. Each override keeps its own context window."})]})]})}),ed.map(e=>(0,a.jsx)(ec,{label:e.label,help:e.help,value:K[e.id]||"",onChange:t=>F(s=>({...s,[e.id]:t})),placeholder:`${D||"Main Model"} (inherit)`,onSelect:()=>B(e.id),disabled:!i},e.id))]}),U&&(0,a.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs ${"success"===U.type?n().positive:n().danger}`,children:[(0,a.jsx)(l.default,{className:"text-[14px]",children:"success"===U.type?"check_circle":"error"}),(0,a.jsx)("span",{children:U.text})]}),(0,a.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2",children:[(0,a.jsxs)(d.$n,{variant:"primary",size:"sm",onClick:er,disabled:!D,loading:$,className:"w-full sm:w-auto",children:[(0,a.jsx)(l.default,{className:"text-[14px] mr-1",children:"save"}),"Apply"]}),(0,a.jsxs)(d.$n,{variant:"outline",size:"sm",onClick:ex,disabled:!w?.hasJRouter,loading:M,className:"w-full sm:w-auto",children:[(0,a.jsx)(l.default,{className:"text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,a.jsxs)(d.$n,{variant:"ghost",size:"sm",onClick:()=>G(!0),className:"w-full sm:w-auto",children:[(0,a.jsx)(l.default,{className:"text-[14px] mr-1",children:"content_copy"}),"Manual Config"]})]})]})]}),J&&(0,a.jsx)(d.rq,{className:n().modelPicker,isOpen:!!J,onClose:()=>B(null),onSelect:e=>{"main"===J?z(e.value):J&&F(t=>({...t,[J]:e.value})),B(null)},selectedModel:"main"===J?D:K[J]||"",activeProviders:x,modelAliases:H,title:"main"===J?"Select Main Model for Grok Build":`Select ${ed.find(e=>e.id===J)?.label||"Subagent"} Model`}),(0,a.jsx)(d.uR,{isOpen:W,onClose:()=>G(!1),title:"Grok Build - Manual Configuration",configs:(()=>{let e=R?.trim()||(u?"<API_KEY_FROM_DASHBOARD>":"sk_jrouter"),t=el(),s=D||"provider/model-id",a=[`[models]
98
+ default = "${eo}"`,`[model.${eo}]
99
+ model = "${s}"
100
+ base_url = "${t}"
101
+ name = "JRouter"
102
+ description = "Routed via JRouter gateway"
103
+ api_backend = "chat_completions"
104
+ api_key = "${e}"
105
+ context_window = ${v(s)||2e5}`],l=[];for(let s of ed){let r=K[s.id]?.trim();if(!r)continue;let i=`${eo}-${s.id}`;l.push(`${s.id} = "${i}"`),a.push(`[model.${i}]
106
+ model = "${r}"
107
+ base_url = "${t}"
108
+ name = "JRouter ${s.id}"
109
+ description = "Routed via JRouter gateway"
110
+ api_backend = "chat_completions"
111
+ api_key = "${e}"
112
+ context_window = ${v(r)||2e5}`)}return l.length&&a.splice(1,0,`[subagents.models]
113
+ ${l.join("\n")}`),[{filename:"~/.grok/config.toml",content:`${a.join("\n\n")}
114
+ `}]})()})]})}var ex=s(28777);function eu({tool:e,isExpanded:t,onToggle:s,baseUrl:i,apiKeys:m,activeProviders:x=[],cloudEnabled:u,initialStatus:p,tunnelEnabled:h,tunnelPublicUrl:g,tailscaleEnabled:f,tailscaleUrl:j}){let[y,v]=(0,o.useState)(()=>p||null),[b,N]=(0,o.useState)(!1),[w,k]=(0,o.useState)(!1),[C,S]=(0,o.useState)(!1),[$,A]=(0,o.useState)(null),[M,I]=(0,o.useState)(!1),[U,L]=(0,o.useState)(()=>m?.[0]?.key||""),[R,T]=(0,o.useState)(()=>{let e=p?.config;return e?.model||e?.openai?.model||e?.providers?.jrouter?.models?.[0]?.id||""}),[D,z]=(0,o.useState)(()=>{let e=p?.config,t=e?.providers?.jrouter?.models;return Array.isArray(t)&&t.length>0?t.map(e=>"string"==typeof e?e:e.id):[]}),[K,F]=(0,o.useState)(!1),[J,B]=(0,o.useState)(!1),[H,q]=(0,o.useState)(""),W=`/api/cli-tools/${e.id}-settings`;(0,o.useEffect)(()=>{let s=!0;return t&&!p&&fetch(W).then(e=>e.json()).then(t=>{if(s){v(t);let s=t?.config;if("pi"===e.id){let e=s?.providers?.jrouter?.models;Array.isArray(e)&&e.length>0&&z(e.map(e=>"string"==typeof e?e:e.id))}else{let e=s?.model||s?.openai?.model||s?.providers?.jrouter?.models?.[0]?.id;e&&T(t=>t||e)}}}).catch(e=>{s&&v({installed:!1,error:e.message})}),()=>{s=!1}},[t,p,W,e.id]);let G=async()=>{N(!0);try{let t=await fetch(W),s=await t.json();v(s);let a=s?.config;if("pi"===e.id){let e=a?.providers?.jrouter?.models;if(Array.isArray(e)&&e.length>0){let t=e.map(e=>"string"==typeof e?e:e.id);z(t)}}else{let e=a?.model||a?.openai?.model||a?.providers?.jrouter?.models?.[0]?.id;e&&!R&&T(e)}}catch(e){v({installed:!1,error:e.message})}finally{N(!1)}},V=()=>{let e=H||`${i}/v1`;return e.endsWith("/v1")?e:`${e}/v1`},Y=(()=>{if(!y?.config)return"";let e=y.config;return"string"==typeof e.baseUrl?e.baseUrl:"string"==typeof e.openai?.base_url?e.openai.base_url:"string"==typeof e.providers?.jrouter?.base_url?e.providers.jrouter.base_url:"string"==typeof e.providers?.jrouter?.baseUrl?e.providers.jrouter.baseUrl:""})(),Q=y?.installed?y.hasJRouter?(Y&&P(Y,{tunnelPublicUrl:g,tailscaleUrl:j}),"configured"):"not_configured":null,Z=async()=>{k(!0),A(null);try{let t=U&&U.trim()||u?U:"sk_jrouter",s={baseUrl:V(),apiKey:t};"pi"===e.id?s.models=D.length>0?D:["provider/model-id"]:s.model=R;let a=await fetch(W,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}),l=await a.json();a.ok?(_(V()),A({type:"success",text:l.message||"Settings applied successfully!"}),await G()):A({type:"error",text:l.error?.message||"Failed to apply settings."})}catch(e){A({type:"error",text:e.message})}finally{k(!1)}},X=async()=>{S(!0),A(null);try{let e=await fetch(W,{method:"DELETE"}),t=await e.json();e.ok?(A({type:"success",text:t.message||"Settings removed successfully."}),await G()):A({type:"error",text:t.error?.message||"Failed to reset settings."})}catch(e){A({type:"error",text:e.message})}finally{S(!1)}};return(0,a.jsxs)(d.Zp,{padding:"none",className:n().panel,children:[(0,a.jsxs)("div",{className:n().panelHeader,onClick:s,children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:e.image?(0,a.jsx)(c.default,{src:e.image,alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"},loading:"lazy",decoding:"async"}):e.icon?(0,a.jsx)(l.default,{className:"text-[28px]",style:{color:e.color},children:e.icon}):(0,a.jsx)(l.default,{className:"text-[28px] text-text-main",children:"terminal"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),"configured"===Q&&(0,a.jsx)(r.A,{variant:"success",className:n().status,children:"Connected"}),"not_configured"===Q&&(0,a.jsx)(r.A,{variant:"warning",className:n().status,children:"Not configured"}),"other"===Q&&(0,a.jsx)(r.A,{variant:"default",dot:!1,className:n().status,children:"Other"})]}),(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.description})]})]}),(0,a.jsx)(l.default,{className:`text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:n().body,children:[b&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,a.jsx)(l.default,{className:"animate-spin",children:"progress_activity"}),(0,a.jsxs)("span",{children:["Checking ",e.name,"..."]})]}),!b&&y&&!y.installed&&(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:`flex flex-col gap-3 p-4 border ${n().notice} ${n().warning}`,children:[(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)(l.default,{className:"text-[var(--warn)]",children:"warning"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsxs)("p",{className:"font-medium text-[var(--warn)]",children:[e.name," not detected locally"]}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Manual configuration is still available if JRouter is deployed on a remote server."})]})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2 sm:pl-9",children:[(0,a.jsxs)(d.$n,{variant:"secondary",size:"sm",onClick:()=>B(!0),children:[(0,a.jsx)(l.default,{className:"text-[18px] mr-1",children:"content_copy"}),"Manual Config"]}),(0,a.jsxs)(d.$n,{variant:"outline",size:"sm",onClick:()=>I(!M),children:[(0,a.jsx)(l.default,{className:"text-[18px] mr-1",children:M?"expand_less":"help"}),M?"Hide":"How to Install"]})]})]}),M&&(0,a.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,a.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,a.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-text-muted mb-1",children:"Install command:"}),(0,a.jsx)("code",{className:"block px-3 py-2 bg-black/5 dark:bg-white/5 rounded font-mono text-xs",children:(()=>{switch(e.id){case"pi":return"curl -fsSL https://pi.dev/install.sh | sh # or: npm install -g --ignore-scripts @earendil-works/pi-coding-agent";case"omp":return"npm install -g oh-my-pi";case"crush":return"brew install charmbracelet/tap/crush # or go install github.com/charmbracelet/crush@latest";case"forge":return"cargo install forgecode";case"smelt":return"cargo install smelt";case"codewhale":return"cargo install codewhale";default:return`npm install -g ${e.id}`}})()})]}),e.docsUrl&&(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["Docs: ",(0,a.jsx)("a",{href:e.docsUrl,target:"_blank",rel:"noreferrer",className:"text-text-main hover:underline",children:e.docsUrl})]})]})]})]}),!b&&y?.installed&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"Select Endpoint"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(E,{value:H||V(),onChange:q,requiresExternalUrl:e.requiresExternalUrl,tunnelEnabled:h,tunnelPublicUrl:g,tailscaleEnabled:f,tailscaleUrl:j,currentUrl:Y})]}),Y?(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"Current"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)("span",{className:"min-w-0 truncate rounded bg-surface/40 px-2 py-2 text-xs text-text-muted sm:py-1.5",children:Y})]}):null,(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"API Key"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)(O,{value:U,onChange:L,apiKeys:m,cloudEnabled:u})]}),"pi"===e.id&&(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr] sm:items-start sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right mt-1 ${n().fieldLabel}`,children:"Models"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline mt-1.5",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"flex-1 flex flex-col gap-2",children:[(0,a.jsx)("div",{className:"flex flex-wrap gap-1.5 min-h-[36px] p-2 bg-surface rounded border border-border",children:0===D.length?(0,a.jsx)("span",{className:"text-xs text-text-muted italic",children:"No models selected. Add models to use in Pi."}):D.map(e=>(0,a.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,a.jsx)("span",{children:e}),(0,a.jsx)("button",{type:"button",onClick:()=>{z(t=>t.filter(t=>t!==e))},className:"text-text-muted hover:text-[var(--danger)] rounded p-0.5",children:(0,a.jsx)(l.default,{className:"text-[12px]",children:"close"})})]},e))}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,a.jsxs)(d.$n,{type:"button",size:"sm",variant:"secondary",onClick:()=>F(!0),disabled:!x?.length,children:[(0,a.jsx)(l.default,{className:"text-[14px] mr-1",children:"add"}),"Add Model"]}),x?.length>0&&(0,a.jsx)(d.$n,{type:"button",size:"sm",variant:"ghost",onClick:()=>{let e=[];x.forEach(t=>{let s=ex.Xg[t.provider]||t.provider;(0,ex.KC)(t.provider).forEach(t=>{let a=`${s}/${t.id}`;e.includes(a)||e.push(a)})}),e.length>0&&z(t=>Array.from(new Set([...t,...e])))},className:"text-xs text-text-main hover:text-text-main",children:"+ Add All Active Models"}),D.length>0&&(0,a.jsx)("button",{type:"button",onClick:()=>z([]),className:"text-xs text-text-muted hover:text-[var(--danger)] ml-auto",children:"Clear all"})]})]})]}),"omp"!==e.id&&"pi"!==e.id&&(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-[8rem_auto_1fr_auto] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:`sm:text-right ${n().fieldLabel}`,children:"Model"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,a.jsx)("input",{type:"text",value:R,onChange:e=>T(e.target.value),placeholder:"provider/model-id",className:"w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5"}),R&&(0,a.jsx)("button",{onClick:()=>T(""),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,a.jsx)(l.default,{className:"text-[14px]",children:"close"})})]}),(0,a.jsx)("button",{onClick:()=>F(!0),disabled:!x?.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 ${x?.length?"bg-surface border-border text-text-main hover:border-[var(--text-2)] cursor-pointer":"opacity-50 cursor-not-allowed border-border"} ${n().selectButton}`,children:"Select Model"})]})]}),$&&(0,a.jsx)("div",{className:`p-3 rounded-lg text-sm ${"success"===$.type?`border ${n().positive}`:`border ${n().danger}`}`,children:$.text}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3 pt-2",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,a.jsx)(d.$n,{variant:"primary",size:"sm",onClick:Z,disabled:w||b,children:w?"Applying...":"Apply Settings"}),y?.hasJRouter&&(0,a.jsx)(d.$n,{variant:"outline",size:"sm",onClick:X,disabled:C||b,className:"text-red-500 hover:text-[var(--danger)] hover:border-red-500/50",children:C?"Removing...":"Remove from Tool"})]}),(0,a.jsxs)(d.$n,{variant:"outline",size:"sm",onClick:()=>B(!0),children:[(0,a.jsx)(l.default,{className:"text-[18px] mr-1",children:"code"}),"Manual Config"]})]})]})]}),(0,a.jsx)(d.rq,{className:n().modelPicker,isOpen:K,onClose:()=>F(!1),onSelect:t=>{"pi"===e.id?D.includes(t.value)||z(e=>[...e,t.value]):T(t.value),F(!1)},activeProviders:x}),(0,a.jsx)(d.uR,{isOpen:J,onClose:()=>B(!1),title:`${e.name} Configuration`,configs:(()=>{let t=V(),s=U||"sk_jrouter",a=R||"provider/model-id";switch(e.id){case"pi":return[{filename:"~/.pi/agent/models.json",content:JSON.stringify({providers:{jrouter:{baseUrl:t,apiKey:s,api:"openai-completions",models:(D.length>0?D:[a]).map(e=>({id:e,name:e,contextWindow:128e3,maxTokens:16384}))}}},null,2)}];case"omp":return[{filename:"~/.omp/agent/models.yml",content:`providers:
115
+ jrouter:
116
+ baseUrl: ${t}
117
+ apiKey: ${s}
118
+ api: openai-completions
119
+ authHeader: true
120
+ disableStrictTools: true
121
+ discovery:
122
+ type: proxy`}];case"crush":return[{filename:"~/.config/crush/crush.json",content:JSON.stringify({providers:{jrouter:{type:"openai-compat",base_url:t,api_key:s,models:[{id:a,name:a,context_window:128e3}]}}},null,2)}];case"forge":return[{filename:"~/.forge/config.toml",content:`# Forge config — managed by JRouter
123
+
124
+ [openai]
125
+ api_key = "${s}"
126
+ base_url = "${t}"
127
+ model = "${a}"`}];case"smelt":return[{filename:"~/.smelt/config.json",content:JSON.stringify({baseUrl:t,apiKey:s,model:a,_managedBy:"jrouter"},null,2)}];case"codewhale":return[{filename:"~/.codewhale/config.toml",content:`# CodeWhale config — managed by JRouter
128
+
129
+ [openai]
130
+ base_url = "${t}"
131
+ api_key = "${s}"
132
+ model = "${a}"`}];default:return[]}})()})]})}let ep="http://localhost:20128";function eh({apiKeys:e,cloudEnabled:t,onStatusChange:s}){let[r,i]=(0,o.useState)(null),[n,c]=(0,o.useState)(!1),[m,x]=(0,o.useState)(!1),[u,p]=(0,o.useState)(""),[h,g]=(0,o.useState)(()=>e?.[0]?.key||""),[f,j]=(0,o.useState)(null),[y,v]=(0,o.useState)(null),[b,N]=(0,o.useState)(null),[w,_]=(0,o.useState)(ep),[k,C]=(0,o.useState)(null),S=r?.isWin===!0,E=S||r?.hasCachedPassword||r?.needsSudoPassword===!1,$=r?.isAdmin!==!1;!$&&(S||r?.hasCachedPassword||r?.needsSudoPassword);let A=(0,o.useCallback)(async()=>{try{let e=await fetch("/api/cli-tools/antigravity-mitm");if(e.ok){let t=await e.json();i(t),t.mitmRouterBaseUrl&&_(t.mitmRouterBaseUrl),s?.(t)}}catch{i({running:!1,certExists:!1,dnsStatus:{}})}},[s]);(0,o.useEffect)(()=>{queueMicrotask(()=>{A()})},[A]);let O=e=>{N(null),r&&(E?M(e,""):(j(e),x(!0),v(null)))},M=async(s,a,l=!1)=>{c(!0),N(null);try{let r;if("trust-cert"===s)r=await fetch("/api/cli-tools/antigravity-mitm",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"trust-cert",sudoPassword:a})});else if("start"===s){let s=h?.trim()||(e?.length>0?e[0].key:null)||(t?null:"sk_jrouter");r=await fetch("/api/cli-tools/antigravity-mitm",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:s,sudoPassword:a,mitmRouterBaseUrl:w.trim()||ep,forceKillPort443:l})})}else r=await fetch("/api/cli-tools/antigravity-mitm",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({sudoPassword:a})});if(!r.ok){let e=await r.json().catch(()=>({}));if("PORT_443_BUSY"===e.code&&e.portOwner){x(!1),C({owner:e.portOwner,password:a});return}N(e.error||`Failed to ${s} MITM server`);return}x(!1),p(""),C(null),await A()}catch(e){N(e.message||"Network error")}finally{c(!1),j(null)}},P=()=>{u.trim()?M(f,u):v("Sudo password is required")},I=r?.running;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.Zp,{padding:"sm",className:"border-primary/20 bg-primary/5",children:(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,a.jsx)(l.default,{className:"text-primary text-[20px]",children:"security"}),(0,a.jsx)("span",{className:"font-semibold text-sm text-text-main",children:"MITM Server"}),I?(0,a.jsx)(d.Ex,{variant:"success",size:"sm",children:"Running"}):(0,a.jsx)(d.Ex,{variant:"default",size:"sm",children:"Stopped"})]}),(0,a.jsx)("div",{className:"flex flex-wrap items-center gap-1 text-xs text-text-muted","data-i18n-skip":"true",children:[{label:"Cert",ok:r?.certExists},{label:"Trusted",ok:r?.certTrusted},{label:"Server",ok:I}].map(({label:e,ok:t})=>(0,a.jsxs)("span",{className:`flex items-center gap-0.5 px-1.5 py-0.5 rounded ${t?"text-green-600":"text-text-muted"}`,children:[(0,a.jsx)(l.default,{className:"text-[12px]",children:t?"check_circle":"cancel"}),e]},e))})]}),(0,a.jsxs)("div",{className:"px-2 py-2 rounded-lg bg-surface/50 border border-border/50 flex flex-col gap-2",children:[(0,a.jsxs)("p",{className:"text-[11px] text-text-muted leading-relaxed",children:[(0,a.jsx)("span",{className:"font-medium text-text-main",children:"Purpose:"})," Use Antigravity IDE & GitHub Copilot → with ANY provider/model from JRouter"]}),(0,a.jsxs)("p",{className:"text-[11px] text-text-muted leading-relaxed",children:[(0,a.jsx)("span",{className:"font-medium text-text-main",children:"How it works:"})," Antigravity/Copilot IDE request → DNS redirect to localhost:443 → MITM proxy intercepts → JRouter → response to Antigravity/Copilot"]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"grid gap-1 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"JRouter Base URL"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)("input",{type:"text",value:w,onChange:e=>_(e.target.value),placeholder:ep,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,a.jsxs)("div",{className:"grid gap-1 sm:grid-cols-[8rem_auto_1fr] sm:items-center sm:gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right sm:text-sm",children:"API Key"}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsx)("input",{type:"text",list:"mitm-api-keys",value:h,onChange:e=>g(e.target.value),placeholder:t?"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"}),e?.length>0&&(0,a.jsx)("datalist",{id:"mitm-api-keys",children:e.map(e=>(0,a.jsx)("option",{value:e.key,children:e.name||e.key},e.id))})]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:flex-wrap sm:items-center","data-i18n-skip":"true",children:[r?.certExists&&!r?.certTrusted&&(0,a.jsxs)("button",{onClick:()=>O("trust-cert"),disabled:n,className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-yellow-500/30 bg-yellow-500/10 px-4 py-2 text-xs font-medium text-yellow-600 transition-colors hover:bg-yellow-500/20 disabled:opacity-50 sm:w-auto sm:py-1.5",children:[(0,a.jsx)(l.default,{className:"text-[16px]",children:"verified_user"}),"Trust Cert"]}),I?(0,a.jsxs)("button",{onClick:()=>O("stop"),disabled:n,className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-red-500/30 bg-red-500/10 px-4 py-2 text-xs font-medium text-red-500 transition-colors hover:bg-red-500/20 disabled:opacity-50 sm:w-auto sm:py-1.5",children:[(0,a.jsx)(l.default,{className:"text-[16px]",children:"stop_circle"}),"Stop Server"]}):(0,a.jsxs)("button",{onClick:()=>O("start"),disabled:n||!r||S&&!$,title:S&&!$?"Administrator required":void 0,className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-primary/30 bg-primary/10 px-4 py-2 text-xs font-medium text-primary transition-colors hover:bg-primary/20 disabled:opacity-50 sm:w-auto sm:py-1.5",children:[(0,a.jsx)(l.default,{className:"text-[16px]",children:"play_circle"}),"Start Server"]}),I&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Enable DNS per tool below to activate interception"})]}),b&&(0,a.jsxs)("div",{className:"flex items-start gap-2 px-2 py-1.5 rounded text-xs bg-red-500/10 text-red-600 dark:text-red-400 border border-red-500/20",children:[(0,a.jsx)(l.default,{className:"text-[14px] mt-0.5 shrink-0",children:"error"}),(0,a.jsx)("span",{children:b})]}),S&&!$&&(0,a.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded text-xs bg-red-500/10 text-red-600 border border-red-500/20",children:[(0,a.jsx)(l.default,{className:"text-[14px]",children:"shield_lock"}),(0,a.jsx)("span",{children:"Administrator required — restart JRouter as Administrator to use MITM"})]})]})}),m&&(0,a.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:(0,a.jsxs)("div",{className:"mx-4 flex w-full max-w-sm flex-col gap-4 rounded-xl border border-border bg-surface p-5 shadow-xl sm:p-6",children:[(0,a.jsx)("h3",{className:"font-semibold text-text-main",children:"Sudo Password Required"}),(0,a.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,a.jsx)(l.default,{className:"text-yellow-500 text-[20px]",children:"warning"}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Required for SSL certificate and server startup"})]}),(0,a.jsx)(d.pd,{type:"password",placeholder:"Enter sudo password",value:u,onChange:e=>p(e.target.value),onKeyDown:e=>{"Enter"!==e.key||n||P()}}),y&&(0,a.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded text-xs bg-red-500/10 text-red-600",children:[(0,a.jsx)(l.default,{className:"text-[14px]",children:"error"}),(0,a.jsx)("span",{children:y})]}),(0,a.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,a.jsx)(d.$n,{variant:"ghost",size:"sm",onClick:()=>{x(!1),p(""),v(null)},disabled:n,children:"Cancel"}),(0,a.jsx)(d.$n,{variant:"primary",size:"sm",onClick:P,loading:n,children:"Confirm"})]})]})}),k&&(0,a.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:(0,a.jsxs)("div",{className:"mx-4 flex w-full max-w-md flex-col gap-4 rounded-xl border border-border bg-surface p-5 shadow-xl sm:p-6",children:[(0,a.jsx)("h3",{className:"font-semibold text-text-main",children:"Port 443 Already In Use"}),(0,a.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,a.jsx)(l.default,{className:"text-yellow-500 text-[20px]",children:"warning"}),(0,a.jsxs)("div",{className:"flex flex-col gap-1 text-xs text-text-muted",children:[(0,a.jsx)("p",{children:"Port 443 is currently used by another process:"}),(0,a.jsxs)("p",{className:"font-mono text-text-main","data-i18n-skip":"true",children:[k.owner.name," (PID ",k.owner.pid,")"]}),(0,a.jsx)("p",{children:"Kill this process to start MITM Server?"})]})]}),(0,a.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,a.jsx)(d.$n,{variant:"ghost",size:"sm",onClick:()=>{C(null),c(!1)},disabled:n,children:"Cancel"}),(0,a.jsx)(d.$n,{variant:"primary",size:"sm",onClick:()=>{M("start",k?.password||"",!0)},loading:n,children:"Kill & Start"})]})]})})]})}var eg=s(40295);function ef({tool:e,isExpanded:t,onToggle:s,serverRunning:r,dnsActive:i,hasCachedPassword:n,needsSudoPassword:m,isWin:x,apiKeys:u,activeProviders:p,hasActiveProviders:h,modelAliases:g={},cloudEnabled:f,onDnsChange:j}){let[y,v]=(0,o.useState)(!1),[b,N]=(0,o.useState)(null),[w,_]=(0,o.useState)(!1),[k,C]=(0,o.useState)(""),[S,E]=(0,o.useState)(null),[$,A]=(0,o.useState)(null),[O,M]=(0,o.useState)({}),[P,I]=(0,o.useState)(!1),[U,L]=(0,o.useState)(null),R=eg.TOOL_HOSTS[e.id]??[],T=x||n||!1===m;(0,o.useEffect)(()=>{t&&D()},[t]);let D=async()=>{try{let t=await fetch(`/api/cli-tools/antigravity-mitm/alias?tool=${e.id}`);if(t.ok){let e=await t.json();Object.keys(e.aliases||{}).length>0&&M(e.aliases)}}catch{}},z=(0,o.useCallback)(async t=>{try{await fetch("/api/cli-tools/antigravity-mitm/alias",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:e.id,mappings:t})})}catch{}},[e.id]),K=(e,t)=>{M(s=>({...s,[e]:t}))},F=()=>{if(!r)return;let e=i?"disable":"enable";T?J(e,""):(E(e),_(!0),A(null))},J=async(t,s)=>{v(!0),N(null);try{let a=await fetch("/api/cli-tools/antigravity-mitm",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:e.id,action:t,sudoPassword:s})}),l=await a.json();if(!a.ok)throw Error(l.error||"Failed to toggle DNS");"enable"===t&&N(`Restart ${e.name} to apply changes`),_(!1),C(""),j?.(l)}catch{}finally{v(!1),E(null)}},B=()=>{k.trim()?J(S,k):A("Sudo password is required")};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(d.Zp,{padding:"xs",className:"overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3 hover:cursor-pointer sm:items-center",onClick:s,children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,a.jsx)("div",{className:"size-8 flex items-center justify-center shrink-0",children:(0,a.jsx)(c.default,{src:e.image,alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm",children:e.name}),r?i?(0,a.jsx)(d.Ex,{variant:"success",size:"sm",children:"Active"}):(0,a.jsx)(d.Ex,{variant:"warning",size:"sm",children:"DNS off"}):(0,a.jsx)(d.Ex,{variant:"default",size:"sm",children:"Server off"})]}),(0,a.jsxs)("p",{className:"text-xs text-text-muted sm:truncate",children:["Intercept ",e.name," requests via MITM proxy"]})]})]}),(0,a.jsx)(l.default,{className:`text-text-muted text-[20px] transition-transform ${t?"rotate-180":""}`,children:"expand_more"})]}),t&&(0,a.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[R.length>0&&(0,a.jsxs)("div",{className:"mt-2 rounded-md border border-border bg-surface/50 px-2 py-1.5",children:[(0,a.jsx)("p",{className:"text-[10px] font-medium tracking-wide text-text-main/80 mb-1",children:"Edit hosts file manually to add the following entries:"}),(0,a.jsx)("ul",{className:"list-none space-y-0.5 font-mono text-[10px] text-text-muted break-all",children:R.map(e=>(0,a.jsxs)("li",{children:["127.0.0.1 ",e]},e))})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-0.5 text-[11px] text-text-muted px-1",children:[(0,a.jsxs)("p",{children:["Toggle DNS to redirect ",e.name," traffic through JRouter via MITM."]}),!i&&(0,a.jsx)("p",{className:"text-amber-600 text-[10px] mt-1",children:"⚠️ Enable DNS to edit model mappings"})]}),e.defaultModels?.length>0&&(0,a.jsx)("div",{className:"flex flex-col gap-2",children:e.defaultModels.map(e=>(0,a.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,a.jsx)("span",{className:"text-xs font-semibold text-text-main sm:text-right",children:e.name}),(0,a.jsx)(l.default,{className:"hidden text-text-muted text-[14px] sm:inline",children:"arrow_forward"}),(0,a.jsxs)("div",{className:"relative w-full min-w-0",children:[(0,a.jsx)("input",{type:"text",value:O[e.alias]||"",onChange:t=>K(e.alias,t.target.value),onBlur:t=>{var s,a;return s=e.alias,a=t.target.value,void z({...O,[s]:a})},placeholder:"provider/model-id",disabled:!i,className:`w-full min-w-0 pl-2 pr-7 py-2 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50 sm:py-1.5 ${!i?"opacity-50 cursor-not-allowed":""}`}),O[e.alias]&&(0,a.jsx)("button",{onClick:()=>{K(e.alias,""),z({...O,[e.alias]:""})},className:"absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,a.jsx)(l.default,{className:"text-[14px]",children:"close"})})]}),(0,a.jsx)("button",{onClick:()=>{L(e.alias),I(!0)},disabled:!h||!i,className:`rounded border px-2 py-2 text-xs transition-colors sm:py-1.5 ${h&&i?"bg-surface border-border hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"}`,children:"Select"})]},e.alias))}),e.defaultModels?.length===0&&(0,a.jsx)("p",{className:"text-xs text-text-muted px-1",children:"Model mappings will be available soon."}),(0,a.jsxs)("div",{className:"flex flex-col gap-2 sm:items-start",children:[i?(0,a.jsxs)("button",{onClick:F,disabled:!r||y,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,a.jsx)(l.default,{className:"text-[16px]",children:"stop_circle"}),"Stop DNS"]}):(0,a.jsxs)("button",{onClick:F,disabled:!r||y,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,a.jsx)(l.default,{className:"text-[16px]",children:"play_circle"}),"Start DNS"]}),b&&(0,a.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded text-xs text-amber-500",children:[(0,a.jsx)(l.default,{className:"text-[14px]",children:"warning"}),(0,a.jsx)("span",{children:b})]})]})]})]}),w&&(0,a.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:(0,a.jsxs)("div",{className:"mx-4 flex w-full max-w-sm flex-col gap-4 rounded-xl border border-border bg-surface p-5 shadow-xl sm:p-6",children:[(0,a.jsx)("h3",{className:"font-semibold text-text-main",children:"Sudo Password Required"}),(0,a.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,a.jsx)(l.default,{className:"text-yellow-500 text-[20px]",children:"warning"}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Required to modify /etc/hosts and flush DNS cache"})]}),(0,a.jsx)(d.pd,{type:"password",placeholder:"Enter sudo password",value:k,onChange:e=>C(e.target.value),onKeyDown:e=>{"Enter"!==e.key||y||B()}}),$&&(0,a.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded text-xs bg-red-500/10 text-red-600",children:[(0,a.jsx)(l.default,{className:"text-[14px]",children:"error"}),(0,a.jsx)("span",{children:$})]}),(0,a.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,a.jsx)(d.$n,{variant:"ghost",size:"sm",onClick:()=>{_(!1),C(""),A(null)},disabled:y,children:"Cancel"}),(0,a.jsx)(d.$n,{variant:"primary",size:"sm",onClick:B,loading:y,children:"Confirm"})]})]})}),P&&(0,a.jsx)(d.rq,{isOpen:P,onClose:()=>I(!1),onSelect:e=>{if(!U||e.isPlaceholder)return;let t={...O,[U]:e.value};M(t),z(t)},selectedModel:U?O[U]:null,activeProviders:p,modelAliases:g,title:`Select model for ${U}`})]})}var ej=s(98500),ey=s.n(ej);function ev({tool:e}){return(0,a.jsx)(ey(),{href:"/dashboard/mitm",className:n().toolLink,children:(0,a.jsxs)(d.Zp,{padding:"none",className:n().tile,children:[(0,a.jsx)("div",{className:n().toolIcon,children:(0,a.jsx)(c.default,{src:e.image,alt:e.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:e=>{e.target.style.display="none"},loading:"lazy",decoding:"async"})}),(0,a.jsxs)("div",{className:n().identity,children:[(0,a.jsxs)("div",{className:n().titleLine,children:[(0,a.jsx)("h3",{className:n().title,title:e.name,children:e.name}),(0,a.jsx)(r.A,{dot:!1,className:n().status,children:"MITM"})]}),(0,a.jsx)("p",{className:n().description,title:e.description,children:e.description})]}),(0,a.jsx)(l.default,{className:n().chevron,size:18,children:"chevron_right"})]})})}},30535:e=>{e.exports={page:"cli-tools_page__HS81E usage_page__TfrVH DashboardControls_formScope__ID02o",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 usage_description___N7_0",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 usage_section__Q1FLM",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 DashboardControls_iconButton__v_EJw",modelPicker:"cli-tools_modelPicker__uXuDA DashboardControls_modelPicker__BheYV DashboardControls_dialog__YyPS4"}},40295:e=>{"use strict";e.exports={TOOL_HOSTS:{antigravity:["daily-cloudcode-pa.googleapis.com","cloudcode-pa.googleapis.com"],copilot:["api.individual.githubcopilot.com"],kiro:["runtime.us-east-1.kiro.dev","q.us-east-1.amazonaws.com","codewhisperer.us-east-1.amazonaws.com"],cursor:["api2.cursor.sh"]}}}}]);