ai-agent-router 0.2.2 → 0.2.4

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 (700) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-path-routes-manifest.json +4 -1
  3. package/.next/build/chunks/{[root-of-the-server]__6d51cb5d._.js → [root-of-the-server]__0iv9ksq._.js} +1 -1
  4. package/.next/build/chunks/[root-of-the-server]__0iv9ksq._.js.map +8 -0
  5. package/.next/build/chunks/{[root-of-the-server]__44695d76._.js → [root-of-the-server]__0rua-~2._.js} +30 -30
  6. package/.next/build/chunks/[root-of-the-server]__0rua-~2._.js.map +11 -0
  7. package/.next/build/chunks/{[turbopack-node]_transforms_postcss_ts_df7a5b11._.js → [turbopack-node]_transforms_postcss_ts_0nnejqq._.js} +2 -2
  8. package/.next/build/chunks/[turbopack]_runtime.js +155 -60
  9. package/.next/build/chunks/[turbopack]_runtime.js.map +6 -5
  10. package/.next/build/chunks/{node_modules_fe693df6._.js → node_modules_13sb.px._.js} +1 -1
  11. package/.next/build/chunks/{node_modules_fe693df6._.js.map → node_modules_13sb.px._.js.map} +42 -42
  12. package/.next/build/postcss.js +5 -5
  13. package/.next/build-manifest.json +8 -7
  14. package/.next/diagnostics/framework.json +1 -1
  15. package/.next/diagnostics/route-bundle-stats.json +93 -0
  16. package/.next/fallback-build-manifest.json +3 -2
  17. package/.next/images-manifest.json +1 -0
  18. package/.next/next-minimal-server.js.nft.json +1 -1
  19. package/.next/next-server.js.nft.json +1 -1
  20. package/.next/prerender-manifest.json +33 -9
  21. package/.next/required-server-files.js +18 -6
  22. package/.next/required-server-files.json +18 -6
  23. package/.next/routes-manifest.json +19 -0
  24. package/.next/server/app/_global-error/page/build-manifest.json +5 -5
  25. package/.next/server/app/_global-error/page.js +8 -9
  26. package/.next/server/app/_global-error/page.js.nft.json +1 -1
  27. package/.next/server/app/_global-error/page_client-reference-manifest.js +2 -1
  28. package/.next/server/app/_global-error.html +1 -2
  29. package/.next/server/app/_global-error.rsc +11 -9
  30. package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +2 -2
  31. package/.next/server/app/_global-error.segments/_full.segment.rsc +11 -9
  32. package/.next/server/app/_global-error.segments/_head.segment.rsc +3 -3
  33. package/.next/server/app/_global-error.segments/_index.segment.rsc +4 -3
  34. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  35. package/.next/server/app/_not-found/page/build-manifest.json +5 -5
  36. package/.next/server/app/_not-found/page.js +11 -12
  37. package/.next/server/app/_not-found/page.js.nft.json +1 -1
  38. package/.next/server/app/_not-found/page_client-reference-manifest.js +2 -1
  39. package/.next/server/app/_not-found.html +1 -1
  40. package/.next/server/app/_not-found.rsc +13 -11
  41. package/.next/server/app/_not-found.segments/_full.segment.rsc +13 -11
  42. package/.next/server/app/_not-found.segments/_head.segment.rsc +3 -3
  43. package/.next/server/app/_not-found.segments/_index.segment.rsc +5 -5
  44. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
  45. package/.next/server/app/_not-found.segments/_not-found.segment.rsc +4 -3
  46. package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  47. package/.next/server/app/api/config/route/build-manifest.json +1 -3
  48. package/.next/server/app/api/config/route.js +4 -4
  49. package/.next/server/app/api/config/route.js.nft.json +1 -1
  50. package/.next/server/app/api/config/route_client-reference-manifest.js +2 -1
  51. package/.next/server/app/api/gateway/[...path]/route/build-manifest.json +1 -3
  52. package/.next/server/app/api/gateway/[...path]/route.js +5 -5
  53. package/.next/server/app/api/gateway/[...path]/route.js.nft.json +1 -1
  54. package/.next/server/app/api/gateway/[...path]/route_client-reference-manifest.js +2 -1
  55. package/.next/server/app/api/gateway/models/route/build-manifest.json +1 -3
  56. package/.next/server/app/api/gateway/models/route.js +4 -4
  57. package/.next/server/app/api/gateway/models/route.js.nft.json +1 -1
  58. package/.next/server/app/api/gateway/models/route_client-reference-manifest.js +2 -1
  59. package/.next/server/app/api/gateway/route/build-manifest.json +1 -3
  60. package/.next/server/app/api/gateway/route.js +5 -5
  61. package/.next/server/app/api/gateway/route.js.nft.json +1 -1
  62. package/.next/server/app/api/gateway/route_client-reference-manifest.js +2 -1
  63. package/.next/server/app/api/ide/claude/apply/route/build-manifest.json +1 -3
  64. package/.next/server/app/api/ide/claude/apply/route.js +4 -4
  65. package/.next/server/app/api/ide/claude/apply/route.js.nft.json +1 -1
  66. package/.next/server/app/api/ide/claude/apply/route_client-reference-manifest.js +2 -1
  67. package/.next/server/app/api/ide/claude/available-models/route/build-manifest.json +1 -3
  68. package/.next/server/app/api/ide/claude/available-models/route.js +4 -4
  69. package/.next/server/app/api/ide/claude/available-models/route.js.nft.json +1 -1
  70. package/.next/server/app/api/ide/claude/available-models/route_client-reference-manifest.js +2 -1
  71. package/.next/server/app/api/ide/claude/restore/route/build-manifest.json +1 -3
  72. package/.next/server/app/api/ide/claude/restore/route.js +3 -3
  73. package/.next/server/app/api/ide/claude/restore/route.js.nft.json +1 -1
  74. package/.next/server/app/api/ide/claude/restore/route_client-reference-manifest.js +2 -1
  75. package/.next/server/app/api/ide/claude/save/route/build-manifest.json +1 -3
  76. package/.next/server/app/api/ide/claude/save/route.js +4 -4
  77. package/.next/server/app/api/ide/claude/save/route.js.nft.json +1 -1
  78. package/.next/server/app/api/ide/claude/save/route_client-reference-manifest.js +2 -1
  79. package/.next/server/app/api/ide/claude/status/route/build-manifest.json +1 -3
  80. package/.next/server/app/api/ide/claude/status/route.js +4 -4
  81. package/.next/server/app/api/ide/claude/status/route.js.nft.json +1 -1
  82. package/.next/server/app/api/ide/claude/status/route_client-reference-manifest.js +2 -1
  83. package/.next/server/app/api/ide/claude/test/route/build-manifest.json +1 -3
  84. package/.next/server/app/api/ide/claude/test/route.js +5 -5
  85. package/.next/server/app/api/ide/claude/test/route.js.nft.json +1 -1
  86. package/.next/server/app/api/ide/claude/test/route_client-reference-manifest.js +2 -1
  87. package/.next/server/app/api/ide/openclaw/apply/route/build-manifest.json +1 -3
  88. package/.next/server/app/api/ide/openclaw/apply/route.js +4 -4
  89. package/.next/server/app/api/ide/openclaw/apply/route.js.nft.json +1 -1
  90. package/.next/server/app/api/ide/openclaw/apply/route_client-reference-manifest.js +2 -1
  91. package/.next/server/app/api/ide/openclaw/available-models/route/build-manifest.json +1 -3
  92. package/.next/server/app/api/ide/openclaw/available-models/route.js +4 -4
  93. package/.next/server/app/api/ide/openclaw/available-models/route.js.nft.json +1 -1
  94. package/.next/server/app/api/ide/openclaw/available-models/route_client-reference-manifest.js +2 -1
  95. package/.next/server/app/api/ide/openclaw/preview/route/build-manifest.json +1 -3
  96. package/.next/server/app/api/ide/openclaw/preview/route.js +4 -4
  97. package/.next/server/app/api/ide/openclaw/preview/route.js.nft.json +1 -1
  98. package/.next/server/app/api/ide/openclaw/preview/route_client-reference-manifest.js +2 -1
  99. package/.next/server/app/api/ide/openclaw/restore/route/build-manifest.json +1 -3
  100. package/.next/server/app/api/ide/openclaw/restore/route.js +3 -3
  101. package/.next/server/app/api/ide/openclaw/restore/route.js.nft.json +1 -1
  102. package/.next/server/app/api/ide/openclaw/restore/route_client-reference-manifest.js +2 -1
  103. package/.next/server/app/api/ide/openclaw/save/route/build-manifest.json +1 -3
  104. package/.next/server/app/api/ide/openclaw/save/route.js +4 -4
  105. package/.next/server/app/api/ide/openclaw/save/route.js.nft.json +1 -1
  106. package/.next/server/app/api/ide/openclaw/save/route_client-reference-manifest.js +2 -1
  107. package/.next/server/app/api/ide/openclaw/status/route/build-manifest.json +1 -3
  108. package/.next/server/app/api/ide/openclaw/status/route.js +4 -4
  109. package/.next/server/app/api/ide/openclaw/status/route.js.nft.json +1 -1
  110. package/.next/server/app/api/ide/openclaw/status/route_client-reference-manifest.js +2 -1
  111. package/.next/server/app/api/ide/openclaw/test/route/build-manifest.json +1 -3
  112. package/.next/server/app/api/ide/openclaw/test/route.js +3 -3
  113. package/.next/server/app/api/ide/openclaw/test/route.js.nft.json +1 -1
  114. package/.next/server/app/api/ide/openclaw/test/route_client-reference-manifest.js +2 -1
  115. package/.next/server/app/api/ide/opencode/apply/route/build-manifest.json +1 -3
  116. package/.next/server/app/api/ide/opencode/apply/route.js +4 -4
  117. package/.next/server/app/api/ide/opencode/apply/route.js.nft.json +1 -1
  118. package/.next/server/app/api/ide/opencode/apply/route_client-reference-manifest.js +2 -1
  119. package/.next/server/app/api/ide/opencode/available-models/route/build-manifest.json +1 -3
  120. package/.next/server/app/api/ide/opencode/available-models/route.js +4 -4
  121. package/.next/server/app/api/ide/opencode/available-models/route.js.nft.json +1 -1
  122. package/.next/server/app/api/ide/opencode/available-models/route_client-reference-manifest.js +2 -1
  123. package/.next/server/app/api/ide/opencode/preview/route/build-manifest.json +1 -3
  124. package/.next/server/app/api/ide/opencode/preview/route.js +4 -4
  125. package/.next/server/app/api/ide/opencode/preview/route.js.nft.json +1 -1
  126. package/.next/server/app/api/ide/opencode/preview/route_client-reference-manifest.js +2 -1
  127. package/.next/server/app/api/ide/opencode/restore/route/build-manifest.json +1 -3
  128. package/.next/server/app/api/ide/opencode/restore/route.js +3 -3
  129. package/.next/server/app/api/ide/opencode/restore/route.js.nft.json +1 -1
  130. package/.next/server/app/api/ide/opencode/restore/route_client-reference-manifest.js +2 -1
  131. package/.next/server/app/api/ide/opencode/save/route/build-manifest.json +1 -3
  132. package/.next/server/app/api/ide/opencode/save/route.js +4 -4
  133. package/.next/server/app/api/ide/opencode/save/route.js.nft.json +1 -1
  134. package/.next/server/app/api/ide/opencode/save/route_client-reference-manifest.js +2 -1
  135. package/.next/server/app/api/ide/opencode/status/route/build-manifest.json +1 -3
  136. package/.next/server/app/api/ide/opencode/status/route.js +4 -4
  137. package/.next/server/app/api/ide/opencode/status/route.js.nft.json +1 -1
  138. package/.next/server/app/api/ide/opencode/status/route_client-reference-manifest.js +2 -1
  139. package/.next/server/app/api/ide/opencode/test/route/build-manifest.json +1 -3
  140. package/.next/server/app/api/ide/opencode/test/route.js +3 -3
  141. package/.next/server/app/api/ide/opencode/test/route.js.nft.json +1 -1
  142. package/.next/server/app/api/ide/opencode/test/route_client-reference-manifest.js +2 -1
  143. package/.next/server/app/api/logs/route/build-manifest.json +1 -3
  144. package/.next/server/app/api/logs/route.js +4 -4
  145. package/.next/server/app/api/logs/route.js.nft.json +1 -1
  146. package/.next/server/app/api/logs/route_client-reference-manifest.js +2 -1
  147. package/.next/server/app/api/models/route/build-manifest.json +1 -3
  148. package/.next/server/app/api/models/route.js +5 -5
  149. package/.next/server/app/api/models/route.js.nft.json +1 -1
  150. package/.next/server/app/api/models/route_client-reference-manifest.js +2 -1
  151. package/.next/server/app/api/providers/route/build-manifest.json +1 -3
  152. package/.next/server/app/api/providers/route.js +5 -5
  153. package/.next/server/app/api/providers/route.js.nft.json +1 -1
  154. package/.next/server/app/api/providers/route_client-reference-manifest.js +2 -1
  155. package/.next/server/app/api/providers/test/route/build-manifest.json +1 -3
  156. package/.next/server/app/api/providers/test/route.js +5 -5
  157. package/.next/server/app/api/providers/test/route.js.nft.json +1 -1
  158. package/.next/server/app/api/providers/test/route_client-reference-manifest.js +2 -1
  159. package/.next/server/app/api/service/force-stop/route/build-manifest.json +1 -3
  160. package/.next/server/app/api/service/force-stop/route.js +4 -4
  161. package/.next/server/app/api/service/force-stop/route.js.nft.json +1 -1
  162. package/.next/server/app/api/service/force-stop/route_client-reference-manifest.js +2 -1
  163. package/.next/server/app/api/service/start/route/build-manifest.json +1 -3
  164. package/.next/server/app/api/service/start/route.js +4 -4
  165. package/.next/server/app/api/service/start/route.js.nft.json +1 -1
  166. package/.next/server/app/api/service/start/route_client-reference-manifest.js +2 -1
  167. package/.next/server/app/api/service/status/route/build-manifest.json +1 -3
  168. package/.next/server/app/api/service/status/route.js +4 -4
  169. package/.next/server/app/api/service/status/route.js.nft.json +1 -1
  170. package/.next/server/app/api/service/status/route_client-reference-manifest.js +2 -1
  171. package/.next/server/app/api/service/stop/route/build-manifest.json +1 -3
  172. package/.next/server/app/api/service/stop/route.js +4 -4
  173. package/.next/server/app/api/service/stop/route.js.nft.json +1 -1
  174. package/.next/server/app/api/service/stop/route_client-reference-manifest.js +2 -1
  175. package/.next/server/app/api/tokenizer/history/route/app-paths-manifest.json +3 -0
  176. package/.next/server/app/api/tokenizer/history/route/build-manifest.json +9 -0
  177. package/.next/server/app/api/tokenizer/history/route/server-reference-manifest.json +4 -0
  178. package/.next/server/app/api/tokenizer/history/route.js +7 -0
  179. package/.next/server/app/api/tokenizer/history/route.js.map +5 -0
  180. package/.next/server/app/api/tokenizer/history/route.js.nft.json +1 -0
  181. package/.next/server/app/api/tokenizer/history/route_client-reference-manifest.js +3 -0
  182. package/.next/server/app/api/tokenizer/test/route/app-paths-manifest.json +3 -0
  183. package/.next/server/app/api/tokenizer/test/route/build-manifest.json +9 -0
  184. package/.next/server/app/api/tokenizer/test/route/server-reference-manifest.json +4 -0
  185. package/.next/server/app/api/tokenizer/test/route.js +8 -0
  186. package/.next/server/app/api/tokenizer/test/route.js.map +5 -0
  187. package/.next/server/app/api/tokenizer/test/route.js.nft.json +1 -0
  188. package/.next/server/app/api/tokenizer/test/route_client-reference-manifest.js +3 -0
  189. package/.next/server/app/ide/page/build-manifest.json +5 -5
  190. package/.next/server/app/ide/page.js +12 -14
  191. package/.next/server/app/ide/page.js.nft.json +1 -1
  192. package/.next/server/app/ide/page_client-reference-manifest.js +2 -1
  193. package/.next/server/app/ide.html +1 -1
  194. package/.next/server/app/ide.rsc +15 -13
  195. package/.next/server/app/ide.segments/_full.segment.rsc +15 -13
  196. package/.next/server/app/ide.segments/_head.segment.rsc +3 -3
  197. package/.next/server/app/ide.segments/_index.segment.rsc +5 -5
  198. package/.next/server/app/ide.segments/_tree.segment.rsc +2 -2
  199. package/.next/server/app/ide.segments/ide/__PAGE__.segment.rsc +4 -4
  200. package/.next/server/app/ide.segments/ide.segment.rsc +4 -3
  201. package/.next/server/app/index.html +1 -1
  202. package/.next/server/app/index.rsc +11 -11
  203. package/.next/server/app/index.segments/__PAGE__.segment.rsc +4 -4
  204. package/.next/server/app/index.segments/_full.segment.rsc +11 -11
  205. package/.next/server/app/index.segments/_head.segment.rsc +3 -3
  206. package/.next/server/app/index.segments/_index.segment.rsc +5 -5
  207. package/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  208. package/.next/server/app/logs/page/build-manifest.json +5 -5
  209. package/.next/server/app/logs/page.js +12 -14
  210. package/.next/server/app/logs/page.js.nft.json +1 -1
  211. package/.next/server/app/logs/page_client-reference-manifest.js +2 -1
  212. package/.next/server/app/logs.html +1 -1
  213. package/.next/server/app/logs.rsc +15 -13
  214. package/.next/server/app/logs.segments/_full.segment.rsc +15 -13
  215. package/.next/server/app/logs.segments/_head.segment.rsc +3 -3
  216. package/.next/server/app/logs.segments/_index.segment.rsc +5 -5
  217. package/.next/server/app/logs.segments/_tree.segment.rsc +2 -2
  218. package/.next/server/app/logs.segments/logs/__PAGE__.segment.rsc +4 -4
  219. package/.next/server/app/logs.segments/logs.segment.rsc +4 -3
  220. package/.next/server/app/models/page/build-manifest.json +5 -5
  221. package/.next/server/app/models/page.js +12 -14
  222. package/.next/server/app/models/page.js.nft.json +1 -1
  223. package/.next/server/app/models/page_client-reference-manifest.js +2 -1
  224. package/.next/server/app/models.html +1 -1
  225. package/.next/server/app/models.rsc +15 -13
  226. package/.next/server/app/models.segments/_full.segment.rsc +15 -13
  227. package/.next/server/app/models.segments/_head.segment.rsc +3 -3
  228. package/.next/server/app/models.segments/_index.segment.rsc +5 -5
  229. package/.next/server/app/models.segments/_tree.segment.rsc +2 -2
  230. package/.next/server/app/models.segments/models/__PAGE__.segment.rsc +4 -4
  231. package/.next/server/app/models.segments/models.segment.rsc +4 -3
  232. package/.next/server/app/page/build-manifest.json +5 -5
  233. package/.next/server/app/page.js +12 -14
  234. package/.next/server/app/page.js.nft.json +1 -1
  235. package/.next/server/app/page_client-reference-manifest.js +2 -1
  236. package/.next/server/app/providers/page/build-manifest.json +5 -5
  237. package/.next/server/app/providers/page.js +12 -14
  238. package/.next/server/app/providers/page.js.nft.json +1 -1
  239. package/.next/server/app/providers/page_client-reference-manifest.js +2 -1
  240. package/.next/server/app/providers.html +1 -1
  241. package/.next/server/app/providers.rsc +15 -13
  242. package/.next/server/app/providers.segments/_full.segment.rsc +15 -13
  243. package/.next/server/app/providers.segments/_head.segment.rsc +3 -3
  244. package/.next/server/app/providers.segments/_index.segment.rsc +5 -5
  245. package/.next/server/app/providers.segments/_tree.segment.rsc +2 -2
  246. package/.next/server/app/providers.segments/providers/__PAGE__.segment.rsc +4 -4
  247. package/.next/server/app/providers.segments/providers.segment.rsc +4 -3
  248. package/.next/server/app/tokenizer/page/app-paths-manifest.json +3 -0
  249. package/.next/server/app/tokenizer/page/build-manifest.json +16 -0
  250. package/.next/server/app/tokenizer/page/next-font-manifest.json +6 -0
  251. package/.next/server/app/tokenizer/page/react-loadable-manifest.json +1 -0
  252. package/.next/server/app/tokenizer/page/server-reference-manifest.json +4 -0
  253. package/.next/server/app/tokenizer/page.js +13 -0
  254. package/.next/server/app/tokenizer/page.js.map +5 -0
  255. package/.next/server/app/tokenizer/page.js.nft.json +1 -0
  256. package/.next/server/app/tokenizer/page_client-reference-manifest.js +3 -0
  257. package/.next/server/app/tokenizer.html +1 -0
  258. package/.next/server/app/tokenizer.meta +15 -0
  259. package/.next/server/app/tokenizer.rsc +20 -0
  260. package/.next/server/app/tokenizer.segments/_full.segment.rsc +20 -0
  261. package/.next/server/app/tokenizer.segments/_head.segment.rsc +5 -0
  262. package/.next/server/app/tokenizer.segments/_index.segment.rsc +6 -0
  263. package/.next/server/app/tokenizer.segments/_tree.segment.rsc +2 -0
  264. package/.next/server/app/tokenizer.segments/tokenizer/__PAGE__.segment.rsc +9 -0
  265. package/.next/server/app/tokenizer.segments/tokenizer.segment.rsc +5 -0
  266. package/.next/server/app-paths-manifest.json +4 -1
  267. package/.next/server/chunks/0zjb_server_app_api_ide_openclaw_available-models_route_actions_0.gjr6a.js +3 -0
  268. package/.next/server/chunks/0zjb_server_app_api_ide_opencode_available-models_route_actions_0poyhyk.js +3 -0
  269. package/.next/server/chunks/[root-of-the-server]__0-_5z3v._.js +3 -0
  270. package/.next/server/chunks/[root-of-the-server]__0-_5z3v._.js.map +1 -0
  271. package/.next/server/chunks/[root-of-the-server]__012ucp~._.js +3 -0
  272. package/.next/server/chunks/[root-of-the-server]__012ucp~._.js.map +1 -0
  273. package/.next/server/chunks/[root-of-the-server]__01atdgx._.js +3 -0
  274. package/.next/server/chunks/[root-of-the-server]__01atdgx._.js.map +1 -0
  275. package/.next/server/chunks/[root-of-the-server]__01~ft76._.js +3 -0
  276. package/.next/server/chunks/[root-of-the-server]__01~ft76._.js.map +1 -0
  277. package/.next/server/chunks/[root-of-the-server]__04sfkei._.js +3 -0
  278. package/.next/server/chunks/[root-of-the-server]__04sfkei._.js.map +1 -0
  279. package/.next/server/chunks/[root-of-the-server]__065r.wp._.js +3 -0
  280. package/.next/server/chunks/[root-of-the-server]__065r.wp._.js.map +1 -0
  281. package/.next/server/chunks/[root-of-the-server]__07pm7px._.js +3 -0
  282. package/.next/server/chunks/[root-of-the-server]__07pm7px._.js.map +1 -0
  283. package/.next/server/chunks/[root-of-the-server]__07vosna._.js +3 -0
  284. package/.next/server/chunks/[root-of-the-server]__07vosna._.js.map +1 -0
  285. package/.next/server/chunks/[root-of-the-server]__083j1v0._.js +3 -0
  286. package/.next/server/chunks/[root-of-the-server]__083j1v0._.js.map +1 -0
  287. package/.next/server/chunks/[root-of-the-server]__08_ekvs._.js +3 -0
  288. package/.next/server/chunks/[root-of-the-server]__08_ekvs._.js.map +1 -0
  289. package/.next/server/chunks/[root-of-the-server]__08ftz8n._.js +3 -0
  290. package/.next/server/chunks/[root-of-the-server]__08ftz8n._.js.map +1 -0
  291. package/.next/server/chunks/[root-of-the-server]__08oq8ma._.js +3 -0
  292. package/.next/server/chunks/[root-of-the-server]__08oq8ma._.js.map +1 -0
  293. package/.next/server/chunks/[root-of-the-server]__099b1my._.js +3 -0
  294. package/.next/server/chunks/[root-of-the-server]__099b1my._.js.map +1 -0
  295. package/.next/server/chunks/[root-of-the-server]__0aw-~h8._.js +3 -0
  296. package/.next/server/chunks/[root-of-the-server]__0aw-~h8._.js.map +1 -0
  297. package/.next/server/chunks/[root-of-the-server]__0dj43ut._.js +3 -0
  298. package/.next/server/chunks/[root-of-the-server]__0dj43ut._.js.map +1 -0
  299. package/.next/server/chunks/[root-of-the-server]__0efv_yh._.js +3 -0
  300. package/.next/server/chunks/[root-of-the-server]__0efv_yh._.js.map +1 -0
  301. package/.next/server/chunks/[root-of-the-server]__0el37wu._.js +7 -0
  302. package/.next/server/chunks/[root-of-the-server]__0el37wu._.js.map +1 -0
  303. package/.next/server/chunks/[root-of-the-server]__0g.1w-q._.js +3 -0
  304. package/.next/server/chunks/[root-of-the-server]__0g.1w-q._.js.map +1 -0
  305. package/.next/server/chunks/[root-of-the-server]__0im~-m7._.js +3 -0
  306. package/.next/server/chunks/[root-of-the-server]__0im~-m7._.js.map +1 -0
  307. package/.next/server/chunks/[root-of-the-server]__0jf1q27._.js +3 -0
  308. package/.next/server/chunks/[root-of-the-server]__0jf1q27._.js.map +1 -0
  309. package/.next/server/chunks/[root-of-the-server]__0kldv62._.js +3 -0
  310. package/.next/server/chunks/[root-of-the-server]__0kldv62._.js.map +1 -0
  311. package/.next/server/chunks/[root-of-the-server]__0lr16iw._.js +3 -0
  312. package/.next/server/chunks/[root-of-the-server]__0lr16iw._.js.map +1 -0
  313. package/.next/server/chunks/[root-of-the-server]__0m62mql._.js +3 -0
  314. package/.next/server/chunks/[root-of-the-server]__0m62mql._.js.map +1 -0
  315. package/.next/server/chunks/[root-of-the-server]__0qp1t_m._.js +3 -0
  316. package/.next/server/chunks/[root-of-the-server]__0qp1t_m._.js.map +1 -0
  317. package/.next/server/chunks/[root-of-the-server]__0qz-m.u._.js +3 -0
  318. package/.next/server/chunks/[root-of-the-server]__0qz-m.u._.js.map +1 -0
  319. package/.next/server/chunks/[root-of-the-server]__0r235yd._.js +3 -0
  320. package/.next/server/chunks/[root-of-the-server]__0r235yd._.js.map +1 -0
  321. package/.next/server/chunks/[root-of-the-server]__0rjkw2y._.js +3 -0
  322. package/.next/server/chunks/[root-of-the-server]__0rjkw2y._.js.map +1 -0
  323. package/.next/server/chunks/[root-of-the-server]__0uaqs.r._.js +3 -0
  324. package/.next/server/chunks/[root-of-the-server]__0uaqs.r._.js.map +1 -0
  325. package/.next/server/chunks/[root-of-the-server]__0vktxod._.js +3 -0
  326. package/.next/server/chunks/[root-of-the-server]__0vktxod._.js.map +1 -0
  327. package/.next/server/chunks/[root-of-the-server]__0vlh9um._.js +3 -0
  328. package/.next/server/chunks/[root-of-the-server]__0vlh9um._.js.map +1 -0
  329. package/.next/server/chunks/{[root-of-the-server]__c1b4b601._.js → [root-of-the-server]__0xb5i_t._.js} +21 -9
  330. package/.next/server/chunks/[root-of-the-server]__0xb5i_t._.js.map +1 -0
  331. package/.next/server/chunks/[root-of-the-server]__0xsal5d._.js +3 -0
  332. package/.next/server/chunks/[root-of-the-server]__0xsal5d._.js.map +1 -0
  333. package/.next/server/chunks/[root-of-the-server]__0yo.c6n._.js +3 -0
  334. package/.next/server/chunks/[root-of-the-server]__0yo.c6n._.js.map +1 -0
  335. package/.next/server/chunks/[root-of-the-server]__0yz0y4l._.js +13 -0
  336. package/.next/server/chunks/[root-of-the-server]__0yz0y4l._.js.map +1 -0
  337. package/.next/server/chunks/{[root-of-the-server]__e7623a6c._.js → [root-of-the-server]__11srlmi._.js} +2 -2
  338. package/.next/server/chunks/{[root-of-the-server]__e7623a6c._.js.map → [root-of-the-server]__11srlmi._.js.map} +1 -1
  339. package/.next/server/chunks/[root-of-the-server]__12d44rt._.js +3 -0
  340. package/.next/server/chunks/[root-of-the-server]__12d44rt._.js.map +1 -0
  341. package/.next/server/chunks/[turbopack]_runtime.js +168 -60
  342. package/.next/server/chunks/[turbopack]_runtime.js.map +6 -5
  343. package/.next/server/chunks/_0v0oe6c._.js +3 -0
  344. package/.next/server/chunks/{_b48847f5._.js.map → _0v0oe6c._.js.map} +1 -1
  345. package/.next/server/chunks/{_next-internal_server_app_api_config_route_actions_308a9f33.js → _next-internal_server_app_api_config_route_actions_08dm.dx.js} +1 -1
  346. package/.next/server/chunks/{_next-internal_server_app_api_gateway_[___path]_route_actions_835b2379.js → _next-internal_server_app_api_gateway_[___path]_route_actions_0mmqyo7.js} +1 -1
  347. package/.next/server/chunks/{_next-internal_server_app_api_gateway_models_route_actions_302c9983.js → _next-internal_server_app_api_gateway_models_route_actions_08b214z.js} +1 -1
  348. package/.next/server/chunks/{_next-internal_server_app_api_gateway_route_actions_e5e7405d.js → _next-internal_server_app_api_gateway_route_actions_0.jzdw1.js} +1 -1
  349. package/.next/server/chunks/{_next-internal_server_app_api_ide_claude_apply_route_actions_5056516c.js → _next-internal_server_app_api_ide_claude_apply_route_actions_0dw2_pf.js} +1 -1
  350. package/.next/server/chunks/{_next-internal_server_app_api_ide_claude_available-models_route_actions_94d710a0.js → _next-internal_server_app_api_ide_claude_available-models_route_actions_0pmwy75.js} +1 -1
  351. package/.next/server/chunks/{_next-internal_server_app_api_ide_claude_restore_route_actions_f37acc94.js → _next-internal_server_app_api_ide_claude_restore_route_actions_11x77hl.js} +1 -1
  352. package/.next/server/chunks/{_next-internal_server_app_api_ide_claude_save_route_actions_407c55f5.js → _next-internal_server_app_api_ide_claude_save_route_actions_0b35ro_.js} +1 -1
  353. package/.next/server/chunks/{_next-internal_server_app_api_ide_claude_status_route_actions_5ac73db8.js → _next-internal_server_app_api_ide_claude_status_route_actions_0fnw-w7.js} +1 -1
  354. package/.next/server/chunks/{_next-internal_server_app_api_ide_claude_test_route_actions_70587902.js → _next-internal_server_app_api_ide_claude_test_route_actions_0jc1czy.js} +1 -1
  355. package/.next/server/chunks/{_next-internal_server_app_api_ide_openclaw_apply_route_actions_2cb9e4b4.js → _next-internal_server_app_api_ide_openclaw_apply_route_actions_07re971.js} +1 -1
  356. package/.next/server/chunks/{_next-internal_server_app_api_ide_openclaw_preview_route_actions_9814a8e4.js → _next-internal_server_app_api_ide_openclaw_preview_route_actions_0q53p05.js} +1 -1
  357. package/.next/server/chunks/{_next-internal_server_app_api_ide_openclaw_restore_route_actions_10ad8f9d.js → _next-internal_server_app_api_ide_openclaw_restore_route_actions_02yog9-.js} +1 -1
  358. package/.next/server/chunks/{_next-internal_server_app_api_ide_openclaw_save_route_actions_044ad081.js → _next-internal_server_app_api_ide_openclaw_save_route_actions_00tjxsz.js} +1 -1
  359. package/.next/server/chunks/{_next-internal_server_app_api_ide_openclaw_status_route_actions_ed9786d2.js → _next-internal_server_app_api_ide_openclaw_status_route_actions_10wsun4.js} +1 -1
  360. package/.next/server/chunks/{_next-internal_server_app_api_ide_openclaw_test_route_actions_ce2cb808.js → _next-internal_server_app_api_ide_openclaw_test_route_actions_0zgwyon.js} +1 -1
  361. package/.next/server/chunks/{_next-internal_server_app_api_ide_opencode_apply_route_actions_6c422244.js → _next-internal_server_app_api_ide_opencode_apply_route_actions_0in-w.g.js} +1 -1
  362. package/.next/server/chunks/{_next-internal_server_app_api_ide_opencode_preview_route_actions_256c82e0.js → _next-internal_server_app_api_ide_opencode_preview_route_actions_06h6.w~.js} +1 -1
  363. package/.next/server/chunks/{_next-internal_server_app_api_ide_opencode_restore_route_actions_371993d3.js → _next-internal_server_app_api_ide_opencode_restore_route_actions_09ipt-l.js} +1 -1
  364. package/.next/server/chunks/{_next-internal_server_app_api_ide_opencode_save_route_actions_6e4c9c41.js → _next-internal_server_app_api_ide_opencode_save_route_actions_0i-~x79.js} +1 -1
  365. package/.next/server/chunks/{_next-internal_server_app_api_ide_opencode_status_route_actions_498ad77b.js → _next-internal_server_app_api_ide_opencode_status_route_actions_0cpf6rv.js} +1 -1
  366. package/.next/server/chunks/{_next-internal_server_app_api_ide_opencode_test_route_actions_c71be510.js → _next-internal_server_app_api_ide_opencode_test_route_actions_0y8aq8h.js} +1 -1
  367. package/.next/server/chunks/{_next-internal_server_app_api_logs_route_actions_30a87f47.js → _next-internal_server_app_api_logs_route_actions_08ef2j7.js} +1 -1
  368. package/.next/server/chunks/{_next-internal_server_app_api_models_route_actions_b6abdc83.js → _next-internal_server_app_api_models_route_actions_0vfccm4.js} +1 -1
  369. package/.next/server/chunks/{_next-internal_server_app_api_providers_route_actions_5388b373.js → _next-internal_server_app_api_providers_route_actions_0ee1p_m.js} +1 -1
  370. package/.next/server/chunks/{_next-internal_server_app_api_providers_test_route_actions_b97ab15a.js → _next-internal_server_app_api_providers_test_route_actions_0vyo652.js} +1 -1
  371. package/.next/server/chunks/{_next-internal_server_app_api_service_force-stop_route_actions_95eba80b.js → _next-internal_server_app_api_service_force-stop_route_actions_0pu9xrq.js} +1 -1
  372. package/.next/server/chunks/{_next-internal_server_app_api_service_start_route_actions_d50efb77.js → _next-internal_server_app_api_service_start_route_actions_0_o53a2.js} +1 -1
  373. package/.next/server/chunks/{_next-internal_server_app_api_service_status_route_actions_30149042.js → _next-internal_server_app_api_service_status_route_actions_08ag8v4.js} +1 -1
  374. package/.next/server/chunks/{_next-internal_server_app_api_service_stop_route_actions_19443941.js → _next-internal_server_app_api_service_stop_route_actions_04dp83p.js} +1 -1
  375. package/.next/server/chunks/_next-internal_server_app_api_tokenizer_history_route_actions_09~nqtd.js +3 -0
  376. package/.next/server/chunks/_next-internal_server_app_api_tokenizer_test_route_actions_0t2swp-.js +3 -0
  377. package/.next/server/chunks/{node_modules_next_dist_esm_build_templates_app-route_4be65264.js → node_modules_next_dist_esm_build_templates_app-route_0d1n5~u.js} +6 -6
  378. package/.next/server/chunks/node_modules_next_dist_esm_build_templates_app-route_0d1n5~u.js.map +1 -0
  379. package/.next/server/chunks/ssr/[root-of-the-server]__0.zquoa._.js +3 -0
  380. package/.next/server/chunks/ssr/[root-of-the-server]__0.zquoa._.js.map +1 -0
  381. package/.next/server/chunks/ssr/[root-of-the-server]__01dqyhh._.js +3 -0
  382. package/.next/server/chunks/ssr/[root-of-the-server]__01dqyhh._.js.map +1 -0
  383. package/.next/server/chunks/ssr/[root-of-the-server]__04qwc64._.js +3 -0
  384. package/.next/server/chunks/ssr/[root-of-the-server]__04qwc64._.js.map +1 -0
  385. package/.next/server/chunks/ssr/[root-of-the-server]__06r_ug4._.js +3 -0
  386. package/.next/server/chunks/ssr/[root-of-the-server]__06r_ug4._.js.map +1 -0
  387. package/.next/server/chunks/ssr/{[root-of-the-server]__f92001a5._.js → [root-of-the-server]__0814l01._.js} +2 -2
  388. package/.next/server/chunks/ssr/[root-of-the-server]__0814l01._.js.map +1 -0
  389. package/.next/server/chunks/ssr/[root-of-the-server]__0gb1hlj._.js +3 -0
  390. package/.next/server/chunks/ssr/[root-of-the-server]__0gb1hlj._.js.map +1 -0
  391. package/.next/server/chunks/ssr/[root-of-the-server]__0p8tmu2._.js +3 -0
  392. package/.next/server/chunks/ssr/[root-of-the-server]__0p8tmu2._.js.map +1 -0
  393. package/.next/server/chunks/ssr/[root-of-the-server]__0rf3.7n._.js +3 -0
  394. package/.next/server/chunks/ssr/[root-of-the-server]__0rf3.7n._.js.map +1 -0
  395. package/.next/server/chunks/ssr/[root-of-the-server]__0~6rwng._.js +33 -0
  396. package/.next/server/chunks/ssr/[root-of-the-server]__0~6rwng._.js.map +1 -0
  397. package/.next/server/chunks/ssr/[root-of-the-server]__10xgshr._.js +33 -0
  398. package/.next/server/chunks/ssr/[root-of-the-server]__10xgshr._.js.map +1 -0
  399. package/.next/server/chunks/ssr/[root-of-the-server]__11i~7lq._.js +3 -0
  400. package/.next/server/chunks/ssr/[root-of-the-server]__11i~7lq._.js.map +1 -0
  401. package/.next/server/chunks/ssr/[turbopack]_runtime.js +168 -60
  402. package/.next/server/chunks/ssr/[turbopack]_runtime.js.map +6 -5
  403. package/.next/server/chunks/ssr/_0k83omg._.js +6 -0
  404. package/.next/server/chunks/ssr/_0k83omg._.js.map +1 -0
  405. package/.next/server/chunks/ssr/_0yyi5po._.js +3 -0
  406. package/.next/server/chunks/ssr/_0yyi5po._.js.map +1 -0
  407. package/.next/server/chunks/ssr/{_next-internal_server_app__global-error_page_actions_75761787.js → _next-internal_server_app__global-error_page_actions_0k77kol.js} +1 -1
  408. package/.next/server/chunks/ssr/{_next-internal_server_app__not-found_page_actions_554ec2bf.js → _next-internal_server_app__not-found_page_actions_0eq97pa.js} +1 -1
  409. package/.next/server/chunks/ssr/{_next-internal_server_app_ide_page_actions_d521d6ae.js → _next-internal_server_app_ide_page_actions_0_opd4~.js} +1 -1
  410. package/.next/server/chunks/ssr/{_next-internal_server_app_logs_page_actions_a1c69041.js → _next-internal_server_app_logs_page_actions_0rvsl~d.js} +1 -1
  411. package/.next/server/chunks/ssr/{_next-internal_server_app_models_page_actions_543cf22f.js → _next-internal_server_app_models_page_actions_0eiz7f7.js} +1 -1
  412. package/.next/server/chunks/ssr/_next-internal_server_app_page_actions_09-gtaw.js +3 -0
  413. package/.next/server/chunks/ssr/_next-internal_server_app_page_actions_09-gtaw.js.map +1 -0
  414. package/.next/server/chunks/ssr/{_next-internal_server_app_providers_page_actions_c75f6cb3.js → _next-internal_server_app_providers_page_actions_0ya36nw.js} +1 -1
  415. package/.next/server/chunks/ssr/_next-internal_server_app_providers_page_actions_0ya36nw.js.map +1 -0
  416. package/.next/server/chunks/ssr/_next-internal_server_app_tokenizer_page_actions_0imc_ya.js +3 -0
  417. package/.next/server/chunks/ssr/_next-internal_server_app_tokenizer_page_actions_0imc_ya.js.map +1 -0
  418. package/.next/server/chunks/ssr/node_modules_09w7yel._.js +33 -0
  419. package/.next/server/chunks/ssr/node_modules_09w7yel._.js.map +1 -0
  420. package/.next/server/chunks/ssr/node_modules_next_dist_06hehg4._.js +19 -0
  421. package/.next/server/chunks/ssr/node_modules_next_dist_06hehg4._.js.map +1 -0
  422. package/.next/server/chunks/ssr/node_modules_next_dist_0e1izl_._.js +6 -0
  423. package/.next/server/chunks/ssr/node_modules_next_dist_0e1izl_._.js.map +1 -0
  424. package/.next/server/chunks/ssr/{node_modules_next_dist_client_components_9774470f._.js → node_modules_next_dist_client_components_0inhx6q._.js} +2 -2
  425. package/.next/server/chunks/ssr/{node_modules_next_dist_client_components_builtin_forbidden_45780354.js → node_modules_next_dist_client_components_builtin_forbidden_0ghu-f7.js} +2 -2
  426. package/.next/server/chunks/ssr/{node_modules_next_dist_client_components_builtin_global-error_ece394eb.js → node_modules_next_dist_client_components_builtin_global-error_0lgvd_..js} +2 -2
  427. package/.next/server/chunks/ssr/node_modules_next_dist_client_components_builtin_global-error_0lgvd_..js.map +1 -0
  428. package/.next/server/chunks/ssr/{node_modules_next_dist_client_components_builtin_unauthorized_15817684.js → node_modules_next_dist_client_components_builtin_unauthorized_0cjv-23.js} +2 -2
  429. package/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_05u.ff5.js +4 -0
  430. package/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_05u.ff5.js.map +1 -0
  431. package/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_06a5k-w.js +4 -0
  432. package/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_06a5k-w.js.map +1 -0
  433. package/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_0_rrdx6.js +4 -0
  434. package/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_0_rrdx6.js.map +1 -0
  435. package/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_0a7b~p7.js +4 -0
  436. package/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_0a7b~p7.js.map +1 -0
  437. package/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_0bj8dkg.js +4 -0
  438. package/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_0bj8dkg.js.map +1 -0
  439. package/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_0cvrgh7.js +4 -0
  440. package/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_0cvrgh7.js.map +1 -0
  441. package/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_0nkcfme.js +4 -0
  442. package/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_0nkcfme.js.map +1 -0
  443. package/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_0rc3ul_.js +4 -0
  444. package/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_0rc3ul_.js.map +1 -0
  445. package/.next/server/chunks/ssr/src_app_components_ConfirmDialog_tsx_0mm3plr._.js +3 -0
  446. package/.next/server/chunks/ssr/src_app_components_ConfirmDialog_tsx_0mm3plr._.js.map +1 -0
  447. package/.next/server/chunks/ssr/src_app_ide_page_tsx_0no40dj._.js +3 -0
  448. package/.next/server/chunks/ssr/{src_app_ide_page_tsx_8962793b._.js.map → src_app_ide_page_tsx_0no40dj._.js.map} +1 -1
  449. package/.next/server/chunks/ssr/src_app_logs_page_tsx_0l8mmxe._.js +3 -0
  450. package/.next/server/chunks/ssr/{src_app_logs_page_tsx_7b7b7b83._.js.map → src_app_logs_page_tsx_0l8mmxe._.js.map} +1 -1
  451. package/.next/server/chunks/ssr/src_app_models_page_tsx_10vsbc1._.js +3 -0
  452. package/.next/server/chunks/ssr/{src_app_models_page_tsx_ed71d32e._.js.map → src_app_models_page_tsx_10vsbc1._.js.map} +1 -1
  453. package/.next/server/chunks/ssr/src_app_page_tsx_0ss2.w7._.js +3 -0
  454. package/.next/server/chunks/ssr/src_app_page_tsx_0ss2.w7._.js.map +1 -0
  455. package/.next/server/chunks/ssr/src_app_providers_page_tsx_10ipz~8._.js +3 -0
  456. package/.next/server/chunks/ssr/{src_app_providers_page_tsx_eb8b5137._.js.map → src_app_providers_page_tsx_10ipz~8._.js.map} +1 -1
  457. package/.next/server/chunks/ssr/src_app_tokenizer_page_tsx_0eqhpbs._.js +3 -0
  458. package/.next/server/chunks/ssr/src_app_tokenizer_page_tsx_0eqhpbs._.js.map +1 -0
  459. package/.next/server/functions-config-manifest.json +3 -1
  460. package/.next/server/middleware-build-manifest.js +10 -10
  461. package/.next/server/pages/404.html +1 -1
  462. package/.next/server/pages/500.html +1 -2
  463. package/.next/server/prefetch-hints.json +1 -0
  464. package/.next/server/server-reference-manifest.js +1 -1
  465. package/.next/server/server-reference-manifest.json +1 -1
  466. package/.next/static/XHnu7Z1vWSrgmneps8rX4/_clientMiddlewareManifest.js +1 -0
  467. package/.next/static/chunks/01xlw8hd842-c.js +1 -0
  468. package/.next/static/chunks/0bzupvr5gt3k9.js +31 -0
  469. package/.next/static/chunks/0d3shmwh5_nmn.js +1 -0
  470. package/.next/static/chunks/0h7-_zr5_nt.5.js +1 -0
  471. package/.next/static/chunks/0mjx90nkvhsot.js +1 -0
  472. package/.next/static/chunks/0ntp1qkrtsgn0.js +1 -0
  473. package/.next/static/chunks/0tc5l6c1zalyc.css +1 -0
  474. package/.next/static/chunks/0v7.1nc4jyaet.js +1 -0
  475. package/.next/static/chunks/0vlwn301rv7dw.js +1 -0
  476. package/.next/static/chunks/0y3~cortx~or~.js +5 -0
  477. package/.next/static/chunks/0~c9fm3-3-f41.js +1 -0
  478. package/.next/static/chunks/11-7_fybhp2~y.js +1 -0
  479. package/.next/static/chunks/121-ofr4.6_5t.js +1 -0
  480. package/.next/static/chunks/16g.ca89g7fib.js +1 -0
  481. package/.next/static/chunks/turbopack-0griofc2i3wvs.js +1 -0
  482. package/.next/types/routes.d.ts +5 -2
  483. package/.next/types/validator.ts +27 -0
  484. package/CHANGELOG.md +15 -0
  485. package/README.md +6 -0
  486. package/dist/.next/dev/types/validator.js +12 -0
  487. package/dist/.next/types/validator.js +12 -0
  488. package/dist/package.json +3 -2
  489. package/dist/src/app/api/tokenizer/history/route.js +60 -0
  490. package/dist/src/app/api/tokenizer/test/route.js +97 -0
  491. package/dist/src/app/components/Nav.js +2 -1
  492. package/dist/src/app/tokenizer/page.js +318 -0
  493. package/dist/src/cli/index.js +3 -3
  494. package/dist/src/db/database.js +19 -21
  495. package/dist/src/db/queries.js +21 -0
  496. package/dist/src/server/tokenizer.js +215 -0
  497. package/package.json +3 -2
  498. package/src/app/api/tokenizer/history/route.ts +63 -0
  499. package/src/app/api/tokenizer/test/route.ts +151 -0
  500. package/src/app/components/Nav.tsx +2 -2
  501. package/src/app/tokenizer/page.tsx +813 -0
  502. package/src/cli/index.ts +4 -4
  503. package/src/db/database.ts +18 -25
  504. package/src/db/queries.ts +22 -0
  505. package/src/server/tokenizer.ts +285 -0
  506. package/.next/build/chunks/[root-of-the-server]__44695d76._.js.map +0 -11
  507. package/.next/build/chunks/[root-of-the-server]__6d51cb5d._.js.map +0 -8
  508. package/.next/server/chunks/[root-of-the-server]__001d5756._.js +0 -3
  509. package/.next/server/chunks/[root-of-the-server]__001d5756._.js.map +0 -1
  510. package/.next/server/chunks/[root-of-the-server]__05f8578b._.js +0 -3
  511. package/.next/server/chunks/[root-of-the-server]__05f8578b._.js.map +0 -1
  512. package/.next/server/chunks/[root-of-the-server]__1480f018._.js +0 -3
  513. package/.next/server/chunks/[root-of-the-server]__1480f018._.js.map +0 -1
  514. package/.next/server/chunks/[root-of-the-server]__1909f3aa._.js +0 -3
  515. package/.next/server/chunks/[root-of-the-server]__1909f3aa._.js.map +0 -1
  516. package/.next/server/chunks/[root-of-the-server]__1d4b7fc5._.js +0 -3
  517. package/.next/server/chunks/[root-of-the-server]__1d4b7fc5._.js.map +0 -1
  518. package/.next/server/chunks/[root-of-the-server]__33fec899._.js +0 -3
  519. package/.next/server/chunks/[root-of-the-server]__33fec899._.js.map +0 -1
  520. package/.next/server/chunks/[root-of-the-server]__372ef2bf._.js +0 -3
  521. package/.next/server/chunks/[root-of-the-server]__372ef2bf._.js.map +0 -1
  522. package/.next/server/chunks/[root-of-the-server]__3a204d25._.js +0 -3
  523. package/.next/server/chunks/[root-of-the-server]__3a204d25._.js.map +0 -1
  524. package/.next/server/chunks/[root-of-the-server]__3aaf963c._.js +0 -3
  525. package/.next/server/chunks/[root-of-the-server]__3aaf963c._.js.map +0 -1
  526. package/.next/server/chunks/[root-of-the-server]__43810962._.js +0 -3
  527. package/.next/server/chunks/[root-of-the-server]__43810962._.js.map +0 -1
  528. package/.next/server/chunks/[root-of-the-server]__4a8f9bc7._.js +0 -3
  529. package/.next/server/chunks/[root-of-the-server]__4a8f9bc7._.js.map +0 -1
  530. package/.next/server/chunks/[root-of-the-server]__55cd88b8._.js +0 -3
  531. package/.next/server/chunks/[root-of-the-server]__55cd88b8._.js.map +0 -1
  532. package/.next/server/chunks/[root-of-the-server]__59aacd30._.js +0 -21
  533. package/.next/server/chunks/[root-of-the-server]__59aacd30._.js.map +0 -1
  534. package/.next/server/chunks/[root-of-the-server]__5e8276bc._.js +0 -3
  535. package/.next/server/chunks/[root-of-the-server]__5e8276bc._.js.map +0 -1
  536. package/.next/server/chunks/[root-of-the-server]__64356cb2._.js +0 -3
  537. package/.next/server/chunks/[root-of-the-server]__64356cb2._.js.map +0 -1
  538. package/.next/server/chunks/[root-of-the-server]__6ce199d2._.js +0 -3
  539. package/.next/server/chunks/[root-of-the-server]__6ce199d2._.js.map +0 -1
  540. package/.next/server/chunks/[root-of-the-server]__760eaa16._.js +0 -3
  541. package/.next/server/chunks/[root-of-the-server]__760eaa16._.js.map +0 -1
  542. package/.next/server/chunks/[root-of-the-server]__772134c6._.js +0 -3
  543. package/.next/server/chunks/[root-of-the-server]__772134c6._.js.map +0 -1
  544. package/.next/server/chunks/[root-of-the-server]__7b77f523._.js +0 -3
  545. package/.next/server/chunks/[root-of-the-server]__7b77f523._.js.map +0 -1
  546. package/.next/server/chunks/[root-of-the-server]__7c298a19._.js +0 -3
  547. package/.next/server/chunks/[root-of-the-server]__7c298a19._.js.map +0 -1
  548. package/.next/server/chunks/[root-of-the-server]__85540228._.js +0 -3
  549. package/.next/server/chunks/[root-of-the-server]__85540228._.js.map +0 -1
  550. package/.next/server/chunks/[root-of-the-server]__94fe8d3c._.js +0 -3
  551. package/.next/server/chunks/[root-of-the-server]__94fe8d3c._.js.map +0 -1
  552. package/.next/server/chunks/[root-of-the-server]__97622908._.js +0 -3
  553. package/.next/server/chunks/[root-of-the-server]__97622908._.js.map +0 -1
  554. package/.next/server/chunks/[root-of-the-server]__a02e6618._.js +0 -3
  555. package/.next/server/chunks/[root-of-the-server]__a02e6618._.js.map +0 -1
  556. package/.next/server/chunks/[root-of-the-server]__a32a20a7._.js +0 -3
  557. package/.next/server/chunks/[root-of-the-server]__a32a20a7._.js.map +0 -1
  558. package/.next/server/chunks/[root-of-the-server]__a719d045._.js +0 -3
  559. package/.next/server/chunks/[root-of-the-server]__a719d045._.js.map +0 -1
  560. package/.next/server/chunks/[root-of-the-server]__af5b556a._.js +0 -3
  561. package/.next/server/chunks/[root-of-the-server]__af5b556a._.js.map +0 -1
  562. package/.next/server/chunks/[root-of-the-server]__c1b4b601._.js.map +0 -1
  563. package/.next/server/chunks/[root-of-the-server]__cafe113e._.js +0 -3
  564. package/.next/server/chunks/[root-of-the-server]__cafe113e._.js.map +0 -1
  565. package/.next/server/chunks/[root-of-the-server]__ccfc7f1d._.js +0 -3
  566. package/.next/server/chunks/[root-of-the-server]__ccfc7f1d._.js.map +0 -1
  567. package/.next/server/chunks/[root-of-the-server]__dc8b0bed._.js +0 -3
  568. package/.next/server/chunks/[root-of-the-server]__dc8b0bed._.js.map +0 -1
  569. package/.next/server/chunks/[root-of-the-server]__f0461b8d._.js +0 -3
  570. package/.next/server/chunks/[root-of-the-server]__f0461b8d._.js.map +0 -1
  571. package/.next/server/chunks/[root-of-the-server]__f8949f88._.js +0 -3
  572. package/.next/server/chunks/[root-of-the-server]__f8949f88._.js.map +0 -1
  573. package/.next/server/chunks/_b48847f5._.js +0 -3
  574. package/.next/server/chunks/ce889_server_app_api_ide_openclaw_available-models_route_actions_e568e70b.js +0 -3
  575. package/.next/server/chunks/ce889_server_app_api_ide_opencode_available-models_route_actions_95230db3.js +0 -3
  576. package/.next/server/chunks/node_modules_next_dist_esm_build_templates_app-route_4be65264.js.map +0 -1
  577. package/.next/server/chunks/ssr/[root-of-the-server]__083d944d._.js +0 -3
  578. package/.next/server/chunks/ssr/[root-of-the-server]__083d944d._.js.map +0 -1
  579. package/.next/server/chunks/ssr/[root-of-the-server]__15600e29._.js +0 -3
  580. package/.next/server/chunks/ssr/[root-of-the-server]__15600e29._.js.map +0 -1
  581. package/.next/server/chunks/ssr/[root-of-the-server]__1836f866._.js +0 -3
  582. package/.next/server/chunks/ssr/[root-of-the-server]__1836f866._.js.map +0 -1
  583. package/.next/server/chunks/ssr/[root-of-the-server]__256a03fe._.js +0 -3
  584. package/.next/server/chunks/ssr/[root-of-the-server]__256a03fe._.js.map +0 -1
  585. package/.next/server/chunks/ssr/[root-of-the-server]__31fde618._.js +0 -3
  586. package/.next/server/chunks/ssr/[root-of-the-server]__31fde618._.js.map +0 -1
  587. package/.next/server/chunks/ssr/[root-of-the-server]__523c120c._.js +0 -3
  588. package/.next/server/chunks/ssr/[root-of-the-server]__523c120c._.js.map +0 -1
  589. package/.next/server/chunks/ssr/[root-of-the-server]__70a81394._.js +0 -3
  590. package/.next/server/chunks/ssr/[root-of-the-server]__70a81394._.js.map +0 -1
  591. package/.next/server/chunks/ssr/[root-of-the-server]__81937253._.js +0 -3
  592. package/.next/server/chunks/ssr/[root-of-the-server]__81937253._.js.map +0 -1
  593. package/.next/server/chunks/ssr/[root-of-the-server]__976ad963._.js +0 -3
  594. package/.next/server/chunks/ssr/[root-of-the-server]__976ad963._.js.map +0 -1
  595. package/.next/server/chunks/ssr/[root-of-the-server]__af2ad6aa._.js +0 -3
  596. package/.next/server/chunks/ssr/[root-of-the-server]__af2ad6aa._.js.map +0 -1
  597. package/.next/server/chunks/ssr/[root-of-the-server]__b9356576._.js +0 -4
  598. package/.next/server/chunks/ssr/[root-of-the-server]__b9356576._.js.map +0 -1
  599. package/.next/server/chunks/ssr/[root-of-the-server]__ccb6a4da._.js +0 -3
  600. package/.next/server/chunks/ssr/[root-of-the-server]__ccb6a4da._.js.map +0 -1
  601. package/.next/server/chunks/ssr/[root-of-the-server]__cfa2d991._.js +0 -3
  602. package/.next/server/chunks/ssr/[root-of-the-server]__cfa2d991._.js.map +0 -1
  603. package/.next/server/chunks/ssr/[root-of-the-server]__f437da88._.js +0 -3
  604. package/.next/server/chunks/ssr/[root-of-the-server]__f437da88._.js.map +0 -1
  605. package/.next/server/chunks/ssr/[root-of-the-server]__f92001a5._.js.map +0 -1
  606. package/.next/server/chunks/ssr/_06262cbd._.js +0 -4
  607. package/.next/server/chunks/ssr/_06262cbd._.js.map +0 -1
  608. package/.next/server/chunks/ssr/_0cd72da5._.js +0 -4
  609. package/.next/server/chunks/ssr/_0cd72da5._.js.map +0 -1
  610. package/.next/server/chunks/ssr/_4828a6d2._.js +0 -4
  611. package/.next/server/chunks/ssr/_4828a6d2._.js.map +0 -1
  612. package/.next/server/chunks/ssr/_69468f4c._.js +0 -3
  613. package/.next/server/chunks/ssr/_69468f4c._.js.map +0 -1
  614. package/.next/server/chunks/ssr/_93850476._.js +0 -6
  615. package/.next/server/chunks/ssr/_93850476._.js.map +0 -1
  616. package/.next/server/chunks/ssr/_c1309523._.js +0 -4
  617. package/.next/server/chunks/ssr/_c1309523._.js.map +0 -1
  618. package/.next/server/chunks/ssr/_f7d273e3._.js +0 -4
  619. package/.next/server/chunks/ssr/_f7d273e3._.js.map +0 -1
  620. package/.next/server/chunks/ssr/_next-internal_server_app_page_actions_39d4fc33.js +0 -3
  621. package/.next/server/chunks/ssr/node_modules_next_dist_08570d7f._.js +0 -4
  622. package/.next/server/chunks/ssr/node_modules_next_dist_08570d7f._.js.map +0 -1
  623. package/.next/server/chunks/ssr/node_modules_next_dist_174ae28d._.js +0 -10
  624. package/.next/server/chunks/ssr/node_modules_next_dist_174ae28d._.js.map +0 -1
  625. package/.next/server/chunks/ssr/node_modules_next_dist_27457240._.js +0 -6
  626. package/.next/server/chunks/ssr/node_modules_next_dist_27457240._.js.map +0 -1
  627. package/.next/server/chunks/ssr/node_modules_next_dist_4b63a0e1._.js +0 -3
  628. package/.next/server/chunks/ssr/node_modules_next_dist_4b63a0e1._.js.map +0 -1
  629. package/.next/server/chunks/ssr/node_modules_next_dist_client_components_builtin_global-error_ece394eb.js.map +0 -1
  630. package/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_65a7265e.js +0 -4
  631. package/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_65a7265e.js.map +0 -1
  632. package/.next/server/chunks/ssr/node_modules_next_dist_f9713a08._.js +0 -3
  633. package/.next/server/chunks/ssr/node_modules_next_dist_f9713a08._.js.map +0 -1
  634. package/.next/server/chunks/ssr/src_app_ide_page_tsx_8962793b._.js +0 -3
  635. package/.next/server/chunks/ssr/src_app_logs_page_tsx_7b7b7b83._.js +0 -3
  636. package/.next/server/chunks/ssr/src_app_models_page_tsx_ed71d32e._.js +0 -3
  637. package/.next/server/chunks/ssr/src_app_providers_page_tsx_eb8b5137._.js +0 -3
  638. package/.next/static/cf2SWIkI5HVbnDjLExI42/_clientMiddlewareManifest.json +0 -1
  639. package/.next/static/chunks/5663c8696095f277.js +0 -1
  640. package/.next/static/chunks/64f547b3bcd3aef4.js +0 -1
  641. package/.next/static/chunks/6992685fe009e8fd.css +0 -1
  642. package/.next/static/chunks/6e0dee5b6681763c.js +0 -1
  643. package/.next/static/chunks/6f7efe5271343778.js +0 -1
  644. package/.next/static/chunks/75f76753fd97c8fd.js +0 -1
  645. package/.next/static/chunks/7c8b7cbb3339f139.js +0 -1
  646. package/.next/static/chunks/8ccc14e022ff6de3.js +0 -1
  647. package/.next/static/chunks/8cf1e5f00ebaea52.js +0 -1
  648. package/.next/static/chunks/a6dad97d9634a72d.js.map +0 -1
  649. package/.next/static/chunks/a7f539bf6487f4ff.js +0 -5
  650. package/.next/static/chunks/a89fdf03c5b0dfbd.js +0 -1
  651. package/.next/static/chunks/d2be314c3ece3fbe.js +0 -1
  652. package/.next/static/chunks/f2f58a7e93290fbb.js +0 -1
  653. package/.next/static/chunks/ff1a16fafef87110.js +0 -1
  654. package/.next/static/chunks/turbopack-fdb839c72e10c2ea.js +0 -4
  655. /package/.next/build/chunks/{[turbopack-node]_transforms_postcss_ts_df7a5b11._.js.map → [turbopack-node]_transforms_postcss_ts_0nnejqq._.js.map} +0 -0
  656. /package/.next/server/chunks/{_next-internal_server_app_api_config_route_actions_308a9f33.js.map → 0zjb_server_app_api_ide_openclaw_available-models_route_actions_0.gjr6a.js.map} +0 -0
  657. /package/.next/server/chunks/{_next-internal_server_app_api_gateway_[___path]_route_actions_835b2379.js.map → 0zjb_server_app_api_ide_opencode_available-models_route_actions_0poyhyk.js.map} +0 -0
  658. /package/.next/server/chunks/{_next-internal_server_app_api_gateway_models_route_actions_302c9983.js.map → _next-internal_server_app_api_config_route_actions_08dm.dx.js.map} +0 -0
  659. /package/.next/server/chunks/{_next-internal_server_app_api_gateway_route_actions_e5e7405d.js.map → _next-internal_server_app_api_gateway_[___path]_route_actions_0mmqyo7.js.map} +0 -0
  660. /package/.next/server/chunks/{_next-internal_server_app_api_ide_claude_apply_route_actions_5056516c.js.map → _next-internal_server_app_api_gateway_models_route_actions_08b214z.js.map} +0 -0
  661. /package/.next/server/chunks/{_next-internal_server_app_api_ide_claude_available-models_route_actions_94d710a0.js.map → _next-internal_server_app_api_gateway_route_actions_0.jzdw1.js.map} +0 -0
  662. /package/.next/server/chunks/{_next-internal_server_app_api_ide_claude_restore_route_actions_f37acc94.js.map → _next-internal_server_app_api_ide_claude_apply_route_actions_0dw2_pf.js.map} +0 -0
  663. /package/.next/server/chunks/{_next-internal_server_app_api_ide_claude_save_route_actions_407c55f5.js.map → _next-internal_server_app_api_ide_claude_available-models_route_actions_0pmwy75.js.map} +0 -0
  664. /package/.next/server/chunks/{_next-internal_server_app_api_ide_claude_status_route_actions_5ac73db8.js.map → _next-internal_server_app_api_ide_claude_restore_route_actions_11x77hl.js.map} +0 -0
  665. /package/.next/server/chunks/{_next-internal_server_app_api_ide_claude_test_route_actions_70587902.js.map → _next-internal_server_app_api_ide_claude_save_route_actions_0b35ro_.js.map} +0 -0
  666. /package/.next/server/chunks/{_next-internal_server_app_api_ide_openclaw_apply_route_actions_2cb9e4b4.js.map → _next-internal_server_app_api_ide_claude_status_route_actions_0fnw-w7.js.map} +0 -0
  667. /package/.next/server/chunks/{_next-internal_server_app_api_ide_openclaw_preview_route_actions_9814a8e4.js.map → _next-internal_server_app_api_ide_claude_test_route_actions_0jc1czy.js.map} +0 -0
  668. /package/.next/server/chunks/{_next-internal_server_app_api_ide_openclaw_restore_route_actions_10ad8f9d.js.map → _next-internal_server_app_api_ide_openclaw_apply_route_actions_07re971.js.map} +0 -0
  669. /package/.next/server/chunks/{_next-internal_server_app_api_ide_openclaw_save_route_actions_044ad081.js.map → _next-internal_server_app_api_ide_openclaw_preview_route_actions_0q53p05.js.map} +0 -0
  670. /package/.next/server/chunks/{_next-internal_server_app_api_ide_openclaw_status_route_actions_ed9786d2.js.map → _next-internal_server_app_api_ide_openclaw_restore_route_actions_02yog9-.js.map} +0 -0
  671. /package/.next/server/chunks/{_next-internal_server_app_api_ide_openclaw_test_route_actions_ce2cb808.js.map → _next-internal_server_app_api_ide_openclaw_save_route_actions_00tjxsz.js.map} +0 -0
  672. /package/.next/server/chunks/{_next-internal_server_app_api_ide_opencode_apply_route_actions_6c422244.js.map → _next-internal_server_app_api_ide_openclaw_status_route_actions_10wsun4.js.map} +0 -0
  673. /package/.next/server/chunks/{_next-internal_server_app_api_ide_opencode_preview_route_actions_256c82e0.js.map → _next-internal_server_app_api_ide_openclaw_test_route_actions_0zgwyon.js.map} +0 -0
  674. /package/.next/server/chunks/{_next-internal_server_app_api_ide_opencode_restore_route_actions_371993d3.js.map → _next-internal_server_app_api_ide_opencode_apply_route_actions_0in-w.g.js.map} +0 -0
  675. /package/.next/server/chunks/{_next-internal_server_app_api_ide_opencode_save_route_actions_6e4c9c41.js.map → _next-internal_server_app_api_ide_opencode_preview_route_actions_06h6.w~.js.map} +0 -0
  676. /package/.next/server/chunks/{_next-internal_server_app_api_ide_opencode_status_route_actions_498ad77b.js.map → _next-internal_server_app_api_ide_opencode_restore_route_actions_09ipt-l.js.map} +0 -0
  677. /package/.next/server/chunks/{_next-internal_server_app_api_ide_opencode_test_route_actions_c71be510.js.map → _next-internal_server_app_api_ide_opencode_save_route_actions_0i-~x79.js.map} +0 -0
  678. /package/.next/server/chunks/{_next-internal_server_app_api_logs_route_actions_30a87f47.js.map → _next-internal_server_app_api_ide_opencode_status_route_actions_0cpf6rv.js.map} +0 -0
  679. /package/.next/server/chunks/{_next-internal_server_app_api_models_route_actions_b6abdc83.js.map → _next-internal_server_app_api_ide_opencode_test_route_actions_0y8aq8h.js.map} +0 -0
  680. /package/.next/server/chunks/{_next-internal_server_app_api_providers_route_actions_5388b373.js.map → _next-internal_server_app_api_logs_route_actions_08ef2j7.js.map} +0 -0
  681. /package/.next/server/chunks/{_next-internal_server_app_api_providers_test_route_actions_b97ab15a.js.map → _next-internal_server_app_api_models_route_actions_0vfccm4.js.map} +0 -0
  682. /package/.next/server/chunks/{_next-internal_server_app_api_service_force-stop_route_actions_95eba80b.js.map → _next-internal_server_app_api_providers_route_actions_0ee1p_m.js.map} +0 -0
  683. /package/.next/server/chunks/{_next-internal_server_app_api_service_start_route_actions_d50efb77.js.map → _next-internal_server_app_api_providers_test_route_actions_0vyo652.js.map} +0 -0
  684. /package/.next/server/chunks/{_next-internal_server_app_api_service_status_route_actions_30149042.js.map → _next-internal_server_app_api_service_force-stop_route_actions_0pu9xrq.js.map} +0 -0
  685. /package/.next/server/chunks/{_next-internal_server_app_api_service_stop_route_actions_19443941.js.map → _next-internal_server_app_api_service_start_route_actions_0_o53a2.js.map} +0 -0
  686. /package/.next/server/chunks/{ce889_server_app_api_ide_openclaw_available-models_route_actions_e568e70b.js.map → _next-internal_server_app_api_service_status_route_actions_08ag8v4.js.map} +0 -0
  687. /package/.next/server/chunks/{ce889_server_app_api_ide_opencode_available-models_route_actions_95230db3.js.map → _next-internal_server_app_api_service_stop_route_actions_04dp83p.js.map} +0 -0
  688. /package/.next/server/chunks/{ssr/_next-internal_server_app__global-error_page_actions_75761787.js.map → _next-internal_server_app_api_tokenizer_history_route_actions_09~nqtd.js.map} +0 -0
  689. /package/.next/server/chunks/{ssr/_next-internal_server_app__not-found_page_actions_554ec2bf.js.map → _next-internal_server_app_api_tokenizer_test_route_actions_0t2swp-.js.map} +0 -0
  690. /package/.next/server/chunks/ssr/{_next-internal_server_app_ide_page_actions_d521d6ae.js.map → _next-internal_server_app__global-error_page_actions_0k77kol.js.map} +0 -0
  691. /package/.next/server/chunks/ssr/{_next-internal_server_app_logs_page_actions_a1c69041.js.map → _next-internal_server_app__not-found_page_actions_0eq97pa.js.map} +0 -0
  692. /package/.next/server/chunks/ssr/{_next-internal_server_app_models_page_actions_543cf22f.js.map → _next-internal_server_app_ide_page_actions_0_opd4~.js.map} +0 -0
  693. /package/.next/server/chunks/ssr/{_next-internal_server_app_page_actions_39d4fc33.js.map → _next-internal_server_app_logs_page_actions_0rvsl~d.js.map} +0 -0
  694. /package/.next/server/chunks/ssr/{_next-internal_server_app_providers_page_actions_c75f6cb3.js.map → _next-internal_server_app_models_page_actions_0eiz7f7.js.map} +0 -0
  695. /package/.next/server/chunks/ssr/{node_modules_next_dist_client_components_9774470f._.js.map → node_modules_next_dist_client_components_0inhx6q._.js.map} +0 -0
  696. /package/.next/server/chunks/ssr/{node_modules_next_dist_client_components_builtin_forbidden_45780354.js.map → node_modules_next_dist_client_components_builtin_forbidden_0ghu-f7.js.map} +0 -0
  697. /package/.next/server/chunks/ssr/{node_modules_next_dist_client_components_builtin_unauthorized_15817684.js.map → node_modules_next_dist_client_components_builtin_unauthorized_0cjv-23.js.map} +0 -0
  698. /package/.next/static/{cf2SWIkI5HVbnDjLExI42 → XHnu7Z1vWSrgmneps8rX4}/_buildManifest.js +0 -0
  699. /package/.next/static/{cf2SWIkI5HVbnDjLExI42 → XHnu7Z1vWSrgmneps8rX4}/_ssgManifest.js +0 -0
  700. /package/.next/static/chunks/{a6dad97d9634a72d.js → 03~yq9q893hmn.js} +0 -0
@@ -1,3 +1,3 @@
1
- module.exports=[93695,(e,t,s)=>{t.exports=e.x("next/dist/shared/lib/no-fallback-error.external.js",()=>require("next/dist/shared/lib/no-fallback-error.external.js"))},14747,(e,t,s)=>{t.exports=e.x("path",()=>require("path"))},70406,(e,t,s)=>{t.exports=e.x("next/dist/compiled/@opentelemetry/api",()=>require("next/dist/compiled/@opentelemetry/api"))},18622,(e,t,s)=>{t.exports=e.x("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js",()=>require("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js"))},56704,(e,t,s)=>{t.exports=e.x("next/dist/server/app-render/work-async-storage.external.js",()=>require("next/dist/server/app-render/work-async-storage.external.js"))},32319,(e,t,s)=>{t.exports=e.x("next/dist/server/app-render/work-unit-async-storage.external.js",()=>require("next/dist/server/app-render/work-unit-async-storage.external.js"))},24725,(e,t,s)=>{t.exports=e.x("next/dist/server/app-render/after-task-async-storage.external.js",()=>require("next/dist/server/app-render/after-task-async-storage.external.js"))},24361,(e,t,s)=>{t.exports=e.x("util",()=>require("util"))},33405,(e,t,s)=>{t.exports=e.x("child_process",()=>require("child_process"))},4446,(e,t,s)=>{t.exports=e.x("net",()=>require("net"))},77922,e=>{"use strict";var t=e.i(33405),s=e.i(24361),r=e.i(14747),a=e.i(97731),i=e.i(71560),o=e.i(4446);let l=(0,s.promisify)(t.exec),n=new class{gatewayProcess=null;isStarting=!1;async checkProcessExists(e){try{return await l(`ps -p ${e} -o pid=`),!0}catch{return!1}}async checkPortAvailable(e){return new Promise(t=>{let s=o.default.createServer();s.listen(e,()=>{s.once("close",()=>t(!0)),s.close()}),s.on("error",()=>{t(!1)})})}async getPidByPort(e){try{let{stdout:t}=await l(`lsof -ti:${e} 2>/dev/null || echo ''`),s=t.trim();if(s&&!isNaN(parseInt(s)))return parseInt(s);try{let{stdout:t}=await l(`netstat -tlnp 2>/dev/null | grep :${e} | awk '{print $7}' | cut -d'/' -f1 || echo ''`),s=t.trim();if(s&&!isNaN(parseInt(s)))return parseInt(s)}catch{}return null}catch{return null}}async forceKillProcess(e){try{try{process.kill(e,"SIGTERM"),await new Promise(e=>setTimeout(e,1e3))}catch{}if(await this.checkProcessExists(e))try{process.kill(e,"SIGKILL"),await new Promise(e=>setTimeout(e,500))}catch{}return!await this.checkProcessExists(e)}catch(t){return console.error(`Failed to kill process ${e}:`,t),!1}}async killProcessByPort(e){return this.forceKillProcessByPort(e)}async forceKillProcessByPort(e){let t=await this.getPidByPort(e);if(!t)return!0;console.log(`Found process ${t} using port ${e}, attempting to kill...`);let s=await this.forceKillProcess(t);return s?console.log(`Successfully killed process ${t}`):console.warn(`Failed to kill process ${t}`),s}async getStatus(){let e=await (0,a.getServiceStatus)();return e?"running"===e.status&&e.pid&&!await this.checkProcessExists(e.pid)?(await (0,a.updateServiceStatus)({status:"stopped",pid:null}),{status:"stopped"}):{status:e.status,port:e.port,pid:e.pid,started_at:e.started_at}:{status:"stopped"}}async start(e){if(this.isStarting)return{status:"stopped",error:"Service is already starting"};let s=await this.getStatus();if("running"===s.status&&s.port===e)return{status:"running",error:"Service is already running",port:s.port,pid:s.pid};if(!await this.checkPortAvailable(e)){if(console.log(`Port ${e} is in use, attempting to free it...`),await this.killProcessByPort(e),await new Promise(e=>setTimeout(e,1e3)),!await this.checkPortAvailable(e))return{status:"stopped",error:`Port ${e} is still in use after cleanup attempt`};console.log(`Port ${e} is now available`)}this.isStarting=!0;try{try{await (0,i.getDatabase)()}catch(e){return console.error("Failed to initialize database:",e),this.isStarting=!1,{status:"stopped",error:"Failed to initialize database"}}let s=r.default.join(process.cwd(),"dist","src","cli","gateway-server.js"),o=(0,t.spawn)(process.execPath,[s,"--port",e.toString()],{cwd:process.cwd(),stdio:["ignore","pipe","pipe"],env:{...process.env,NODE_ENV:"production"}});o.stdout&&o.stdout.on("data",e=>{process.stdout.write(`[Gateway] ${e}`)}),o.stderr&&o.stderr.on("data",e=>{process.stderr.write(`[Gateway Error] ${e}`)}),o.on("exit",async e=>{console.log(`Gateway process exited with code ${e}`),this.gatewayProcess===o&&(this.gatewayProcess=null,await (0,a.updateServiceStatus)({status:"stopped",pid:null}))}),o.on("error",e=>{console.error(`Failed to start gateway process: ${e.message}`)}),this.gatewayProcess=o;let l=o.pid||null,n=new Date().toISOString();return await (0,a.setServiceStatus)({status:"running",port:e,pid:l,started_at:n}),this.isStarting=!1,console.log(`Gateway server started on port ${e} (PID: ${l})`),{status:"running",port:e,pid:l,started_at:n}}catch(e){return this.isStarting=!1,this.gatewayProcess=null,console.error(`Failed to start gateway service: ${e.message}`),{status:"stopped",error:e.message||"Failed to start service"}}}async stop(){let e=await this.getStatus();if("stopped"===e.status)return{status:"stopped"};let t=e.port||parseInt((await (0,a.getConfig)("port"))?.value||"1357");try{if(this.gatewayProcess&&this.gatewayProcess.pid){let e=this.gatewayProcess.pid;console.log(`Attempting to kill gateway process (PID: ${e})`);try{process.kill(e,"SIGTERM"),console.log(`Sent SIGTERM to process ${e}`),await new Promise(e=>setTimeout(e,1e3))}catch(t){"ESRCH"===t.code?console.log(`Process ${e} already dead (ESRCH)`):console.log(`SIGTERM failed for process ${e}: ${t.message}`)}if(await this.checkProcessExists(e)){console.log(`Process ${e} still exists after SIGTERM, sending SIGKILL`);try{process.kill(e,"SIGKILL"),await new Promise(e=>setTimeout(e,500))}catch(t){"ESRCH"===t.code?console.log(`Process ${e} already dead (ESRCH)`):console.log(`SIGKILL failed for process ${e}: ${t.message}`)}}await this.checkProcessExists(e)?console.warn(`Process ${e} still exists after kill attempts`):console.log(`Successfully killed gateway process ${e}`),this.gatewayProcess=null}if(await new Promise(e=>setTimeout(e,500)),!await this.checkPortAvailable(t)&&(console.log(`Port ${t} still in use, attempting to free it...`),await this.killProcessByPort(t),await new Promise(e=>setTimeout(e,1e3)),!await this.checkPortAvailable(t)))return console.error(`Failed to free port ${t} - it may be in TIME_WAIT state`),{status:"stopped",error:`Port ${t} is still in use. It may be in TIME_WAIT state and will be available shortly.`};return await (0,a.updateServiceStatus)({status:"stopped",pid:null}),this.gatewayProcess=null,console.log("Gateway service stopped"),{status:"stopped"}}catch(e){return await (0,a.updateServiceStatus)({status:"stopped",pid:null}),this.gatewayProcess=null,{status:"stopped",error:e.message||"Failed to stop service"}}}};e.s(["serviceManager",0,n])}];
1
+ module.exports=[93695,(e,t,s)=>{t.exports=e.x("next/dist/shared/lib/no-fallback-error.external.js",()=>require("next/dist/shared/lib/no-fallback-error.external.js"))},18622,(e,t,s)=>{t.exports=e.x("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js",()=>require("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js"))},56704,(e,t,s)=>{t.exports=e.x("next/dist/server/app-render/work-async-storage.external.js",()=>require("next/dist/server/app-render/work-async-storage.external.js"))},32319,(e,t,s)=>{t.exports=e.x("next/dist/server/app-render/work-unit-async-storage.external.js",()=>require("next/dist/server/app-render/work-unit-async-storage.external.js"))},24725,(e,t,s)=>{t.exports=e.x("next/dist/server/app-render/after-task-async-storage.external.js",()=>require("next/dist/server/app-render/after-task-async-storage.external.js"))},70406,(e,t,s)=>{t.exports=e.x("next/dist/compiled/@opentelemetry/api",()=>require("next/dist/compiled/@opentelemetry/api"))},14747,(e,t,s)=>{t.exports=e.x("path",()=>require("path"))},24361,(e,t,s)=>{t.exports=e.x("util",()=>require("util"))},33405,(e,t,s)=>{t.exports=e.x("child_process",()=>require("child_process"))},4446,(e,t,s)=>{t.exports=e.x("net",()=>require("net"))},77922,e=>{"use strict";var t=e.i(33405),s=e.i(24361),r=e.i(14747),a=e.i(97731),i=e.i(71560),o=e.i(4446);let l=(0,s.promisify)(t.exec),n=new class{gatewayProcess=null;isStarting=!1;async checkProcessExists(e){try{return await l(`ps -p ${e} -o pid=`),!0}catch{return!1}}async checkPortAvailable(e){return new Promise(t=>{let s=o.default.createServer();s.listen(e,()=>{s.once("close",()=>t(!0)),s.close()}),s.on("error",()=>{t(!1)})})}async getPidByPort(e){try{let{stdout:t}=await l(`lsof -ti:${e} 2>/dev/null || echo ''`),s=t.trim();if(s&&!isNaN(parseInt(s)))return parseInt(s);try{let{stdout:t}=await l(`netstat -tlnp 2>/dev/null | grep :${e} | awk '{print $7}' | cut -d'/' -f1 || echo ''`),s=t.trim();if(s&&!isNaN(parseInt(s)))return parseInt(s)}catch{}return null}catch{return null}}async forceKillProcess(e){try{try{process.kill(e,"SIGTERM"),await new Promise(e=>setTimeout(e,1e3))}catch{}if(await this.checkProcessExists(e))try{process.kill(e,"SIGKILL"),await new Promise(e=>setTimeout(e,500))}catch{}return!await this.checkProcessExists(e)}catch(t){return console.error(`Failed to kill process ${e}:`,t),!1}}async killProcessByPort(e){return this.forceKillProcessByPort(e)}async forceKillProcessByPort(e){let t=await this.getPidByPort(e);if(!t)return!0;console.log(`Found process ${t} using port ${e}, attempting to kill...`);let s=await this.forceKillProcess(t);return s?console.log(`Successfully killed process ${t}`):console.warn(`Failed to kill process ${t}`),s}async getStatus(){let e=await (0,a.getServiceStatus)();return e?"running"===e.status&&e.pid&&!await this.checkProcessExists(e.pid)?(await (0,a.updateServiceStatus)({status:"stopped",pid:null}),{status:"stopped"}):{status:e.status,port:e.port,pid:e.pid,started_at:e.started_at}:{status:"stopped"}}async start(e){if(this.isStarting)return{status:"stopped",error:"Service is already starting"};let s=await this.getStatus();if("running"===s.status&&s.port===e)return{status:"running",error:"Service is already running",port:s.port,pid:s.pid};if(!await this.checkPortAvailable(e)){if(console.log(`Port ${e} is in use, attempting to free it...`),await this.killProcessByPort(e),await new Promise(e=>setTimeout(e,1e3)),!await this.checkPortAvailable(e))return{status:"stopped",error:`Port ${e} is still in use after cleanup attempt`};console.log(`Port ${e} is now available`)}this.isStarting=!0;try{try{await (0,i.getDatabase)()}catch(e){return console.error("Failed to initialize database:",e),this.isStarting=!1,{status:"stopped",error:"Failed to initialize database"}}let s=r.default.join(process.cwd(),"dist","src","cli","gateway-server.js"),o=(0,t.spawn)(process.execPath,[s,"--port",e.toString()],{cwd:process.cwd(),stdio:["ignore","pipe","pipe"],env:{...process.env,NODE_ENV:"production"}});o.stdout&&o.stdout.on("data",e=>{process.stdout.write(`[Gateway] ${e}`)}),o.stderr&&o.stderr.on("data",e=>{process.stderr.write(`[Gateway Error] ${e}`)}),o.on("exit",async e=>{console.log(`Gateway process exited with code ${e}`),this.gatewayProcess===o&&(this.gatewayProcess=null,await (0,a.updateServiceStatus)({status:"stopped",pid:null}))}),o.on("error",e=>{console.error(`Failed to start gateway process: ${e.message}`)}),this.gatewayProcess=o;let l=o.pid||null,n=new Date().toISOString();return await (0,a.setServiceStatus)({status:"running",port:e,pid:l,started_at:n}),this.isStarting=!1,console.log(`Gateway server started on port ${e} (PID: ${l})`),{status:"running",port:e,pid:l,started_at:n}}catch(e){return this.isStarting=!1,this.gatewayProcess=null,console.error(`Failed to start gateway service: ${e.message}`),{status:"stopped",error:e.message||"Failed to start service"}}}async stop(){let e=await this.getStatus();if("stopped"===e.status)return{status:"stopped"};let t=e.port||parseInt((await (0,a.getConfig)("port"))?.value||"1357");try{if(this.gatewayProcess&&this.gatewayProcess.pid){let e=this.gatewayProcess.pid;console.log(`Attempting to kill gateway process (PID: ${e})`);try{process.kill(e,"SIGTERM"),console.log(`Sent SIGTERM to process ${e}`),await new Promise(e=>setTimeout(e,1e3))}catch(t){"ESRCH"===t.code?console.log(`Process ${e} already dead (ESRCH)`):console.log(`SIGTERM failed for process ${e}: ${t.message}`)}if(await this.checkProcessExists(e)){console.log(`Process ${e} still exists after SIGTERM, sending SIGKILL`);try{process.kill(e,"SIGKILL"),await new Promise(e=>setTimeout(e,500))}catch(t){"ESRCH"===t.code?console.log(`Process ${e} already dead (ESRCH)`):console.log(`SIGKILL failed for process ${e}: ${t.message}`)}}await this.checkProcessExists(e)?console.warn(`Process ${e} still exists after kill attempts`):console.log(`Successfully killed gateway process ${e}`),this.gatewayProcess=null}if(await new Promise(e=>setTimeout(e,500)),!await this.checkPortAvailable(t)&&(console.log(`Port ${t} still in use, attempting to free it...`),await this.killProcessByPort(t),await new Promise(e=>setTimeout(e,1e3)),!await this.checkPortAvailable(t)))return console.error(`Failed to free port ${t} - it may be in TIME_WAIT state`),{status:"stopped",error:`Port ${t} is still in use. It may be in TIME_WAIT state and will be available shortly.`};return await (0,a.updateServiceStatus)({status:"stopped",pid:null}),this.gatewayProcess=null,console.log("Gateway service stopped"),{status:"stopped"}}catch(e){return await (0,a.updateServiceStatus)({status:"stopped",pid:null}),this.gatewayProcess=null,{status:"stopped",error:e.message||"Failed to stop service"}}}};e.s(["serviceManager",0,n])}];
2
2
 
3
- //# sourceMappingURL=%5Broot-of-the-server%5D__e7623a6c._.js.map
3
+ //# sourceMappingURL=%5Broot-of-the-server%5D__11srlmi._.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/server/service-manager.ts"],"sourcesContent":["import { exec, execSync, spawn, ChildProcess } from 'child_process';\nimport { promisify } from 'util';\nimport path from 'path';\nimport { getServiceStatus, setServiceStatus, updateServiceStatus, getConfig } from '@/db/queries';\nimport { getDatabase } from '@/db/database';\nimport net from 'net';\n\nconst execAsync = promisify(exec);\n\nexport interface ServiceStatusResponse {\n status: 'running' | 'stopped';\n port?: number;\n pid?: number | null;\n started_at?: string | null;\n error?: string;\n}\n\nclass ServiceManager {\n private gatewayProcess: ChildProcess | null = null;\n private isStarting: boolean = false;\n\n /**\n * Check if a process with given PID exists\n */\n private async checkProcessExists(pid: number): Promise<boolean> {\n try {\n await execAsync(`ps -p ${pid} -o pid=`);\n return true;\n } catch {\n return false;\n }\n }\n\n /**\n * Check if a port is available\n */\n private async checkPortAvailable(port: number): Promise<boolean> {\n return new Promise((resolve) => {\n const server = net.createServer();\n\n server.listen(port, () => {\n server.once('close', () => resolve(true));\n server.close();\n });\n\n server.on('error', () => {\n resolve(false);\n });\n });\n }\n\n /**\n * Get PID using a specific port\n */\n private async getPidByPort(port: number): Promise<number | null> {\n try {\n // Try lsof first (macOS/Linux)\n const { stdout } = await execAsync(`lsof -ti:${port} 2>/dev/null || echo ''`);\n const pid = stdout.trim();\n if (pid && !isNaN(parseInt(pid))) {\n return parseInt(pid);\n }\n\n // Try netstat as fallback (some systems)\n try {\n const { stdout: netstatOut } = await execAsync(`netstat -tlnp 2>/dev/null | grep :${port} | awk '{print $7}' | cut -d'/' -f1 || echo ''`);\n const pid2 = netstatOut.trim();\n if (pid2 && !isNaN(parseInt(pid2))) {\n return parseInt(pid2);\n }\n } catch {\n // netstat might not be available\n }\n\n return null;\n } catch {\n return null;\n }\n }\n\n /**\n * Force kill a process by PID\n */\n private async forceKillProcess(pid: number): Promise<boolean> {\n try {\n // First try SIGTERM for graceful shutdown\n try {\n process.kill(pid, 'SIGTERM');\n // Give process time to terminate gracefully\n await new Promise(resolve => setTimeout(resolve, 1000));\n } catch {\n // Process might already be dead\n }\n\n // Check if process still exists\n if (await this.checkProcessExists(pid)) {\n // Try SIGKILL\n try {\n process.kill(pid, 'SIGKILL');\n await new Promise(resolve => setTimeout(resolve, 500));\n } catch {\n // Might fail if process already dead\n }\n }\n\n return !(await this.checkProcessExists(pid));\n } catch (error) {\n console.error(`Failed to kill process ${pid}:`, error);\n return false;\n }\n }\n\n /**\n * Kill process using a specific port (public method)\n */\n async killProcessByPort(port: number): Promise<boolean> {\n return this.forceKillProcessByPort(port);\n }\n\n /**\n * Force kill a process by PID (private helper)\n */\n private async forceKillProcessByPort(port: number): Promise<boolean> {\n const pid = await this.getPidByPort(port);\n if (!pid) {\n return true; // No process using the port\n }\n\n console.log(`Found process ${pid} using port ${port}, attempting to kill...`);\n const killed = await this.forceKillProcess(pid);\n \n if (killed) {\n console.log(`Successfully killed process ${pid}`);\n } else {\n console.warn(`Failed to kill process ${pid}`);\n }\n\n return killed;\n }\n\n /**\n * Get current service status, verifying process existence\n */\n async getStatus(): Promise<ServiceStatusResponse> {\n const dbStatus = await getServiceStatus();\n\n if (!dbStatus) {\n return { status: 'stopped' };\n }\n\n // If status is running, verify process actually exists\n if (dbStatus.status === 'running' && dbStatus.pid) {\n const processExists = await this.checkProcessExists(dbStatus.pid);\n if (!processExists) {\n // Process doesn't exist, update database\n await updateServiceStatus({ status: 'stopped', pid: null });\n return { status: 'stopped' };\n }\n }\n\n return {\n status: dbStatus.status,\n port: dbStatus.port,\n pid: dbStatus.pid,\n started_at: dbStatus.started_at,\n };\n }\n\n /**\n * Start gateway service\n */\n async start(port: number): Promise<ServiceStatusResponse> {\n // Prevent concurrent starts\n if (this.isStarting) {\n return { status: 'stopped', error: 'Service is already starting' };\n }\n\n // Check if service is already running\n const currentStatus = await this.getStatus();\n if (currentStatus.status === 'running' && currentStatus.port === port) {\n return { status: 'running', error: 'Service is already running', port: currentStatus.port, pid: currentStatus.pid };\n }\n\n // Check if port is available\n const portAvailable = await this.checkPortAvailable(port);\n if (!portAvailable) {\n console.log(`Port ${port} is in use, attempting to free it...`);\n\n // Try to kill the process using the port\n const killed = await this.killProcessByPort(port);\n\n // Wait for port to be released\n await new Promise(resolve => setTimeout(resolve, 1000));\n\n // Check again\n const portNowAvailable = await this.checkPortAvailable(port);\n if (!portNowAvailable) {\n return { status: 'stopped', error: `Port ${port} is still in use after cleanup attempt` };\n }\n\n console.log(`Port ${port} is now available`);\n }\n\n this.isStarting = true;\n\n try {\n // Initialize database\n try {\n await getDatabase();\n } catch (error: any) {\n console.error('Failed to initialize database:', error);\n this.isStarting = false;\n return { status: 'stopped', error: 'Failed to initialize database' };\n }\n\n // Get the path to the gateway server entry script\n const gatewayScriptPath = path.join(process.cwd(), 'dist', 'src', 'cli', 'gateway-server.js');\n\n // Spawn the gateway server in a separate process\n const gatewayProcess = spawn(process.execPath, [gatewayScriptPath, '--port', port.toString()], {\n cwd: process.cwd(),\n stdio: ['ignore', 'pipe', 'pipe'],\n env: { ...process.env, NODE_ENV: process.env.NODE_ENV || 'development' },\n });\n\n // Capture process output\n if (gatewayProcess.stdout) {\n gatewayProcess.stdout.on('data', (data) => {\n process.stdout.write(`[Gateway] ${data}`);\n });\n }\n if (gatewayProcess.stderr) {\n gatewayProcess.stderr.on('data', (data) => {\n process.stderr.write(`[Gateway Error] ${data}`);\n });\n }\n\n // Handle process exit\n gatewayProcess.on('exit', async (code) => {\n console.log(`Gateway process exited with code ${code}`);\n if (this.gatewayProcess === gatewayProcess) {\n this.gatewayProcess = null;\n await updateServiceStatus({ status: 'stopped', pid: null });\n }\n });\n\n gatewayProcess.on('error', (error) => {\n console.error(`Failed to start gateway process: ${error.message}`);\n });\n\n this.gatewayProcess = gatewayProcess;\n const pid = gatewayProcess.pid || null;\n const startedAt = new Date().toISOString();\n\n await setServiceStatus({\n status: 'running',\n port,\n pid,\n started_at: startedAt,\n });\n\n this.isStarting = false;\n\n console.log(`Gateway server started on port ${port} (PID: ${pid})`);\n\n return {\n status: 'running',\n port,\n pid,\n started_at: startedAt,\n };\n } catch (error: any) {\n this.isStarting = false;\n this.gatewayProcess = null;\n console.error(`Failed to start gateway service: ${error.message}`);\n return { status: 'stopped', error: error.message || 'Failed to start service' };\n }\n }\n\n /**\n * Stop the gateway service\n */\n async stop(): Promise<ServiceStatusResponse> {\n const currentStatus = await this.getStatus();\n\n if (currentStatus.status === 'stopped') {\n return { status: 'stopped' };\n }\n\n const port = currentStatus.port || parseInt((await getConfig('port'))?.value || '1357');\n\n try {\n // Track if we successfully killed something\n let killedSuccessfully = false;\n\n // Try to stop the gateway server process\n if (this.gatewayProcess && this.gatewayProcess.pid) {\n const pid = this.gatewayProcess.pid;\n console.log(`Attempting to kill gateway process (PID: ${pid})`);\n\n // First try SIGTERM for graceful shutdown\n try {\n process.kill(pid, 'SIGTERM');\n console.log(`Sent SIGTERM to process ${pid}`);\n // Give process time to terminate gracefully\n await new Promise(resolve => setTimeout(resolve, 1000));\n } catch (error: any) {\n if (error.code === 'ESRCH') {\n console.log(`Process ${pid} already dead (ESRCH)`);\n } else {\n console.log(`SIGTERM failed for process ${pid}: ${error.message}`);\n }\n }\n\n // Check if process still exists\n if (await this.checkProcessExists(pid)) {\n console.log(`Process ${pid} still exists after SIGTERM, sending SIGKILL`);\n try {\n process.kill(pid, 'SIGKILL');\n await new Promise(resolve => setTimeout(resolve, 500));\n } catch (error: any) {\n if (error.code === 'ESRCH') {\n console.log(`Process ${pid} already dead (ESRCH)`);\n } else {\n console.log(`SIGKILL failed for process ${pid}: ${error.message}`);\n }\n }\n }\n\n // Verify process is dead\n if (!(await this.checkProcessExists(pid))) {\n console.log(`Successfully killed gateway process ${pid}`);\n killedSuccessfully = true;\n } else {\n console.warn(`Process ${pid} still exists after kill attempts`);\n }\n\n this.gatewayProcess = null;\n }\n\n // Wait a bit for cleanup\n await new Promise(resolve => setTimeout(resolve, 500));\n\n // Check if port is still in use - if so, force kill by port\n const portStillInUse = !(await this.checkPortAvailable(port));\n\n if (portStillInUse) {\n console.log(`Port ${port} still in use, attempting to free it...`);\n const killed = await this.killProcessByPort(port);\n\n // Wait and verify\n await new Promise(resolve => setTimeout(resolve, 1000));\n\n const stillInUse = !(await this.checkPortAvailable(port));\n if (stillInUse) {\n console.error(`Failed to free port ${port} - it may be in TIME_WAIT state`);\n return {\n status: 'stopped',\n error: `Port ${port} is still in use. It may be in TIME_WAIT state and will be available shortly.`,\n };\n }\n\n killedSuccessfully = true;\n }\n\n // Update database status\n await updateServiceStatus({ status: 'stopped', pid: null });\n this.gatewayProcess = null;\n\n console.log('Gateway service stopped');\n return { status: 'stopped' };\n } catch (error: any) {\n // Even if there's an error, try to update status\n await updateServiceStatus({ status: 'stopped', pid: null });\n this.gatewayProcess = null;\n return { status: 'stopped', error: error.message || 'Failed to stop service' };\n }\n }\n}\n\n// Export singleton instance\nexport const serviceManager = new ServiceManager();\n"],"names":[],"mappings":"8uCAAA,IAAA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,MAEA,IAAM,EAAY,CAAA,EAAA,EAAA,SAAA,AAAS,EAAC,E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B,EAAE,EAAI,EAAE,EAAE,EAAM,OAAO,CAAA,CAAE,CAErE,CACF,CAGM,MAAM,IAAI,CAAC,kBAAkB,CAAC,GAIlC,GAJyC,KAIjC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAI,iCAAiC,CAAC,EAH9D,QAAQ,GAAG,CAAC,CAAC,oCAAoC,EAAE,EAAA,CAAK,EAM1D,IAAI,CAAC,cAAc,CAAG,IACxB,CAQA,GALA,CAKI,KALE,IAAI,OAKU,CALF,GAAW,WAAW,EAAS,MAG1B,CAAE,MAAM,IAAI,CAAC,kBAAkB,CAAC,KAGrD,QAAQ,GAAG,CAAC,CAAC,KAAK,EAAE,EAAK,uCAAuC,CAAC,EAClD,MAAM,IAAI,CAAC,iBAAiB,CAAC,GAG5C,MAAM,IAAI,QAAQ,GAAW,WAAW,EAAS,MAE9B,CAAE,MAAM,IAAI,CAAC,kBAAkB,CAAC,IAGjD,OADA,QAAQ,KAAK,CAAC,CAAC,oBAAoB,EAAE,EAAK,+BAA+B,CAAC,EACnE,CACL,OAAQ,UACR,MAAO,CAAC,KAAK,EAAE,EAAK,6EAA6E,CAAC,AACpG,EAWJ,OAJA,MAAM,CAAA,EAAA,EAAA,mBAAA,AAAmB,EAAC,CAAE,OAAQ,UAAW,IAAK,IAAK,GACzD,IAAI,CAAC,cAAc,CAAG,KAEtB,QAAQ,GAAG,CAAC,2BACL,CAAE,OAAQ,SAAU,CAC7B,CAAE,MAAO,EAAY,CAInB,OAFA,MAAM,CAAA,EAAA,EAAA,mBAAA,AAAmB,EAAC,CAAE,OAAQ,UAAW,IAAK,IAAK,GACzD,IAAI,CAAC,cAAc,CAAG,KACf,CAAE,OAAQ,UAAW,MAAO,EAAM,OAAO,EAAI,wBAAyB,CAC/E,CACF,CACF"}
1
+ {"version":3,"sources":["../../../src/server/service-manager.ts"],"sourcesContent":["import { exec, execSync, spawn, ChildProcess } from 'child_process';\nimport { promisify } from 'util';\nimport path from 'path';\nimport { getServiceStatus, setServiceStatus, updateServiceStatus, getConfig } from '@/db/queries';\nimport { getDatabase } from '@/db/database';\nimport net from 'net';\n\nconst execAsync = promisify(exec);\n\nexport interface ServiceStatusResponse {\n status: 'running' | 'stopped';\n port?: number;\n pid?: number | null;\n started_at?: string | null;\n error?: string;\n}\n\nclass ServiceManager {\n private gatewayProcess: ChildProcess | null = null;\n private isStarting: boolean = false;\n\n /**\n * Check if a process with given PID exists\n */\n private async checkProcessExists(pid: number): Promise<boolean> {\n try {\n await execAsync(`ps -p ${pid} -o pid=`);\n return true;\n } catch {\n return false;\n }\n }\n\n /**\n * Check if a port is available\n */\n private async checkPortAvailable(port: number): Promise<boolean> {\n return new Promise((resolve) => {\n const server = net.createServer();\n\n server.listen(port, () => {\n server.once('close', () => resolve(true));\n server.close();\n });\n\n server.on('error', () => {\n resolve(false);\n });\n });\n }\n\n /**\n * Get PID using a specific port\n */\n private async getPidByPort(port: number): Promise<number | null> {\n try {\n // Try lsof first (macOS/Linux)\n const { stdout } = await execAsync(`lsof -ti:${port} 2>/dev/null || echo ''`);\n const pid = stdout.trim();\n if (pid && !isNaN(parseInt(pid))) {\n return parseInt(pid);\n }\n\n // Try netstat as fallback (some systems)\n try {\n const { stdout: netstatOut } = await execAsync(`netstat -tlnp 2>/dev/null | grep :${port} | awk '{print $7}' | cut -d'/' -f1 || echo ''`);\n const pid2 = netstatOut.trim();\n if (pid2 && !isNaN(parseInt(pid2))) {\n return parseInt(pid2);\n }\n } catch {\n // netstat might not be available\n }\n\n return null;\n } catch {\n return null;\n }\n }\n\n /**\n * Force kill a process by PID\n */\n private async forceKillProcess(pid: number): Promise<boolean> {\n try {\n // First try SIGTERM for graceful shutdown\n try {\n process.kill(pid, 'SIGTERM');\n // Give process time to terminate gracefully\n await new Promise(resolve => setTimeout(resolve, 1000));\n } catch {\n // Process might already be dead\n }\n\n // Check if process still exists\n if (await this.checkProcessExists(pid)) {\n // Try SIGKILL\n try {\n process.kill(pid, 'SIGKILL');\n await new Promise(resolve => setTimeout(resolve, 500));\n } catch {\n // Might fail if process already dead\n }\n }\n\n return !(await this.checkProcessExists(pid));\n } catch (error) {\n console.error(`Failed to kill process ${pid}:`, error);\n return false;\n }\n }\n\n /**\n * Kill process using a specific port (public method)\n */\n async killProcessByPort(port: number): Promise<boolean> {\n return this.forceKillProcessByPort(port);\n }\n\n /**\n * Force kill a process by PID (private helper)\n */\n private async forceKillProcessByPort(port: number): Promise<boolean> {\n const pid = await this.getPidByPort(port);\n if (!pid) {\n return true; // No process using the port\n }\n\n console.log(`Found process ${pid} using port ${port}, attempting to kill...`);\n const killed = await this.forceKillProcess(pid);\n \n if (killed) {\n console.log(`Successfully killed process ${pid}`);\n } else {\n console.warn(`Failed to kill process ${pid}`);\n }\n\n return killed;\n }\n\n /**\n * Get current service status, verifying process existence\n */\n async getStatus(): Promise<ServiceStatusResponse> {\n const dbStatus = await getServiceStatus();\n\n if (!dbStatus) {\n return { status: 'stopped' };\n }\n\n // If status is running, verify process actually exists\n if (dbStatus.status === 'running' && dbStatus.pid) {\n const processExists = await this.checkProcessExists(dbStatus.pid);\n if (!processExists) {\n // Process doesn't exist, update database\n await updateServiceStatus({ status: 'stopped', pid: null });\n return { status: 'stopped' };\n }\n }\n\n return {\n status: dbStatus.status,\n port: dbStatus.port,\n pid: dbStatus.pid,\n started_at: dbStatus.started_at,\n };\n }\n\n /**\n * Start gateway service\n */\n async start(port: number): Promise<ServiceStatusResponse> {\n // Prevent concurrent starts\n if (this.isStarting) {\n return { status: 'stopped', error: 'Service is already starting' };\n }\n\n // Check if service is already running\n const currentStatus = await this.getStatus();\n if (currentStatus.status === 'running' && currentStatus.port === port) {\n return { status: 'running', error: 'Service is already running', port: currentStatus.port, pid: currentStatus.pid };\n }\n\n // Check if port is available\n const portAvailable = await this.checkPortAvailable(port);\n if (!portAvailable) {\n console.log(`Port ${port} is in use, attempting to free it...`);\n\n // Try to kill the process using the port\n const killed = await this.killProcessByPort(port);\n\n // Wait for port to be released\n await new Promise(resolve => setTimeout(resolve, 1000));\n\n // Check again\n const portNowAvailable = await this.checkPortAvailable(port);\n if (!portNowAvailable) {\n return { status: 'stopped', error: `Port ${port} is still in use after cleanup attempt` };\n }\n\n console.log(`Port ${port} is now available`);\n }\n\n this.isStarting = true;\n\n try {\n // Initialize database\n try {\n await getDatabase();\n } catch (error: any) {\n console.error('Failed to initialize database:', error);\n this.isStarting = false;\n return { status: 'stopped', error: 'Failed to initialize database' };\n }\n\n // Get the path to the gateway server entry script\n const gatewayScriptPath = path.join(process.cwd(), 'dist', 'src', 'cli', 'gateway-server.js');\n\n // Spawn the gateway server in a separate process\n const gatewayProcess = spawn(process.execPath, [gatewayScriptPath, '--port', port.toString()], {\n cwd: process.cwd(),\n stdio: ['ignore', 'pipe', 'pipe'],\n env: { ...process.env, NODE_ENV: process.env.NODE_ENV || 'development' },\n });\n\n // Capture process output\n if (gatewayProcess.stdout) {\n gatewayProcess.stdout.on('data', (data) => {\n process.stdout.write(`[Gateway] ${data}`);\n });\n }\n if (gatewayProcess.stderr) {\n gatewayProcess.stderr.on('data', (data) => {\n process.stderr.write(`[Gateway Error] ${data}`);\n });\n }\n\n // Handle process exit\n gatewayProcess.on('exit', async (code) => {\n console.log(`Gateway process exited with code ${code}`);\n if (this.gatewayProcess === gatewayProcess) {\n this.gatewayProcess = null;\n await updateServiceStatus({ status: 'stopped', pid: null });\n }\n });\n\n gatewayProcess.on('error', (error) => {\n console.error(`Failed to start gateway process: ${error.message}`);\n });\n\n this.gatewayProcess = gatewayProcess;\n const pid = gatewayProcess.pid || null;\n const startedAt = new Date().toISOString();\n\n await setServiceStatus({\n status: 'running',\n port,\n pid,\n started_at: startedAt,\n });\n\n this.isStarting = false;\n\n console.log(`Gateway server started on port ${port} (PID: ${pid})`);\n\n return {\n status: 'running',\n port,\n pid,\n started_at: startedAt,\n };\n } catch (error: any) {\n this.isStarting = false;\n this.gatewayProcess = null;\n console.error(`Failed to start gateway service: ${error.message}`);\n return { status: 'stopped', error: error.message || 'Failed to start service' };\n }\n }\n\n /**\n * Stop the gateway service\n */\n async stop(): Promise<ServiceStatusResponse> {\n const currentStatus = await this.getStatus();\n\n if (currentStatus.status === 'stopped') {\n return { status: 'stopped' };\n }\n\n const port = currentStatus.port || parseInt((await getConfig('port'))?.value || '1357');\n\n try {\n // Track if we successfully killed something\n let killedSuccessfully = false;\n\n // Try to stop the gateway server process\n if (this.gatewayProcess && this.gatewayProcess.pid) {\n const pid = this.gatewayProcess.pid;\n console.log(`Attempting to kill gateway process (PID: ${pid})`);\n\n // First try SIGTERM for graceful shutdown\n try {\n process.kill(pid, 'SIGTERM');\n console.log(`Sent SIGTERM to process ${pid}`);\n // Give process time to terminate gracefully\n await new Promise(resolve => setTimeout(resolve, 1000));\n } catch (error: any) {\n if (error.code === 'ESRCH') {\n console.log(`Process ${pid} already dead (ESRCH)`);\n } else {\n console.log(`SIGTERM failed for process ${pid}: ${error.message}`);\n }\n }\n\n // Check if process still exists\n if (await this.checkProcessExists(pid)) {\n console.log(`Process ${pid} still exists after SIGTERM, sending SIGKILL`);\n try {\n process.kill(pid, 'SIGKILL');\n await new Promise(resolve => setTimeout(resolve, 500));\n } catch (error: any) {\n if (error.code === 'ESRCH') {\n console.log(`Process ${pid} already dead (ESRCH)`);\n } else {\n console.log(`SIGKILL failed for process ${pid}: ${error.message}`);\n }\n }\n }\n\n // Verify process is dead\n if (!(await this.checkProcessExists(pid))) {\n console.log(`Successfully killed gateway process ${pid}`);\n killedSuccessfully = true;\n } else {\n console.warn(`Process ${pid} still exists after kill attempts`);\n }\n\n this.gatewayProcess = null;\n }\n\n // Wait a bit for cleanup\n await new Promise(resolve => setTimeout(resolve, 500));\n\n // Check if port is still in use - if so, force kill by port\n const portStillInUse = !(await this.checkPortAvailable(port));\n\n if (portStillInUse) {\n console.log(`Port ${port} still in use, attempting to free it...`);\n const killed = await this.killProcessByPort(port);\n\n // Wait and verify\n await new Promise(resolve => setTimeout(resolve, 1000));\n\n const stillInUse = !(await this.checkPortAvailable(port));\n if (stillInUse) {\n console.error(`Failed to free port ${port} - it may be in TIME_WAIT state`);\n return {\n status: 'stopped',\n error: `Port ${port} is still in use. It may be in TIME_WAIT state and will be available shortly.`,\n };\n }\n\n killedSuccessfully = true;\n }\n\n // Update database status\n await updateServiceStatus({ status: 'stopped', pid: null });\n this.gatewayProcess = null;\n\n console.log('Gateway service stopped');\n return { status: 'stopped' };\n } catch (error: any) {\n // Even if there's an error, try to update status\n await updateServiceStatus({ status: 'stopped', pid: null });\n this.gatewayProcess = null;\n return { status: 'stopped', error: error.message || 'Failed to stop service' };\n }\n }\n}\n\n// Export singleton instance\nexport const serviceManager = new ServiceManager();\n"],"names":["execAsync","ServiceManager","gatewayProcess","isStarting","checkProcessExists","pid","checkPortAvailable","port","Promise","resolve","server","createServer","listen","once","close","on","getPidByPort","stdout","trim","isNaN","parseInt","netstatOut","pid2","forceKillProcess","process","kill","setTimeout","error","console","killProcessByPort","forceKillProcessByPort","log","killed","warn","getStatus","dbStatus","status","processExists","started_at","start","currentStatus","portAvailable","portNowAvailable","gatewayScriptPath","join","cwd","execPath","toString","stdio","env","NODE_ENV","data","write","stderr","code","message","startedAt","Date","toISOString","stop","value","killedSuccessfully","portStillInUse","stillInUse","serviceManager"],"mappings":"8uCAAA,IAAA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,MAEA,IAAMA,EAAY,CAAA,EAAA,EAAA,SAAA,AAAS,EAAC,EAAA,IAAI,EAsXnBgE,EAAiB,IA5W9B,AA4WkC/D,MA5W5BA,AACIC,eAAsC,IAAK,CAC3CC,YAAsB,CAAM,AAKpC,OAAcC,mBAAmBC,CAAW,CAAoB,CAC9D,GAAI,CAEF,OADA,MAAML,EAAU,CAAC,MAAM,EAAEK,EAAI,QAAQ,CAAC,GAC/B,CACT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,CAAA,EAAA,EAAA,mBAAA,AAAmB,EAAC,CAAES,OAAQ,UAAW/B,IAAK,IAAK,GACzD,IAAI,CAACH,cAAc,CAAG,KACf,CAAEkC,OAAQ,UAAWT,MAAOA,EAAM4B,OAAO,EAAI,wBAAyB,CAC/E,CACF,CACF"}
@@ -0,0 +1,3 @@
1
+ module.exports=[93695,(e,t,r)=>{t.exports=e.x("next/dist/shared/lib/no-fallback-error.external.js",()=>require("next/dist/shared/lib/no-fallback-error.external.js"))},18622,(e,t,r)=>{t.exports=e.x("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js",()=>require("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js"))},56704,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/work-async-storage.external.js",()=>require("next/dist/server/app-render/work-async-storage.external.js"))},32319,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/work-unit-async-storage.external.js",()=>require("next/dist/server/app-render/work-unit-async-storage.external.js"))},24725,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/after-task-async-storage.external.js",()=>require("next/dist/server/app-render/after-task-async-storage.external.js"))},70406,(e,t,r)=>{t.exports=e.x("next/dist/compiled/@opentelemetry/api",()=>require("next/dist/compiled/@opentelemetry/api"))},14747,(e,t,r)=>{t.exports=e.x("path",()=>require("path"))},67003,e=>{"use strict";var t=e.i(47909),r=e.i(74017),a=e.i(96250),n=e.i(59756),s=e.i(61916),o=e.i(74677),i=e.i(69741),l=e.i(16795),d=e.i(87718),u=e.i(95169),p=e.i(47587),c=e.i(66012),v=e.i(70101),x=e.i(26937),R=e.i(10372),h=e.i(93695);e.i(52474);var g=e.i(220),f=e.i(89171),y=e.i(71560),m=e.i(97731),w=e.i(38483);async function P(e){try{await (0,y.getDatabase)();let{searchParams:t}=new URL(e.url),r=t.get("id"),a="true"===t.get("includeKey");if(r){let e=await (0,m.getProviderById)(parseInt(r));if(!e)return f.NextResponse.json({error:"Provider not found"},{status:404});return f.NextResponse.json({...e,api_key:a?(0,w.decryptApiKey)(e.api_key):"***"})}let n=(await (0,m.getAllProviders)()).map(e=>({...e,api_key:"***"}));return f.NextResponse.json(n)}catch(e){return console.error("Providers API error:",e),f.NextResponse.json({error:e.message||"Internal server error",stack:void 0},{status:500})}}async function E(e){try{await (0,y.getDatabase)();let{name:t,protocol:r,base_url:a,api_key:n}=await e.json();if(!t||!r||!a||!n)return f.NextResponse.json({error:"Missing required fields"},{status:400});let s=(0,w.encryptApiKey)(n.trim()),o=(0,m.createProvider)({name:t,protocol:r,base_url:a,api_key:s});return f.NextResponse.json({...o,api_key:"***"})}catch(e){return console.error("Providers API error:",e),f.NextResponse.json({error:e.message||"Internal server error",stack:void 0},{status:500})}}async function N(e){try{await (0,y.getDatabase)();let{id:t,name:r,protocol:a,base_url:n,api_key:s}=await e.json();if(!t)return f.NextResponse.json({error:"Provider ID is required"},{status:400});if(!(0,m.getProviderById)(t))return f.NextResponse.json({error:"Provider not found"},{status:404});let o={};void 0!==r&&(o.name=r),void 0!==a&&(o.protocol=a),void 0!==n&&(o.base_url=n),null!=s&&""!==s.trim()&&(o.api_key=(0,w.encryptApiKey)(s.trim()));let i=(0,m.updateProvider)(t,o);if(!i)return f.NextResponse.json({error:"Provider not found"},{status:404});return f.NextResponse.json({...i,api_key:"***"})}catch(e){return console.error("Providers API error:",e),f.NextResponse.json({error:e.message||"Internal server error",stack:void 0},{status:500})}}async function A(e){try{await (0,y.getDatabase)();let{searchParams:t}=new URL(e.url),r=t.get("id");if(!r)return f.NextResponse.json({error:"Provider ID is required"},{status:400});if(!(0,m.deleteProvider)(parseInt(r)))return f.NextResponse.json({error:"Provider not found"},{status:404});return f.NextResponse.json({success:!0})}catch(e){return console.error("Providers API error:",e),f.NextResponse.json({error:e.message||"Internal server error",stack:void 0},{status:500})}}e.s(["DELETE",0,A,"GET",0,P,"POST",0,E,"PUT",0,N,"runtime",0,"nodejs"],34202);var C=e.i(34202);let j=new t.AppRouteRouteModule({definition:{kind:r.RouteKind.APP_ROUTE,page:"/api/providers/route",pathname:"/api/providers",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/src/app/api/providers/route.ts",nextConfigOutput:"",userland:C}),{workAsyncStorage:b,workUnitAsyncStorage:k,serverHooks:I}=j;async function _(e,t,a){a.requestMeta&&(0,n.setRequestMeta)(e,a.requestMeta),j.isDev&&(0,n.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let f="/api/providers/route";f=f.replace(/\/index$/,"")||"/";let y=await j.prepare(e,t,{srcPage:f,multiZoneDraftMode:!1});if(!y)return t.statusCode=400,t.end("Bad Request"),null==a.waitUntil||a.waitUntil.call(a,Promise.resolve()),null;let{buildId:m,params:w,nextConfig:P,parsedUrl:E,isDraftMode:N,prerenderManifest:A,routerServerContext:C,isOnDemandRevalidate:b,revalidateOnlyGenerated:k,resolvedPathname:I,clientReferenceManifest:_,serverActionsManifest:T}=y,q=(0,i.normalizeAppPath)(f),S=!!(A.dynamicRoutes[q]||A.routes[I]),O=async()=>((null==C?void 0:C.render404)?await C.render404(e,t,E,!1):t.end("This page could not be found"),null);if(S&&!N){let e=!!A.routes[I],t=A.dynamicRoutes[q];if(t&&!1===t.fallback&&!e){if(P.adapterPath)return await O();throw new h.NoFallbackError}}let D=null;!S||j.isDev||N||(D="/index"===(D=I)?"/":D);let U=!0===j.isDev||!S,H=S&&!U;T&&_&&(0,o.setManifestsSingleton)({page:f,clientReferenceManifest:_,serverActionsManifest:T});let M=e.method||"GET",K=(0,s.getTracer)(),$=K.getActiveScopeSpan(),B=!!(null==C?void 0:C.isWrappedByNextServer),F=!!(0,n.getRequestMeta)(e,"minimalMode"),L=(0,n.getRequestMeta)(e,"incrementalCache")||await j.getIncrementalCache(e,P,A,F);null==L||L.resetRequestCache(),globalThis.__incrementalCache=L;let G={params:w,previewProps:A.preview,renderOpts:{experimental:{authInterrupts:!!P.experimental.authInterrupts},cacheComponents:!!P.cacheComponents,supportsDynamicResponse:U,incrementalCache:L,cacheLifeProfiles:P.cacheLife,waitUntil:a.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,r,a,n)=>j.onRequestError(e,t,a,n,C)},sharedContext:{buildId:m}},V=new l.NodeNextRequest(e),W=new l.NodeNextResponse(t),X=d.NextRequestAdapter.fromNodeNextRequest(V,(0,d.signalFromNodeResponse)(t));try{let n,o=async e=>j.handle(X,G).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let r=K.getRootSpanAttributes();if(!r)return;if(r.get("next.span_type")!==u.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${r.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let a=r.get("next.route");if(a){let t=`${M} ${a}`;e.setAttributes({"next.route":a,"http.route":a,"next.span_name":t}),e.updateName(t),n&&n!==e&&(n.setAttribute("http.route",a),n.updateName(t))}else e.updateName(`${M} ${f}`)}),i=async n=>{var s,i;let l=async({previousCacheEntry:r})=>{try{if(!F&&b&&k&&!r)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let s=await o(n);e.fetchMetrics=G.renderOpts.fetchMetrics;let i=G.renderOpts.pendingWaitUntil;i&&a.waitUntil&&(a.waitUntil(i),i=void 0);let l=G.renderOpts.collectedTags;if(!S)return await (0,c.sendResponse)(V,W,s,G.renderOpts.pendingWaitUntil),null;{let e=await s.blob(),t=(0,v.toNodeOutgoingHttpHeaders)(s.headers);l&&(t[R.NEXT_CACHE_TAGS_HEADER]=l),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let r=void 0!==G.renderOpts.collectedRevalidate&&!(G.renderOpts.collectedRevalidate>=R.INFINITE_CACHE)&&G.renderOpts.collectedRevalidate,a=void 0===G.renderOpts.collectedExpire||G.renderOpts.collectedExpire>=R.INFINITE_CACHE?void 0:G.renderOpts.collectedExpire;return{value:{kind:g.CachedRouteKind.APP_ROUTE,status:s.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:r,expire:a}}}}catch(t){throw(null==r?void 0:r.isStale)&&await j.onRequestError(e,t,{routerKind:"App Router",routePath:f,routeType:"route",revalidateReason:(0,p.getRevalidateReason)({isStaticGeneration:H,isOnDemandRevalidate:b})},!1,C),t}},d=await j.handleResponse({req:e,nextConfig:P,cacheKey:D,routeKind:r.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:A,isRoutePPREnabled:!1,isOnDemandRevalidate:b,revalidateOnlyGenerated:k,responseGenerator:l,waitUntil:a.waitUntil,isMinimalMode:F});if(!S)return null;if((null==d||null==(s=d.value)?void 0:s.kind)!==g.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==d||null==(i=d.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});F||t.setHeader("x-nextjs-cache",b?"REVALIDATED":d.isMiss?"MISS":d.isStale?"STALE":"HIT"),N&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let u=(0,v.fromNodeOutgoingHttpHeaders)(d.value.headers);return F&&S||u.delete(R.NEXT_CACHE_TAGS_HEADER),!d.cacheControl||t.getHeader("Cache-Control")||u.get("Cache-Control")||u.set("Cache-Control",(0,x.getCacheControlHeader)(d.cacheControl)),await (0,c.sendResponse)(V,W,new Response(d.value.body,{headers:u,status:d.value.status||200})),null};B&&$?await i($):(n=K.getActiveScopeSpan(),await K.withPropagatedContext(e.headers,()=>K.trace(u.BaseServerSpan.handleRequest,{spanName:`${M} ${f}`,kind:s.SpanKind.SERVER,attributes:{"http.method":M,"http.target":e.url}},i),void 0,!B))}catch(t){if(t instanceof h.NoFallbackError||await j.onRequestError(e,t,{routerKind:"App Router",routePath:q,routeType:"route",revalidateReason:(0,p.getRevalidateReason)({isStaticGeneration:H,isOnDemandRevalidate:b})},!1,C),S)throw t;return await (0,c.sendResponse)(V,W,new Response(null,{status:500})),null}}e.s(["handler",0,_,"patchFetch",0,function(){return(0,a.patchFetch)({workAsyncStorage:b,workUnitAsyncStorage:k})},"routeModule",0,j,"serverHooks",0,I,"workAsyncStorage",0,b,"workUnitAsyncStorage",0,k],67003)}];
2
+
3
+ //# sourceMappingURL=%5Broot-of-the-server%5D__12d44rt._.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/app/api/providers/route.ts","../../../node_modules/next/dist/esm/build/templates/app-route.js"],"sourcesContent":["import { NextRequest, NextResponse } from 'next/server';\nimport { getDatabase } from '@/db/database';\nimport { getAllProviders, getProviderById, createProvider, updateProvider, deleteProvider } from '@/db/queries';\nimport { encryptApiKey, decryptApiKey } from '@/server/crypto';\n\n// Ensure Node.js runtime (required for SQLite)\nexport const runtime = 'nodejs';\n\nexport async function GET(request: NextRequest) {\n try {\n await getDatabase();\n const { searchParams } = new URL(request.url);\n const id = searchParams.get('id');\n const includeKey = searchParams.get('includeKey') === 'true';\n\n // If ID is provided, return single provider (for editing)\n if (id) {\n const provider = await getProviderById(parseInt(id));\n if (!provider) {\n return NextResponse.json(\n { error: 'Provider not found' },\n { status: 404 }\n );\n }\n // Return with decrypted API key if requested (for editing)\n return NextResponse.json({\n ...provider,\n api_key: includeKey ? decryptApiKey(provider.api_key) : '***',\n });\n }\n\n // Return all providers\n const providers = await getAllProviders();\n // Don't return API keys in list view\n const sanitized = providers.map(p => ({\n ...p,\n api_key: '***',\n }));\n return NextResponse.json(sanitized);\n } catch (error: any) {\n console.error('Providers API error:', error);\n return NextResponse.json(\n { error: error.message || 'Internal server error', stack: process.env.NODE_ENV === 'development' ? error.stack : undefined },\n { status: 500 }\n );\n }\n}\n\nexport async function POST(request: NextRequest) {\n try {\n await getDatabase();\n const body = await request.json();\n const { name, protocol, base_url, api_key } = body;\n\n if (!name || !protocol || !base_url || !api_key) {\n return NextResponse.json(\n { error: 'Missing required fields' },\n { status: 400 }\n );\n }\n\n const encryptedKey = encryptApiKey(api_key.trim());\n const provider = createProvider({\n name,\n protocol,\n base_url,\n api_key: encryptedKey,\n });\n\n return NextResponse.json({\n ...provider,\n api_key: '***',\n });\n } catch (error: any) {\n console.error('Providers API error:', error);\n return NextResponse.json(\n { error: error.message || 'Internal server error', stack: process.env.NODE_ENV === 'development' ? error.stack : undefined },\n { status: 500 }\n );\n }\n}\n\nexport async function PUT(request: NextRequest) {\n try {\n await getDatabase();\n const body = await request.json();\n const { id, name, protocol, base_url, api_key } = body;\n\n if (!id) {\n return NextResponse.json(\n { error: 'Provider ID is required' },\n { status: 400 }\n );\n }\n\n const existingProvider = getProviderById(id);\n if (!existingProvider) {\n return NextResponse.json(\n { error: 'Provider not found' },\n { status: 404 }\n );\n }\n\n const updateData: any = {};\n if (name !== undefined) updateData.name = name;\n if (protocol !== undefined) updateData.protocol = protocol;\n if (base_url !== undefined) updateData.base_url = base_url;\n if (api_key !== undefined && api_key !== null && api_key.trim() !== '') {\n updateData.api_key = encryptApiKey(api_key.trim());\n }\n\n const provider = updateProvider(id, updateData);\n if (!provider) {\n return NextResponse.json(\n { error: 'Provider not found' },\n { status: 404 }\n );\n }\n\n return NextResponse.json({\n ...provider,\n api_key: '***',\n });\n } catch (error: any) {\n console.error('Providers API error:', error);\n return NextResponse.json(\n { error: error.message || 'Internal server error', stack: process.env.NODE_ENV === 'development' ? error.stack : undefined },\n { status: 500 }\n );\n }\n}\n\nexport async function DELETE(request: NextRequest) {\n try {\n await getDatabase();\n const { searchParams } = new URL(request.url);\n const id = searchParams.get('id');\n\n if (!id) {\n return NextResponse.json(\n { error: 'Provider ID is required' },\n { status: 400 }\n );\n }\n\n const success = deleteProvider(parseInt(id));\n if (!success) {\n return NextResponse.json(\n { error: 'Provider not found' },\n { status: 404 }\n );\n }\n\n return NextResponse.json({ success: true });\n } catch (error: any) {\n console.error('Providers API error:', error);\n return NextResponse.json(\n { error: error.message || 'Internal server error', stack: process.env.NODE_ENV === 'development' ? error.stack : undefined },\n { status: 500 }\n );\n }\n}\n","import { AppRouteRouteModule } from \"next/dist/esm/server/route-modules/app-route/module.compiled\";\nimport { RouteKind } from \"next/dist/esm/server/route-kind\";\nimport { patchFetch as _patchFetch } from \"next/dist/esm/server/lib/patch-fetch\";\nimport { addRequestMeta, getRequestMeta, setRequestMeta } from \"next/dist/esm/server/request-meta\";\nimport { getTracer, SpanKind } from \"next/dist/esm/server/lib/trace/tracer\";\nimport { setManifestsSingleton } from \"next/dist/esm/server/app-render/manifests-singleton\";\nimport { normalizeAppPath } from \"next/dist/esm/shared/lib/router/utils/app-paths\";\nimport { NodeNextRequest, NodeNextResponse } from \"next/dist/esm/server/base-http/node\";\nimport { NextRequestAdapter, signalFromNodeResponse } from \"next/dist/esm/server/web/spec-extension/adapters/next-request\";\nimport { BaseServerSpan } from \"next/dist/esm/server/lib/trace/constants\";\nimport { getRevalidateReason } from \"next/dist/esm/server/instrumentation/utils\";\nimport { sendResponse } from \"next/dist/esm/server/send-response\";\nimport { fromNodeOutgoingHttpHeaders, toNodeOutgoingHttpHeaders } from \"next/dist/esm/server/web/utils\";\nimport { getCacheControlHeader } from \"next/dist/esm/server/lib/cache-control\";\nimport { INFINITE_CACHE, NEXT_CACHE_TAGS_HEADER } from \"next/dist/esm/lib/constants\";\nimport { NoFallbackError } from \"next/dist/esm/shared/lib/no-fallback-error.external\";\nimport { CachedRouteKind } from \"next/dist/esm/server/response-cache\";\nimport * as userland from \"INNER_APP_ROUTE\";\n// We inject the nextConfigOutput here so that we can use them in the route\n// module.\nconst nextConfigOutput = \"\"\nconst routeModule = new AppRouteRouteModule({\n definition: {\n kind: RouteKind.APP_ROUTE,\n page: \"/api/providers/route\",\n pathname: \"/api/providers\",\n filename: \"route\",\n bundlePath: \"\"\n },\n distDir: process.env.__NEXT_RELATIVE_DIST_DIR || '',\n relativeProjectDir: process.env.__NEXT_RELATIVE_PROJECT_DIR || '',\n resolvedPagePath: \"[project]/src/app/api/providers/route.ts\",\n nextConfigOutput,\n userland\n});\n// Pull out the exports that we need to expose from the module. This should\n// be eliminated when we've moved the other routes to the new format. These\n// are used to hook into the route.\nconst { workAsyncStorage, workUnitAsyncStorage, serverHooks } = routeModule;\nfunction patchFetch() {\n return _patchFetch({\n workAsyncStorage,\n workUnitAsyncStorage\n });\n}\nexport { routeModule, workAsyncStorage, workUnitAsyncStorage, serverHooks, patchFetch, };\nexport async function handler(req, res, ctx) {\n if (ctx.requestMeta) {\n setRequestMeta(req, ctx.requestMeta);\n }\n if (routeModule.isDev) {\n addRequestMeta(req, 'devRequestTimingInternalsEnd', process.hrtime.bigint());\n }\n let srcPage = \"/api/providers/route\";\n // turbopack doesn't normalize `/index` in the page name\n // so we need to to process dynamic routes properly\n // TODO: fix turbopack providing differing value from webpack\n if (process.env.TURBOPACK) {\n srcPage = srcPage.replace(/\\/index$/, '') || '/';\n } else if (srcPage === '/index') {\n // we always normalize /index specifically\n srcPage = '/';\n }\n const multiZoneDraftMode = process.env.__NEXT_MULTI_ZONE_DRAFT_MODE;\n const prepareResult = await routeModule.prepare(req, res, {\n srcPage,\n multiZoneDraftMode\n });\n if (!prepareResult) {\n res.statusCode = 400;\n res.end('Bad Request');\n ctx.waitUntil == null ? void 0 : ctx.waitUntil.call(ctx, Promise.resolve());\n return null;\n }\n const { buildId, params, nextConfig, parsedUrl, isDraftMode, prerenderManifest, routerServerContext, isOnDemandRevalidate, revalidateOnlyGenerated, resolvedPathname, clientReferenceManifest, serverActionsManifest } = prepareResult;\n const normalizedSrcPage = normalizeAppPath(srcPage);\n let isIsr = Boolean(prerenderManifest.dynamicRoutes[normalizedSrcPage] || prerenderManifest.routes[resolvedPathname]);\n const render404 = async ()=>{\n // TODO: should route-module itself handle rendering the 404\n if (routerServerContext == null ? void 0 : routerServerContext.render404) {\n await routerServerContext.render404(req, res, parsedUrl, false);\n } else {\n res.end('This page could not be found');\n }\n return null;\n };\n if (isIsr && !isDraftMode) {\n const isPrerendered = Boolean(prerenderManifest.routes[resolvedPathname]);\n const prerenderInfo = prerenderManifest.dynamicRoutes[normalizedSrcPage];\n if (prerenderInfo) {\n if (prerenderInfo.fallback === false && !isPrerendered) {\n if (nextConfig.adapterPath) {\n return await render404();\n }\n throw new NoFallbackError();\n }\n }\n }\n let cacheKey = null;\n if (isIsr && !routeModule.isDev && !isDraftMode) {\n cacheKey = resolvedPathname;\n // ensure /index and / is normalized to one key\n cacheKey = cacheKey === '/index' ? '/' : cacheKey;\n }\n const supportsDynamicResponse = // If we're in development, we always support dynamic HTML\n routeModule.isDev === true || // If this is not SSG or does not have static paths, then it supports\n // dynamic HTML.\n !isIsr;\n // This is a revalidation request if the request is for a static\n // page and it is not being resumed from a postponed render and\n // it is not a dynamic RSC request then it is a revalidation\n // request.\n const isStaticGeneration = isIsr && !supportsDynamicResponse;\n // Before rendering (which initializes component tree modules), we have to\n // set the reference manifests to our global store so Server Action's\n // encryption util can access to them at the top level of the page module.\n if (serverActionsManifest && clientReferenceManifest) {\n setManifestsSingleton({\n page: srcPage,\n clientReferenceManifest,\n serverActionsManifest\n });\n }\n const method = req.method || 'GET';\n const tracer = getTracer();\n const activeSpan = tracer.getActiveScopeSpan();\n const isWrappedByNextServer = Boolean(routerServerContext == null ? void 0 : routerServerContext.isWrappedByNextServer);\n const isMinimalMode = Boolean(getRequestMeta(req, 'minimalMode'));\n const incrementalCache = getRequestMeta(req, 'incrementalCache') || await routeModule.getIncrementalCache(req, nextConfig, prerenderManifest, isMinimalMode);\n incrementalCache == null ? void 0 : incrementalCache.resetRequestCache();\n globalThis.__incrementalCache = incrementalCache;\n const context = {\n params,\n previewProps: prerenderManifest.preview,\n renderOpts: {\n experimental: {\n authInterrupts: Boolean(nextConfig.experimental.authInterrupts)\n },\n cacheComponents: Boolean(nextConfig.cacheComponents),\n supportsDynamicResponse,\n incrementalCache,\n cacheLifeProfiles: nextConfig.cacheLife,\n waitUntil: ctx.waitUntil,\n onClose: (cb)=>{\n res.on('close', cb);\n },\n onAfterTaskError: undefined,\n onInstrumentationRequestError: (error, _request, errorContext, silenceLog)=>routeModule.onRequestError(req, error, errorContext, silenceLog, routerServerContext)\n },\n sharedContext: {\n buildId\n }\n };\n const nodeNextReq = new NodeNextRequest(req);\n const nodeNextRes = new NodeNextResponse(res);\n const nextReq = NextRequestAdapter.fromNodeNextRequest(nodeNextReq, signalFromNodeResponse(res));\n try {\n let parentSpan;\n const invokeRouteModule = async (span)=>{\n return routeModule.handle(nextReq, context).finally(()=>{\n if (!span) return;\n span.setAttributes({\n 'http.status_code': res.statusCode,\n 'next.rsc': false\n });\n const rootSpanAttributes = tracer.getRootSpanAttributes();\n // We were unable to get attributes, probably OTEL is not enabled\n if (!rootSpanAttributes) {\n return;\n }\n if (rootSpanAttributes.get('next.span_type') !== BaseServerSpan.handleRequest) {\n console.warn(`Unexpected root span type '${rootSpanAttributes.get('next.span_type')}'. Please report this Next.js issue https://github.com/vercel/next.js`);\n return;\n }\n const route = rootSpanAttributes.get('next.route');\n if (route) {\n const name = `${method} ${route}`;\n span.setAttributes({\n 'next.route': route,\n 'http.route': route,\n 'next.span_name': name\n });\n span.updateName(name);\n // Propagate http.route to the parent span if one exists (e.g.\n // a platform-created HTTP span in adapter deployments).\n if (parentSpan && parentSpan !== span) {\n parentSpan.setAttribute('http.route', route);\n parentSpan.updateName(name);\n }\n } else {\n span.updateName(`${method} ${srcPage}`);\n }\n });\n };\n const handleResponse = async (currentSpan)=>{\n var _cacheEntry_value;\n const responseGenerator = async ({ previousCacheEntry })=>{\n try {\n if (!isMinimalMode && isOnDemandRevalidate && revalidateOnlyGenerated && !previousCacheEntry) {\n res.statusCode = 404;\n // on-demand revalidate always sets this header\n res.setHeader('x-nextjs-cache', 'REVALIDATED');\n res.end('This page could not be found');\n return null;\n }\n const response = await invokeRouteModule(currentSpan);\n req.fetchMetrics = context.renderOpts.fetchMetrics;\n let pendingWaitUntil = context.renderOpts.pendingWaitUntil;\n // Attempt using provided waitUntil if available\n // if it's not we fallback to sendResponse's handling\n if (pendingWaitUntil) {\n if (ctx.waitUntil) {\n ctx.waitUntil(pendingWaitUntil);\n pendingWaitUntil = undefined;\n }\n }\n const cacheTags = context.renderOpts.collectedTags;\n // If the request is for a static response, we can cache it so long\n // as it's not edge.\n if (isIsr) {\n const blob = await response.blob();\n // Copy the headers from the response.\n const headers = toNodeOutgoingHttpHeaders(response.headers);\n if (cacheTags) {\n headers[NEXT_CACHE_TAGS_HEADER] = cacheTags;\n }\n if (!headers['content-type'] && blob.type) {\n headers['content-type'] = blob.type;\n }\n const revalidate = typeof context.renderOpts.collectedRevalidate === 'undefined' || context.renderOpts.collectedRevalidate >= INFINITE_CACHE ? false : context.renderOpts.collectedRevalidate;\n const expire = typeof context.renderOpts.collectedExpire === 'undefined' || context.renderOpts.collectedExpire >= INFINITE_CACHE ? undefined : context.renderOpts.collectedExpire;\n // Create the cache entry for the response.\n const cacheEntry = {\n value: {\n kind: CachedRouteKind.APP_ROUTE,\n status: response.status,\n body: Buffer.from(await blob.arrayBuffer()),\n headers\n },\n cacheControl: {\n revalidate,\n expire\n }\n };\n return cacheEntry;\n } else {\n // send response without caching if not ISR\n await sendResponse(nodeNextReq, nodeNextRes, response, context.renderOpts.pendingWaitUntil);\n return null;\n }\n } catch (err) {\n // if this is a background revalidate we need to report\n // the request error here as it won't be bubbled\n if (previousCacheEntry == null ? void 0 : previousCacheEntry.isStale) {\n const silenceLog = false;\n await routeModule.onRequestError(req, err, {\n routerKind: 'App Router',\n routePath: srcPage,\n routeType: 'route',\n revalidateReason: getRevalidateReason({\n isStaticGeneration,\n isOnDemandRevalidate\n })\n }, silenceLog, routerServerContext);\n }\n throw err;\n }\n };\n const cacheEntry = await routeModule.handleResponse({\n req,\n nextConfig,\n cacheKey,\n routeKind: RouteKind.APP_ROUTE,\n isFallback: false,\n prerenderManifest,\n isRoutePPREnabled: false,\n isOnDemandRevalidate,\n revalidateOnlyGenerated,\n responseGenerator,\n waitUntil: ctx.waitUntil,\n isMinimalMode\n });\n // we don't create a cacheEntry for ISR\n if (!isIsr) {\n return null;\n }\n if ((cacheEntry == null ? void 0 : (_cacheEntry_value = cacheEntry.value) == null ? void 0 : _cacheEntry_value.kind) !== CachedRouteKind.APP_ROUTE) {\n var _cacheEntry_value1;\n throw Object.defineProperty(new Error(`Invariant: app-route received invalid cache entry ${cacheEntry == null ? void 0 : (_cacheEntry_value1 = cacheEntry.value) == null ? void 0 : _cacheEntry_value1.kind}`), \"__NEXT_ERROR_CODE\", {\n value: \"E701\",\n enumerable: false,\n configurable: true\n });\n }\n if (!isMinimalMode) {\n res.setHeader('x-nextjs-cache', isOnDemandRevalidate ? 'REVALIDATED' : cacheEntry.isMiss ? 'MISS' : cacheEntry.isStale ? 'STALE' : 'HIT');\n }\n // Draft mode should never be cached\n if (isDraftMode) {\n res.setHeader('Cache-Control', 'private, no-cache, no-store, max-age=0, must-revalidate');\n }\n const headers = fromNodeOutgoingHttpHeaders(cacheEntry.value.headers);\n if (!(isMinimalMode && isIsr)) {\n headers.delete(NEXT_CACHE_TAGS_HEADER);\n }\n // If cache control is already set on the response we don't\n // override it to allow users to customize it via next.config\n if (cacheEntry.cacheControl && !res.getHeader('Cache-Control') && !headers.get('Cache-Control')) {\n headers.set('Cache-Control', getCacheControlHeader(cacheEntry.cacheControl));\n }\n await sendResponse(nodeNextReq, nodeNextRes, // @ts-expect-error - Argument of type 'Buffer<ArrayBufferLike>' is not assignable to parameter of type 'BodyInit | null | undefined'.\n new Response(cacheEntry.value.body, {\n headers,\n status: cacheEntry.value.status || 200\n }));\n return null;\n };\n // TODO: activeSpan code path is for when wrapped by\n // next-server can be removed when this is no longer used\n if (isWrappedByNextServer && activeSpan) {\n await handleResponse(activeSpan);\n } else {\n parentSpan = tracer.getActiveScopeSpan();\n await tracer.withPropagatedContext(req.headers, ()=>tracer.trace(BaseServerSpan.handleRequest, {\n spanName: `${method} ${srcPage}`,\n kind: SpanKind.SERVER,\n attributes: {\n 'http.method': method,\n 'http.target': req.url\n }\n }, handleResponse), undefined, !isWrappedByNextServer);\n }\n } catch (err) {\n if (!(err instanceof NoFallbackError)) {\n const silenceLog = false;\n await routeModule.onRequestError(req, err, {\n routerKind: 'App Router',\n routePath: normalizedSrcPage,\n routeType: 'route',\n revalidateReason: getRevalidateReason({\n isStaticGeneration,\n isOnDemandRevalidate\n })\n }, silenceLog, routerServerContext);\n }\n // rethrow so that we can handle serving error page\n // If this is during static generation, throw the error again.\n if (isIsr) throw err;\n // Otherwise, send a 500 response.\n await sendResponse(nodeNextReq, nodeNextRes, new Response(null, {\n status: 500\n }));\n return null;\n }\n}\n\n//# sourceMappingURL=app-route.js.map\n"],"names":["runtime","GET","request","searchParams","URL","url","id","get","includeKey","sanitized","message","provider","parseInt","json","error","status","api_key","providers","map","p","console","stack","undefined","POST","body","name","protocol","base_url","encryptedKey","trim","PUT","success","existingProvider","updateData","DELETE"],"mappings":"8iCCAA,IAAA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACAS,EAAAA,EAAAA,CAAAA,CAAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,CAAA,CAAA,OAAA,IAAA,EAAA,EAAA,CAAA,CAAA,KDhBA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OAKO,eAAeR,EAAIC,CAAoB,EAC5C,GAAI,CACF,MAAM,CAAA,EAAA,EAAA,WAAA,AAAW,IACjB,G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,mCA3TA,SAAS,EACL,MAAO,CAAA,EAAA,EAAA,UAAA,AAAW,EAAC,kBACf,uBACA,CACJ,EACJ","ignoreList":[1]}
@@ -1,12 +1,52 @@
1
1
  const RUNTIME_PUBLIC_PATH = "server/chunks/[turbopack]_runtime.js";
2
2
  const RELATIVE_ROOT_PATH = "..";
3
3
  const ASSET_PREFIX = "/";
4
+ const WORKER_FORWARDED_GLOBALS = ["NEXT_DEPLOYMENT_ID","NEXT_CLIENT_ASSET_SUFFIX"];
5
+ // Apply forwarded globals from workerData if running in a worker thread
6
+ if (typeof require !== 'undefined') {
7
+ try {
8
+ const { workerData } = require('worker_threads');
9
+ if (workerData?.__turbopack_globals__) {
10
+ Object.assign(globalThis, workerData.__turbopack_globals__);
11
+ // Remove internal data so it's not visible to user code
12
+ delete workerData.__turbopack_globals__;
13
+ }
14
+ } catch (_) {
15
+ // Not in a worker thread context, ignore
16
+ }
17
+ }
4
18
  /**
5
19
  * This file contains runtime types and functions that are shared between all
6
20
  * TurboPack ECMAScript runtimes.
7
21
  *
8
22
  * It will be prepended to the runtime code of each runtime.
9
23
  */ /* eslint-disable @typescript-eslint/no-unused-vars */ /// <reference path="./runtime-types.d.ts" />
24
+ /**
25
+ * Describes why a module was instantiated.
26
+ * Shared between browser and Node.js runtimes.
27
+ */ var SourceType = /*#__PURE__*/ function(SourceType) {
28
+ /**
29
+ * The module was instantiated because it was included in an evaluated chunk's
30
+ * runtime.
31
+ * SourceData is a ChunkPath.
32
+ */ SourceType[SourceType["Runtime"] = 0] = "Runtime";
33
+ /**
34
+ * The module was instantiated because a parent module imported it.
35
+ * SourceData is a ModuleId.
36
+ */ SourceType[SourceType["Parent"] = 1] = "Parent";
37
+ /**
38
+ * The module was instantiated because it was included in a chunk's hot module
39
+ * update.
40
+ * SourceData is an array of ModuleIds or undefined.
41
+ */ SourceType[SourceType["Update"] = 2] = "Update";
42
+ return SourceType;
43
+ }(SourceType || {});
44
+ /**
45
+ * Flag indicating which module object type to create when a module is merged. Set to `true`
46
+ * by each runtime that uses ModuleWithDirection (browser dev-base.ts, nodejs dev-base.ts,
47
+ * nodejs build-base.ts). Browser production (build-base.ts) leaves it as `false` since it
48
+ * uses plain Module objects.
49
+ */ let createModuleWithDirectionFlag = false;
10
50
  const REEXPORTED_OBJECTS = new WeakMap();
11
51
  /**
12
52
  * Constructs the `__turbopack_context__` object for a module.
@@ -30,9 +70,12 @@ function defineProp(obj, name, options) {
30
70
  function getOverwrittenModule(moduleCache, id) {
31
71
  let module = moduleCache[id];
32
72
  if (!module) {
33
- // This is invoked when a module is merged into another module, thus it wasn't invoked via
34
- // instantiateModule and the cache entry wasn't created yet.
35
- module = createModuleObject(id);
73
+ if (createModuleWithDirectionFlag) {
74
+ // set in development modes for hmr support
75
+ module = createModuleWithDirection(id);
76
+ } else {
77
+ module = createModuleObject(id);
78
+ }
36
79
  moduleCache[id] = module;
37
80
  }
38
81
  return module;
@@ -47,6 +90,16 @@ function getOverwrittenModule(moduleCache, id) {
47
90
  namespaceObject: undefined
48
91
  };
49
92
  }
93
+ function createModuleWithDirection(id) {
94
+ return {
95
+ exports: {},
96
+ error: undefined,
97
+ id,
98
+ namespaceObject: undefined,
99
+ parents: [],
100
+ children: []
101
+ };
102
+ }
50
103
  const BindingTag_Value = 0;
51
104
  /**
52
105
  * Adds the getters to the exports object.
@@ -331,7 +384,6 @@ function createPromise() {
331
384
  function installCompressedModuleFactories(chunkModules, offset, moduleFactories, newModuleId) {
332
385
  let i = offset;
333
386
  while(i < chunkModules.length){
334
- let moduleId = chunkModules[i];
335
387
  let end = i + 1;
336
388
  // Find our factory function
337
389
  while(end < chunkModules.length && typeof chunkModules[end] !== 'function'){
@@ -340,15 +392,33 @@ function installCompressedModuleFactories(chunkModules, offset, moduleFactories,
340
392
  if (end === chunkModules.length) {
341
393
  throw new Error('malformed chunk format, expected a factory function');
342
394
  }
343
- // Each chunk item has a 'primary id' and optional additional ids. If the primary id is already
344
- // present we know all the additional ids are also present, so we don't need to check.
345
- if (!moduleFactories.has(moduleId)) {
346
- const moduleFactoryFn = chunkModules[end];
347
- applyModuleFactoryName(moduleFactoryFn);
348
- newModuleId?.(moduleId);
349
- for(; i < end; i++){
350
- moduleId = chunkModules[i];
351
- moduleFactories.set(moduleId, moduleFactoryFn);
395
+ // Install the factory for each module ID that doesn't already have one.
396
+ // When some IDs in this group already have a factory, reuse that existing
397
+ // group factory for the missing IDs to keep all IDs in the group consistent.
398
+ // Otherwise, install the factory from this chunk.
399
+ const moduleFactoryFn = chunkModules[end];
400
+ let existingGroupFactory = undefined;
401
+ for(let j = i; j < end; j++){
402
+ const id = chunkModules[j];
403
+ const existingFactory = moduleFactories.get(id);
404
+ if (existingFactory) {
405
+ existingGroupFactory = existingFactory;
406
+ break;
407
+ }
408
+ }
409
+ const factoryToInstall = existingGroupFactory ?? moduleFactoryFn;
410
+ let didInstallFactory = false;
411
+ for(let j = i; j < end; j++){
412
+ const id = chunkModules[j];
413
+ if (!moduleFactories.has(id)) {
414
+ if (!didInstallFactory) {
415
+ if (factoryToInstall === moduleFactoryFn) {
416
+ applyModuleFactoryName(moduleFactoryFn);
417
+ }
418
+ didInstallFactory = true;
419
+ }
420
+ moduleFactories.set(id, factoryToInstall);
421
+ newModuleId?.(id);
352
422
  }
353
423
  }
354
424
  i = end + 1; // end is pointing at the last factory advance to the next id or the end of the array.
@@ -488,6 +558,25 @@ contextPrototype.U = relativeURL;
488
558
  */ function invariant(never, computeMessage) {
489
559
  throw new Error(`Invariant: ${computeMessage(never)}`);
490
560
  }
561
+ /**
562
+ * Constructs an error message for when a module factory is not available.
563
+ */ function factoryNotAvailableMessage(moduleId, sourceType, sourceData) {
564
+ let instantiationReason;
565
+ switch(sourceType){
566
+ case 0:
567
+ instantiationReason = `as a runtime entry of chunk ${sourceData}`;
568
+ break;
569
+ case 1:
570
+ instantiationReason = `because it was required from module ${sourceData}`;
571
+ break;
572
+ case 2:
573
+ instantiationReason = 'because of an HMR update';
574
+ break;
575
+ default:
576
+ invariant(sourceType, (sourceType)=>`Unknown source type: ${sourceType}`);
577
+ }
578
+ return `Module ${moduleId} was instantiated ${instantiationReason}, but the module factory is not available.`;
579
+ }
491
580
  /**
492
581
  * A stub function to make `require` available but non-functional in ESM.
493
582
  */ function requireStub(_moduleId) {
@@ -502,7 +591,7 @@ function applyModuleFactoryName(factory) {
502
591
  value: 'module evaluation'
503
592
  });
504
593
  }
505
- /// <reference path="../shared/runtime-utils.ts" />
594
+ /// <reference path="../shared/runtime/runtime-utils.ts" />
506
595
  /// A 'base' utilities to support runtime can have externals.
507
596
  /// Currently this is for node.js / edge runtime both.
508
597
  /// If a fn requires node.js specific behavior, it should be placed in `node-external-utils` instead.
@@ -564,7 +653,7 @@ const ABSOLUTE_ROOT = path.resolve(__filename, relativePathToDistRoot);
564
653
  return ABSOLUTE_ROOT;
565
654
  }
566
655
  Context.prototype.P = resolveAbsolutePath;
567
- /* eslint-disable @typescript-eslint/no-unused-vars */ /// <reference path="../shared/runtime-utils.ts" />
656
+ /* eslint-disable @typescript-eslint/no-unused-vars */ /// <reference path="../shared/runtime/runtime-utils.ts" />
568
657
  function readWebAssemblyAsResponse(path) {
569
658
  const { createReadStream } = require('fs');
570
659
  const { Readable } = require('stream');
@@ -585,29 +674,18 @@ async function instantiateWebAssemblyFromPath(path, importsObj) {
585
674
  const { instance } = await WebAssembly.instantiateStreaming(response, importsObj);
586
675
  return instance.exports;
587
676
  }
588
- /* eslint-disable @typescript-eslint/no-unused-vars */ /// <reference path="../shared/runtime-utils.ts" />
589
- /// <reference path="../shared-node/base-externals-utils.ts" />
590
- /// <reference path="../shared-node/node-externals-utils.ts" />
591
- /// <reference path="../shared-node/node-wasm-utils.ts" />
592
- var SourceType = /*#__PURE__*/ function(SourceType) {
593
- /**
594
- * The module was instantiated because it was included in an evaluated chunk's
595
- * runtime.
596
- * SourceData is a ChunkPath.
597
- */ SourceType[SourceType["Runtime"] = 0] = "Runtime";
598
- /**
599
- * The module was instantiated because a parent module imported it.
600
- * SourceData is a ModuleId.
601
- */ SourceType[SourceType["Parent"] = 1] = "Parent";
602
- return SourceType;
603
- }(SourceType || {});
604
- process.env.TURBOPACK = '1';
605
- const nodeContextPrototype = Context.prototype;
677
+ /* eslint-disable @typescript-eslint/no-unused-vars */ /// <reference path="../../shared/runtime/runtime-utils.ts" />
678
+ /// <reference path="../../shared-node/base-externals-utils.ts" />
679
+ /// <reference path="../../shared-node/node-externals-utils.ts" />
680
+ /// <reference path="../../shared-node/node-wasm-utils.ts" />
681
+ /// <reference path="./nodejs-globals.d.ts" />
682
+ /**
683
+ * Base Node.js runtime shared between production and development.
684
+ * Contains chunk loading, module caching, and other non-HMR functionality.
685
+ */ process.env.TURBOPACK = '1';
606
686
  const url = require('url');
607
687
  const moduleFactories = new Map();
608
- nodeContextPrototype.M = moduleFactories;
609
688
  const moduleCache = Object.create(null);
610
- nodeContextPrototype.c = moduleCache;
611
689
  /**
612
690
  * Returns an absolute path to the given module's id.
613
691
  */ function resolvePathFromModule(moduleId) {
@@ -620,7 +698,11 @@ nodeContextPrototype.c = moduleCache;
620
698
  const resolved = path.resolve(RUNTIME_ROOT, strippedAssetPrefix);
621
699
  return url.pathToFileURL(resolved).href;
622
700
  }
623
- nodeContextPrototype.R = resolvePathFromModule;
701
+ /**
702
+ * Exports a URL value. No suffix is added in Node.js runtime.
703
+ */ function exportUrl(urlValue, id) {
704
+ exportValue.call(this, urlValue, id);
705
+ }
624
706
  function loadRuntimeChunk(sourcePath, chunkData) {
625
707
  if (typeof chunkData === 'string') {
626
708
  loadRuntimeChunkPath(sourcePath, chunkData);
@@ -634,6 +716,7 @@ const loadedChunk = Promise.resolve(undefined);
634
716
  const chunkCache = new Map();
635
717
  function clearChunkCache() {
636
718
  chunkCache.clear();
719
+ loadedChunks.clear();
637
720
  }
638
721
  function loadRuntimeChunkPath(sourcePath, chunkPath) {
639
722
  if (!isJs(chunkPath)) {
@@ -708,30 +791,60 @@ function loadWebAssemblyModule(chunkPath, _edgeModule) {
708
791
  return compileWebAssemblyFromPath(resolved);
709
792
  }
710
793
  contextPrototype.u = loadWebAssemblyModule;
711
- function getWorkerBlobURL(_chunks) {
712
- throw new Error('Worker blobs are not implemented yet for Node.js');
794
+ /**
795
+ * Creates a Node.js worker thread by instantiating the given WorkerConstructor
796
+ * with the appropriate path and options, including forwarded globals.
797
+ *
798
+ * @param WorkerConstructor The Worker constructor from worker_threads
799
+ * @param workerPath Path to the worker entry chunk
800
+ * @param workerOptions options to pass to the Worker constructor (optional)
801
+ */ function createWorker(WorkerConstructor, workerPath, workerOptions) {
802
+ // Build the forwarded globals object
803
+ const forwardedGlobals = {};
804
+ for (const name of WORKER_FORWARDED_GLOBALS){
805
+ forwardedGlobals[name] = globalThis[name];
806
+ }
807
+ // Merge workerData with forwarded globals
808
+ const existingWorkerData = workerOptions?.workerData || {};
809
+ const options = {
810
+ ...workerOptions,
811
+ workerData: {
812
+ ...typeof existingWorkerData === 'object' ? existingWorkerData : {},
813
+ __turbopack_globals__: forwardedGlobals
814
+ }
815
+ };
816
+ return new WorkerConstructor(workerPath, options);
713
817
  }
714
- nodeContextPrototype.b = getWorkerBlobURL;
818
+ const regexJsUrl = /\.js(?:\?[^#]*)?(?:#.*)?$/;
819
+ /**
820
+ * Checks if a given path/URL ends with .js, optionally followed by ?query or #fragment.
821
+ */ function isJs(chunkUrlOrPath) {
822
+ return regexJsUrl.test(chunkUrlOrPath);
823
+ }
824
+ /* eslint-disable @typescript-eslint/no-unused-vars */ /// <reference path="./runtime-base.ts" />
825
+ /**
826
+ * Production Node.js runtime.
827
+ * Uses ModuleWithDirection and simple module instantiation without HMR support.
828
+ */ // moduleCache and moduleFactories are declared in runtime-base.ts
829
+ // this is read in runtime-utils.ts so it creates a module with direction for hmr
830
+ createModuleWithDirectionFlag = true;
831
+ const nodeContextPrototype = Context.prototype;
832
+ nodeContextPrototype.q = exportUrl;
833
+ nodeContextPrototype.M = moduleFactories;
834
+ // Cast moduleCache to ModuleWithDirection for production mode
835
+ nodeContextPrototype.c = moduleCache;
836
+ nodeContextPrototype.R = resolvePathFromModule;
837
+ nodeContextPrototype.b = createWorker;
838
+ nodeContextPrototype.C = clearChunkCache;
715
839
  function instantiateModule(id, sourceType, sourceData) {
716
840
  const moduleFactory = moduleFactories.get(id);
717
841
  if (typeof moduleFactory !== 'function') {
718
842
  // This can happen if modules incorrectly handle HMR disposes/updates,
719
843
  // e.g. when they keep a `setTimeout` around which still executes old code
720
844
  // and contains e.g. a `require("something")` call.
721
- let instantiationReason;
722
- switch(sourceType){
723
- case 0:
724
- instantiationReason = `as a runtime entry of chunk ${sourceData}`;
725
- break;
726
- case 1:
727
- instantiationReason = `because it was required from module ${sourceData}`;
728
- break;
729
- default:
730
- invariant(sourceType, (sourceType)=>`Unknown source type: ${sourceType}`);
731
- }
732
- throw new Error(`Module ${id} was instantiated ${instantiationReason}, but the module factory is not available.`);
845
+ throw new Error(factoryNotAvailableMessage(id, sourceType, sourceData));
733
846
  }
734
- const module1 = createModuleObject(id);
847
+ const module1 = createModuleWithDirection(id);
735
848
  const exports = module1.exports;
736
849
  moduleCache[id] = module1;
737
850
  const context = new Context(module1, exports);
@@ -742,6 +855,7 @@ function instantiateModule(id, sourceType, sourceData) {
742
855
  module1.error = error;
743
856
  throw error;
744
857
  }
858
+ ;
745
859
  module1.loaded = true;
746
860
  if (module1.namespaceObject && module1.exports !== module1.namespaceObject) {
747
861
  // in case of a circular dependency: cjs1 -> esm2 -> cjs1
@@ -760,12 +874,12 @@ function getOrInstantiateModuleFromParent(id, sourceModule) {
760
874
  }
761
875
  return module1;
762
876
  }
763
- return instantiateModule(id, 1, sourceModule.id);
877
+ return instantiateModule(id, SourceType.Parent, sourceModule.id);
764
878
  }
765
879
  /**
766
880
  * Instantiates a runtime module.
767
881
  */ function instantiateRuntimeModule(chunkPath, moduleId) {
768
- return instantiateModule(moduleId, 0, chunkPath);
882
+ return instantiateModule(moduleId, SourceType.Runtime, chunkPath);
769
883
  }
770
884
  /**
771
885
  * Retrieves a module from the cache, or instantiate it as a runtime module if it is not cached.
@@ -780,12 +894,6 @@ function getOrInstantiateRuntimeModule(chunkPath, moduleId) {
780
894
  }
781
895
  return instantiateRuntimeModule(chunkPath, moduleId);
782
896
  }
783
- const regexJsUrl = /\.js(?:\?[^#]*)?(?:#.*)?$/;
784
- /**
785
- * Checks if a given path/URL ends with .js, optionally followed by ?query or #fragment.
786
- */ function isJs(chunkUrlOrPath) {
787
- return regexJsUrl.test(chunkUrlOrPath);
788
- }
789
897
  module.exports = (sourcePath)=>({
790
898
  m: (id)=>getOrInstantiateRuntimeModule(sourcePath, id),
791
899
  c: (chunkData)=>loadRuntimeChunk(sourcePath, chunkData)