ai-agent-router 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (354) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-path-routes-manifest.json +14 -0
  3. package/.next/build-manifest.json +2 -2
  4. package/.next/fallback-build-manifest.json +2 -2
  5. package/.next/next-server.js.nft.json +1 -1
  6. package/.next/prerender-manifest.json +3 -3
  7. package/.next/required-server-files.js +4 -4
  8. package/.next/required-server-files.json +4 -4
  9. package/.next/routes-manifest.json +84 -0
  10. package/.next/server/app/_global-error/page.js +1 -1
  11. package/.next/server/app/_global-error/page.js.nft.json +1 -1
  12. package/.next/server/app/_global-error.html +2 -2
  13. package/.next/server/app/_global-error.rsc +1 -1
  14. package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  15. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  16. package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  17. package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  18. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  19. package/.next/server/app/_not-found/page.js +2 -2
  20. package/.next/server/app/_not-found/page.js.nft.json +1 -1
  21. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  22. package/.next/server/app/_not-found.html +1 -1
  23. package/.next/server/app/_not-found.rsc +2 -2
  24. package/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
  25. package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  26. package/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
  27. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  28. package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  29. package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  30. package/.next/server/app/api/config/route.js.nft.json +1 -1
  31. package/.next/server/app/api/gateway/[...path]/route.js.nft.json +1 -1
  32. package/.next/server/app/api/gateway/models/route.js.nft.json +1 -1
  33. package/.next/server/app/api/gateway/route.js.nft.json +1 -1
  34. package/.next/server/app/api/ide/claude/apply/route.js.nft.json +1 -1
  35. package/.next/server/app/api/ide/claude/available-models/route.js.nft.json +1 -1
  36. package/.next/server/app/api/ide/claude/restore/route.js.nft.json +1 -1
  37. package/.next/server/app/api/ide/claude/save/route.js.nft.json +1 -1
  38. package/.next/server/app/api/ide/claude/status/route.js.nft.json +1 -1
  39. package/.next/server/app/api/ide/claude/test/route.js +1 -1
  40. package/.next/server/app/api/ide/claude/test/route.js.nft.json +1 -1
  41. package/.next/server/app/api/ide/openclaw/apply/route/app-paths-manifest.json +3 -0
  42. package/.next/server/app/api/ide/openclaw/apply/route/build-manifest.json +11 -0
  43. package/.next/server/app/api/ide/openclaw/apply/route/server-reference-manifest.json +4 -0
  44. package/.next/server/app/api/ide/openclaw/apply/route.js +7 -0
  45. package/.next/server/app/api/ide/openclaw/apply/route.js.map +5 -0
  46. package/.next/server/app/api/ide/openclaw/apply/route.js.nft.json +1 -0
  47. package/.next/server/app/api/ide/openclaw/apply/route_client-reference-manifest.js +2 -0
  48. package/.next/server/app/api/ide/openclaw/available-models/route/app-paths-manifest.json +3 -0
  49. package/.next/server/app/api/ide/openclaw/available-models/route/build-manifest.json +11 -0
  50. package/.next/server/app/api/ide/openclaw/available-models/route/server-reference-manifest.json +4 -0
  51. package/.next/server/app/api/ide/openclaw/available-models/route.js +7 -0
  52. package/.next/server/app/api/ide/openclaw/available-models/route.js.map +5 -0
  53. package/.next/server/app/api/ide/openclaw/available-models/route.js.nft.json +1 -0
  54. package/.next/server/app/api/ide/openclaw/available-models/route_client-reference-manifest.js +2 -0
  55. package/.next/server/app/api/ide/openclaw/preview/route/app-paths-manifest.json +3 -0
  56. package/.next/server/app/api/ide/openclaw/preview/route/build-manifest.json +11 -0
  57. package/.next/server/app/api/ide/openclaw/preview/route/server-reference-manifest.json +4 -0
  58. package/.next/server/app/api/ide/openclaw/preview/route.js +7 -0
  59. package/.next/server/app/api/ide/openclaw/preview/route.js.map +5 -0
  60. package/.next/server/app/api/ide/openclaw/preview/route.js.nft.json +1 -0
  61. package/.next/server/app/api/ide/openclaw/preview/route_client-reference-manifest.js +2 -0
  62. package/.next/server/app/api/ide/openclaw/restore/route/app-paths-manifest.json +3 -0
  63. package/.next/server/app/api/ide/openclaw/restore/route/build-manifest.json +11 -0
  64. package/.next/server/app/api/ide/openclaw/restore/route/server-reference-manifest.json +4 -0
  65. package/.next/server/app/api/ide/openclaw/restore/route.js +6 -0
  66. package/.next/server/app/api/ide/openclaw/restore/route.js.map +5 -0
  67. package/.next/server/app/api/ide/openclaw/restore/route.js.nft.json +1 -0
  68. package/.next/server/app/api/ide/openclaw/restore/route_client-reference-manifest.js +2 -0
  69. package/.next/server/app/api/ide/openclaw/save/route/app-paths-manifest.json +3 -0
  70. package/.next/server/app/api/ide/openclaw/save/route/build-manifest.json +11 -0
  71. package/.next/server/app/api/ide/openclaw/save/route/server-reference-manifest.json +4 -0
  72. package/.next/server/app/api/ide/openclaw/save/route.js +7 -0
  73. package/.next/server/app/api/ide/openclaw/save/route.js.map +5 -0
  74. package/.next/server/app/api/ide/openclaw/save/route.js.nft.json +1 -0
  75. package/.next/server/app/api/ide/openclaw/save/route_client-reference-manifest.js +2 -0
  76. package/.next/server/app/api/ide/openclaw/status/route/app-paths-manifest.json +3 -0
  77. package/.next/server/app/api/ide/openclaw/status/route/build-manifest.json +11 -0
  78. package/.next/server/app/api/ide/openclaw/status/route/server-reference-manifest.json +4 -0
  79. package/.next/server/app/api/ide/openclaw/status/route.js +7 -0
  80. package/.next/server/app/api/ide/openclaw/status/route.js.map +5 -0
  81. package/.next/server/app/api/ide/openclaw/status/route.js.nft.json +1 -0
  82. package/.next/server/app/api/ide/openclaw/status/route_client-reference-manifest.js +2 -0
  83. package/.next/server/app/api/ide/openclaw/test/route/app-paths-manifest.json +3 -0
  84. package/.next/server/app/api/ide/openclaw/test/route/build-manifest.json +11 -0
  85. package/.next/server/app/api/ide/openclaw/test/route/server-reference-manifest.json +4 -0
  86. package/.next/server/app/api/ide/openclaw/test/route.js +6 -0
  87. package/.next/server/app/api/ide/openclaw/test/route.js.map +5 -0
  88. package/.next/server/app/api/ide/openclaw/test/route.js.nft.json +1 -0
  89. package/.next/server/app/api/ide/openclaw/test/route_client-reference-manifest.js +2 -0
  90. package/.next/server/app/api/ide/opencode/apply/route/app-paths-manifest.json +3 -0
  91. package/.next/server/app/api/ide/opencode/apply/route/build-manifest.json +11 -0
  92. package/.next/server/app/api/ide/opencode/apply/route/server-reference-manifest.json +4 -0
  93. package/.next/server/app/api/ide/opencode/apply/route.js +7 -0
  94. package/.next/server/app/api/ide/opencode/apply/route.js.map +5 -0
  95. package/.next/server/app/api/ide/opencode/apply/route.js.nft.json +1 -0
  96. package/.next/server/app/api/ide/opencode/apply/route_client-reference-manifest.js +2 -0
  97. package/.next/server/app/api/ide/opencode/available-models/route/app-paths-manifest.json +3 -0
  98. package/.next/server/app/api/ide/opencode/available-models/route/build-manifest.json +11 -0
  99. package/.next/server/app/api/ide/opencode/available-models/route/server-reference-manifest.json +4 -0
  100. package/.next/server/app/api/ide/opencode/available-models/route.js +7 -0
  101. package/.next/server/app/api/ide/opencode/available-models/route.js.map +5 -0
  102. package/.next/server/app/api/ide/opencode/available-models/route.js.nft.json +1 -0
  103. package/.next/server/app/api/ide/opencode/available-models/route_client-reference-manifest.js +2 -0
  104. package/.next/server/app/api/ide/opencode/preview/route/app-paths-manifest.json +3 -0
  105. package/.next/server/app/api/ide/opencode/preview/route/build-manifest.json +11 -0
  106. package/.next/server/app/api/ide/opencode/preview/route/server-reference-manifest.json +4 -0
  107. package/.next/server/app/api/ide/opencode/preview/route.js +7 -0
  108. package/.next/server/app/api/ide/opencode/preview/route.js.map +5 -0
  109. package/.next/server/app/api/ide/opencode/preview/route.js.nft.json +1 -0
  110. package/.next/server/app/api/ide/opencode/preview/route_client-reference-manifest.js +2 -0
  111. package/.next/server/app/api/ide/opencode/restore/route/app-paths-manifest.json +3 -0
  112. package/.next/server/app/api/ide/opencode/restore/route/build-manifest.json +11 -0
  113. package/.next/server/app/api/ide/opencode/restore/route/server-reference-manifest.json +4 -0
  114. package/.next/server/app/api/ide/opencode/restore/route.js +6 -0
  115. package/.next/server/app/api/ide/opencode/restore/route.js.map +5 -0
  116. package/.next/server/app/api/ide/opencode/restore/route.js.nft.json +1 -0
  117. package/.next/server/app/api/ide/opencode/restore/route_client-reference-manifest.js +2 -0
  118. package/.next/server/app/api/ide/opencode/save/route/app-paths-manifest.json +3 -0
  119. package/.next/server/app/api/ide/opencode/save/route/build-manifest.json +11 -0
  120. package/.next/server/app/api/ide/opencode/save/route/server-reference-manifest.json +4 -0
  121. package/.next/server/app/api/ide/opencode/save/route.js +7 -0
  122. package/.next/server/app/api/ide/opencode/save/route.js.map +5 -0
  123. package/.next/server/app/api/ide/opencode/save/route.js.nft.json +1 -0
  124. package/.next/server/app/api/ide/opencode/save/route_client-reference-manifest.js +2 -0
  125. package/.next/server/app/api/ide/opencode/status/route/app-paths-manifest.json +3 -0
  126. package/.next/server/app/api/ide/opencode/status/route/build-manifest.json +11 -0
  127. package/.next/server/app/api/ide/opencode/status/route/server-reference-manifest.json +4 -0
  128. package/.next/server/app/api/ide/opencode/status/route.js +7 -0
  129. package/.next/server/app/api/ide/opencode/status/route.js.map +5 -0
  130. package/.next/server/app/api/ide/opencode/status/route.js.nft.json +1 -0
  131. package/.next/server/app/api/ide/opencode/status/route_client-reference-manifest.js +2 -0
  132. package/.next/server/app/api/ide/opencode/test/route/app-paths-manifest.json +3 -0
  133. package/.next/server/app/api/ide/opencode/test/route/build-manifest.json +11 -0
  134. package/.next/server/app/api/ide/opencode/test/route/server-reference-manifest.json +4 -0
  135. package/.next/server/app/api/ide/opencode/test/route.js +6 -0
  136. package/.next/server/app/api/ide/opencode/test/route.js.map +5 -0
  137. package/.next/server/app/api/ide/opencode/test/route.js.nft.json +1 -0
  138. package/.next/server/app/api/ide/opencode/test/route_client-reference-manifest.js +2 -0
  139. package/.next/server/app/api/logs/route.js.nft.json +1 -1
  140. package/.next/server/app/api/models/route.js.nft.json +1 -1
  141. package/.next/server/app/api/providers/route.js.nft.json +1 -1
  142. package/.next/server/app/api/providers/test/route.js.nft.json +1 -1
  143. package/.next/server/app/api/service/force-stop/route.js.nft.json +1 -1
  144. package/.next/server/app/api/service/start/route.js.nft.json +1 -1
  145. package/.next/server/app/api/service/status/route.js.nft.json +1 -1
  146. package/.next/server/app/api/service/stop/route.js.nft.json +1 -1
  147. package/.next/server/app/ide/page.js +2 -2
  148. package/.next/server/app/ide/page.js.nft.json +1 -1
  149. package/.next/server/app/ide/page_client-reference-manifest.js +1 -1
  150. package/.next/server/app/ide.html +1 -1
  151. package/.next/server/app/ide.rsc +3 -3
  152. package/.next/server/app/ide.segments/_full.segment.rsc +3 -3
  153. package/.next/server/app/ide.segments/_head.segment.rsc +1 -1
  154. package/.next/server/app/ide.segments/_index.segment.rsc +2 -2
  155. package/.next/server/app/ide.segments/_tree.segment.rsc +2 -2
  156. package/.next/server/app/ide.segments/ide/__PAGE__.segment.rsc +2 -2
  157. package/.next/server/app/ide.segments/ide.segment.rsc +1 -1
  158. package/.next/server/app/index.html +1 -1
  159. package/.next/server/app/index.rsc +2 -2
  160. package/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  161. package/.next/server/app/index.segments/_full.segment.rsc +2 -2
  162. package/.next/server/app/index.segments/_head.segment.rsc +1 -1
  163. package/.next/server/app/index.segments/_index.segment.rsc +2 -2
  164. package/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  165. package/.next/server/app/logs/page.js +2 -2
  166. package/.next/server/app/logs/page.js.nft.json +1 -1
  167. package/.next/server/app/logs/page_client-reference-manifest.js +1 -1
  168. package/.next/server/app/logs.html +1 -1
  169. package/.next/server/app/logs.rsc +3 -3
  170. package/.next/server/app/logs.segments/_full.segment.rsc +3 -3
  171. package/.next/server/app/logs.segments/_head.segment.rsc +1 -1
  172. package/.next/server/app/logs.segments/_index.segment.rsc +2 -2
  173. package/.next/server/app/logs.segments/_tree.segment.rsc +2 -2
  174. package/.next/server/app/logs.segments/logs/__PAGE__.segment.rsc +2 -2
  175. package/.next/server/app/logs.segments/logs.segment.rsc +1 -1
  176. package/.next/server/app/models/page.js +2 -2
  177. package/.next/server/app/models/page.js.nft.json +1 -1
  178. package/.next/server/app/models/page_client-reference-manifest.js +1 -1
  179. package/.next/server/app/models.html +1 -1
  180. package/.next/server/app/models.rsc +2 -2
  181. package/.next/server/app/models.segments/_full.segment.rsc +2 -2
  182. package/.next/server/app/models.segments/_head.segment.rsc +1 -1
  183. package/.next/server/app/models.segments/_index.segment.rsc +2 -2
  184. package/.next/server/app/models.segments/_tree.segment.rsc +2 -2
  185. package/.next/server/app/models.segments/models/__PAGE__.segment.rsc +1 -1
  186. package/.next/server/app/models.segments/models.segment.rsc +1 -1
  187. package/.next/server/app/page.js +2 -2
  188. package/.next/server/app/page.js.nft.json +1 -1
  189. package/.next/server/app/page_client-reference-manifest.js +1 -1
  190. package/.next/server/app/providers/page.js +2 -2
  191. package/.next/server/app/providers/page.js.nft.json +1 -1
  192. package/.next/server/app/providers/page_client-reference-manifest.js +1 -1
  193. package/.next/server/app/providers.html +1 -1
  194. package/.next/server/app/providers.rsc +2 -2
  195. package/.next/server/app/providers.segments/_full.segment.rsc +2 -2
  196. package/.next/server/app/providers.segments/_head.segment.rsc +1 -1
  197. package/.next/server/app/providers.segments/_index.segment.rsc +2 -2
  198. package/.next/server/app/providers.segments/_tree.segment.rsc +2 -2
  199. package/.next/server/app/providers.segments/providers/__PAGE__.segment.rsc +1 -1
  200. package/.next/server/app/providers.segments/providers.segment.rsc +1 -1
  201. package/.next/server/app-paths-manifest.json +14 -0
  202. package/.next/server/chunks/[root-of-the-server]__001d5756._.js +3 -0
  203. package/.next/server/chunks/[root-of-the-server]__001d5756._.js.map +1 -0
  204. package/.next/server/chunks/[root-of-the-server]__05f8578b._.js +3 -0
  205. package/.next/server/chunks/[root-of-the-server]__05f8578b._.js.map +1 -0
  206. package/.next/server/chunks/[root-of-the-server]__3a204d25._.js +1 -1
  207. package/.next/server/chunks/[root-of-the-server]__3a204d25._.js.map +1 -1
  208. package/.next/server/chunks/[root-of-the-server]__43810962._.js +3 -0
  209. package/.next/server/chunks/[root-of-the-server]__43810962._.js.map +1 -0
  210. package/.next/server/chunks/[root-of-the-server]__4a8f9bc7._.js +1 -1
  211. package/.next/server/chunks/[root-of-the-server]__4a8f9bc7._.js.map +1 -1
  212. package/.next/server/chunks/[root-of-the-server]__55cd88b8._.js +3 -0
  213. package/.next/server/chunks/[root-of-the-server]__55cd88b8._.js.map +1 -0
  214. package/.next/server/chunks/[root-of-the-server]__5e8276bc._.js +1 -1
  215. package/.next/server/chunks/[root-of-the-server]__5e8276bc._.js.map +1 -1
  216. package/.next/server/chunks/[root-of-the-server]__760eaa16._.js +3 -0
  217. package/.next/server/chunks/[root-of-the-server]__760eaa16._.js.map +1 -0
  218. package/.next/server/chunks/[root-of-the-server]__7c298a19._.js +3 -0
  219. package/.next/server/chunks/[root-of-the-server]__7c298a19._.js.map +1 -0
  220. package/.next/server/chunks/[root-of-the-server]__85540228._.js +3 -0
  221. package/.next/server/chunks/[root-of-the-server]__85540228._.js.map +1 -0
  222. package/.next/server/chunks/[root-of-the-server]__94fe8d3c._.js +3 -0
  223. package/.next/server/chunks/[root-of-the-server]__94fe8d3c._.js.map +1 -0
  224. package/.next/server/chunks/[root-of-the-server]__97622908._.js +3 -0
  225. package/.next/server/chunks/[root-of-the-server]__97622908._.js.map +1 -0
  226. package/.next/server/chunks/[root-of-the-server]__a02e6618._.js +3 -0
  227. package/.next/server/chunks/[root-of-the-server]__a02e6618._.js.map +1 -0
  228. package/.next/server/chunks/[root-of-the-server]__a32a20a7._.js +3 -0
  229. package/.next/server/chunks/[root-of-the-server]__a32a20a7._.js.map +1 -0
  230. package/.next/server/chunks/[root-of-the-server]__af5b556a._.js +3 -0
  231. package/.next/server/chunks/[root-of-the-server]__af5b556a._.js.map +1 -0
  232. package/.next/server/chunks/[root-of-the-server]__c1b4b601._.js +16 -16
  233. package/.next/server/chunks/[root-of-the-server]__c1b4b601._.js.map +1 -1
  234. package/.next/server/chunks/[root-of-the-server]__cafe113e._.js +3 -0
  235. package/.next/server/chunks/[root-of-the-server]__cafe113e._.js.map +1 -0
  236. package/.next/server/chunks/[root-of-the-server]__dc8b0bed._.js +3 -0
  237. package/.next/server/chunks/[root-of-the-server]__dc8b0bed._.js.map +1 -0
  238. package/.next/server/chunks/[root-of-the-server]__f0461b8d._.js +1 -1
  239. package/.next/server/chunks/[root-of-the-server]__f0461b8d._.js.map +1 -1
  240. package/.next/server/chunks/[root-of-the-server]__f8949f88._.js +1 -1
  241. package/.next/server/chunks/[root-of-the-server]__f8949f88._.js.map +1 -1
  242. package/.next/server/chunks/_next-internal_server_app_api_ide_openclaw_apply_route_actions_2cb9e4b4.js +3 -0
  243. package/.next/server/chunks/_next-internal_server_app_api_ide_openclaw_apply_route_actions_2cb9e4b4.js.map +1 -0
  244. package/.next/server/chunks/_next-internal_server_app_api_ide_openclaw_preview_route_actions_9814a8e4.js +3 -0
  245. package/.next/server/chunks/_next-internal_server_app_api_ide_openclaw_preview_route_actions_9814a8e4.js.map +1 -0
  246. package/.next/server/chunks/_next-internal_server_app_api_ide_openclaw_restore_route_actions_10ad8f9d.js +3 -0
  247. package/.next/server/chunks/_next-internal_server_app_api_ide_openclaw_restore_route_actions_10ad8f9d.js.map +1 -0
  248. package/.next/server/chunks/_next-internal_server_app_api_ide_openclaw_save_route_actions_044ad081.js +3 -0
  249. package/.next/server/chunks/_next-internal_server_app_api_ide_openclaw_save_route_actions_044ad081.js.map +1 -0
  250. package/.next/server/chunks/_next-internal_server_app_api_ide_openclaw_status_route_actions_ed9786d2.js +3 -0
  251. package/.next/server/chunks/_next-internal_server_app_api_ide_openclaw_status_route_actions_ed9786d2.js.map +1 -0
  252. package/.next/server/chunks/_next-internal_server_app_api_ide_openclaw_test_route_actions_ce2cb808.js +3 -0
  253. package/.next/server/chunks/_next-internal_server_app_api_ide_openclaw_test_route_actions_ce2cb808.js.map +1 -0
  254. package/.next/server/chunks/_next-internal_server_app_api_ide_opencode_apply_route_actions_6c422244.js +3 -0
  255. package/.next/server/chunks/_next-internal_server_app_api_ide_opencode_apply_route_actions_6c422244.js.map +1 -0
  256. package/.next/server/chunks/_next-internal_server_app_api_ide_opencode_preview_route_actions_256c82e0.js +3 -0
  257. package/.next/server/chunks/_next-internal_server_app_api_ide_opencode_preview_route_actions_256c82e0.js.map +1 -0
  258. package/.next/server/chunks/_next-internal_server_app_api_ide_opencode_restore_route_actions_371993d3.js +3 -0
  259. package/.next/server/chunks/_next-internal_server_app_api_ide_opencode_restore_route_actions_371993d3.js.map +1 -0
  260. package/.next/server/chunks/_next-internal_server_app_api_ide_opencode_save_route_actions_6e4c9c41.js +3 -0
  261. package/.next/server/chunks/_next-internal_server_app_api_ide_opencode_save_route_actions_6e4c9c41.js.map +1 -0
  262. package/.next/server/chunks/_next-internal_server_app_api_ide_opencode_status_route_actions_498ad77b.js +3 -0
  263. package/.next/server/chunks/_next-internal_server_app_api_ide_opencode_status_route_actions_498ad77b.js.map +1 -0
  264. package/.next/server/chunks/_next-internal_server_app_api_ide_opencode_test_route_actions_c71be510.js +3 -0
  265. package/.next/server/chunks/_next-internal_server_app_api_ide_opencode_test_route_actions_c71be510.js.map +1 -0
  266. package/.next/server/chunks/ce889_server_app_api_ide_openclaw_available-models_route_actions_e568e70b.js +3 -0
  267. package/.next/server/chunks/ce889_server_app_api_ide_openclaw_available-models_route_actions_e568e70b.js.map +1 -0
  268. package/.next/server/chunks/ce889_server_app_api_ide_opencode_available-models_route_actions_95230db3.js +3 -0
  269. package/.next/server/chunks/ce889_server_app_api_ide_opencode_available-models_route_actions_95230db3.js.map +1 -0
  270. package/.next/server/chunks/ssr/{[root-of-the-server]__bec95712._.js → [root-of-the-server]__81937253._.js} +2 -2
  271. package/.next/server/chunks/ssr/{[root-of-the-server]__bec95712._.js.map → [root-of-the-server]__81937253._.js.map} +1 -1
  272. package/.next/server/chunks/ssr/{[root-of-the-server]__71c85955._.js → [root-of-the-server]__976ad963._.js} +2 -2
  273. package/.next/server/chunks/ssr/{[root-of-the-server]__71c85955._.js.map → [root-of-the-server]__976ad963._.js.map} +1 -1
  274. package/.next/server/chunks/ssr/_69468f4c._.js +3 -0
  275. package/.next/server/chunks/ssr/_69468f4c._.js.map +1 -0
  276. package/.next/server/chunks/ssr/src_app_ide_page_tsx_8962793b._.js +1 -1
  277. package/.next/server/chunks/ssr/src_app_ide_page_tsx_8962793b._.js.map +1 -1
  278. package/.next/server/chunks/ssr/src_app_logs_page_tsx_7b7b7b83._.js +1 -1
  279. package/.next/server/chunks/ssr/src_app_logs_page_tsx_7b7b7b83._.js.map +1 -1
  280. package/.next/server/pages/404.html +1 -1
  281. package/.next/server/pages/500.html +2 -2
  282. package/.next/server/server-reference-manifest.js +1 -1
  283. package/.next/server/server-reference-manifest.json +1 -1
  284. package/.next/static/chunks/64f547b3bcd3aef4.js +1 -0
  285. package/.next/static/chunks/6992685fe009e8fd.css +1 -0
  286. package/.next/static/chunks/{b6b258e8582e47c4.js → 7c8b7cbb3339f139.js} +1 -1
  287. package/.next/static/chunks/8ccc14e022ff6de3.js +1 -0
  288. package/.next/types/routes.d.ts +15 -1
  289. package/.next/types/validator.ts +126 -0
  290. package/README.md +31 -4
  291. package/dist/.next/dev/types/validator.js +56 -0
  292. package/dist/.next/types/validator.js +56 -0
  293. package/dist/package.json +55 -0
  294. package/dist/src/app/api/config/route.js +17 -0
  295. package/dist/src/app/api/ide/claude/apply/route.js +126 -31
  296. package/dist/src/app/api/ide/claude/restore/route.js +30 -0
  297. package/dist/src/app/api/ide/claude/save/route.js +79 -0
  298. package/dist/src/app/api/ide/claude/status/route.js +6 -1
  299. package/dist/src/app/api/ide/openclaw/apply/route.js +92 -0
  300. package/dist/src/app/api/ide/openclaw/available-models/route.js +46 -0
  301. package/dist/src/app/api/ide/openclaw/build-config.js +101 -0
  302. package/dist/src/app/api/ide/openclaw/preview/route.js +49 -0
  303. package/dist/src/app/api/ide/openclaw/restore/route.js +24 -0
  304. package/dist/src/app/api/ide/openclaw/save/route.js +54 -0
  305. package/dist/src/app/api/ide/openclaw/status/route.js +139 -0
  306. package/dist/src/app/api/ide/openclaw/test/route.js +158 -0
  307. package/dist/src/app/api/ide/opencode/apply/route.js +89 -0
  308. package/dist/src/app/api/ide/opencode/available-models/route.js +46 -0
  309. package/dist/src/app/api/ide/opencode/build-config.js +54 -0
  310. package/dist/src/app/api/ide/opencode/preview/route.js +36 -0
  311. package/dist/src/app/api/ide/opencode/restore/route.js +40 -0
  312. package/dist/src/app/api/ide/opencode/save/route.js +123 -0
  313. package/dist/src/app/api/ide/opencode/status/route.js +106 -0
  314. package/dist/src/app/api/ide/opencode/test/route.js +136 -0
  315. package/dist/src/app/components/Footer.js +11 -0
  316. package/dist/src/app/ide/page.js +651 -81
  317. package/dist/src/app/layout.js +5 -1
  318. package/dist/src/app/logs/page.js +4 -2
  319. package/dist/src/db/database.js +44 -8
  320. package/package.json +1 -1
  321. package/src/app/api/config/route.ts +17 -0
  322. package/src/app/api/ide/claude/apply/route.ts +140 -31
  323. package/src/app/api/ide/claude/restore/route.ts +36 -1
  324. package/src/app/api/ide/claude/save/route.ts +91 -1
  325. package/src/app/api/ide/claude/status/route.ts +12 -2
  326. package/src/app/api/ide/openclaw/apply/route.ts +103 -0
  327. package/src/app/api/ide/openclaw/available-models/route.ts +59 -0
  328. package/src/app/api/ide/openclaw/build-config.ts +152 -0
  329. package/src/app/api/ide/openclaw/preview/route.ts +57 -0
  330. package/src/app/api/ide/openclaw/restore/route.ts +27 -0
  331. package/src/app/api/ide/openclaw/save/route.ts +67 -0
  332. package/src/app/api/ide/openclaw/status/route.ts +178 -0
  333. package/src/app/api/ide/openclaw/test/route.ts +194 -0
  334. package/src/app/api/ide/opencode/apply/route.ts +92 -0
  335. package/src/app/api/ide/opencode/available-models/route.ts +59 -0
  336. package/src/app/api/ide/opencode/build-config.ts +69 -0
  337. package/src/app/api/ide/opencode/preview/route.ts +40 -0
  338. package/src/app/api/ide/opencode/restore/route.ts +52 -0
  339. package/src/app/api/ide/opencode/save/route.ts +131 -0
  340. package/src/app/api/ide/opencode/status/route.ts +128 -0
  341. package/src/app/api/ide/opencode/test/route.ts +145 -0
  342. package/src/app/components/Footer.tsx +9 -0
  343. package/src/app/globals.css +17 -0
  344. package/src/app/ide/page.tsx +1587 -118
  345. package/src/app/layout.tsx +3 -1
  346. package/src/app/logs/page.tsx +4 -2
  347. package/src/db/database.ts +55 -8
  348. package/.next/server/chunks/ssr/src_app_b2b1d928._.js +0 -3
  349. package/.next/server/chunks/ssr/src_app_b2b1d928._.js.map +0 -1
  350. package/.next/static/chunks/6418ca50028376b7.css +0 -1
  351. package/.next/static/chunks/9ec3b97741b6575e.js +0 -1
  352. /package/.next/static/{ryTeHAYUvjT1bYolc-x9Z → cf2SWIkI5HVbnDjLExI42}/_buildManifest.js +0 -0
  353. /package/.next/static/{ryTeHAYUvjT1bYolc-x9Z → cf2SWIkI5HVbnDjLExI42}/_clientMiddlewareManifest.json +0 -0
  354. /package/.next/static/{ryTeHAYUvjT1bYolc-x9Z → cf2SWIkI5HVbnDjLExI42}/_ssgManifest.js +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/app/api/ide/claude/apply/route.ts","../../../node_modules/next/dist/esm/build/templates/app-route.js"],"sourcesContent":["import { NextRequest, NextResponse } from 'next/server';\nimport { existsSync, readFileSync, writeFileSync, copyFileSync, mkdirSync } from 'fs';\nimport { join } from 'path';\nimport { homedir } from 'os';\nimport { getDatabase } from '@/db/database';\nimport { getConfig } from '@/db/queries';\n\n// Claude settings.json 文件路径\nconst CLAUDE_DIR = join(homedir(), '.claude');\nconst SETTINGS_FILE = join(CLAUDE_DIR, 'settings.json');\nconst BACKUP_FILE = join(CLAUDE_DIR, 'settings.json.aar.bak');\n\n// 默认模型映射\nconst DEFAULT_MODEL_MAPPING = {\n haiku: 'GLM-4.5-air',\n sonnet: 'MiniMax-M2.1',\n opus: 'GLM-4.7',\n default: 'GLM-4.7',\n} as const;\n\n/**\n * 应用 Claude IDE 配置\n */\nexport async function POST(request: NextRequest) {\n try {\n const body = await request.json();\n const { haiku, sonnet, opus, default: defaultModel, reasoning: reasoningModel } = body;\n\n // 验证请求参数 - haiku, sonnet, opus, default, reasoning 都需要\n if (haiku === undefined || sonnet === undefined || opus === undefined || defaultModel === undefined || reasoningModel === undefined) {\n return NextResponse.json(\n { error: 'Missing required fields: haiku, sonnet, opus, default, reasoning' },\n { status: 400 }\n );\n }\n\n // 获取当前网关地址和API Key(从数据库读取)\n const gatewayAddress = await getGatewayAddress();\n const gatewayApiKey = await getGatewayApiKey();\n\n // 生成配置对象\n const modelMapping = { haiku, sonnet, opus, default: defaultModel, reasoning: reasoningModel };\n const config = generateClaudeConfig(gatewayAddress, gatewayApiKey, modelMapping);\n\n // 备份原有配置\n const backupResult = backupOriginalConfig();\n if (!backupResult.success) {\n return NextResponse.json(\n { error: backupResult.error },\n { status: 500 }\n );\n }\n\n // 确保目录存在\n if (!existsSync(CLAUDE_DIR)) {\n mkdirSync(CLAUDE_DIR, { recursive: true });\n }\n\n // 验证并写入新配置\n const validationResult = validateAndWriteConfig(config);\n if (!validationResult.success) {\n return NextResponse.json(\n { error: validationResult.error },\n { status: 500 }\n );\n }\n\n return NextResponse.json({\n success: true,\n message: 'Configuration applied successfully',\n config,\n backup: backupResult.existed ? 'Created backup' : 'No existing config to backup',\n previousWasFromAar: backupResult.existed && backupResult.isFromAar,\n });\n } catch (error: any) {\n console.error('IDE Apply 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\n/**\n * 获取当前网关地址(从数据库读取)\n */\nasync function getGatewayAddress(): Promise<string> {\n await getDatabase();\n // 默认端口 1357\n const portConfig = await getConfig('port');\n const port = portConfig?.value || '1357';\n return `http://localhost:${port}`;\n}\n\n/**\n * 获取当前网关 API Key(从数据库读取)\n */\nasync function getGatewayApiKey(): Promise<string> {\n await getDatabase();\n const apiKeyConfig = await getConfig('api_key');\n return apiKeyConfig?.value || 'your-gateway-api-key';\n}\n\n/**\n * 生成 Claude 配置\n */\nfunction generateClaudeConfig(\n gatewayAddress: string,\n gatewayApiKey: string,\n modelMapping: { haiku: string; sonnet: string; opus: string; default: string; reasoning: string }\n): any {\n return {\n // 路由提供者标识,标识配置来自当前工具 aar\n router_provider: 'aar',\n env: {\n ANTHROPIC_AUTH_TOKEN: gatewayApiKey,\n ANTHROPIC_BASE_URL: gatewayAddress,\n ANTHROPIC_DEFAULT_HAIKU_MODEL: modelMapping.haiku,\n ANTHROPIC_DEFAULT_OPUS_MODEL: modelMapping.opus,\n ANTHROPIC_DEFAULT_SONNET_MODEL: modelMapping.sonnet,\n ANTHROPIC_MODEL: modelMapping.default,\n ANTHROPIC_REASONING_MODEL: modelMapping.reasoning,\n API_TIMEOUT_MS: '3000000',\n CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: 1,\n hasCompletedOnboarding: true,\n },\n };\n}\n\n/**\n * 备份原有配置\n * 返回原有配置是否来自当前工具(router_provider === 'aar')\n */\nfunction backupOriginalConfig(): { success: boolean; existed: boolean; isFromAar: boolean; error?: string } {\n try {\n // 检查原有配置是否存在\n const existing = existsSync(SETTINGS_FILE);\n\n if (existing) {\n // 读取原有配置\n const originalConfig = readFileSync(SETTINGS_FILE, 'utf-8');\n\n // 解析配置检查 router_provider\n let isFromAar = false;\n try {\n const parsedConfig = JSON.parse(originalConfig);\n isFromAar = parsedConfig.router_provider === 'aar';\n } catch (error) {\n // 解析失败,不影响备份操作\n isFromAar = false;\n }\n\n // 写入备份文件\n writeFileSync(BACKUP_FILE, originalConfig, 'utf-8');\n\n return { success: true, existed: true, isFromAar };\n }\n\n return { success: true, existed: false, isFromAar: false };\n } catch (error: any) {\n return {\n success: false,\n existed: false,\n isFromAar: false,\n error: `Backup failed: ${error.message}`,\n };\n }\n}\n\n/**\n * 验证并写入配置\n */\nfunction validateAndWriteConfig(config: any): { success: boolean; error?: string } {\n try {\n // 序列化为 JSON 验证格式\n const jsonString = JSON.stringify(config, null, 2);\n\n // 验证是否能解析\n JSON.parse(jsonString);\n\n // 写入文件\n writeFileSync(SETTINGS_FILE, jsonString, 'utf-8');\n\n return { success: true };\n } catch (error: any) {\n return {\n success: false,\n error: `Validation or write failed: ${error.message}`,\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 } 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/ide/claude/apply/route\",\n pathname: \"/api/ide/claude/apply\",\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/ide/claude/apply/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 (routeModule.isDev) {\n addRequestMeta(req, 'devRequestTimingInternalsEnd', process.hrtime.bigint());\n }\n let srcPage = \"/api/ide/claude/apply/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.experimental.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 context = {\n params,\n prerenderManifest,\n renderOpts: {\n experimental: {\n authInterrupts: Boolean(nextConfig.experimental.authInterrupts)\n },\n cacheComponents: Boolean(nextConfig.cacheComponents),\n supportsDynamicResponse,\n incrementalCache: getRequestMeta(req, '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 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 } else {\n span.updateName(`${method} ${srcPage}`);\n }\n });\n };\n const isMinimalMode = Boolean(process.env.MINIMAL_MODE || getRequestMeta(req, 'minimalMode'));\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 (activeSpan) {\n await handleResponse(activeSpan);\n } else {\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));\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":[],"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,OACA,EAAA,EAAA,CAAA,CAAA,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,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OAGA,IAAM,EAAa,CAAA,EAAA,EAAA,IAAA,AAAI,EAAC,CAAA,EAAA,EAAA,OAAA,AAAO,IAAI,WAC7B,EAAgB,CAAA,EAAA,EAAA,IAAA,AAAI,EAAC,EAAY,iBACjC,EAAc,CAAA,EAAA,EAAA,IAAA,AAA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oreList":[1]}
1
+ {"version":3,"sources":["../../../src/app/api/ide/claude/apply/route.ts","../../../node_modules/next/dist/esm/build/templates/app-route.js"],"sourcesContent":["import { NextRequest, NextResponse } from 'next/server';\nimport { existsSync, readFileSync, writeFileSync, copyFileSync, mkdirSync } from 'fs';\nimport { join } from 'path';\nimport { homedir } from 'os';\nimport { getDatabase } from '@/db/database';\nimport { getConfig } from '@/db/queries';\n\n// Claude settings.json 文件路径\nconst CLAUDE_DIR = join(homedir(), '.claude');\nconst SETTINGS_FILE = join(CLAUDE_DIR, 'settings.json');\nconst BACKUP_FILE = join(CLAUDE_DIR, 'settings.json.aar.bak');\n\n// Claude 登录配置文件(用于 hasCompletedOnboarding)\nconst CLAUDE_JSON_FILE = join(homedir(), '.claude.json');\n\n// AAR 备份目录\nconst AAR_BACKUP_DIR = join(homedir(), '.aar', 'backups');\n\n// 默认模型映射\nconst DEFAULT_MODEL_MAPPING = {\n haiku: 'GLM-4.5-air',\n sonnet: 'MiniMax-M2.1',\n opus: 'GLM-4.7',\n default: 'GLM-4.7',\n} as const;\n\n/**\n * 应用 Claude IDE 配置\n */\nexport async function POST(request: NextRequest) {\n try {\n const body = await request.json();\n const { haiku, sonnet, opus, default: defaultModel, reasoning: reasoningModel } = body;\n\n // 验证请求参数 - haiku, sonnet, opus, default, reasoning 都需要\n if (haiku === undefined || sonnet === undefined || opus === undefined || defaultModel === undefined || reasoningModel === undefined) {\n return NextResponse.json(\n { error: 'Missing required fields: haiku, sonnet, opus, default, reasoning' },\n { status: 400 }\n );\n }\n\n // 获取当前网关地址和API Key(从数据库读取)\n const gatewayAddress = await getGatewayAddress();\n const gatewayApiKey = await getGatewayApiKey();\n\n const modelMapping = { haiku, sonnet, opus, default: defaultModel, reasoning: reasoningModel };\n const aarEnv = buildAarEnv(gatewayAddress, gatewayApiKey, modelMapping);\n\n // 在修改配置前,先备份到 ~/.aar/backups 目录\n const settingsBackup = backupToAar(SETTINGS_FILE, 'settings');\n const claudeJsonBackup = backupToAar(CLAUDE_JSON_FILE, 'claude');\n \n if (!settingsBackup.success) {\n console.warn('[Claude Apply] Settings backup warning:', settingsBackup.error);\n }\n if (!claudeJsonBackup.success) {\n console.warn('[Claude Apply] Claude.json backup warning:', claudeJsonBackup.error);\n }\n\n const backupResult = backupOriginalConfig();\n if (!backupResult.success) {\n return NextResponse.json(\n { error: backupResult.error },\n { status: 500 }\n );\n }\n\n if (!existsSync(CLAUDE_DIR)) {\n mkdirSync(CLAUDE_DIR, { recursive: true });\n }\n\n let configToWrite: any;\n if (existsSync(SETTINGS_FILE)) {\n try {\n const existing = JSON.parse(readFileSync(SETTINGS_FILE, 'utf-8'));\n configToWrite = {\n ...existing,\n env: { ...(existing.env || {}), ...aarEnv },\n router_provider: 'aar',\n };\n } catch {\n configToWrite = generateClaudeConfig(gatewayAddress, gatewayApiKey, modelMapping);\n }\n } else {\n configToWrite = generateClaudeConfig(gatewayAddress, gatewayApiKey, modelMapping);\n }\n\n const validationResult = validateAndWriteConfig(configToWrite);\n if (!validationResult.success) {\n return NextResponse.json(\n { error: validationResult.error },\n { status: 500 }\n );\n }\n\n // 处理 ~/.claude.json,确保包含 hasCompletedOnboarding: true\n const onboardingResult = ensureClaudeOnboarding();\n if (!onboardingResult.success) {\n console.warn('[Claude Apply] Onboarding update warning:', onboardingResult.error);\n }\n\n return NextResponse.json({\n success: true,\n message: 'Configuration applied successfully',\n config: configToWrite,\n backup: backupResult.existed ? 'Created backup' : 'No existing config to backup',\n previousWasFromAar: backupResult.existed && backupResult.isFromAar,\n onboarding: onboardingResult.created ? 'Created ~/.claude.json' : 'Updated ~/.claude.json',\n aarBackups: {\n settings: settingsBackup.backupPath,\n claudeJson: claudeJsonBackup.backupPath,\n },\n });\n } catch (error: any) {\n console.error('IDE Apply 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\n/**\n * 获取当前网关地址(从数据库读取)\n */\nasync function getGatewayAddress(): Promise<string> {\n await getDatabase();\n // 默认端口 1357\n const portConfig = await getConfig('port');\n const port = portConfig?.value || '1357';\n return `http://localhost:${port}`;\n}\n\n/**\n * 获取当前网关 API Key(从数据库读取)\n */\nasync function getGatewayApiKey(): Promise<string> {\n await getDatabase();\n const apiKeyConfig = await getConfig('api_key');\n return apiKeyConfig?.value || 'your-gateway-api-key';\n}\n\n/** 仅生成 AAR 相关的 env 字段,用于合并到现有配置 */\nfunction buildAarEnv(\n gatewayAddress: string,\n gatewayApiKey: string,\n modelMapping: { haiku: string; sonnet: string; opus: string; default: string; reasoning: string }\n): Record<string, unknown> {\n return {\n ANTHROPIC_AUTH_TOKEN: gatewayApiKey,\n ANTHROPIC_BASE_URL: gatewayAddress,\n ANTHROPIC_DEFAULT_HAIKU_MODEL: modelMapping.haiku,\n ANTHROPIC_DEFAULT_OPUS_MODEL: modelMapping.opus,\n ANTHROPIC_DEFAULT_SONNET_MODEL: modelMapping.sonnet,\n ANTHROPIC_MODEL: modelMapping.default,\n ANTHROPIC_REASONING_MODEL: modelMapping.reasoning,\n API_TIMEOUT_MS: '3000000',\n CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: 1,\n hasCompletedOnboarding: true,\n };\n}\n\n/** 生成完整 Claude 配置(仅在无现有文件时使用) */\nfunction generateClaudeConfig(\n gatewayAddress: string,\n gatewayApiKey: string,\n modelMapping: { haiku: string; sonnet: string; opus: string; default: string; reasoning: string }\n): any {\n return {\n router_provider: 'aar',\n env: buildAarEnv(gatewayAddress, gatewayApiKey, modelMapping),\n };\n}\n\n/**\n * 备份原有配置\n * 仅在当前配置不是 AAR 时写入备份,这样「还原」才能恢复到应用 AAR 前的状态\n */\nfunction backupOriginalConfig(): { success: boolean; existed: boolean; isFromAar: boolean; error?: string } {\n try {\n const existing = existsSync(SETTINGS_FILE);\n\n if (existing) {\n const originalConfig = readFileSync(SETTINGS_FILE, 'utf-8');\n\n let isFromAar = false;\n try {\n const parsedConfig = JSON.parse(originalConfig);\n isFromAar = parsedConfig.router_provider === 'aar';\n } catch {\n isFromAar = false;\n }\n\n if (!isFromAar) {\n writeFileSync(BACKUP_FILE, originalConfig, 'utf-8');\n }\n\n return { success: true, existed: true, isFromAar };\n }\n\n return { success: true, existed: false, isFromAar: false };\n } catch (error: any) {\n return {\n success: false,\n existed: false,\n isFromAar: false,\n error: `Backup failed: ${error.message}`,\n };\n }\n}\n\n/**\n * 验证并写入配置\n */\nfunction validateAndWriteConfig(config: any): { success: boolean; error?: string } {\n try {\n // 序列化为 JSON 验证格式\n const jsonString = JSON.stringify(config, null, 2);\n\n // 验证是否能解析\n JSON.parse(jsonString);\n\n // 写入文件\n writeFileSync(SETTINGS_FILE, jsonString, 'utf-8');\n\n return { success: true };\n } catch (error: any) {\n return {\n success: false,\n error: `Validation or write failed: ${error.message}`,\n };\n }\n}\n\n/**\n * 备份文件到 ~/.aar/backups 目录\n */\nfunction backupToAar(filePath: string, backupName: string): { success: boolean; backupPath?: string; error?: string } {\n try {\n if (!existsSync(filePath)) {\n return { success: true }; // 文件不存在,无需备份\n }\n \n if (!existsSync(AAR_BACKUP_DIR)) {\n mkdirSync(AAR_BACKUP_DIR, { recursive: true });\n }\n \n const timestamp = new Date().toISOString().replace(/[:.]/g, '-');\n const backupPath = join(AAR_BACKUP_DIR, `${backupName}-${timestamp}.json`);\n copyFileSync(filePath, backupPath);\n \n return { success: true, backupPath };\n } catch (error: any) {\n return {\n success: false,\n error: `Backup to AAR failed: ${error.message}`,\n };\n }\n}\n\n/**\n * 确保 ~/.claude.json 文件中包含 hasCompletedOnboarding: true\n * 这允许用户跳过 Claude 登录使用自定义模型\n */\nfunction ensureClaudeOnboarding(): { success: boolean; created: boolean; error?: string } {\n try {\n let config: any = {};\n let created = false;\n \n if (existsSync(CLAUDE_JSON_FILE)) {\n try {\n const content = readFileSync(CLAUDE_JSON_FILE, 'utf-8');\n config = JSON.parse(content);\n } catch {\n // 文件存在但解析失败,使用空对象\n config = {};\n }\n } else {\n created = true;\n }\n \n // 检查是否已经有 hasCompletedOnboarding\n if (config.hasCompletedOnboarding === true) {\n return { success: true, created: false };\n }\n \n // 添加 hasCompletedOnboarding\n config.hasCompletedOnboarding = true;\n writeFileSync(CLAUDE_JSON_FILE, JSON.stringify(config, null, 2), 'utf-8');\n \n return { success: true, created };\n } catch (error: any) {\n return {\n success: false,\n created: false,\n error: `Failed to update claude.json: ${error.message}`,\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 } 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/ide/claude/apply/route\",\n pathname: \"/api/ide/claude/apply\",\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/ide/claude/apply/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 (routeModule.isDev) {\n addRequestMeta(req, 'devRequestTimingInternalsEnd', process.hrtime.bigint());\n }\n let srcPage = \"/api/ide/claude/apply/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.experimental.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 context = {\n params,\n prerenderManifest,\n renderOpts: {\n experimental: {\n authInterrupts: Boolean(nextConfig.experimental.authInterrupts)\n },\n cacheComponents: Boolean(nextConfig.cacheComponents),\n supportsDynamicResponse,\n incrementalCache: getRequestMeta(req, '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 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 } else {\n span.updateName(`${method} ${srcPage}`);\n }\n });\n };\n const isMinimalMode = Boolean(process.env.MINIMAL_MODE || getRequestMeta(req, 'minimalMode'));\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 (activeSpan) {\n await handleResponse(activeSpan);\n } else {\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));\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":[],"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,OACA,EAAA,EAAA,CAAA,CAAA,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,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OAGA,IAAM,EAAa,CAAA,EAAA,EAAA,IAAA,AAAI,EAAC,CAAA,EAAA,EAAA,OAAA,AAAO,IAAI,WAC7B,EAAgB,CAAA,EAAA,EAAA,IAAA,AAAI,EAAC,EAAY,iBACjC,EAAc,CAAA,EAAA,EAAA,IAAA,AAAI,EAAC,EAAY,yBAG/B,EAAmB,CAAA,EAAA,EAAA,IAAA,AAAI,EAAC,CAAA,EAAA,EAAA,OAA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A,sBAAsB,GAIrC,EAAW,YAAY,EAAK,EAAD,AAAK,SAAS,CAAC,kBAAqB,EAAD,AAAS,GAAG,CAAC,kBAAkB,AAC7F,EAAQ,GAAG,CAAC,gBAAiB,CAAA,EAAA,EAAA,qBAAA,AAAqB,EAAC,EAAW,YAAY,GAE9E,MAAM,CAAA,EAAA,EAAA,YAAA,AAAY,EAAC,EAAa,EAChC,IAAI,SAAS,EAAW,KAAK,CAAC,IAAI,CAAE,CAChC,UACA,OAAQ,EAAW,KAAK,CAAC,MAAM,EAAI,GACvC,IACO,IACX,EAGI,EACA,MAAM,EAAe,EADT,CAGZ,MAAM,EAAO,qBAAqB,CAAC,EAAI,OAAO,CAAE,IAAI,EAAO,KAAK,CAAC,EAAA,cAAc,CAAC,aAAa,CAAE,CACvF,SAAU,CAAA,EAAG,EAAO,CAAC,EAAE,EAAA,CAAS,CAChC,KAAM,EAAA,QAAQ,CAAC,MAAM,CACrB,WAAY,CACR,cAAe,EACf,cAAe,EAAI,GAAG,AAC1B,CACJ,EAAG,GAEf,CAAE,MAAO,EAAK,CAeV,GAdM,aAAe,EAAA,eAAe,EAEhC,CAFmC,KAE7B,EAAY,cAAc,CAAC,EAAK,EAAK,CACvC,WAAY,aACZ,UAAW,EACX,UAAW,QACX,iBAAkB,CAAA,EAAA,EAAA,mBAAA,AAAmB,EAAC,oBAClC,uBACA,CACJ,EACJ,GAAG,AATgB,EASJ,GAIf,EAAO,MAAM,EAKjB,OAHA,MAAM,CAAA,EAAA,EAAA,YAAA,AAAY,EAAC,EAAa,EAAa,IAAI,SAAS,KAAM,CAC5D,OAAQ,GACZ,IACO,IACX,CACJ,EAEA,qCAAqC","ignoreList":[1]}
@@ -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"))},14747,(e,t,r)=>{t.exports=e.x("path",()=>require("path"))},70406,(e,t,r)=>{t.exports=e.x("next/dist/compiled/@opentelemetry/api",()=>require("next/dist/compiled/@opentelemetry/api"))},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"))},30031,e=>{"use strict";var t=e.i(47909),r=e.i(74017),n=e.i(96250),a=e.i(59756),o=e.i(61916),s=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),x=e.i(70101),h=e.i(26937),R=e.i(10372),f=e.i(93695);e.i(52474);var v=e.i(220),g=e.i(89171),m=e.i(22734),y=e.i(14747),E=e.i(46786);let w=(0,y.join)((0,E.homedir)(),".config","opencode"),C=(0,y.join)(w,"opencode.json"),N=(0,y.join)(w,"opencode.json.aar.bak");async function b(e){try{let e;if(!(0,m.existsSync)(N))return g.NextResponse.json({error:"No backup file found. Please apply configuration first before restoring."},{status:404});let t=(0,m.readFileSync)(N,"utf-8");if(!(0,m.existsSync)(w))return g.NextResponse.json({error:"OpenCode config directory does not exist"},{status:500});(0,m.copyFileSync)(N,C);try{e=JSON.parse(t)}catch{return g.NextResponse.json({error:"Backup file is corrupted or invalid JSON",backupContent:t},{status:500})}return g.NextResponse.json({success:!0,message:"OpenCode configuration restored successfully",config:e})}catch(e){return console.error("OpenCode Restore API error:",e),g.NextResponse.json({error:e.message||"Internal server error",stack:void 0},{status:500})}}e.s(["POST",()=>b],93269);var A=e.i(93269);let j=new t.AppRouteRouteModule({definition:{kind:r.RouteKind.APP_ROUTE,page:"/api/ide/opencode/restore/route",pathname:"/api/ide/opencode/restore",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/src/app/api/ide/opencode/restore/route.ts",nextConfigOutput:"",userland:A}),{workAsyncStorage:O,workUnitAsyncStorage:P,serverHooks:S}=j;function k(){return(0,n.patchFetch)({workAsyncStorage:O,workUnitAsyncStorage:P})}async function T(e,t,n){j.isDev&&(0,a.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let g="/api/ide/opencode/restore/route";g=g.replace(/\/index$/,"")||"/";let m=await j.prepare(e,t,{srcPage:g,multiZoneDraftMode:!1});if(!m)return t.statusCode=400,t.end("Bad Request"),null==n.waitUntil||n.waitUntil.call(n,Promise.resolve()),null;let{buildId:y,params:E,nextConfig:w,parsedUrl:C,isDraftMode:N,prerenderManifest:b,routerServerContext:A,isOnDemandRevalidate:O,revalidateOnlyGenerated:P,resolvedPathname:S,clientReferenceManifest:k,serverActionsManifest:T}=m,q=(0,i.normalizeAppPath)(g),_=!!(b.dynamicRoutes[q]||b.routes[S]),H=async()=>((null==A?void 0:A.render404)?await A.render404(e,t,C,!1):t.end("This page could not be found"),null);if(_&&!N){let e=!!b.routes[S],t=b.dynamicRoutes[q];if(t&&!1===t.fallback&&!e){if(w.experimental.adapterPath)return await H();throw new f.NoFallbackError}}let I=null;!_||j.isDev||N||(I="/index"===(I=S)?"/":I);let U=!0===j.isDev||!_,D=_&&!U;T&&k&&(0,s.setManifestsSingleton)({page:g,clientReferenceManifest:k,serverActionsManifest:T});let M=e.method||"GET",F=(0,o.getTracer)(),$=F.getActiveScopeSpan(),K={params:E,prerenderManifest:b,renderOpts:{experimental:{authInterrupts:!!w.experimental.authInterrupts},cacheComponents:!!w.cacheComponents,supportsDynamicResponse:U,incrementalCache:(0,a.getRequestMeta)(e,"incrementalCache"),cacheLifeProfiles:w.cacheLife,waitUntil:n.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,r,n,a)=>j.onRequestError(e,t,n,a,A)},sharedContext:{buildId:y}},B=new l.NodeNextRequest(e),L=new l.NodeNextResponse(t),G=d.NextRequestAdapter.fromNodeNextRequest(B,(0,d.signalFromNodeResponse)(t));try{let s=async e=>j.handle(G,K).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let r=F.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 n=r.get("next.route");if(n){let t=`${M} ${n}`;e.setAttributes({"next.route":n,"http.route":n,"next.span_name":t}),e.updateName(t)}else e.updateName(`${M} ${g}`)}),i=!!(0,a.getRequestMeta)(e,"minimalMode"),l=async a=>{var o,l;let d=async({previousCacheEntry:r})=>{try{if(!i&&O&&P&&!r)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let o=await s(a);e.fetchMetrics=K.renderOpts.fetchMetrics;let l=K.renderOpts.pendingWaitUntil;l&&n.waitUntil&&(n.waitUntil(l),l=void 0);let d=K.renderOpts.collectedTags;if(!_)return await (0,c.sendResponse)(B,L,o,K.renderOpts.pendingWaitUntil),null;{let e=await o.blob(),t=(0,x.toNodeOutgoingHttpHeaders)(o.headers);d&&(t[R.NEXT_CACHE_TAGS_HEADER]=d),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let r=void 0!==K.renderOpts.collectedRevalidate&&!(K.renderOpts.collectedRevalidate>=R.INFINITE_CACHE)&&K.renderOpts.collectedRevalidate,n=void 0===K.renderOpts.collectedExpire||K.renderOpts.collectedExpire>=R.INFINITE_CACHE?void 0:K.renderOpts.collectedExpire;return{value:{kind:v.CachedRouteKind.APP_ROUTE,status:o.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:r,expire:n}}}}catch(t){throw(null==r?void 0:r.isStale)&&await j.onRequestError(e,t,{routerKind:"App Router",routePath:g,routeType:"route",revalidateReason:(0,p.getRevalidateReason)({isStaticGeneration:D,isOnDemandRevalidate:O})},!1,A),t}},u=await j.handleResponse({req:e,nextConfig:w,cacheKey:I,routeKind:r.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:b,isRoutePPREnabled:!1,isOnDemandRevalidate:O,revalidateOnlyGenerated:P,responseGenerator:d,waitUntil:n.waitUntil,isMinimalMode:i});if(!_)return null;if((null==u||null==(o=u.value)?void 0:o.kind)!==v.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==u||null==(l=u.value)?void 0:l.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});i||t.setHeader("x-nextjs-cache",O?"REVALIDATED":u.isMiss?"MISS":u.isStale?"STALE":"HIT"),N&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let f=(0,x.fromNodeOutgoingHttpHeaders)(u.value.headers);return i&&_||f.delete(R.NEXT_CACHE_TAGS_HEADER),!u.cacheControl||t.getHeader("Cache-Control")||f.get("Cache-Control")||f.set("Cache-Control",(0,h.getCacheControlHeader)(u.cacheControl)),await (0,c.sendResponse)(B,L,new Response(u.value.body,{headers:f,status:u.value.status||200})),null};$?await l($):await F.withPropagatedContext(e.headers,()=>F.trace(u.BaseServerSpan.handleRequest,{spanName:`${M} ${g}`,kind:o.SpanKind.SERVER,attributes:{"http.method":M,"http.target":e.url}},l))}catch(t){if(t instanceof f.NoFallbackError||await j.onRequestError(e,t,{routerKind:"App Router",routePath:q,routeType:"route",revalidateReason:(0,p.getRevalidateReason)({isStaticGeneration:D,isOnDemandRevalidate:O})},!1,A),_)throw t;return await (0,c.sendResponse)(B,L,new Response(null,{status:500})),null}}e.s(["handler",()=>T,"patchFetch",()=>k,"routeModule",()=>j,"serverHooks",()=>S,"workAsyncStorage",()=>O,"workUnitAsyncStorage",()=>P],30031)}];
2
+
3
+ //# sourceMappingURL=%5Broot-of-the-server%5D__760eaa16._.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/app/api/ide/opencode/restore/route.ts","../../../node_modules/next/dist/esm/build/templates/app-route.js"],"sourcesContent":["import { NextRequest, NextResponse } from 'next/server';\nimport { existsSync, readFileSync, copyFileSync } from 'fs';\nimport { join } from 'path';\nimport { homedir } from 'os';\n\nconst OPENCODE_DIR =\n process.platform === 'win32'\n ? join(process.env.APPDATA || homedir(), 'opencode')\n : join(homedir(), '.config', 'opencode');\nconst OPENCODE_FILE = join(OPENCODE_DIR, 'opencode.json');\nconst BACKUP_FILE = join(OPENCODE_DIR, 'opencode.json.aar.bak');\n\nexport async function POST(request: NextRequest) {\n try {\n if (!existsSync(BACKUP_FILE)) {\n return NextResponse.json(\n { error: 'No backup file found. Please apply configuration first before restoring.' },\n { status: 404 }\n );\n }\n\n const backupContent = readFileSync(BACKUP_FILE, 'utf-8');\n\n if (!existsSync(OPENCODE_DIR)) {\n return NextResponse.json({ error: 'OpenCode config directory does not exist' }, { status: 500 });\n }\n\n copyFileSync(BACKUP_FILE, OPENCODE_FILE);\n\n let parsedBackup: any;\n try {\n parsedBackup = JSON.parse(backupContent);\n } catch {\n return NextResponse.json(\n { error: 'Backup file is corrupted or invalid JSON', backupContent },\n { status: 500 }\n );\n }\n\n return NextResponse.json({\n success: true,\n message: 'OpenCode configuration restored successfully',\n config: parsedBackup,\n });\n } catch (error: any) {\n console.error('OpenCode Restore 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 } 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/ide/opencode/restore/route\",\n pathname: \"/api/ide/opencode/restore\",\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/ide/opencode/restore/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 (routeModule.isDev) {\n addRequestMeta(req, 'devRequestTimingInternalsEnd', process.hrtime.bigint());\n }\n let srcPage = \"/api/ide/opencode/restore/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.experimental.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 context = {\n params,\n prerenderManifest,\n renderOpts: {\n experimental: {\n authInterrupts: Boolean(nextConfig.experimental.authInterrupts)\n },\n cacheComponents: Boolean(nextConfig.cacheComponents),\n supportsDynamicResponse,\n incrementalCache: getRequestMeta(req, '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 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 } else {\n span.updateName(`${method} ${srcPage}`);\n }\n });\n };\n const isMinimalMode = Boolean(process.env.MINIMAL_MODE || getRequestMeta(req, 'minimalMode'));\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 (activeSpan) {\n await handleResponse(activeSpan);\n } else {\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));\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":[],"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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back-error.external.js",()=>require("next/dist/shared/lib/no-fallback-error.external.js"))},14747,(e,t,a)=>{t.exports=e.x("path",()=>require("path"))},70406,(e,t,a)=>{t.exports=e.x("next/dist/compiled/@opentelemetry/api",()=>require("next/dist/compiled/@opentelemetry/api"))},18622,(e,t,a)=>{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,a)=>{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,a)=>{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,a)=>{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"))},68646,e=>{"use strict";var t=e.i(71560),a=e.i(97731);async function r(){await (0,t.getDatabase)();let e=await (0,a.getConfig)("port"),r=e?.value||"1357";return`http://localhost:${r}/v1`}async function n(){await (0,t.getDatabase)();let e=await (0,a.getConfig)("api_key");return e?.value||"your-gateway-api-key"}async function s(){return{baseUrl:await r(),apiKey:await n(),api:"openai-completions",models:(await (0,a.getAllModels)()).filter(e=>e.enabled).map(e=>({id:e.model_id,name:e.name,reasoning:e.reasoning||!1,input:e.input||["text"],cost:e.cost||{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:e.context_window||2e5,maxTokens:e.max_tokens||8192}))}}let i="aar-gateway";async function o(e,t){return function(e,t,a){let r=e&&"object"==typeof e?{...e}:{},n=r.models||{},s=n.providers||{};s[i]=a,n.providers=s,n.mode="merge",r.models=n;let o=r.agents||{},l=o.defaults||{},d=l.model||{},u=`${i}/${t.defaultModel}`,c=t.imageModel?`${i}/${t.imageModel}`:void 0;d.primary=u,t.defaultFallbacks&&t.defaultFallbacks.length>0?d.fallbacks=t.defaultFallbacks.map(e=>e.startsWith(`${i}/`)?e:`${i}/${e}`):delete d.fallbacks,l.model=d;let p=l.imageModel||{};c&&(p.primary=c),t.imageFallbacks&&t.imageFallbacks.length>0?p.fallbacks=t.imageFallbacks.map(e=>e.startsWith(`${i}/`)?e:`${i}/${e}`):delete p.fallbacks,l.imageModel=p;let f=l.models||{};for(let e of a.models){let t=`${i}/${e.id}`;f[t]=f[t]||{alias:e.name}}return l.models=f,o.defaults=l,r.agents=o,r.channels||(r.channels={}),r}(t,e,await s())}e.s(["buildMergedConfig",()=>o])},17739,e=>{"use strict";var t=e.i(47909),a=e.i(74017),r=e.i(96250),n=e.i(59756),s=e.i(61916),i=e.i(74677),o=e.i(69741),l=e.i(16795),d=e.i(87718),u=e.i(95169),c=e.i(47587),p=e.i(66012),f=e.i(70101),g=e.i(26937),m=e.i(10372),x=e.i(93695);e.i(52474);var h=e.i(220),y=e.i(89171),w=e.i(22734),v=e.i(14747),R=e.i(46786),b=e.i(68646);let k=(0,v.join)((0,R.homedir)(),".openclaw"),C=(0,v.join)(k,"openclaw.json"),E=(0,v.join)(k,"openclaw.json.aar.bak");async function A(e){try{let t,{default_model:a,default_fallbacks:r=[],image_model:n,image_fallbacks:s=[],config:i}=await e.json(),o=null;if((0,w.existsSync)(C))try{o=JSON.parse((0,w.readFileSync)(C,"utf-8"))}catch{o=null}if("string"==typeof i&&i.trim())try{if(!(t=JSON.parse(i))||"object"!=typeof t)throw Error("Invalid config object")}catch(e){return y.NextResponse.json({error:"Invalid config JSON: "+(e.message||"parse error")},{status:400})}else{if(!a)return y.NextResponse.json({error:"Missing required field: default_model"},{status:400});t=await (0,b.buildMergedConfig)({defaultModel:a,defaultFallbacks:r,imageModel:n||void 0,imageFallbacks:s},o)}let l=function(){try{if((0,w.existsSync)(C)){let e=(0,w.readFileSync)(C,"utf-8"),t=!1;try{let a=JSON.parse(e);t=!!a.models?.providers?.["aar-gateway"]}catch{}return t||(0,w.writeFileSync)(E,e,"utf-8"),{success:!0,existed:!0,isFromAar:t}}return{success:!0,existed:!1,isFromAar:!1}}catch(e){return{success:!1,existed:!1,isFromAar:!1,error:`Backup failed: ${e.message}`}}}();if(!l.success)return y.NextResponse.json({error:l.error},{status:500});(0,w.existsSync)(k)||(0,w.mkdirSync)(k,{recursive:!0});let d=JSON.stringify(t,null,2);(0,w.writeFileSync)(C,d,"utf-8");let u=!!o?.models?.providers?.["aar-gateway"];return y.NextResponse.json({success:!0,message:u?"OpenClaw 配置已更新为最新网关信息":"OpenClaw configuration applied successfully",config:t,backup:l.existed?"Created backup":"No existing config to backup",previousWasFromAar:l.existed&&l.isFromAar})}catch(e){return console.error("OpenClaw Apply API error:",e),y.NextResponse.json({error:e.message||"Internal server error",stack:void 0},{status:500})}}e.s(["POST",()=>A],82069);var N=e.i(82069);let S=new t.AppRouteRouteModule({definition:{kind:a.RouteKind.APP_ROUTE,page:"/api/ide/openclaw/apply/route",pathname:"/api/ide/openclaw/apply",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/src/app/api/ide/openclaw/apply/route.ts",nextConfigOutput:"",userland:N}),{workAsyncStorage:j,workUnitAsyncStorage:O,serverHooks:_}=S;function T(){return(0,r.patchFetch)({workAsyncStorage:j,workUnitAsyncStorage:O})}async function P(e,t,r){S.isDev&&(0,n.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let y="/api/ide/openclaw/apply/route";y=y.replace(/\/index$/,"")||"/";let w=await S.prepare(e,t,{srcPage:y,multiZoneDraftMode:!1});if(!w)return t.statusCode=400,t.end("Bad Request"),null==r.waitUntil||r.waitUntil.call(r,Promise.resolve()),null;let{buildId:v,params:R,nextConfig:b,parsedUrl:k,isDraftMode:C,prerenderManifest:E,routerServerContext:A,isOnDemandRevalidate:N,revalidateOnlyGenerated:j,resolvedPathname:O,clientReferenceManifest:_,serverActionsManifest:T}=w,P=(0,o.normalizeAppPath)(y),$=!!(E.dynamicRoutes[P]||E.routes[O]),q=async()=>((null==A?void 0:A.render404)?await A.render404(e,t,k,!1):t.end("This page could not be found"),null);if($&&!C){let e=!!E.routes[O],t=E.dynamicRoutes[P];if(t&&!1===t.fallback&&!e){if(b.experimental.adapterPath)return await q();throw new x.NoFallbackError}}let F=null;!$||S.isDev||C||(F="/index"===(F=O)?"/":F);let M=!0===S.isDev||!$,I=$&&!M;T&&_&&(0,i.setManifestsSingleton)({page:y,clientReferenceManifest:_,serverActionsManifest:T});let H=e.method||"GET",U=(0,s.getTracer)(),D=U.getActiveScopeSpan(),K={params:R,prerenderManifest:E,renderOpts:{experimental:{authInterrupts:!!b.experimental.authInterrupts},cacheComponents:!!b.cacheComponents,supportsDynamicResponse:M,incrementalCache:(0,n.getRequestMeta)(e,"incrementalCache"),cacheLifeProfiles:b.cacheLife,waitUntil:r.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,a,r,n)=>S.onRequestError(e,t,r,n,A)},sharedContext:{buildId:v}},W=new l.NodeNextRequest(e),B=new l.NodeNextResponse(t),J=d.NextRequestAdapter.fromNodeNextRequest(W,(0,d.signalFromNodeResponse)(t));try{let i=async e=>S.handle(J,K).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let a=U.getRootSpanAttributes();if(!a)return;if(a.get("next.span_type")!==u.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${a.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let r=a.get("next.route");if(r){let t=`${H} ${r}`;e.setAttributes({"next.route":r,"http.route":r,"next.span_name":t}),e.updateName(t)}else e.updateName(`${H} ${y}`)}),o=!!(0,n.getRequestMeta)(e,"minimalMode"),l=async n=>{var s,l;let d=async({previousCacheEntry:a})=>{try{if(!o&&N&&j&&!a)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let s=await i(n);e.fetchMetrics=K.renderOpts.fetchMetrics;let l=K.renderOpts.pendingWaitUntil;l&&r.waitUntil&&(r.waitUntil(l),l=void 0);let d=K.renderOpts.collectedTags;if(!$)return await (0,p.sendResponse)(W,B,s,K.renderOpts.pendingWaitUntil),null;{let e=await s.blob(),t=(0,f.toNodeOutgoingHttpHeaders)(s.headers);d&&(t[m.NEXT_CACHE_TAGS_HEADER]=d),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let a=void 0!==K.renderOpts.collectedRevalidate&&!(K.renderOpts.collectedRevalidate>=m.INFINITE_CACHE)&&K.renderOpts.collectedRevalidate,r=void 0===K.renderOpts.collectedExpire||K.renderOpts.collectedExpire>=m.INFINITE_CACHE?void 0:K.renderOpts.collectedExpire;return{value:{kind:h.CachedRouteKind.APP_ROUTE,status:s.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:a,expire:r}}}}catch(t){throw(null==a?void 0:a.isStale)&&await S.onRequestError(e,t,{routerKind:"App Router",routePath:y,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:I,isOnDemandRevalidate:N})},!1,A),t}},u=await S.handleResponse({req:e,nextConfig:b,cacheKey:F,routeKind:a.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:E,isRoutePPREnabled:!1,isOnDemandRevalidate:N,revalidateOnlyGenerated:j,responseGenerator:d,waitUntil:r.waitUntil,isMinimalMode:o});if(!$)return null;if((null==u||null==(s=u.value)?void 0:s.kind)!==h.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==u||null==(l=u.value)?void 0:l.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});o||t.setHeader("x-nextjs-cache",N?"REVALIDATED":u.isMiss?"MISS":u.isStale?"STALE":"HIT"),C&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let x=(0,f.fromNodeOutgoingHttpHeaders)(u.value.headers);return o&&$||x.delete(m.NEXT_CACHE_TAGS_HEADER),!u.cacheControl||t.getHeader("Cache-Control")||x.get("Cache-Control")||x.set("Cache-Control",(0,g.getCacheControlHeader)(u.cacheControl)),await (0,p.sendResponse)(W,B,new Response(u.value.body,{headers:x,status:u.value.status||200})),null};D?await l(D):await U.withPropagatedContext(e.headers,()=>U.trace(u.BaseServerSpan.handleRequest,{spanName:`${H} ${y}`,kind:s.SpanKind.SERVER,attributes:{"http.method":H,"http.target":e.url}},l))}catch(t){if(t instanceof x.NoFallbackError||await S.onRequestError(e,t,{routerKind:"App Router",routePath:P,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:I,isOnDemandRevalidate:N})},!1,A),$)throw t;return await (0,p.sendResponse)(W,B,new Response(null,{status:500})),null}}e.s(["handler",()=>P,"patchFetch",()=>T,"routeModule",()=>S,"serverHooks",()=>_,"workAsyncStorage",()=>j,"workUnitAsyncStorage",()=>O],17739)}];
2
+
3
+ //# sourceMappingURL=%5Broot-of-the-server%5D__7c298a19._.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/app/api/ide/openclaw/build-config.ts","../../../src/app/api/ide/openclaw/apply/route.ts","../../../node_modules/next/dist/esm/build/templates/app-route.js"],"sourcesContent":["import { getDatabase } from '@/db/database';\nimport { getConfig } from '@/db/queries';\nimport { getAllModels } from '@/db/queries';\n\nexport async function getGatewayAddress(): Promise<string> {\n await getDatabase();\n const portConfig = await getConfig('port');\n const port = portConfig?.value || '1357';\n return `http://localhost:${port}/v1`;\n}\n\nexport async function getGatewayApiKey(): Promise<string> {\n await getDatabase();\n const apiKeyConfig = await getConfig('api_key');\n return apiKeyConfig?.value || 'your-gateway-api-key';\n}\n\n/** OpenClaw provider entry structure */\nexport type OpenClawProviderEntry = {\n baseUrl: string;\n apiKey: string;\n api: 'openai-completions';\n models: Array<{\n id: string;\n name: string;\n reasoning?: boolean;\n input?: string[];\n cost?: {\n input: number;\n output: number;\n cacheRead: number;\n cacheWrite: number;\n };\n contextWindow?: number;\n maxTokens?: number;\n }>;\n};\n\nexport async function buildAarGatewayProvider(): Promise<OpenClawProviderEntry> {\n const gatewayAddress = await getGatewayAddress();\n const gatewayApiKey = await getGatewayApiKey();\n const allModels = (await getAllModels()).filter((m: any) => m.enabled);\n\n const models = allModels.map((m: any) => ({\n id: m.model_id,\n name: m.name,\n reasoning: m.reasoning || false,\n input: m.input || ['text'],\n cost: m.cost || { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },\n contextWindow: m.context_window || 200000,\n maxTokens: m.max_tokens || 8192,\n }));\n\n return {\n baseUrl: gatewayAddress,\n apiKey: gatewayApiKey,\n api: 'openai-completions',\n models,\n };\n}\n\nconst AAR_PROVIDER_ID = 'aar-gateway';\n\n/** Merge existing OpenClaw config with AAR gateway */\nexport function mergeConfigWithAar(\n existing: Record<string, any> | null,\n config: {\n defaultModel: string;\n defaultFallbacks?: string[];\n imageModel?: string;\n imageFallbacks?: string[];\n },\n aarProvider: OpenClawProviderEntry\n): Record<string, any> {\n const base = existing && typeof existing === 'object' ? { ...existing } : {};\n\n // Update models.providers\n const modelsConfig = base.models || {};\n const providers = modelsConfig.providers || {};\n providers[AAR_PROVIDER_ID] = aarProvider;\n modelsConfig.providers = providers;\n modelsConfig.mode = 'merge';\n base.models = modelsConfig;\n\n // Update agents.defaults.model\n const agents = base.agents || {};\n const defaults = agents.defaults || {};\n const model = defaults.model || {};\n\n // Format: provider/model\n const fullModelId = `${AAR_PROVIDER_ID}/${config.defaultModel}`;\n const fullImageModelId = config.imageModel\n ? `${AAR_PROVIDER_ID}/${config.imageModel}`\n : undefined;\n\n model.primary = fullModelId;\n if (config.defaultFallbacks && config.defaultFallbacks.length > 0) {\n model.fallbacks = config.defaultFallbacks.map((m: string) =>\n m.startsWith(`${AAR_PROVIDER_ID}/`) ? m : `${AAR_PROVIDER_ID}/${m}`\n );\n } else {\n delete model.fallbacks;\n }\n\n defaults.model = model;\n\n // Update agents.defaults.imageModel\n const imageModel = defaults.imageModel || {};\n if (fullImageModelId) {\n imageModel.primary = fullImageModelId;\n }\n if (config.imageFallbacks && config.imageFallbacks.length > 0) {\n imageModel.fallbacks = config.imageFallbacks.map((m: string) =>\n m.startsWith(`${AAR_PROVIDER_ID}/`) ? m : `${AAR_PROVIDER_ID}/${m}`\n );\n } else {\n delete imageModel.fallbacks;\n }\n defaults.imageModel = imageModel;\n\n // Update agents.defaults.models so OpenClaw can resolve aar-gateway model ids (alias, etc.)\n const modelsMap = defaults.models || {};\n for (const m of aarProvider.models) {\n const fullId = `${AAR_PROVIDER_ID}/${m.id}`;\n modelsMap[fullId] = modelsMap[fullId] || { alias: m.name };\n }\n defaults.models = modelsMap;\n\n agents.defaults = defaults;\n base.agents = agents;\n\n // Ensure channels exists (even if empty)\n if (!base.channels) {\n base.channels = {};\n }\n\n return base;\n}\n\n/** Generate merged config for preview or apply */\nexport async function buildMergedConfig(\n config: {\n defaultModel: string;\n defaultFallbacks?: string[];\n imageModel?: string;\n imageFallbacks?: string[];\n },\n existing: Record<string, any> | null\n): Promise<Record<string, any>> {\n const aarProvider = await buildAarGatewayProvider();\n return mergeConfigWithAar(existing, config, aarProvider);\n}\n","import { NextRequest, NextResponse } from 'next/server';\nimport { existsSync, readFileSync, writeFileSync, mkdirSync } from 'fs';\nimport { join } from 'path';\nimport { homedir } from 'os';\nimport { buildMergedConfig } from '../build-config';\n\nconst OPENCLAW_DIR = join(homedir(), '.openclaw');\nconst OPENCLAW_FILE = join(OPENCLAW_DIR, 'openclaw.json');\nconst BACKUP_FILE = join(OPENCLAW_DIR, 'openclaw.json.aar.bak');\n\nfunction backupOriginalConfig(): { success: boolean; existed: boolean; isFromAar: boolean; error?: string } {\n try {\n const existing = existsSync(OPENCLAW_FILE);\n if (existing) {\n const original = readFileSync(OPENCLAW_FILE, 'utf-8');\n let isFromAar = false;\n try {\n const parsed = JSON.parse(original);\n isFromAar = !!(parsed.models?.providers?.['aar-gateway']);\n } catch {}\n // 仅在当前配置不是 AAR 时写入备份,这样「还原」才能恢复到应用 AAR 前的状态;若已是 AAR 则保留原有备份不覆盖\n if (!isFromAar) {\n writeFileSync(BACKUP_FILE, original, 'utf-8');\n }\n return { success: true, existed: true, isFromAar };\n }\n return { success: true, existed: false, isFromAar: false };\n } catch (error: any) {\n return { success: false, existed: false, isFromAar: false, error: `Backup failed: ${error.message}` };\n }\n}\n\nexport async function POST(request: NextRequest) {\n try {\n const body = await request.json();\n const {\n default_model: defaultModel,\n default_fallbacks: defaultFallbacks = [],\n image_model: imageModel,\n image_fallbacks: imageFallbacks = [],\n config: customConfigStr,\n } = body;\n\n let existing: Record<string, any> | null = null;\n if (existsSync(OPENCLAW_FILE)) {\n try {\n existing = JSON.parse(readFileSync(OPENCLAW_FILE, 'utf-8'));\n } catch {\n existing = null;\n }\n }\n\n let config: Record<string, any>;\n if (typeof customConfigStr === 'string' && customConfigStr.trim()) {\n try {\n config = JSON.parse(customConfigStr);\n if (!config || typeof config !== 'object') throw new Error('Invalid config object');\n } catch (e: any) {\n return NextResponse.json({ error: 'Invalid config JSON: ' + (e.message || 'parse error') }, { status: 400 });\n }\n } else {\n if (!defaultModel) {\n return NextResponse.json({ error: 'Missing required field: default_model' }, { status: 400 });\n }\n config = await buildMergedConfig(\n {\n defaultModel,\n defaultFallbacks,\n imageModel: imageModel || undefined,\n imageFallbacks,\n },\n existing\n );\n }\n\n const backupResult = backupOriginalConfig();\n if (!backupResult.success) {\n return NextResponse.json({ error: backupResult.error }, { status: 500 });\n }\n\n if (!existsSync(OPENCLAW_DIR)) {\n mkdirSync(OPENCLAW_DIR, { recursive: true });\n }\n\n const jsonString = JSON.stringify(config, null, 2);\n writeFileSync(OPENCLAW_FILE, jsonString, 'utf-8');\n\n const alreadyHadAar = !!(existing?.models?.providers?.['aar-gateway']);\n return NextResponse.json({\n success: true,\n message: alreadyHadAar ? 'OpenClaw 配置已更新为最新网关信息' : 'OpenClaw configuration applied successfully',\n config,\n backup: backupResult.existed ? 'Created backup' : 'No existing config to backup',\n previousWasFromAar: backupResult.existed && backupResult.isFromAar,\n });\n } catch (error: any) {\n console.error('OpenClaw Apply 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 } 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/ide/openclaw/apply/route\",\n pathname: \"/api/ide/openclaw/apply\",\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/ide/openclaw/apply/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 (routeModule.isDev) {\n addRequestMeta(req, 'devRequestTimingInternalsEnd', process.hrtime.bigint());\n }\n let srcPage = \"/api/ide/openclaw/apply/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.experimental.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 context = {\n params,\n prerenderManifest,\n renderOpts: {\n experimental: {\n authInterrupts: Boolean(nextConfig.experimental.authInterrupts)\n },\n cacheComponents: Boolean(nextConfig.cacheComponents),\n supportsDynamicResponse,\n incrementalCache: getRequestMeta(req, '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 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 } else {\n span.updateName(`${method} ${srcPage}`);\n }\n });\n };\n const isMinimalMode = Boolean(process.env.MINIMAL_MODE || getRequestMeta(req, 'minimalMode'));\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 (activeSpan) {\n await handleResponse(activeSpan);\n } else {\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));\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(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SAAS,EAAW,KAAK,CAAC,IAAI,CAAE,SAChC,EACA,OAAQ,EAAW,KAAK,CAAC,MAAM,EAAI,GACvC,IACO,IACX,EAGI,EACA,MAAM,EAAe,EADT,CAGZ,MAAM,EAAO,qBAAqB,CAAC,EAAI,OAAO,CAAE,IAAI,EAAO,KAAK,CAAC,EAAA,cAAc,CAAC,aAAa,CAAE,CACvF,SAAU,CAAA,EAAG,EAAO,CAAC,EAAE,EAAA,CAAS,CAChC,KAAM,EAAA,QAAQ,CAAC,MAAM,CACrB,WAAY,CACR,cAAe,EACf,cAAe,EAAI,GAAG,AAC1B,CACJ,EAAG,GAEf,CAAE,MAAO,EAAK,CAeV,GAdM,aAAe,EAAA,eAAe,EAEhC,CAFmC,KAE7B,EAAY,cAAc,CAAC,EAAK,EAAK,CACvC,WAAY,aACZ,UAAW,EACX,UAAW,QACX,iBAAkB,CAAA,EAAA,EAAA,mBAAA,AAAmB,EAAC,oBAClC,uBACA,CACJ,EACJ,GAAG,AATgB,EASJ,GAIf,EAAO,MAAM,EAKjB,OAHA,MAAM,CAAA,EAAA,EAAA,YAAA,AAAY,EAAC,EAAa,EAAa,IAAI,SAAS,KAAM,CAC5D,OAAQ,GACZ,IACO,IACX,CACJ,EAEA,qCAAqC","ignoreList":[2]}
@@ -0,0 +1,3 @@
1
+ module.exports=[93695,(e,t,a)=>{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,a)=>{t.exports=e.x("path",()=>require("path"))},70406,(e,t,a)=>{t.exports=e.x("next/dist/compiled/@opentelemetry/api",()=>require("next/dist/compiled/@opentelemetry/api"))},18622,(e,t,a)=>{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,a)=>{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,a)=>{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,a)=>{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"))},68646,e=>{"use strict";var t=e.i(71560),a=e.i(97731);async function r(){await (0,t.getDatabase)();let e=await (0,a.getConfig)("port"),r=e?.value||"1357";return`http://localhost:${r}/v1`}async function n(){await (0,t.getDatabase)();let e=await (0,a.getConfig)("api_key");return e?.value||"your-gateway-api-key"}async function i(){return{baseUrl:await r(),apiKey:await n(),api:"openai-completions",models:(await (0,a.getAllModels)()).filter(e=>e.enabled).map(e=>({id:e.model_id,name:e.name,reasoning:e.reasoning||!1,input:e.input||["text"],cost:e.cost||{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:e.context_window||2e5,maxTokens:e.max_tokens||8192}))}}let s="aar-gateway";async function o(e,t){return function(e,t,a){let r=e&&"object"==typeof e?{...e}:{},n=r.models||{},i=n.providers||{};i[s]=a,n.providers=i,n.mode="merge",r.models=n;let o=r.agents||{},l=o.defaults||{},d=l.model||{},u=`${s}/${t.defaultModel}`,c=t.imageModel?`${s}/${t.imageModel}`:void 0;d.primary=u,t.defaultFallbacks&&t.defaultFallbacks.length>0?d.fallbacks=t.defaultFallbacks.map(e=>e.startsWith(`${s}/`)?e:`${s}/${e}`):delete d.fallbacks,l.model=d;let p=l.imageModel||{};c&&(p.primary=c),t.imageFallbacks&&t.imageFallbacks.length>0?p.fallbacks=t.imageFallbacks.map(e=>e.startsWith(`${s}/`)?e:`${s}/${e}`):delete p.fallbacks,l.imageModel=p;let m=l.models||{};for(let e of a.models){let t=`${s}/${e.id}`;m[t]=m[t]||{alias:e.name}}return l.models=m,o.defaults=l,r.agents=o,r.channels||(r.channels={}),r}(t,e,await i())}e.s(["buildMergedConfig",()=>o])},58306,e=>{"use strict";var t=e.i(47909),a=e.i(74017),r=e.i(96250),n=e.i(59756),i=e.i(61916),s=e.i(74677),o=e.i(69741),l=e.i(16795),d=e.i(87718),u=e.i(95169),c=e.i(47587),p=e.i(66012),m=e.i(70101),h=e.i(26937),g=e.i(10372),f=e.i(93695);e.i(52474);var x=e.i(220),v=e.i(89171),w=e.i(22734),R=e.i(14747),y=e.i(46786),b=e.i(68646);let C=(0,R.join)((0,y.homedir)(),".aar"),E=(0,R.join)(C,"openclaw.tmp.json"),k=(0,R.join)((0,y.homedir)(),".openclaw","openclaw.json");async function A(e){try{let{default_model:t,default_fallbacks:a=[],image_model:r,image_fallbacks:n=[]}=await e.json();(0,w.existsSync)(C)||(0,w.mkdirSync)(C,{recursive:!0});let i=null;if((0,w.existsSync)(k))try{i=JSON.parse((0,w.readFileSync)(k,"utf-8"))}catch{i=null}await (0,b.buildMergedConfig)({defaultModel:t,defaultFallbacks:a,imageModel:r,imageFallbacks:n},i);let s={defaultModel:t,defaultFallbacks:a,imageModel:r,imageFallbacks:n,updatedAt:new Date().toISOString()};return(0,w.writeFileSync)(E,JSON.stringify(s,null,2),"utf-8"),v.NextResponse.json({success:!0,saveType:"temp",message:"Configuration saved temporarily"})}catch(e){return console.error("OpenClaw Save API error:",e),v.NextResponse.json({error:e.message||"Internal server error",stack:void 0},{status:500})}}e.s(["POST",()=>A],5234);var S=e.i(5234);let _=new t.AppRouteRouteModule({definition:{kind:a.RouteKind.APP_ROUTE,page:"/api/ide/openclaw/save/route",pathname:"/api/ide/openclaw/save",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/src/app/api/ide/openclaw/save/route.ts",nextConfigOutput:"",userland:S}),{workAsyncStorage:N,workUnitAsyncStorage:T,serverHooks:j}=_;function O(){return(0,r.patchFetch)({workAsyncStorage:N,workUnitAsyncStorage:T})}async function P(e,t,r){_.isDev&&(0,n.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let v="/api/ide/openclaw/save/route";v=v.replace(/\/index$/,"")||"/";let w=await _.prepare(e,t,{srcPage:v,multiZoneDraftMode:!1});if(!w)return t.statusCode=400,t.end("Bad Request"),null==r.waitUntil||r.waitUntil.call(r,Promise.resolve()),null;let{buildId:R,params:y,nextConfig:b,parsedUrl:C,isDraftMode:E,prerenderManifest:k,routerServerContext:A,isOnDemandRevalidate:S,revalidateOnlyGenerated:N,resolvedPathname:T,clientReferenceManifest:j,serverActionsManifest:O}=w,P=(0,o.normalizeAppPath)(v),$=!!(k.dynamicRoutes[P]||k.routes[T]),q=async()=>((null==A?void 0:A.render404)?await A.render404(e,t,C,!1):t.end("This page could not be found"),null);if($&&!E){let e=!!k.routes[T],t=k.dynamicRoutes[P];if(t&&!1===t.fallback&&!e){if(b.experimental.adapterPath)return await q();throw new f.NoFallbackError}}let M=null;!$||_.isDev||E||(M="/index"===(M=T)?"/":M);let I=!0===_.isDev||!$,H=$&&!I;O&&j&&(0,s.setManifestsSingleton)({page:v,clientReferenceManifest:j,serverActionsManifest:O});let U=e.method||"GET",D=(0,i.getTracer)(),F=D.getActiveScopeSpan(),K={params:y,prerenderManifest:k,renderOpts:{experimental:{authInterrupts:!!b.experimental.authInterrupts},cacheComponents:!!b.cacheComponents,supportsDynamicResponse:I,incrementalCache:(0,n.getRequestMeta)(e,"incrementalCache"),cacheLifeProfiles:b.cacheLife,waitUntil:r.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,a,r,n)=>_.onRequestError(e,t,r,n,A)},sharedContext:{buildId:R}},W=new l.NodeNextRequest(e),B=new l.NodeNextResponse(t),L=d.NextRequestAdapter.fromNodeNextRequest(W,(0,d.signalFromNodeResponse)(t));try{let s=async e=>_.handle(L,K).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let a=D.getRootSpanAttributes();if(!a)return;if(a.get("next.span_type")!==u.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${a.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let r=a.get("next.route");if(r){let t=`${U} ${r}`;e.setAttributes({"next.route":r,"http.route":r,"next.span_name":t}),e.updateName(t)}else e.updateName(`${U} ${v}`)}),o=!!(0,n.getRequestMeta)(e,"minimalMode"),l=async n=>{var i,l;let d=async({previousCacheEntry:a})=>{try{if(!o&&S&&N&&!a)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let i=await s(n);e.fetchMetrics=K.renderOpts.fetchMetrics;let l=K.renderOpts.pendingWaitUntil;l&&r.waitUntil&&(r.waitUntil(l),l=void 0);let d=K.renderOpts.collectedTags;if(!$)return await (0,p.sendResponse)(W,B,i,K.renderOpts.pendingWaitUntil),null;{let e=await i.blob(),t=(0,m.toNodeOutgoingHttpHeaders)(i.headers);d&&(t[g.NEXT_CACHE_TAGS_HEADER]=d),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let a=void 0!==K.renderOpts.collectedRevalidate&&!(K.renderOpts.collectedRevalidate>=g.INFINITE_CACHE)&&K.renderOpts.collectedRevalidate,r=void 0===K.renderOpts.collectedExpire||K.renderOpts.collectedExpire>=g.INFINITE_CACHE?void 0:K.renderOpts.collectedExpire;return{value:{kind:x.CachedRouteKind.APP_ROUTE,status:i.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:a,expire:r}}}}catch(t){throw(null==a?void 0:a.isStale)&&await _.onRequestError(e,t,{routerKind:"App Router",routePath:v,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:H,isOnDemandRevalidate:S})},!1,A),t}},u=await _.handleResponse({req:e,nextConfig:b,cacheKey:M,routeKind:a.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:k,isRoutePPREnabled:!1,isOnDemandRevalidate:S,revalidateOnlyGenerated:N,responseGenerator:d,waitUntil:r.waitUntil,isMinimalMode:o});if(!$)return null;if((null==u||null==(i=u.value)?void 0:i.kind)!==x.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==u||null==(l=u.value)?void 0:l.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});o||t.setHeader("x-nextjs-cache",S?"REVALIDATED":u.isMiss?"MISS":u.isStale?"STALE":"HIT"),E&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let f=(0,m.fromNodeOutgoingHttpHeaders)(u.value.headers);return o&&$||f.delete(g.NEXT_CACHE_TAGS_HEADER),!u.cacheControl||t.getHeader("Cache-Control")||f.get("Cache-Control")||f.set("Cache-Control",(0,h.getCacheControlHeader)(u.cacheControl)),await (0,p.sendResponse)(W,B,new Response(u.value.body,{headers:f,status:u.value.status||200})),null};F?await l(F):await D.withPropagatedContext(e.headers,()=>D.trace(u.BaseServerSpan.handleRequest,{spanName:`${U} ${v}`,kind:i.SpanKind.SERVER,attributes:{"http.method":U,"http.target":e.url}},l))}catch(t){if(t instanceof f.NoFallbackError||await _.onRequestError(e,t,{routerKind:"App Router",routePath:P,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:H,isOnDemandRevalidate:S})},!1,A),$)throw t;return await (0,p.sendResponse)(W,B,new Response(null,{status:500})),null}}e.s(["handler",()=>P,"patchFetch",()=>O,"routeModule",()=>_,"serverHooks",()=>j,"workAsyncStorage",()=>N,"workUnitAsyncStorage",()=>T],58306)}];
2
+
3
+ //# sourceMappingURL=%5Broot-of-the-server%5D__85540228._.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/app/api/ide/openclaw/build-config.ts","../../../node_modules/next/dist/esm/build/templates/app-route.js","../../../src/app/api/ide/openclaw/save/route.ts"],"sourcesContent":["import { getDatabase } from '@/db/database';\nimport { getConfig } from '@/db/queries';\nimport { getAllModels } from '@/db/queries';\n\nexport async function getGatewayAddress(): Promise<string> {\n await getDatabase();\n const portConfig = await getConfig('port');\n const port = portConfig?.value || '1357';\n return `http://localhost:${port}/v1`;\n}\n\nexport async function getGatewayApiKey(): Promise<string> {\n await getDatabase();\n const apiKeyConfig = await getConfig('api_key');\n return apiKeyConfig?.value || 'your-gateway-api-key';\n}\n\n/** OpenClaw provider entry structure */\nexport type OpenClawProviderEntry = {\n baseUrl: string;\n apiKey: string;\n api: 'openai-completions';\n models: Array<{\n id: string;\n name: string;\n reasoning?: boolean;\n input?: string[];\n cost?: {\n input: number;\n output: number;\n cacheRead: number;\n cacheWrite: number;\n };\n contextWindow?: number;\n maxTokens?: number;\n }>;\n};\n\nexport async function buildAarGatewayProvider(): Promise<OpenClawProviderEntry> {\n const gatewayAddress = await getGatewayAddress();\n const gatewayApiKey = await getGatewayApiKey();\n const allModels = (await getAllModels()).filter((m: any) => m.enabled);\n\n const models = allModels.map((m: any) => ({\n id: m.model_id,\n name: m.name,\n reasoning: m.reasoning || false,\n input: m.input || ['text'],\n cost: m.cost || { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },\n contextWindow: m.context_window || 200000,\n maxTokens: m.max_tokens || 8192,\n }));\n\n return {\n baseUrl: gatewayAddress,\n apiKey: gatewayApiKey,\n api: 'openai-completions',\n models,\n };\n}\n\nconst AAR_PROVIDER_ID = 'aar-gateway';\n\n/** Merge existing OpenClaw config with AAR gateway */\nexport function mergeConfigWithAar(\n existing: Record<string, any> | null,\n config: {\n defaultModel: string;\n defaultFallbacks?: string[];\n imageModel?: string;\n imageFallbacks?: string[];\n },\n aarProvider: OpenClawProviderEntry\n): Record<string, any> {\n const base = existing && typeof existing === 'object' ? { ...existing } : {};\n\n // Update models.providers\n const modelsConfig = base.models || {};\n const providers = modelsConfig.providers || {};\n providers[AAR_PROVIDER_ID] = aarProvider;\n modelsConfig.providers = providers;\n modelsConfig.mode = 'merge';\n base.models = modelsConfig;\n\n // Update agents.defaults.model\n const agents = base.agents || {};\n const defaults = agents.defaults || {};\n const model = defaults.model || {};\n\n // Format: provider/model\n const fullModelId = `${AAR_PROVIDER_ID}/${config.defaultModel}`;\n const fullImageModelId = config.imageModel\n ? `${AAR_PROVIDER_ID}/${config.imageModel}`\n : undefined;\n\n model.primary = fullModelId;\n if (config.defaultFallbacks && config.defaultFallbacks.length > 0) {\n model.fallbacks = config.defaultFallbacks.map((m: string) =>\n m.startsWith(`${AAR_PROVIDER_ID}/`) ? m : `${AAR_PROVIDER_ID}/${m}`\n );\n } else {\n delete model.fallbacks;\n }\n\n defaults.model = model;\n\n // Update agents.defaults.imageModel\n const imageModel = defaults.imageModel || {};\n if (fullImageModelId) {\n imageModel.primary = fullImageModelId;\n }\n if (config.imageFallbacks && config.imageFallbacks.length > 0) {\n imageModel.fallbacks = config.imageFallbacks.map((m: string) =>\n m.startsWith(`${AAR_PROVIDER_ID}/`) ? m : `${AAR_PROVIDER_ID}/${m}`\n );\n } else {\n delete imageModel.fallbacks;\n }\n defaults.imageModel = imageModel;\n\n // Update agents.defaults.models so OpenClaw can resolve aar-gateway model ids (alias, etc.)\n const modelsMap = defaults.models || {};\n for (const m of aarProvider.models) {\n const fullId = `${AAR_PROVIDER_ID}/${m.id}`;\n modelsMap[fullId] = modelsMap[fullId] || { alias: m.name };\n }\n defaults.models = modelsMap;\n\n agents.defaults = defaults;\n base.agents = agents;\n\n // Ensure channels exists (even if empty)\n if (!base.channels) {\n base.channels = {};\n }\n\n return base;\n}\n\n/** Generate merged config for preview or apply */\nexport async function buildMergedConfig(\n config: {\n defaultModel: string;\n defaultFallbacks?: string[];\n imageModel?: string;\n imageFallbacks?: string[];\n },\n existing: Record<string, any> | null\n): Promise<Record<string, any>> {\n const aarProvider = await buildAarGatewayProvider();\n return mergeConfigWithAar(existing, config, aarProvider);\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 } 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/ide/openclaw/save/route\",\n pathname: \"/api/ide/openclaw/save\",\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/ide/openclaw/save/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 (routeModule.isDev) {\n addRequestMeta(req, 'devRequestTimingInternalsEnd', process.hrtime.bigint());\n }\n let srcPage = \"/api/ide/openclaw/save/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.experimental.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 context = {\n params,\n prerenderManifest,\n renderOpts: {\n experimental: {\n authInterrupts: Boolean(nextConfig.experimental.authInterrupts)\n },\n cacheComponents: Boolean(nextConfig.cacheComponents),\n supportsDynamicResponse,\n incrementalCache: getRequestMeta(req, '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 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 } else {\n span.updateName(`${method} ${srcPage}`);\n }\n });\n };\n const isMinimalMode = Boolean(process.env.MINIMAL_MODE || getRequestMeta(req, 'minimalMode'));\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 (activeSpan) {\n await handleResponse(activeSpan);\n } else {\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));\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","import { NextRequest, NextResponse } from 'next/server';\nimport { existsSync, readFileSync, writeFileSync, mkdirSync } from 'fs';\nimport { join } from 'path';\nimport { homedir } from 'os';\nimport { buildMergedConfig } from '../build-config';\n\nconst AAR_DIR = join(homedir(), '.aar');\nconst TEMP_OPENCLAW_FILE = join(AAR_DIR, 'openclaw.tmp.json');\nconst OPENCLAW_FILE = join(homedir(), '.openclaw', 'openclaw.json');\n\nexport async function POST(request: NextRequest) {\n try {\n const body = await request.json();\n const {\n default_model: defaultModel,\n default_fallbacks: defaultFallbacks = [],\n image_model: imageModel,\n image_fallbacks: imageFallbacks = [],\n } = body;\n\n if (!existsSync(AAR_DIR)) {\n mkdirSync(AAR_DIR, { recursive: true });\n }\n\n let existing: Record<string, any> | null = null;\n if (existsSync(OPENCLAW_FILE)) {\n try {\n existing = JSON.parse(readFileSync(OPENCLAW_FILE, 'utf-8'));\n } catch {\n existing = null;\n }\n }\n\n // Build the merged config\n const mergedConfig = await buildMergedConfig(\n {\n defaultModel,\n defaultFallbacks,\n imageModel,\n imageFallbacks,\n },\n existing\n );\n\n // Save to temp file\n const tempData = {\n defaultModel,\n defaultFallbacks,\n imageModel,\n imageFallbacks,\n updatedAt: new Date().toISOString(),\n };\n writeFileSync(TEMP_OPENCLAW_FILE, JSON.stringify(tempData, null, 2), 'utf-8');\n\n return NextResponse.json({\n success: true,\n saveType: 'temp',\n message: 'Configuration saved temporarily'\n });\n } catch (error: any) {\n console.error('OpenClaw Save 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"],"names":[],"mappings":"8iCAAA,IAAA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OAGO,eAAe,IACpB,MAAM,CAAA,EAAA,EAAA,WAAA,AAAW,IACjB,IAAM,EAAa,MAAM,CAAA,EAAA,EAAA,SAAA,AAAS,EAAC,QAC7B,EAAO,GAAY,OAAS,OAClC,MAAO,CAAC,iBAAiB,EAAE,EAAK,GAAG,CAAC,AACtC,CAEO,eAAe,IACpB,MAAM,CAAA,EAAA,EAAA,WAAA,AAAW,IACjB,IAAM,EAAe,MAAM,CAAA,EAAA,EAAA,SAAA,AAAS,EAAC,WACrC,OAAO,GAAc,OAAS,sBAChC,CAuBO,eAAe,IAepB,MAAO,CACL,QAfqB,CAeZ,KAfkB,IAgB3B,OAfoB,CAeZ,KA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A,EAAA,EAAA,YAAA,AAAY,EAAC,EAAa,EAAa,IAAI,SAAS,KAAM,CAC5D,OAAQ,GACZ,IACO,IACX,CACJ,EAEA,qCAAqC","ignoreList":[1]}
@@ -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"))},14747,(e,t,r)=>{t.exports=e.x("path",()=>require("path"))},70406,(e,t,r)=>{t.exports=e.x("next/dist/compiled/@opentelemetry/api",()=>require("next/dist/compiled/@opentelemetry/api"))},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"))},53394,e=>{"use strict";var t=e.i(47909),r=e.i(74017),a=e.i(96250),n=e.i(59756),o=e.i(61916),s=e.i(74677),i=e.i(69741),l=e.i(16795),d=e.i(87718),p=e.i(95169),u=e.i(47587),c=e.i(66012),h=e.i(70101),x=e.i(26937),v=e.i(10372),y=e.i(93695);e.i(52474);var f=e.i(220),R=e.i(89171),g=e.i(22734),m=e.i(14747),w=e.i(46786),E=e.i(71560),C=e.i(97731);let b=(0,m.join)((0,w.homedir)(),".config","opencode"),S=(0,m.join)(b,"opencode.json"),j=(0,m.join)(b,"opencode.json.aar.bak"),A=(0,m.join)((0,w.homedir)(),".aar"),N=(0,m.join)(A,"opencode.tmp.json");function k(e){return e&&"your-gateway-api-key"!==e?e.length<=8?e.slice(0,2)+"***"+e.slice(-2):e.slice(0,4)+"****"+e.slice(-4):e}async function O(e){try{let e,t,r=(0,g.existsSync)(S),a=(0,g.existsSync)(j);await (0,E.getDatabase)();let n=await (0,C.getConfig)("api_key"),o=await (0,C.getConfig)("port"),s=n?.value||"your-gateway-api-key",i=`http://localhost:${o?.value||"1357"}/v1`;if(!r){let e;if((0,g.existsSync)(N))try{e=JSON.parse((0,g.readFileSync)(N,"utf-8")).defaultModel}catch{}return R.NextResponse.json({applied:!1,defaultModel:void 0,gatewayAddress:i,apiKey:k(s),backupExists:!1,lastUpdated:void 0,matchCurrentGateway:!1,routerProvider:void 0,tempDefaultModel:e})}let l=(0,g.readFileSync)(S,"utf-8");try{e=JSON.parse(l)}catch{return R.NextResponse.json({error:"Invalid opencode.json format"},{status:500})}let d=(e.provider&&"object"==typeof e.provider?e.provider:{})["aar-gateway"],p=d?.options?.baseURL,u=d?.options?.apiKey,c=p===i&&u===s,h="string"==typeof e.model&&e.model.startsWith("aar-gateway/")?e.model.slice(12):e.default_model,x=d?.models?Object.keys(d.models).length:0;if(!c&&(0,g.existsSync)(N))try{t=JSON.parse((0,g.readFileSync)(N,"utf-8")).defaultModel}catch{}let v=null;try{v=new Date((0,g.statSync)(S).mtime).toISOString()}catch{}let y={applied:!0,defaultModel:h,gatewayAddress:p,apiKey:k(u||s),backupExists:a,lastUpdated:v,matchCurrentGateway:c,routerProvider:d?"aar":void 0,tempDefaultModel:t,providerName:d?.name,modelsCount:x,config:e};return R.NextResponse.json(y)}catch(e){return console.error("OpenCode Status API error:",e),R.NextResponse.json({error:e.message||"Internal server error",stack:void 0},{status:500})}}e.s(["GET",()=>O],36272);var P=e.i(36272);let T=new t.AppRouteRouteModule({definition:{kind:r.RouteKind.APP_ROUTE,page:"/api/ide/opencode/status/route",pathname:"/api/ide/opencode/status",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/src/app/api/ide/opencode/status/route.ts",nextConfigOutput:"",userland:P}),{workAsyncStorage:_,workUnitAsyncStorage:q,serverHooks:I}=T;function U(){return(0,a.patchFetch)({workAsyncStorage:_,workUnitAsyncStorage:q})}async function H(e,t,a){T.isDev&&(0,n.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let R="/api/ide/opencode/status/route";R=R.replace(/\/index$/,"")||"/";let g=await T.prepare(e,t,{srcPage:R,multiZoneDraftMode:!1});if(!g)return t.statusCode=400,t.end("Bad Request"),null==a.waitUntil||a.waitUntil.call(a,Promise.resolve()),null;let{buildId:m,params:w,nextConfig:E,parsedUrl:C,isDraftMode:b,prerenderManifest:S,routerServerContext:j,isOnDemandRevalidate:A,revalidateOnlyGenerated:N,resolvedPathname:k,clientReferenceManifest:O,serverActionsManifest:P}=g,_=(0,i.normalizeAppPath)(R),q=!!(S.dynamicRoutes[_]||S.routes[k]),I=async()=>((null==j?void 0:j.render404)?await j.render404(e,t,C,!1):t.end("This page could not be found"),null);if(q&&!b){let e=!!S.routes[k],t=S.dynamicRoutes[_];if(t&&!1===t.fallback&&!e){if(E.experimental.adapterPath)return await I();throw new y.NoFallbackError}}let U=null;!q||T.isDev||b||(U="/index"===(U=k)?"/":U);let H=!0===T.isDev||!q,D=q&&!H;P&&O&&(0,s.setManifestsSingleton)({page:R,clientReferenceManifest:O,serverActionsManifest:P});let M=e.method||"GET",F=(0,o.getTracer)(),K=F.getActiveScopeSpan(),$={params:w,prerenderManifest:S,renderOpts:{experimental:{authInterrupts:!!E.experimental.authInterrupts},cacheComponents:!!E.cacheComponents,supportsDynamicResponse:H,incrementalCache:(0,n.getRequestMeta)(e,"incrementalCache"),cacheLifeProfiles:E.cacheLife,waitUntil:a.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,r,a,n)=>T.onRequestError(e,t,a,n,j)},sharedContext:{buildId:m}},L=new l.NodeNextRequest(e),B=new l.NodeNextResponse(t),G=d.NextRequestAdapter.fromNodeNextRequest(L,(0,d.signalFromNodeResponse)(t));try{let s=async e=>T.handle(G,$).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let r=F.getRootSpanAttributes();if(!r)return;if(r.get("next.span_type")!==p.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)}else e.updateName(`${M} ${R}`)}),i=!!(0,n.getRequestMeta)(e,"minimalMode"),l=async n=>{var o,l;let d=async({previousCacheEntry:r})=>{try{if(!i&&A&&N&&!r)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let o=await s(n);e.fetchMetrics=$.renderOpts.fetchMetrics;let l=$.renderOpts.pendingWaitUntil;l&&a.waitUntil&&(a.waitUntil(l),l=void 0);let d=$.renderOpts.collectedTags;if(!q)return await (0,c.sendResponse)(L,B,o,$.renderOpts.pendingWaitUntil),null;{let e=await o.blob(),t=(0,h.toNodeOutgoingHttpHeaders)(o.headers);d&&(t[v.NEXT_CACHE_TAGS_HEADER]=d),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let r=void 0!==$.renderOpts.collectedRevalidate&&!($.renderOpts.collectedRevalidate>=v.INFINITE_CACHE)&&$.renderOpts.collectedRevalidate,a=void 0===$.renderOpts.collectedExpire||$.renderOpts.collectedExpire>=v.INFINITE_CACHE?void 0:$.renderOpts.collectedExpire;return{value:{kind:f.CachedRouteKind.APP_ROUTE,status:o.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:r,expire:a}}}}catch(t){throw(null==r?void 0:r.isStale)&&await T.onRequestError(e,t,{routerKind:"App Router",routePath:R,routeType:"route",revalidateReason:(0,u.getRevalidateReason)({isStaticGeneration:D,isOnDemandRevalidate:A})},!1,j),t}},p=await T.handleResponse({req:e,nextConfig:E,cacheKey:U,routeKind:r.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:S,isRoutePPREnabled:!1,isOnDemandRevalidate:A,revalidateOnlyGenerated:N,responseGenerator:d,waitUntil:a.waitUntil,isMinimalMode:i});if(!q)return null;if((null==p||null==(o=p.value)?void 0:o.kind)!==f.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==p||null==(l=p.value)?void 0:l.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});i||t.setHeader("x-nextjs-cache",A?"REVALIDATED":p.isMiss?"MISS":p.isStale?"STALE":"HIT"),b&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let y=(0,h.fromNodeOutgoingHttpHeaders)(p.value.headers);return i&&q||y.delete(v.NEXT_CACHE_TAGS_HEADER),!p.cacheControl||t.getHeader("Cache-Control")||y.get("Cache-Control")||y.set("Cache-Control",(0,x.getCacheControlHeader)(p.cacheControl)),await (0,c.sendResponse)(L,B,new Response(p.value.body,{headers:y,status:p.value.status||200})),null};K?await l(K):await F.withPropagatedContext(e.headers,()=>F.trace(p.BaseServerSpan.handleRequest,{spanName:`${M} ${R}`,kind:o.SpanKind.SERVER,attributes:{"http.method":M,"http.target":e.url}},l))}catch(t){if(t instanceof y.NoFallbackError||await T.onRequestError(e,t,{routerKind:"App Router",routePath:_,routeType:"route",revalidateReason:(0,u.getRevalidateReason)({isStaticGeneration:D,isOnDemandRevalidate:A})},!1,j),q)throw t;return await (0,c.sendResponse)(L,B,new Response(null,{status:500})),null}}e.s(["handler",()=>H,"patchFetch",()=>U,"routeModule",()=>T,"serverHooks",()=>I,"workAsyncStorage",()=>_,"workUnitAsyncStorage",()=>q],53394)}];
2
+
3
+ //# sourceMappingURL=%5Broot-of-the-server%5D__94fe8d3c._.js.map