omniroute 2.3.13 → 2.3.14

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 (235) hide show
  1. package/app/.next/BUILD_ID +1 -1
  2. package/app/.next/app-path-routes-manifest.json +52 -52
  3. package/app/.next/build-manifest.json +2 -2
  4. package/app/.next/server/app/(dashboard)/dashboard/a2a/page_client-reference-manifest.js +1 -1
  5. package/app/.next/server/app/(dashboard)/dashboard/agents/page_client-reference-manifest.js +1 -1
  6. package/app/.next/server/app/(dashboard)/dashboard/analytics/page_client-reference-manifest.js +1 -1
  7. package/app/.next/server/app/(dashboard)/dashboard/api-manager/page_client-reference-manifest.js +1 -1
  8. package/app/.next/server/app/(dashboard)/dashboard/audit-log/page_client-reference-manifest.js +1 -1
  9. package/app/.next/server/app/(dashboard)/dashboard/auto-combo/page_client-reference-manifest.js +1 -1
  10. package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
  11. package/app/.next/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
  12. package/app/.next/server/app/(dashboard)/dashboard/costs/page_client-reference-manifest.js +1 -1
  13. package/app/.next/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
  14. package/app/.next/server/app/(dashboard)/dashboard/health/page_client-reference-manifest.js +1 -1
  15. package/app/.next/server/app/(dashboard)/dashboard/limits/page_client-reference-manifest.js +1 -1
  16. package/app/.next/server/app/(dashboard)/dashboard/logs/page_client-reference-manifest.js +1 -1
  17. package/app/.next/server/app/(dashboard)/dashboard/mcp/page_client-reference-manifest.js +1 -1
  18. package/app/.next/server/app/(dashboard)/dashboard/media/page_client-reference-manifest.js +1 -1
  19. package/app/.next/server/app/(dashboard)/dashboard/onboarding/page_client-reference-manifest.js +1 -1
  20. package/app/.next/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
  21. package/app/.next/server/app/(dashboard)/dashboard/playground/page_client-reference-manifest.js +1 -1
  22. package/app/.next/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
  23. package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
  24. package/app/.next/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
  25. package/app/.next/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
  26. package/app/.next/server/app/(dashboard)/dashboard/settings/page_client-reference-manifest.js +1 -1
  27. package/app/.next/server/app/(dashboard)/dashboard/settings/pricing/page.js +1 -1
  28. package/app/.next/server/app/(dashboard)/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
  29. package/app/.next/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
  30. package/app/.next/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
  31. package/app/.next/server/app/.well-known/agent.json/route_client-reference-manifest.js +1 -1
  32. package/app/.next/server/app/400/page_client-reference-manifest.js +1 -1
  33. package/app/.next/server/app/401/page_client-reference-manifest.js +1 -1
  34. package/app/.next/server/app/403/page_client-reference-manifest.js +1 -1
  35. package/app/.next/server/app/408/page_client-reference-manifest.js +1 -1
  36. package/app/.next/server/app/429/page_client-reference-manifest.js +1 -1
  37. package/app/.next/server/app/500/page_client-reference-manifest.js +1 -1
  38. package/app/.next/server/app/502/page_client-reference-manifest.js +1 -1
  39. package/app/.next/server/app/503/page_client-reference-manifest.js +1 -1
  40. package/app/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  41. package/app/.next/server/app/_global-error.html +2 -2
  42. package/app/.next/server/app/_global-error.rsc +1 -1
  43. package/app/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  44. package/app/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  45. package/app/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  46. package/app/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  47. package/app/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  48. package/app/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  49. package/app/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  50. package/app/.next/server/app/a2a/route_client-reference-manifest.js +1 -1
  51. package/app/.next/server/app/api/a2a/status/route_client-reference-manifest.js +1 -1
  52. package/app/.next/server/app/api/a2a/tasks/[id]/cancel/route_client-reference-manifest.js +1 -1
  53. package/app/.next/server/app/api/a2a/tasks/[id]/route_client-reference-manifest.js +1 -1
  54. package/app/.next/server/app/api/a2a/tasks/route_client-reference-manifest.js +1 -1
  55. package/app/.next/server/app/api/acp/agents/route_client-reference-manifest.js +1 -1
  56. package/app/.next/server/app/api/auth/login/route_client-reference-manifest.js +1 -1
  57. package/app/.next/server/app/api/auth/logout/route_client-reference-manifest.js +1 -1
  58. package/app/.next/server/app/api/auth/status/route_client-reference-manifest.js +1 -1
  59. package/app/.next/server/app/api/cache/route_client-reference-manifest.js +1 -1
  60. package/app/.next/server/app/api/cache/stats/route_client-reference-manifest.js +1 -1
  61. package/app/.next/server/app/api/cli-tools/antigravity-mitm/alias/route_client-reference-manifest.js +1 -1
  62. package/app/.next/server/app/api/cli-tools/antigravity-mitm/route_client-reference-manifest.js +1 -1
  63. package/app/.next/server/app/api/cli-tools/backups/route_client-reference-manifest.js +1 -1
  64. package/app/.next/server/app/api/cli-tools/claude-settings/route_client-reference-manifest.js +1 -1
  65. package/app/.next/server/app/api/cli-tools/cline-settings/route_client-reference-manifest.js +1 -1
  66. package/app/.next/server/app/api/cli-tools/codex-profiles/route_client-reference-manifest.js +1 -1
  67. package/app/.next/server/app/api/cli-tools/codex-settings/route_client-reference-manifest.js +1 -1
  68. package/app/.next/server/app/api/cli-tools/droid-settings/route_client-reference-manifest.js +1 -1
  69. package/app/.next/server/app/api/cli-tools/guide-settings/[toolId]/route_client-reference-manifest.js +1 -1
  70. package/app/.next/server/app/api/cli-tools/kilo-settings/route_client-reference-manifest.js +1 -1
  71. package/app/.next/server/app/api/cli-tools/openclaw/auto-order/route_client-reference-manifest.js +1 -1
  72. package/app/.next/server/app/api/cli-tools/openclaw-settings/route_client-reference-manifest.js +1 -1
  73. package/app/.next/server/app/api/cli-tools/runtime/[toolId]/route_client-reference-manifest.js +1 -1
  74. package/app/.next/server/app/api/cli-tools/status/route_client-reference-manifest.js +1 -1
  75. package/app/.next/server/app/api/cloud/auth/route_client-reference-manifest.js +1 -1
  76. package/app/.next/server/app/api/cloud/credentials/update/route_client-reference-manifest.js +1 -1
  77. package/app/.next/server/app/api/cloud/model/resolve/route_client-reference-manifest.js +1 -1
  78. package/app/.next/server/app/api/cloud/models/alias/route_client-reference-manifest.js +1 -1
  79. package/app/.next/server/app/api/combos/[id]/route_client-reference-manifest.js +1 -1
  80. package/app/.next/server/app/api/combos/auto/route.js +1 -1
  81. package/app/.next/server/app/api/combos/auto/route_client-reference-manifest.js +1 -1
  82. package/app/.next/server/app/api/combos/metrics/route_client-reference-manifest.js +1 -1
  83. package/app/.next/server/app/api/combos/route_client-reference-manifest.js +1 -1
  84. package/app/.next/server/app/api/combos/test/route_client-reference-manifest.js +1 -1
  85. package/app/.next/server/app/api/compliance/audit-log/route_client-reference-manifest.js +1 -1
  86. package/app/.next/server/app/api/db-backups/export/route_client-reference-manifest.js +1 -1
  87. package/app/.next/server/app/api/db-backups/exportAll/route_client-reference-manifest.js +1 -1
  88. package/app/.next/server/app/api/db-backups/import/route_client-reference-manifest.js +1 -1
  89. package/app/.next/server/app/api/db-backups/route_client-reference-manifest.js +1 -1
  90. package/app/.next/server/app/api/evals/[suiteId]/route_client-reference-manifest.js +1 -1
  91. package/app/.next/server/app/api/evals/route_client-reference-manifest.js +1 -1
  92. package/app/.next/server/app/api/fallback/chains/route_client-reference-manifest.js +1 -1
  93. package/app/.next/server/app/api/init/route_client-reference-manifest.js +1 -1
  94. package/app/.next/server/app/api/keys/[id]/route_client-reference-manifest.js +1 -1
  95. package/app/.next/server/app/api/keys/route_client-reference-manifest.js +1 -1
  96. package/app/.next/server/app/api/logs/console/route_client-reference-manifest.js +1 -1
  97. package/app/.next/server/app/api/mcp/audit/route_client-reference-manifest.js +1 -1
  98. package/app/.next/server/app/api/mcp/audit/stats/route_client-reference-manifest.js +1 -1
  99. package/app/.next/server/app/api/mcp/sse/route_client-reference-manifest.js +1 -1
  100. package/app/.next/server/app/api/mcp/status/route_client-reference-manifest.js +1 -1
  101. package/app/.next/server/app/api/mcp/stream/route_client-reference-manifest.js +1 -1
  102. package/app/.next/server/app/api/mcp/tools/route_client-reference-manifest.js +1 -1
  103. package/app/.next/server/app/api/models/alias/route_client-reference-manifest.js +1 -1
  104. package/app/.next/server/app/api/models/availability/route_client-reference-manifest.js +1 -1
  105. package/app/.next/server/app/api/models/catalog/route_client-reference-manifest.js +1 -1
  106. package/app/.next/server/app/api/models/openrouter-catalog/route_client-reference-manifest.js +1 -1
  107. package/app/.next/server/app/api/models/route.js +1 -1
  108. package/app/.next/server/app/api/models/route_client-reference-manifest.js +1 -1
  109. package/app/.next/server/app/api/monitoring/health/route.js +1 -1
  110. package/app/.next/server/app/api/monitoring/health/route_client-reference-manifest.js +1 -1
  111. package/app/.next/server/app/api/oauth/[provider]/[action]/route.js +1 -1
  112. package/app/.next/server/app/api/oauth/[provider]/[action]/route_client-reference-manifest.js +1 -1
  113. package/app/.next/server/app/api/oauth/cursor/auto-import/route_client-reference-manifest.js +1 -1
  114. package/app/.next/server/app/api/oauth/cursor/import/route.js +1 -1
  115. package/app/.next/server/app/api/oauth/cursor/import/route_client-reference-manifest.js +1 -1
  116. package/app/.next/server/app/api/oauth/kiro/auto-import/route_client-reference-manifest.js +1 -1
  117. package/app/.next/server/app/api/oauth/kiro/import/route.js +1 -1
  118. package/app/.next/server/app/api/oauth/kiro/import/route_client-reference-manifest.js +1 -1
  119. package/app/.next/server/app/api/oauth/kiro/social-authorize/route.js +1 -1
  120. package/app/.next/server/app/api/oauth/kiro/social-authorize/route_client-reference-manifest.js +1 -1
  121. package/app/.next/server/app/api/oauth/kiro/social-exchange/route.js +1 -1
  122. package/app/.next/server/app/api/oauth/kiro/social-exchange/route_client-reference-manifest.js +1 -1
  123. package/app/.next/server/app/api/policies/route_client-reference-manifest.js +1 -1
  124. package/app/.next/server/app/api/pricing/defaults/route.js +1 -1
  125. package/app/.next/server/app/api/pricing/defaults/route_client-reference-manifest.js +1 -1
  126. package/app/.next/server/app/api/pricing/models/route_client-reference-manifest.js +1 -1
  127. package/app/.next/server/app/api/pricing/route_client-reference-manifest.js +1 -1
  128. package/app/.next/server/app/api/provider-metrics/route_client-reference-manifest.js +1 -1
  129. package/app/.next/server/app/api/provider-models/route_client-reference-manifest.js +1 -1
  130. package/app/.next/server/app/api/provider-nodes/[id]/route_client-reference-manifest.js +1 -1
  131. package/app/.next/server/app/api/provider-nodes/route_client-reference-manifest.js +1 -1
  132. package/app/.next/server/app/api/provider-nodes/validate/route_client-reference-manifest.js +1 -1
  133. package/app/.next/server/app/api/providers/[id]/models/route_client-reference-manifest.js +1 -1
  134. package/app/.next/server/app/api/providers/[id]/route_client-reference-manifest.js +1 -1
  135. package/app/.next/server/app/api/providers/[id]/test/route_client-reference-manifest.js +1 -1
  136. package/app/.next/server/app/api/providers/client/route_client-reference-manifest.js +1 -1
  137. package/app/.next/server/app/api/providers/route.js +1 -1
  138. package/app/.next/server/app/api/providers/route_client-reference-manifest.js +1 -1
  139. package/app/.next/server/app/api/providers/test-batch/route_client-reference-manifest.js +1 -1
  140. package/app/.next/server/app/api/providers/validate/route_client-reference-manifest.js +1 -1
  141. package/app/.next/server/app/api/rate-limit/route_client-reference-manifest.js +1 -1
  142. package/app/.next/server/app/api/rate-limits/route_client-reference-manifest.js +1 -1
  143. package/app/.next/server/app/api/resilience/reset/route_client-reference-manifest.js +1 -1
  144. package/app/.next/server/app/api/resilience/route_client-reference-manifest.js +1 -1
  145. package/app/.next/server/app/api/restart/route_client-reference-manifest.js +1 -1
  146. package/app/.next/server/app/api/sessions/route_client-reference-manifest.js +1 -1
  147. package/app/.next/server/app/api/settings/background-degradation/route_client-reference-manifest.js +1 -1
  148. package/app/.next/server/app/api/settings/combo-defaults/route_client-reference-manifest.js +1 -1
  149. package/app/.next/server/app/api/settings/ip-filter/route_client-reference-manifest.js +1 -1
  150. package/app/.next/server/app/api/settings/model-aliases/route_client-reference-manifest.js +1 -1
  151. package/app/.next/server/app/api/settings/proxy/route_client-reference-manifest.js +1 -1
  152. package/app/.next/server/app/api/settings/proxy/test/route_client-reference-manifest.js +1 -1
  153. package/app/.next/server/app/api/settings/require-login/route_client-reference-manifest.js +1 -1
  154. package/app/.next/server/app/api/settings/route_client-reference-manifest.js +1 -1
  155. package/app/.next/server/app/api/settings/system-prompt/route_client-reference-manifest.js +1 -1
  156. package/app/.next/server/app/api/settings/thinking-budget/route_client-reference-manifest.js +1 -1
  157. package/app/.next/server/app/api/shutdown/route_client-reference-manifest.js +1 -1
  158. package/app/.next/server/app/api/storage/health/route_client-reference-manifest.js +1 -1
  159. package/app/.next/server/app/api/sync/cloud/route_client-reference-manifest.js +1 -1
  160. package/app/.next/server/app/api/sync/initialize/route_client-reference-manifest.js +1 -1
  161. package/app/.next/server/app/api/tags/route_client-reference-manifest.js +1 -1
  162. package/app/.next/server/app/api/telemetry/summary/route_client-reference-manifest.js +1 -1
  163. package/app/.next/server/app/api/token-health/route_client-reference-manifest.js +1 -1
  164. package/app/.next/server/app/api/translator/detect/route_client-reference-manifest.js +1 -1
  165. package/app/.next/server/app/api/translator/history/route_client-reference-manifest.js +1 -1
  166. package/app/.next/server/app/api/translator/load/route_client-reference-manifest.js +1 -1
  167. package/app/.next/server/app/api/translator/save/route_client-reference-manifest.js +1 -1
  168. package/app/.next/server/app/api/translator/send/route_client-reference-manifest.js +1 -1
  169. package/app/.next/server/app/api/translator/translate/route_client-reference-manifest.js +1 -1
  170. package/app/.next/server/app/api/usage/[connectionId]/route_client-reference-manifest.js +1 -1
  171. package/app/.next/server/app/api/usage/analytics/route_client-reference-manifest.js +1 -1
  172. package/app/.next/server/app/api/usage/budget/route_client-reference-manifest.js +1 -1
  173. package/app/.next/server/app/api/usage/call-logs/[id]/route_client-reference-manifest.js +1 -1
  174. package/app/.next/server/app/api/usage/call-logs/route_client-reference-manifest.js +1 -1
  175. package/app/.next/server/app/api/usage/history/route_client-reference-manifest.js +1 -1
  176. package/app/.next/server/app/api/usage/logs/route_client-reference-manifest.js +1 -1
  177. package/app/.next/server/app/api/usage/proxy-logs/route_client-reference-manifest.js +1 -1
  178. package/app/.next/server/app/api/usage/quota/route_client-reference-manifest.js +1 -1
  179. package/app/.next/server/app/api/usage/request-logs/route_client-reference-manifest.js +1 -1
  180. package/app/.next/server/app/api/v1/api/chat/route_client-reference-manifest.js +1 -1
  181. package/app/.next/server/app/api/v1/audio/speech/route_client-reference-manifest.js +1 -1
  182. package/app/.next/server/app/api/v1/audio/transcriptions/route_client-reference-manifest.js +1 -1
  183. package/app/.next/server/app/api/v1/chat/completions/route_client-reference-manifest.js +1 -1
  184. package/app/.next/server/app/api/v1/completions/route_client-reference-manifest.js +1 -1
  185. package/app/.next/server/app/api/v1/embeddings/route_client-reference-manifest.js +1 -1
  186. package/app/.next/server/app/api/v1/images/generations/route_client-reference-manifest.js +1 -1
  187. package/app/.next/server/app/api/v1/messages/count_tokens/route_client-reference-manifest.js +1 -1
  188. package/app/.next/server/app/api/v1/messages/route_client-reference-manifest.js +1 -1
  189. package/app/.next/server/app/api/v1/models/route_client-reference-manifest.js +1 -1
  190. package/app/.next/server/app/api/v1/moderations/route_client-reference-manifest.js +1 -1
  191. package/app/.next/server/app/api/v1/music/generations/route_client-reference-manifest.js +1 -1
  192. package/app/.next/server/app/api/v1/providers/[provider]/chat/completions/route_client-reference-manifest.js +1 -1
  193. package/app/.next/server/app/api/v1/providers/[provider]/embeddings/route_client-reference-manifest.js +1 -1
  194. package/app/.next/server/app/api/v1/providers/[provider]/images/generations/route_client-reference-manifest.js +1 -1
  195. package/app/.next/server/app/api/v1/rerank/route_client-reference-manifest.js +1 -1
  196. package/app/.next/server/app/api/v1/responses/route_client-reference-manifest.js +1 -1
  197. package/app/.next/server/app/api/v1/route_client-reference-manifest.js +1 -1
  198. package/app/.next/server/app/api/v1/videos/generations/route_client-reference-manifest.js +1 -1
  199. package/app/.next/server/app/api/v1beta/models/[...path]/route_client-reference-manifest.js +1 -1
  200. package/app/.next/server/app/api/v1beta/models/route_client-reference-manifest.js +1 -1
  201. package/app/.next/server/app/callback/page_client-reference-manifest.js +1 -1
  202. package/app/.next/server/app/docs/page.js +1 -1
  203. package/app/.next/server/app/docs/page_client-reference-manifest.js +1 -1
  204. package/app/.next/server/app/forbidden/page_client-reference-manifest.js +1 -1
  205. package/app/.next/server/app/forgot-password/page_client-reference-manifest.js +1 -1
  206. package/app/.next/server/app/landing/page_client-reference-manifest.js +1 -1
  207. package/app/.next/server/app/login/page_client-reference-manifest.js +1 -1
  208. package/app/.next/server/app/maintenance/page_client-reference-manifest.js +1 -1
  209. package/app/.next/server/app/offline/page_client-reference-manifest.js +1 -1
  210. package/app/.next/server/app/page_client-reference-manifest.js +1 -1
  211. package/app/.next/server/app/privacy/page_client-reference-manifest.js +1 -1
  212. package/app/.next/server/app/status/page_client-reference-manifest.js +1 -1
  213. package/app/.next/server/app/terms/page_client-reference-manifest.js +1 -1
  214. package/app/.next/server/app-paths-manifest.json +52 -52
  215. package/app/.next/server/chunks/1909.js +1 -1
  216. package/app/.next/server/chunks/3699.js +1 -1
  217. package/app/.next/server/chunks/4935.js +1 -1
  218. package/app/.next/server/chunks/8158.js +1 -1
  219. package/app/.next/server/chunks/9342.js +1 -1
  220. package/app/.next/server/chunks/9631.js +1 -1
  221. package/app/.next/server/pages/500.html +2 -2
  222. package/app/.next/server/server-reference-manifest.js +1 -1
  223. package/app/.next/server/server-reference-manifest.json +1 -1
  224. package/app/.next/static/chunks/{5846-56c40f2351d4d1dc.js → 5846-98fad78774a68a3d.js} +1 -1
  225. package/app/.next/static/chunks/app/(dashboard)/dashboard/settings/pricing/page-aab023f14c6ff966.js +1 -0
  226. package/app/package.json +1 -1
  227. package/app/src/mitm/cert/generate.js +73 -0
  228. package/app/src/mitm/cert/install.js +137 -0
  229. package/app/src/mitm/dns/dnsConfig.js +118 -0
  230. package/app/src/mitm/manager.js +229 -0
  231. package/app/src/mitm/server.js +265 -0
  232. package/package.json +1 -1
  233. package/app/.next/static/chunks/app/(dashboard)/dashboard/settings/pricing/page-d23e0e2c39ee0e0f.js +0 -1
  234. /package/app/.next/static/{BVNxmHsI7LQYBdU_fXC34 → Ar-vIXY0zIZS50yZlitmE}/_buildManifest.js +0 -0
  235. /package/app/.next/static/{BVNxmHsI7LQYBdU_fXC34 → Ar-vIXY0zIZS50yZlitmE}/_ssgManifest.js +0 -0
@@ -0,0 +1,229 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getCachedPassword = getCachedPassword;
7
+ exports.setCachedPassword = setCachedPassword;
8
+ exports.clearCachedPassword = clearCachedPassword;
9
+ exports.getMitmStatus = getMitmStatus;
10
+ exports.startMitm = startMitm;
11
+ exports.stopMitm = stopMitm;
12
+ const child_process_1 = require("child_process");
13
+ const path_1 = __importDefault(require("path"));
14
+ const fs_1 = __importDefault(require("fs"));
15
+ const dataPaths_1 = require("@/lib/dataPaths");
16
+ const dnsConfig_1 = require("./dns/dnsConfig");
17
+ const generate_1 = require("./cert/generate");
18
+ const install_1 = require("./cert/install");
19
+ // Store server process
20
+ let serverProcess = null;
21
+ let serverPid = null;
22
+ // Module-scoped password cache (not exposed on globalThis).
23
+ // Cleared automatically when the MITM proxy is stopped.
24
+ let _cachedPassword = null;
25
+ function getCachedPassword() {
26
+ return _cachedPassword;
27
+ }
28
+ function setCachedPassword(pwd) {
29
+ _cachedPassword = pwd || null;
30
+ }
31
+ function clearCachedPassword() {
32
+ _cachedPassword = null;
33
+ }
34
+ // server.js is in same directory as this file
35
+ const PID_FILE = path_1.default.join((0, dataPaths_1.resolveDataDir)(), "mitm", ".mitm.pid");
36
+ // Check if a PID is alive
37
+ function isProcessAlive(pid) {
38
+ try {
39
+ process.kill(pid, 0);
40
+ return true;
41
+ }
42
+ catch {
43
+ return false;
44
+ }
45
+ }
46
+ /**
47
+ * Get MITM status
48
+ */
49
+ async function getMitmStatus() {
50
+ // Check in-memory process first, then fallback to PID file
51
+ let running = serverProcess !== null && !serverProcess.killed;
52
+ let pid = serverPid;
53
+ if (!running) {
54
+ try {
55
+ if (fs_1.default.existsSync(PID_FILE)) {
56
+ const savedPid = parseInt(fs_1.default.readFileSync(PID_FILE, "utf-8").trim(), 10);
57
+ if (savedPid && isProcessAlive(savedPid)) {
58
+ running = true;
59
+ pid = savedPid;
60
+ }
61
+ else {
62
+ // Stale PID file, clean up
63
+ fs_1.default.unlinkSync(PID_FILE);
64
+ }
65
+ }
66
+ }
67
+ catch {
68
+ // Ignore
69
+ }
70
+ }
71
+ // Check DNS configuration
72
+ let dnsConfigured = false;
73
+ try {
74
+ const hostsContent = fs_1.default.readFileSync("/etc/hosts", "utf-8");
75
+ dnsConfigured = hostsContent.includes("daily-cloudcode-pa.googleapis.com");
76
+ }
77
+ catch {
78
+ // Ignore
79
+ }
80
+ // Check cert
81
+ const certDir = path_1.default.join((0, dataPaths_1.resolveDataDir)(), "mitm");
82
+ const certExists = fs_1.default.existsSync(path_1.default.join(certDir, "server.crt"));
83
+ return { running, pid, dnsConfigured, certExists };
84
+ }
85
+ /**
86
+ * Start MITM proxy
87
+ * @param {string} apiKey - OmniRoute API key
88
+ * @param {string} sudoPassword - Sudo password for DNS/cert operations
89
+ */
90
+ async function startMitm(apiKey, sudoPassword) {
91
+ // Check if already running
92
+ if (serverProcess && !serverProcess.killed) {
93
+ throw new Error("MITM proxy is already running");
94
+ }
95
+ // 1. Generate SSL certificate if not exists
96
+ const certPath = path_1.default.join((0, dataPaths_1.resolveDataDir)(), "mitm", "server.crt");
97
+ if (!fs_1.default.existsSync(certPath)) {
98
+ console.log("Generating SSL certificate...");
99
+ await (0, generate_1.generateCert)();
100
+ }
101
+ // 2. Install certificate to system keychain
102
+ await (0, install_1.installCert)(sudoPassword, certPath);
103
+ // 3. Add DNS entry
104
+ console.log("Adding DNS entry...");
105
+ await (0, dnsConfig_1.addDNSEntry)(sudoPassword);
106
+ // 4. Start MITM server
107
+ console.log("Starting MITM server...");
108
+ const serverPath = path_1.default.join(process.cwd(), "src/mitm/server.js");
109
+ serverProcess = (0, child_process_1.spawn)("node", [serverPath], {
110
+ env: {
111
+ ...process.env,
112
+ ROUTER_API_KEY: apiKey,
113
+ NODE_ENV: "production",
114
+ },
115
+ detached: false,
116
+ stdio: ["ignore", "pipe", "pipe"],
117
+ });
118
+ serverPid = serverProcess.pid;
119
+ // Save PID to file
120
+ fs_1.default.writeFileSync(PID_FILE, String(serverPid));
121
+ // Log server output
122
+ serverProcess.stdout.on("data", (data) => {
123
+ console.log(`[MITM Server] ${data.toString().trim()}`);
124
+ });
125
+ serverProcess.stderr.on("data", (data) => {
126
+ console.error(`[MITM Server Error] ${data.toString().trim()}`);
127
+ });
128
+ serverProcess.on("exit", (code) => {
129
+ console.log(`MITM server exited with code ${code}`);
130
+ serverProcess = null;
131
+ serverPid = null;
132
+ // Remove PID file
133
+ try {
134
+ fs_1.default.unlinkSync(PID_FILE);
135
+ }
136
+ catch (error) {
137
+ // Ignore
138
+ }
139
+ });
140
+ // Wait and verify server actually started
141
+ const started = await new Promise((resolve) => {
142
+ let resolved = false;
143
+ const timeout = setTimeout(() => {
144
+ if (!resolved) {
145
+ resolved = true;
146
+ resolve(true);
147
+ }
148
+ }, 2000);
149
+ serverProcess.on("exit", (code) => {
150
+ clearTimeout(timeout);
151
+ if (!resolved) {
152
+ resolved = true;
153
+ resolve(false);
154
+ }
155
+ });
156
+ // Check stderr for error messages
157
+ serverProcess.stderr.on("data", (data) => {
158
+ const msg = data.toString().trim();
159
+ if (msg.includes("Port") && msg.includes("already in use")) {
160
+ clearTimeout(timeout);
161
+ if (!resolved) {
162
+ resolved = true;
163
+ resolve(false);
164
+ }
165
+ }
166
+ });
167
+ });
168
+ if (!started) {
169
+ throw new Error("MITM server failed to start (port 443 may be in use)");
170
+ }
171
+ return {
172
+ running: true,
173
+ pid: serverPid,
174
+ };
175
+ }
176
+ /**
177
+ * Stop MITM proxy
178
+ * @param {string} sudoPassword - Sudo password for DNS cleanup
179
+ */
180
+ async function stopMitm(sudoPassword) {
181
+ // 1. Kill server process (in-memory or from PID file)
182
+ const proc = serverProcess;
183
+ if (proc && !proc.killed) {
184
+ console.log("Stopping MITM server...");
185
+ proc.kill("SIGTERM");
186
+ await new Promise((resolve) => setTimeout(resolve, 1000));
187
+ if (!proc.killed) {
188
+ proc.kill("SIGKILL");
189
+ }
190
+ serverProcess = null;
191
+ serverPid = null;
192
+ }
193
+ else {
194
+ // Fallback: kill by PID file
195
+ try {
196
+ if (fs_1.default.existsSync(PID_FILE)) {
197
+ const savedPid = parseInt(fs_1.default.readFileSync(PID_FILE, "utf-8").trim(), 10);
198
+ if (savedPid && isProcessAlive(savedPid)) {
199
+ console.log(`Killing MITM server (PID: ${savedPid})...`);
200
+ process.kill(savedPid, "SIGTERM");
201
+ await new Promise((resolve) => setTimeout(resolve, 1000));
202
+ if (isProcessAlive(savedPid)) {
203
+ process.kill(savedPid, "SIGKILL");
204
+ }
205
+ }
206
+ }
207
+ }
208
+ catch {
209
+ // Ignore
210
+ }
211
+ serverProcess = null;
212
+ serverPid = null;
213
+ }
214
+ // 2. Remove DNS entry
215
+ console.log("Removing DNS entry...");
216
+ await (0, dnsConfig_1.removeDNSEntry)(sudoPassword);
217
+ // 3. Clean up
218
+ clearCachedPassword(); // Clear password from memory when proxy stops
219
+ try {
220
+ fs_1.default.unlinkSync(PID_FILE);
221
+ }
222
+ catch (error) {
223
+ // Ignore
224
+ }
225
+ return {
226
+ running: false,
227
+ pid: null,
228
+ };
229
+ }
@@ -0,0 +1,265 @@
1
+ const https = require("https");
2
+ const fs = require("fs");
3
+ const path = require("path");
4
+ const dns = require("dns");
5
+ const { promisify } = require("util");
6
+ const os = require("os");
7
+ // Resolve data directory — mirrors src/lib/dataPaths.ts logic.
8
+ // This file runs as a standalone CommonJS process and cannot import the ES module.
9
+ function getDataDir() {
10
+ if (process.env.DATA_DIR)
11
+ return path.resolve(process.env.DATA_DIR.trim());
12
+ return path.join(os.homedir(), ".omniroute");
13
+ }
14
+ // Configuration
15
+ const TARGET_HOST = "daily-cloudcode-pa.googleapis.com";
16
+ const LOCAL_PORT = 443;
17
+ const ROUTER_URL = "http://localhost:20128/v1/chat/completions";
18
+ const API_KEY = process.env.ROUTER_API_KEY;
19
+ const DATA_DIR = getDataDir();
20
+ const DB_FILE = path.join(DATA_DIR, "db.json");
21
+ const SQLITE_FILE = path.join(DATA_DIR, "storage.sqlite");
22
+ let _sqliteDb = null;
23
+ // Toggle logging (set true to enable file logging for debugging)
24
+ const ENABLE_FILE_LOG = false;
25
+ if (!API_KEY) {
26
+ console.error("❌ ROUTER_API_KEY required");
27
+ process.exit(1);
28
+ }
29
+ // Load SSL certificates
30
+ const certDir = path.join(DATA_DIR, "mitm");
31
+ const sslOptions = {
32
+ key: fs.readFileSync(path.join(certDir, "server.key")),
33
+ cert: fs.readFileSync(path.join(certDir, "server.crt")),
34
+ };
35
+ // Chat endpoints that should be intercepted
36
+ const CHAT_URL_PATTERNS = [":generateContent", ":streamGenerateContent"];
37
+ // Log directory for request/response dumps
38
+ const LOG_DIR = path.join(__dirname, "../../logs/mitm");
39
+ if (ENABLE_FILE_LOG && !fs.existsSync(LOG_DIR))
40
+ fs.mkdirSync(LOG_DIR, { recursive: true });
41
+ // Safe log filename: only alphanumeric + hyphens, anchored inside LOG_DIR
42
+ function safeLogPath(name) {
43
+ const safe = name.replace(/[^a-zA-Z0-9_\-]/g, "_").substring(0, 80);
44
+ const resolved = path.resolve(LOG_DIR, safe);
45
+ if (!resolved.startsWith(path.resolve(LOG_DIR) + path.sep)) {
46
+ throw new Error("Path traversal attempt detected in log filename");
47
+ }
48
+ return resolved;
49
+ }
50
+ function saveRequestLog(url, bodyBuffer) {
51
+ if (!ENABLE_FILE_LOG)
52
+ return;
53
+ try {
54
+ const ts = new Date().toISOString().replace(/[:.]/g, "-");
55
+ const urlSlug = url.replace(/[^a-zA-Z0-9]/g, "_").substring(0, 60);
56
+ const filePath = safeLogPath(`${ts}_${urlSlug}.json`);
57
+ const body = JSON.parse(bodyBuffer.toString());
58
+ fs.writeFileSync(filePath, JSON.stringify(body, null, 2));
59
+ console.log(`💾 Saved request: ${filePath}`);
60
+ }
61
+ catch {
62
+ // Ignore
63
+ }
64
+ }
65
+ function saveResponseLog(url, data) {
66
+ if (!ENABLE_FILE_LOG)
67
+ return;
68
+ try {
69
+ const ts = new Date().toISOString().replace(/[:.]/g, "-");
70
+ const urlSlug = url.replace(/[^a-zA-Z0-9]/g, "_").substring(0, 60);
71
+ const filePath = safeLogPath(`${ts}_${urlSlug}_response.txt`);
72
+ fs.writeFileSync(filePath, data);
73
+ console.log(`💾 Saved response: ${filePath}`);
74
+ }
75
+ catch {
76
+ // Ignore
77
+ }
78
+ }
79
+ // Resolve real IP of target host (bypass /etc/hosts)
80
+ let cachedTargetIP = null;
81
+ async function resolveTargetIP() {
82
+ if (cachedTargetIP)
83
+ return cachedTargetIP;
84
+ const resolver = new dns.Resolver();
85
+ resolver.setServers(["8.8.8.8"]);
86
+ const resolve4 = promisify(resolver.resolve4.bind(resolver));
87
+ const addresses = await resolve4(TARGET_HOST);
88
+ cachedTargetIP = addresses[0];
89
+ return cachedTargetIP;
90
+ }
91
+ function collectBodyRaw(req) {
92
+ return new Promise((resolve, reject) => {
93
+ const chunks = [];
94
+ req.on("data", (chunk) => chunks.push(chunk));
95
+ req.on("end", () => resolve(Buffer.concat(chunks)));
96
+ req.on("error", reject);
97
+ });
98
+ }
99
+ function extractModel(body) {
100
+ try {
101
+ return JSON.parse(body.toString()).model || null;
102
+ }
103
+ catch {
104
+ return null;
105
+ }
106
+ }
107
+ /**
108
+ * Get a lazy SQLite connection for reading MITM aliases.
109
+ * Falls back to null if better-sqlite3 is unavailable.
110
+ */
111
+ function getSqliteDb() {
112
+ if (_sqliteDb)
113
+ return _sqliteDb;
114
+ try {
115
+ const Database = require("better-sqlite3");
116
+ if (fs.existsSync(SQLITE_FILE)) {
117
+ _sqliteDb = new Database(SQLITE_FILE, { readonly: true });
118
+ return _sqliteDb;
119
+ }
120
+ }
121
+ catch {
122
+ // better-sqlite3 not available in this process
123
+ }
124
+ return null;
125
+ }
126
+ function getMappedModel(model) {
127
+ if (!model)
128
+ return null;
129
+ // Primary: read from SQLite key_value table
130
+ try {
131
+ const db = getSqliteDb();
132
+ if (db) {
133
+ const row = db
134
+ .prepare("SELECT value FROM key_value WHERE namespace = 'mitmAlias' AND key = 'antigravity'")
135
+ .get();
136
+ if (row) {
137
+ const mappings = JSON.parse(row.value);
138
+ return mappings[model] || null;
139
+ }
140
+ }
141
+ }
142
+ catch {
143
+ // Fall through to JSON fallback
144
+ }
145
+ // Fallback: read from db.json (legacy installs not yet migrated)
146
+ try {
147
+ if (fs.existsSync(DB_FILE)) {
148
+ const db = JSON.parse(fs.readFileSync(DB_FILE, "utf-8"));
149
+ return db.mitmAlias?.antigravity?.[model] || null;
150
+ }
151
+ }
152
+ catch {
153
+ // Ignore
154
+ }
155
+ return null;
156
+ }
157
+ async function passthrough(req, res, bodyBuffer) {
158
+ const targetIP = await resolveTargetIP();
159
+ // TLS validation is enabled by default. Set MITM_DISABLE_TLS_VERIFY=1 only
160
+ // in controlled local environments where the target uses a self-signed cert.
161
+ const rejectUnauthorized = process.env.MITM_DISABLE_TLS_VERIFY !== "1";
162
+ const forwardReq = https.request({
163
+ hostname: targetIP,
164
+ port: 443,
165
+ path: req.url,
166
+ method: req.method,
167
+ headers: { ...req.headers, host: TARGET_HOST },
168
+ servername: TARGET_HOST,
169
+ rejectUnauthorized,
170
+ }, (forwardRes) => {
171
+ res.writeHead(forwardRes.statusCode, forwardRes.headers);
172
+ forwardRes.pipe(res);
173
+ });
174
+ forwardReq.on("error", (err) => {
175
+ console.error(`❌ Passthrough error: ${err.message}`);
176
+ if (!res.headersSent)
177
+ res.writeHead(502);
178
+ res.end("Bad Gateway");
179
+ });
180
+ if (bodyBuffer.length > 0)
181
+ forwardReq.write(bodyBuffer);
182
+ forwardReq.end();
183
+ }
184
+ async function intercept(req, res, bodyBuffer, mappedModel) {
185
+ try {
186
+ const body = JSON.parse(bodyBuffer.toString());
187
+ body.model = mappedModel;
188
+ const response = await fetch(ROUTER_URL, {
189
+ method: "POST",
190
+ headers: {
191
+ "Content-Type": "application/json",
192
+ Authorization: `Bearer ${API_KEY}`,
193
+ },
194
+ body: JSON.stringify(body),
195
+ });
196
+ if (!response.ok) {
197
+ const errText = await response.text().catch(() => "");
198
+ throw new Error(`OmniRoute ${response.status}: ${errText}`);
199
+ }
200
+ res.writeHead(200, {
201
+ "Content-Type": "text/event-stream",
202
+ "Cache-Control": "no-cache",
203
+ Connection: "keep-alive",
204
+ "X-Accel-Buffering": "no",
205
+ });
206
+ const reader = response.body.getReader();
207
+ const decoder = new TextDecoder();
208
+ while (true) {
209
+ const { done, value } = await reader.read();
210
+ if (done) {
211
+ res.end();
212
+ break;
213
+ }
214
+ res.write(decoder.decode(value, { stream: true }));
215
+ }
216
+ }
217
+ catch (error) {
218
+ console.error(`❌ ${error.message}`);
219
+ if (!res.headersSent)
220
+ res.writeHead(500, { "Content-Type": "application/json" });
221
+ res.end(JSON.stringify({ error: { message: error.message, type: "mitm_error" } }));
222
+ }
223
+ }
224
+ const server = https.createServer(sslOptions, async (req, res) => {
225
+ const bodyBuffer = await collectBodyRaw(req);
226
+ // Save request log if enabled
227
+ if (bodyBuffer.length > 0)
228
+ saveRequestLog(req.url, bodyBuffer);
229
+ // Anti-loop: requests from OmniRoute bypass interception
230
+ if (req.headers["x-omniroute-source"] === "omniroute") {
231
+ return passthrough(req, res, bodyBuffer);
232
+ }
233
+ const isChatRequest = CHAT_URL_PATTERNS.some((p) => req.url.includes(p));
234
+ if (!isChatRequest) {
235
+ return passthrough(req, res, bodyBuffer);
236
+ }
237
+ const model = extractModel(bodyBuffer);
238
+ const mappedModel = getMappedModel(model);
239
+ if (!mappedModel) {
240
+ return passthrough(req, res, bodyBuffer);
241
+ }
242
+ console.log(`🔀 ${model} → ${mappedModel}`);
243
+ return intercept(req, res, bodyBuffer, mappedModel);
244
+ });
245
+ server.listen(LOCAL_PORT, () => {
246
+ console.log(`🚀 MITM ready on :${LOCAL_PORT} → ${ROUTER_URL}`);
247
+ });
248
+ server.on("error", (error) => {
249
+ if (error.code === "EADDRINUSE") {
250
+ console.error(`❌ Port ${LOCAL_PORT} already in use`);
251
+ }
252
+ else if (error.code === "EACCES") {
253
+ console.error(`❌ Permission denied for port ${LOCAL_PORT}`);
254
+ }
255
+ else {
256
+ console.error(`❌ ${error.message}`);
257
+ }
258
+ process.exit(1);
259
+ });
260
+ process.on("SIGTERM", () => {
261
+ server.close(() => process.exit(0));
262
+ });
263
+ process.on("SIGINT", () => {
264
+ server.close(() => process.exit(0));
265
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omniroute",
3
- "version": "2.3.13",
3
+ "version": "2.3.14",
4
4
  "description": "Smart AI Router with auto fallback — route to FREE & cheap models, zero downtime. Works with Cursor, Cline, Claude Desktop, Codex, and any OpenAI-compatible tool.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[410],{50910:(e,t,c)=>{"use strict";c.d(t,{c:()=>i});var a=c(33418);function n(e,t){return(...e)=>{try{return t(...e)}catch{throw Error(void 0)}}}let i=n(0,a.c3);n(0,a.kc)},67040:(e,t,c)=>{"use strict";function a(...e){return e.filter(Boolean).join(" ").replace(/\s+/g," ").trim()}c.d(t,{cn:()=>a})},73321:(e,t,c)=>{"use strict";var a=c(74645);c.o(a,"useParams")&&c.d(t,{useParams:function(){return a.useParams}}),c.o(a,"usePathname")&&c.d(t,{usePathname:function(){return a.usePathname}}),c.o(a,"useRouter")&&c.d(t,{useRouter:function(){return a.useRouter}}),c.o(a,"useSearchParams")&&c.d(t,{useSearchParams:function(){return a.useSearchParams}})},81060:(e,t,c)=>{"use strict";c.d(t,{default:()=>i});var a=c(95155),n=c(67040);function i({children:e,title:t,subtitle:c,icon:i,action:o,padding:r="md",hover:s=!1,className:u,...d}){return(0,a.jsxs)("div",{className:(0,n.cn)("bg-surface","border border-black/5 dark:border-white/5","rounded-lg shadow-sm",s&&"hover:shadow-md hover:border-primary/30 transition-all cursor-pointer",{none:"",xs:"p-3",sm:"p-4",md:"p-6",lg:"p-8"}[r],u),...d,children:[(t||o)&&(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[i&&(0,a.jsx)("div",{className:"p-2 rounded-lg bg-bg text-text-muted",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:i})}),(0,a.jsxs)("div",{children:[t&&(0,a.jsx)("h3",{className:"text-text-main font-semibold",children:t}),c&&(0,a.jsx)("p",{className:"text-sm text-text-muted",children:c})]})]}),o]}),e]})}i.Section=function({children:e,className:t,...c}){return(0,a.jsx)("div",{className:(0,n.cn)("p-4 rounded-lg","bg-black/[0.02] dark:bg-white/[0.02]","border border-black/5 dark:border-white/5",t),...c,children:e})},i.Row=function({children:e,className:t,...c}){return(0,a.jsx)("div",{className:(0,n.cn)("p-3 -mx-3 px-3 transition-colors","border-b border-black/5 dark:border-white/5 last:border-b-0","hover:bg-black/[0.02] dark:hover:bg-white/[0.02]",t),...c,children:e})},i.ListItem=function({children:e,actions:t,className:c,...i}){return(0,a.jsxs)("div",{className:(0,n.cn)("group flex items-center justify-between p-3 -mx-3 px-3","border-b border-black/[0.03] dark:border-white/[0.03] last:border-b-0","hover:bg-black/[0.02] dark:hover:bg-white/[0.02]","transition-colors",c),...i,children:[(0,a.jsx)("div",{className:"flex-1 min-w-0",children:e}),t&&(0,a.jsx)("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 focus-within:opacity-100 transition-opacity",children:t})]})}},85109:(e,t,c)=>{Promise.resolve().then(c.bind(c,95204))},95204:(e,t,c)=>{"use strict";c.r(t),c.d(t,{default:()=>d});var a=c(95155),n=c(12115),i=c(73321),o=c(81060);let r={cc:{"claude-opus-4-5-20251101":{input:15,output:75,cached:7.5,reasoning:75,cache_creation:15},"claude-sonnet-4-5-20250929":{input:3,output:15,cached:1.5,reasoning:15,cache_creation:3},"claude-haiku-4-5-20251001":{input:.5,output:2.5,cached:.25,reasoning:2.5,cache_creation:.5}},cx:{"gpt-5.2-codex":{input:5,output:20,cached:2.5,reasoning:30,cache_creation:5},"gpt-5.2":{input:5,output:20,cached:2.5,reasoning:30,cache_creation:5},"gpt-5.1-codex-max":{input:8,output:32,cached:4,reasoning:48,cache_creation:8},"gpt-5.1-codex":{input:4,output:16,cached:2,reasoning:24,cache_creation:4},"gpt-5.1-codex-mini":{input:1.5,output:6,cached:.75,reasoning:9,cache_creation:1.5},"gpt-5.1":{input:4,output:16,cached:2,reasoning:24,cache_creation:4},"gpt-5-codex":{input:3,output:12,cached:1.5,reasoning:18,cache_creation:3},"gpt-5-codex-mini":{input:1,output:4,cached:.5,reasoning:6,cache_creation:1}},gc:{"gemini-3-flash-preview":{input:.5,output:3,cached:.03,reasoning:4.5,cache_creation:.5},"gemini-3-pro-preview":{input:2,output:12,cached:.25,reasoning:18,cache_creation:2},"gemini-2.5-pro":{input:2,output:12,cached:.25,reasoning:18,cache_creation:2},"gemini-2.5-flash":{input:.3,output:2.5,cached:.03,reasoning:3.75,cache_creation:.3},"gemini-2.5-flash-lite":{input:.15,output:1.25,cached:.015,reasoning:1.875,cache_creation:.15}},qw:{"qwen3-coder-plus":{input:1,output:4,cached:.5,reasoning:6,cache_creation:1},"qwen3-coder-next":{input:2,output:8,cached:1,reasoning:12,cache_creation:2},"qwen3-coder-flash":{input:.5,output:2,cached:.25,reasoning:3,cache_creation:.5},"vision-model":{input:1.5,output:6,cached:.75,reasoning:9,cache_creation:1.5}},if:{"qwen3-coder-plus":{input:1,output:4,cached:.5,reasoning:6,cache_creation:1},"kimi-k2":{input:1,output:4,cached:.5,reasoning:6,cache_creation:1},"kimi-k2-thinking":{input:1.5,output:6,cached:.75,reasoning:9,cache_creation:1.5},"deepseek-r1":{input:.75,output:3,cached:.375,reasoning:4.5,cache_creation:.75},"deepseek-v3.2-chat":{input:.5,output:2,cached:.25,reasoning:3,cache_creation:.5},"deepseek-v3.2-reasoner":{input:.75,output:3,cached:.375,reasoning:4.5,cache_creation:.75},"deepseek-3.1":{input:.27,output:1.1,cached:.07,reasoning:2.2,cache_creation:.27},"deepseek-3.2":{input:.27,output:1.1,cached:.07,reasoning:2.2,cache_creation:.27},"minimax-m2":{input:.5,output:2,cached:.25,reasoning:3,cache_creation:.5},"glm-4.6":{input:.5,output:2,cached:.25,reasoning:3,cache_creation:.5},"glm-4.7":{input:.75,output:3,cached:.375,reasoning:4.5,cache_creation:.75}},ag:{"gemini-3.1-pro-low":{input:2,output:12,cached:.25,reasoning:18,cache_creation:2},"gemini-3.1-pro-high":{input:4,output:18,cached:.5,reasoning:27,cache_creation:4},"gemini-3-flash":{input:.5,output:3,cached:.03,reasoning:4.5,cache_creation:.5},"claude-sonnet-4-6":{input:3,output:15,cached:.3,reasoning:22.5,cache_creation:3},"claude-opus-4-6-thinking":{input:5,output:25,cached:.5,reasoning:37.5,cache_creation:5},"gpt-oss-120b-medium":{input:.5,output:2,cached:.25,reasoning:3,cache_creation:.5}},gh:{"gpt-5":{input:3,output:12,cached:1.5,reasoning:18,cache_creation:3},"gpt-5-mini":{input:.75,output:3,cached:.375,reasoning:4.5,cache_creation:.75},"gpt-5.1-codex":{input:4,output:16,cached:2,reasoning:24,cache_creation:4},"gpt-5.1-codex-max":{input:8,output:32,cached:4,reasoning:48,cache_creation:8},"gpt-4.1":{input:2.5,output:10,cached:1.25,reasoning:15,cache_creation:2.5},"claude-4.5-sonnet":{input:3,output:15,cached:.3,reasoning:22.5,cache_creation:3},"claude-4.5-opus":{input:5,output:25,cached:.5,reasoning:37.5,cache_creation:5},"claude-4.5-haiku":{input:.5,output:2.5,cached:.05,reasoning:3.75,cache_creation:.5},"gemini-3-pro":{input:2,output:12,cached:.25,reasoning:18,cache_creation:2},"gemini-3-flash":{input:.5,output:3,cached:.03,reasoning:4.5,cache_creation:.5},"gemini-2.5-pro":{input:2,output:12,cached:.25,reasoning:18,cache_creation:2},"grok-code-fast-1":{input:.5,output:2,cached:.25,reasoning:3,cache_creation:.5}},openai:{"gpt-4o":{input:2.5,output:10,cached:1.25,reasoning:15,cache_creation:2.5},"gpt-4o-mini":{input:.15,output:.6,cached:.075,reasoning:.9,cache_creation:.15},"gpt-4-turbo":{input:10,output:30,cached:5,reasoning:45,cache_creation:10},o1:{input:15,output:60,cached:7.5,reasoning:90,cache_creation:15},"o1-mini":{input:3,output:12,cached:1.5,reasoning:18,cache_creation:3}},anthropic:{"claude-sonnet-4-20250514":{input:3,output:15,cached:1.5,reasoning:15,cache_creation:3},"claude-opus-4-20250514":{input:15,output:75,cached:7.5,reasoning:112.5,cache_creation:15},"claude-3-5-sonnet-20241022":{input:3,output:15,cached:1.5,reasoning:15,cache_creation:3}},gemini:{"gemini-3-pro-preview":{input:2,output:12,cached:.25,reasoning:18,cache_creation:2},"gemini-2.5-pro":{input:2,output:12,cached:.25,reasoning:18,cache_creation:2},"gemini-2.5-flash":{input:.3,output:2.5,cached:.03,reasoning:3.75,cache_creation:.3},"gemini-2.5-flash-lite":{input:.15,output:1.25,cached:.015,reasoning:1.875,cache_creation:.15}},openrouter:{auto:{input:2,output:8,cached:1,reasoning:12,cache_creation:2}},glm:{"glm-4.7":{input:.75,output:3,cached:.375,reasoning:4.5,cache_creation:.75},"glm-4.6":{input:.5,output:2,cached:.25,reasoning:3,cache_creation:.5},"glm-4.6v":{input:.75,output:3,cached:.375,reasoning:4.5,cache_creation:.75}},kimi:{"kimi-latest":{input:1,output:4,cached:.5,reasoning:6,cache_creation:1}},minimax:{"MiniMax-M2.1":{input:.5,output:2,cached:.25,reasoning:3,cache_creation:.5}},groq:{"openai/gpt-oss-120b":{input:0,output:0,cached:0,reasoning:0,cache_creation:0},"gpt-oss-120b":{input:0,output:0,cached:0,reasoning:0,cache_creation:0},"llama-3.3-70b-versatile":{input:0,output:0,cached:0,reasoning:0,cache_creation:0},"meta-llama/llama-4-maverick-17b-128e-instruct":{input:0,output:0,cached:0,reasoning:0,cache_creation:0},"qwen/qwen3-32b":{input:0,output:0,cached:0,reasoning:0,cache_creation:0}},blackbox:{"gpt-4o":{input:0,output:0,cached:0,reasoning:0,cache_creation:0},"gemini-2.5-flash":{input:0,output:0,cached:0,reasoning:0,cache_creation:0},"claude-sonnet-4":{input:0,output:0,cached:0,reasoning:0,cache_creation:0},"deepseek-v3":{input:0,output:0,cached:0,reasoning:0,cache_creation:0},blackboxai:{input:0,output:0,cached:0,reasoning:0,cache_creation:0},"blackboxai-pro":{input:0,output:0,cached:0,reasoning:0,cache_creation:0}},fireworks:{"accounts/fireworks/models/gpt-oss-120b":{input:0,output:0,cached:0,reasoning:0,cache_creation:0},"gpt-oss-120b":{input:0,output:0,cached:0,reasoning:0,cache_creation:0},"accounts/fireworks/models/deepseek-v3p1":{input:0,output:0,cached:0,reasoning:0,cache_creation:0},"accounts/fireworks/models/llama-v3p3-70b-instruct":{input:0,output:0,cached:0,reasoning:0,cache_creation:0},"accounts/fireworks/models/qwen3-235b-a22b":{input:0,output:0,cached:0,reasoning:0,cache_creation:0}},cerebras:{"gpt-oss-120b":{input:0,output:0,cached:0,reasoning:0,cache_creation:0},"zai-glm-4.7":{input:0,output:0,cached:0,reasoning:0,cache_creation:0},"llama-3.3-70b":{input:0,output:0,cached:0,reasoning:0,cache_creation:0},"llama-4-scout-17b-16e-instruct":{input:0,output:0,cached:0,reasoning:0,cache_creation:0},"qwen-3-235b-a22b-instruct-2507":{input:0,output:0,cached:0,reasoning:0,cache_creation:0},"qwen-3-32b":{input:0,output:0,cached:0,reasoning:0,cache_creation:0}},nvidia:{"openai/gpt-oss-120b":{input:0,output:0,cached:0,reasoning:0,cache_creation:0},"gpt-oss-120b":{input:0,output:0,cached:0,reasoning:0,cache_creation:0},"moonshotai/kimi-k2.5":{input:0,output:0,cached:0,reasoning:0,cache_creation:0},"z-ai/glm4.7":{input:0,output:0,cached:0,reasoning:0,cache_creation:0},"deepseek-ai/deepseek-v3.2":{input:0,output:0,cached:0,reasoning:0,cache_creation:0},"nvidia/llama-3.3-70b-instruct":{input:0,output:0,cached:0,reasoning:0,cache_creation:0},"meta/llama-4-maverick-17b-128e-instruct":{input:0,output:0,cached:0,reasoning:0,cache_creation:0},"deepseek/deepseek-r1":{input:0,output:0,cached:0,reasoning:0,cache_creation:0}},nebius:{"openai/gpt-oss-120b":{input:0,output:0,cached:0,reasoning:0,cache_creation:0},"gpt-oss-120b":{input:0,output:0,cached:0,reasoning:0,cache_creation:0},"meta-llama/Llama-3.3-70B-Instruct":{input:0,output:0,cached:0,reasoning:0,cache_creation:0}},siliconflow:{"openai/gpt-oss-120b":{input:0,output:0,cached:0,reasoning:0,cache_creation:0},"gpt-oss-120b":{input:0,output:0,cached:0,reasoning:0,cache_creation:0},"deepseek-ai/DeepSeek-V3.2":{input:0,output:0,cached:0,reasoning:0,cache_creation:0},"deepseek-ai/DeepSeek-V3.1":{input:0,output:0,cached:0,reasoning:0,cache_creation:0},"deepseek-ai/DeepSeek-R1":{input:0,output:0,cached:0,reasoning:0,cache_creation:0},"Qwen/Qwen3-235B-A22B-Instruct-2507":{input:0,output:0,cached:0,reasoning:0,cache_creation:0},"Qwen/Qwen3-Coder-480B-A35B-Instruct":{input:0,output:0,cached:0,reasoning:0,cache_creation:0},"Qwen/Qwen3-32B":{input:0,output:0,cached:0,reasoning:0,cache_creation:0},"moonshotai/Kimi-K2.5":{input:0,output:0,cached:0,reasoning:0,cache_creation:0},"zai-org/GLM-4.7":{input:0,output:0,cached:0,reasoning:0,cache_creation:0},"baidu/ERNIE-4.5-300B-A47B":{input:0,output:0,cached:0,reasoning:0,cache_creation:0}},hyperbolic:{"openai/gpt-oss-120b":{input:0,output:0,cached:0,reasoning:0,cache_creation:0},"gpt-oss-120b":{input:0,output:0,cached:0,reasoning:0,cache_creation:0},"Qwen/QwQ-32B":{input:0,output:0,cached:0,reasoning:0,cache_creation:0},"deepseek-ai/DeepSeek-R1":{input:0,output:0,cached:0,reasoning:0,cache_creation:0},"deepseek-ai/DeepSeek-V3":{input:0,output:0,cached:0,reasoning:0,cache_creation:0},"meta-llama/Llama-3.3-70B-Instruct":{input:0,output:0,cached:0,reasoning:0,cache_creation:0},"meta-llama/Llama-3.2-3B-Instruct":{input:0,output:0,cached:0,reasoning:0,cache_creation:0},"Qwen/Qwen2.5-72B-Instruct":{input:0,output:0,cached:0,reasoning:0,cache_creation:0},"Qwen/Qwen2.5-Coder-32B-Instruct":{input:0,output:0,cached:0,reasoning:0,cache_creation:0},"NousResearch/Hermes-3-Llama-3.1-70B":{input:0,output:0,cached:0,reasoning:0,cache_creation:0}},kiro:{"claude-sonnet-4.5":{input:3,output:15,cached:1.5,reasoning:15,cache_creation:3},"claude-haiku-4.5":{input:.5,output:2.5,cached:.25,reasoning:2.5,cache_creation:.5}}};function s({isOpen:e,onClose:t,onSave:c}){let[i,o]=(0,n.useState)({}),[s,u]=(0,n.useState)(!0),[d,p]=(0,n.useState)(!1);(0,n.useEffect)(()=>{e&&h()},[e]);let h=async()=>{u(!0);try{let e=await fetch("/api/pricing");if(e.ok){let t=await e.json();o(t)}else o(r)}catch(e){console.error("Failed to load pricing:",e),o(r)}finally{u(!1)}},l=async()=>{p(!0);try{let e=await fetch("/api/pricing",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(e.ok)c?.(),t();else{let t=await e.json();alert(`Failed to save pricing: ${t.error}`)}}catch(e){console.error("Failed to save pricing:",e),alert("Failed to save pricing")}finally{p(!1)}},g=async()=>{if(confirm("Reset all pricing to defaults? This cannot be undone."))try{(await fetch("/api/pricing",{method:"DELETE"})).ok&&o(r)}catch(e){console.error("Failed to reset pricing:",e),alert("Failed to reset pricing")}};if(!e)return null;let m=Object.keys(i).sort(),x=["input","output","cached","reasoning","cache_creation"];return(0,a.jsx)("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:(0,a.jsxs)("div",{className:"bg-bg-base border border-border rounded-lg shadow-xl max-w-6xl w-full max-h-[90vh] overflow-hidden flex flex-col",children:[(0,a.jsxs)("div",{className:"p-4 border-b border-border flex items-center justify-between",children:[(0,a.jsx)("h2",{className:"text-xl font-semibold",children:"Pricing Configuration"}),(0,a.jsx)("button",{onClick:t,className:"text-text-muted hover:text-text text-2xl leading-none",children:"\xd7"})]}),(0,a.jsx)("div",{className:"flex-1 overflow-auto p-4",children:s?(0,a.jsx)("div",{className:"text-center py-8 text-text-muted",children:"Loading pricing data..."}):(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)("div",{className:"bg-bg-subtle border border-border rounded-lg p-3 text-sm",children:[(0,a.jsx)("p",{className:"font-medium mb-1",children:"Pricing Rates Format"}),(0,a.jsxs)("p",{className:"text-text-muted",children:["All rates are in ",(0,a.jsx)("strong",{children:"dollars per million tokens"})," ($/1M tokens). Example: Input rate of 2.50 means $2.50 per 1,000,000 input tokens."]})]}),m.map(e=>{let t=Object.keys(i[e]).sort();return(0,a.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden",children:[(0,a.jsx)("div",{className:"bg-bg-subtle px-4 py-2 font-semibold text-sm",children:e.toUpperCase()}),(0,a.jsx)("div",{className:"overflow-x-auto",children:(0,a.jsxs)("table",{className:"w-full text-sm",children:[(0,a.jsx)("thead",{className:"bg-bg-hover text-text-muted uppercase text-xs",children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:"px-3 py-2 text-left",children:"Model"}),(0,a.jsx)("th",{className:"px-3 py-2 text-right",children:"Input"}),(0,a.jsx)("th",{className:"px-3 py-2 text-right",children:"Output"}),(0,a.jsx)("th",{className:"px-3 py-2 text-right",children:"Cached"}),(0,a.jsx)("th",{className:"px-3 py-2 text-right",children:"Reasoning"}),(0,a.jsx)("th",{className:"px-3 py-2 text-right",children:"Cache Creation"})]})}),(0,a.jsx)("tbody",{className:"divide-y divide-border",children:t.map(t=>(0,a.jsxs)("tr",{className:"hover:bg-bg-subtle/50",children:[(0,a.jsx)("td",{className:"px-3 py-2 font-medium",children:t}),x.map(c=>(0,a.jsx)("td",{className:"px-3 py-2",children:(0,a.jsx)("input",{type:"number",step:"0.01",min:"0",value:i[e][t][c]||0,onChange:a=>{let n;!isNaN(n=parseFloat(a.target.value))&&!(n<0)&&o(a=>{let i={...a};return i[e]||(i[e]={}),i[e][t]||(i[e][t]={}),i[e][t][c]=n,i})},className:"w-20 px-2 py-1 text-right bg-bg-base border border-border rounded focus:outline-none focus:border-primary"})},c))]},t))})]})})]},e)}),0===m.length&&(0,a.jsx)("div",{className:"text-center py-8 text-text-muted",children:"No pricing data available"})]})}),(0,a.jsxs)("div",{className:"p-4 border-t border-border flex items-center justify-between gap-2",children:[(0,a.jsx)("button",{onClick:g,className:"px-4 py-2 text-sm text-red-500 hover:bg-red-500/10 rounded border border-red-500/20 transition-colors",disabled:d,children:"Reset to Defaults"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)("button",{onClick:t,className:"px-4 py-2 text-sm text-text-muted hover:text-text border border-border rounded transition-colors",disabled:d,children:"Cancel"}),(0,a.jsx)("button",{onClick:l,className:"px-4 py-2 text-sm bg-primary text-white rounded hover:bg-primary/90 transition-colors disabled:opacity-50",disabled:d,children:d?"Saving...":"Save Changes"})]})]})]})})}var u=c(50910);function d(){(0,i.useRouter)();let[e,t]=(0,n.useState)(!1),[c,r]=(0,n.useState)(null),[d,p]=(0,n.useState)(!0),h=(0,u.c)("settings");(0,n.useEffect)(()=>{l()},[]);let l=async()=>{p(!0);try{let e=await fetch("/api/pricing");if(e.ok){let t=await e.json();r(t)}}catch(e){console.error("Failed to load pricing:",e)}finally{p(!1)}};return(0,a.jsxs)("div",{className:"max-w-6xl mx-auto p-6 space-y-6",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h1",{className:"text-3xl font-bold",children:h("pricingSettingsTitle")}),(0,a.jsx)("p",{className:"text-text-muted mt-1",children:h("modelPricingDesc")})]}),(0,a.jsx)("button",{onClick:()=>t(!0),className:"px-4 py-2 bg-primary text-white rounded hover:bg-primary/90 transition-colors",children:h("editPricing")})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[(0,a.jsxs)(o.default,{className:"p-4",children:[(0,a.jsx)("div",{className:"text-text-muted text-sm uppercase font-semibold",children:h("totalModels")}),(0,a.jsx)("div",{className:"text-2xl font-bold mt-1",children:d?"...":(()=>{if(!c)return 0;let e=0;for(let t in c)e+=Object.keys(c[t]).length;return e})()})]}),(0,a.jsxs)(o.default,{className:"p-4",children:[(0,a.jsx)("div",{className:"text-text-muted text-sm uppercase font-semibold",children:h("providers")}),(0,a.jsx)("div",{className:"text-2xl font-bold mt-1",children:d?"...":(!c?[]:Object.keys(c).sort()).length})]}),(0,a.jsxs)(o.default,{className:"p-4",children:[(0,a.jsx)("div",{className:"text-text-muted text-sm uppercase font-semibold",children:h("status")}),(0,a.jsx)("div",{className:"text-2xl font-bold mt-1 text-success",children:d?"...":h("active")})]})]}),(0,a.jsxs)(o.default,{className:"p-6",children:[(0,a.jsx)("h2",{className:"text-xl font-semibold mb-4",children:h("howPricingWorks")}),(0,a.jsxs)("div",{className:"space-y-3 text-sm text-text-muted",children:[(0,a.jsxs)("p",{children:[(0,a.jsxs)("strong",{children:[h("costCalculation"),":"]})," ",h("costCalculationDesc")]}),(0,a.jsxs)("p",{children:[(0,a.jsxs)("strong",{children:[h("pricingFormat"),":"]})," ",h("pricingFormatDesc")]}),(0,a.jsx)("p",{children:(0,a.jsxs)("strong",{children:[h("tokenTypes"),":"]})}),(0,a.jsxs)("ul",{className:"list-disc list-inside ml-4 space-y-1",children:[(0,a.jsxs)("li",{children:[(0,a.jsxs)("strong",{children:[h("input"),":"]})," ",h("inputTokenDesc")]}),(0,a.jsxs)("li",{children:[(0,a.jsxs)("strong",{children:[h("output"),":"]})," ",h("outputTokenDesc")]}),(0,a.jsxs)("li",{children:[(0,a.jsxs)("strong",{children:[h("cached"),":"]})," ",h("cachedTokenDesc")]}),(0,a.jsxs)("li",{children:[(0,a.jsxs)("strong",{children:[h("reasoning"),":"]})," ",h("reasoningTokenDesc")]}),(0,a.jsxs)("li",{children:[(0,a.jsxs)("strong",{children:[h("cacheCreation"),":"]})," ",h("cacheCreationTokenDesc")]})]}),(0,a.jsx)("p",{children:h("customPricingNote")})]})]}),(0,a.jsxs)(o.default,{className:"p-6",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,a.jsx)("h2",{className:"text-xl font-semibold",children:h("currentPricing")}),(0,a.jsx)("button",{onClick:()=>t(!0),className:"text-primary hover:underline text-sm",children:h("viewFullDetails")})]}),d?(0,a.jsx)("div",{className:"text-center py-4 text-text-muted",children:h("loadingPricing")}):c?(0,a.jsxs)("div",{className:"space-y-3",children:[Object.keys(c).slice(0,5).map(e=>(0,a.jsxs)("div",{className:"text-sm",children:[(0,a.jsxs)("span",{className:"font-semibold",children:[e.toUpperCase(),":"]})," ",(0,a.jsxs)("span",{className:"text-text-muted",children:[Object.keys(c[e]).length," ",h("models")]})]},e)),Object.keys(c).length>5&&(0,a.jsxs)("div",{className:"text-sm text-text-muted",children:["+ ",h("moreProviders",{count:Object.keys(c).length-5})]})]}):(0,a.jsx)("div",{className:"text-text-muted",children:h("noPricing")})]}),e&&(0,a.jsx)(s,{isOpen:e,onClose:()=>t(!1),onSave:()=>{l()}})]})}}},e=>{e.O(0,[3418,8441,3794,7358],()=>e(e.s=85109)),_N_E=e.O()}]);