switchboard-router 0.6.13 → 0.6.15

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 (348) hide show
  1. package/app/.next-cli-build/BUILD_ID +1 -1
  2. package/app/.next-cli-build/app-path-routes-manifest.json +6 -6
  3. package/app/.next-cli-build/build-manifest.json +2 -2
  4. package/app/.next-cli-build/prerender-manifest.json +3 -3
  5. package/app/.next-cli-build/server/app/(dashboard)/dashboard/agent-library/page.js.nft.json +1 -1
  6. package/app/.next-cli-build/server/app/(dashboard)/dashboard/agent-library/page_client-reference-manifest.js +1 -1
  7. package/app/.next-cli-build/server/app/(dashboard)/dashboard/basic-chat/page.js.nft.json +1 -1
  8. package/app/.next-cli-build/server/app/(dashboard)/dashboard/basic-chat/page_client-reference-manifest.js +1 -1
  9. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page.js.nft.json +1 -1
  10. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page_client-reference-manifest.js +1 -1
  11. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page.js.nft.json +1 -1
  12. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
  13. package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page.js.nft.json +1 -1
  14. package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
  15. package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/routing/page.js.nft.json +1 -1
  16. package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/routing/page_client-reference-manifest.js +1 -1
  17. package/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page.js.nft.json +1 -1
  18. package/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page_client-reference-manifest.js +1 -1
  19. package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page.js.nft.json +1 -1
  20. package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
  21. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page.js.nft.json +1 -1
  22. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page_client-reference-manifest.js +1 -1
  23. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page.js.nft.json +1 -1
  24. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page_client-reference-manifest.js +1 -1
  25. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page.js.nft.json +1 -1
  26. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page_client-reference-manifest.js +1 -1
  27. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/page.js.nft.json +1 -1
  28. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/page_client-reference-manifest.js +1 -1
  29. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page.js.nft.json +1 -1
  30. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page_client-reference-manifest.js +1 -1
  31. package/app/.next-cli-build/server/app/(dashboard)/dashboard/mitm/page.js.nft.json +1 -1
  32. package/app/.next-cli-build/server/app/(dashboard)/dashboard/mitm/page_client-reference-manifest.js +1 -1
  33. package/app/.next-cli-build/server/app/(dashboard)/dashboard/page.js.nft.json +1 -1
  34. package/app/.next-cli-build/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
  35. package/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page.js.nft.json +1 -1
  36. package/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
  37. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page.js +2 -2
  38. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page.js.nft.json +1 -1
  39. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
  40. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page.js.nft.json +1 -1
  41. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
  42. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page.js.nft.json +1 -1
  43. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
  44. package/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page.js.nft.json +1 -1
  45. package/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page_client-reference-manifest.js +1 -1
  46. package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/[id]/page.js.nft.json +1 -1
  47. package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/[id]/page_client-reference-manifest.js +1 -1
  48. package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/page.js.nft.json +1 -1
  49. package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/page_client-reference-manifest.js +1 -1
  50. package/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page.js.nft.json +1 -1
  51. package/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page_client-reference-manifest.js +1 -1
  52. package/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page.js.nft.json +1 -1
  53. package/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
  54. package/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page.js.nft.json +1 -1
  55. package/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
  56. package/app/.next-cli-build/server/app/_global-error/page.js.nft.json +1 -1
  57. package/app/.next-cli-build/server/app/_global-error/page_client-reference-manifest.js +1 -1
  58. package/app/.next-cli-build/server/app/_global-error.html +1 -1
  59. package/app/.next-cli-build/server/app/_global-error.rsc +1 -1
  60. package/app/.next-cli-build/server/app/_global-error.segments/_full.segment.rsc +1 -1
  61. package/app/.next-cli-build/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  62. package/app/.next-cli-build/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  63. package/app/.next-cli-build/server/app/_global-error.segments/_head.segment.rsc +1 -1
  64. package/app/.next-cli-build/server/app/_global-error.segments/_index.segment.rsc +1 -1
  65. package/app/.next-cli-build/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  66. package/app/.next-cli-build/server/app/_not-found/page.js.nft.json +1 -1
  67. package/app/.next-cli-build/server/app/_not-found/page_client-reference-manifest.js +1 -1
  68. package/app/.next-cli-build/server/app/_not-found.html +1 -1
  69. package/app/.next-cli-build/server/app/_not-found.rsc +3 -3
  70. package/app/.next-cli-build/server/app/_not-found.segments/_full.segment.rsc +3 -3
  71. package/app/.next-cli-build/server/app/_not-found.segments/_head.segment.rsc +1 -1
  72. package/app/.next-cli-build/server/app/_not-found.segments/_index.segment.rsc +3 -3
  73. package/app/.next-cli-build/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  74. package/app/.next-cli-build/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  75. package/app/.next-cli-build/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  76. package/app/.next-cli-build/server/app/api/agent-library/catalog/route.js.nft.json +1 -1
  77. package/app/.next-cli-build/server/app/api/agent-library/doctor/route.js.nft.json +1 -1
  78. package/app/.next-cli-build/server/app/api/agent-library/export/route.js.nft.json +1 -1
  79. package/app/.next-cli-build/server/app/api/agent-library/mcp/route.js.nft.json +1 -1
  80. package/app/.next-cli-build/server/app/api/agent-library/route.js.nft.json +1 -1
  81. package/app/.next-cli-build/server/app/api/agent-library/skills/route.js.nft.json +1 -1
  82. package/app/.next-cli-build/server/app/api/agent-library/sync/route.js.nft.json +1 -1
  83. package/app/.next-cli-build/server/app/api/agent-library/updates/route.js.nft.json +1 -1
  84. package/app/.next-cli-build/server/app/api/auth/status/route.js.nft.json +1 -1
  85. package/app/.next-cli-build/server/app/api/cli-tools/aider-settings/route.js +2 -2
  86. package/app/.next-cli-build/server/app/api/cli-tools/aider-settings/route.js.nft.json +1 -1
  87. package/app/.next-cli-build/server/app/api/cli-tools/all-statuses/route.js +4 -4
  88. package/app/.next-cli-build/server/app/api/cli-tools/all-statuses/route.js.nft.json +1 -1
  89. package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/alias/route.js +2 -2
  90. package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/alias/route.js.nft.json +1 -1
  91. package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/route.js.nft.json +1 -1
  92. package/app/.next-cli-build/server/app/api/cli-tools/claude-settings/route.js +2 -2
  93. package/app/.next-cli-build/server/app/api/cli-tools/claude-settings/route.js.nft.json +1 -1
  94. package/app/.next-cli-build/server/app/api/cli-tools/cline-settings/route.js +1 -1
  95. package/app/.next-cli-build/server/app/api/cli-tools/cline-settings/route.js.nft.json +1 -1
  96. package/app/.next-cli-build/server/app/api/cli-tools/codex-settings/route.js +1 -1
  97. package/app/.next-cli-build/server/app/api/cli-tools/codex-settings/route.js.nft.json +1 -1
  98. package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-registry/route.js +1 -1
  99. package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-registry/route.js.nft.json +1 -1
  100. package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-tools/route.js +2 -2
  101. package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-tools/route.js.nft.json +1 -1
  102. package/app/.next-cli-build/server/app/api/cli-tools/cowork-settings/route.js +1 -1
  103. package/app/.next-cli-build/server/app/api/cli-tools/cowork-settings/route.js.nft.json +1 -1
  104. package/app/.next-cli-build/server/app/api/cli-tools/deepseek-tui-settings/route.js +2 -2
  105. package/app/.next-cli-build/server/app/api/cli-tools/deepseek-tui-settings/route.js.nft.json +1 -1
  106. package/app/.next-cli-build/server/app/api/cli-tools/droid-settings/route.js +2 -2
  107. package/app/.next-cli-build/server/app/api/cli-tools/droid-settings/route.js.nft.json +1 -1
  108. package/app/.next-cli-build/server/app/api/cli-tools/gemini-cli-settings/route.js +3 -3
  109. package/app/.next-cli-build/server/app/api/cli-tools/gemini-cli-settings/route.js.nft.json +1 -1
  110. package/app/.next-cli-build/server/app/api/cli-tools/grok-settings/route.js +2 -2
  111. package/app/.next-cli-build/server/app/api/cli-tools/grok-settings/route.js.nft.json +1 -1
  112. package/app/.next-cli-build/server/app/api/cli-tools/hermes-settings/route.js +2 -2
  113. package/app/.next-cli-build/server/app/api/cli-tools/hermes-settings/route.js.nft.json +1 -1
  114. package/app/.next-cli-build/server/app/api/cli-tools/jcode-settings/route.js +2 -2
  115. package/app/.next-cli-build/server/app/api/cli-tools/jcode-settings/route.js.nft.json +1 -1
  116. package/app/.next-cli-build/server/app/api/cli-tools/kilo-settings/route.js +2 -2
  117. package/app/.next-cli-build/server/app/api/cli-tools/kilo-settings/route.js.nft.json +1 -1
  118. package/app/.next-cli-build/server/app/api/cli-tools/openclaw-settings/route.js +1 -1
  119. package/app/.next-cli-build/server/app/api/cli-tools/openclaw-settings/route.js.nft.json +1 -1
  120. package/app/.next-cli-build/server/app/api/cli-tools/opencode-settings/route.js +1 -1
  121. package/app/.next-cli-build/server/app/api/cli-tools/opencode-settings/route.js.nft.json +1 -1
  122. package/app/.next-cli-build/server/app/api/cli-tools/pi-settings/route.js +2 -2
  123. package/app/.next-cli-build/server/app/api/cli-tools/pi-settings/route.js.nft.json +1 -1
  124. package/app/.next-cli-build/server/app/api/combos/[id]/route.js.nft.json +1 -1
  125. package/app/.next-cli-build/server/app/api/combos/route.js.nft.json +1 -1
  126. package/app/.next-cli-build/server/app/api/headroom/proxy/[...path]/route.js.nft.json +1 -1
  127. package/app/.next-cli-build/server/app/api/headroom/start/route.js.nft.json +1 -1
  128. package/app/.next-cli-build/server/app/api/headroom/status/route.js.nft.json +1 -1
  129. package/app/.next-cli-build/server/app/api/headroom/stop/route.js.nft.json +1 -1
  130. package/app/.next-cli-build/server/app/api/health/route.js.nft.json +1 -1
  131. package/app/.next-cli-build/server/app/api/keys/[id]/route.js.nft.json +1 -1
  132. package/app/.next-cli-build/server/app/api/keys/route.js.nft.json +1 -1
  133. package/app/.next-cli-build/server/app/api/locale/route.js.nft.json +1 -1
  134. package/app/.next-cli-build/server/app/api/mcp/[plugin]/message/route.js.nft.json +1 -1
  135. package/app/.next-cli-build/server/app/api/mcp/[plugin]/sse/route.js.nft.json +1 -1
  136. package/app/.next-cli-build/server/app/api/media-providers/tts/deepgram/voices/route.js.nft.json +1 -1
  137. package/app/.next-cli-build/server/app/api/media-providers/tts/elevenlabs/voices/route.js.nft.json +1 -1
  138. package/app/.next-cli-build/server/app/api/media-providers/tts/inworld/voices/route.js.nft.json +1 -1
  139. package/app/.next-cli-build/server/app/api/media-providers/tts/minimax/voices/route.js.nft.json +1 -1
  140. package/app/.next-cli-build/server/app/api/media-providers/tts/voices/route.js.nft.json +1 -1
  141. package/app/.next-cli-build/server/app/api/mgmt/v1/combos/[id]/route.js.nft.json +1 -1
  142. package/app/.next-cli-build/server/app/api/mgmt/v1/combos/[id]/strategy/route.js.nft.json +1 -1
  143. package/app/.next-cli-build/server/app/api/mgmt/v1/combos/route.js.nft.json +1 -1
  144. package/app/.next-cli-build/server/app/api/mgmt/v1/health/route.js.nft.json +1 -1
  145. package/app/.next-cli-build/server/app/api/mgmt/v1/providers/route.js.nft.json +1 -1
  146. package/app/.next-cli-build/server/app/api/mgmt/v1/routing/route.js.nft.json +1 -1
  147. package/app/.next-cli-build/server/app/api/mgmt/v1/usage/route.js.nft.json +1 -1
  148. package/app/.next-cli-build/server/app/api/mgmt/v1/version/route.js.nft.json +1 -1
  149. package/app/.next-cli-build/server/app/api/models/alias/route.js.nft.json +1 -1
  150. package/app/.next-cli-build/server/app/api/models/availability/route.js.nft.json +1 -1
  151. package/app/.next-cli-build/server/app/api/models/custom/route.js.nft.json +1 -1
  152. package/app/.next-cli-build/server/app/api/models/disabled/route.js.nft.json +1 -1
  153. package/app/.next-cli-build/server/app/api/models/route.js.nft.json +1 -1
  154. package/app/.next-cli-build/server/app/api/models/test/route.js.nft.json +1 -1
  155. package/app/.next-cli-build/server/app/api/oauth/[provider]/[action]/route.js +1 -1
  156. package/app/.next-cli-build/server/app/api/oauth/[provider]/[action]/route.js.nft.json +1 -1
  157. package/app/.next-cli-build/server/app/api/oauth/codex/bulk-import/route.js +1 -1
  158. package/app/.next-cli-build/server/app/api/oauth/codex/bulk-import/route.js.nft.json +1 -1
  159. package/app/.next-cli-build/server/app/api/oauth/codex/import-token/route.js +1 -1
  160. package/app/.next-cli-build/server/app/api/oauth/codex/import-token/route.js.nft.json +1 -1
  161. package/app/.next-cli-build/server/app/api/oauth/cursor/auto-import/route.js +3 -3
  162. package/app/.next-cli-build/server/app/api/oauth/cursor/auto-import/route.js.nft.json +1 -1
  163. package/app/.next-cli-build/server/app/api/oauth/cursor/import/route.js.nft.json +1 -1
  164. package/app/.next-cli-build/server/app/api/oauth/gitlab/pat/route.js.nft.json +1 -1
  165. package/app/.next-cli-build/server/app/api/oauth/iflow/cookie/route.js.nft.json +1 -1
  166. package/app/.next-cli-build/server/app/api/oauth/kiro/api-key/route.js.nft.json +1 -1
  167. package/app/.next-cli-build/server/app/api/oauth/kiro/auto-import/route.js.nft.json +1 -1
  168. package/app/.next-cli-build/server/app/api/oauth/kiro/import/route.js.nft.json +1 -1
  169. package/app/.next-cli-build/server/app/api/oauth/kiro/import-cli-proxy/route.js.nft.json +1 -1
  170. package/app/.next-cli-build/server/app/api/oauth/kiro/social-authorize/route.js.nft.json +1 -1
  171. package/app/.next-cli-build/server/app/api/oauth/kiro/social-exchange/route.js.nft.json +1 -1
  172. package/app/.next-cli-build/server/app/api/pricing/route.js.nft.json +1 -1
  173. package/app/.next-cli-build/server/app/api/provider-nodes/[id]/route.js.nft.json +1 -1
  174. package/app/.next-cli-build/server/app/api/provider-nodes/route.js.nft.json +1 -1
  175. package/app/.next-cli-build/server/app/api/provider-nodes/validate/route.js.nft.json +1 -1
  176. package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/batch/route.js.nft.json +1 -1
  177. package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/cache/route.js.nft.json +1 -1
  178. package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/prepare/route.js.nft.json +1 -1
  179. package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/remove-unavailable/route.js.nft.json +1 -1
  180. package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/route.js.nft.json +1 -1
  181. package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/verify/cancel/route.js.nft.json +1 -1
  182. package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/verify/start/route.js.nft.json +1 -1
  183. package/app/.next-cli-build/server/app/api/providers/[id]/model-probes/verify/status/route.js.nft.json +1 -1
  184. package/app/.next-cli-build/server/app/api/providers/[id]/models/route.js +1 -1
  185. package/app/.next-cli-build/server/app/api/providers/[id]/models/route.js.nft.json +1 -1
  186. package/app/.next-cli-build/server/app/api/providers/[id]/route.js.nft.json +1 -1
  187. package/app/.next-cli-build/server/app/api/providers/[id]/test/route.js.nft.json +1 -1
  188. package/app/.next-cli-build/server/app/api/providers/[id]/test-models/route.js.nft.json +1 -1
  189. package/app/.next-cli-build/server/app/api/providers/client/route.js +1 -1
  190. package/app/.next-cli-build/server/app/api/providers/client/route.js.nft.json +1 -1
  191. package/app/.next-cli-build/server/app/api/providers/kilo/free-models/route.js.nft.json +1 -1
  192. package/app/.next-cli-build/server/app/api/providers/route.js.nft.json +1 -1
  193. package/app/.next-cli-build/server/app/api/providers/suggested-models/route.js.nft.json +1 -1
  194. package/app/.next-cli-build/server/app/api/providers/test-batch/route.js.nft.json +1 -1
  195. package/app/.next-cli-build/server/app/api/providers/validate/route.js.nft.json +1 -1
  196. package/app/.next-cli-build/server/app/api/routing/feedback/route.js.nft.json +1 -1
  197. package/app/.next-cli-build/server/app/api/routing/insights/route.js.nft.json +1 -1
  198. package/app/.next-cli-build/server/app/api/routing/learn/route.js.nft.json +1 -1
  199. package/app/.next-cli-build/server/app/api/routing/stats/route.js.nft.json +1 -1
  200. package/app/.next-cli-build/server/app/api/routing/versions/promote/route.js.nft.json +1 -1
  201. package/app/.next-cli-build/server/app/api/routing/versions/rollback/route.js.nft.json +1 -1
  202. package/app/.next-cli-build/server/app/api/settings/database/route.js.nft.json +1 -1
  203. package/app/.next-cli-build/server/app/api/settings/proxy-test/route.js.nft.json +1 -1
  204. package/app/.next-cli-build/server/app/api/settings/route.js +1 -1
  205. package/app/.next-cli-build/server/app/api/settings/route.js.nft.json +1 -1
  206. package/app/.next-cli-build/server/app/api/shutdown/route.js.nft.json +1 -1
  207. package/app/.next-cli-build/server/app/api/skills/[id]/route.js.nft.json +1 -1
  208. package/app/.next-cli-build/server/app/api/tags/route.js.nft.json +1 -1
  209. package/app/.next-cli-build/server/app/api/token-saver/vault-stats/route.js.nft.json +1 -1
  210. package/app/.next-cli-build/server/app/api/translator/console-logs/route.js.nft.json +1 -1
  211. package/app/.next-cli-build/server/app/api/translator/console-logs/stream/route.js.nft.json +1 -1
  212. package/app/.next-cli-build/server/app/api/translator/load/route.js.nft.json +1 -1
  213. package/app/.next-cli-build/server/app/api/translator/save/route.js.nft.json +1 -1
  214. package/app/.next-cli-build/server/app/api/translator/send/route.js +1 -1
  215. package/app/.next-cli-build/server/app/api/translator/send/route.js.nft.json +1 -1
  216. package/app/.next-cli-build/server/app/api/translator/translate/route.js +1 -1
  217. package/app/.next-cli-build/server/app/api/translator/translate/route.js.nft.json +1 -1
  218. package/app/.next-cli-build/server/app/api/usage/[connectionId]/codex-reset-credits/route.js +1 -1
  219. package/app/.next-cli-build/server/app/api/usage/[connectionId]/codex-reset-credits/route.js.nft.json +1 -1
  220. package/app/.next-cli-build/server/app/api/usage/[connectionId]/route.js +1 -1
  221. package/app/.next-cli-build/server/app/api/usage/[connectionId]/route.js.nft.json +1 -1
  222. package/app/.next-cli-build/server/app/api/usage/chart/route.js.nft.json +1 -1
  223. package/app/.next-cli-build/server/app/api/usage/history/route.js.nft.json +1 -1
  224. package/app/.next-cli-build/server/app/api/usage/logs/route.js.nft.json +1 -1
  225. package/app/.next-cli-build/server/app/api/usage/providers/route.js.nft.json +1 -1
  226. package/app/.next-cli-build/server/app/api/usage/request-details/route.js.nft.json +1 -1
  227. package/app/.next-cli-build/server/app/api/usage/request-logs/route.js.nft.json +1 -1
  228. package/app/.next-cli-build/server/app/api/usage/stats/route.js.nft.json +1 -1
  229. package/app/.next-cli-build/server/app/api/usage/stream/route.js.nft.json +1 -1
  230. package/app/.next-cli-build/server/app/api/v1/api/chat/route.js +1 -1
  231. package/app/.next-cli-build/server/app/api/v1/api/chat/route.js.nft.json +1 -1
  232. package/app/.next-cli-build/server/app/api/v1/audio/speech/route.js.nft.json +1 -1
  233. package/app/.next-cli-build/server/app/api/v1/audio/transcriptions/route.js.nft.json +1 -1
  234. package/app/.next-cli-build/server/app/api/v1/audio/voices/route.js.nft.json +1 -1
  235. package/app/.next-cli-build/server/app/api/v1/chat/completions/route.js +1 -1
  236. package/app/.next-cli-build/server/app/api/v1/chat/completions/route.js.nft.json +1 -1
  237. package/app/.next-cli-build/server/app/api/v1/embeddings/route.js +1 -1
  238. package/app/.next-cli-build/server/app/api/v1/embeddings/route.js.nft.json +1 -1
  239. package/app/.next-cli-build/server/app/api/v1/images/generations/route.js +1 -1
  240. package/app/.next-cli-build/server/app/api/v1/images/generations/route.js.nft.json +1 -1
  241. package/app/.next-cli-build/server/app/api/v1/messages/count_tokens/route.js.nft.json +1 -1
  242. package/app/.next-cli-build/server/app/api/v1/messages/route.js +1 -1
  243. package/app/.next-cli-build/server/app/api/v1/messages/route.js.nft.json +1 -1
  244. package/app/.next-cli-build/server/app/api/v1/models/[kind]/route.js +1 -1
  245. package/app/.next-cli-build/server/app/api/v1/models/[kind]/route.js.nft.json +1 -1
  246. package/app/.next-cli-build/server/app/api/v1/models/info/route.js.nft.json +1 -1
  247. package/app/.next-cli-build/server/app/api/v1/models/route.js +1 -1
  248. package/app/.next-cli-build/server/app/api/v1/models/route.js.nft.json +1 -1
  249. package/app/.next-cli-build/server/app/api/v1/responses/compact/route.js +1 -1
  250. package/app/.next-cli-build/server/app/api/v1/responses/compact/route.js.nft.json +1 -1
  251. package/app/.next-cli-build/server/app/api/v1/responses/route.js +1 -1
  252. package/app/.next-cli-build/server/app/api/v1/responses/route.js.nft.json +1 -1
  253. package/app/.next-cli-build/server/app/api/v1/route.js +1 -1
  254. package/app/.next-cli-build/server/app/api/v1/route.js.nft.json +1 -1
  255. package/app/.next-cli-build/server/app/api/v1/search/route.js +1 -1
  256. package/app/.next-cli-build/server/app/api/v1/search/route.js.nft.json +1 -1
  257. package/app/.next-cli-build/server/app/api/v1/web/fetch/route.js +1 -1
  258. package/app/.next-cli-build/server/app/api/v1/web/fetch/route.js.nft.json +1 -1
  259. package/app/.next-cli-build/server/app/api/v1beta/models/[...path]/route.js +1 -1
  260. package/app/.next-cli-build/server/app/api/v1beta/models/[...path]/route.js.nft.json +1 -1
  261. package/app/.next-cli-build/server/app/api/v1beta/models/route.js.nft.json +1 -1
  262. package/app/.next-cli-build/server/app/api/version/route.js +1 -1
  263. package/app/.next-cli-build/server/app/api/version/route.js.nft.json +1 -1
  264. package/app/.next-cli-build/server/app/api/version/shutdown/route.js.nft.json +1 -1
  265. package/app/.next-cli-build/server/app/api/version/update/route.js.nft.json +1 -1
  266. package/app/.next-cli-build/server/app/callback/page.js.nft.json +1 -1
  267. package/app/.next-cli-build/server/app/callback/page_client-reference-manifest.js +1 -1
  268. package/app/.next-cli-build/server/app/callback.html +1 -1
  269. package/app/.next-cli-build/server/app/callback.rsc +3 -3
  270. package/app/.next-cli-build/server/app/callback.segments/_full.segment.rsc +3 -3
  271. package/app/.next-cli-build/server/app/callback.segments/_head.segment.rsc +1 -1
  272. package/app/.next-cli-build/server/app/callback.segments/_index.segment.rsc +3 -3
  273. package/app/.next-cli-build/server/app/callback.segments/_tree.segment.rsc +1 -1
  274. package/app/.next-cli-build/server/app/callback.segments/callback/__PAGE__.segment.rsc +1 -1
  275. package/app/.next-cli-build/server/app/callback.segments/callback.segment.rsc +1 -1
  276. package/app/.next-cli-build/server/app/dashboard/settings/pricing/page.js.nft.json +1 -1
  277. package/app/.next-cli-build/server/app/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
  278. package/app/.next-cli-build/server/app/dashboard/settings/pricing.html +1 -1
  279. package/app/.next-cli-build/server/app/dashboard/settings/pricing.rsc +3 -3
  280. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_full.segment.rsc +3 -3
  281. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_head.segment.rsc +1 -1
  282. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_index.segment.rsc +3 -3
  283. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_tree.segment.rsc +1 -1
  284. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing/__PAGE__.segment.rsc +1 -1
  285. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing.segment.rsc +1 -1
  286. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings.segment.rsc +1 -1
  287. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard.segment.rsc +1 -1
  288. package/app/.next-cli-build/server/app/favicon.ico/route.js.nft.json +1 -1
  289. package/app/.next-cli-build/server/app/index.html +1 -1
  290. package/app/.next-cli-build/server/app/index.rsc +3 -3
  291. package/app/.next-cli-build/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  292. package/app/.next-cli-build/server/app/index.segments/_full.segment.rsc +3 -3
  293. package/app/.next-cli-build/server/app/index.segments/_head.segment.rsc +1 -1
  294. package/app/.next-cli-build/server/app/index.segments/_index.segment.rsc +3 -3
  295. package/app/.next-cli-build/server/app/index.segments/_tree.segment.rsc +1 -1
  296. package/app/.next-cli-build/server/app/landing/page.js.nft.json +1 -1
  297. package/app/.next-cli-build/server/app/landing/page_client-reference-manifest.js +1 -1
  298. package/app/.next-cli-build/server/app/landing.html +1 -1
  299. package/app/.next-cli-build/server/app/landing.rsc +3 -3
  300. package/app/.next-cli-build/server/app/landing.segments/_full.segment.rsc +3 -3
  301. package/app/.next-cli-build/server/app/landing.segments/_head.segment.rsc +1 -1
  302. package/app/.next-cli-build/server/app/landing.segments/_index.segment.rsc +3 -3
  303. package/app/.next-cli-build/server/app/landing.segments/_tree.segment.rsc +1 -1
  304. package/app/.next-cli-build/server/app/landing.segments/landing/__PAGE__.segment.rsc +1 -1
  305. package/app/.next-cli-build/server/app/landing.segments/landing.segment.rsc +1 -1
  306. package/app/.next-cli-build/server/app/login/page.js.nft.json +1 -1
  307. package/app/.next-cli-build/server/app/login/page_client-reference-manifest.js +1 -1
  308. package/app/.next-cli-build/server/app/login.html +1 -1
  309. package/app/.next-cli-build/server/app/login.rsc +3 -3
  310. package/app/.next-cli-build/server/app/login.segments/_full.segment.rsc +3 -3
  311. package/app/.next-cli-build/server/app/login.segments/_head.segment.rsc +1 -1
  312. package/app/.next-cli-build/server/app/login.segments/_index.segment.rsc +3 -3
  313. package/app/.next-cli-build/server/app/login.segments/_tree.segment.rsc +1 -1
  314. package/app/.next-cli-build/server/app/login.segments/login/__PAGE__.segment.rsc +1 -1
  315. package/app/.next-cli-build/server/app/login.segments/login.segment.rsc +1 -1
  316. package/app/.next-cli-build/server/app/manifest.webmanifest/route.js.nft.json +1 -1
  317. package/app/.next-cli-build/server/app/page.js.nft.json +1 -1
  318. package/app/.next-cli-build/server/app/page_client-reference-manifest.js +1 -1
  319. package/app/.next-cli-build/server/app-paths-manifest.json +6 -6
  320. package/app/.next-cli-build/server/chunks/1937.js +10 -0
  321. package/app/.next-cli-build/server/chunks/194.js +1 -1
  322. package/app/.next-cli-build/server/chunks/4126.js +1 -1
  323. package/app/.next-cli-build/server/chunks/4746.js +1 -1
  324. package/app/.next-cli-build/server/chunks/5139.js +1 -1
  325. package/app/.next-cli-build/server/chunks/5615.js +1 -1
  326. package/app/.next-cli-build/server/chunks/688.js +1 -0
  327. package/app/.next-cli-build/server/chunks/7141.js +1 -1
  328. package/app/.next-cli-build/server/chunks/7828.js +4 -1
  329. package/app/.next-cli-build/server/chunks/8400.js +1 -1
  330. package/app/.next-cli-build/server/chunks/869.js +1 -1
  331. package/app/.next-cli-build/server/chunks/8998.js +1 -1
  332. package/app/.next-cli-build/server/chunks/9696.js +1 -1
  333. package/app/.next-cli-build/server/middleware-build-manifest.js +1 -1
  334. package/app/.next-cli-build/server/middleware.js +1 -1
  335. package/app/.next-cli-build/server/pages/404.html +1 -1
  336. package/app/.next-cli-build/server/pages/500.html +1 -1
  337. package/app/.next-cli-build/server/server-reference-manifest.js +1 -1
  338. package/app/.next-cli-build/server/server-reference-manifest.json +1 -1
  339. package/app/.next-cli-build/static/chunks/1321-941975a3154c23e5.js +1 -0
  340. package/app/.next-cli-build/static/chunks/{5497-3d546c1b7aa357b1.js → 5497-f7310b0eb1e78666.js} +2 -2
  341. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/[id]/{page-e023b0417bbc3b44.js → page-1242ee346513608b.js} +2 -2
  342. package/app/package.json +1 -1
  343. package/package.json +1 -1
  344. package/app/.next-cli-build/server/chunks/4192.js +0 -1
  345. package/app/.next-cli-build/server/chunks/4904.js +0 -10
  346. package/app/.next-cli-build/static/chunks/1321-f614c7c6e5ab4bcc.js +0 -1
  347. /package/app/.next-cli-build/static/{y86nLCzoD011gXPeccvk9 → _3QZ47oq1giiHkNB7shrR}/_buildManifest.js +0 -0
  348. /package/app/.next-cli-build/static/{y86nLCzoD011gXPeccvk9 → _3QZ47oq1giiHkNB7shrR}/_ssgManifest.js +0 -0
@@ -1,4 +1,4 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2134],{4003:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>H});var a=s(95155),i=s(12115),r=s(73321),n=s(98500),l=s.n(n),o=s(5772),d=s(35497),c=s(88105),m=s(28777),p=s(16600),u=s(47224);let x=["none","low","medium","high"],h=["none","thinking"],f=["none","low","medium","high","max"],g={openai:["none","minimal","low","medium","high","xhigh"],"claude-adaptive":f,"claude-budget":["none","low","medium","high","xhigh","max"],"gemini-level":["minimal","low","medium","high"],"gemini-budget":x,zai:h,qwen:x,kimi:f,deepseek:["none","high","max"],minimax:h,hunyuan:x,step:x},y=[{pattern:"*codex*",levels:["low","medium","high","xhigh"]}];function b(e,t){let s=(0,p.nl)(e,t);if(!s.reasoning)return null;let a=y.find(e=>(0,u.gH)(e.pattern,t)),i=a?.levels||g[s.thinkingFormat]||x;return!1===s.thinkingCanDisable&&(i=i.filter(e=>"none"!==e)),i}var v=s(11059),j=s(929),w=s(73006);let k=new Map;async function N(e){if(!e?.url||!e?.type||e.requiresAuth)return[];let t=k.get(e.url);if(t&&Date.now()<t.expiresAt)return t.data;try{let t=new URLSearchParams({url:e.url,type:e.type}),s=await fetch(`/api/providers/suggested-models?${t}`);if(!s.ok)return[];let a=(await s.json()).data??[];return k.set(e.url,{data:a,expiresAt:Date.now()+6e5}),a}catch{return[]}}var C=s(81231);function S(e,t={}){let s=t.kind||t.type;if(s&&"string"==typeof s){let e=s.toLowerCase();return"chat"===e||"text"===e||"language"===e?"llm":e}let a=String(e||"").toLowerCase();return/embed/.test(a)?"embedding":/(^|[-_/])(tts|speech)([-_/]|$)/.test(a)?"tts":/(whisper|transcri|speech-to-text|(^|[-_/])stt([-_/]|$))/.test(a)?"stt":/(imagine-video|video-gen|(^|[-_/])video([-_/]|$))/.test(a)&&!/revision/.test(a)?"video":/(imagine-image|dall-e|stable-diffusion|sdxl|flux|midjourney|image-gen)/.test(a)||/(^|[-_/])image([-_/]|$)/.test(a)&&!/(vision|vl|multimodal)/.test(a)?"image":"llm"}function $(e,t){let s=String(e||"").trim();if(!s)return"";if(s=s.replace(/^models\//,""),t){let e=`${t}/`;s.startsWith(e)&&(s=s.slice(e.length))}return(s=s.replace(/^(openai|anthropic|google|x-ai|xai|meta-llama|mistralai)\//i,"")).trim()}var A=s(14051),T=s.n(A);function O({model:e,fullModel:t,alias:s,copied:i,onCopy:r,testStatus:n,isCustom:l,isFree:o,onDeleteAlias:c,onTest:m,isTesting:p,onDisable:u,caps:x,thinkingSuffix:h,latencyMs:f,probeState:g}){let y=h?`${t}(${h})`:t,b="ok"===n?"#22c55e":"error"===n?"#ef4444":void 0;return(0,a.jsx)("div",{className:`group min-w-0 max-w-full rounded-lg border px-3 py-2 ${"ok"===n?"border-green-500/40":"error"===n?"border-red-500/40":"border-border"} hover:bg-sidebar/50`,children:(0,a.jsxs)("div",{className:"flex min-w-0 items-start gap-2 sm:items-center",children:[(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-base",style:b?{color:b}:void 0,children:"ok"===n?"check_circle":"error"===n?"cancel":"smart_toy"}),(0,a.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("code",{className:"max-w-[72vw] truncate rounded bg-sidebar px-1.5 py-0.5 font-mono text-xs text-text-muted sm:max-w-[360px]",children:y}),g&&("testing"===g?(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 animate-spin text-[14px] text-text-muted",title:"Testing...",children:"progress_activity"}):(0,a.jsx)("span",{title:"ok"===g?"Reachable":"dead"===g?"Unavailable (dead)":"Retry later",className:`shrink-0 inline-block h-2 w-2 rounded-full ${"ok"===g?"bg-green-500":"dead"===g?"bg-red-500":"bg-amber-500"}`}))]}),(0,a.jsxs)("span",{className:"flex min-w-0 items-center text-[9px] gap-1 pl-1",children:[e.name&&(0,a.jsx)("span",{className:"truncate text-[9px] italic text-text-muted/70",children:e.name}),Number.isFinite(f)&&(0,a.jsxs)("span",{className:"shrink-0 text-[9px] text-text-muted/70 tabular-nums",children:[Math.round(f),"ms"]}),(0,a.jsx)(d.nh,{caps:x,colorOverride:"text-text-muted/70",size:12})]})]}),m&&(0,a.jsxs)("div",{className:"relative shrink-0 group/btn",children:[(0,a.jsx)("button",{onClick:m,disabled:p,className:`rounded p-0.5 text-text-muted transition-opacity hover:bg-sidebar hover:text-primary ${p?"opacity-100":"opacity-100 sm:opacity-0 sm:group-hover:opacity-100"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",style:p?{animation:"spin 1s linear infinite"}:void 0,children:p?"progress_activity":"science"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute mt-1 top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:p?"Testing...":"Test"})]}),(0,a.jsxs)("div",{className:"relative shrink-0 group/btn",children:[(0,a.jsx)("button",{onClick:()=>r(y,`model-${e.id}`),className:"rounded p-0.5 text-text-muted hover:bg-sidebar hover:text-primary",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:i===`model-${e.id}`?"check":"content_copy"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute mt-1 top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:i===`model-${e.id}`?"Copied!":"Copy"})]}),l?(0,a.jsx)("button",{onClick:c,className:"ml-auto rounded p-0.5 text-text-muted opacity-100 transition-opacity hover:bg-red-500/10 hover:text-red-500 sm:opacity-0 sm:group-hover:opacity-100",title:"Remove custom model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"close"})}):u?(0,a.jsx)("button",{onClick:u,className:"ml-auto rounded p-0.5 text-text-muted opacity-100 transition-opacity hover:bg-red-500/10 hover:text-red-500 sm:opacity-0 sm:group-hover:opacity-100",title:"Disable this model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"close"})}):null]})})}O.propTypes={model:T().shape({id:T().string.isRequired}).isRequired,fullModel:T().string.isRequired,alias:T().string,copied:T().string,onCopy:T().func.isRequired,testStatus:T().oneOf(["ok","error"]),isCustom:T().bool,isFree:T().bool,onDeleteAlias:T().func,onTest:T().func,isTesting:T().bool,onDisable:T().func,caps:T().object,thinkingSuffix:T().string,latencyMs:T().number,probeState:T().string};var E=s(78559);function R({modelId:e,fullModel:t,copied:s,onCopy:i,onDeleteAlias:r,onTest:n,testStatus:l,isTesting:o}){let d="ok"===l?"#22c55e":"error"===l?"#ef4444":void 0;return(0,a.jsxs)("div",{className:`flex items-center gap-3 p-3 rounded-lg border ${"ok"===l?"border-green-500/40":"error"===l?"border-red-500/40":"border-border"} hover:bg-sidebar/50`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base text-text-muted",style:d?{color:d}:void 0,children:"ok"===l?"check_circle":"error"===l?"cancel":"smart_toy"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"text-sm font-medium truncate",children:e}),(0,a.jsxs)("div",{className:"flex items-center gap-1 mt-1",children:[(0,a.jsx)("code",{className:"text-xs text-text-muted font-mono bg-sidebar px-1.5 py-0.5 rounded",children:t}),(0,a.jsxs)("div",{className:"relative group/btn",children:[(0,a.jsx)("button",{onClick:()=>i(t,`model-${e}`),className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:s===`model-${e}`?"check":"content_copy"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:s===`model-${e}`?"Copied!":"Copy"})]}),n&&(0,a.jsxs)("div",{className:"relative group/btn",children:[(0,a.jsx)("button",{onClick:n,disabled:o,className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",style:o?{animation:"spin 1s linear infinite"}:void 0,children:o?"progress_activity":"science"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:o?"Testing...":"Test"})]})]})]}),(0,a.jsx)("button",{onClick:r,className:"p-1 hover:bg-red-50 rounded text-red-500",title:"Remove model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"delete"})})]})}function D({providerStorageAlias:e,providerDisplayAlias:t,modelAliases:s,customModels:r,copied:n,onCopy:l,onDeleteAlias:o,onAddCustomModel:c,onDeleteCustomModel:m,onRefreshModels:p,connections:u,isAnthropic:x}){let[h,f]=(0,i.useState)(""),[g,y]=(0,i.useState)(!1),[b,v]=(0,i.useState)(!1),[j,w]=(0,i.useState)(""),[k,N]=(0,i.useState)(null),[S,$]=(0,i.useState)({}),A=async t=>{if(!k){N(t);try{let s=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${e}/${t}`})}),a=await s.json();$(e=>({...e,[t]:a.ok?"ok":"error"}))}catch{$(e=>({...e,[t]:"error"}))}finally{N(null)}}},T=(0,C.R)({customModels:r,modelAliases:s,providerAlias:e,type:"llm"}),O=async()=>{if(!h.trim()||g)return;let e=h.trim();if(T.some(t=>t.id===e))return void(0,E.s)("Model already exists for this provider.");y(!0);try{await c(e),f("")}catch(e){(0,E.s)("Error adding model:",e)}finally{y(!1)}},I=async()=>{if(b)return;let t=u.find(e=>!1!==e.isActive);if(t){v(!0),w("");try{let s=await fetch(`/api/providers/${t.id}/models`),a=await s.json().catch(()=>({}));if(!s.ok)return void(0,E.s)(a.error||"Failed to import models");let i=a.models||[];if(0===i.length)return void(0,E.s)("No models returned from /models.");let r=new Set(T.map(e=>e.id)),n=[],l=new Set;for(let t of i){let s=String(t.id||t.name||t.model||"").trim();!s||r.has(s)||l.has(s)||(l.add(s),n.push({providerAlias:e,id:s,type:"llm",name:t.display_name||t.displayName||t.name||s}))}if(0===n.length)return void w("All models already in list");let o=await fetch("/api/models/custom",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({models:n})}),d=await o.json().catch(()=>({}));if(!o.ok){let e=0;for(let t of n)await c(t.id),e+=1;w(e?`Imported ${e} model(s)`:"No new models were added");return}w(`Imported ${d.added??n.length} model(s)`),"function"==typeof p?await p():window.dispatchEvent(new CustomEvent("customModelChanged"))}catch(e){(0,E.s)("Error importing models:",e),(0,E.s)(e?.message||"Import failed")}finally{v(!1)}}},P=u.some(e=>!1!==e.isActive);return(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("p",{className:"text-sm text-text-muted",children:["Add ",x?"Anthropic":"OpenAI","-compatible models manually or import them from the /models endpoint."]}),(0,a.jsxs)("div",{className:"flex items-end gap-2 flex-wrap",children:[(0,a.jsxs)("div",{className:"flex-1 min-w-[240px]",children:[(0,a.jsx)("label",{htmlFor:"new-compatible-model-input",className:"text-xs text-text-muted mb-1 block",children:"Model ID"}),(0,a.jsx)("input",{id:"new-compatible-model-input",type:"text",value:h,onChange:e=>f(e.target.value),onKeyDown:e=>"Enter"===e.key&&O(),placeholder:x?"claude-3-opus-20240229":"gpt-4o",className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})]}),(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:O,disabled:!h.trim()||g,children:g?"Adding...":"Add"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"cloud_download",onClick:I,disabled:!P||b,children:b?"Importing...":"Import models"})]}),!P&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Add a connection to enable importing models."}),j&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:j}),T.length>0&&(0,a.jsx)("div",{className:"flex flex-col gap-3",children:T.map(({id:s,alias:i,source:r})=>(0,a.jsx)(R,{modelId:s,fullModel:`${t}/${s}`,copied:n,onCopy:l,onDeleteAlias:()=>"custom"===r?m(s):o(i),onTest:u.length>0?()=>A(s):void 0,testStatus:S[s],isTesting:k===s},`${r}-${e}/${s}`))})]})}T().string.isRequired,T().string.isRequired,T().string,T().func.isRequired,T().func.isRequired,T().func,T().oneOf(["ok","error"]),T().bool,T().string.isRequired,T().object.isRequired,T().arrayOf(T().object),T().string,T().func.isRequired,T().func.isRequired,T().func.isRequired,T().func.isRequired,D.propTypes={providerStorageAlias:T().string.isRequired,providerDisplayAlias:T().string.isRequired,modelAliases:T().object.isRequired,customModels:T().arrayOf(T().object),copied:T().string,onCopy:T().func.isRequired,onDeleteAlias:T().func.isRequired,onAddCustomModel:T().func.isRequired,onDeleteCustomModel:T().func.isRequired,onRefreshModels:T().func,connections:T().arrayOf(T().shape({id:T().string,isActive:T().bool})).isRequired,isAnthropic:T().bool};var I=s(70217);function P({until:e}){let[t,s]=(0,i.useState)("");return((0,i.useEffect)(()=>{let t=()=>{let t=new Date(e).getTime()-Date.now();if(t<=0)return void s("");let a=Math.floor(t/1e3);if(a<60)s(`${a}s`);else if(a<3600)s(`${Math.floor(a/60)}m ${a%60}s`);else{let e=Math.floor(a/3600),t=Math.floor(a%3600/60);s(`${e}h ${t}m`)}};t();let a=setInterval(t,1e3);return()=>clearInterval(a)},[e]),t)?(0,a.jsxs)("span",{className:"text-xs text-orange-500 font-mono",children:["⏱ ",t]}):null}function M({connection:e,isOAuth:t,isFirst:s,isLast:r,onMoveUp:n,onMoveDown:l,onToggleActive:o,onEdit:c,onDelete:m,onAllowlistHost:p=null,oneByOneStatus:u=null,autoPing:x=null}){let h=/SSRF blocked|Blocked URL: (private IP|internal host)/i.test(e.lastError||""),f=e.providerSpecificData?.connectionProxyEnabled===!0&&!!e.providerSpecificData?.connectionProxyUrl,g=f?`Proxy: ${e.providerSpecificData?.connectionProxyUrl}`:"",y=x?.provider==="codex"?"Auto-starts the next 5h Codex window after reset by sending a tiny gpt-5.5 request. Consumes a small amount of quota.":"When your 5h quota runs out, auto-sends a request the moment it resets so a new window starts right away.",b="";if(e.providerSpecificData?.connectionProxyUrl){let t=e.providerSpecificData?.connectionProxyUrl;try{let e=new URL(t);b=`${e.protocol}//${e.hostname}${e.port?`:${e.port}`:""}`}catch{b=t}}let v=e.providerSpecificData?.connectionNoProxy||"",j=f?"success":"default",w=e.authType||(t?"oauth":"apikey"),k="oauth"===w,N="cookie"===w,C=e.name?.trim()||e.email?.trim()||e.displayName?.trim()||(k?"OAuth Account":N?"Cookie Account":"API Key"),S=e.name?.trim()&&e.email?.trim()&&e.name.trim()!==e.email.trim()?e.email.trim():e.name?.trim()&&e.displayName?.trim()&&e.name.trim()!==e.displayName.trim()?e.displayName.trim():null,[$,A]=(0,i.useState)(!1),T=Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>e).filter(e=>!!e).sort()[0]||null;(0,i.useEffect)(()=>{let t=()=>{A(!!Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>e).filter(e=>e&&new Date(e).getTime()>Date.now()).sort()[0])};t();let s=T?setInterval(t,1e3):null;return()=>{s&&clearInterval(s)}},[e,T]);let O="unavailable"!==e.testStatus||$?e.testStatus:"active",E=()=>u?"queued"===u.state?"queued":"testing"===u.state?"testing":"success"===u.state?"success":"failed"===u.state?u.error?`failed: ${u.error}`:"failed":null:null;return(0,a.jsxs)("div",{className:`group flex min-w-0 flex-col gap-3 rounded-lg p-2 transition-colors hover:bg-black/[0.02] dark:hover:bg-white/[0.02] sm:flex-row sm:items-center sm:justify-between ${!1===e.isActive?"opacity-60":""}`,children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-1 items-start gap-2 sm:items-center sm:gap-3",children:[(0,a.jsxs)("div",{className:"flex shrink-0 flex-col",children:[(0,a.jsx)("button",{onClick:n,disabled:s,className:`p-0.5 rounded ${s?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_up"})}),(0,a.jsx)("button",{onClick:l,disabled:r,className:`p-0.5 rounded ${r?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_down"})})]}),(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-base text-text-muted",children:N?"cookie":k?"lock":"key"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"text-sm font-medium truncate",children:C}),S&&(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:S}),(0,a.jsxs)("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1.5 sm:gap-2",children:[(0,a.jsx)(d.Ex,{variant:(0,I.g)(e.isActive,O),size:"sm",dot:!0,children:!1===e.isActive?"disabled":O||"Unknown"}),(0,a.jsx)(d.Ex,{variant:"default",size:"sm",children:k?"OAuth":N?"Cookie":"API Key"}),f&&(0,a.jsx)(d.Ex,{variant:j,size:"sm",children:"Proxy"}),$&&!1!==e.isActive&&(0,a.jsx)(P,{until:T}),e.lastError&&!1!==e.isActive&&(0,a.jsx)("span",{className:"max-w-full truncate text-xs text-red-500 sm:max-w-[300px]",title:e.lastError,children:e.lastError}),h&&!1!==e.isActive&&p&&(0,a.jsxs)("button",{onClick:p,title:"Trust this host past the SSRF guard and retry",className:"inline-flex items-center gap-1 rounded border border-amber-500/40 px-1.5 py-0.5 text-xs text-amber-600 hover:bg-amber-500/10 dark:text-amber-400",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"verified_user"}),"Add to allow list"]}),(0,a.jsxs)("span",{className:"text-xs text-text-muted",children:["#",e.priority]}),e.globalPriority&&(0,a.jsxs)("span",{className:"text-xs text-text-muted",children:["Auto: ",e.globalPriority]}),E()&&(0,a.jsx)(d.Ex,{variant:u?"success"===u.state?"success":"failed"===u.state?"error":"testing"===u.state?"primary":"default":"default",size:"sm",children:E()})]}),f&&(0,a.jsxs)("div",{className:"mt-1 flex items-center gap-2 flex-wrap",children:[(0,a.jsx)("span",{className:"max-w-full truncate text-[11px] text-text-muted sm:max-w-[420px]",title:g,children:g}),b&&(0,a.jsx)("code",{className:"max-w-full truncate rounded bg-black/5 px-1 py-0.5 font-mono text-[10px] text-text-muted dark:bg-white/5 sm:max-w-[260px]",children:b}),v&&(0,a.jsxs)("span",{className:"max-w-full truncate text-[11px] text-text-muted sm:max-w-[320px]",title:v,children:["no_proxy: ",v]})]})]})]}),(0,a.jsxs)("div",{className:"flex w-full items-center justify-between gap-2 sm:w-auto sm:justify-end",children:[(0,a.jsxs)("div",{className:"grid flex-1 grid-cols-3 gap-1 sm:flex sm:flex-none",children:[x&&(0,a.jsx)(d.m_,{text:y,children:(0,a.jsxs)("button",{onClick:()=>x.onToggle(!x.on),className:`flex w-full flex-col items-center rounded px-2 py-1 transition-colors hover:bg-black/5 dark:hover:bg-white/5 ${x.on?"text-primary":"text-text-muted hover:text-primary"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"bolt"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Auto-ping"})]})}),(0,a.jsxs)("button",{onClick:c,className:"flex flex-col items-center rounded px-2 py-1 text-text-muted hover:bg-black/5 hover:text-primary dark:hover:bg-white/5",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"edit"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Edit"})]}),(0,a.jsxs)("button",{onClick:m,className:"flex flex-col items-center rounded px-2 py-1 text-red-500 hover:bg-red-500/10",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"delete"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Delete"})]})]}),(0,a.jsx)(d.lM,{size:"sm",checked:e.isActive??!0,onChange:o,title:e.isActive??!0?"Disable connection":"Enable connection"})]})]})}P.propTypes={until:T().string.isRequired},M.propTypes={connection:T().shape({id:T().string,name:T().string,email:T().string,displayName:T().string,modelLockUntil:T().string,testStatus:T().string,isActive:T().bool,lastError:T().string,priority:T().number,globalPriority:T().number,providerSpecificData:T().object}).isRequired,isOAuth:T().bool.isRequired,isFirst:T().bool.isRequired,isLast:T().bool.isRequired,onMoveUp:T().func.isRequired,onMoveDown:T().func.isRequired,onToggleActive:T().func.isRequired,onEdit:T().func.isRequired,onDelete:T().func.isRequired,onAllowlistHost:T().func,oneByOneStatus:T().shape({state:T().string,error:T().string}),autoPing:T().shape({on:T().bool,onToggle:T().func,provider:T().string})};let z=`name1|sk-key1
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2134],{4003:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>H});var a=s(95155),i=s(12115),r=s(73321),n=s(98500),l=s.n(n),o=s(5772),d=s(35497),c=s(88105),m=s(28777),p=s(16600),u=s(47224);let x=["none","low","medium","high"],h=["none","thinking"],f=["none","low","medium","high","max"],g={openai:["none","minimal","low","medium","high","xhigh"],"claude-adaptive":f,"claude-budget":["none","low","medium","high","xhigh","max"],"gemini-level":["minimal","low","medium","high"],"gemini-budget":x,zai:h,qwen:x,kimi:f,deepseek:["none","high","max"],minimax:h,hunyuan:x,step:x},y=[{pattern:"*codex*",levels:["low","medium","high","xhigh"]}];function b(e,t){let s=(0,p.nl)(e,t);if(!s.reasoning)return null;let a=y.find(e=>(0,u.gH)(e.pattern,t)),i=a?.levels||g[s.thinkingFormat]||x;return!1===s.thinkingCanDisable&&(i=i.filter(e=>"none"!==e)),i}var v=s(11059),j=s(929),w=s(73006);let k=new Map;async function N(e){if(!e?.url||!e?.type||e.requiresAuth)return[];let t=k.get(e.url);if(t&&Date.now()<t.expiresAt)return t.data;try{let t=new URLSearchParams({url:e.url,type:e.type}),s=await fetch(`/api/providers/suggested-models?${t}`);if(!s.ok)return[];let a=(await s.json()).data??[];return k.set(e.url,{data:a,expiresAt:Date.now()+6e5}),a}catch{return[]}}var C=s(81231);function S(e,t={}){let s=t.kind||t.type;if(s&&"string"==typeof s){let e=s.toLowerCase();return"chat"===e||"text"===e||"language"===e?"llm":e}let a=String(e||"").toLowerCase();return/embed/.test(a)?"embedding":/(^|[-_/])(tts|speech)([-_/]|$)/.test(a)?"tts":/(whisper|transcri|speech-to-text|(^|[-_/])stt([-_/]|$))/.test(a)?"stt":/(imagine-video|video-gen|(^|[-_/])video([-_/]|$))/.test(a)&&!/revision/.test(a)?"video":/(imagine-image|dall-e|stable-diffusion|sdxl|flux|midjourney|image-gen)/.test(a)||/(^|[-_/])image([-_/]|$)/.test(a)&&!/(vision|vl|multimodal)/.test(a)?"image":"llm"}function $(e,t){let s=String(e||"").trim();if(!s)return"";if(s=s.replace(/^models\//,""),t){let e=`${t}/`;s.startsWith(e)&&(s=s.slice(e.length))}return(s=s.replace(/^(openai|anthropic|google|x-ai|xai|meta-llama|mistralai)\//i,"")).trim()}var A=s(14051),T=s.n(A);function O({model:e,fullModel:t,alias:s,copied:i,onCopy:r,testStatus:n,isCustom:l,isFree:o,onDeleteAlias:c,onTest:m,isTesting:p,onDisable:u,caps:x,thinkingSuffix:h,latencyMs:f,probeState:g}){let y=h?`${t}(${h})`:t,b="ok"===n?"#22c55e":"error"===n?"#ef4444":void 0;return(0,a.jsx)("div",{className:`group min-w-0 max-w-full rounded-lg border px-3 py-2 ${"ok"===n?"border-green-500/40":"error"===n?"border-red-500/40":"border-border"} hover:bg-sidebar/50`,children:(0,a.jsxs)("div",{className:"flex min-w-0 items-start gap-2 sm:items-center",children:[(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-base",style:b?{color:b}:void 0,children:"ok"===n?"check_circle":"error"===n?"cancel":"smart_toy"}),(0,a.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("code",{className:"max-w-[72vw] truncate rounded bg-sidebar px-1.5 py-0.5 font-mono text-xs text-text-muted sm:max-w-[360px]",children:y}),g&&("testing"===g?(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 animate-spin text-[14px] text-text-muted",title:"Testing...",children:"progress_activity"}):(0,a.jsx)("span",{title:"ok"===g?"Reachable":"dead"===g?"Unavailable (dead)":"Retry later",className:`shrink-0 inline-block h-2 w-2 rounded-full ${"ok"===g?"bg-green-500":"dead"===g?"bg-red-500":"bg-amber-500"}`}))]}),(0,a.jsxs)("span",{className:"flex min-w-0 items-center text-[9px] gap-1 pl-1",children:[e.name&&(0,a.jsx)("span",{className:"truncate text-[9px] italic text-text-muted/70",children:e.name}),Number.isFinite(f)&&(0,a.jsxs)("span",{className:"shrink-0 text-[9px] text-text-muted/70 tabular-nums",children:[Math.round(f),"ms"]}),(0,a.jsx)(d.nh,{caps:x,colorOverride:"text-text-muted/70",size:12})]})]}),m&&(0,a.jsxs)("div",{className:"relative shrink-0 group/btn",children:[(0,a.jsx)("button",{onClick:m,disabled:p,className:`rounded p-0.5 text-text-muted transition-opacity hover:bg-sidebar hover:text-primary ${p?"opacity-100":"opacity-100 sm:opacity-0 sm:group-hover:opacity-100"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",style:p?{animation:"spin 1s linear infinite"}:void 0,children:p?"progress_activity":"science"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute mt-1 top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:p?"Testing...":"Test"})]}),(0,a.jsxs)("div",{className:"relative shrink-0 group/btn",children:[(0,a.jsx)("button",{onClick:()=>r(y,`model-${e.id}`),className:"rounded p-0.5 text-text-muted hover:bg-sidebar hover:text-primary",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:i===`model-${e.id}`?"check":"content_copy"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute mt-1 top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:i===`model-${e.id}`?"Copied!":"Copy"})]}),l?(0,a.jsx)("button",{onClick:c,className:"ml-auto rounded p-0.5 text-text-muted opacity-100 transition-opacity hover:bg-red-500/10 hover:text-red-500 sm:opacity-0 sm:group-hover:opacity-100",title:"Remove custom model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"close"})}):u?(0,a.jsx)("button",{onClick:u,className:"ml-auto rounded p-0.5 text-text-muted opacity-100 transition-opacity hover:bg-red-500/10 hover:text-red-500 sm:opacity-0 sm:group-hover:opacity-100",title:"Disable this model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"close"})}):null]})})}O.propTypes={model:T().shape({id:T().string.isRequired}).isRequired,fullModel:T().string.isRequired,alias:T().string,copied:T().string,onCopy:T().func.isRequired,testStatus:T().oneOf(["ok","error"]),isCustom:T().bool,isFree:T().bool,onDeleteAlias:T().func,onTest:T().func,isTesting:T().bool,onDisable:T().func,caps:T().object,thinkingSuffix:T().string,latencyMs:T().number,probeState:T().string};var E=s(78559);function R({modelId:e,fullModel:t,copied:s,onCopy:i,onDeleteAlias:r,onTest:n,testStatus:l,isTesting:o}){let d="ok"===l?"#22c55e":"error"===l?"#ef4444":void 0;return(0,a.jsxs)("div",{className:`flex items-center gap-3 p-3 rounded-lg border ${"ok"===l?"border-green-500/40":"error"===l?"border-red-500/40":"border-border"} hover:bg-sidebar/50`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base text-text-muted",style:d?{color:d}:void 0,children:"ok"===l?"check_circle":"error"===l?"cancel":"smart_toy"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"text-sm font-medium truncate",children:e}),(0,a.jsxs)("div",{className:"flex items-center gap-1 mt-1",children:[(0,a.jsx)("code",{className:"text-xs text-text-muted font-mono bg-sidebar px-1.5 py-0.5 rounded",children:t}),(0,a.jsxs)("div",{className:"relative group/btn",children:[(0,a.jsx)("button",{onClick:()=>i(t,`model-${e}`),className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:s===`model-${e}`?"check":"content_copy"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:s===`model-${e}`?"Copied!":"Copy"})]}),n&&(0,a.jsxs)("div",{className:"relative group/btn",children:[(0,a.jsx)("button",{onClick:n,disabled:o,className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",style:o?{animation:"spin 1s linear infinite"}:void 0,children:o?"progress_activity":"science"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:o?"Testing...":"Test"})]})]})]}),(0,a.jsx)("button",{onClick:r,className:"p-1 hover:bg-red-50 rounded text-red-500",title:"Remove model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"delete"})})]})}function D({providerStorageAlias:e,providerDisplayAlias:t,modelAliases:s,customModels:r,copied:n,onCopy:l,onDeleteAlias:o,onAddCustomModel:c,onDeleteCustomModel:m,onRefreshModels:p,connections:u,isAnthropic:x}){let[h,f]=(0,i.useState)(""),[g,y]=(0,i.useState)(!1),[b,v]=(0,i.useState)(!1),[j,w]=(0,i.useState)(""),[k,N]=(0,i.useState)(null),[S,$]=(0,i.useState)({}),A=async t=>{if(!k){N(t);try{let s=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${e}/${t}`})}),a=await s.json();$(e=>({...e,[t]:a.ok?"ok":"error"}))}catch{$(e=>({...e,[t]:"error"}))}finally{N(null)}}},T=(0,C.R3)({customModels:r,modelAliases:s,providerAlias:e,type:"llm"}),O=async()=>{if(!h.trim()||g)return;let e=h.trim();if(T.some(t=>t.id===e))return void(0,E.s)("Model already exists for this provider.");y(!0);try{await c(e),f("")}catch(e){(0,E.s)("Error adding model:",e)}finally{y(!1)}},I=async()=>{if(b)return;let t=u.find(e=>!1!==e.isActive);if(t){v(!0),w("");try{let s=await fetch(`/api/providers/${t.id}/models`),a=await s.json().catch(()=>({}));if(!s.ok)return void(0,E.s)(a.error||"Failed to import models");let i=a.models||[];if(0===i.length)return void(0,E.s)("No models returned from /models.");let r=new Set(T.map(e=>e.id)),n=[],l=new Set;for(let t of i){let s=String(t.id||t.name||t.model||"").trim();!s||r.has(s)||l.has(s)||(l.add(s),n.push({providerAlias:e,id:s,type:"llm",name:t.display_name||t.displayName||t.name||s}))}if(0===n.length)return void w("All models already in list");let o=await fetch("/api/models/custom",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({models:n})}),d=await o.json().catch(()=>({}));if(!o.ok){let e=0;for(let t of n)await c(t.id),e+=1;w(e?`Imported ${e} model(s)`:"No new models were added");return}w(`Imported ${d.added??n.length} model(s)`),"function"==typeof p?await p():window.dispatchEvent(new CustomEvent("customModelChanged"))}catch(e){(0,E.s)("Error importing models:",e),(0,E.s)(e?.message||"Import failed")}finally{v(!1)}}},P=u.some(e=>!1!==e.isActive);return(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("p",{className:"text-sm text-text-muted",children:["Add ",x?"Anthropic":"OpenAI","-compatible models manually or import them from the /models endpoint."]}),(0,a.jsxs)("div",{className:"flex items-end gap-2 flex-wrap",children:[(0,a.jsxs)("div",{className:"flex-1 min-w-[240px]",children:[(0,a.jsx)("label",{htmlFor:"new-compatible-model-input",className:"text-xs text-text-muted mb-1 block",children:"Model ID"}),(0,a.jsx)("input",{id:"new-compatible-model-input",type:"text",value:h,onChange:e=>f(e.target.value),onKeyDown:e=>"Enter"===e.key&&O(),placeholder:x?"claude-3-opus-20240229":"gpt-4o",className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})]}),(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:O,disabled:!h.trim()||g,children:g?"Adding...":"Add"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"cloud_download",onClick:I,disabled:!P||b,children:b?"Importing...":"Import models"})]}),!P&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Add a connection to enable importing models."}),j&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:j}),T.length>0&&(0,a.jsx)("div",{className:"flex flex-col gap-3",children:T.map(({id:s,alias:i,source:r})=>(0,a.jsx)(R,{modelId:s,fullModel:`${t}/${s}`,copied:n,onCopy:l,onDeleteAlias:()=>"custom"===r?m(s):o(i),onTest:u.length>0?()=>A(s):void 0,testStatus:S[s],isTesting:k===s},`${r}-${e}/${s}`))})]})}T().string.isRequired,T().string.isRequired,T().string,T().func.isRequired,T().func.isRequired,T().func,T().oneOf(["ok","error"]),T().bool,T().string.isRequired,T().object.isRequired,T().arrayOf(T().object),T().string,T().func.isRequired,T().func.isRequired,T().func.isRequired,T().func.isRequired,D.propTypes={providerStorageAlias:T().string.isRequired,providerDisplayAlias:T().string.isRequired,modelAliases:T().object.isRequired,customModels:T().arrayOf(T().object),copied:T().string,onCopy:T().func.isRequired,onDeleteAlias:T().func.isRequired,onAddCustomModel:T().func.isRequired,onDeleteCustomModel:T().func.isRequired,onRefreshModels:T().func,connections:T().arrayOf(T().shape({id:T().string,isActive:T().bool})).isRequired,isAnthropic:T().bool};var I=s(70217);function P({until:e}){let[t,s]=(0,i.useState)("");return((0,i.useEffect)(()=>{let t=()=>{let t=new Date(e).getTime()-Date.now();if(t<=0)return void s("");let a=Math.floor(t/1e3);if(a<60)s(`${a}s`);else if(a<3600)s(`${Math.floor(a/60)}m ${a%60}s`);else{let e=Math.floor(a/3600),t=Math.floor(a%3600/60);s(`${e}h ${t}m`)}};t();let a=setInterval(t,1e3);return()=>clearInterval(a)},[e]),t)?(0,a.jsxs)("span",{className:"text-xs text-orange-500 font-mono",children:["⏱ ",t]}):null}function M({connection:e,isOAuth:t,isFirst:s,isLast:r,onMoveUp:n,onMoveDown:l,onToggleActive:o,onEdit:c,onDelete:m,onAllowlistHost:p=null,oneByOneStatus:u=null,autoPing:x=null}){let h=/SSRF blocked|Blocked URL: (private IP|internal host)/i.test(e.lastError||""),f=e.providerSpecificData?.connectionProxyEnabled===!0&&!!e.providerSpecificData?.connectionProxyUrl,g=f?`Proxy: ${e.providerSpecificData?.connectionProxyUrl}`:"",y=x?.provider==="codex"?"Auto-starts the next 5h Codex window after reset by sending a tiny gpt-5.5 request. Consumes a small amount of quota.":"When your 5h quota runs out, auto-sends a request the moment it resets so a new window starts right away.",b="";if(e.providerSpecificData?.connectionProxyUrl){let t=e.providerSpecificData?.connectionProxyUrl;try{let e=new URL(t);b=`${e.protocol}//${e.hostname}${e.port?`:${e.port}`:""}`}catch{b=t}}let v=e.providerSpecificData?.connectionNoProxy||"",j=f?"success":"default",w=e.authType||(t?"oauth":"apikey"),k="oauth"===w,N="cookie"===w,C=e.name?.trim()||e.email?.trim()||e.displayName?.trim()||(k?"OAuth Account":N?"Cookie Account":"API Key"),S=e.name?.trim()&&e.email?.trim()&&e.name.trim()!==e.email.trim()?e.email.trim():e.name?.trim()&&e.displayName?.trim()&&e.name.trim()!==e.displayName.trim()?e.displayName.trim():null,[$,A]=(0,i.useState)(!1),T=Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>e).filter(e=>!!e).sort()[0]||null;(0,i.useEffect)(()=>{let t=()=>{A(!!Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>e).filter(e=>e&&new Date(e).getTime()>Date.now()).sort()[0])};t();let s=T?setInterval(t,1e3):null;return()=>{s&&clearInterval(s)}},[e,T]);let O="unavailable"!==e.testStatus||$?e.testStatus:"active",E=()=>u?"queued"===u.state?"queued":"testing"===u.state?"testing":"success"===u.state?"success":"failed"===u.state?u.error?`failed: ${u.error}`:"failed":null:null;return(0,a.jsxs)("div",{className:`group flex min-w-0 flex-col gap-3 rounded-lg p-2 transition-colors hover:bg-black/[0.02] dark:hover:bg-white/[0.02] sm:flex-row sm:items-center sm:justify-between ${!1===e.isActive?"opacity-60":""}`,children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-1 items-start gap-2 sm:items-center sm:gap-3",children:[(0,a.jsxs)("div",{className:"flex shrink-0 flex-col",children:[(0,a.jsx)("button",{onClick:n,disabled:s,className:`p-0.5 rounded ${s?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_up"})}),(0,a.jsx)("button",{onClick:l,disabled:r,className:`p-0.5 rounded ${r?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_down"})})]}),(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-base text-text-muted",children:N?"cookie":k?"lock":"key"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"text-sm font-medium truncate",children:C}),S&&(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:S}),(0,a.jsxs)("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1.5 sm:gap-2",children:[(0,a.jsx)(d.Ex,{variant:(0,I.g)(e.isActive,O),size:"sm",dot:!0,children:!1===e.isActive?"disabled":O||"Unknown"}),(0,a.jsx)(d.Ex,{variant:"default",size:"sm",children:k?"OAuth":N?"Cookie":"API Key"}),f&&(0,a.jsx)(d.Ex,{variant:j,size:"sm",children:"Proxy"}),$&&!1!==e.isActive&&(0,a.jsx)(P,{until:T}),e.lastError&&!1!==e.isActive&&(0,a.jsx)("span",{className:"max-w-full truncate text-xs text-red-500 sm:max-w-[300px]",title:e.lastError,children:e.lastError}),h&&!1!==e.isActive&&p&&(0,a.jsxs)("button",{onClick:p,title:"Trust this host past the SSRF guard and retry",className:"inline-flex items-center gap-1 rounded border border-amber-500/40 px-1.5 py-0.5 text-xs text-amber-600 hover:bg-amber-500/10 dark:text-amber-400",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"verified_user"}),"Add to allow list"]}),(0,a.jsxs)("span",{className:"text-xs text-text-muted",children:["#",e.priority]}),e.globalPriority&&(0,a.jsxs)("span",{className:"text-xs text-text-muted",children:["Auto: ",e.globalPriority]}),E()&&(0,a.jsx)(d.Ex,{variant:u?"success"===u.state?"success":"failed"===u.state?"error":"testing"===u.state?"primary":"default":"default",size:"sm",children:E()})]}),f&&(0,a.jsxs)("div",{className:"mt-1 flex items-center gap-2 flex-wrap",children:[(0,a.jsx)("span",{className:"max-w-full truncate text-[11px] text-text-muted sm:max-w-[420px]",title:g,children:g}),b&&(0,a.jsx)("code",{className:"max-w-full truncate rounded bg-black/5 px-1 py-0.5 font-mono text-[10px] text-text-muted dark:bg-white/5 sm:max-w-[260px]",children:b}),v&&(0,a.jsxs)("span",{className:"max-w-full truncate text-[11px] text-text-muted sm:max-w-[320px]",title:v,children:["no_proxy: ",v]})]})]})]}),(0,a.jsxs)("div",{className:"flex w-full items-center justify-between gap-2 sm:w-auto sm:justify-end",children:[(0,a.jsxs)("div",{className:"grid flex-1 grid-cols-3 gap-1 sm:flex sm:flex-none",children:[x&&(0,a.jsx)(d.m_,{text:y,children:(0,a.jsxs)("button",{onClick:()=>x.onToggle(!x.on),className:`flex w-full flex-col items-center rounded px-2 py-1 transition-colors hover:bg-black/5 dark:hover:bg-white/5 ${x.on?"text-primary":"text-text-muted hover:text-primary"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"bolt"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Auto-ping"})]})}),(0,a.jsxs)("button",{onClick:c,className:"flex flex-col items-center rounded px-2 py-1 text-text-muted hover:bg-black/5 hover:text-primary dark:hover:bg-white/5",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"edit"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Edit"})]}),(0,a.jsxs)("button",{onClick:m,className:"flex flex-col items-center rounded px-2 py-1 text-red-500 hover:bg-red-500/10",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"delete"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Delete"})]})]}),(0,a.jsx)(d.lM,{size:"sm",checked:e.isActive??!0,onChange:o,title:e.isActive??!0?"Disable connection":"Enable connection"})]})]})}P.propTypes={until:T().string.isRequired},M.propTypes={connection:T().shape({id:T().string,name:T().string,email:T().string,displayName:T().string,modelLockUntil:T().string,testStatus:T().string,isActive:T().bool,lastError:T().string,priority:T().number,globalPriority:T().number,providerSpecificData:T().object}).isRequired,isOAuth:T().bool.isRequired,isFirst:T().bool.isRequired,isLast:T().bool.isRequired,onMoveUp:T().func.isRequired,onMoveDown:T().func.isRequired,onToggleActive:T().func.isRequired,onEdit:T().func.isRequired,onDelete:T().func.isRequired,onAllowlistHost:T().func,oneByOneStatus:T().shape({state:T().string,error:T().string}),autoPing:T().shape({on:T().bool,onToggle:T().func,provider:T().string})};let z=`name1|sk-key1
2
2
  name2|sk-key2
3
3
  sk-key-only-auto-named`;function U({isOpen:e,provider:t,providerName:s,isCompatible:r,isAnthropic:n,authType:l,authHint:o,website:m,error:p,onSave:u,onBulkDone:x,onClose:h}){let f="ollama-local"===t,g="cookie"===l,y="xai"===t&&!g,b=g?"Cookie Value":"API Key",v="azure"===t,j="cloudflare-ai"===t,w=c.Q2?.[t]?.regions||null,k=c.Q2?.[t]?.defaultRegion||w?.[0]?.id||"",[N,C]=(0,i.useState)({name:"",apiKey:"",defaultModel:"",priority:1,ollamaHostUrl:""}),[S,$]=(0,i.useState)({azureEndpoint:"",apiVersion:"2024-10-01-preview",deployment:"",organization:""}),[A,T]=(0,i.useState)({accountId:""}),[O,E]=(0,i.useState)(k),[R,D]=(0,i.useState)(!1),[I,P]=(0,i.useState)(null),[M,q]=(0,i.useState)(!1),[_,F]=(0,i.useState)("single"),[L,J]=(0,i.useState)(""),[K,B]=(0,i.useState)(null),H=N.name.trim().length>0,W=N.apiKey.trim().length>0,V=()=>f&&N.ollamaHostUrl.trim()?{baseUrl:N.ollamaHostUrl.trim()}:v?{azureEndpoint:S.azureEndpoint,apiVersion:S.apiVersion,deployment:S.deployment,organization:S.organization}:j?{accountId:A.accountId}:w&&O?{region:O}:void 0,G=async()=>{let e=N.apiKey.trim();if(e){D(!0);try{let s=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:e,providerSpecificData:V()})}),a=await s.json();P(a.valid?"success":"failed")}catch{P("failed")}finally{D(!1)}}},Q=async()=>{if(!t)return;let e=N.name.trim(),s=N.apiKey.trim();if((f||s)&&(f||e)&&(!r||N.defaultModel.trim())){q(!0);try{let a=!1;try{D(!0),P(null);let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:s,providerSpecificData:V()})});a=!!(await e.json()).valid,P(a?"success":"failed")}catch{P("failed")}finally{D(!1)}await u({name:e||(f?"Ollama Local":""),apiKey:s,defaultModel:r?N.defaultModel.trim():void 0,priority:N.priority,testStatus:a?"active":"unknown",providerSpecificData:V()})}finally{q(!1)}}},Z=async()=>{let e=L.split("\n").map(e=>e.trim()).filter(Boolean);if(!e.length)return;q(!0),B(null);let s=0,a=0;for(let i=0;i<e.length;i++){let r=e[i].split("|"),n=r.length>=2?r.slice(1).join("|").trim():r[0].trim();if(!n){a++;continue}let l=r.length>=2&&r[0].trim()||"Key",o=`${l} ${i+1}`;try{(await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:n,name:o,priority:1,testStatus:"unknown"})})).ok?s++:a++}catch{a++}}q(!1),B({success:s,failed:a}),s>0&&x&&x()};return t?(0,a.jsx)(d.aF,{isOpen:e,title:`Add ${s||t} ${b}`,onClose:h,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{size:"sm",variant:"single"===_?"primary":"ghost",onClick:()=>{F("single"),B(null)},children:"Single"}),(0,a.jsx)(d.$n,{size:"sm",variant:"bulk"===_?"primary":"ghost",onClick:()=>{F("bulk"),B(null)},children:"Bulk Add"})]}),"bulk"===_&&(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["One key per line. Format: ",(0,a.jsx)("code",{children:"name|apiKey"})," or just ",(0,a.jsx)("code",{children:"apiKey"})," (auto-named by index)."]}),(0,a.jsx)("textarea",{className:"w-full rounded border border-accent/30 bg-sidebar p-2 text-sm font-mono resize-y min-h-[140px] focus:outline-none focus:ring-1 focus:ring-primary",placeholder:z,value:L,onChange:e=>J(e.target.value)}),K&&(0,a.jsxs)("div",{className:`text-sm font-medium ${K.failed>0?"text-yellow-400":"text-green-400"}`,children:["✓ ",K.success," added",K.failed>0?`, ✗ ${K.failed} failed`:""]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{onClick:Z,fullWidth:!0,disabled:M||!L.trim(),children:M?"Adding...":"Add All Keys"}),(0,a.jsx)(d.$n,{onClick:h,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),"single"===_&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.pd,{label:"Name",value:N.name,onChange:e=>C({...N,name:e.target.value}),placeholder:f?"Ollama Local":"Production Key"}),f&&(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.pd,{label:"Ollama Host URL",value:N.ollamaHostUrl,onChange:e=>C({...N,ollamaHostUrl:e.target.value}),placeholder:"http://localhost:11434",className:"flex-1"}),(0,a.jsx)("div",{className:"pt-6",children:(0,a.jsx)(d.$n,{onClick:G,disabled:R||M,variant:"secondary",children:R?"Checking...":"Check"})})]}),!f&&(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.pd,{label:b,type:g?"text":"password",autoComplete:"off",value:N.apiKey,onChange:e=>C({...N,apiKey:e.target.value}),placeholder:g?"grok-web"===t?"sso=xxxxx... or just the raw value":"eyJhbGciOi...":y?"xai-...":"",className:"flex-1"}),(0,a.jsx)("div",{className:"pt-6",children:(0,a.jsx)(d.$n,{onClick:G,disabled:!N.apiKey||R||M,variant:"secondary",children:R?"Checking...":"Check"})})]}),y&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Use a direct xAI API key from console.x.ai. This is separate from Grok Build OAuth."}),g&&o&&(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:[o,m&&(0,a.jsxs)(a.Fragment,{children:[" ",(0,a.jsxs)("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline",children:["Open ",m.replace(/^https?:\/\//,"")]})]})]}),w&&(0,a.jsx)(d.l6,{label:"Region",value:O,onChange:e=>E(e.target.value),options:w.map(e=>({value:e.id,label:e.label}))}),r&&(0,a.jsx)(d.pd,{label:"Default Model",value:N.defaultModel,onChange:e=>C({...N,defaultModel:e.target.value}),placeholder:n?"claude-3-5-sonnet-latest":"gpt-4o-mini"}),f&&(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["Leave blank to use ",(0,a.jsx)("code",{children:"http://localhost:11434"}),". For remote Ollama, enter the full host URL (e.g. ",(0,a.jsx)("code",{children:"http://192.168.1.10:11434"}),")."]}),I&&(0,a.jsx)(d.Ex,{variant:"success"===I?"success":"error",children:"success"===I?"Valid":"Invalid"}),p&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:p}),r&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Enter the model ID exactly as your compatible endpoint expects it. This model will be saved as the connection default."}),j&&(0,a.jsxs)("div",{className:"bg-sidebar/50 p-4 rounded-lg border border-accent/20",children:[(0,a.jsx)("h3",{className:"font-semibold mb-3 text-sm",children:"Cloudflare Workers AI"}),(0,a.jsx)(d.pd,{label:"Account ID",value:A.accountId,onChange:e=>T({...A,accountId:e.target.value}),placeholder:"abc123def456..."}),(0,a.jsxs)("p",{className:"text-xs text-text-muted mt-2",children:["Find your Account ID in the right sidebar of ",(0,a.jsx)("a",{href:"https://dash.cloudflare.com",target:"_blank",rel:"noopener noreferrer",className:"text-primary underline",children:"dash.cloudflare.com"})]})]}),v&&(0,a.jsxs)("div",{className:"bg-sidebar/50 p-4 rounded-lg border border-accent/20",children:[(0,a.jsx)("h3",{className:"font-semibold mb-3 text-sm",children:"Azure OpenAI Configuration"}),(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsx)(d.pd,{label:"Azure Endpoint",value:S.azureEndpoint,onChange:e=>$({...S,azureEndpoint:e.target.value}),placeholder:"https://your-resource.openai.azure.com"}),(0,a.jsx)(d.pd,{label:"Deployment Name",value:S.deployment,onChange:e=>$({...S,deployment:e.target.value}),placeholder:"gpt-4"}),(0,a.jsx)(d.pd,{label:"API Version",value:S.apiVersion,onChange:e=>$({...S,apiVersion:e.target.value}),placeholder:"2024-10-01-preview"}),(0,a.jsx)(d.pd,{label:"Organization",value:S.organization,onChange:e=>$({...S,organization:e.target.value}),placeholder:"Organization ID"})]})]}),(0,a.jsx)(d.pd,{label:"Priority",type:"number",min:1,value:N.priority,onChange:e=>C({...N,priority:Number.parseInt(e.target.value)||1})}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{onClick:Q,fullWidth:!0,disabled:M||!f&&(!H||!W)||r&&!N.defaultModel.trim()||v&&(!S.azureEndpoint||!S.deployment||!S.organization)||j&&!A.accountId,children:M?"Saving...":"Save"}),(0,a.jsx)(d.$n,{onClick:h,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})}):null}function q({isOpen:e,node:t,onSave:s,onClose:r,isAnthropic:n}){let[l,o]=(0,i.useState)({name:"",apiType:"chat",baseUrl:"https://api.openai.com/v1"}),[c,m]=(0,i.useState)(!1),[p,u]=(0,i.useState)(""),[x,h]=(0,i.useState)(""),[f,g]=(0,i.useState)(!1),[y,b]=(0,i.useState)(null),v=function(e){try{return["http:","https:"].includes(new URL(e).protocol)}catch{return!1}}(l.baseUrl.trim());(0,i.useEffect)(()=>{t&&(o({name:t.name||"",apiType:t.apiType||"chat",baseUrl:t.baseUrl||(n?"https://api.anthropic.com/v1":"https://api.openai.com/v1")}),b(null),u(""),h(""))},[t,n]);let j=async()=>{if(l.name.trim()&&v){m(!0);try{let e={name:l.name.trim(),baseUrl:l.baseUrl.trim()};n||(e.apiType=l.apiType),await s(e)}finally{m(!1)}}},w=async()=>{g(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:l.baseUrl,apiKey:p,type:n?"anthropic-compatible":"openai-compatible",modelId:x.trim()||void 0})}),t=await e.json();b(t.valid?"success":"failed")}catch{b("failed")}finally{g(!1)}};return t?(0,a.jsx)(d.aF,{isOpen:e,title:`Edit ${n?"Anthropic":"OpenAI"} Compatible`,onClose:r,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)(d.pd,{label:"Name",value:l.name,onChange:e=>o({...l,name:e.target.value}),placeholder:`${n?"Anthropic":"OpenAI"} Compatible`,hint:"Friendly label for this provider."}),!n&&(0,a.jsx)(d.l6,{label:"API Type",options:[{value:"chat",label:"Chat Completions"},{value:"responses",label:"Responses API"}],value:l.apiType,onChange:e=>o({...l,apiType:e.target.value})}),(0,a.jsx)(d.pd,{label:"Base URL",value:l.baseUrl,onChange:e=>o({...l,baseUrl:e.target.value}),placeholder:n?"https://api.anthropic.com/v1":"https://api.openai.com/v1",hint:`Base URL ending in /v1 for your ${n?"Anthropic":"OpenAI"}-compatible API.`}),t.prefix?(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["Model IDs use prefix ",(0,a.jsx)("code",{className:"bg-sidebar px-1 rounded font-mono",children:t.prefix})," ","(auto-assigned; stable so combos keep working)."]}):null,(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.pd,{label:"API Key (for Check)",type:"password",autoComplete:"off",value:p,onChange:e=>u(e.target.value),className:"flex-1"}),(0,a.jsx)("div",{className:"pt-6",children:(0,a.jsx)(d.$n,{onClick:w,disabled:!p||f||!v,variant:"secondary",children:f?"Checking...":"Check"})})]}),(0,a.jsx)(d.pd,{label:"Model ID (optional)",value:x,onChange:e=>h(e.target.value),placeholder:"e.g. my-model-id",hint:"If the provider has no /models endpoint, test with a model ID."}),y&&(0,a.jsx)(d.Ex,{variant:"success"===y?"success":"error",children:"success"===y?"Valid":"Invalid"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{onClick:j,fullWidth:!0,disabled:!l.name.trim()||!v||c,children:c?"Saving...":"Save"}),(0,a.jsx)(d.$n,{onClick:r,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}function _({isOpen:e,providerAlias:t,providerDisplayAlias:s,onSave:r,onClose:n}){let[l,o]=(0,i.useState)(""),[c,m]=(0,i.useState)(null),[p,u]=(0,i.useState)(""),[x,h]=(0,i.useState)(!1);(0,i.useEffect)(()=>{e&&(o(""),m(null),u(""))},[e]);let f=e=>{let s=`${t}/`;return e.startsWith(s)?e.slice(s.length):e},g=async()=>{let e=f(l.trim());if(e){m("testing"),u("");try{let s=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${t}/${e}`})}),a=await s.json();m(a.ok?"ok":"error"),u(a.error||"")}catch(e){m("error"),u(e.message)}}},y=async()=>{let e=f(l.trim());if(e&&!x){h(!0);try{await r(e)}finally{h(!1)}}};return(0,a.jsx)(d.aF,{isOpen:e,onClose:n,title:"Add Custom Model",children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"text-sm font-medium mb-1.5 block",children:"Model ID"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)("input",{type:"text",value:l,onChange:e=>{o(e.target.value),m(null),u("")},onKeyDown:e=>{"Enter"===e.key&&g()},placeholder:"e.g. claude-opus-4-5",className:"flex-1 px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",autoFocus:!0}),(0,a.jsx)(d.$n,{variant:"secondary",icon:"science",loading:"testing"===c,onClick:g,disabled:!l.trim()||"testing"===c,children:"testing"===c?"Testing...":"Test"})]}),(0,a.jsxs)("p",{className:"text-xs text-text-muted mt-1",children:["Sent to provider as: ",(0,a.jsx)("code",{className:"font-mono bg-sidebar px-1 rounded",children:f(l.trim())||"model-id"})]})]}),"ok"===c&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-sm text-green-600",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base",children:"check_circle"}),"Model is reachable"]}),"error"===c&&(0,a.jsxs)("div",{className:"flex items-start gap-2 text-sm text-red-500",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base shrink-0",children:"cancel"}),(0,a.jsx)("span",{children:p||"Model not reachable"})]}),(0,a.jsxs)("div",{className:"flex gap-2 pt-1",children:[(0,a.jsx)(d.$n,{onClick:n,variant:"ghost",fullWidth:!0,size:"sm",children:"Cancel"}),(0,a.jsx)(d.$n,{onClick:y,fullWidth:!0,size:"sm",disabled:!l.trim()||x,children:x?"Adding...":"Add Model"})]})]})})}U.propTypes={isOpen:T().bool.isRequired,provider:T().string,providerName:T().string,isCompatible:T().bool,isAnthropic:T().bool,authType:T().string,authHint:T().string,website:T().string,error:T().string,onSave:T().func.isRequired,onBulkDone:T().func,onClose:T().func.isRequired},q.propTypes={isOpen:T().bool.isRequired,node:T().shape({id:T().string,name:T().string,prefix:T().string,apiType:T().string,baseUrl:T().string}),onSave:T().func.isRequired,onClose:T().func.isRequired,isAnthropic:T().bool},_.propTypes={isOpen:T().bool.isRequired,providerAlias:T().string.isRequired,providerDisplayAlias:T().string.isRequired,onSave:T().func.isRequired,onClose:T().func.isRequired};let F=`[
4
4
  {
@@ -7,4 +7,4 @@ sk-key-only-auto-named`;function U({isOpen:e,provider:t,providerName:s,isCompati
7
7
  "idToken": "eyJhbGc...",
8
8
  "email": "user@example.com"
9
9
  }
10
- ]`;function L({isOpen:e,onClose:t,onSuccess:s}){let[r,n]=(0,i.useState)(""),[l,o]=(0,i.useState)(!1),[c,m]=(0,i.useState)(""),[p,u]=(0,i.useState)(null),x=()=>{l||(n(""),m(""),u(null),t())},h=async()=>{var e;let t;m(""),u(null);let a=r.trim();if(!a)return;try{t=JSON.parse(a)}catch(e){m(`${(0,w.Tl)("Invalid JSON")}: ${e.message}`);return}let i=Array.isArray(e=t)?e:e&&"object"==typeof e?Array.isArray(e.accounts)?e.accounts:[e]:null;if(!i||0===i.length)return void m((0,w.Tl)("No accounts found in input"));o(!0);try{let e=await fetch("/api/oauth/codex/bulk-import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({accounts:i})}),t=await e.json();if(!e.ok)return void m(t?.error||`Request failed: ${e.status}`);u(t),t.success>0&&"function"==typeof s&&s()}catch(e){m(e.message||(0,w.Tl)("Request failed"))}finally{o(!1)}},f=p?.results?.filter(e=>!e.ok)||[];return(0,a.jsx)(d.aF,{isOpen:e,title:(0,w.Tl)("Bulk Add Codex Accounts"),onClose:x,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)("p",{className:"text-xs text-text-muted",children:(0,w.Tl)("Paste an array of codex account JSON objects. Each must include accessToken (and ideally refreshToken, idToken).")}),(0,a.jsx)("textarea",{className:"w-full rounded border border-accent/30 bg-sidebar p-2 text-sm font-mono resize-y min-h-[240px] focus:outline-none focus:ring-1 focus:ring-primary",placeholder:F,value:r,onChange:e=>n(e.target.value),disabled:l}),c&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:c}),p&&(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:`text-sm font-medium ${p.failed>0?"text-yellow-400":"text-green-400"}`,children:["✓ ",p.success," ",(0,w.Tl)("added"),p.failed>0?`, ✗ ${p.failed} ${(0,w.Tl)("failed")}`:""]}),f.length>0&&(0,a.jsx)("ul",{className:"rounded border border-accent/20 bg-sidebar/50 p-2 text-xs font-mono max-h-40 overflow-y-auto",children:f.map(e=>(0,a.jsxs)("li",{className:"text-red-400",children:["[",e.index,"] ",e.error]},e.index))})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{onClick:h,fullWidth:!0,disabled:l||!r.trim(),children:l?(0,w.Tl)("Importing..."):(0,w.Tl)("Import All")}),(0,a.jsx)(d.$n,{onClick:x,variant:"ghost",fullWidth:!0,disabled:l,children:(0,w.Tl)("Close")})]})]})})}L.propTypes={isOpen:T().bool.isRequired,onClose:T().func.isRequired,onSuccess:T().func};function J({connectionId:e,providerAlias:t,models:s,jobSnapshot:r,onComplete:n,onStarted:l,onClose:o}){let[c,m]=(0,i.useState)(4),[p,u]=(0,i.useState)(50),[x,h]=(0,i.useState)(Math.round(20)),[f,g]=(0,i.useState)(!1),[y,b]=(0,i.useState)(null),[v,j]=(0,i.useState)(null),[w,k]=(0,i.useState)(""),[N,C]=(0,i.useState)(""),S=(0,i.useRef)({onComplete:n,onStarted:l}),$=(0,i.useRef)(null),A=(0,i.useRef)(e),T=(0,i.useRef)(null),O=s?.length||0,E=(0,i.useMemo)(()=>`max concurrency 16 \xb7 batch 200 \xb7 timeout ${60}s`,[]);function R(e){if(e){if("idle"===e.status){T.current=null,g(!1);return}if(b({done:e.done||0,total:e.total||0,ok:e.ok||0,dead:e.dead||0,retryable:e.retryable||0,skippedDead:e.skippedDead||0,skippedDup:e.skippedDup||0}),"running"===e.status&&(T.current=e.connectionId||A.current,$.current=null,g(!0)),e.currentRange&&C(`Probing ${e.currentRange.from}–${e.currentRange.to} of ${e.total}…`),e.error&&k(e.error),"done"===e.status||"cancelled"===e.status||"error"===e.status){T.current=null,g(!1);let t={ok:e.ok||0,dead:e.dead||0,retryable:e.retryable||0,tested:e.done||0,skippedDead:e.skippedDead||0,skippedDup:e.skippedDup||0,cancelled:"cancelled"===e.status};j(t),C("cancelled"===e.status?"Cancelled (partial results saved).":"error"===e.status?"Stopped.":"Done.");let s=`${e.startedAt||"unknown"}:${e.status}`;$.current!==s&&($.current=s,S.current.onComplete?.(t))}}}async function D(){if(f||!e||0===O)return;g(!0),k(""),j(null),C("Starting…");let a={concurrency:Math.max(1,Math.min(16,Number(c)||4)),batchSize:Math.max(1,Math.min(200,Number(p)||50)),timeoutMs:Math.max(1e3,Math.min(6e4,1e3*(Number(x)||20)))};T.current=e;try{let i=await fetch(`/api/providers/${e}/model-probes/verify/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({models:s,providerAlias:t,...a,timeoutMs:a.timeoutMs})}),r=await i.json().catch(()=>({}));if(A.current!==e){T.current=null,g(!1);return}if(!i.ok){T.current=null,k(r.error||"Failed to start"),g(!1);return}S.current.onStarted?.(r),R(r),"running"!==r.status&&g(!1)}catch(e){T.current=null,k(e?.message||"Verify failed"),g(!1)}}async function I(){let t=T.current||e;await fetch(`/api/providers/${t}/model-probes/verify/cancel`,{method:"POST"}).catch(()=>{})}async function P(){if(!e)return;C("Removing unavailable custom models…");let s=await fetch(`/api/providers/${e}/model-probes/remove-unavailable`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:t,kind:"llm"})}),a=await s.json().catch(()=>({}));s.ok?(C(`Removed ${a.removed||0} unavailable custom model(s).`),S.current.onComplete?.({...v||{},removed:a.removed||0})):k(a.error||"Remove failed")}async function M(){if(!e)return;let t=await fetch(`/api/providers/${e}/model-probes/cache`,{method:"DELETE"}),s=await t.json().catch(()=>({}));t.ok?(C(`Cleared probe cache (${s.cleared||0} rows). Next verify will re-test everything.`),j(null),b(null),S.current.onComplete?.({cacheCleared:!0,cleared:s.cleared||0})):k(s.error||"Clear cache failed")}(0,i.useEffect)(()=>{S.current={onComplete:n,onStarted:l},A.current=e}),(0,i.useEffect)(()=>{R(r)},[r]);let z=y?.total?Math.min(100,Math.round(y.done/y.total*100)):0;return(0,a.jsxs)("div",{className:"mb-4 rounded-lg border border-border bg-sidebar/40 p-3 space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"text-sm font-semibold text-text-main",children:"Verify models"}),(0,a.jsxs)("p",{className:"text-[11px] text-text-muted mt-0.5",children:["Batch-ping availability and latency. Dead = permanently unavailable (404/403) and can be removed; retry = transient (timeout/429/5xx). Known-dead models are skipped until you Clear cache. Caps: ",E,"."]})]}),o&&(0,a.jsx)("button",{type:"button",onClick:o,className:"p-1 text-text-muted hover:text-text-main rounded",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"close"})})]}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-3 items-end",children:[(0,a.jsxs)("label",{className:"text-xs text-text-muted",children:["Concurrency",(0,a.jsx)("input",{type:"number",min:1,max:16,value:c,disabled:f,onChange:e=>m(e.target.value),className:"mt-1 block w-20 rounded-md border border-border bg-background px-2 py-1 text-xs"})]}),(0,a.jsxs)("label",{className:"text-xs text-text-muted",children:["Batch size",(0,a.jsx)("input",{type:"number",min:1,max:200,value:p,disabled:f,onChange:e=>u(e.target.value),className:"mt-1 block w-20 rounded-md border border-border bg-background px-2 py-1 text-xs"})]}),(0,a.jsxs)("label",{className:"text-xs text-text-muted",children:["Timeout (s)",(0,a.jsx)("input",{type:"number",min:1,max:60,value:x,disabled:f,onChange:e=>h(e.target.value),className:"mt-1 block w-20 rounded-md border border-border bg-background px-2 py-1 text-xs"})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[f?(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"stop",onClick:I,children:"Cancel"}):(0,a.jsx)(d.$n,{size:"sm",icon:"science",onClick:D,disabled:!e||0===O,children:"Start"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"delete_sweep",onClick:M,disabled:f,children:"Clear cache"})]})]}),y&&(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)("div",{className:"h-1.5 w-full rounded-full bg-border overflow-hidden",children:(0,a.jsx)("div",{className:"h-full bg-primary transition-all",style:{width:`${z}%`}})}),(0,a.jsxs)("p",{className:"text-[11px] text-text-muted flex flex-wrap gap-x-2",children:[(0,a.jsxs)("span",{title:"Models probed this run",children:[y.done,"/",y.total," tested"]}),(0,a.jsxs)("span",{title:"Reachable",children:["\xb7 ok ",y.ok]}),(0,a.jsxs)("span",{title:"Permanently unavailable this run (404 not found / 403 access denied)",children:["\xb7 dead ",y.dead]}),(0,a.jsxs)("span",{title:"Transient failure this run (timeout / 429 / 5xx / network); re-testable",children:["\xb7 retry ",y.retryable]}),y.skippedDead?(0,a.jsxs)("span",{title:"Not probed — cache already marks them dead. Clear cache to re-test.",children:["\xb7 skipped known-dead ",y.skippedDead]}):null,y.skippedDup?(0,a.jsxs)("span",{title:"Duplicate ids collapsed",children:["\xb7 dupes ",y.skippedDup]}):null]})]}),N&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:N}),w&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:w}),v&&(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:[(0,a.jsxs)("span",{className:"text-xs text-text-main",children:["Summary: ",v.ok," ok \xb7 ",v.dead," dead \xb7 ",v.retryable," retry",v.skippedDead?` \xb7 ${v.skippedDead} skipped known-dead`:"",v.cancelled?" \xb7 cancelled":""]}),v.dead>0&&(0,a.jsxs)(d.$n,{size:"sm",variant:"primary",icon:"delete_sweep",onClick:P,disabled:f,children:["Remove ",v.dead," dead"]})]})]})}function K(e,t=""){let s=String(e||"").trim();if(!s)return"";s=(s=s.replace(/\s+/g,"")).replace(/^models\//i,"");let a=String(t||"").trim();return a&&s.toLowerCase().startsWith(`${a.toLowerCase()}/`)&&(s=s.slice(a.length+1)),(s=s.replace(/\/{2,}/g,"/").replace(/^\/+|\/+$/g,"")).toLowerCase()}J.propTypes={connectionId:T().string,providerAlias:T().string,models:T().arrayOf(T().object),jobSnapshot:T().object,onComplete:T().func,onStarted:T().func,onClose:T().func};let B={claude:"claudeAutoPing",codex:"codexAutoPing"};function H(){let e,t,s,n=(0,r.useParams)(),p=(0,r.useRouter)(),u=n.id,{getCaps:x}=(0,j.y)(),[h,f]=(0,i.useState)([]),[g,y]=(0,i.useState)([]),[k,A]=(0,i.useState)(!0),[T,R]=(0,i.useState)(null),[I,P]=(0,i.useState)(!1),[z,F]=(0,i.useState)(!1),[H,W]=(0,i.useState)(!1),[V,G]=(0,i.useState)(""),[Q,Z]=(0,i.useState)(!1),[X,Y]=(0,i.useState)(!1),[ee,et]=(0,i.useState)(!1),[es,ea]=(0,i.useState)(null),[ei,er]=(0,i.useState)({}),[en,el]=(0,i.useState)([]),[eo,ed]=(0,i.useState)(!1),[ec,em]=(0,i.useState)({}),[ep,eu]=(0,i.useState)(""),[ex,eh]=(0,i.useState)(()=>new Set),[ef,eg]=(0,i.useState)(!1),[ey,eb]=(0,i.useState)(null),[ev,ej]=(0,i.useState)(""),[ew,ek]=(0,i.useState)("auto"),[eN,eC]=(0,i.useState)({enabled:!1,connections:{}}),[eS,e$]=(0,i.useState)([]),[eA,eT]=(0,i.useState)([]),[eO,eE]=(0,i.useState)([]),[eR,eD]=(0,i.useState)([]),[eI,eP]=(0,i.useState)(null),[eM,ez]=(0,i.useState)(!1),[eU,eq]=(0,i.useState)(!1),[e_,eF]=(0,i.useState)(!1),[eL,eJ]=(0,i.useState)(null),[eK,eB]=(0,i.useState)({}),[eH,eW]=(0,i.useState)(null),eV=(0,i.useRef)(!1),eG=(0,i.useRef)(null),eQ=(0,i.useRef)(0),eZ=(0,i.useRef)(0),[eX,eY]=(0,i.useState)(!1),[e0,e1]=(0,i.useState)(""),[e2,e5]=(0,i.useState)(!1),[e4,e3]=(0,i.useState)(null),[e6,e7]=(0,i.useState)({}),[e8,e9]=(0,i.useState)({}),[te,tt]=(0,i.useState)("all"),{copied:ts,copy:ta}=(0,v.C)(),ti="ag_risk_confirmed",tr=()=>{P(!0)},tn=()=>{"antigravity"===u&&"true"!==window.localStorage.getItem(ti)?ez(!0):tm?tr():(G(""),W(!0))},tl=()=>{G(""),W(!0)},to=()=>{tm?tn():tl()},td=T?{id:T.id,name:T.name||("anthropic-compatible"===T.type?"Anthropic Compatible":"OpenAI Compatible"),color:"anthropic-compatible"===T.type?"#D97757":"#10A37F",textIcon:"anthropic-compatible"===T.type?"AC":"OC",apiType:T.apiType,baseUrl:T.baseUrl,type:T.type}:c.zN[u]||c.fg[u]||c.IS[u]||c.nJ[u]||c.br[u],tc=td?.authModes||[],tm=!!c.zN[u]||!!c.IS[u]||tc.includes("oauth"),tp=!!c.fg[u]||tc.includes("apikey"),tu=!!c.IS[u]?.noAuth,tx=(0,m.KC)(u),th=(()=>{let e=new Map(tx.map(e=>[e.id,e]));for(let t of eA)t?.id&&e.set(t.id,{...e.get(t.id),...t});return[...e.values()]})(),tf=(0,c.wG)(u),tg=(0,c.mq)(u),ty=(0,c.gb)(u),tb=tg||ty,tv=h.some(e=>!1!==e.isActive),tj=function({isCompatible:e,hasActiveConnection:t}){let s=!e,a=!e;return{showToolbar:s||t||a,showImport:s,showVerify:t,showBulkControls:a}}({isCompatible:tb,hasActiveConnection:tv}),tw=!tb&&tm&&tp,tk="xai"===u?"Grok Build OAuth":"OAuth",tN="xai"===u?"xAI API Key":"API Key",tC=e=>{if(!ew||"auto"===ew)return null;let t=b(u,e);return t&&t.includes(ew)?ew:null},tS=(()=>{let e=new Set;for(let t of th){let s=b(u,t.id);s&&s.forEach(t=>{"none"!==t&&e.add(t)})}return e.size?["auto",...e]:null})(),t$=tb?u:tf,tA=tb?T?.prefix||u:tf,tT=(0,i.useCallback)(async()=>{try{let e=await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(t$)}`,{cache:"no-store"}),t=await e.json();e.ok&&eD(t.ids||[])}catch(e){(0,E.s)("Error fetching disabled models:",e)}},[t$]),tO=async e=>{try{(await fetch("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:t$,ids:[e]})})).ok&&await tT()}catch(e){(0,E.s)("Error disabling model:",e)}},tE=async e=>{try{(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(t$)}&id=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await tT()}catch(e){(0,E.s)("Error enabling model:",e)}},tR=async e=>{e.length&&eP({title:"Disable All Models",message:`Disable all ${e.length} model(s)?`,onConfirm:async()=>{eP(null);try{(await fetch("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:t$,ids:e})})).ok&&await tT()}catch(e){(0,E.s)("Error disabling all models:",e)}}})},tD=async()=>{try{(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(t$)}`,{method:"DELETE"})).ok&&await tT()}catch(e){(0,E.s)("Error enabling all models:",e)}},tI=(0,i.useCallback)(async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&er(t.aliases||{})}catch(e){(0,E.s)("Error fetching aliases:",e)}},[]),tP=(0,i.useCallback)(async()=>{try{let e=await fetch("/api/models/custom",{cache:"no-store"}),t=await e.json();e.ok&&el(t.models||[])}catch(e){(0,E.s)("Error fetching custom models:",e)}},[]);(0,i.useEffect)(()=>{"kilocode"===u&&fetch("/api/providers/kilo/free-models").then(e=>e.json()).then(e=>{e.models?.length&&eE(e.models)}).catch(()=>{})},[u]);let tM=(0,i.useCallback)(async()=>{try{let[e,t,s]=await Promise.all([fetch("/api/providers",{cache:"no-store"}),fetch("/api/provider-nodes",{cache:"no-store"}),fetch("/api/settings",{cache:"no-store"})]),a=await e.json(),i=await t.json(),r=s.ok?await s.json():{};if(e.ok){let e=(a.connections||[]).filter(e=>e.provider===u);f(e)}let n=(r.providerStrategies||{})[u]||{};eb(n.fallbackStrategy||null),ej(null!=n.stickyRoundRobinLimit?String(n.stickyRoundRobinLimit):"1");let l=(r.providerThinking||{})[u]||{};ek(l.mode||"auto");let o=B[u],d=o&&r[o]||{};if(eC({enabled:!0===d.enabled,connections:d.connections||{}}),t.ok){let e=(i.nodes||[]).find(e=>e.id===u)||null;if(!e&&tb)for(let t=0;t<3;t+=1){await new Promise(e=>setTimeout(e,150));let t=await fetch("/api/provider-nodes",{cache:"no-store"});if(t.ok&&(e=((await t.json()).nodes||[]).find(e=>e.id===u)||null))break}R(e)}}catch(e){(0,E.s)("Error fetching connections:",e)}finally{A(!1)}},[u,tb]),tz=(0,i.useCallback)(async(e=null)=>{let t=++eZ.current,s=e?h.find(t=>t.id===e&&!1!==t.isActive):h.find(e=>g.includes(e.id)&&!1!==e.isActive)||h.find(e=>!1!==e.isActive);if(!s){e9({}),e7({});return}try{let e=await fetch(`/api/providers/${s.id}/model-probes`,{cache:"no-store"});if(!e.ok)return;let a=await e.json().catch(()=>({})),i={},r={};for(let e of a.probes||[])i[e.modelId]="ok"===e.status?"ok":"dead"===e.status?"dead":"retry",null!=e.latencyMs&&(r[e.modelId]=e.latencyMs);if(t!==eZ.current)return;e9(i),e7(r)}catch{}},[h,g]),tU=async e=>{try{let t=await fetch(`/api/provider-nodes/${u}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),s=await t.json();t.ok&&(R(s.node),await tM(),et(!1))}catch(e){(0,E.s)("Error updating provider node:",e)}},tq=async(e,t)=>{try{let s=await fetch("/api/settings",{cache:"no-store"}),a=(s.ok?await s.json():{}).providerStrategies||{},i={};e&&(i.fallbackStrategy=e),"round-robin"===e&&""!==t&&(i.stickyRoundRobinLimit=Number(t)||3);let r={...a};0===Object.keys(i).length?delete r[u]:r[u]=i,await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerStrategies:r})})}catch(e){(0,E.s)("Error saving provider strategy:",e)}},t_=async e=>{try{let t=await fetch("/api/settings",{cache:"no-store"}),s={...(t.ok?await t.json():{}).providerThinking||{}};e&&"auto"!==e?s[u]={mode:e}:delete s[u],await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerThinking:s})})}catch(e){(0,E.s)("Error saving thinking config:",e)}},tF=async e=>{let t=B[u];if(t){eC(e);try{await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[t]:e})})}catch(e){(0,E.s)("Error saving auto-ping config:",e)}}};(0,i.useEffect)(()=>{tM(),tI(),tP(),tT()},[tM,tI,tP,tT]),(0,i.useEffect)(()=>{tz()},[tz]),(0,i.useEffect)(()=>{if(tb)return;let e=h.find(e=>!1!==e.isActive);if(!e)return void eT([]);let t=!1;return fetch(`/api/providers/${e.id}/models`,{cache:"no-store"}).then(e=>e.json().catch(()=>({}))).then(e=>{!t&&Array.isArray(e.models)&&e.models.length>0&&eT(e.models)}).catch(()=>{}),()=>{t=!0}},[h,tb]),(0,i.useEffect)(()=>{let e=(c.zN[u]||c.fg[u]||c.IS[u]||c.nJ[u])?.modelsFetcher;e&&N(e).then(e$)},[u]);let tL=(0,i.useCallback)(e=>{let t=++eQ.current;eG.current&&(clearTimeout(eG.current),eG.current=null);let s=async()=>{try{let a=await fetch(`/api/providers/${e}/model-probes/verify/status`,{cache:"no-store"}),i=await a.json().catch(()=>null);if(t!==eQ.current)return;if(!a.ok||!i?.status)throw Error("Verify status temporarily unavailable");e3(i&&i.status?i:null),i?.status==="running"?eG.current=setTimeout(s,1500):(eG.current=null,await tz(e))}catch{t===eQ.current&&(eG.current=setTimeout(s,1500))}};eG.current=setTimeout(s,0)},[tz]);(0,i.useEffect)(()=>{let e=h.find(e=>g.includes(e.id)&&!1!==e.isActive)||h.find(e=>!1!==e.isActive);return e?(tL(e.id),()=>{eQ.current+=1,eG.current&&(clearTimeout(eG.current),eG.current=null)}):void e3(null)},[h,g,tL]);let tJ=async(e,t,s=tf)=>{let a=`${s}/${e}`;try{let e=await fetch("/api/models/alias",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:a,alias:t})});if(e.ok)await tI();else{let t=await e.json();(0,E.s)(t.error||"Failed to set alias")}}catch(e){(0,E.s)("Error setting alias:",e)}},tK=async e=>{try{(await fetch(`/api/models/alias?alias=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await tI()}catch(e){(0,E.s)("Error deleting alias:",e)}},tB=async(e,t="llm",s=t$)=>{try{let a=await fetch("/api/models/custom",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:s,id:e,type:t})});if(a.ok)await tP(),window.dispatchEvent(new CustomEvent("customModelChanged"));else{let e=await a.json();(0,E.s)(e.error||"Failed to add custom model")}}catch(e){(0,E.s)("Error adding custom model:",e)}},tH=async(e,t="llm",s=t$)=>{try{let a=new URLSearchParams({providerAlias:s,id:e,type:t});(await fetch(`/api/models/custom?${a}`,{method:"DELETE"})).ok&&(await tP(),window.dispatchEvent(new CustomEvent("customModelChanged")))}catch(e){(0,E.s)("Error deleting custom model:",e)}},tW=async()=>{if(eX)return;let e=h.find(e=>g.includes(e.id)&&!1!==e.isActive)||h.find(e=>!1!==e.isActive);if(!e)return void(0,E.s)((0,w.Tl)("Add an active connection first"));eY(!0),e1("");try{let t=await fetch(`/api/providers/${e.id}/models`),s=await t.json().catch(()=>({}));if(!t.ok)return void(0,E.s)(s.error||(0,w.Tl)("Failed to fetch models"));let a=s.models||[];if(0===a.length)return void(0,E.s)(s.warning||(0,w.Tl)("No models returned"));let i=new Set;try{let t=await fetch(`/api/providers/${e.id}/model-probes`,{cache:"no-store"});for(let e of(await t.json().catch(()=>({}))).probes||[])"dead"===e.status&&i.add(e.modelId)}catch{}let r=0,n=new Set(th.map(e=>e.id)),l=[],o=[],d=new Set;for(let e of a){let t=function(e,t){if(null==e)return null;if("string"==typeof e){let s=$(e,t);return s?{id:s,name:s,type:S(s)}:null}let s=e.id||e.name||e.model||e.slug;if(!s)return null;let a=$(s,t);if(!a)return null;let i=e.display_name||e.displayName||e.name||e.title||a;return{id:a,name:String(i),type:S(a,e)}}(e,t$);if(!t)continue;let{id:s,name:a,type:c}=t;if(i.has(K(s,t$))){r+=1;continue}let m=`${c}|${s}`;if(d.has(m))continue;if(d.add(m),n.has(s)){eR.includes(s)&&o.push(s);continue}if(en.some(e=>e.providerAlias===t$&&e.id===s&&(e.kind||e.type||"llm")===c))continue;let p=`${t$}/${s}`;Object.values(ei).includes(p)||l.push({providerAlias:t$,id:s,type:c,name:a})}let c=0;if(o.length>0)try{for(let e of o)(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(t$)}&id=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&(c+=1);await tT()}catch{}let m=0;if(l.length>0){let e=await fetch("/api/models/custom",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({models:l})}),t=await e.json().catch(()=>({}));if(!e.ok)return void(0,E.s)(t.error||(0,w.Tl)("Failed to save models"));m=t.added??l.length,await tP(),window.dispatchEvent(new CustomEvent("customModelChanged"))}let p=l.filter(e=>"llm"!==e.type).length,u=[];if(m>0&&u.push(`${m} new`),c>0&&u.push(`${c} re-enabled`),0===u.length)e1((0,w.Tl)("All models already in list"));else{let e=`Imported ${u.join(" \xb7 ")} (${a.length} from provider)`;p>0&&(e+=" \xb7 non-chat types stored for media pages"),s.warning&&(e+=` \xb7 ${s.warning}`),e1(e)}if(r>0&&e1(e=>`${e} \xb7 ${r} skipped (known dead)`),m>0||c>0)try{let t=[...th,...l.map(e=>({id:e.id,name:e.name,kind:e.type}))],s=await fetch(`/api/providers/${e.id}/model-probes/verify/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({models:t,providerAlias:t$})}),a=await s.json().catch(()=>({}));if(!s.ok)throw Error(a.error||"Failed to start auto-verify");e3(a&&a.status?a:null),tL(e.id)}catch(e){e1(t=>`${t} \xb7 auto-verify failed: ${e?.message||e}`)}}catch(e){(0,E.s)("Error importing models:",e),(0,E.s)((0,w.Tl)("Error fetching models")+": "+(e?.message||e))}finally{eY(!1)}},tV=async()=>{if(eU||0===h.length)return;let e=Object.fromEntries(h.map(e=>[e.id,{state:"queued",error:null}]));eV.current=!1,eq(!0),eF(!1),eJ(null),eB(e),eW({total:h.length,completed:0,passed:0,failed:0,stopped:!1});let t=0,s=0;try{for(let e=0;e<h.length;e+=1){if(eV.current){eW({total:h.length,completed:e,passed:t,failed:s,stopped:!0});break}let a=h[e];eJ(a.id),eB(e=>({...e,[a.id]:{state:"testing",error:null}}));try{let e=await fetch(`/api/providers/${a.id}/test`,{method:"POST"}),i=await e.json(),r=!!i.valid;r?t+=1:s+=1,eB(e=>({...e,[a.id]:{state:r?"success":"failed",error:r?null:i.error||null}}))}catch(e){s+=1,eB(t=>({...t,[a.id]:{state:"failed",error:e.message||"Test failed"}}))}eW({total:h.length,completed:e+1,passed:t,failed:s,stopped:!1}),e<h.length-1&&await new Promise(e=>setTimeout(e,1e3))}}finally{eJ(null),eq(!1),eF(!1),eV.current=!1}},tG=async e=>{let t=h.find(t=>t.id===e),s=t?.name?.trim()||t?.email?.trim()||e;eP({title:"Delete Connection",message:`Delete connection “${s}”?`,onConfirm:async()=>{eP(null);try{(await fetch(`/api/providers/${e}`,{method:"DELETE"})).ok&&f(t=>t.filter(t=>t.id!==e))}catch(e){(0,E.s)("Error deleting connection:",e)}}})},tQ=()=>{tM(),P(!1)},tZ=async e=>{G("");try{let t=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:u,...e})}),s=null;try{s=await t.json()}catch{s=null}if(t.ok){await tM(),W(!1);return}G(s?.error||"Failed to save connection")}catch(e){(0,E.s)("Error saving connection:",e),G("Failed to save connection")}},tX=async e=>{try{(await fetch(`/api/providers/${es.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok&&(await tM(),Y(!1))}catch(e){(0,E.s)("Error updating connection:",e)}},tY=async(e,t)=>{try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&f(s=>s.map(s=>s.id===e?{...s,isActive:t}:s))}catch(e){(0,E.s)("Error updating connection status:",e)}},t0=async e=>{let t,s=e?.providerSpecificData?.baseUrl;if(s){try{t=new URL(s).hostname.toLowerCase().replace(/^\[|\]$/g,"")}catch{(0,E.s)("Cannot allow-list: invalid base URL",s);return}try{let e=await fetch("/api/settings",{cache:"no-store"});if(!e.ok)throw Error(`Failed to load settings (${e.status})`);let s=await e.json(),a=[...new Set([...s.ssrfAllowHosts||[],t])],i=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({ssrfAllowHosts:a})});if(!i.ok)throw Error(`Failed to update allow list (${i.status})`);await tM()}catch(e){(0,E.s)("Error adding host to allow list:",e)}}},t1=async(e,t)=>{let s=[...h];[s[e],s[t]]=[s[t],s[e]],f(s);try{await Promise.all([fetch(`/api/providers/${s[e].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:e})}),fetch(`/api/providers/${s[t].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:t})})])}catch(e){(0,E.s)("Error swapping priority:",e),await tM()}},t2=h.length>0&&g.length===h.length,t5=(0,a.jsx)("div",{className:"flex min-w-0 flex-col divide-y divide-black/[0.03] dark:divide-white/[0.03]",children:h.map((e,t)=>(0,a.jsxs)("div",{className:"flex min-w-0 items-stretch",children:[(0,a.jsx)("div",{className:"flex shrink-0 items-center pl-1 sm:pl-2",children:(0,a.jsx)("input",{type:"checkbox",checked:g.includes(e.id),onChange:()=>{var t;return t=e.id,void y(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])},className:"h-4 w-4 rounded border-gray-300 text-primary focus:ring-primary"})}),(0,a.jsx)("div",{className:"flex-1 min-w-0",children:(0,a.jsx)(M,{connection:e,isOAuth:tm,isFirst:0===t,isLast:t===h.length-1,onMoveUp:()=>t1(t,t-1),onMoveDown:()=>t1(t,t+1),onToggleActive:t=>tY(e.id,t),autoPing:B[u]&&"oauth"===e.authType?{on:!0===eN.connections[e.id],onToggle:t=>{var s;return s=e.id,void tF({...eN,connections:{...eN.connections,[s]:t}})},provider:u}:null,onEdit:()=>{ea(e),Y(!0)},onDelete:()=>tG(e.id),onAllowlistHost:()=>t0(e),oneByOneStatus:eK[e.id]||null})})]},e.id))}),t4=async e=>{if(!ex.has(e)){eh(t=>new Set(t).add(e));try{let t=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${t$}/${e}`})}),s=await t.json();em(t=>({...t,[e]:s.ok?"ok":"error"})),eu(s.ok?"":s.error||"Model not reachable")}catch{em(t=>({...t,[e]:"error"})),eu("Network error")}finally{eh(t=>{let s=new Set(t);return s.delete(e),s})}}};return k?(0,a.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,a.jsx)(d.Qv,{}),(0,a.jsx)(d.Qv,{})]}):td?(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:gap-8 sm:px-0",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)(l(),{href:"/dashboard/providers",className:"inline-flex items-center gap-1 text-sm text-text-muted hover:text-primary transition-colors mb-4",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-lg",children:"arrow_back"}),"Back to Providers"]}),(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3 sm:gap-4",children:[(0,a.jsx)("div",{className:"flex size-12 shrink-0 items-center justify-center rounded-lg",style:{backgroundColor:`${td.color}15`},children:eo?(0,a.jsx)("span",{className:"text-sm font-bold",style:{color:td.color},children:td.textIcon||td.id.slice(0,2).toUpperCase()}):(0,a.jsx)(o.default,{src:tg&&td.apiType?"responses"===td.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":ty?"/providers/anthropic-m.png":`/providers/${td.id}.png`,alt:td.name,width:48,height:48,className:"max-h-12 max-w-12 rounded-lg object-contain",sizes:"48px",onError:()=>ed(!0)})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 flex-wrap",children:[(0,a.jsx)("h1",{className:"truncate text-2xl font-semibold tracking-tight sm:text-3xl",children:td.name}),(td.notice?.apiKeyUrl||td.notice?.signupUrl||td.website)&&(0,a.jsxs)("a",{href:td.notice?.apiKeyUrl||td.notice?.signupUrl||td.website,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline inline-flex items-center gap-1",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"open_in_new"}),td.notice?.apiKeyUrl?"Get API Key":"Sign up / Learn more"]})]}),(0,a.jsxs)("p",{className:"text-text-muted",children:[h.length," connection",1===h.length?"":"s"]})]})]})]}),td.deprecated&&(0,a.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px] text-yellow-500 mt-0.5 shrink-0",children:"warning"}),(0,a.jsx)("p",{className:"text-xs text-red-600 dark:text-yellow-400 leading-relaxed",children:td.deprecationNotice})]}),td.notice?.text&&!td.deprecated&&(0,a.jsxs)("div",{className:"flex flex-col gap-2 rounded-lg border border-blue-500/30 bg-blue-500/10 px-3 py-2 sm:flex-row sm:items-center",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px] text-blue-500 shrink-0",children:"info"}),(0,a.jsx)("p",{className:"min-w-0 flex-1 text-xs leading-relaxed text-blue-600 dark:text-blue-400",children:td.notice.text}),td.notice.apiKeyUrl&&(0,a.jsx)("a",{href:td.notice.apiKeyUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex justify-center rounded bg-blue-500 px-2 py-1 text-xs font-medium text-white transition-colors hover:bg-blue-600 sm:py-0.5",children:"Get API Key →"})]}),tb&&T&&(0,a.jsx)(d.Zp,{children:(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:ty?"Anthropic Compatible Details":"OpenAI Compatible Details"}),(0,a.jsxs)("p",{className:"break-all text-sm text-text-muted",children:[ty?"Messages API":"responses"===T.apiType?"Responses API":"Chat Completions"," \xb7 ",(T.baseUrl||"").replace(/\/$/,""),"/",ty?"messages":"responses"===T.apiType?"responses":"chat/completions"]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:()=>{G(""),W(!0)},className:"w-full sm:w-auto",children:"Add API Key"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"edit",onClick:()=>et(!0),className:"w-full sm:w-auto",children:"Edit"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"delete",onClick:async()=>{eP({title:"Delete Compatible Node",message:`Delete this ${ty?"Anthropic":"OpenAI"} Compatible node?`,onConfirm:async()=>{eP(null);try{(await fetch(`/api/provider-nodes/${u}`,{method:"DELETE"})).ok&&p.push("/dashboard/providers")}catch(e){(0,E.s)("Error deleting provider node:",e)}}})},className:"w-full sm:w-auto",children:"Delete"})]})]})}),tu?(0,a.jsx)(d.gw,{providerId:u}):(0,a.jsxs)(d.Zp,{children:[(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Connections"}),(0,a.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:gap-4",children:[h.length>0&&(0,a.jsxs)(a.Fragment,{children:[g.length>0&&(0,a.jsxs)(d.$n,{size:"sm",variant:"danger",icon:"delete",onClick:()=>{let e=g.length;0!==e&&eP({title:`Delete ${e} Connection${e>1?"s":""}`,message:`Delete ${e} connection${e>1?"s":""}? This cannot be undone.`,onConfirm:async()=>{eP(null);let e=0,t=[...g];for(let s of t)try{(await fetch(`/api/providers/${s}`,{method:"DELETE"})).ok||(e+=1)}catch(t){(0,E.s)("Error deleting connection:",t),e+=1}f(e=>e.filter(e=>!t.includes(e.id))),y([]),e>0&&(0,E.s)(`Deleted ${t.length-e} connection(s), ${e} failed.`)}})},children:["Delete Selected (",g.length,")"]}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"sync",onClick:tV,disabled:eU,children:eU?"Testing Connection One-by-One...":"Test Connection One-by-One"}),eU&&(0,a.jsx)(d.$n,{size:"sm",variant:"ghost",icon:"stop",onClick:()=>{eU&&(eV.current=!0,eF(!0))},disabled:e_,children:e_?"Stopping...":"Stop"})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,a.jsx)("span",{className:"text-xs text-text-muted font-medium",children:"Round Robin"}),(0,a.jsx)(d.lM,{checked:"round-robin"===ey,onChange:e=>{let t=e?"round-robin":null,s=e?ev||"1":ev;e&&!ev&&ej("1"),eb(t),tq(t,s)}}),"round-robin"===ey&&(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"text-xs text-text-muted",children:"Sticky:"}),(0,a.jsx)("input",{type:"number",min:1,value:ev,onChange:e=>{var t;ej(t=e.target.value),tq("round-robin",t)},placeholder:"1",className:"w-14 px-2 py-1 text-xs border border-border rounded-md bg-background focus:outline-none focus:border-primary"})]})]})]})]}),0===h.length?(0,a.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"inline-flex items-center justify-center w-9 h-9 rounded-full bg-primary/10 text-primary shrink-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:tm?"lock":"key"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"No connections yet"}),tw&&(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["Choose ",tk," or ",tN,"."]})]})]}),(0,a.jsx)("div",{className:"flex gap-2",children:tw?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.$n,{size:"sm",icon:"lock",variant:"secondary",onClick:tn,children:tk}),(0,a.jsx)(d.$n,{size:"sm",icon:"key",onClick:tl,children:tN})]}):(0,a.jsxs)(a.Fragment,{children:[!tb&&"iflow"===u&&(0,a.jsx)(d.$n,{size:"sm",icon:"cookie",variant:"secondary",onClick:()=>F(!0),children:"Cookie"}),"codex"===u&&(0,a.jsx)(d.$n,{size:"sm",icon:"playlist_add",variant:"secondary",onClick:()=>Z(!0),children:(0,w.Tl)("Bulk Add")}),(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:to,children:tb?"Add API Key":"iflow"===u?"OAuth":"Add Connection"})]})})]}):(0,a.jsxs)(a.Fragment,{children:[eH&&(0,a.jsx)("div",{className:"mb-4 rounded-lg border border-black/10 bg-black/[0.02] px-3 py-2 text-xs text-text-muted dark:border-white/10 dark:bg-white/[0.03]",children:(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,a.jsxs)("span",{children:["Total: ",eH.total]}),(0,a.jsxs)("span",{children:["Completed: ",eH.completed]}),(0,a.jsxs)("span",{children:["Passed: ",eH.passed]}),(0,a.jsxs)("span",{children:["Failed: ",eH.failed]}),eH.stopped&&(0,a.jsx)("span",{className:"text-amber-600 dark:text-amber-400",children:"Stopped"}),eU&&eL&&(0,a.jsxs)("span",{children:["Running: ",h.find(e=>e.id===eL)?.name||eL]})]})}),h.length>0&&(0,a.jsx)("div",{className:"mb-3 flex items-center gap-2 border-b border-black/[0.03] pb-2 dark:border-white/[0.03]",children:(0,a.jsxs)("label",{className:"flex cursor-pointer items-center gap-1.5 text-xs text-text-muted hover:text-primary",children:[(0,a.jsx)("input",{type:"checkbox",checked:t2,onChange:()=>{t2?y([]):y(h.map(e=>e.id))},className:"h-3.5 w-3.5 rounded border-gray-300 text-primary focus:ring-primary"}),"Select All"]})}),t5,!tb&&(0,a.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-2 sm:flex",children:["iflow"===u&&(0,a.jsx)(d.$n,{size:"sm",icon:"cookie",variant:"secondary",onClick:()=>F(!0),title:"Add connection using browser cookie",className:"w-full sm:w-auto",children:"Cookie"}),"codex"===u&&(0,a.jsx)(d.$n,{size:"sm",icon:"playlist_add",variant:"secondary",onClick:()=>Z(!0),title:(0,w.Tl)("Bulk import codex accounts from JSON"),className:"w-full sm:w-auto",children:(0,w.Tl)("Bulk Add")}),tw?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.$n,{size:"sm",icon:"lock",variant:"secondary",onClick:tn,className:"w-full sm:w-auto",children:tk}),(0,a.jsx)(d.$n,{size:"sm",icon:"key",onClick:tl,className:"w-full sm:w-auto",children:tN})]}):(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:to,className:"w-full sm:w-auto",children:"Add"})]})]})]}),(0,a.jsxs)(d.Zp,{children:[(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Available Models"}),tS&&(0,a.jsx)("select",{value:ew,onChange:e=>{var t;ek(t=e.target.value),t_(t)},title:"Appends (level) suffix to copied model names",className:"rounded-md border border-border bg-background px-2 py-1 text-xs focus:border-primary focus:outline-none",children:tS.map(e=>(0,a.jsx)("option",{value:e,children:`Thinking: ${e.charAt(0).toUpperCase()+e.slice(1)}`},e))})]}),tj.showToolbar&&(e=(tj.showBulkControls?[...th,...eO.filter(e=>!th.some(t=>t.id===e.id))].filter(e=>{let t=(0,m.CP)(e);return!t||"llm"===t}).map(e=>e.id):[]).filter(e=>!eR.includes(e)),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[tj.showImport&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:eX?"progress_activity":"cloud_download",onClick:tW,disabled:eX||!tv,title:tv?"Import models from the active connection":"Add an active connection to import models",children:eX?"Importing...":"Import models"}),tj.showVerify&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:e4?.status==="running"?"progress_activity":"science",onClick:()=>e5(e=>!e),children:e4?.status==="running"?`Verifying ${e4.done}/${e4.total}`:e2?"Hide verify":"Verify models"}),tj.showBulkControls&&eR.length>0&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"restart_alt",onClick:tD,children:"Active All"}),tj.showBulkControls&&e.length>0&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"block",onClick:()=>tR(e),children:"Disable All"})]}))]}),!!ep&&(0,a.jsx)("p",{className:"text-xs text-red-500 mb-3 break-words",children:ep}),e0&&(0,a.jsx)("p",{className:"text-xs text-text-muted mb-3",children:e0}),e2&&(t=h.find(e=>g.includes(e.id)&&!1!==e.isActive)||h.find(e=>!1!==e.isActive),s=[...(0,C.R)({customModels:en,modelAliases:ei,providerAlias:t$,builtInModels:th,type:"llm"}).map(e=>({id:e.id,name:e.name||e.id,kind:"llm"})),...th.filter(e=>{let t=(0,m.CP)(e);return(!t||"llm"===t)&&!eR.includes(e.id)}).map(e=>({id:e.id,name:e.name||e.id,kind:"llm"}))],(0,a.jsx)(J,{connectionId:t?.id,providerAlias:t$,models:s,jobSnapshot:e4,onClose:()=>e5(!1),onStarted:e=>{e3(e&&e.status?e:null);let s=e?.connectionId||t?.id;s&&tL(s)},onComplete:async e=>{e?.removed>0&&await tP(),(e?.removed>0||e?.cacheCleared)&&await tz(t?.id)}})),(()=>{let e,t,s;if(tb)return(0,a.jsx)(D,{providerStorageAlias:t$,providerDisplayAlias:tA,modelAliases:ei,customModels:en,copied:ts,onCopy:ta,onSetAlias:tJ,onDeleteAlias:tK,onAddCustomModel:e=>tB(e,"llm",t$),onDeleteCustomModel:e=>tH(e,"llm",t$),onRefreshModels:tP,connections:h,isAnthropic:ty});let i=[...th,...eO.filter(e=>!th.some(t=>t.id===e.id))].filter(e=>{let t=(0,m.CP)(e);return!t||"llm"===t}),r=new Set(eR),n=i.filter(e=>!r.has(e.id)),l=i.filter(e=>r.has(e.id)),o=(0,C.R)({customModels:en,modelAliases:ei,providerAlias:t$,builtInModels:th,type:"llm"}),d=o.filter(e=>"all"===te||(e8[K(e.id,t$)]||null)===te),c=n.filter(e=>"all"===te||(e8[K(e.id,t$)]||null)===te);return(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsx)("div",{className:"mb-2 flex gap-1 text-xs",children:["all","ok","dead","retry"].map(e=>(0,a.jsx)("button",{onClick:()=>tt(e),className:`rounded px-2 py-0.5 ${te===e?"bg-primary text-white":"text-text-muted hover:bg-black/5 dark:hover:bg-white/5"}`,children:"all"===e?"All":"ok"===e?"OK":"dead"===e?"Dead":"Retry"},e))}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-3",children:[d.map(e=>{let t=K(e.id,t$);return(0,a.jsx)(O,{model:{id:e.id,name:e.name},fullModel:`${tA}/${e.id}`,alias:e.alias,copied:ts,onCopy:ta,onSetAlias:()=>{},onDeleteAlias:()=>{"custom"===e.source?tH(e.id,"llm",t$):tK(e.alias)},testStatus:ec[e.id],onTest:h.length>0||tu?()=>t4(e.id):void 0,isTesting:ex.has(e.id),isCustom:!0,isFree:!1,caps:x(`${u}/${e.id}`),thinkingSuffix:tC(e.id),latencyMs:e6[e.id]??e6[t],probeState:e4?.status==="running"&&e4?.perModel?.[t]?e4.perModel[t]:e8[t]||null},`${e.source}-${e.fullModel}`)}),c.map(e=>{let t=`${t$}/${e.id}`,s=`${u}/${e.id}`,i=Object.entries(ei).find(([,e])=>e===t||e===s)?.[0],r=K(e.id,t$);return(0,a.jsx)(O,{model:e,fullModel:`${tA}/${e.id}`,alias:i,copied:ts,onSetAlias:t=>tJ(e.id,t,t$),onCopy:ta,onDeleteAlias:()=>tK(i),testStatus:ec[e.id],onTest:h.length>0||tu?()=>t4(e.id):void 0,isTesting:ex.has(e.id),isFree:e.isFree,onDisable:()=>tO(e.id),caps:x(`${u}/${e.id}`),thinkingSuffix:tC(e.id),latencyMs:e6[e.id]??e6[r],probeState:e4?.status==="running"&&e4?.perModel?.[r]?e4.perModel[r]:e8[r]||null},e.id)}),(0,a.jsxs)("button",{onClick:()=>eg(!0),className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-primary/40 px-3 py-2 text-xs text-primary transition-colors hover:border-primary hover:bg-primary/5 sm:w-auto",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"add"}),"Add Model"]}),eS.length>0&&(e=new Set([...Object.values(ei),...o.map(e=>e.fullModel)]),t=new Set(th.map(e=>e.id)),0===(s=eS.filter(s=>!e.has(`${t$}/${s.id}`)&&!t.has(s.id))).length?null:(0,a.jsxs)("div",{className:"w-full mt-2",children:[(0,a.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"Suggested free models (≥200k context):"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:s.map(e=>(0,a.jsxs)("button",{onClick:async()=>{await tB(e.id,"llm",t$)},className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg border border-black/10 dark:border-white/10 text-xs text-text-muted hover:text-primary hover:border-primary/40 hover:bg-primary/5 transition-colors",title:`${e.name} \xb7 ${(e.contextLength/1e3).toFixed(0)}k ctx`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"add"}),e.id.split("/").pop()]},e.id))})]})),l.length>0&&(0,a.jsxs)("div",{className:"w-full mt-2",children:[(0,a.jsxs)("p",{className:"text-xs text-text-muted mb-2",children:["Disabled models (",l.length,"):"]}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:l.map(e=>(0,a.jsxs)("button",{onClick:()=>tE(e.id),className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg border border-dashed border-black/10 dark:border-white/10 text-xs text-text-muted hover:text-primary hover:border-primary/40 hover:bg-primary/5 transition-colors",title:"Restore model",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"add"}),e.id]},e.id))})]})]})]})})()]}),"kiro"===u?(0,a.jsx)(d.Mh,{isOpen:I,providerInfo:td,onSuccess:tQ,onClose:()=>P(!1)}):"cursor"===u?(0,a.jsx)(d.G9,{isOpen:I,onSuccess:tQ,onClose:()=>P(!1)}):"gitlab"===u?(0,a.jsx)(d.vj,{isOpen:I,providerInfo:td,onSuccess:tQ,onClose:()=>P(!1)}):(0,a.jsx)(d.LF,{isOpen:I,provider:u,providerInfo:td,onSuccess:tQ,onClose:()=>P(!1)}),"iflow"===u&&(0,a.jsx)(d.vE,{isOpen:z,onSuccess:()=>{tM(),F(!1)},onClose:()=>F(!1)}),(0,a.jsx)(U,{isOpen:H,provider:u,providerName:td.name,isCompatible:tb,isAnthropic:ty,authType:td?.authType,authHint:td?.authHint,website:td?.website,error:V,onSave:tZ,onBulkDone:tM,onClose:()=>{G(""),W(!1)}}),(0,a.jsx)(d.wI,{isOpen:X,connection:es,onSave:tX,onClose:()=>Y(!1)}),tb&&(0,a.jsx)(q,{isOpen:ee,node:T,onSave:tU,onClose:()=>et(!1),isAnthropic:ty}),!tb&&(0,a.jsx)(_,{isOpen:ef,providerAlias:t$,providerDisplayAlias:tA,onSave:async e=>{await tB(e,"llm",t$),eg(!1)},onClose:()=>eg(!1)}),"codex"===u&&(0,a.jsx)(L,{isOpen:Q,onClose:()=>Z(!1),onSuccess:tM}),(0,a.jsx)(d.uo,{isOpen:eM,onClose:()=>ez(!1),onConfirm:()=>{(window.localStorage.setItem(ti,"true"),ez(!1),tm)?tr():tl()},title:"Risk Notice",message:td?.deprecationNotice,confirmText:"I Understand, Continue",cancelText:"Cancel",variant:"danger"}),(0,a.jsx)(d.uo,{isOpen:!!eI,onClose:()=>eP(null),onConfirm:eI?.onConfirm,title:eI?.title||"Confirm",message:eI?.message,variant:"danger"})]}):(0,a.jsxs)("div",{className:"text-center py-20",children:[(0,a.jsx)("p",{className:"text-text-muted",children:"Provider not found"}),(0,a.jsx)(l(),{href:"/dashboard/providers",className:"text-primary mt-4 inline-block",children:"Back to Providers"})]})}},7687:(e,t,s)=>{Promise.resolve().then(s.bind(s,4003))},70217:(e,t,s)=>{"use strict";function a(e,t){return!1===e?"default":"active"===t||"success"===t?"success":"error"===t||"expired"===t||"unavailable"===t?"error":"default"}s.d(t,{g:()=>a})}},e=>{e.O(0,[2574,3862,782,8500,594,1321,7592,5497,8441,3794,7358],()=>e(e.s=7687)),_N_E=e.O()}]);
10
+ ]`;function L({isOpen:e,onClose:t,onSuccess:s}){let[r,n]=(0,i.useState)(""),[l,o]=(0,i.useState)(!1),[c,m]=(0,i.useState)(""),[p,u]=(0,i.useState)(null),x=()=>{l||(n(""),m(""),u(null),t())},h=async()=>{var e;let t;m(""),u(null);let a=r.trim();if(!a)return;try{t=JSON.parse(a)}catch(e){m(`${(0,w.Tl)("Invalid JSON")}: ${e.message}`);return}let i=Array.isArray(e=t)?e:e&&"object"==typeof e?Array.isArray(e.accounts)?e.accounts:[e]:null;if(!i||0===i.length)return void m((0,w.Tl)("No accounts found in input"));o(!0);try{let e=await fetch("/api/oauth/codex/bulk-import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({accounts:i})}),t=await e.json();if(!e.ok)return void m(t?.error||`Request failed: ${e.status}`);u(t),t.success>0&&"function"==typeof s&&s()}catch(e){m(e.message||(0,w.Tl)("Request failed"))}finally{o(!1)}},f=p?.results?.filter(e=>!e.ok)||[];return(0,a.jsx)(d.aF,{isOpen:e,title:(0,w.Tl)("Bulk Add Codex Accounts"),onClose:x,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)("p",{className:"text-xs text-text-muted",children:(0,w.Tl)("Paste an array of codex account JSON objects. Each must include accessToken (and ideally refreshToken, idToken).")}),(0,a.jsx)("textarea",{className:"w-full rounded border border-accent/30 bg-sidebar p-2 text-sm font-mono resize-y min-h-[240px] focus:outline-none focus:ring-1 focus:ring-primary",placeholder:F,value:r,onChange:e=>n(e.target.value),disabled:l}),c&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:c}),p&&(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:`text-sm font-medium ${p.failed>0?"text-yellow-400":"text-green-400"}`,children:["✓ ",p.success," ",(0,w.Tl)("added"),p.failed>0?`, ✗ ${p.failed} ${(0,w.Tl)("failed")}`:""]}),f.length>0&&(0,a.jsx)("ul",{className:"rounded border border-accent/20 bg-sidebar/50 p-2 text-xs font-mono max-h-40 overflow-y-auto",children:f.map(e=>(0,a.jsxs)("li",{className:"text-red-400",children:["[",e.index,"] ",e.error]},e.index))})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{onClick:h,fullWidth:!0,disabled:l||!r.trim(),children:l?(0,w.Tl)("Importing..."):(0,w.Tl)("Import All")}),(0,a.jsx)(d.$n,{onClick:x,variant:"ghost",fullWidth:!0,disabled:l,children:(0,w.Tl)("Close")})]})]})})}L.propTypes={isOpen:T().bool.isRequired,onClose:T().func.isRequired,onSuccess:T().func};function J({connectionId:e,providerAlias:t,models:s,jobSnapshot:r,onComplete:n,onStarted:l,onClose:o}){let[c,m]=(0,i.useState)(4),[p,u]=(0,i.useState)(50),[x,h]=(0,i.useState)(Math.round(20)),[f,g]=(0,i.useState)(!1),[y,b]=(0,i.useState)(null),[v,j]=(0,i.useState)(null),[w,k]=(0,i.useState)(""),[N,C]=(0,i.useState)(""),S=(0,i.useRef)({onComplete:n,onStarted:l}),$=(0,i.useRef)(null),A=(0,i.useRef)(e),T=(0,i.useRef)(null),O=s?.length||0,E=(0,i.useMemo)(()=>`max concurrency 16 \xb7 batch 200 \xb7 timeout ${60}s`,[]);function R(e){if(e){if("idle"===e.status){T.current=null,g(!1);return}if(b({done:e.done||0,total:e.total||0,ok:e.ok||0,dead:e.dead||0,retryable:e.retryable||0,skippedDead:e.skippedDead||0,skippedDup:e.skippedDup||0}),"running"===e.status&&(T.current=e.connectionId||A.current,$.current=null,g(!0)),e.currentRange&&C(`Probing ${e.currentRange.from}–${e.currentRange.to} of ${e.total}…`),e.error&&k(e.error),"done"===e.status||"cancelled"===e.status||"error"===e.status){T.current=null,g(!1);let t={ok:e.ok||0,dead:e.dead||0,retryable:e.retryable||0,tested:e.done||0,skippedDead:e.skippedDead||0,skippedDup:e.skippedDup||0,cancelled:"cancelled"===e.status};j(t),C("cancelled"===e.status?"Cancelled (partial results saved).":"error"===e.status?"Stopped.":"Done.");let s=`${e.startedAt||"unknown"}:${e.status}`;$.current!==s&&($.current=s,S.current.onComplete?.(t))}}}async function D(){if(f||!e||0===O)return;g(!0),k(""),j(null),C("Starting…");let a={concurrency:Math.max(1,Math.min(16,Number(c)||4)),batchSize:Math.max(1,Math.min(200,Number(p)||50)),timeoutMs:Math.max(1e3,Math.min(6e4,1e3*(Number(x)||20)))};T.current=e;try{let i=await fetch(`/api/providers/${e}/model-probes/verify/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({models:s,providerAlias:t,...a,timeoutMs:a.timeoutMs})}),r=await i.json().catch(()=>({}));if(A.current!==e){T.current=null,g(!1);return}if(!i.ok){T.current=null,k(r.error||"Failed to start"),g(!1);return}S.current.onStarted?.(r),R(r),"running"!==r.status&&g(!1)}catch(e){T.current=null,k(e?.message||"Verify failed"),g(!1)}}async function I(){let t=T.current||e;await fetch(`/api/providers/${t}/model-probes/verify/cancel`,{method:"POST"}).catch(()=>{})}async function P(){if(!e)return;C("Removing unavailable custom models…");let s=await fetch(`/api/providers/${e}/model-probes/remove-unavailable`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:t,kind:"llm"})}),a=await s.json().catch(()=>({}));s.ok?(C(`Removed ${a.removed||0} unavailable custom model(s).`),S.current.onComplete?.({...v||{},removed:a.removed||0})):k(a.error||"Remove failed")}async function M(){if(!e)return;let t=await fetch(`/api/providers/${e}/model-probes/cache`,{method:"DELETE"}),s=await t.json().catch(()=>({}));t.ok?(C(`Cleared probe cache (${s.cleared||0} rows). Next verify will re-test everything.`),j(null),b(null),S.current.onComplete?.({cacheCleared:!0,cleared:s.cleared||0})):k(s.error||"Clear cache failed")}(0,i.useEffect)(()=>{S.current={onComplete:n,onStarted:l},A.current=e}),(0,i.useEffect)(()=>{R(r)},[r]);let z=y?.total?Math.min(100,Math.round(y.done/y.total*100)):0;return(0,a.jsxs)("div",{className:"mb-4 rounded-lg border border-border bg-sidebar/40 p-3 space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"text-sm font-semibold text-text-main",children:"Verify models"}),(0,a.jsxs)("p",{className:"text-[11px] text-text-muted mt-0.5",children:["Batch-ping availability and latency. Dead = permanently unavailable (404/403) and can be removed; retry = transient (timeout/429/5xx). Known-dead models are skipped until you Clear cache. Caps: ",E,"."]})]}),o&&(0,a.jsx)("button",{type:"button",onClick:o,className:"p-1 text-text-muted hover:text-text-main rounded",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"close"})})]}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-3 items-end",children:[(0,a.jsxs)("label",{className:"text-xs text-text-muted",children:["Concurrency",(0,a.jsx)("input",{type:"number",min:1,max:16,value:c,disabled:f,onChange:e=>m(e.target.value),className:"mt-1 block w-20 rounded-md border border-border bg-background px-2 py-1 text-xs"})]}),(0,a.jsxs)("label",{className:"text-xs text-text-muted",children:["Batch size",(0,a.jsx)("input",{type:"number",min:1,max:200,value:p,disabled:f,onChange:e=>u(e.target.value),className:"mt-1 block w-20 rounded-md border border-border bg-background px-2 py-1 text-xs"})]}),(0,a.jsxs)("label",{className:"text-xs text-text-muted",children:["Timeout (s)",(0,a.jsx)("input",{type:"number",min:1,max:60,value:x,disabled:f,onChange:e=>h(e.target.value),className:"mt-1 block w-20 rounded-md border border-border bg-background px-2 py-1 text-xs"})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[f?(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"stop",onClick:I,children:"Cancel"}):(0,a.jsx)(d.$n,{size:"sm",icon:"science",onClick:D,disabled:!e||0===O,children:"Start"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"delete_sweep",onClick:M,disabled:f,children:"Clear cache"})]})]}),y&&(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)("div",{className:"h-1.5 w-full rounded-full bg-border overflow-hidden",children:(0,a.jsx)("div",{className:"h-full bg-primary transition-all",style:{width:`${z}%`}})}),(0,a.jsxs)("p",{className:"text-[11px] text-text-muted flex flex-wrap gap-x-2",children:[(0,a.jsxs)("span",{title:"Models probed this run",children:[y.done,"/",y.total," tested"]}),(0,a.jsxs)("span",{title:"Reachable",children:["\xb7 ok ",y.ok]}),(0,a.jsxs)("span",{title:"Permanently unavailable this run (404 not found / 403 access denied)",children:["\xb7 dead ",y.dead]}),(0,a.jsxs)("span",{title:"Transient failure this run (timeout / 429 / 5xx / network); re-testable",children:["\xb7 retry ",y.retryable]}),y.skippedDead?(0,a.jsxs)("span",{title:"Not probed — cache already marks them dead. Clear cache to re-test.",children:["\xb7 skipped known-dead ",y.skippedDead]}):null,y.skippedDup?(0,a.jsxs)("span",{title:"Duplicate ids collapsed",children:["\xb7 dupes ",y.skippedDup]}):null]})]}),N&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:N}),w&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:w}),v&&(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:[(0,a.jsxs)("span",{className:"text-xs text-text-main",children:["Summary: ",v.ok," ok \xb7 ",v.dead," dead \xb7 ",v.retryable," retry",v.skippedDead?` \xb7 ${v.skippedDead} skipped known-dead`:"",v.cancelled?" \xb7 cancelled":""]}),v.dead>0&&(0,a.jsxs)(d.$n,{size:"sm",variant:"primary",icon:"delete_sweep",onClick:P,disabled:f,children:["Remove ",v.dead," dead"]})]})]})}function K(e,t=""){let s=String(e||"").trim();if(!s)return"";s=(s=s.replace(/\s+/g,"")).replace(/^models\//i,"");let a=String(t||"").trim();return a&&s.toLowerCase().startsWith(`${a.toLowerCase()}/`)&&(s=s.slice(a.length+1)),(s=s.replace(/\/{2,}/g,"/").replace(/^\/+|\/+$/g,"")).toLowerCase()}J.propTypes={connectionId:T().string,providerAlias:T().string,models:T().arrayOf(T().object),jobSnapshot:T().object,onComplete:T().func,onStarted:T().func,onClose:T().func};let B={claude:"claudeAutoPing",codex:"codexAutoPing"};function H(){let e,t,s,n=(0,r.useParams)(),p=(0,r.useRouter)(),u=n.id,{getCaps:x}=(0,j.y)(),[h,f]=(0,i.useState)([]),[g,y]=(0,i.useState)([]),[k,A]=(0,i.useState)(!0),[T,R]=(0,i.useState)(null),[I,P]=(0,i.useState)(!1),[z,F]=(0,i.useState)(!1),[H,W]=(0,i.useState)(!1),[V,G]=(0,i.useState)(""),[Q,Z]=(0,i.useState)(!1),[X,Y]=(0,i.useState)(!1),[ee,et]=(0,i.useState)(!1),[es,ea]=(0,i.useState)(null),[ei,er]=(0,i.useState)({}),[en,el]=(0,i.useState)([]),[eo,ed]=(0,i.useState)(!1),[ec,em]=(0,i.useState)({}),[ep,eu]=(0,i.useState)(""),[ex,eh]=(0,i.useState)(()=>new Set),[ef,eg]=(0,i.useState)(!1),[ey,eb]=(0,i.useState)(null),[ev,ej]=(0,i.useState)(""),[ew,ek]=(0,i.useState)("auto"),[eN,eC]=(0,i.useState)({enabled:!1,connections:{}}),[eS,e$]=(0,i.useState)([]),[eA,eT]=(0,i.useState)([]),[eO,eE]=(0,i.useState)([]),[eR,eD]=(0,i.useState)([]),[eI,eP]=(0,i.useState)(null),[eM,ez]=(0,i.useState)(!1),[eU,eq]=(0,i.useState)(!1),[e_,eF]=(0,i.useState)(!1),[eL,eJ]=(0,i.useState)(null),[eK,eB]=(0,i.useState)({}),[eH,eW]=(0,i.useState)(null),eV=(0,i.useRef)(!1),eG=(0,i.useRef)(null),eQ=(0,i.useRef)(0),eZ=(0,i.useRef)(0),[eX,eY]=(0,i.useState)(!1),[e0,e1]=(0,i.useState)(""),[e2,e5]=(0,i.useState)(!1),[e3,e4]=(0,i.useState)(null),[e6,e7]=(0,i.useState)({}),[e8,e9]=(0,i.useState)({}),[te,tt]=(0,i.useState)("all"),{copied:ts,copy:ta}=(0,v.C)(),ti="ag_risk_confirmed",tr=()=>{P(!0)},tn=()=>{"antigravity"===u&&"true"!==window.localStorage.getItem(ti)?ez(!0):tm?tr():(G(""),W(!0))},tl=()=>{G(""),W(!0)},to=()=>{tm?tn():tl()},td=T?{id:T.id,name:T.name||("anthropic-compatible"===T.type?"Anthropic Compatible":"OpenAI Compatible"),color:"anthropic-compatible"===T.type?"#D97757":"#10A37F",textIcon:"anthropic-compatible"===T.type?"AC":"OC",apiType:T.apiType,baseUrl:T.baseUrl,type:T.type}:c.zN[u]||c.fg[u]||c.IS[u]||c.nJ[u]||c.br[u],tc=td?.authModes||[],tm=!!c.zN[u]||!!c.IS[u]||tc.includes("oauth"),tp=!!c.fg[u]||tc.includes("apikey"),tu=!!c.IS[u]?.noAuth,tx=(0,m.KC)(u),th=(()=>{let e=new Map(tx.map(e=>[e.id,e]));for(let t of eA)t?.id&&e.set(t.id,{...e.get(t.id),...t});return[...e.values()]})(),tf=(0,c.wG)(u),tg=(0,c.mq)(u),ty=(0,c.gb)(u),tb=tg||ty,tv=h.some(e=>!1!==e.isActive),tj=function({isCompatible:e,hasActiveConnection:t}){let s=!e,a=!e;return{showToolbar:s||t||a,showImport:s,showVerify:t,showBulkControls:a}}({isCompatible:tb,hasActiveConnection:tv}),tw=!tb&&tm&&tp,tk="xai"===u?"Grok Build OAuth":"OAuth",tN="xai"===u?"xAI API Key":"API Key",tC=e=>{if(!ew||"auto"===ew)return null;let t=b(u,e);return t&&t.includes(ew)?ew:null},tS=(()=>{let e=new Set;for(let t of th){let s=b(u,t.id);s&&s.forEach(t=>{"none"!==t&&e.add(t)})}return e.size?["auto",...e]:null})(),t$=tb?u:tf,tA=tb?T?.prefix||u:tf,tT=(0,i.useCallback)(async()=>{try{let e=await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(t$)}`,{cache:"no-store"}),t=await e.json();e.ok&&eD(t.ids||[])}catch(e){(0,E.s)("Error fetching disabled models:",e)}},[t$]),tO=async e=>{try{(await fetch("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:t$,ids:[e]})})).ok&&await tT()}catch(e){(0,E.s)("Error disabling model:",e)}},tE=async e=>{try{(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(t$)}&id=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await tT()}catch(e){(0,E.s)("Error enabling model:",e)}},tR=async e=>{e.length&&eP({title:"Disable All Models",message:`Disable all ${e.length} model(s)?`,onConfirm:async()=>{eP(null);try{(await fetch("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:t$,ids:e})})).ok&&await tT()}catch(e){(0,E.s)("Error disabling all models:",e)}}})},tD=async()=>{try{(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(t$)}`,{method:"DELETE"})).ok&&await tT()}catch(e){(0,E.s)("Error enabling all models:",e)}},tI=(0,i.useCallback)(async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&er(t.aliases||{})}catch(e){(0,E.s)("Error fetching aliases:",e)}},[]),tP=(0,i.useCallback)(async()=>{try{let e=await fetch("/api/models/custom",{cache:"no-store"}),t=await e.json();e.ok&&el(t.models||[])}catch(e){(0,E.s)("Error fetching custom models:",e)}},[]);(0,i.useEffect)(()=>{"kilocode"===u&&fetch("/api/providers/kilo/free-models").then(e=>e.json()).then(e=>{e.models?.length&&eE(e.models)}).catch(()=>{})},[u]);let tM=(0,i.useCallback)(async()=>{try{let[e,t,s]=await Promise.all([fetch("/api/providers",{cache:"no-store"}),fetch("/api/provider-nodes",{cache:"no-store"}),fetch("/api/settings",{cache:"no-store"})]),a=await e.json(),i=await t.json(),r=s.ok?await s.json():{};if(e.ok){let e=(a.connections||[]).filter(e=>e.provider===u);f(e)}let n=(r.providerStrategies||{})[u]||{};eb(n.fallbackStrategy||null),ej(null!=n.stickyRoundRobinLimit?String(n.stickyRoundRobinLimit):"1");let l=(r.providerThinking||{})[u]||{};ek(l.mode||"auto");let o=B[u],d=o&&r[o]||{};if(eC({enabled:!0===d.enabled,connections:d.connections||{}}),t.ok){let e=(i.nodes||[]).find(e=>e.id===u)||null;if(!e&&tb)for(let t=0;t<3;t+=1){await new Promise(e=>setTimeout(e,150));let t=await fetch("/api/provider-nodes",{cache:"no-store"});if(t.ok&&(e=((await t.json()).nodes||[]).find(e=>e.id===u)||null))break}R(e)}}catch(e){(0,E.s)("Error fetching connections:",e)}finally{A(!1)}},[u,tb]),tz=(0,i.useCallback)(async(e=null)=>{let t=++eZ.current,s=e?h.find(t=>t.id===e&&!1!==t.isActive):h.find(e=>g.includes(e.id)&&!1!==e.isActive)||h.find(e=>!1!==e.isActive);if(!s){e9({}),e7({});return}try{let e=await fetch(`/api/providers/${s.id}/model-probes`,{cache:"no-store"});if(!e.ok)return;let a=await e.json().catch(()=>({})),i={},r={};for(let e of a.probes||[])i[e.modelId]="ok"===e.status?"ok":"dead"===e.status?"dead":"retry",null!=e.latencyMs&&(r[e.modelId]=e.latencyMs);if(t!==eZ.current)return;e9(i),e7(r)}catch{}},[h,g]),tU=async e=>{try{let t=await fetch(`/api/provider-nodes/${u}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),s=await t.json();t.ok&&(R(s.node),await tM(),et(!1))}catch(e){(0,E.s)("Error updating provider node:",e)}},tq=async(e,t)=>{try{let s=await fetch("/api/settings",{cache:"no-store"}),a=(s.ok?await s.json():{}).providerStrategies||{},i={};e&&(i.fallbackStrategy=e),"round-robin"===e&&""!==t&&(i.stickyRoundRobinLimit=Number(t)||3);let r={...a};0===Object.keys(i).length?delete r[u]:r[u]=i,await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerStrategies:r})})}catch(e){(0,E.s)("Error saving provider strategy:",e)}},t_=async e=>{try{let t=await fetch("/api/settings",{cache:"no-store"}),s={...(t.ok?await t.json():{}).providerThinking||{}};e&&"auto"!==e?s[u]={mode:e}:delete s[u],await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerThinking:s})})}catch(e){(0,E.s)("Error saving thinking config:",e)}},tF=async e=>{let t=B[u];if(t){eC(e);try{await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[t]:e})})}catch(e){(0,E.s)("Error saving auto-ping config:",e)}}};(0,i.useEffect)(()=>{tM(),tI(),tP(),tT()},[tM,tI,tP,tT]),(0,i.useEffect)(()=>{tz()},[tz]),(0,i.useEffect)(()=>{if(tb)return;let e=h.find(e=>!1!==e.isActive);if(!e)return void eT([]);let t=!1;return fetch(`/api/providers/${e.id}/models`,{cache:"no-store"}).then(e=>e.json().catch(()=>({}))).then(e=>{!t&&Array.isArray(e.models)&&e.models.length>0&&eT(e.models)}).catch(()=>{}),()=>{t=!0}},[h,tb]),(0,i.useEffect)(()=>{let e=(c.zN[u]||c.fg[u]||c.IS[u]||c.nJ[u])?.modelsFetcher;e&&N(e).then(e$)},[u]);let tL=(0,i.useCallback)(e=>{let t=++eQ.current;eG.current&&(clearTimeout(eG.current),eG.current=null);let s=async()=>{try{let a=await fetch(`/api/providers/${e}/model-probes/verify/status`,{cache:"no-store"}),i=await a.json().catch(()=>null);if(t!==eQ.current)return;if(!a.ok||!i?.status)throw Error("Verify status temporarily unavailable");e4(i&&i.status?i:null),i?.status==="running"?eG.current=setTimeout(s,1500):(eG.current=null,await tz(e))}catch{t===eQ.current&&(eG.current=setTimeout(s,1500))}};eG.current=setTimeout(s,0)},[tz]);(0,i.useEffect)(()=>{let e=h.find(e=>g.includes(e.id)&&!1!==e.isActive)||h.find(e=>!1!==e.isActive);return e?(tL(e.id),()=>{eQ.current+=1,eG.current&&(clearTimeout(eG.current),eG.current=null)}):void e4(null)},[h,g,tL]);let tJ=async(e,t,s=tf)=>{let a=`${s}/${e}`;try{let e=await fetch("/api/models/alias",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:a,alias:t})});if(e.ok)await tI();else{let t=await e.json();(0,E.s)(t.error||"Failed to set alias")}}catch(e){(0,E.s)("Error setting alias:",e)}},tK=async e=>{try{(await fetch(`/api/models/alias?alias=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await tI()}catch(e){(0,E.s)("Error deleting alias:",e)}},tB=async(e,t="llm",s=t$)=>{try{let a=await fetch("/api/models/custom",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:s,id:e,type:t})});if(a.ok)await tP(),window.dispatchEvent(new CustomEvent("customModelChanged"));else{let e=await a.json();(0,E.s)(e.error||"Failed to add custom model")}}catch(e){(0,E.s)("Error adding custom model:",e)}},tH=async(e,t="llm",s=t$)=>{try{let a=new URLSearchParams({providerAlias:s,id:e,type:t});(await fetch(`/api/models/custom?${a}`,{method:"DELETE"})).ok&&(await tP(),window.dispatchEvent(new CustomEvent("customModelChanged")))}catch(e){(0,E.s)("Error deleting custom model:",e)}},tW=async()=>{if(eX)return;let e=h.find(e=>g.includes(e.id)&&!1!==e.isActive)||h.find(e=>!1!==e.isActive);if(!e)return void(0,E.s)((0,w.Tl)("Add an active connection first"));eY(!0),e1("");try{let t=await fetch(`/api/providers/${e.id}/models`),s=await t.json().catch(()=>({}));if(!t.ok)return void(0,E.s)(s.error||(0,w.Tl)("Failed to fetch models"));let a=s.models||[];if(0===a.length)return void(0,E.s)(s.warning||(0,w.Tl)("No models returned"));let i=new Set;try{let t=await fetch(`/api/providers/${e.id}/model-probes`,{cache:"no-store"});for(let e of(await t.json().catch(()=>({}))).probes||[])"dead"===e.status&&i.add(e.modelId)}catch{}let r=0,n=new Set(th.map(e=>e.id)),l=[],o=[],d=new Set;for(let e of a){let t=function(e,t){if(null==e)return null;if("string"==typeof e){let s=$(e,t);return s?{id:s,name:s,type:S(s)}:null}let s=e.id||e.name||e.model||e.slug;if(!s)return null;let a=$(s,t);if(!a)return null;let i=e.display_name||e.displayName||e.name||e.title||a;return{id:a,name:String(i),type:S(a,e)}}(e,t$);if(!t)continue;let{id:s,name:a,type:c}=t;if(i.has(K(s,t$))){r+=1;continue}let m=`${c}|${s}`;if(d.has(m))continue;if(d.add(m),n.has(s)){eR.includes(s)&&o.push(s);continue}if(en.some(e=>e.providerAlias===t$&&e.id===s&&(e.kind||e.type||"llm")===c))continue;let p=`${t$}/${s}`;Object.values(ei).includes(p)||l.push({providerAlias:t$,id:s,type:c,name:a})}let c=0;if(o.length>0)try{for(let e of o)(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(t$)}&id=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&(c+=1);await tT()}catch{}let m=0;if(l.length>0){let e=await fetch("/api/models/custom",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({models:l})}),t=await e.json().catch(()=>({}));if(!e.ok)return void(0,E.s)(t.error||(0,w.Tl)("Failed to save models"));m=t.added??l.length,await tP(),window.dispatchEvent(new CustomEvent("customModelChanged"))}let p=l.filter(e=>"llm"!==e.type).length,u=[];if(m>0&&u.push(`${m} new`),c>0&&u.push(`${c} re-enabled`),0===u.length)e1((0,w.Tl)("All models already in list"));else{let e=`Imported ${u.join(" \xb7 ")} (${a.length} from provider)`;p>0&&(e+=" \xb7 non-chat types stored for media pages"),s.warning&&(e+=` \xb7 ${s.warning}`),e1(e)}if(r>0&&e1(e=>`${e} \xb7 ${r} skipped (known dead)`),m>0||c>0)try{let t=[...th,...l.map(e=>({id:e.id,name:e.name,kind:e.type}))],s=await fetch(`/api/providers/${e.id}/model-probes/verify/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({models:t,providerAlias:t$})}),a=await s.json().catch(()=>({}));if(!s.ok)throw Error(a.error||"Failed to start auto-verify");e4(a&&a.status?a:null),tL(e.id)}catch(e){e1(t=>`${t} \xb7 auto-verify failed: ${e?.message||e}`)}}catch(e){(0,E.s)("Error importing models:",e),(0,E.s)((0,w.Tl)("Error fetching models")+": "+(e?.message||e))}finally{eY(!1)}},tV=async()=>{if(eU||0===h.length)return;let e=Object.fromEntries(h.map(e=>[e.id,{state:"queued",error:null}]));eV.current=!1,eq(!0),eF(!1),eJ(null),eB(e),eW({total:h.length,completed:0,passed:0,failed:0,stopped:!1});let t=0,s=0;try{for(let e=0;e<h.length;e+=1){if(eV.current){eW({total:h.length,completed:e,passed:t,failed:s,stopped:!0});break}let a=h[e];eJ(a.id),eB(e=>({...e,[a.id]:{state:"testing",error:null}}));try{let e=await fetch(`/api/providers/${a.id}/test`,{method:"POST"}),i=await e.json(),r=!!i.valid;r?t+=1:s+=1,eB(e=>({...e,[a.id]:{state:r?"success":"failed",error:r?null:i.error||null}}))}catch(e){s+=1,eB(t=>({...t,[a.id]:{state:"failed",error:e.message||"Test failed"}}))}eW({total:h.length,completed:e+1,passed:t,failed:s,stopped:!1}),e<h.length-1&&await new Promise(e=>setTimeout(e,1e3))}}finally{eJ(null),eq(!1),eF(!1),eV.current=!1}},tG=async e=>{let t=h.find(t=>t.id===e),s=t?.name?.trim()||t?.email?.trim()||e;eP({title:"Delete Connection",message:`Delete connection “${s}”?`,onConfirm:async()=>{eP(null);try{(await fetch(`/api/providers/${e}`,{method:"DELETE"})).ok&&f(t=>t.filter(t=>t.id!==e))}catch(e){(0,E.s)("Error deleting connection:",e)}}})},tQ=()=>{tM(),P(!1)},tZ=async e=>{G("");try{let t=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:u,...e})}),s=null;try{s=await t.json()}catch{s=null}if(t.ok){await tM(),W(!1);return}G(s?.error||"Failed to save connection")}catch(e){(0,E.s)("Error saving connection:",e),G("Failed to save connection")}},tX=async e=>{try{(await fetch(`/api/providers/${es.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok&&(await tM(),Y(!1))}catch(e){(0,E.s)("Error updating connection:",e)}},tY=async(e,t)=>{try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&f(s=>s.map(s=>s.id===e?{...s,isActive:t}:s))}catch(e){(0,E.s)("Error updating connection status:",e)}},t0=async e=>{let t,s=e?.providerSpecificData?.baseUrl;if(s){try{t=new URL(s).hostname.toLowerCase().replace(/^\[|\]$/g,"")}catch{(0,E.s)("Cannot allow-list: invalid base URL",s);return}try{let e=await fetch("/api/settings",{cache:"no-store"});if(!e.ok)throw Error(`Failed to load settings (${e.status})`);let s=await e.json(),a=[...new Set([...s.ssrfAllowHosts||[],t])],i=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({ssrfAllowHosts:a})});if(!i.ok)throw Error(`Failed to update allow list (${i.status})`);await tM()}catch(e){(0,E.s)("Error adding host to allow list:",e)}}},t1=async(e,t)=>{let s=[...h];[s[e],s[t]]=[s[t],s[e]],f(s);try{await Promise.all([fetch(`/api/providers/${s[e].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:e})}),fetch(`/api/providers/${s[t].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:t})})])}catch(e){(0,E.s)("Error swapping priority:",e),await tM()}},t2=h.length>0&&g.length===h.length,t5=(0,a.jsx)("div",{className:"flex min-w-0 flex-col divide-y divide-black/[0.03] dark:divide-white/[0.03]",children:h.map((e,t)=>(0,a.jsxs)("div",{className:"flex min-w-0 items-stretch",children:[(0,a.jsx)("div",{className:"flex shrink-0 items-center pl-1 sm:pl-2",children:(0,a.jsx)("input",{type:"checkbox",checked:g.includes(e.id),onChange:()=>{var t;return t=e.id,void y(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])},className:"h-4 w-4 rounded border-gray-300 text-primary focus:ring-primary"})}),(0,a.jsx)("div",{className:"flex-1 min-w-0",children:(0,a.jsx)(M,{connection:e,isOAuth:tm,isFirst:0===t,isLast:t===h.length-1,onMoveUp:()=>t1(t,t-1),onMoveDown:()=>t1(t,t+1),onToggleActive:t=>tY(e.id,t),autoPing:B[u]&&"oauth"===e.authType?{on:!0===eN.connections[e.id],onToggle:t=>{var s;return s=e.id,void tF({...eN,connections:{...eN.connections,[s]:t}})},provider:u}:null,onEdit:()=>{ea(e),Y(!0)},onDelete:()=>tG(e.id),onAllowlistHost:()=>t0(e),oneByOneStatus:eK[e.id]||null})})]},e.id))}),t3=async e=>{if(!ex.has(e)){eh(t=>new Set(t).add(e));try{let t=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${t$}/${e}`})}),s=await t.json();em(t=>({...t,[e]:s.ok?"ok":"error"})),eu(s.ok?"":s.error||"Model not reachable")}catch{em(t=>({...t,[e]:"error"})),eu("Network error")}finally{eh(t=>{let s=new Set(t);return s.delete(e),s})}}};return k?(0,a.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,a.jsx)(d.Qv,{}),(0,a.jsx)(d.Qv,{})]}):td?(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:gap-8 sm:px-0",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)(l(),{href:"/dashboard/providers",className:"inline-flex items-center gap-1 text-sm text-text-muted hover:text-primary transition-colors mb-4",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-lg",children:"arrow_back"}),"Back to Providers"]}),(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3 sm:gap-4",children:[(0,a.jsx)("div",{className:"flex size-12 shrink-0 items-center justify-center rounded-lg",style:{backgroundColor:`${td.color}15`},children:eo?(0,a.jsx)("span",{className:"text-sm font-bold",style:{color:td.color},children:td.textIcon||td.id.slice(0,2).toUpperCase()}):(0,a.jsx)(o.default,{src:tg&&td.apiType?"responses"===td.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":ty?"/providers/anthropic-m.png":`/providers/${td.id}.png`,alt:td.name,width:48,height:48,className:"max-h-12 max-w-12 rounded-lg object-contain",sizes:"48px",onError:()=>ed(!0)})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 flex-wrap",children:[(0,a.jsx)("h1",{className:"truncate text-2xl font-semibold tracking-tight sm:text-3xl",children:td.name}),(td.notice?.apiKeyUrl||td.notice?.signupUrl||td.website)&&(0,a.jsxs)("a",{href:td.notice?.apiKeyUrl||td.notice?.signupUrl||td.website,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline inline-flex items-center gap-1",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"open_in_new"}),td.notice?.apiKeyUrl?"Get API Key":"Sign up / Learn more"]})]}),(0,a.jsxs)("p",{className:"text-text-muted",children:[h.length," connection",1===h.length?"":"s"]})]})]})]}),td.deprecated&&(0,a.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px] text-yellow-500 mt-0.5 shrink-0",children:"warning"}),(0,a.jsx)("p",{className:"text-xs text-red-600 dark:text-yellow-400 leading-relaxed",children:td.deprecationNotice})]}),td.notice?.text&&!td.deprecated&&(0,a.jsxs)("div",{className:"flex flex-col gap-2 rounded-lg border border-blue-500/30 bg-blue-500/10 px-3 py-2 sm:flex-row sm:items-center",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px] text-blue-500 shrink-0",children:"info"}),(0,a.jsx)("p",{className:"min-w-0 flex-1 text-xs leading-relaxed text-blue-600 dark:text-blue-400",children:td.notice.text}),td.notice.apiKeyUrl&&(0,a.jsx)("a",{href:td.notice.apiKeyUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex justify-center rounded bg-blue-500 px-2 py-1 text-xs font-medium text-white transition-colors hover:bg-blue-600 sm:py-0.5",children:"Get API Key →"})]}),tb&&T&&(0,a.jsx)(d.Zp,{children:(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:ty?"Anthropic Compatible Details":"OpenAI Compatible Details"}),(0,a.jsxs)("p",{className:"break-all text-sm text-text-muted",children:[ty?"Messages API":"responses"===T.apiType?"Responses API":"Chat Completions"," \xb7 ",(T.baseUrl||"").replace(/\/$/,""),"/",ty?"messages":"responses"===T.apiType?"responses":"chat/completions"]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:()=>{G(""),W(!0)},className:"w-full sm:w-auto",children:"Add API Key"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"edit",onClick:()=>et(!0),className:"w-full sm:w-auto",children:"Edit"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"delete",onClick:async()=>{eP({title:"Delete Compatible Node",message:`Delete this ${ty?"Anthropic":"OpenAI"} Compatible node?`,onConfirm:async()=>{eP(null);try{(await fetch(`/api/provider-nodes/${u}`,{method:"DELETE"})).ok&&p.push("/dashboard/providers")}catch(e){(0,E.s)("Error deleting provider node:",e)}}})},className:"w-full sm:w-auto",children:"Delete"})]})]})}),tu?(0,a.jsx)(d.gw,{providerId:u}):(0,a.jsxs)(d.Zp,{children:[(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Connections"}),(0,a.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:gap-4",children:[h.length>0&&(0,a.jsxs)(a.Fragment,{children:[g.length>0&&(0,a.jsxs)(d.$n,{size:"sm",variant:"danger",icon:"delete",onClick:()=>{let e=g.length;0!==e&&eP({title:`Delete ${e} Connection${e>1?"s":""}`,message:`Delete ${e} connection${e>1?"s":""}? This cannot be undone.`,onConfirm:async()=>{eP(null);let e=0,t=[...g];for(let s of t)try{(await fetch(`/api/providers/${s}`,{method:"DELETE"})).ok||(e+=1)}catch(t){(0,E.s)("Error deleting connection:",t),e+=1}f(e=>e.filter(e=>!t.includes(e.id))),y([]),e>0&&(0,E.s)(`Deleted ${t.length-e} connection(s), ${e} failed.`)}})},children:["Delete Selected (",g.length,")"]}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"sync",onClick:tV,disabled:eU,children:eU?"Testing Connection One-by-One...":"Test Connection One-by-One"}),eU&&(0,a.jsx)(d.$n,{size:"sm",variant:"ghost",icon:"stop",onClick:()=>{eU&&(eV.current=!0,eF(!0))},disabled:e_,children:e_?"Stopping...":"Stop"})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,a.jsx)("span",{className:"text-xs text-text-muted font-medium",children:"Round Robin"}),(0,a.jsx)(d.lM,{checked:"round-robin"===ey,onChange:e=>{let t=e?"round-robin":null,s=e?ev||"1":ev;e&&!ev&&ej("1"),eb(t),tq(t,s)}}),"round-robin"===ey&&(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"text-xs text-text-muted",children:"Sticky:"}),(0,a.jsx)("input",{type:"number",min:1,value:ev,onChange:e=>{var t;ej(t=e.target.value),tq("round-robin",t)},placeholder:"1",className:"w-14 px-2 py-1 text-xs border border-border rounded-md bg-background focus:outline-none focus:border-primary"})]})]})]})]}),0===h.length?(0,a.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"inline-flex items-center justify-center w-9 h-9 rounded-full bg-primary/10 text-primary shrink-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:tm?"lock":"key"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"No connections yet"}),tw&&(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["Choose ",tk," or ",tN,"."]})]})]}),(0,a.jsx)("div",{className:"flex gap-2",children:tw?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.$n,{size:"sm",icon:"lock",variant:"secondary",onClick:tn,children:tk}),(0,a.jsx)(d.$n,{size:"sm",icon:"key",onClick:tl,children:tN})]}):(0,a.jsxs)(a.Fragment,{children:[!tb&&"iflow"===u&&(0,a.jsx)(d.$n,{size:"sm",icon:"cookie",variant:"secondary",onClick:()=>F(!0),children:"Cookie"}),"codex"===u&&(0,a.jsx)(d.$n,{size:"sm",icon:"playlist_add",variant:"secondary",onClick:()=>Z(!0),children:(0,w.Tl)("Bulk Add")}),(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:to,children:tb?"Add API Key":"iflow"===u?"OAuth":"Add Connection"})]})})]}):(0,a.jsxs)(a.Fragment,{children:[eH&&(0,a.jsx)("div",{className:"mb-4 rounded-lg border border-black/10 bg-black/[0.02] px-3 py-2 text-xs text-text-muted dark:border-white/10 dark:bg-white/[0.03]",children:(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,a.jsxs)("span",{children:["Total: ",eH.total]}),(0,a.jsxs)("span",{children:["Completed: ",eH.completed]}),(0,a.jsxs)("span",{children:["Passed: ",eH.passed]}),(0,a.jsxs)("span",{children:["Failed: ",eH.failed]}),eH.stopped&&(0,a.jsx)("span",{className:"text-amber-600 dark:text-amber-400",children:"Stopped"}),eU&&eL&&(0,a.jsxs)("span",{children:["Running: ",h.find(e=>e.id===eL)?.name||eL]})]})}),h.length>0&&(0,a.jsx)("div",{className:"mb-3 flex items-center gap-2 border-b border-black/[0.03] pb-2 dark:border-white/[0.03]",children:(0,a.jsxs)("label",{className:"flex cursor-pointer items-center gap-1.5 text-xs text-text-muted hover:text-primary",children:[(0,a.jsx)("input",{type:"checkbox",checked:t2,onChange:()=>{t2?y([]):y(h.map(e=>e.id))},className:"h-3.5 w-3.5 rounded border-gray-300 text-primary focus:ring-primary"}),"Select All"]})}),t5,!tb&&(0,a.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-2 sm:flex",children:["iflow"===u&&(0,a.jsx)(d.$n,{size:"sm",icon:"cookie",variant:"secondary",onClick:()=>F(!0),title:"Add connection using browser cookie",className:"w-full sm:w-auto",children:"Cookie"}),"codex"===u&&(0,a.jsx)(d.$n,{size:"sm",icon:"playlist_add",variant:"secondary",onClick:()=>Z(!0),title:(0,w.Tl)("Bulk import codex accounts from JSON"),className:"w-full sm:w-auto",children:(0,w.Tl)("Bulk Add")}),tw?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.$n,{size:"sm",icon:"lock",variant:"secondary",onClick:tn,className:"w-full sm:w-auto",children:tk}),(0,a.jsx)(d.$n,{size:"sm",icon:"key",onClick:tl,className:"w-full sm:w-auto",children:tN})]}):(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:to,className:"w-full sm:w-auto",children:"Add"})]})]})]}),(0,a.jsxs)(d.Zp,{children:[(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Available Models"}),tS&&(0,a.jsx)("select",{value:ew,onChange:e=>{var t;ek(t=e.target.value),t_(t)},title:"Appends (level) suffix to copied model names",className:"rounded-md border border-border bg-background px-2 py-1 text-xs focus:border-primary focus:outline-none",children:tS.map(e=>(0,a.jsx)("option",{value:e,children:`Thinking: ${e.charAt(0).toUpperCase()+e.slice(1)}`},e))})]}),tj.showToolbar&&(e=(tj.showBulkControls?[...th,...eO.filter(e=>!th.some(t=>t.id===e.id))].filter(e=>{let t=(0,m.CP)(e);return!t||"llm"===t}).map(e=>e.id):[]).filter(e=>!eR.includes(e)),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[tj.showImport&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:eX?"progress_activity":"cloud_download",onClick:tW,disabled:eX||!tv,title:tv?"Import models from the active connection":"Add an active connection to import models",children:eX?"Importing...":"Import models"}),tj.showVerify&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:e3?.status==="running"?"progress_activity":"science",onClick:()=>e5(e=>!e),children:e3?.status==="running"?`Verifying ${e3.done}/${e3.total}`:e2?"Hide verify":"Verify models"}),tj.showBulkControls&&eR.length>0&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"restart_alt",onClick:tD,children:"Active All"}),tj.showBulkControls&&e.length>0&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"block",onClick:()=>tR(e),children:"Disable All"})]}))]}),!!ep&&(0,a.jsx)("p",{className:"text-xs text-red-500 mb-3 break-words",children:ep}),e0&&(0,a.jsx)("p",{className:"text-xs text-text-muted mb-3",children:e0}),e2&&(t=h.find(e=>g.includes(e.id)&&!1!==e.isActive)||h.find(e=>!1!==e.isActive),s=[...(0,C.R3)({customModels:en,modelAliases:ei,providerAlias:t$,builtInModels:th,type:"llm"}).map(e=>({id:e.id,name:e.name||e.id,kind:"llm"})),...th.filter(e=>{let t=(0,m.CP)(e);return(!t||"llm"===t)&&!eR.includes(e.id)}).map(e=>({id:e.id,name:e.name||e.id,kind:"llm"}))],(0,a.jsx)(J,{connectionId:t?.id,providerAlias:t$,models:s,jobSnapshot:e3,onClose:()=>e5(!1),onStarted:e=>{e4(e&&e.status?e:null);let s=e?.connectionId||t?.id;s&&tL(s)},onComplete:async e=>{e?.removed>0&&await tP(),(e?.removed>0||e?.cacheCleared)&&await tz(t?.id)}})),(()=>{let e,t,s;if(tb)return(0,a.jsx)(D,{providerStorageAlias:t$,providerDisplayAlias:tA,modelAliases:ei,customModels:en,copied:ts,onCopy:ta,onSetAlias:tJ,onDeleteAlias:tK,onAddCustomModel:e=>tB(e,"llm",t$),onDeleteCustomModel:e=>tH(e,"llm",t$),onRefreshModels:tP,connections:h,isAnthropic:ty});let i=[...th,...eO.filter(e=>!th.some(t=>t.id===e.id))].filter(e=>{let t=(0,m.CP)(e);return!t||"llm"===t}),r=new Set(eR),n=i.filter(e=>!r.has(e.id)),l=i.filter(e=>r.has(e.id)),o=(0,C.R3)({customModels:en,modelAliases:ei,providerAlias:t$,builtInModels:th,type:"llm"}),d=o.filter(e=>"all"===te||(e8[K(e.id,t$)]||null)===te),c=n.filter(e=>"all"===te||(e8[K(e.id,t$)]||null)===te);return(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsx)("div",{className:"mb-2 flex gap-1 text-xs",children:["all","ok","dead","retry"].map(e=>(0,a.jsx)("button",{onClick:()=>tt(e),className:`rounded px-2 py-0.5 ${te===e?"bg-primary text-white":"text-text-muted hover:bg-black/5 dark:hover:bg-white/5"}`,children:"all"===e?"All":"ok"===e?"OK":"dead"===e?"Dead":"Retry"},e))}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-3",children:[d.map(e=>{let t=K(e.id,t$);return(0,a.jsx)(O,{model:{id:e.id,name:e.name},fullModel:`${tA}/${e.id}`,alias:e.alias,copied:ts,onCopy:ta,onSetAlias:()=>{},onDeleteAlias:()=>{"custom"===e.source?tH(e.id,"llm",t$):tK(e.alias)},testStatus:ec[e.id],onTest:h.length>0||tu?()=>t3(e.id):void 0,isTesting:ex.has(e.id),isCustom:!0,isFree:!1,caps:x(`${u}/${e.id}`),thinkingSuffix:tC(e.id),latencyMs:e6[e.id]??e6[t],probeState:e3?.status==="running"&&e3?.perModel?.[t]?e3.perModel[t]:e8[t]||null},`${e.source}-${e.fullModel}`)}),c.map(e=>{let t=`${t$}/${e.id}`,s=`${u}/${e.id}`,i=Object.entries(ei).find(([,e])=>e===t||e===s)?.[0],r=K(e.id,t$);return(0,a.jsx)(O,{model:e,fullModel:`${tA}/${e.id}`,alias:i,copied:ts,onSetAlias:t=>tJ(e.id,t,t$),onCopy:ta,onDeleteAlias:()=>tK(i),testStatus:ec[e.id],onTest:h.length>0||tu?()=>t3(e.id):void 0,isTesting:ex.has(e.id),isFree:e.isFree,onDisable:()=>tO(e.id),caps:x(`${u}/${e.id}`),thinkingSuffix:tC(e.id),latencyMs:e6[e.id]??e6[r],probeState:e3?.status==="running"&&e3?.perModel?.[r]?e3.perModel[r]:e8[r]||null},e.id)}),(0,a.jsxs)("button",{onClick:()=>eg(!0),className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-primary/40 px-3 py-2 text-xs text-primary transition-colors hover:border-primary hover:bg-primary/5 sm:w-auto",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"add"}),"Add Model"]}),eS.length>0&&(e=new Set([...Object.values(ei),...o.map(e=>e.fullModel)]),t=new Set(th.map(e=>e.id)),0===(s=eS.filter(s=>!e.has(`${t$}/${s.id}`)&&!t.has(s.id))).length?null:(0,a.jsxs)("div",{className:"w-full mt-2",children:[(0,a.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"Suggested free models (≥200k context):"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:s.map(e=>(0,a.jsxs)("button",{onClick:async()=>{await tB(e.id,"llm",t$)},className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg border border-black/10 dark:border-white/10 text-xs text-text-muted hover:text-primary hover:border-primary/40 hover:bg-primary/5 transition-colors",title:`${e.name} \xb7 ${(e.contextLength/1e3).toFixed(0)}k ctx`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"add"}),e.id.split("/").pop()]},e.id))})]})),l.length>0&&(0,a.jsxs)("div",{className:"w-full mt-2",children:[(0,a.jsxs)("p",{className:"text-xs text-text-muted mb-2",children:["Disabled models (",l.length,"):"]}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:l.map(e=>(0,a.jsxs)("button",{onClick:()=>tE(e.id),className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg border border-dashed border-black/10 dark:border-white/10 text-xs text-text-muted hover:text-primary hover:border-primary/40 hover:bg-primary/5 transition-colors",title:"Restore model",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"add"}),e.id]},e.id))})]})]})]})})()]}),"kiro"===u?(0,a.jsx)(d.Mh,{isOpen:I,providerInfo:td,onSuccess:tQ,onClose:()=>P(!1)}):"cursor"===u?(0,a.jsx)(d.G9,{isOpen:I,onSuccess:tQ,onClose:()=>P(!1)}):"gitlab"===u?(0,a.jsx)(d.vj,{isOpen:I,providerInfo:td,onSuccess:tQ,onClose:()=>P(!1)}):(0,a.jsx)(d.LF,{isOpen:I,provider:u,providerInfo:td,onSuccess:tQ,onClose:()=>P(!1)}),"iflow"===u&&(0,a.jsx)(d.vE,{isOpen:z,onSuccess:()=>{tM(),F(!1)},onClose:()=>F(!1)}),(0,a.jsx)(U,{isOpen:H,provider:u,providerName:td.name,isCompatible:tb,isAnthropic:ty,authType:td?.authType,authHint:td?.authHint,website:td?.website,error:V,onSave:tZ,onBulkDone:tM,onClose:()=>{G(""),W(!1)}}),(0,a.jsx)(d.wI,{isOpen:X,connection:es,onSave:tX,onClose:()=>Y(!1)}),tb&&(0,a.jsx)(q,{isOpen:ee,node:T,onSave:tU,onClose:()=>et(!1),isAnthropic:ty}),!tb&&(0,a.jsx)(_,{isOpen:ef,providerAlias:t$,providerDisplayAlias:tA,onSave:async e=>{await tB(e,"llm",t$),eg(!1)},onClose:()=>eg(!1)}),"codex"===u&&(0,a.jsx)(L,{isOpen:Q,onClose:()=>Z(!1),onSuccess:tM}),(0,a.jsx)(d.uo,{isOpen:eM,onClose:()=>ez(!1),onConfirm:()=>{(window.localStorage.setItem(ti,"true"),ez(!1),tm)?tr():tl()},title:"Risk Notice",message:td?.deprecationNotice,confirmText:"I Understand, Continue",cancelText:"Cancel",variant:"danger"}),(0,a.jsx)(d.uo,{isOpen:!!eI,onClose:()=>eP(null),onConfirm:eI?.onConfirm,title:eI?.title||"Confirm",message:eI?.message,variant:"danger"})]}):(0,a.jsxs)("div",{className:"text-center py-20",children:[(0,a.jsx)("p",{className:"text-text-muted",children:"Provider not found"}),(0,a.jsx)(l(),{href:"/dashboard/providers",className:"text-primary mt-4 inline-block",children:"Back to Providers"})]})}},7687:(e,t,s)=>{Promise.resolve().then(s.bind(s,4003))},70217:(e,t,s)=>{"use strict";function a(e,t){return!1===e?"default":"active"===t||"success"===t?"success":"error"===t||"expired"===t||"unavailable"===t?"error":"default"}s.d(t,{g:()=>a})}},e=>{e.O(0,[2574,3862,782,8500,594,1321,7592,5497,8441,3794,7358],()=>e(e.s=7687)),_N_E=e.O()}]);
package/app/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "switchboard-app",
3
- "version": "0.6.13",
3
+ "version": "0.6.15",
4
4
  "description": "Switchboard — intelligent model routing dashboard",
5
5
  "private": true,
6
6
  "scripts": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "switchboard-router",
3
- "version": "0.6.13",
3
+ "version": "0.6.15",
4
4
  "description": "Switchboard CLI — local AI routing gateway (install: npm i -g switchboard-router; run: switchboard)",
5
5
  "bin": {
6
6
  "switchboard": "./cli.js"
@@ -1 +0,0 @@
1
- "use strict";exports.id=4192,exports.ids=[4192],exports.modules={40694:(a,b,c)=>{c.d(b,{P:()=>e});var d=c(7866);async function e(a,b={}){let c=!!a?.apiKey,f=c?a.apiKey:a?.accessToken;if(!f)return null;let g=new AbortController,h=setTimeout(()=>g.abort(),5e3);b.signal&&"function"!=typeof AbortSignal.any&&b.signal.addEventListener("abort",()=>{clearTimeout(h),g.abort(b.signal.reason)},{once:!0});let i=b.signal&&"function"==typeof AbortSignal.any?AbortSignal.any([b.signal,g.signal]):g.signal;try{let a=c?{Accept:"application/json",Authorization:`Bearer ${f}`}:(0,d.w$)(f,{Accept:"application/json"}),b=await fetch("https://api.cline.bot/api/v1/models",{method:"GET",headers:a,signal:i});if(!b.ok)return null;let e=await b.json(),g=Array.isArray(e)?e:e?.data;if(!Array.isArray(g))return null;let h=g.filter(a=>"string"==typeof a?.id&&a.id.startsWith("cline-pass/")).map(a=>({id:a.id,name:a.name||a.id}));return h.length?{models:h}:null}catch{return null}finally{clearTimeout(h)}}},47293:(a,b,c)=>{c.d(b,{A:()=>f});let d=new Uint8Array(16);var e=c(50122);let f=function(a,b,c){return b||a||!crypto.randomUUID?function(a,b,c){let f=(a=a||{}).random??a.rng?.()??crypto.getRandomValues(d);if(f.length<16)throw Error("Random bytes length must be >= 16");if(f[6]=15&f[6]|64,f[8]=63&f[8]|128,b){if((c=c||0)<0||c+16>b.length)throw RangeError(`UUID byte range ${c}:${c+15} is out of buffer bounds`);for(let a=0;a<16;++a)b[c+a]=f[a];return b}return(0,e.k)(f)}(a,b,c):crypto.randomUUID()}},50122:(a,b,c)=>{c.d(b,{k:()=>e});let d=[];for(let a=0;a<256;++a)d.push((a+256).toString(16).slice(1));function e(a,b=0){return(d[a[b+0]]+d[a[b+1]]+d[a[b+2]]+d[a[b+3]]+"-"+d[a[b+4]]+d[a[b+5]]+"-"+d[a[b+6]]+d[a[b+7]]+"-"+d[a[b+8]]+d[a[b+9]]+"-"+d[a[b+10]]+d[a[b+11]]+d[a[b+12]]+d[a[b+13]]+d[a[b+14]]+d[a[b+15]]).toLowerCase()}},58255:(a,b,c)=>{c.d(b,{Mz:()=>k});var d=c(67141),e=c(29790),f=c(33026);let g=new Map,h=new Map;function i(a){let b=[],c=new Set;for(let d of Array.isArray(a)?a:[]){let a="string"==typeof d?d.trim():d&&"object"==typeof d?String(d.id||d.slug||d.model||d.name||"").trim():"";if(!(!a||c.has(a))){if(c.add(a),"string"==typeof d){b.push({id:a,name:a});continue}b.push({...d,id:a,name:d.display_name||d.displayName||d.name||a})}}return b}async function j(a,b,c,d){let g=new AbortController,h=setTimeout(()=>g.abort(),1e4),j=d.signal&&"function"==typeof AbortSignal.any?AbortSignal.any([d.signal,g.signal]):d.signal||g.signal;try{var k;let d=await fetch(c.url,{method:c.method,headers:function(a,b,c){let d=b?.providerSpecificData?.copilotToken||b?.providerSpecificData?.apiKey||b?.accessToken||b?.apiKey||null;if("cursor-protobuf"===c)return d?(0,e.JA)(d,b?.providerSpecificData?.machineId,b?.providerSpecificData?.ghostMode!==!1):{"Content-Type":"application/connect+proto"};let f={...a?.transport?.headers||{},"Content-Type":"application/json"};return d&&(a?.transport?.format==="claude"&&(f["x-api-key"]=d),f.Authorization=`Bearer ${d}`),f}(b,a,c.type),...void 0!==c.body?{body:c.body}:{},cache:"no-store",redirect:"error",signal:j});if(!d.ok){try{await d.body?.cancel?.()}catch{}return null}if("cursor-protobuf"===c.type)return function(a){let b=[],c=0;for(;c<a.length;){let d=(0,f.yX)(a.slice(c));if(!d)break;for(let a of(c+=d.consumed,(0,f.Y8)(d.payload).get(3)||[])){if(2!==a.wireType)continue;let c=Buffer.from(a.value).toString("utf8").trim();c&&/^[a-z0-9][a-z0-9._:/+~-]{1,}$/i.test(c)&&b.push(c)}}return i(b)}(Buffer.from(await d.arrayBuffer()));return i((k=await d.json(),Array.isArray(k)?k:k?.data||k?.models||k?.results||[]))}finally{clearTimeout(h)}}async function k(a,b={}){var c;let e,f=(c=a?.provider,d.A.find(a=>a.id===c)),i=function(a){let b=a?.modelsFetcher;if(b?.url)return{url:b.url,method:b.method||"GET",type:b.type||"openai",body:b.body};if(a?.id==="cursor"&&a.oauth?.apiEndpoint&&a.oauth?.modelsEndpoint)return{url:`${a.oauth.apiEndpoint.replace(/\/$/,"")}${a.oauth.modelsEndpoint}`,method:"POST",type:"cursor-protobuf",body:new Uint8Array([0,0,0,0,0])};try{let b=function(a){let b;if("string"!=typeof a||!a.trim())return null;try{b=new URL(a)}catch{return null}let c=b.pathname.replace(/\/$/,"");return c.endsWith("/models")||(c.endsWith("/chat/completions")?b.pathname=c.slice(0,-17)+"/models":c.endsWith("/messages")?b.pathname=c.slice(0,-9)+"/models":c.endsWith("/responses")?b.pathname=c.slice(0,-10)+"/models":c.endsWith("/api/chat")?b.pathname=c.slice(0,-9)+"/api/tags":b.pathname=`${c}/models`),b.toString()}(a?.transport?.baseUrl);return b?{url:b,method:"GET",type:"openai"}:null}catch{return null}}(f);if(!f||!i)return null;let l=a?.id||null,m=Date.now();if(l&&!b.forceRefresh){let a=g.get(l);if(a&&a.expiresAt>m)return g.delete(l),g.set(l,a),{models:a.models};if(a&&g.delete(l),h.has(l))return h.get(l)}return e=j(a,f,i,b).then(a=>{if(!a?.length)return null;if(l)for(g.delete(l),g.set(l,{expiresAt:Date.now()+3e5,models:a});g.size>256;)g.delete(g.keys().next().value);return{models:a}}).catch(()=>null).finally(()=>{h.get(l)===e&&h.delete(l)}),l&&h.set(l,e),e}},58569:(a,b,c)=>{c.d(b,{cW:()=>m});var d=c(47293),e=c(55511),f=c(41029),g=c(57034);let h="1.0.0",i="0.10.32",j="us-east-1",k=new Map;async function l(a,b){let c,f,k,l=a?.providerSpecificData?.profileArn||"",m=function(a){if(!a||"string"!=typeof a)return j;let b=a.split(":");return b.length>=4&&b[3]?(0,g.l6)(b[3],j):j}(l),n=new URLSearchParams;n.set("origin","AI_EDITOR"),l&&n.set("profileArn",l);let o=`https://q.${m}.amazonaws.com/ListAvailableModels?${n.toString()}`,p={...(f=a?.providerSpecificData?.clientId||a?.refreshToken||a?.providerSpecificData?.profileArn||a?.accessToken||"kiro-anonymous",k=(0,e.createHash)("sha256").update(String(f)).digest("hex"),{"User-Agent":`aws-sdk-js/${h} ua/2.1 os/windows#10.0.26200 lang/js md/nodejs#22.21.1 api/codewhispererruntime#${h} m/N,E KiroIDE-${i}-${k}`,"x-amz-user-agent":`aws-sdk-js/${h} KiroIDE-${i}-${k}`,"x-amzn-kiro-agent-mode":"vibe","x-amzn-codewhisperer-optout":"true","amz-sdk-request":"attempt=1; max=1","amz-sdk-invocation-id":(0,d.A)(),Accept:"application/json"}),Authorization:`Bearer ${a?.accessToken||""}`},q=new AbortController,r=setTimeout(()=>q.abort("timeout"),3e4);b&&"function"==typeof b.addEventListener&&b.addEventListener("abort",()=>q.abort(b.reason));try{c=await fetch(o,{method:"GET",headers:p,signal:q.signal})}finally{clearTimeout(r)}if(!c.ok){let a=await c.text().catch(()=>""),b=Error(`Kiro ListAvailableModels ${c.status}: ${a||c.statusText}`);throw b.status=c.status,b.body=a,b}let s=await c.json();return Array.isArray(s?.models)?s.models:[]}async function m(a,b={}){let c,d,g;if(!a||!a.accessToken)return b.log?.debug?.("KIRO_MODELS","No accessToken; skipping live fetch"),null;let h=(g=(d=a?.providerSpecificData||{}).profileArn||d.clientId||a?.refreshToken||a?.accessToken||"anonymous",(0,e.createHash)("sha256").update(`kiro:${g}`).digest("hex")),i=Date.now();if(!b.forceRefresh){let a=k.get(h);if(a&&a.expiresAt>i)return{models:a.models,rawModels:a.rawModels}}try{c=await l(a,b.signal)}catch(d){if(!d||401!==d.status||!a.refreshToken)return b.log?.warn?.("KIRO_MODELS",`ListAvailableModels failed: ${d?.message||d}`),null;{b.log?.info?.("KIRO_MODELS","Got 401 from Kiro; refreshing token");let d=await (0,f.Ql)(a.refreshToken,a.providerSpecificData,b.log);if(!d?.accessToken)return b.log?.warn?.("KIRO_MODELS","Token refresh did not return accessToken"),null;{let e={...a,...d};if("function"==typeof b.onCredentialsRefreshed)try{await b.onCredentialsRefreshed(d)}catch(a){b.log?.warn?.("KIRO_MODELS",`onCredentialsRefreshed failed: ${a?.message||a}`)}try{c=await l(e,b.signal),a.accessToken=e.accessToken,e.refreshToken&&(a.refreshToken=e.refreshToken)}catch(a){return b.log?.warn?.("KIRO_MODELS",`Retry after refresh failed: ${a?.message||a}`),null}}}}let j=[];for(let a of c){if(!a||"object"!=typeof a)continue;let b=a.modelId||a.id;if(!b)continue;let c=function(a,b,c){let d=(a||b||"Kiro").trim(),e=Number(c);if(!Number.isFinite(e)||1e-9>Math.abs(e-1)||e<=0)return`Kiro ${d}`;let f=e.toFixed(1).replace(",",".");return`Kiro ${d} (${f}x credit)`}(a.modelName,b,a.rateMultiplier),d=Number(a?.tokenLimits?.maxInputTokens)||2e5;for(let e of function(a,b){let c,d=((c=a).endsWith("-agentic")&&(c=c.slice(0,-8)),c.endsWith("-thinking")&&(c=c.slice(0,-9)),c),e=b||`Kiro ${d}`,f=[{id:d,name:e,capabilities:{thinking:!1,agentic:!1}},{id:`${d}-thinking`,name:`${e} (Thinking)`,capabilities:{thinking:!0,agentic:!1}}];return"auto"!==d&&(f.push({id:`${d}-agentic`,name:`${e} (Agentic)`,capabilities:{thinking:!1,agentic:!0}}),f.push({id:`${d}-thinking-agentic`,name:`${e} (Thinking + Agentic)`,capabilities:{thinking:!0,agentic:!0}})),f}(b,c))j.push({...e,contextLength:d,rateMultiplier:Number.isFinite(Number(a.rateMultiplier))?Number(a.rateMultiplier):1,upstreamModelId:b,description:a.description||""})}return k.set(h,{expiresAt:i+3e5,models:j,rawModels:c}),{models:j,rawModels:c}}}};
@@ -1,10 +0,0 @@
1
- "use strict";exports.id=4904,exports.ids=[4904],exports.modules={7866:(a,b,c)=>{c.d(b,{w$:()=>e});let d=c(39006).rE||"0.0.0";function e(a,b={}){let c,f=(c=function(a){if("string"!=typeof a)return"";let b=a.trim();return b?b.startsWith("workos:")?b:`workos:${b}`:""}(a))?`Bearer ${c}`:"",g={"HTTP-Referer":"https://cline.bot","X-Title":"Cline","User-Agent":`Switchboard/${d}`,"X-PLATFORM":process.platform||"unknown","X-PLATFORM-VERSION":process.version||"unknown","X-CLIENT-TYPE":"switchboard","X-CLIENT-VERSION":d,"X-CORE-VERSION":d,"X-IS-MULTIROOT":"false",...b};return f&&(g.Authorization=f),g}},8298:(a,b,c)=>{c.d(b,{KC:()=>j,RB:()=>q,Ty:()=>m,_G:()=>h,bg:()=>g,cT:()=>l,pM:()=>p,pr:()=>r,qk:()=>n,rf:()=>f,t6:()=>k,xG:()=>o});let d="https://openapi.qoder.sh",e="https://api3.qoder.sh",f="https://qoder.com/device/selectAccounts",g=`${d}/api/v1/deviceToken/poll`,h=`${d}/api/v1/userinfo`,i=`${e}/algo/api/v2/service/pro/sse/agent_chat_generation?FetchKeys=llm_model_result&AgentId=agent_common`,j=`${i}&Encode=1`,k=`${e}/algo/api/v2/model/list`,l="1.0.0",m="5",n="disagree",o="v2",p="x86_64_windows",q="5",r=`-----BEGIN PUBLIC KEY-----
2
- MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDA8iMH5c02LilrsERw9t6Pv5Nc
3
- 4k6Pz1EaDicBMpdpxKduSZu5OANqUq8er4GM95omAGIOPOh+Nx0spthYA2BqGz+l
4
- 6HRkPJ7S236FZz73In/KVuLnwI8JJ2CbuJap8kvheCCZpmAWpb/cPx/3Vr/J6I17
5
- XcW+ML9FoCI6AOvOzwIDAQAB
6
- -----END PUBLIC KEY-----`},9155:(a,b,c)=>{c.d(b,{EV:()=>l,X5:()=>k});var d=c(55511),e=c(89843),f=c(99393),g=c(8298);let h=new Map,i=new Map;async function j(a,b,c=null){let d,h,i={userId:(h=a?.providerSpecificData||{}).userId,authToken:a.accessToken,name:a.displayName||"",email:a.email||"",machineId:h.machineId||""};if(!i.userId||!i.authToken)return null;let k={Accept:"application/json","Accept-Encoding":"identity",...(0,f.d)(Buffer.alloc(0),g.t6,i)},l=new AbortController,m=null,n=null;try{m=setTimeout(()=>l.abort("timeout"),15e3),b&&"function"==typeof b.addEventListener&&(b.aborted?l.abort(b.reason):(n=()=>l.abort(b.reason),b.addEventListener("abort",n))),d=await (0,e.proxyAwareFetch)(g.t6,{method:"GET",headers:k,signal:l.signal},c)}finally{m&&clearTimeout(m),b&&n&&b.removeEventListener("abort",n)}if(!d.ok)return null;let o=await d.json().catch(()=>null);if(!o||!Array.isArray(o.chat))return null;let p=[],q=new Map;for(let a of o.chat){if(!a||"object"!=typeof a)continue;let b=a.key;if(!b||(q.set(b,a),!1===a.enable))continue;let c=a.display_name||b,d=Number(a.max_input_tokens)||131072;p.push({id:b,name:`${c}`,contextLength:d,isVL:!!a.is_vl,isReasoning:!!a.is_reasoning,maxOutputTokens:Number(a.max_output_tokens)||0,description:a.description||""})}return{models:p,rawConfigs:q}}async function k(a,b,c={}){let d=await l(a,c);if(!d)return null;let e=d.rawConfigs.get(b);return e?{...e,key:b}:null}async function l(a,b={}){let c;if(!a?.accessToken||!(a.providerSpecificData||{}).userId)return null;let e=(c=(a?.providerSpecificData||{}).userId||a?.refreshToken||a?.accessToken||"anonymous",(0,d.createHash)("sha256").update(`qoder:${c}`).digest("hex")),f=Date.now();if(!b.forceRefresh){let a=h.get(e);if(a&&a.expiresAt>f)return a}let g=i.get(e);if(g&&!b.forceRefresh)return g;let k=(async()=>{let c=await j(a,b.signal,b.proxyOptions);if(!c)return null;let d={expiresAt:Date.now()+36e5,models:c.models,rawConfigs:c.rawConfigs,fetched:!0};return h.set(e,d),d})();i.set(e,k);try{return await k}finally{i.get(e)===k&&i.delete(e)}}},29790:(a,b,c)=>{c.d(b,{JA:()=>l});var d=c(55511),e=c(77598);let f=function(a){return Array.isArray(a)?a=Buffer.from(a):"string"==typeof a&&(a=Buffer.from(a,"utf8")),(0,e.createHash)("sha1").update(a).digest()},g=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i,h=function(a){let b;if(!("string"==typeof a&&g.test(a)))throw TypeError("Invalid UUID");return Uint8Array.of((b=parseInt(a.slice(0,8),16))>>>24,b>>>16&255,b>>>8&255,255&b,(b=parseInt(a.slice(9,13),16))>>>8,255&b,(b=parseInt(a.slice(14,18),16))>>>8,255&b,(b=parseInt(a.slice(19,23),16))>>>8,255&b,(b=parseInt(a.slice(24,36),16))/0x10000000000&255,b/0x100000000&255,b>>>24&255,b>>>16&255,b>>>8&255,255&b)};var i=c(50122);function j(a,b,c,d){var e=b,g=d;let j="string"==typeof a?function(a){let b=new Uint8Array((a=unescape(encodeURIComponent(a))).length);for(let c=0;c<a.length;++c)b[c]=a.charCodeAt(c);return b}(a):a,k="string"==typeof e?h(e):e;if("string"==typeof e&&(e=h(e)),e?.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let l=new Uint8Array(16+j.length);if(l.set(k),l.set(j,k.length),(l=f(l))[6]=15&l[6]|80,l[8]=63&l[8]|128,c){if((g??=0)<0||g+16>c.length)throw RangeError(`UUID byte range ${g}:${g+15} is out of buffer bounds`);for(let a=0;a<16;++a)c[g+a]=l[a];return c}return(0,i.k)(l)}function k(a,b=""){return d.createHash("sha256").update(a+b).digest("hex")}function l(a,b=null,c=!0){let e=a.includes("::")?a.split("::")[1]:a,f=b||k(e,"machineId"),g=j(e,j.DNS),h=k(e),i=function(a){let b=Math.floor(Date.now()/1e6),c=new Uint8Array([b>>40&255,b>>32&255,b>>24&255,b>>16&255,b>>8&255,255&b]),d=165;for(let a=0;a<c.length;a++)c[a]=(c[a]^d)+a%256&255,d=c[a];let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",f="";for(let a=0;a<c.length;a+=3){let b=c[a],d=a+1<c.length?c[a+1]:0,g=a+2<c.length?c[a+2]:0;f+=e[b>>2],f+=e[(3&b)<<4|d>>4],a+1<c.length&&(f+=e[(15&d)<<2|g>>6]),a+2<c.length&&(f+=e[63&g])}return`${f}${a}`}(f),m="linux";"u">typeof process&&("win32"===process.platform?m="windows":"darwin"===process.platform&&(m="macos"));let n="x64";return"u">typeof process&&"arm64"===process.arch&&(n="aarch64"),{authorization:`Bearer ${e}`,"connect-accept-encoding":"gzip","connect-protocol-version":"1","content-type":"application/connect+proto","user-agent":"connect-es/1.6.1","x-amzn-trace-id":`Root=${d.randomUUID()}`,"x-client-key":h,"x-cursor-checksum":i,"x-cursor-client-version":"3.1.0","x-cursor-client-type":"ide","x-cursor-client-os":m,"x-cursor-client-arch":n,"x-cursor-client-device-type":"desktop","x-cursor-config-version":d.randomUUID(),"x-cursor-timezone":Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC","x-ghost-mode":c?"true":"false","x-request-id":d.randomUUID(),"x-session-id":g}}j.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",j.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8"},33026:(a,b,c)=>{c.d(b,{CP:()=>q,Y8:()=>o,yI:()=>m,yX:()=>p});var d=c(47293),e=c(74075);let f="1"===process.env.CURSOR_PROTOBUF_DEBUG,g=(a,...b)=>f&&console.log(`[PROTOBUF:${a}]`,...b);new TextDecoder;let h="1.1.3",i=new Set([1,2,3,9,10,11,27,1,25]);function j(a){let b=[];for(;a>=128;)b.push(127&a|128),a>>>=7;return b.push(127&a),new Uint8Array(b)}function k(a,b,c){let d=j(a<<3|b);if(0===b)return l(d,j(c));if(2===b){let a="string"==typeof c?new TextEncoder().encode(c):c instanceof Uint8Array?c:Buffer.isBuffer(c)?new Uint8Array(c):new Uint8Array(0);return l(d,j(a.length),a)}return new Uint8Array(0)}function l(...a){let b=new Uint8Array(a.reduce((a,b)=>a+b.length,0)),c=0;for(let d of a)b.set(d,c),c+=d.length;return b}function m(a,b,c=[],f=null,h=!1){g("BODY",`Generating: ${a.length} msgs, model=${b}, tools=${c.length}, reasoning=${f||"none"}, forceAgentMode=${h}`);let i=function(a,b,c=[],e=null,f=!1){return k(1,2,function(a,b,c=[],e=null,f=!1){let h,i=c?.length>0,m=i||f,n=[],o=[],p=[];for(let b=0;b<a.length;b++){let c=a[b],d=Array.isArray(c?.tool_calls)&&c.tool_calls.length>0,e=Array.isArray(c?.tool_results)&&c.tool_results.length>0;if(c?.role==="assistant"&&d&&e){g("ENCODE",`normalizing mixed assistant tool payload at msg[${b}] (calls=${c.tool_calls.length}, results=${c.tool_results.length})`),p.push({...c,tool_results:[]});let d=a[b+1],e=d?.role==="assistant"&&Array.isArray(d?.tool_results)&&d.tool_results.length>0,f=new Set(c.tool_results.map(a=>a?.tool_call_id).filter(a=>"string"==typeof a)),h=new Set((d?.tool_results||[]).map(a=>a?.tool_call_id).filter(a=>"string"==typeof a)),i=f.size>0&&f.size===h.size;if(i){for(let a of f)if(!h.has(a)){i=!1;break}}e&&i||p.push({role:"assistant",content:"",tool_results:c.tool_results});continue}p.push(c)}for(let a=0;a<p.length;a++){let b=p[a],c="user"===b.role?1:2,e=(0,d.A)(),f=a===p.length-1;n.push({content:b.content,role:c,messageId:e,isLast:f,hasTools:i,toolResults:b.tool_results||[]}),o.push({messageId:e,role:c})}let q=0;return"medium"===e?q=1:"high"===e&&(q=2),l(...n.map(a=>k(1,2,function(a,b,c,d=null,e=!1,f=!1,g=[],h=null){let i=g.length>0;return l(k(1,2,a),k(2,0,b),k(13,2,c),...h?[k(32,2,h)]:[],...i?g.map(a=>k(18,2,function(a){var b;let c,d,e=function(a){let b="string"==typeof a&&a.length>0?a:"tool";if(b.startsWith("mcp__")){let a=b.slice(5),c=a.indexOf("__");if(c>=0){let b=a.slice(0,c)||"custom",d=a.slice(c+2)||"tool";return`mcp_${b}_${d}`}return`mcp_custom_${a||"tool"}`}return b.startsWith("mcp_")?b:`mcp_custom_${b}`}(a.tool_name||a.name||""),f=a.raw_args||"{}",g=a.result_content||a.result||"",{toolCallId:h,modelCallId:i}=(b=a.tool_call_id||"",c="\nmc_",(d=b.indexOf(c))>=0?{toolCallId:b.slice(0,d),modelCallId:b.slice(d+c.length)}:{toolCallId:b,modelCallId:null}),j=a.tool_index||a.index||1,{serverName:m,selectedTool:n}=function(a){if("string"!=typeof a||!a.startsWith("mcp_"))return{serverName:"custom",selectedTool:a||"tool"};let b=a.slice(4),c=b.indexOf("_");return c<0?{serverName:"custom",selectedTool:b||"tool"}:{serverName:b.slice(0,c)||"custom",selectedTool:b.slice(c+1)||"tool"}}(e);return l(k(1,2,h),k(2,2,e),k(3,0,j>0?j:1),...i?[k(12,2,i)]:[],k(5,2,f),k(8,2,function(a,b,c,d,e=1){return l(k(1,0,19),k(28,2,l(k(1,2,c),k(2,2,d))),k(35,2,a),...b?[k(48,2,b)]:[],k(49,0,e>0?e:1))}(h,i,n,g,j)),k(11,2,function(a,b,c,d,e,f,g=1){let h;return l(k(1,0,19),k(27,2,(h=l(k(1,2,c),k(3,2,e),k(4,2,d)),k(1,2,h))),k(3,2,a),k(9,2,b),k(10,2,e),k(48,0,g>0?g:1),...f?[k(49,2,f)]:[])}(h,e,n,m,f,i,j)))}(a))):[],k(29,0,+!!f),k(47,0,f?2:1),...e&&f?[k(51,2,j(1))]:[])}(a.content,a.role,a.messageId,null,a.isLast,a.hasTools,a.toolResults))),k(2,0,1),k(3,2,new Uint8Array(0)),k(4,0,1),k(5,2,l(k(1,2,b),k(4,2,new Uint8Array(0)))),k(8,2,""),k(13,0,1),k(15,2,(h=l(k(1,2,new Uint8Array(0)),k(2,2,new Uint8Array(0))),l(k(1,2,"cursor\\aisettings"),k(3,2,new Uint8Array(0)),k(6,2,h),k(8,0,1),k(9,0,1)))),k(19,0,1),k(23,2,(0,d.A)()),k(26,2,l(k(1,2,process.platform||"linux"),k(2,2,process.arch||"x64"),k(3,2,process.version||"v20.0.0"),k(4,2,process.cwd?.()||"/"),k(5,2,new Date().toISOString()))),k(27,0,+!!m),...m?[k(29,2,j(1))]:[],...o.map(a=>k(30,2,function(a,b,c=null){return l(k(1,2,a),...c?[k(2,2,c)]:[],k(3,0,b))}(a.messageId,a.role))),...c?.length>0?c.map(a=>{let b,c,d;return k(34,2,(b=a.function?.name||a.name||"",c=a.function?.description||a.description||"",d=a.function?.parameters||a.input_schema||{},l(...b?[k(1,2,b)]:[],...c?[k(2,2,c)]:[],...Object.keys(d).length>0?[k(3,2,JSON.stringify(d))]:[],k(4,2,"custom"))))}):[],k(35,0,0),k(38,0,0),k(46,0,m?2:1),k(47,2,""),k(48,0,+!m),k(49,0,q),k(51,0,0),k(53,0,1),k(54,2,m?"Agent":"Ask"))}(a,b,c,e,f))}(a,b,c,f,h),n=function(a,b=!1){let c=a,d=0;b&&(c=new Uint8Array(e.gzipSync(Buffer.from(a))),d=1);let f=new Uint8Array(5+c.length);return f[0]=d,f[1]=c.length>>24&255,f[2]=c.length>>16&255,f[3]=c.length>>8&255,f[4]=255&c.length,f.set(c,5),f}(i,!1);return g("BODY",`Protobuf=${i.length}B, Framed=${n.length}B`),n}function n(a,b){let c=0,d=0,e=b;for(;e<a.length;){let b=a[e];if(c|=(127&b)<<d,e++,!(128&b))break;d+=7}return[c,e]}function o(a){let b=new Map,c=0;for(;c<a.length;){let[d,e,f,g]=function(a,b){let c;if(b>=a.length)return[null,null,null,b];let[d,e]=n(a,b),f=7&d,g=e;if(0===f)[c,g]=n(a,g);else if(2===f){let[b,d]=n(a,g);c=a.slice(d,d+b),g=d+b}else 1===f?(c=a.slice(g,g+8),g+=8):5===f?(c=a.slice(g,g+4),g+=4):c=null;return[d>>3,f,c,g]}(a,c);if(null===d)break;b.has(d)||b.set(d,[]),b.get(d).push({wireType:e,value:f}),c=g}return b}function p(a){if(a.length<5)return null;let b=a[0],c=a[1]<<24|a[2]<<16|a[3]<<8|a[4];if(a.length<5+c)return null;let d=a.slice(5,5+c),f=!1;if(1===b)try{d=new Uint8Array(e.gunzipSync(Buffer.from(d)))}catch(a){g("PARSE",`Decompression failed: ${a.message}`),d=new Uint8Array(0),f=!0}return{flags:b,length:c,payload:d,consumed:5+c,decompressFailed:f}}function q(a){try{let b=o(a);for(let a of b.keys())i.has(a)||g("SCHEMA",`Unknown response field #${a} detected. Schema v${h} may be outdated.`);if(b.has(1)){let a=function(a){let b=o(a),c="",d="",e="",f=!1;if(b.has(3)&&(c=new TextDecoder().decode(b.get(3)[0].value).split("\n")[0]),b.has(9)&&(d=new TextDecoder().decode(b.get(9)[0].value)),b.has(11)&&(f=0!==b.get(11)[0].value),b.has(27))try{let a=o(b.get(27)[0].value);if(a.has(1)){let b=o(a.get(1)[0].value);b.has(1)&&(d=new TextDecoder().decode(b.get(1)[0].value)),b.has(3)&&(e=new TextDecoder().decode(b.get(3)[0].value))}}catch(a){g("EXTRACT",`MCP parse error: ${a.message}`)}return(!e&&b.has(10)&&(e=new TextDecoder().decode(b.get(10)[0].value)),c&&d)?{id:c,type:"function",function:{name:d,arguments:e||"{}"},isLast:f}:null}(b.get(1)[0].value);if(a)return g("EXTRACT",`Tool call: ${a.function.name}`),{text:null,error:null,toolCall:a,thinking:null}}if(b.has(2)){let{text:a,thinking:c}=function(a){let b=o(a),c=null,d=null;if(b.has(1)&&(c=new TextDecoder().decode(b.get(1)[0].value)),b.has(25))try{let a=o(b.get(25)[0].value);a.has(1)&&(d=new TextDecoder().decode(a.get(1)[0].value))}catch(a){g("EXTRACT",`Thinking parse error: ${a.message}`)}return{text:c,thinking:d}}(b.get(2)[0].value);if(a||c)return{text:a,error:null,toolCall:null,thinking:c}}return{text:null,error:null,toolCall:null,thinking:null}}catch(b){return g("EXTRACT",`Decode failed (schema v${h}): ${b.message}`),{text:null,error:null,toolCall:null,thinking:null,raw:Buffer.from(a).toString("base64"),decodeError:b.message}}}},86925:(a,b,c)=>{c.d(b,{av:()=>o,gK:()=>m});var d=c(55511),e=c(89843);let f="https://llm.kimchi.dev",g=new Set([429,500,502,503,504]),h=new Map,i=new Map;function j(a){return(("string"==typeof a?a.trim():"")||f).replace(/\/+$/,"")}function k(a){return a?.accessToken||a?.apiKey||a?.providerSpecificData?.apiKey||null}function l(a){if(!a||"object"!=typeof a)return null;let b=a.slug||a.id||a.model||a.name;if("string"!=typeof b||""===b.trim())return null;let c=Array.isArray(a.input_modalities)?a.input_modalities.filter(a=>"text"===a||"image"===a):[],d=a.limits&&"object"==typeof a.limits?a.limits:{},e=Number(d.context_window||a.contextLength||a.context_length)||void 0,f=Number(d.max_output_tokens||a.maxOutputTokens||a.max_output_tokens)||void 0,g="string"==typeof a.provider?a.provider:"",h=!0===a.reasoning,i=Array.isArray(c)&&c.includes("image")?"imageToText":"llm",j={...a,id:b.trim(),name:String(a.display_name||a.displayName||a.name||b).trim(),provider:g,upstreamProvider:g,reasoning:h,inputModalities:c,kind:i,type:i,capabilities:{vision:c.includes("image"),reasoning:h,...e?{contextWindow:e}:{},...f?{maxOutput:f}:{},...g?{upstreamProvider:g}:{}},...e?{contextLength:e}:{},...f?{maxOutputTokens:f}:{}};return"anthropic"===g&&(j.compat={supportsReasoningEffort:!1,cacheControlFormat:"anthropic"}),j}function m(a){if("string"!=typeof a||""===a.trim())return null;let b=a.includes("/")?a.split("/").pop():a;return i.get(b)||i.get(b.toLowerCase())||null}async function n(a,b,c={}){let d=`${j(b)}/v1/models/metadata?include_in_cli=true`,f=new AbortController,h=setTimeout(()=>f.abort(Error("Kimchi models fetch timeout")),2e4),i=c.signal?AbortSignal.any([c.signal,f.signal]):f.signal;try{let b=await (0,e.proxyAwareFetch)(d,{method:"GET",headers:{Accept:"application/json",Authorization:`Bearer ${a}`,"User-Agent":"kimchi/0.1.40"},cache:"no-store",signal:i},c.proxyOptions||null);if(!b.ok){let a=Error(`Kimchi models ${b.status}: ${b.statusText}`);throw a.status=b.status,a.retryable=g.has(b.status),a}let f=await b.json();return Array.isArray(f?.models)?f.models:[]}finally{clearTimeout(h)}}async function o(a,b={}){let c,e,g,m=k(a);if(!m)return null;let p=a?.providerSpecificData?.kimchiEndpoint||b.endpoint||f,q=(g=(e=a?.providerSpecificData||{}).userId||e.username||a?.refreshToken||k(a)||"anonymous",(0,d.createHash)("sha256").update(`kimchi:${j(p)}:${g}`).digest("hex")),r=Date.now();if(!b.forceRefresh){let a=h.get(q);if(a&&a.expiresAt>r)return a}try{c=await n(m,p,b)}catch(a){return b.log?.warn?.("KIMCHI_MODELS",a.message),null}let s=c.map(l).filter(Boolean);if(0===s.length)return null;for(let a of s||[])a?.id&&(i.set(a.id,a),i.set(a.id.toLowerCase(),a));let t={expiresAt:Date.now()+3e5,models:s,rawModels:c};return h.set(q,t),t}},99393:(a,b,c)=>{c.d(b,{d:()=>h});var d=c(55511),e=c(47293),f=c(8298);function g(a){return d.createHash("md5").update(a).digest("hex")}function h(a,b,c){var h;let i,j;if(!c?.userId)throw Error("cosy: user id is empty");if(!c?.authToken)throw Error("cosy: auth token is empty");let k=Buffer.isBuffer(a)?a:"string"==typeof a?Buffer.from(a,"latin1"):Buffer.from(a||[]),{cosyKey:l,info:m}=(h={uid:c.userId,security_oauth_token:c.authToken,name:c.name||"",aid:"",email:c.email||""},i=(0,e.A)().slice(0,16),j=function(a,b){var c;let e,f,g=Buffer.from(b,"utf8");if(16!==g.length)throw Error(`aes key must be 16 bytes, got ${g.length}`);let h=g.subarray(0,16),i=d.createCipheriv("aes-128-cbc",g,h);i.setAutoPadding(!1);let j=(e=16-(c=Buffer.from(a,"utf8")).length%16,f=Buffer.alloc(c.length+e,e),c.copy(f,0),f);return Buffer.concat([i.update(j),i.final()]).toString("base64")}(JSON.stringify(h),i),{cosyKey:d.publicEncrypt({key:f.pr,padding:d.constants.RSA_PKCS1_PADDING},Buffer.from(i,"utf8")).toString("base64"),info:j}),n=String(Math.floor(Date.now()/1e3)),o=JSON.stringify({version:"v1",requestId:(0,e.A)(),info:m,cosyVersion:f.cT,ideVersion:""}),p=Buffer.from(o,"utf8").toString("base64"),q=function(a){let b;try{b=new URL(a).pathname||""}catch{return""}return b.startsWith("/algo")?b.slice(5):b}(b),r=`${p}
7
- ${l}
8
- ${n}
9
- ${k.toString("latin1")}
10
- ${q}`,s=g(Buffer.from(r,"latin1")),t=c.machineId||(0,e.A)(),u=g(k),v=String(k.length);return{Authorization:`Bearer COSY.${p}.${s}`,"Cosy-Key":l,"Cosy-User":c.userId,"Cosy-Date":n,"Cosy-Version":f.cT,"Cosy-Machineid":t,"Cosy-Machinetoken":t,"Cosy-Machinetype":f.RB,"Cosy-Machineos":f.pM,"Cosy-Clienttype":f.Ty,"Cosy-Clientip":"127.0.0.1","Cosy-Bodyhash":u,"Cosy-Bodylength":v,"Cosy-Sigpath":q,"Cosy-Data-Policy":f.qk,"Cosy-Organization-Id":"","Cosy-Organization-Tags":"","Login-Version":f.xG,"X-Request-Id":(0,e.A)()}}}};