@yina-npm/openrouterx 0.4.33 → 0.4.38

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 (295) hide show
  1. package/README.md +54 -0
  2. package/app/.next/BUILD_ID +1 -1
  3. package/app/.next/app-path-routes-manifest.json +2 -2
  4. package/app/.next/build-manifest.json +2 -2
  5. package/app/.next/required-server-files.json +1 -1
  6. package/app/.next/routes-manifest.json +27 -1
  7. package/app/.next/server/app/(dashboard)/dashboard/admin/keys/page.js +1 -1
  8. package/app/.next/server/app/(dashboard)/dashboard/admin/keys/page_client-reference-manifest.js +1 -1
  9. package/app/.next/server/app/(dashboard)/dashboard/admin/users/page.js +1 -1
  10. package/app/.next/server/app/(dashboard)/dashboard/admin/users/page_client-reference-manifest.js +1 -1
  11. package/app/.next/server/app/(dashboard)/dashboard/basic-chat/page.js +1 -1
  12. package/app/.next/server/app/(dashboard)/dashboard/basic-chat/page_client-reference-manifest.js +1 -1
  13. package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page.js +1 -1
  14. package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
  15. package/app/.next/server/app/(dashboard)/dashboard/combos/page.js +1 -1
  16. package/app/.next/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
  17. package/app/.next/server/app/(dashboard)/dashboard/console-log/page.js +1 -1
  18. package/app/.next/server/app/(dashboard)/dashboard/console-log/page_client-reference-manifest.js +1 -1
  19. package/app/.next/server/app/(dashboard)/dashboard/endpoint/page.js +1 -1
  20. package/app/.next/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
  21. package/app/.next/server/app/(dashboard)/dashboard/focus-ui/page.js +1 -1
  22. package/app/.next/server/app/(dashboard)/dashboard/focus-ui/page_client-reference-manifest.js +1 -1
  23. package/app/.next/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page.js +1 -1
  24. package/app/.next/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page_client-reference-manifest.js +1 -1
  25. package/app/.next/server/app/(dashboard)/dashboard/media-providers/[kind]/page.js +1 -1
  26. package/app/.next/server/app/(dashboard)/dashboard/media-providers/[kind]/page_client-reference-manifest.js +1 -1
  27. package/app/.next/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page.js +1 -1
  28. package/app/.next/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page_client-reference-manifest.js +1 -1
  29. package/app/.next/server/app/(dashboard)/dashboard/media-providers/web/page.js +1 -1
  30. package/app/.next/server/app/(dashboard)/dashboard/media-providers/web/page_client-reference-manifest.js +1 -1
  31. package/app/.next/server/app/(dashboard)/dashboard/mitm/page.js +1 -1
  32. package/app/.next/server/app/(dashboard)/dashboard/mitm/page_client-reference-manifest.js +1 -1
  33. package/app/.next/server/app/(dashboard)/dashboard/network-analysis/page.js +1 -1
  34. package/app/.next/server/app/(dashboard)/dashboard/network-analysis/page_client-reference-manifest.js +1 -1
  35. package/app/.next/server/app/(dashboard)/dashboard/page.js +1 -1
  36. package/app/.next/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
  37. package/app/.next/server/app/(dashboard)/dashboard/profile/page.js +1 -1
  38. package/app/.next/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
  39. package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page.js +1 -1
  40. package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
  41. package/app/.next/server/app/(dashboard)/dashboard/providers/new/page.js +1 -1
  42. package/app/.next/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
  43. package/app/.next/server/app/(dashboard)/dashboard/providers/page.js +1 -1
  44. package/app/.next/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
  45. package/app/.next/server/app/(dashboard)/dashboard/proxy-pools/page.js +1 -1
  46. package/app/.next/server/app/(dashboard)/dashboard/proxy-pools/page_client-reference-manifest.js +1 -1
  47. package/app/.next/server/app/(dashboard)/dashboard/quota/page.js +1 -1
  48. package/app/.next/server/app/(dashboard)/dashboard/quota/page_client-reference-manifest.js +1 -1
  49. package/app/.next/server/app/(dashboard)/dashboard/skills/page.js +1 -1
  50. package/app/.next/server/app/(dashboard)/dashboard/skills/page_client-reference-manifest.js +1 -1
  51. package/app/.next/server/app/(dashboard)/dashboard/translator/page.js +1 -1
  52. package/app/.next/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
  53. package/app/.next/server/app/(dashboard)/dashboard/usage/page.js +1 -1
  54. package/app/.next/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
  55. package/app/.next/server/app/(dashboard)/dashboard/user/page.js +1 -1
  56. package/app/.next/server/app/(dashboard)/dashboard/user/page_client-reference-manifest.js +1 -1
  57. package/app/.next/server/app/_global-error/page.js +1 -1
  58. package/app/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  59. package/app/.next/server/app/_global-error.html +1 -1
  60. package/app/.next/server/app/_global-error.rsc +1 -1
  61. package/app/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  62. package/app/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  63. package/app/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  64. package/app/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  65. package/app/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  66. package/app/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  67. package/app/.next/server/app/_not-found/page.js +1 -1
  68. package/app/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  69. package/app/.next/server/app/_not-found.html +1 -1
  70. package/app/.next/server/app/_not-found.rsc +3 -3
  71. package/app/.next/server/app/_not-found.segments/_full.segment.rsc +3 -3
  72. package/app/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  73. package/app/.next/server/app/_not-found.segments/_index.segment.rsc +3 -3
  74. package/app/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  75. package/app/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  76. package/app/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  77. package/app/.next/server/app/api/auth/login/route.js +1 -1
  78. package/app/.next/server/app/api/auth/logout/route.js +1 -1
  79. package/app/.next/server/app/api/auth/me/route.js +1 -1
  80. package/app/.next/server/app/api/auth/oidc/callback/route.js +1 -1
  81. package/app/.next/server/app/api/auth/oidc/start/route.js +1 -1
  82. package/app/.next/server/app/api/auth/oidc/test/route.js +1 -1
  83. package/app/.next/server/app/api/auth/status/route.js +1 -1
  84. package/app/.next/server/app/api/cli-tools/all-statuses/route.js +1 -1
  85. package/app/.next/server/app/api/cli-tools/antigravity-mitm/alias/route.js +1 -1
  86. package/app/.next/server/app/api/cli-tools/antigravity-mitm/inject-auth/route.js +1 -1
  87. package/app/.next/server/app/api/cli-tools/antigravity-mitm/inject-auth/route.js.nft.json +1 -1
  88. package/app/.next/server/app/api/cli-tools/antigravity-mitm/restart/route.js +1 -1
  89. package/app/.next/server/app/api/cli-tools/antigravity-mitm/route.js +1 -1
  90. package/app/.next/server/app/api/cli-tools/antigravity-mitm/test/route.js +1 -1
  91. package/app/.next/server/app/api/cli-tools/claude-settings/route.js +1 -1
  92. package/app/.next/server/app/api/cli-tools/cline-settings/route.js +1 -1
  93. package/app/.next/server/app/api/cli-tools/codex-settings/activate-account/route.js +2 -2
  94. package/app/.next/server/app/api/cli-tools/codex-settings/route.js +1 -1
  95. package/app/.next/server/app/api/cli-tools/copilot-settings/route.js +1 -1
  96. package/app/.next/server/app/api/cli-tools/cowork-mcp-registry/route.js +1 -1
  97. package/app/.next/server/app/api/cli-tools/cowork-mcp-tools/route.js +1 -1
  98. package/app/.next/server/app/api/cli-tools/cowork-settings/route.js +1 -1
  99. package/app/.next/server/app/api/cli-tools/droid-settings/route.js +1 -1
  100. package/app/.next/server/app/api/cli-tools/hermes-settings/route.js +1 -1
  101. package/app/.next/server/app/api/cli-tools/kilo-settings/route.js +1 -1
  102. package/app/.next/server/app/api/cli-tools/openclaw-settings/route.js +1 -1
  103. package/app/.next/server/app/api/cli-tools/opencode-settings/route.js +1 -1
  104. package/app/.next/server/app/api/cloud/auth/route.js +1 -1
  105. package/app/.next/server/app/api/cloud/credentials/update/route.js +1 -1
  106. package/app/.next/server/app/api/cloud/model/resolve/route.js +1 -1
  107. package/app/.next/server/app/api/cloud/models/alias/route.js +1 -1
  108. package/app/.next/server/app/api/combos/[id]/route.js +1 -1
  109. package/app/.next/server/app/api/combos/route.js +1 -1
  110. package/app/.next/server/app/api/health/route.js +1 -1
  111. package/app/.next/server/app/api/init/route.js +1 -1
  112. package/app/.next/server/app/api/keys/[id]/route.js +1 -1
  113. package/app/.next/server/app/api/keys/route.js +1 -1
  114. package/app/.next/server/app/api/locale/route.js +1 -1
  115. package/app/.next/server/app/api/mcp/[plugin]/message/route.js +1 -1
  116. package/app/.next/server/app/api/mcp/[plugin]/sse/route.js +1 -1
  117. package/app/.next/server/app/api/media-providers/tts/deepgram/voices/route.js +1 -1
  118. package/app/.next/server/app/api/media-providers/tts/elevenlabs/voices/route.js +1 -1
  119. package/app/.next/server/app/api/media-providers/tts/inworld/voices/route.js +1 -1
  120. package/app/.next/server/app/api/media-providers/tts/voices/route.js +1 -1
  121. package/app/.next/server/app/api/models/alias/route.js +1 -1
  122. package/app/.next/server/app/api/models/availability/route.js +1 -1
  123. package/app/.next/server/app/api/models/custom/route.js +1 -1
  124. package/app/.next/server/app/api/models/disabled/route.js +1 -1
  125. package/app/.next/server/app/api/models/route.js +1 -1
  126. package/app/.next/server/app/api/models/test/route.js +1 -1
  127. package/app/.next/server/app/api/network-analysis/route.js +2 -2
  128. package/app/.next/server/app/api/oauth/[provider]/[action]/route.js +2 -2
  129. package/app/.next/server/app/api/oauth/cursor/auto-import/route.js +1 -1
  130. package/app/.next/server/app/api/oauth/cursor/import/route.js +1 -1
  131. package/app/.next/server/app/api/oauth/gitlab/pat/route.js +1 -1
  132. package/app/.next/server/app/api/oauth/iflow/cookie/route.js +1 -1
  133. package/app/.next/server/app/api/oauth/kiro/auto-import/route.js +1 -1
  134. package/app/.next/server/app/api/oauth/kiro/import/route.js +1 -1
  135. package/app/.next/server/app/api/oauth/kiro/social-authorize/route.js +1 -1
  136. package/app/.next/server/app/api/oauth/kiro/social-exchange/route.js +1 -1
  137. package/app/.next/server/app/api/pricing/route.js +1 -1
  138. package/app/.next/server/app/api/provider-nodes/[id]/route.js +1 -1
  139. package/app/.next/server/app/api/provider-nodes/route.js +1 -1
  140. package/app/.next/server/app/api/provider-nodes/validate/route.js +1 -1
  141. package/app/.next/server/app/api/providers/[id]/models/route.js +1 -1
  142. package/app/.next/server/app/api/providers/[id]/route.js +1 -1
  143. package/app/.next/server/app/api/providers/[id]/test/route.js +1 -1
  144. package/app/.next/server/app/api/providers/[id]/test-models/route.js +1 -1
  145. package/app/.next/server/app/api/providers/client/route.js +1 -1
  146. package/app/.next/server/app/api/providers/kilo/free-models/route.js +1 -1
  147. package/app/.next/server/app/api/providers/route.js +1 -1
  148. package/app/.next/server/app/api/providers/suggested-models/route.js +1 -1
  149. package/app/.next/server/app/api/providers/test-batch/route.js +1 -1
  150. package/app/.next/server/app/api/providers/validate/route.js +1 -1
  151. package/app/.next/server/app/api/proxy-pools/[id]/route.js +1 -1
  152. package/app/.next/server/app/api/proxy-pools/[id]/test/route.js +1 -1
  153. package/app/.next/server/app/api/proxy-pools/route.js +1 -1
  154. package/app/.next/server/app/api/proxy-pools/vercel-deploy/route.js +1 -1
  155. package/app/.next/server/app/api/settings/database/route.js +1 -1
  156. package/app/.next/server/app/api/settings/proxy-test/route.js +1 -1
  157. package/app/.next/server/app/api/settings/require-login/route.js +1 -1
  158. package/app/.next/server/app/api/settings/route.js +1 -1
  159. package/app/.next/server/app/api/shutdown/route.js +1 -1
  160. package/app/.next/server/app/api/startup-notices/route.js +1 -1
  161. package/app/.next/server/app/api/tags/route.js +1 -1
  162. package/app/.next/server/app/api/translator/console-logs/route.js +1 -1
  163. package/app/.next/server/app/api/translator/console-logs/stream/route.js +1 -1
  164. package/app/.next/server/app/api/translator/load/route.js +1 -1
  165. package/app/.next/server/app/api/translator/save/route.js +1 -1
  166. package/app/.next/server/app/api/translator/send/route.js +1 -1
  167. package/app/.next/server/app/api/translator/translate/route.js +1 -1
  168. package/app/.next/server/app/api/tunnel/disable/route.js +1 -1
  169. package/app/.next/server/app/api/tunnel/enable/route.js +1 -1
  170. package/app/.next/server/app/api/tunnel/status/route.js +1 -1
  171. package/app/.next/server/app/api/tunnel/tailscale-check/route.js +1 -1
  172. package/app/.next/server/app/api/tunnel/tailscale-disable/route.js +1 -1
  173. package/app/.next/server/app/api/tunnel/tailscale-enable/route.js +1 -1
  174. package/app/.next/server/app/api/tunnel/tailscale-install/route.js +2 -2
  175. package/app/.next/server/app/api/tunnel/tailscale-login/route.js +1 -1
  176. package/app/.next/server/app/api/tunnel/tailscale-start-daemon/route.js +1 -1
  177. package/app/.next/server/app/api/usage/[connectionId]/route.js +1 -1
  178. package/app/.next/server/app/api/usage/api-keys/route.js +1 -1
  179. package/app/.next/server/app/api/usage/chart/route.js +1 -1
  180. package/app/.next/server/app/api/usage/history/route.js +1 -1
  181. package/app/.next/server/app/api/usage/logs/route.js +1 -1
  182. package/app/.next/server/app/api/usage/providers/route.js +1 -1
  183. package/app/.next/server/app/api/usage/request-details/route.js +1 -1
  184. package/app/.next/server/app/api/usage/request-logs/route.js +1 -1
  185. package/app/.next/server/app/api/usage/stats/route.js +1 -1
  186. package/app/.next/server/app/api/usage/stream/route.js +1 -1
  187. package/app/.next/server/app/api/users/[id]/route.js +1 -1
  188. package/app/.next/server/app/api/users/route.js +1 -1
  189. package/app/.next/server/app/api/v1/api/chat/route.js +1 -1
  190. package/app/.next/server/app/api/v1/audio/speech/route.js +1 -1
  191. package/app/.next/server/app/api/v1/audio/transcriptions/route.js +1 -1
  192. package/app/.next/server/app/api/v1/audio/voices/route.js +1 -1
  193. package/app/.next/server/app/api/v1/chat/completions/route.js +1 -1
  194. package/app/.next/server/app/api/v1/embeddings/route.js +1 -1
  195. package/app/.next/server/app/api/v1/images/generations/route.js +1 -1
  196. package/app/.next/server/app/api/v1/messages/count_tokens/route.js +1 -1
  197. package/app/.next/server/app/api/v1/messages/route.js +1 -1
  198. package/app/.next/server/app/api/v1/models/[kind]/route.js +1 -1
  199. package/app/.next/server/app/api/v1/models/info/route.js +1 -1
  200. package/app/.next/server/app/api/v1/models/route.js +1 -1
  201. package/app/.next/server/app/api/v1/responses/compact/route.js +1 -1
  202. package/app/.next/server/app/api/v1/responses/route.js +1 -1
  203. package/app/.next/server/app/api/v1/route.js +1 -1
  204. package/app/.next/server/app/api/v1/search/route.js +1 -1
  205. package/app/.next/server/app/api/v1/web/fetch/route.js +1 -1
  206. package/app/.next/server/app/api/v1beta/models/[...path]/route.js +1 -1
  207. package/app/.next/server/app/api/v1beta/models/route.js +1 -1
  208. package/app/.next/server/app/api/version/route.js +1 -1
  209. package/app/.next/server/app/api/version/shutdown/route.js +1 -1
  210. package/app/.next/server/app/api/version/update/route.js +1 -1
  211. package/app/.next/server/app/callback/page.js +1 -1
  212. package/app/.next/server/app/callback/page_client-reference-manifest.js +1 -1
  213. package/app/.next/server/app/callback.html +1 -1
  214. package/app/.next/server/app/callback.rsc +3 -3
  215. package/app/.next/server/app/callback.segments/_full.segment.rsc +3 -3
  216. package/app/.next/server/app/callback.segments/_head.segment.rsc +1 -1
  217. package/app/.next/server/app/callback.segments/_index.segment.rsc +3 -3
  218. package/app/.next/server/app/callback.segments/_tree.segment.rsc +1 -1
  219. package/app/.next/server/app/callback.segments/callback/__PAGE__.segment.rsc +1 -1
  220. package/app/.next/server/app/callback.segments/callback.segment.rsc +1 -1
  221. package/app/.next/server/app/dashboard/settings/pricing/page.js +1 -1
  222. package/app/.next/server/app/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
  223. package/app/.next/server/app/dashboard/settings/pricing.html +1 -1
  224. package/app/.next/server/app/dashboard/settings/pricing.rsc +3 -3
  225. package/app/.next/server/app/dashboard/settings/pricing.segments/_full.segment.rsc +3 -3
  226. package/app/.next/server/app/dashboard/settings/pricing.segments/_head.segment.rsc +1 -1
  227. package/app/.next/server/app/dashboard/settings/pricing.segments/_index.segment.rsc +3 -3
  228. package/app/.next/server/app/dashboard/settings/pricing.segments/_tree.segment.rsc +1 -1
  229. package/app/.next/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing/__PAGE__.segment.rsc +1 -1
  230. package/app/.next/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing.segment.rsc +1 -1
  231. package/app/.next/server/app/dashboard/settings/pricing.segments/dashboard/settings.segment.rsc +1 -1
  232. package/app/.next/server/app/dashboard/settings/pricing.segments/dashboard.segment.rsc +1 -1
  233. package/app/.next/server/app/favicon.ico/route.js +1 -1
  234. package/app/.next/server/app/index.html +1 -1
  235. package/app/.next/server/app/index.rsc +3 -3
  236. package/app/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  237. package/app/.next/server/app/index.segments/_full.segment.rsc +3 -3
  238. package/app/.next/server/app/index.segments/_head.segment.rsc +1 -1
  239. package/app/.next/server/app/index.segments/_index.segment.rsc +3 -3
  240. package/app/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  241. package/app/.next/server/app/landing/page.js +1 -1
  242. package/app/.next/server/app/landing/page_client-reference-manifest.js +1 -1
  243. package/app/.next/server/app/landing.html +1 -1
  244. package/app/.next/server/app/landing.rsc +3 -3
  245. package/app/.next/server/app/landing.segments/_full.segment.rsc +3 -3
  246. package/app/.next/server/app/landing.segments/_head.segment.rsc +1 -1
  247. package/app/.next/server/app/landing.segments/_index.segment.rsc +3 -3
  248. package/app/.next/server/app/landing.segments/_tree.segment.rsc +1 -1
  249. package/app/.next/server/app/landing.segments/landing/__PAGE__.segment.rsc +1 -1
  250. package/app/.next/server/app/landing.segments/landing.segment.rsc +1 -1
  251. package/app/.next/server/app/login/page.js +1 -1
  252. package/app/.next/server/app/login/page_client-reference-manifest.js +1 -1
  253. package/app/.next/server/app/login.html +1 -1
  254. package/app/.next/server/app/login.rsc +4 -4
  255. package/app/.next/server/app/login.segments/_full.segment.rsc +4 -4
  256. package/app/.next/server/app/login.segments/_head.segment.rsc +1 -1
  257. package/app/.next/server/app/login.segments/_index.segment.rsc +3 -3
  258. package/app/.next/server/app/login.segments/_tree.segment.rsc +1 -1
  259. package/app/.next/server/app/login.segments/login/__PAGE__.segment.rsc +2 -2
  260. package/app/.next/server/app/login.segments/login.segment.rsc +1 -1
  261. package/app/.next/server/app/manifest.webmanifest/route.js +1 -1
  262. package/app/.next/server/app/page.js +1 -1
  263. package/app/.next/server/app/page_client-reference-manifest.js +1 -1
  264. package/app/.next/server/app-paths-manifest.json +2 -2
  265. package/app/.next/server/chunks/1350.js +1 -1
  266. package/app/.next/server/chunks/3110.js +1 -1
  267. package/app/.next/server/chunks/3493.js +1 -1
  268. package/app/.next/server/chunks/4922.js +1 -1
  269. package/app/.next/server/chunks/5627.js +6 -6
  270. package/app/.next/server/chunks/6182.js +3 -3
  271. package/app/.next/server/chunks/7595.js +1 -1
  272. package/app/.next/server/chunks/7774.js +2 -2
  273. package/app/.next/server/chunks/8866.js +1 -1
  274. package/app/.next/server/chunks/9718.js +1 -1
  275. package/app/.next/server/middleware-build-manifest.js +1 -1
  276. package/app/.next/server/middleware.js +1 -1
  277. package/app/.next/server/pages/404.html +1 -1
  278. package/app/.next/server/pages/500.html +1 -1
  279. package/app/.next/static/9qtW6KlzV_D2b828CZp1A/_buildManifest.js +1 -0
  280. package/app/.next/static/chunks/{1321-194580b028caec3a.js → 1321-634f2d25db77d618.js} +1 -1
  281. package/app/.next/static/chunks/5095-42d435b0583b2f98.js +2 -0
  282. package/app/.next/static/chunks/main-2237af167d2c1c35.js +5 -0
  283. package/app/package.json +1 -1
  284. package/app/src/mitm/config.js +1 -0
  285. package/app/src/mitm/dns/dnsConfig.js +20 -73
  286. package/app/src/mitm/handlers/base.js +19 -20
  287. package/app/src/mitm/manager.js +79 -45
  288. package/app/src/mitm/server.js +36 -36
  289. package/cli.js +0 -170
  290. package/hooks/postinstall.js +25 -26
  291. package/package.json +1 -1
  292. package/app/.next/static/XHWEINo8HqIhskxHTrvjk/_buildManifest.js +0 -1
  293. package/app/.next/static/chunks/5095-fea302b55a08f07b.js +0 -2
  294. package/app/.next/static/chunks/main-9b9267659a73e61e.js +0 -5
  295. /package/app/.next/static/{XHWEINo8HqIhskxHTrvjk → 9qtW6KlzV_D2b828CZp1A}/_ssgManifest.js +0 -0
package/cli.js CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  const { spawn } = require("node:child_process");
4
4
  const fs = require("node:fs");
5
- const https = require("node:https");
6
5
  const os = require("node:os");
7
6
  const path = require("node:path");
8
7
  const net = require("node:net");
@@ -18,17 +17,8 @@ const PID_FILE = path.join(DATA_DIR, "server.pid");
18
17
  const META_FILE = path.join(DATA_DIR, "server.json");
19
18
  const LOG_FILE = path.join(DATA_DIR, "server.log");
20
19
  const MITM_PID_FILE = path.join(DATA_DIR, "mitm", ".mitm.pid");
21
- const STARTUP_NOTICE_DIR = path.join(DATA_DIR, "notices");
22
- const PORT_MIGRATION_NOTICE_FILE = path.join(STARTUP_NOTICE_DIR, "port-migration.json");
23
20
  const DEFAULT_PORT = "20502";
24
21
  const DEFAULT_HOST = "0.0.0.0";
25
- const NPM_PACKAGE_NAME = "@yina-npm/openrouterx";
26
- const INSTALL_CMD_LATEST = `npm i -g ${NPM_PACKAGE_NAME}@latest --prefer-online --registry=https://registry.npmjs.org/`;
27
- const DEFAULT_MITM_ROUTER_BASE_URL = `http://localhost:${DEFAULT_PORT}`;
28
- const LEGACY_DEFAULT_MITM_ROUTER_BASE_URLS = new Set([
29
- "http://localhost:20128",
30
- "http://127.0.0.1:20128",
31
- ]);
32
22
 
33
23
  function parseArgs(argv = process.argv.slice(2)) {
34
24
  const options = {
@@ -129,156 +119,6 @@ function ensureDataDir() {
129
119
  fs.mkdirSync(DATA_DIR, { recursive: true });
130
120
  }
131
121
 
132
- function stripTrailingSlash(value) {
133
- return String(value || "").trim().replace(/\/+$/, "");
134
- }
135
-
136
- function normalizeMitmRouterBaseUrl(value) {
137
- const raw = stripTrailingSlash(value);
138
- if (!raw || LEGACY_DEFAULT_MITM_ROUTER_BASE_URLS.has(raw)) {
139
- return DEFAULT_MITM_ROUTER_BASE_URL;
140
- }
141
- return raw;
142
- }
143
-
144
- function migrateJsonSettingsFile() {
145
- const jsonDbFile = path.join(DATA_DIR, "db.json");
146
- if (!fs.existsSync(jsonDbFile)) return false;
147
-
148
- try {
149
- const data = JSON.parse(fs.readFileSync(jsonDbFile, "utf8"));
150
- if (!data || typeof data !== "object") return false;
151
- if (!data.settings || typeof data.settings !== "object" || Array.isArray(data.settings)) {
152
- data.settings = {};
153
- }
154
- const current = data.settings.mitmRouterBaseUrl;
155
- const next = normalizeMitmRouterBaseUrl(current);
156
- if (current === next) return false;
157
- data.settings.mitmRouterBaseUrl = next;
158
- fs.writeFileSync(jsonDbFile, `${JSON.stringify(data, null, 2)}\n`);
159
- return true;
160
- } catch {
161
- return false;
162
- }
163
- }
164
-
165
- function migrateSqliteSettingsFile() {
166
- const sqliteFile = path.join(DATA_DIR, "db", "data.sqlite");
167
- if (!fs.existsSync(sqliteFile)) return false;
168
-
169
- let Database;
170
- try {
171
- Database = require("better-sqlite3");
172
- } catch {
173
- return false;
174
- }
175
-
176
- let db;
177
- try {
178
- db = new Database(sqliteFile);
179
- const table = db.prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'settings'").get();
180
- if (!table) return false;
181
- const row = db.prepare("SELECT id, data FROM settings WHERE id = 1").get();
182
- if (!row) return false;
183
- const settings = JSON.parse(row.data || "{}");
184
- const current = settings.mitmRouterBaseUrl;
185
- const next = normalizeMitmRouterBaseUrl(current);
186
- if (current === next) return false;
187
- settings.mitmRouterBaseUrl = next;
188
- db.prepare("UPDATE settings SET data = ? WHERE id = ?").run(JSON.stringify(settings), row.id);
189
- return true;
190
- } catch {
191
- return false;
192
- } finally {
193
- try {
194
- db?.close();
195
- } catch {}
196
- }
197
- }
198
-
199
- function writePortMigrationNotice(changedStores) {
200
- if (!changedStores.length) return;
201
- try {
202
- fs.mkdirSync(STARTUP_NOTICE_DIR, { recursive: true });
203
- fs.writeFileSync(PORT_MIGRATION_NOTICE_FILE, `${JSON.stringify({
204
- id: "port-migration-20128-20502",
205
- type: "port-migration",
206
- fromPort: 20128,
207
- toPort: Number(DEFAULT_PORT),
208
- fromBaseUrl: "http://localhost:20128",
209
- toBaseUrl: DEFAULT_MITM_ROUTER_BASE_URL,
210
- stores: changedStores,
211
- createdAt: new Date().toISOString(),
212
- }, null, 2)}\n`);
213
- } catch {}
214
- }
215
-
216
- function refreshRuntimePortSettings({ quiet = true } = {}) {
217
- ensureDataDir();
218
- const changed = [];
219
- if (migrateJsonSettingsFile()) changed.push("db.json");
220
- if (migrateSqliteSettingsFile()) changed.push("data.sqlite");
221
- writePortMigrationNotice(changed);
222
- if (!quiet && changed.length > 0) {
223
- console.log(`Refreshed MITM router port settings: ${changed.join(", ")} -> ${DEFAULT_MITM_ROUTER_BASE_URL}`);
224
- }
225
- return changed;
226
- }
227
-
228
- function compareVersions(a, b) {
229
- const pa = String(a || "").split(".").map(Number);
230
- const pb = String(b || "").split(".").map(Number);
231
- for (let i = 0; i < 3; i += 1) {
232
- const av = Number.isFinite(pa[i]) ? pa[i] : 0;
233
- const bv = Number.isFinite(pb[i]) ? pb[i] : 0;
234
- if (av > bv) return 1;
235
- if (av < bv) return -1;
236
- }
237
- return 0;
238
- }
239
-
240
- function checkForUpdate({ skipUpdate } = {}) {
241
- return new Promise((resolve) => {
242
- if (skipUpdate) {
243
- resolve(null);
244
- return;
245
- }
246
-
247
- let resolved = false;
248
- const done = (version) => {
249
- if (resolved) return;
250
- resolved = true;
251
- resolve(version);
252
- };
253
-
254
- const req = https.get(
255
- `https://registry.npmjs.org/${encodeURIComponent(NPM_PACKAGE_NAME).replace("%40", "@")}/latest`,
256
- { timeout: 3000 },
257
- (res) => {
258
- let data = "";
259
- res.on("data", (chunk) => {
260
- data += chunk;
261
- });
262
- res.on("end", () => {
263
- try {
264
- const latest = JSON.parse(data);
265
- const latestVersion = latest?.version;
266
- done(latestVersion && compareVersions(latestVersion, pkg.version) > 0 ? latestVersion : null);
267
- } catch {
268
- done(null);
269
- }
270
- });
271
- }
272
- );
273
-
274
- req.on("error", () => done(null));
275
- req.on("timeout", () => {
276
- req.destroy();
277
- done(null);
278
- });
279
- });
280
- }
281
-
282
122
  function readMeta() {
283
123
  try {
284
124
  return JSON.parse(fs.readFileSync(META_FILE, "utf8"));
@@ -548,7 +388,6 @@ function printChooser(serverUrl) {
548
388
 
549
389
  async function runCli() {
550
390
  const options = parseArgs();
551
- refreshRuntimePortSettings({ quiet: true });
552
391
 
553
392
  if (options.help) {
554
393
  console.log(formatHelp());
@@ -600,7 +439,6 @@ async function runCli() {
600
439
  const baseUrl = process.env.NEXT_PUBLIC_BASE_URL || `http://localhost:${port}`;
601
440
  const foreground = options.foreground || (process.env.ORX_CHOOSER_ACTION !== undefined && process.env.ORX_CHOOSER_ACTION !== "hide");
602
441
  const runningPid = readPid();
603
- const latestVersion = await checkForUpdate({ skipUpdate: options.skipUpdate });
604
442
 
605
443
  if (isProcessRunning(runningPid) && options.command !== "restart") {
606
444
  const runningMeta = readMeta();
@@ -618,10 +456,6 @@ async function runCli() {
618
456
  }
619
457
 
620
458
  printChooser(baseUrl);
621
- if (latestVersion) {
622
- console.log(`Update available: v${pkg.version} -> v${latestVersion}`);
623
- console.log(`Run: ${INSTALL_CMD_LATEST}`);
624
- }
625
459
 
626
460
  const stdio = foreground ? "inherit" : createLogFileDescriptors();
627
461
  const child = spawn(process.execPath, [serverEntry], {
@@ -682,8 +516,4 @@ module.exports = {
682
516
  isProcessRunning,
683
517
  printStatus,
684
518
  stopServer,
685
- refreshRuntimePortSettings,
686
- normalizeMitmRouterBaseUrl,
687
- compareVersions,
688
- checkForUpdate,
689
519
  };
@@ -99,49 +99,48 @@ function refreshRuntimePortSettings() {
99
99
 
100
100
  refreshRuntimePortSettings();
101
101
 
102
- if (!fs.existsSync(betterSqlitePath)) {
103
- console.log("better-sqlite3 not found, skipping rebuild");
104
- process.exit(0);
105
- }
106
-
107
102
  function isValidBinary() {
108
- const binaryPath = path.join(betterSqlitePath, "build", "Release", "better_sqlite3.node");
109
-
110
- if (!fs.existsSync(binaryPath)) {
103
+ try {
104
+ const Database = require(betterSqlitePath);
105
+ const db = new Database(":memory:");
106
+ db.close();
107
+ return true;
108
+ } catch {
111
109
  return false;
112
110
  }
111
+ }
113
112
 
114
- const fd = fs.openSync(binaryPath, "r");
115
- const buffer = Buffer.alloc(4);
116
- fs.readSync(fd, buffer, 0, 4, 0);
117
- fs.closeSync(fd);
118
-
119
- const magic = buffer.toString("hex");
120
- const isLinux = magic.startsWith("7f454c46");
121
- const isMacOS = magic.startsWith("cffaedfe") || magic.startsWith("cefaedfe");
122
- const isWindows = magic.startsWith("4d5a");
123
-
124
- return (process.platform === "linux" && isLinux) ||
125
- (process.platform === "darwin" && isMacOS) ||
126
- (process.platform === "win32" && isWindows);
113
+ function getBetterSqliteVersion() {
114
+ try {
115
+ const appPkg = JSON.parse(fs.readFileSync(path.join(appDir, "package.json"), "utf8"));
116
+ return appPkg.optionalDependencies?.["better-sqlite3"]
117
+ || appPkg.dependencies?.["better-sqlite3"]
118
+ || "latest";
119
+ } catch {
120
+ return "latest";
121
+ }
127
122
  }
128
123
 
129
124
  if (isValidBinary()) {
130
- console.log("better-sqlite3 binary is valid for this platform, skipping rebuild");
125
+ console.log("better-sqlite3 can open a database with this Node runtime, skipping repair");
131
126
  process.exit(0);
132
127
  }
133
128
 
134
- console.log("Rebuilding better-sqlite3 for current platform...");
129
+ console.log("Repairing better-sqlite3 for current Node runtime...");
135
130
 
136
131
  try {
137
- execSync("npm rebuild better-sqlite3 --build-from-source", {
132
+ fs.rmSync(betterSqlitePath, { recursive: true, force: true });
133
+ execSync("npm install better-sqlite3@" + getBetterSqliteVersion() + " --save-optional --ignore-scripts=false --force", {
138
134
  cwd: appDir,
139
135
  stdio: "inherit",
140
136
  timeout: 120000,
141
137
  });
142
- console.log("better-sqlite3 rebuilt successfully");
138
+ if (!isValidBinary()) {
139
+ throw new Error("better-sqlite3 still cannot open a database after repair");
140
+ }
141
+ console.log("better-sqlite3 repaired successfully");
143
142
  } catch (error) {
144
- console.warn("Failed to rebuild better-sqlite3. The app may not work correctly.");
143
+ console.warn("Failed to repair better-sqlite3. The app may not work correctly.");
145
144
  console.warn("Make sure you have build tools installed (python, make, gcc/node-gyp)");
146
145
  console.warn("Error:", error.message);
147
146
  process.exit(0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yina-npm/openrouterx",
3
- "version": "0.4.33",
3
+ "version": "0.4.38",
4
4
  "description": "openrouterX CLI - Start and manage 9Router server",
5
5
  "bin": {
6
6
  "openrouterX": "./cli.js"
@@ -1 +0,0 @@
1
- self.__BUILD_MANIFEST={__rewrites:{afterFiles:[],beforeFiles:[],fallback:[]},__routerFilterStatic:{numItems:147,errorRate:1e-4,numBits:2819,numHashes:14,bitArray:[0,1,0,0,1,0,1,1,1,1,0,1,0,1,1,1,0,1,0,1,1,0,1,0,1,0,0,1,0,0,1,1,0,1,0,1,1,1,1,1,0,0,1,0,0,0,1,0,0,0,0,0,0,1,1,0,0,1,0,1,0,1,1,0,0,0,1,1,1,0,1,0,1,1,0,1,0,1,1,0,1,1,1,0,1,1,0,1,0,1,1,1,1,1,1,1,0,0,1,1,0,1,1,1,0,1,1,1,0,0,0,1,0,1,0,0,1,0,1,1,0,1,0,1,1,0,1,1,0,1,1,0,1,1,1,0,1,1,0,1,0,0,1,1,0,0,0,1,1,1,0,0,0,0,1,0,1,0,1,1,0,0,1,1,1,1,1,0,1,0,0,0,1,1,0,0,1,1,0,0,0,0,1,0,0,1,0,1,0,0,0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,0,0,0,0,1,1,0,1,0,0,0,1,0,0,0,0,1,1,1,1,0,0,1,0,1,1,1,1,1,0,1,0,0,1,1,1,1,1,1,1,0,1,1,1,1,1,0,1,0,0,1,0,0,0,0,1,0,1,0,0,0,0,1,1,1,1,0,1]},__routerFilterDynamic:{numItems:14,errorRate:1e-4,numBits:269,numHashes:14,bitArray:[0,0,0,1,1,1,0,0,1,1,0,1,1,0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,1,0,1,1,0,0,0,1,0,1,1,0,0,0,0,0,0,1,0,1,1,0,1,1,1,0,1,0,1,0,1,0,1,0,1,0,0,0,0,1,0,0,1,0,1,1,1,1,0,0,1,1,0,1,0,0,1,1,0,0,0,1,1,0,0,0,0,0,1,1,1,0,1,0,0,0,1,0,1,0,1,0,1,0,1,0,1,0,1,1,1,0,1,1,1,1,0,1,1,1,0,1,0,0,0,1,0,1,0,0,1,1,0,0,1,1,0,1,1,0,1,0,0,1,0,0,1,1,0,0,0,1,1,1,0,1,1,1,1,1,0,1,1,0,1,1,1,0,0,0,0,1,1,0,1,0,0,0,1,0,0,0,0,1,0,0,1,1,0,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,1,0,1,1,1,0,0,0,1,1,0,1,1,1,0,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,0,1,0,1,0,1,1,1,0,1,0,1,1,0,1,0,1,0,1]},sortedPages:["/_app"]},self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB();
@@ -1,2 +0,0 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5095],{75095:(e,t,r)=>{r.d(t,{A:()=>y});var a=r(95155),s=r(12115),l=r(57250),i=r(45564);function n(e,t){return t&&0!==t?!e||e<0?100:e>=t?0:Math.round((t-e)/t*100):0}function o({quotas:e=[],compact:t=!1}){if(!e||0===e.length)return null;let r=t?"py-1 px-1.5":"py-2 px-3",s=t?"text-[11px]":"text-sm",l=t?"text-[11px]":"text-sm",i=t?"text-[10px] leading-tight":"text-xs";return(0,a.jsx)("div",{className:"overflow-x-auto",children:(0,a.jsx)("table",{className:"w-full table-fixed text-left",children:(0,a.jsx)("tbody",{children:e.map((e,o)=>{let c=void 0!==e.remainingPercentage?Math.round(e.remainingPercentage):n(e.used,e.total),d=c>70?{text:"text-green-600 dark:text-green-400",bg:"bg-green-500",bgLight:"bg-green-500/10",emoji:"\uD83D\uDFE2"}:c>=30?{text:"text-yellow-600 dark:text-yellow-400",bg:"bg-yellow-500",bgLight:"bg-yellow-500/10",emoji:"\uD83D\uDFE1"}:{text:"text-red-600 dark:text-red-400",bg:"bg-red-500",bgLight:"bg-red-500/10",emoji:"\uD83D\uDD34"},u=function(e){if(!e)return"-";try{let t="string"==typeof e?new Date(e):e,r=new Date,a=t-r;if(a<=0)return"-";let s=Math.ceil(a/6e4);if(s<60)return`${s}m`;let l=Math.floor(s/60),i=s%60;if(l<24)return`${l}h ${i}m`;let n=Math.floor(l/24);return`${n}d ${l%24}h ${i}m`}catch(e){return"-"}}(e.resetAt),m=function(e){if(!e)return null;try{let t=new Date(e),r=new Date,a=new Date(r.getFullYear(),r.getMonth(),r.getDate()),s=new Date(a);s.setDate(s.getDate()+1);let l="";l=t>=a&&t<s?"Today":t>=s&&t<new Date(s.getTime()+864e5)?"Tomorrow":t.toLocaleDateString("en-US",{month:"short",day:"numeric"});let i=t.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0});return`${l}, ${i}`}catch{return null}}(e.resetAt);return(0,a.jsxs)("tr",{className:"border-b border-black/5 dark:border-white/5 hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors",children:[(0,a.jsx)("td",{className:`${r} w-[30%]`,children:(0,a.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,a.jsx)("span",{className:"text-[10px] shrink-0",children:d.emoji}),(0,a.jsx)("span",{className:`${s} font-medium text-text-primary truncate`,children:e.name})]})}),(0,a.jsx)("td",{className:`${r} w-[45%]`,children:(0,a.jsxs)("div",{className:t?"space-y-1":"space-y-1.5",children:[(0,a.jsx)("div",{className:`${t?"h-1":"h-1.5"} rounded-full overflow-hidden border ${d.bgLight} ${0===c?"border-black/10 dark:border-white/10":"border-transparent"}`,children:(0,a.jsx)("div",{className:`h-full transition-all duration-300 ${d.bg}`,style:{width:`${Math.min(c,100)}%`}})}),(0,a.jsxs)("div",{className:`flex items-center justify-between ${t?"text-[10px]":"text-xs"}`,children:[(0,a.jsxs)("span",{className:"text-text-muted",children:[e.used.toLocaleString()," / ",e.total>0?e.total.toLocaleString():"∞"]}),(0,a.jsxs)("span",{className:`font-medium ${d.text}`,children:[c,"%"]})]})]})}),(0,a.jsx)("td",{className:`${r} w-[25%]`,children:"-"!==u||m?t?(0,a.jsx)("div",{className:`${l} text-text-primary font-medium truncate`,title:m||"",children:"-"!==u?`in ${u}`:m}):(0,a.jsxs)("div",{className:"space-y-0.5",children:["-"!==u&&(0,a.jsxs)("div",{className:`${l} text-text-primary font-medium`,children:["in ",u]}),m&&(0,a.jsx)("div",{className:`${i} text-text-muted`,children:m})]}):(0,a.jsx)("div",{className:`${l} text-text-muted italic`,children:"N/A"})})]},o)})})})})}var c=r(98542),d=r(84588),u=r(35497),m=r(52679),x=r(65921);let h=e=>m.wb.includes(e.provider)&&("oauth"===e.authType||m.jO.includes(e.provider)),p=Math.ceil(300),b="quotaAutoRefresh",f=e=>new Promise(t=>setTimeout(t,e));async function g(e,t){for(let r=0;r<e.length;r+=1){if(r>0){let e=Math.floor(1200*Math.random());await f(1800+e)}let a=e[r];await t(a.id,a.provider)}}function y({readOnly:e=!1,allowCodexActivation:t=!1,embedded:r=!1,gridClassName:f="grid grid-cols-1 md:grid-cols-2 gap-3",title:v="Provider Limits",activeFirst:j=!1,maxRows:w=null,maxColumns:k=4}){let[N,$]=(0,s.useState)([]),[C,A]=(0,s.useState)({}),[S,E]=(0,s.useState)({}),[q,T]=(0,s.useState)({}),[P,D]=(0,s.useState)(()=>{let e=window.localStorage.getItem(b);return null===e||"true"===e}),[L,O]=(0,s.useState)(null),[I,M]=(0,s.useState)(!1),[F,z]=(0,s.useState)(p),[_,R]=(0,s.useState)(!0),[U,K]=(0,s.useState)(null),[H,J]=(0,s.useState)(null),[G,Y]=(0,s.useState)(!1),[B,Q]=(0,s.useState)(null),[V,W]=(0,s.useState)([]),[X,Z]=(0,s.useState)("all"),[ee,et]=(0,s.useState)(!1),[er,ea]=(0,s.useState)(!1),[es,el]=(0,s.useState)(!1),[ei,en]=(0,s.useState)(null),eo=(0,x.i)(),ec=!e||t,ed=(0,s.useRef)(null),eu=(0,s.useRef)(null),em=(0,s.useCallback)(async()=>{try{let e=await fetch("/api/providers/client");if(!e.ok)throw Error("Failed to fetch connections");let t=(await e.json()).connections||[];return $(t),t}catch(e){return console.error("Error fetching connections:",e),$([]),[]}},[]),ex=(0,s.useCallback)(async(e,t)=>{E(t=>({...t,[e]:!0})),T(t=>({...t,[e]:null}));try{console.log(`[ProviderLimits] Fetching quota for ${t} (${e})`);let r=await fetch(`/api/usage/${e}`);if(!r.ok){let a=(await r.json().catch(()=>({}))).error||r.statusText;if(404===r.status)return void console.warn(`[ProviderLimits] Connection not found for ${t}, skipping`);if(401===r.status){console.warn(`[ProviderLimits] Auth error for ${t}:`,a),A(t=>({...t,[e]:{quotas:[],message:a}}));return}throw Error(`HTTP ${r.status}: ${a}`)}let a=await r.json();console.log(`[ProviderLimits] Got quota for ${t}:`,a);let s=function(e,t){if(!t||"object"!=typeof t)return[];let r=[];try{switch(e.toLowerCase()){case"github":default:t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null})});break;case"antigravity":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:t.displayName||e,modelKey:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null,remainingPercentage:t.remainingPercentage})});break;case"codex":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null})});break;case"kiro":t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null})});break;case"claude":t.message?r.push({name:"error",used:0,total:0,resetAt:null,message:t.message}):t.quotas&&Object.entries(t.quotas).forEach(([e,t])=>{r.push({name:e,used:t.used||0,total:t.total||0,resetAt:t.resetAt||null})})}}catch(t){return console.error(`Error parsing quota data for ${e}:`,t),[]}let a=(0,i.KC)(e);if(a.length>0){let e=new Map(a.map((e,t)=>[e.id,t]));r.sort((t,r)=>{let a=t.modelKey||t.name,s=r.modelKey||r.name;return(e.get(a)??999)-(e.get(s)??999)})}return r}(t,a);A(t=>({...t,[e]:{quotas:s,plan:a.plan||null,message:a.message||null,raw:a}}))}catch(r){console.error(`[ProviderLimits] Error fetching quota for ${t} (${e}):`,r),T(t=>({...t,[e]:r.message||"Failed to fetch quota"}))}finally{E(t=>({...t,[e]:!1}))}},[]),eh=(0,s.useCallback)(async(e,t)=>{await ex(e,t),O(new Date)},[ex]),ep=(0,s.useCallback)(async e=>{if(confirm("Delete this connection?")){K(e);try{(await fetch(`/api/providers/${e}`,{method:"DELETE"})).ok&&($(t=>t.filter(t=>t.id!==e)),A(t=>{let r={...t};return delete r[e],r}),E(t=>{let r={...t};return delete r[e],r}),T(t=>{let r={...t};return delete r[e],r}))}catch(e){console.error("Error deleting connection:",e)}finally{K(null)}}},[]),eb=(0,s.useCallback)(async(e,t)=>{J(e);try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&$(r=>r.map(r=>r.id===e?{...r,isActive:t}:r))}catch(e){console.error("Error updating connection status:",e)}finally{J(null)}},[]),ef=(0,s.useCallback)(async e=>{if(!B?.id)return;let t=B.id,r=B.provider;try{(await fetch(`/api/providers/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok&&(await em(),Y(!1),Q(null),m.wb.includes(r)&&await ex(t,r))}catch(e){console.error("Error saving connection:",e)}},[B,em,ex]),eg=(0,s.useCallback)(async e=>{if(e?.id&&!ei){en(e.id);try{let t=await fetch("/api/cli-tools/codex-settings/activate-account",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({connectionId:e.id,restartCodex:!0})}),r=await t.json().catch(()=>({}));if(!t.ok){let e=Array.isArray(r.installHints)&&r.installHints.length>0?r.installHints:r.installCommand?[r.installCommand]:[],t=e.length?`
2
- Install: ${e.join(" or ")}`:"";throw Error(`${r.error||"Failed to activate Codex account"}${t}`)}let a=r.restart?.success?"Codex was restarted automatically.":r.restart?.reason?`Restart Codex manually: ${r.restart.reason}`:"Restart Codex to use it.",s=r.keychain?.success?"Keychain auth was updated.":r.keychain?.reason?`Keychain auth failed: ${r.keychain.reason}`:"",l=`${r.account||e.email||e.name||"Account"} is now written to local Codex auth. ${s} ${a}`.trim();r.keychain?.success&&r.restart?.success?eo.success(l,"Codex account activated"):eo.error(l,"Codex activation incomplete")}catch(e){eo.error(e.message||"Failed to activate Codex account","Codex activation failed")}finally{en(null)}}},[ei,eo]);(0,s.useEffect)(()=>{if(e)return;let t=!1;return fetch("/api/proxy-pools?isActive=true",{cache:"no-store"}).then(e=>e.json()).then(e=>{!t&&e?.proxyPools&&W(e.proxyPools)}).catch(()=>{}),()=>{t=!0}},[e]);let ey=(0,s.useCallback)(async()=>{if(!I){M(!0),z(p);try{let e=(await em()).filter(h);await g(e,ex),O(new Date)}catch(e){console.error("Error refreshing all providers:",e)}finally{M(!1)}}},[I,em,ex]);(0,s.useEffect)(()=>{(async()=>{R(!0);let e=await em();R(!1);let t=e.filter(h),r={};t.forEach(e=>{r[e.id]=!0}),E(r),await g(t,ex),O(new Date)})()},[]),(0,s.useEffect)(()=>{window.localStorage.setItem(b,String(P))},[P]),(0,s.useEffect)(()=>{if(!P){ed.current&&(clearInterval(ed.current),ed.current=null),eu.current&&(clearInterval(eu.current),eu.current=null);return}return ed.current=setInterval(()=>{ey()},3e5),eu.current=setInterval(()=>{z(e=>e<=1?p:e-1)},1e3),()=>{ed.current&&clearInterval(ed.current),eu.current&&clearInterval(eu.current)}},[P,ey]),(0,s.useEffect)(()=>{let e=()=>{document.hidden?(ed.current&&(clearInterval(ed.current),ed.current=null),eu.current&&(clearInterval(eu.current),eu.current=null)):P&&(ed.current=setInterval(ey,3e5),eu.current=setInterval(()=>{z(e=>e<=1?p:e-1)},1e3))};return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}},[P,ey]);let ev=N.filter(h),ej=ev.filter(e=>"all"===X||e.provider===X),ew=e=>{let t=(C[e.id]?.quotas||[]).map(e=>e.resetAt?new Date(e.resetAt).getTime():1/0).filter(e=>Number.isFinite(e));return t.length>0?Math.min(...t):1/0},ek=[...ej].sort((e,t)=>{if(j){let r=+(!1===e.isActive),a=+(!1===t.isActive);if(r!==a)return r-a}if(ee){let r=ew(e)-ew(t);if(0!==r)return r}let r=m.wb.indexOf(e.provider),a=m.wb.indexOf(t.provider);return r!==a?r-a:e.provider.localeCompare(t.provider)}),eN=Number.isFinite(w)&&w>0?Math.floor(w)*Math.max(1,Math.floor(k||1)):null,e$=eN?ek.slice(0,eN):ek,eC=e=>{let t=C[e.id]?.quotas;return!!t?.length&&t.some(e=>!!e.total&&!(e.total<=0)&&5>=n(e.used,e.total))},eA=(0,s.useCallback)(async(e,t)=>{if(e.length&&!es){el(!0);try{await Promise.all(e.map(e=>fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})}))),$(r=>r.map(r=>e.includes(r.id)?{...r,isActive:t}:r))}catch(e){console.error("Error bulk toggling connections:",e)}finally{el(!1)}}},[es]),eS=Array.from(new Set(ev.map(e=>e.provider))).sort(),eE="all"===X?"All providers":X;return(ek.length,Object.values(C).filter(e=>e?.quotas?.length>0).length,Object.values(C).reduce((e,t)=>t?.quotas?e+ +!!t.quotas.some(e=>30>n(e.used,e.total)&&e.total>0):e,0),_||0!==ek.length)?(0,a.jsxs)("div",{className:r?"space-y-4":"space-y-6",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsx)("div",{className:"flex flex-col gap-1 sm:flex-row sm:items-center sm:gap-3",children:(0,a.jsx)("h2",{className:"text-xl font-semibold text-text-primary",children:v})}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>ea(e=>!e),className:"flex h-8 items-center justify-between gap-1 rounded-lg border border-black/10 bg-black/[0.02] px-2 text-xs text-text-primary transition-colors hover:bg-black/5 dark:border-white/10 dark:bg-white/[0.03] dark:hover:bg-white/10","aria-haspopup":"menu","aria-expanded":er,title:"Filter quota providers",children:[(0,a.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5",children:["all"===X?(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted",children:"apps"}):(0,a.jsx)(l.A,{src:`/providers/${X}.png`,alt:X,size:18,className:"size-[18px] rounded object-contain",fallbackText:X.slice(0,2).toUpperCase()}),(0,a.jsx)("span",{className:"truncate capitalize hidden lg:inline",children:eE})]}),(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted",children:"expand_more"})]}),er&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("button",{type:"button",className:"fixed inset-0 z-30 bg-transparent","aria-label":"Close provider filter",onClick:()=>ea(!1)}),(0,a.jsxs)("div",{className:"absolute left-0 z-40 mt-2 w-64 overflow-hidden rounded-2xl border border-black/10 bg-surface/95 p-1.5 shadow-xl shadow-black/10 backdrop-blur dark:border-white/10 dark:bg-surface/95 sm:w-72",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>{Z("all"),ea(!1)},className:`flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left text-sm transition-colors ${"all"===X?"bg-primary/10 text-primary":"text-text-primary hover:bg-black/5 dark:hover:bg-white/10"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[22px]",children:"apps"}),(0,a.jsx)("span",{className:"font-medium",children:"All providers"}),"all"===X&&(0,a.jsx)("span",{className:"material-symbols-outlined ml-auto text-[20px]",children:"check"})]}),(0,a.jsx)("div",{className:"my-1 h-px bg-black/10 dark:bg-white/10"}),(0,a.jsx)("div",{className:"max-h-72 overflow-y-auto pr-1",children:eS.map(e=>(0,a.jsxs)("button",{type:"button",onClick:()=>{Z(e),ea(!1)},className:`flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left text-sm transition-colors ${X===e?"bg-primary/10 text-primary":"text-text-primary hover:bg-black/5 dark:hover:bg-white/10"}`,children:[(0,a.jsx)(l.A,{src:`/providers/${e}.png`,alt:e,size:24,className:"size-6 rounded-md object-contain",fallbackText:e.slice(0,2).toUpperCase()}),(0,a.jsx)("span",{className:"font-medium capitalize",children:e}),X===e&&(0,a.jsx)("span",{className:"material-symbols-outlined ml-auto text-[20px]",children:"check"})]},e))})]})]})]}),(0,a.jsxs)("button",{type:"button",onClick:()=>et(e=>!e),className:`flex h-8 shrink-0 items-center gap-1 rounded-lg border px-2 text-xs transition-colors ${ee?"border-amber-500/40 bg-amber-500/10 text-amber-500":"border-black/10 text-text-primary hover:bg-black/5 dark:border-white/10 dark:hover:bg-white/5"}`,title:"Sort accounts by earliest quota reset time",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"hourglass_top"}),(0,a.jsx)("span",{className:"hidden sm:inline",children:"Expiring first"})]}),!e&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("button",{type:"button",onClick:()=>{eA(ek.filter(e=>(e.isActive??!0)&&eC(e)).map(e=>e.id),!1)},disabled:es,className:"flex h-8 shrink-0 items-center gap-1 rounded-lg border border-red-500/30 px-2 text-xs text-red-500 transition-colors hover:bg-red-500/10 disabled:opacity-50",title:"Disable connections with depleted quota (within current filter)",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"block"}),(0,a.jsx)("span",{className:"hidden sm:inline",children:"Turn off Empty"})]}),(0,a.jsxs)("button",{type:"button",onClick:()=>{eA(ek.filter(e=>!(e.isActive??!0)&&!eC(e)).map(e=>e.id),!0)},disabled:es,className:"flex h-8 shrink-0 items-center gap-1 rounded-lg border border-emerald-500/30 px-2 text-xs text-emerald-500 transition-colors hover:bg-emerald-500/10 disabled:opacity-50",title:"Enable connections that still have quota (within current filter)",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"check_circle"}),(0,a.jsx)("span",{className:"hidden sm:inline",children:"Turn on Available"})]})]}),(0,a.jsxs)("button",{onClick:()=>D(e=>!e),className:"flex h-8 shrink-0 items-center gap-1 rounded-lg border border-black/10 px-2 text-xs transition-colors hover:bg-black/5 dark:border-white/10 dark:hover:bg-white/5",title:P?"Disable auto-refresh":"Enable auto-refresh",children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[14px] ${P?"text-primary":"text-text-muted"}`,children:P?"toggle_on":"toggle_off"}),(0,a.jsx)("span",{className:"hidden text-text-primary sm:inline",children:"Auto-refresh"}),P&&(0,a.jsxs)("span",{className:"text-[10px] text-text-muted tabular-nums",children:["(",F,"s)"]})]}),(0,a.jsx)("button",{type:"button",onClick:ey,disabled:I,className:"flex h-8 shrink-0 items-center gap-1 rounded-lg border border-black/10 px-2 text-xs text-text-primary transition-colors hover:bg-black/5 dark:border-white/10 dark:hover:bg-white/5 disabled:opacity-50",title:"Refresh all",children:(0,a.jsx)("span",{className:`material-symbols-outlined text-[14px] ${I?"animate-spin":""}`,children:"refresh"})})]})]}),(0,a.jsx)("div",{className:f,children:e$.map(t=>{let r,s,i=C[t.id],n=S[t.id],u=q[t.id],m=!1===t.isActive,x=U===t.id||H===t.id,h=ei===t.id;return(0,a.jsxs)(d.default,{padding:"none",className:`min-w-0 ${m?"opacity-60":""}`,children:[(0,a.jsx)("div",{className:"px-3 py-2 border-b border-black/10 dark:border-white/10",children:(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,a.jsx)("div",{className:"w-8 h-8 shrink-0 rounded-md flex items-center justify-center overflow-hidden",children:(0,a.jsx)(l.A,{src:`/providers/${t.provider}.png`,alt:t.provider,size:32,className:"object-contain",fallbackText:t.provider?.slice(0,2).toUpperCase()||"PR"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h3",{className:"text-sm font-semibold text-text-primary capitalize truncate",children:t.provider}),(s=(r=e=>"string"==typeof e&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e))(t.email)?t.email:(r(t.name),t.name))?(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:s}):null]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[ec&&"codex"===t.provider&&(0,a.jsxs)("button",{type:"button",onClick:()=>eg(t),disabled:x||h,className:"h-8 inline-flex items-center gap-1 rounded-lg border border-emerald-500/30 px-2 text-xs font-medium text-emerald-600 hover:bg-emerald-500/10 transition-colors disabled:opacity-50 dark:text-emerald-400",title:"Activate this account in local Codex",children:[(0,a.jsx)("span",{className:`material-symbols-outlined text-[18px] ${h?"animate-pulse":""}`,children:"key"}),(0,a.jsx)("span",{className:"hidden xl:inline",children:"Activate"})]}),(0,a.jsx)("button",{type:"button",onClick:()=>eh(t.id,t.provider),disabled:n||x,className:"p-1.5 rounded-lg hover:bg-black/5 dark:hover:bg-white/5 transition-colors disabled:opacity-50",title:"Refresh quota",children:(0,a.jsx)("span",{className:`material-symbols-outlined text-[18px] text-text-muted ${n?"animate-spin":""}`,children:"refresh"})}),!e&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("button",{type:"button",onClick:()=>{Q(t),Y(!0)},disabled:x,className:"p-1.5 rounded-lg hover:bg-black/5 dark:hover:bg-white/5 text-text-muted hover:text-primary transition-colors disabled:opacity-50",title:"Edit connection",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"edit"})}),(0,a.jsx)("button",{type:"button",onClick:()=>ep(t.id),disabled:x,className:"p-1.5 rounded-lg hover:bg-red-500/10 text-red-500 transition-colors disabled:opacity-50",title:"Delete connection",children:(0,a.jsx)("span",{className:`material-symbols-outlined text-[18px] ${U===t.id?"animate-pulse":""}`,children:"delete"})}),(0,a.jsx)("div",{className:"inline-flex items-center pl-0.5",title:t.isActive??!0?"Disable connection":"Enable connection",children:(0,a.jsx)(c.default,{size:"sm",checked:t.isActive??!0,disabled:x,onChange:e=>eb(t.id,e)})})]})]})]})}),(0,a.jsx)("div",{className:"px-2 py-1.5",children:n?(0,a.jsx)("div",{className:"text-center py-5 text-text-muted",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[28px] animate-spin",children:"progress_activity"})}):u?(0,a.jsxs)("div",{className:"text-center py-5",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[28px] text-red-500",children:"error"}),(0,a.jsx)("p",{className:"mt-1.5 text-xs text-text-muted",children:u})]}):i?.message?(0,a.jsx)("div",{className:"text-center py-5",children:(0,a.jsx)("p",{className:"text-xs text-text-muted",children:i.message})}):(0,a.jsx)(o,{quotas:i?.quotas,compact:!0})})]},t.id)})}),!e&&(0,a.jsx)(u.wI,{isOpen:G,connection:B,proxyPools:V,onSave:ef,onClose:()=>{Y(!1),Q(null)}})]}):(0,a.jsx)(d.default,{padding:"lg",children:(0,a.jsxs)("div",{className:"text-center py-12",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[64px] text-text-muted opacity-20",children:"cloud_off"}),(0,a.jsx)("h3",{className:"mt-4 text-lg font-semibold text-text-primary",children:"No Providers Connected"}),(0,a.jsx)("p",{className:"mt-2 text-sm text-text-muted max-w-md mx-auto",children:"Connect to providers with OAuth to track your API quota limits and usage."})]})})}}}]);