@pricening/pi-web 0.9.7 → 0.9.9

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 (257) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-path-routes-manifest.json +13 -11
  3. package/.next/build-manifest.json +2 -2
  4. package/.next/prerender-manifest.json +4 -4
  5. package/.next/required-server-files.js +1 -1
  6. package/.next/required-server-files.json +1 -1
  7. package/.next/routes-manifest.json +12 -0
  8. package/.next/server/app/_global-error/page.js +2 -2
  9. package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  10. package/.next/server/app/_global-error.html +1 -1
  11. package/.next/server/app/_global-error.rsc +1 -1
  12. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  13. package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  14. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  15. package/.next/server/app/_not-found/page.js +1 -1
  16. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  17. package/.next/server/app/_not-found.html +1 -1
  18. package/.next/server/app/_not-found.rsc +3 -3
  19. package/.next/server/app/_not-found.segments/_full.segment.rsc +3 -3
  20. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +3 -3
  21. package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  22. package/.next/server/app/api/agent/[id]/bash-output/route.js +1 -1
  23. package/.next/server/app/api/agent/[id]/events/route.js +2 -2
  24. package/.next/server/app/api/agent/[id]/lease/route.js +1 -1
  25. package/.next/server/app/api/agent/[id]/route.js +1 -1
  26. package/.next/server/app/api/agent/new/route.js +1 -1
  27. package/.next/server/app/api/agent/running/route.js +1 -1
  28. package/.next/server/app/api/app-update/route.js +1 -1
  29. package/.next/server/app/api/archives/route.js +1 -0
  30. package/.next/server/app/api/archives/route.js.nft.json +1 -0
  31. package/.next/server/app/api/archives/route_client-reference-manifest.js +1 -0
  32. package/.next/server/app/api/archives/sessions/route.js +1 -0
  33. package/.next/server/app/api/archives/sessions/route.js.nft.json +1 -0
  34. package/.next/server/app/api/archives/sessions/route_client-reference-manifest.js +1 -0
  35. package/.next/server/app/api/auth/api-key/[provider]/route.js +1 -1
  36. package/.next/server/app/api/auth/login/[provider]/route.js +2 -2
  37. package/.next/server/app/api/auth/logout/[provider]/route.js +1 -1
  38. package/.next/server/app/api/auth/providers/route.js +1 -1
  39. package/.next/server/app/api/cwd/browse/route.js +1 -1
  40. package/.next/server/app/api/cwd/validate/route.js +1 -1
  41. package/.next/server/app/api/default-cwd/route.js +1 -1
  42. package/.next/server/app/api/file-index/route.js +1 -1
  43. package/.next/server/app/api/files/[...path]/route.js +1 -1
  44. package/.next/server/app/api/git/diff/route.js +2 -2
  45. package/.next/server/app/api/git/status/route.js +2 -2
  46. package/.next/server/app/api/home/route.js +1 -1
  47. package/.next/server/app/api/models/route.js +1 -1
  48. package/.next/server/app/api/models-config/catalog/route.js +1 -1
  49. package/.next/server/app/api/models-config/discover/route.js +1 -1
  50. package/.next/server/app/api/models-config/route.js +1 -1
  51. package/.next/server/app/api/models-config/test/route.js +1 -1
  52. package/.next/server/app/api/pins/route.js +1 -1
  53. package/.next/server/app/api/plugins/check/route.js +1 -1
  54. package/.next/server/app/api/plugins/route.js +1 -1
  55. package/.next/server/app/api/project-trust/route.js +1 -1
  56. package/.next/server/app/api/provider-usage/query/route.js +1 -1
  57. package/.next/server/app/api/push/config/route.js +1 -1
  58. package/.next/server/app/api/push/subscribe/route.js +1 -1
  59. package/.next/server/app/api/sessions/[id]/auto-name/route.js +4 -3
  60. package/.next/server/app/api/sessions/[id]/auto-name/route.js.nft.json +1 -1
  61. package/.next/server/app/api/sessions/[id]/context/route.js +1 -1
  62. package/.next/server/app/api/sessions/[id]/entries/[entryId]/thinking/route.js +1 -1
  63. package/.next/server/app/api/sessions/[id]/entries/[entryId]/tool-result-image/route.js +1 -1
  64. package/.next/server/app/api/sessions/[id]/export/route.js +1 -1
  65. package/.next/server/app/api/sessions/[id]/route.js +1 -1
  66. package/.next/server/app/api/sessions/[id]/state/route.js +1 -1
  67. package/.next/server/app/api/sessions/route.js +1 -1
  68. package/.next/server/app/api/sessions/route.js.nft.json +1 -1
  69. package/.next/server/app/api/sessions/search/route.js +1 -1
  70. package/.next/server/app/api/skills/check/route.js +1 -1
  71. package/.next/server/app/api/skills/install/route.js +1 -1
  72. package/.next/server/app/api/skills/route.js +1 -1
  73. package/.next/server/app/api/skills/search/route.js +1 -1
  74. package/.next/server/app/api/skills/update/route.js +1 -1
  75. package/.next/server/app/api/subagents/[id]/route.js +1 -1
  76. package/.next/server/app/api/subagents/profiles/route.js +1 -1
  77. package/.next/server/app/api/subagents/settings/route.js +1 -1
  78. package/.next/server/app/api/terminal/[id]/events/route.js +1 -1
  79. package/.next/server/app/api/terminal/[id]/route.js +1 -1
  80. package/.next/server/app/api/terminal/route.js +1 -1
  81. package/.next/server/app/api/tools/settings/route.js +1 -1
  82. package/.next/server/app/api/web-auth/route.js +1 -1
  83. package/.next/server/app/api/worktrees/route.js +1 -1
  84. package/.next/server/app/favicon.ico/route.js +1 -1
  85. package/.next/server/app/index.html +1 -1
  86. package/.next/server/app/index.rsc +5 -5
  87. package/.next/server/app/index.segments/__PAGE__.segment.rsc +5 -5
  88. package/.next/server/app/index.segments/_full.segment.rsc +5 -5
  89. package/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  90. package/.next/server/app/login/page.js +1 -1
  91. package/.next/server/app/login/page_client-reference-manifest.js +1 -1
  92. package/.next/server/app/login.html +1 -1
  93. package/.next/server/app/login.rsc +4 -4
  94. package/.next/server/app/login.segments/_full.segment.rsc +4 -4
  95. package/.next/server/app/login.segments/_tree.segment.rsc +2 -2
  96. package/.next/server/app/login.segments/login/__PAGE__.segment.rsc +4 -4
  97. package/.next/server/app/manifest.webmanifest/route.js +2 -2
  98. package/.next/server/app/page.js +20 -20
  99. package/.next/server/app/page_client-reference-manifest.js +1 -1
  100. package/.next/server/app-paths-manifest.json +13 -11
  101. package/.next/server/chunks/2243.js +1 -1
  102. package/.next/server/chunks/3573.js +1 -1
  103. package/.next/server/chunks/4353.js +1 -0
  104. package/.next/server/chunks/5582.js +2 -2
  105. package/.next/server/chunks/6429.js +1 -1
  106. package/.next/server/chunks/8410.js +1 -0
  107. package/.next/server/instrumentation.js +1 -1
  108. package/.next/server/instrumentation.js.nft.json +1 -1
  109. package/.next/server/middleware-build-manifest.js +1 -1
  110. package/.next/server/next-font-manifest.js +1 -1
  111. package/.next/server/next-font-manifest.json +1 -1
  112. package/.next/server/pages/404.html +1 -1
  113. package/.next/server/pages/500.html +1 -1
  114. package/.next/server/server-reference-manifest.json +1 -1
  115. package/.next/static/chunks/1278-c20177e2f0547fb0.js +1 -0
  116. package/.next/static/chunks/app/_global-error/page-0d0785de797ec9c7.js +1 -0
  117. package/.next/static/chunks/app/api/agent/[id]/bash-output/route-0d0785de797ec9c7.js +1 -0
  118. package/.next/static/chunks/app/api/agent/[id]/events/route-0d0785de797ec9c7.js +1 -0
  119. package/.next/static/chunks/app/api/agent/[id]/lease/route-0d0785de797ec9c7.js +1 -0
  120. package/.next/static/chunks/app/api/agent/[id]/route-0d0785de797ec9c7.js +1 -0
  121. package/.next/static/chunks/app/api/agent/new/route-0d0785de797ec9c7.js +1 -0
  122. package/.next/static/chunks/app/api/agent/running/route-0d0785de797ec9c7.js +1 -0
  123. package/.next/static/chunks/app/api/app-update/route-0d0785de797ec9c7.js +1 -0
  124. package/.next/static/chunks/app/api/archives/route-0d0785de797ec9c7.js +1 -0
  125. package/.next/static/chunks/app/api/archives/sessions/route-0d0785de797ec9c7.js +1 -0
  126. package/.next/static/chunks/app/api/auth/api-key/[provider]/route-0d0785de797ec9c7.js +1 -0
  127. package/.next/static/chunks/app/api/auth/login/[provider]/route-0d0785de797ec9c7.js +1 -0
  128. package/.next/static/chunks/app/api/auth/logout/[provider]/route-0d0785de797ec9c7.js +1 -0
  129. package/.next/static/chunks/app/api/auth/providers/route-0d0785de797ec9c7.js +1 -0
  130. package/.next/static/chunks/app/api/cwd/browse/route-0d0785de797ec9c7.js +1 -0
  131. package/.next/static/chunks/app/api/cwd/validate/route-0d0785de797ec9c7.js +1 -0
  132. package/.next/static/chunks/app/api/default-cwd/route-0d0785de797ec9c7.js +1 -0
  133. package/.next/static/chunks/app/api/file-index/route-0d0785de797ec9c7.js +1 -0
  134. package/.next/static/chunks/app/api/files/[...path]/route-0d0785de797ec9c7.js +1 -0
  135. package/.next/static/chunks/app/api/git/diff/route-0d0785de797ec9c7.js +1 -0
  136. package/.next/static/chunks/app/api/git/status/route-0d0785de797ec9c7.js +1 -0
  137. package/.next/static/chunks/app/api/home/route-0d0785de797ec9c7.js +1 -0
  138. package/.next/static/chunks/app/api/models/route-0d0785de797ec9c7.js +1 -0
  139. package/.next/static/chunks/app/api/models-config/catalog/route-0d0785de797ec9c7.js +1 -0
  140. package/.next/static/chunks/app/api/models-config/discover/route-0d0785de797ec9c7.js +1 -0
  141. package/.next/static/chunks/app/api/models-config/route-0d0785de797ec9c7.js +1 -0
  142. package/.next/static/chunks/app/api/models-config/test/route-0d0785de797ec9c7.js +1 -0
  143. package/.next/static/chunks/app/api/pins/route-0d0785de797ec9c7.js +1 -0
  144. package/.next/static/chunks/app/api/plugins/check/route-0d0785de797ec9c7.js +1 -0
  145. package/.next/static/chunks/app/api/plugins/route-0d0785de797ec9c7.js +1 -0
  146. package/.next/static/chunks/app/api/project-trust/route-0d0785de797ec9c7.js +1 -0
  147. package/.next/static/chunks/app/api/provider-usage/query/route-0d0785de797ec9c7.js +1 -0
  148. package/.next/static/chunks/app/api/push/config/route-0d0785de797ec9c7.js +1 -0
  149. package/.next/static/chunks/app/api/push/subscribe/route-0d0785de797ec9c7.js +1 -0
  150. package/.next/static/chunks/app/api/sessions/[id]/auto-name/route-0d0785de797ec9c7.js +1 -0
  151. package/.next/static/chunks/app/api/sessions/[id]/context/route-0d0785de797ec9c7.js +1 -0
  152. package/.next/static/chunks/app/api/sessions/[id]/entries/[entryId]/thinking/route-0d0785de797ec9c7.js +1 -0
  153. package/.next/static/chunks/app/api/sessions/[id]/entries/[entryId]/tool-result-image/route-0d0785de797ec9c7.js +1 -0
  154. package/.next/static/chunks/app/api/sessions/[id]/export/route-0d0785de797ec9c7.js +1 -0
  155. package/.next/static/chunks/app/api/sessions/[id]/route-0d0785de797ec9c7.js +1 -0
  156. package/.next/static/chunks/app/api/sessions/[id]/state/route-0d0785de797ec9c7.js +1 -0
  157. package/.next/static/chunks/app/api/sessions/route-0d0785de797ec9c7.js +1 -0
  158. package/.next/static/chunks/app/api/sessions/search/route-0d0785de797ec9c7.js +1 -0
  159. package/.next/static/chunks/app/api/skills/check/route-0d0785de797ec9c7.js +1 -0
  160. package/.next/static/chunks/app/api/skills/install/route-0d0785de797ec9c7.js +1 -0
  161. package/.next/static/chunks/app/api/skills/route-0d0785de797ec9c7.js +1 -0
  162. package/.next/static/chunks/app/api/skills/search/route-0d0785de797ec9c7.js +1 -0
  163. package/.next/static/chunks/app/api/skills/update/route-0d0785de797ec9c7.js +1 -0
  164. package/.next/static/chunks/app/api/subagents/[id]/route-0d0785de797ec9c7.js +1 -0
  165. package/.next/static/chunks/app/api/subagents/profiles/route-0d0785de797ec9c7.js +1 -0
  166. package/.next/static/chunks/app/api/subagents/settings/route-0d0785de797ec9c7.js +1 -0
  167. package/.next/static/chunks/app/api/terminal/[id]/events/route-0d0785de797ec9c7.js +1 -0
  168. package/.next/static/chunks/app/api/terminal/[id]/route-0d0785de797ec9c7.js +1 -0
  169. package/.next/static/chunks/app/api/terminal/route-0d0785de797ec9c7.js +1 -0
  170. package/.next/static/chunks/app/api/tools/settings/route-0d0785de797ec9c7.js +1 -0
  171. package/.next/static/chunks/app/api/web-auth/route-0d0785de797ec9c7.js +1 -0
  172. package/.next/static/chunks/app/api/worktrees/route-0d0785de797ec9c7.js +1 -0
  173. package/.next/static/chunks/app/{layout-5bc416fd5398564d.js → layout-d336308f5f5c4e97.js} +1 -1
  174. package/.next/static/chunks/app/manifest.webmanifest/route-0d0785de797ec9c7.js +1 -0
  175. package/.next/static/chunks/app/page-ebd11e43d32c7c7f.js +283 -0
  176. package/.next/static/chunks/next/dist/client/components/builtin/app-error-0d0785de797ec9c7.js +1 -0
  177. package/.next/static/chunks/next/dist/client/components/builtin/forbidden-0d0785de797ec9c7.js +1 -0
  178. package/.next/static/chunks/next/dist/client/components/builtin/not-found-0d0785de797ec9c7.js +1 -0
  179. package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-0d0785de797ec9c7.js +1 -0
  180. package/.next/static/css/{f4a799a04a7a8a76.css → ca4e6d06382119bd.css} +1 -1
  181. package/.next/static/qDrZc4StIk3gX1M8cE65k/_buildManifest.js +1 -0
  182. package/.next/trace +40 -41
  183. package/.next/trace-build +1 -1
  184. package/.next/types/app/api/archives/route.ts +353 -0
  185. package/.next/types/app/api/archives/sessions/route.ts +353 -0
  186. package/.next/types/routes.d.ts +3 -1
  187. package/.next/types/validator.ts +18 -0
  188. package/README.ja.md +7 -130
  189. package/README.md +51 -123
  190. package/README.ru.md +7 -130
  191. package/README.zh-CN.md +51 -77
  192. package/package.json +3 -3
  193. package/.next/server/chunks/2349.js +0 -1
  194. package/.next/static/8LHW2XYS_VC9FpfLDlmpF/_buildManifest.js +0 -1
  195. package/.next/static/chunks/1278-4e101e127edaae15.js +0 -1
  196. package/.next/static/chunks/app/_global-error/page-6f128c132ee86731.js +0 -1
  197. package/.next/static/chunks/app/api/agent/[id]/bash-output/route-6f128c132ee86731.js +0 -1
  198. package/.next/static/chunks/app/api/agent/[id]/events/route-6f128c132ee86731.js +0 -1
  199. package/.next/static/chunks/app/api/agent/[id]/lease/route-6f128c132ee86731.js +0 -1
  200. package/.next/static/chunks/app/api/agent/[id]/route-6f128c132ee86731.js +0 -1
  201. package/.next/static/chunks/app/api/agent/new/route-6f128c132ee86731.js +0 -1
  202. package/.next/static/chunks/app/api/agent/running/route-6f128c132ee86731.js +0 -1
  203. package/.next/static/chunks/app/api/app-update/route-6f128c132ee86731.js +0 -1
  204. package/.next/static/chunks/app/api/auth/api-key/[provider]/route-6f128c132ee86731.js +0 -1
  205. package/.next/static/chunks/app/api/auth/login/[provider]/route-6f128c132ee86731.js +0 -1
  206. package/.next/static/chunks/app/api/auth/logout/[provider]/route-6f128c132ee86731.js +0 -1
  207. package/.next/static/chunks/app/api/auth/providers/route-6f128c132ee86731.js +0 -1
  208. package/.next/static/chunks/app/api/cwd/browse/route-6f128c132ee86731.js +0 -1
  209. package/.next/static/chunks/app/api/cwd/validate/route-6f128c132ee86731.js +0 -1
  210. package/.next/static/chunks/app/api/default-cwd/route-6f128c132ee86731.js +0 -1
  211. package/.next/static/chunks/app/api/file-index/route-6f128c132ee86731.js +0 -1
  212. package/.next/static/chunks/app/api/files/[...path]/route-6f128c132ee86731.js +0 -1
  213. package/.next/static/chunks/app/api/git/diff/route-6f128c132ee86731.js +0 -1
  214. package/.next/static/chunks/app/api/git/status/route-6f128c132ee86731.js +0 -1
  215. package/.next/static/chunks/app/api/home/route-6f128c132ee86731.js +0 -1
  216. package/.next/static/chunks/app/api/models/route-6f128c132ee86731.js +0 -1
  217. package/.next/static/chunks/app/api/models-config/catalog/route-6f128c132ee86731.js +0 -1
  218. package/.next/static/chunks/app/api/models-config/discover/route-6f128c132ee86731.js +0 -1
  219. package/.next/static/chunks/app/api/models-config/route-6f128c132ee86731.js +0 -1
  220. package/.next/static/chunks/app/api/models-config/test/route-6f128c132ee86731.js +0 -1
  221. package/.next/static/chunks/app/api/pins/route-6f128c132ee86731.js +0 -1
  222. package/.next/static/chunks/app/api/plugins/check/route-6f128c132ee86731.js +0 -1
  223. package/.next/static/chunks/app/api/plugins/route-6f128c132ee86731.js +0 -1
  224. package/.next/static/chunks/app/api/project-trust/route-6f128c132ee86731.js +0 -1
  225. package/.next/static/chunks/app/api/provider-usage/query/route-6f128c132ee86731.js +0 -1
  226. package/.next/static/chunks/app/api/push/config/route-6f128c132ee86731.js +0 -1
  227. package/.next/static/chunks/app/api/push/subscribe/route-6f128c132ee86731.js +0 -1
  228. package/.next/static/chunks/app/api/sessions/[id]/auto-name/route-6f128c132ee86731.js +0 -1
  229. package/.next/static/chunks/app/api/sessions/[id]/context/route-6f128c132ee86731.js +0 -1
  230. package/.next/static/chunks/app/api/sessions/[id]/entries/[entryId]/thinking/route-6f128c132ee86731.js +0 -1
  231. package/.next/static/chunks/app/api/sessions/[id]/entries/[entryId]/tool-result-image/route-6f128c132ee86731.js +0 -1
  232. package/.next/static/chunks/app/api/sessions/[id]/export/route-6f128c132ee86731.js +0 -1
  233. package/.next/static/chunks/app/api/sessions/[id]/route-6f128c132ee86731.js +0 -1
  234. package/.next/static/chunks/app/api/sessions/[id]/state/route-6f128c132ee86731.js +0 -1
  235. package/.next/static/chunks/app/api/sessions/route-6f128c132ee86731.js +0 -1
  236. package/.next/static/chunks/app/api/sessions/search/route-6f128c132ee86731.js +0 -1
  237. package/.next/static/chunks/app/api/skills/check/route-6f128c132ee86731.js +0 -1
  238. package/.next/static/chunks/app/api/skills/install/route-6f128c132ee86731.js +0 -1
  239. package/.next/static/chunks/app/api/skills/route-6f128c132ee86731.js +0 -1
  240. package/.next/static/chunks/app/api/skills/search/route-6f128c132ee86731.js +0 -1
  241. package/.next/static/chunks/app/api/skills/update/route-6f128c132ee86731.js +0 -1
  242. package/.next/static/chunks/app/api/subagents/[id]/route-6f128c132ee86731.js +0 -1
  243. package/.next/static/chunks/app/api/subagents/profiles/route-6f128c132ee86731.js +0 -1
  244. package/.next/static/chunks/app/api/subagents/settings/route-6f128c132ee86731.js +0 -1
  245. package/.next/static/chunks/app/api/terminal/[id]/events/route-6f128c132ee86731.js +0 -1
  246. package/.next/static/chunks/app/api/terminal/[id]/route-6f128c132ee86731.js +0 -1
  247. package/.next/static/chunks/app/api/terminal/route-6f128c132ee86731.js +0 -1
  248. package/.next/static/chunks/app/api/tools/settings/route-6f128c132ee86731.js +0 -1
  249. package/.next/static/chunks/app/api/web-auth/route-6f128c132ee86731.js +0 -1
  250. package/.next/static/chunks/app/api/worktrees/route-6f128c132ee86731.js +0 -1
  251. package/.next/static/chunks/app/manifest.webmanifest/route-6f128c132ee86731.js +0 -1
  252. package/.next/static/chunks/app/page-904541ae65f082d4.js +0 -283
  253. package/.next/static/chunks/next/dist/client/components/builtin/app-error-6f128c132ee86731.js +0 -1
  254. package/.next/static/chunks/next/dist/client/components/builtin/forbidden-6f128c132ee86731.js +0 -1
  255. package/.next/static/chunks/next/dist/client/components/builtin/not-found-6f128c132ee86731.js +0 -1
  256. package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-6f128c132ee86731.js +0 -1
  257. /package/.next/static/{8LHW2XYS_VC9FpfLDlmpF → qDrZc4StIk3gX1M8cE65k}/_ssgManifest.js +0 -0
@@ -1 +1 @@
1
- (()=>{var a={};a.id=7483,a.ids=[7483],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},8102:(a,b,c)=>{"use strict";c.d(b,{$:()=>g});var d=c(55511),e=c(29021),f=c(33873);function g(a,b){let c=(0,f.dirname)(a),g=(0,f.join)(c,`.${(0,f.basename)(a)}-${(0,d.randomUUID)()}.tmp`),h=!1;try{(0,e.writeFileSync)(g,b,{encoding:"utf8",flag:"wx",mode:384,flush:!0}),(0,e.renameSync)(g,a)}catch(a){throw h=!0,a}finally{try{(0,e.unlinkSync)(g)}catch(a){if("ENOENT"!==a.code&&!h)throw a}}}},8128:a=>{"use strict";a.exports=require("next/dist/server/runtime-reacts.external.js")},10846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},17551:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{IX:()=>n,V6:()=>m});var e=c(73024),f=c(76760),g=c(75430),h=c(8102),i=c(28967),j=a([g]);g=(j.then?(await j)():j)[0];let o=["input","output","cacheRead","cacheWrite"];function k(a){return"object"==typeof a&&null!==a&&!Array.isArray(a)}function l(){return(0,f.join)((0,g.getAgentDir)(),"models.json")}function m(a=l()){if(!(0,e.existsSync)(a))return{providers:{}};try{return JSON.parse((0,e.readFileSync)(a,"utf8"))}catch{return{providers:{}}}}function n(a,b=l()){let c=(0,f.dirname)(b);(0,e.existsSync)(c)||(0,e.mkdirSync)(c,{recursive:!0});let d=function(a){let b=structuredClone(a);if(!k(b.providers))return b;for(let a of Object.values(b.providers))if(k(a)&&Array.isArray(a.models))for(let b of a.models){if(!k(b)||!("cost"in b))continue;let a=function(a){if(!k(a))return;let b=o.filter(b=>void 0!==a[b]);if(0!==b.length&&!b.some(b=>"number"!=typeof a[b]||!Number.isFinite(a[b])))return Object.fromEntries([...Object.entries(a),...o.map(b=>[b,a[b]??0])])}(b.cost);a?b.cost=a:delete b.cost}return b}(function(a){if(!k(a.providers))return a;let b=Object.fromEntries(Object.entries(a.providers).map(([a,b])=>{if(!k(b)||!Array.isArray(b.models))return[a,b];let c=b.models.filter(a=>!k(a)||"string"!=typeof a.id||a.id.trim().length>0);return[a,{...b,models:c}]}));return{...a,providers:b}}(a));(0,h.$)(b,JSON.stringify(d,null,2)),(0,i.kn)()}d()}catch(a){d(a)}})},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},28967:(a,b,c)=>{"use strict";function d(){return globalThis.__piModelsCacheState||(globalThis.__piModelsCacheState={entries:new Map,inFlight:new Map,generation:0}),globalThis.__piModelsCacheState}function e(){let a=d();a.generation+=1,a.entries.clear(),a.inFlight.clear()}function f(a,b){return b?{...a,modelError:b}:a}function g(a){return{...a,modelError:"Model list is temporarily unavailable. Check your configuration and try again."}}function h(a,b){let c=d(),e=c.entries.get(a);if(e){if(e.expiresAt>Date.now())return Promise.resolve(e.data);c.entries.delete(a)}let f=c.inFlight.get(a);if(f)return f;let g=c.generation,h=Promise.resolve().then(b).then(b=>{if(c.generation===g&&c.inFlight.get(a)===h){let d=Date.now();for(let[a,b]of c.entries)b.expiresAt<=d&&c.entries.delete(a);for(;c.entries.size>=32;){let a=c.entries.keys().next().value;if(void 0===a)break;c.entries.delete(a)}c.entries.set(a,{data:b,expiresAt:d+6e4})}return b}).finally(()=>{c.inFlight.get(a)===h&&c.inFlight.delete(a)});return c.inFlight.set(a,h),h}c.d(b,{Fw:()=>g,Mx:()=>f,kn:()=>e,rC:()=>h})},29021:a=>{"use strict";a.exports=require("fs")},29294:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},33873:a=>{"use strict";a.exports=require("path")},44870:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},53718:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.r(b),c.d(b,{GET:()=>h,PUT:()=>i,dynamic:()=>j});var e=c(23211),f=c(17551),g=a([f]);f=(g.then?(await g)():g)[0];let j="force-dynamic";async function h(){return e.NextResponse.json((0,f.V6)())}async function i(a){try{let b=await a.json();return(0,f.IX)(b),e.NextResponse.json({success:!0})}catch(a){return e.NextResponse.json({error:String(a)},{status:500})}}d()}catch(a){d(a)}})},55511:a=>{"use strict";a.exports=require("crypto")},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},73024:a=>{"use strict";a.exports=require("node:fs")},75430:a=>{"use strict";a.exports=import("@earendil-works/pi-coding-agent")},76760:a=>{"use strict";a.exports=require("node:path")},78335:()=>{},86439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},90271:(a,b,c)=>{"use strict";c.r(b),c.d(b,{handler:()=>z,patchFetch:()=>y,routeModule:()=>u,serverHooks:()=>x,workAsyncStorage:()=>v,workUnitAsyncStorage:()=>w});var d=c(19225),e=c(84006),f=c(8317),g=c(99373),h=c(34775),i=c(24235),j=c(261),k=c(54365),l=c(90771),m=c(73461),n=c(67798),o=c(92280),p=c(62018),q=c(45696),r=c(47929),s=c(86439),t=c(37527);let u=new d.AppRouteRouteModule({definition:{kind:e.RouteKind.APP_ROUTE,page:"/api/models-config/route",pathname:"/api/models-config",filename:"route",bundlePath:"app/api/models-config/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/home/runner/work/pi-web/pi-web/app/api/models-config/route.ts",nextConfigOutput:"",userland:()=>c(53718),...{}}),{workAsyncStorage:v,workUnitAsyncStorage:w,serverHooks:x}=u;function y(){return(0,f.patchFetch)({workAsyncStorage:v,workUnitAsyncStorage:w})}async function z(a,b,c){c.requestMeta&&(0,g.setRequestMeta)(a,c.requestMeta),u.isDev&&(0,g.addRequestMeta)(a,"devRequestTimingInternalsEnd",process.hrtime.bigint());let d="/api/models-config/route";"/index"===d&&(d="/");let f=await u.prepare(a,b,{srcPage:d,multiZoneDraftMode:!1});if(!f)return b.statusCode=400,b.end("Bad Request"),null==c.waitUntil||c.waitUntil.call(c,Promise.resolve()),null;let{buildId:v,deploymentId:w,params:x,nextConfig:y,parsedUrl:z,isDraftMode:A,prerenderManifest:B,routerServerContext:C,isOnDemandRevalidate:D,revalidateOnlyGenerated:E,resolvedPathname:F,clientReferenceManifest:G,serverActionsManifest:H}=f,I=(0,j.normalizeAppPath)(d),J=!!(B.dynamicRoutes[I]||B.routes[F]),K=async()=>((null==C?void 0:C.render404)?await C.render404(a,b,z,!1):b.end("This page could not be found"),null);if(J&&!A){let a=!!B.routes[F],b=B.dynamicRoutes[I];if(b&&!1===b.fallback&&!a){if(y.adapterPath)return await K();throw new s.NoFallbackError}}let L=null;!J||u.isDev||A||(L="/index"===(L=F)?"/":L);let M=!0===u.isDev||!J,N=J&&!M;H&&G&&(0,i.setManifestsSingleton)({page:d,clientReferenceManifest:G,serverActionsManifest:H});let O=a.method||"GET",P=(0,h.getTracer)(),Q=P.getActiveScopeSpan(),R=!!(null==C?void 0:C.isWrappedByNextServer),S=!!(0,g.getRequestMeta)(a,"minimalMode"),T=(0,g.getRequestMeta)(a,"incrementalCache")||await u.getIncrementalCache(a,y,B,S);null==T||T.resetRequestCache(),globalThis.__incrementalCache=T;let U={params:x,previewProps:B.preview,renderOpts:{experimental:{authInterrupts:!!y.experimental.authInterrupts,useCacheTimeout:y.experimental.useCacheTimeout},cacheComponents:!!y.cacheComponents,validationLevel:y.experimental.instantInsights.validationLevel,supportsDynamicResponse:M,incrementalCache:T,hmrRefreshHash:(0,g.getRequestMeta)(a,"hmrRefreshHash"),cacheLifeProfiles:y.cacheLife,staticPageGenerationTimeout:y.staticPageGenerationTimeout,waitUntil:c.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:void 0,onInstrumentationRequestError:(b,c,d,e)=>u.onRequestError(a,b,d,e,C)},sharedContext:{buildId:v,deploymentId:w}},V=new k.NodeNextRequest(a),W=new k.NodeNextResponse(b),X=l.NextRequestAdapter.fromNodeNextRequest(V,(0,l.signalFromNodeResponse)(b)),Y=async({previousCacheEntry:e})=>{try{if(!S&&D&&E&&!e)return b.statusCode=404,b.setHeader("x-nextjs-cache","REVALIDATED"),b.end("This page could not be found"),null;let d=await u.handle(X,U);a.fetchMetrics=U.renderOpts.fetchMetrics;let f=U.renderOpts.pendingWaitUntil;f&&c.waitUntil&&(c.waitUntil(f),f=void 0);let g=U.renderOpts.collectedTags;if(!J)return await (0,o.I)(V,W,d,f),null;{let a=await d.blob(),b=(0,p.toNodeOutgoingHttpHeaders)(d.headers);g&&(b[r.NEXT_CACHE_TAGS_HEADER]=g),!b["content-type"]&&a.type&&(b["content-type"]=a.type);let c=void 0!==U.renderOpts.collectedRevalidate&&!(U.renderOpts.collectedRevalidate>=r.INFINITE_CACHE)&&U.renderOpts.collectedRevalidate,e=void 0===U.renderOpts.collectedExpire||U.renderOpts.collectedExpire>=r.INFINITE_CACHE?!1!==c&&c>0?y.expireTime:void 0:U.renderOpts.collectedExpire;return{value:{kind:t.CachedRouteKind.APP_ROUTE,status:d.status,body:Buffer.from(await a.arrayBuffer()),headers:b},cacheControl:{revalidate:c,expire:e}}}}catch(b){throw(null==e?void 0:e.isStale)&&await u.onRequestError(a,b,{routerKind:"App Router",routePath:d,routeType:"route",revalidateReason:(0,n.getRevalidateReason)({isStaticGeneration:N,isOnDemandRevalidate:D})},!1,C),b}},Z=async(d,f)=>{try{var g,i;let d=await u.handleResponse({req:a,nextConfig:y,cacheKey:L,routeKind:e.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:B,isRoutePPREnabled:!1,isOnDemandRevalidate:D,revalidateOnlyGenerated:E,responseGenerator:Y,waitUntil:c.waitUntil,isMinimalMode:S});if(!J)return;if((null==d||null==(g=d.value)?void 0:g.kind)!==t.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==d||null==(i=d.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});S||b.setHeader("x-nextjs-cache",D?"REVALIDATED":d.isMiss?"MISS":d.isStale?"STALE":"HIT"),A&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let f=(0,p.fromNodeOutgoingHttpHeaders)(d.value.headers);S&&J||f.delete(r.NEXT_CACHE_TAGS_HEADER),!d.cacheControl||b.getHeader("Cache-Control")||f.get("Cache-Control")||f.set("Cache-Control",(0,q.getCacheControlHeader)(d.cacheControl)),await (0,o.I)(V,W,new Response(d.value.body,{headers:f,status:d.value.status||200}));return}catch(b){if(b instanceof s.NoFallbackError||await u.onRequestError(a,b,{routerKind:"App Router",routePath:I,routeType:"route",revalidateReason:(0,n.getRevalidateReason)({isStaticGeneration:N,isOnDemandRevalidate:D})},!1,C),J)throw b;await (0,o.I)(V,W,new Response(null,{status:500}));return}finally{(()=>{if(!d)return;let a=b.statusCode;d.setAttributes({"http.status_code":a,"next.rsc":!1}),a&&a>=500&&(d.setStatus({code:h.SpanStatusCode.ERROR}),d.setAttribute("error.type",a.toString()));let c=P.getRootSpanAttributes();if(!c)return;if(c.get("next.span_type")!==m.BaseServerSpan.handleRequest)return console.warn(`Unexpected root span type '${c.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let e=c.get("next.route")||I,g=`${O} ${e}`;d.setAttributes({"next.route":e,"http.route":e,"next.span_name":g}),d.updateName(g),f&&f!==d&&(f.setAttribute("http.route",e),f.updateName(g))})()}};if(R&&Q)await Z(Q,void 0);else{let b=P.getActiveScopeSpan();await P.withPropagatedContext(a.headers,()=>P.trace(m.BaseServerSpan.handleRequest,{spanName:`${O} ${d}`,kind:h.SpanKind.SERVER,attributes:{"http.method":O,"http.target":a.url}},a=>Z(a,b)),void 0,!R)}}},96487:()=>{}};var b=require("../../../webpack-runtime.js");b.C(a);var c=b.X(0,[4741,1813],()=>b(b.s=90271));module.exports=c})();
1
+ (()=>{var a={};a.id=7483,a.ids=[7483],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},8102:(a,b,c)=>{"use strict";c.d(b,{$:()=>g});var d=c(55511),e=c(29021),f=c(33873);function g(a,b){let c=(0,f.dirname)(a),g=(0,f.join)(c,`.${(0,f.basename)(a)}-${(0,d.randomUUID)()}.tmp`),h=!1;try{(0,e.writeFileSync)(g,b,{encoding:"utf8",flag:"wx",mode:384,flush:!0}),(0,e.renameSync)(g,a)}catch(a){throw h=!0,a}finally{try{(0,e.unlinkSync)(g)}catch(a){if("ENOENT"!==a.code&&!h)throw a}}}},8128:a=>{"use strict";a.exports=require("next/dist/server/runtime-reacts.external.js")},10846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},17551:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{IX:()=>n,V6:()=>m});var e=c(73024),f=c(76760),g=c(75430),h=c(8102),i=c(28967),j=a([g]);g=(j.then?(await j)():j)[0];let o=["input","output","cacheRead","cacheWrite"];function k(a){return"object"==typeof a&&null!==a&&!Array.isArray(a)}function l(){return(0,f.join)((0,g.getAgentDir)(),"models.json")}function m(a=l()){if(!(0,e.existsSync)(a))return{providers:{}};try{return JSON.parse((0,e.readFileSync)(a,"utf8"))}catch{return{providers:{}}}}function n(a,b=l()){let c=(0,f.dirname)(b);(0,e.existsSync)(c)||(0,e.mkdirSync)(c,{recursive:!0});let d=function(a){let b=structuredClone(a);if(!k(b.providers))return b;for(let a of Object.values(b.providers))if(k(a)&&Array.isArray(a.models))for(let b of a.models){if(!k(b)||!("cost"in b))continue;let a=function(a){if(!k(a))return;let b=o.filter(b=>void 0!==a[b]);if(0!==b.length&&!b.some(b=>"number"!=typeof a[b]||!Number.isFinite(a[b])))return Object.fromEntries([...Object.entries(a),...o.map(b=>[b,a[b]??0])])}(b.cost);a?b.cost=a:delete b.cost}return b}(function(a){if(!k(a.providers))return a;let b=Object.fromEntries(Object.entries(a.providers).map(([a,b])=>{if(!k(b)||!Array.isArray(b.models))return[a,b];let c=b.models.filter(a=>!k(a)||"string"!=typeof a.id||a.id.trim().length>0);return[a,{...b,models:c}]}));return{...a,providers:b}}(a));(0,h.$)(b,JSON.stringify(d,null,2)),(0,i.kn)()}d()}catch(a){d(a)}})},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},28967:(a,b,c)=>{"use strict";function d(){return globalThis.__piModelsCacheState||(globalThis.__piModelsCacheState={entries:new Map,inFlight:new Map,generation:0}),globalThis.__piModelsCacheState}function e(){let a=d();a.generation+=1,a.entries.clear(),a.inFlight.clear()}function f(a,b){return b?{...a,modelError:b}:a}function g(a){return{...a,modelError:"Model list is temporarily unavailable. Check your configuration and try again."}}function h(a,b){let c=d(),e=c.entries.get(a);if(e){if(e.expiresAt>Date.now())return Promise.resolve(e.data);c.entries.delete(a)}let f=c.inFlight.get(a);if(f)return f;let g=c.generation,h=Promise.resolve().then(b).then(b=>{if(c.generation===g&&c.inFlight.get(a)===h){let d=Date.now();for(let[a,b]of c.entries)b.expiresAt<=d&&c.entries.delete(a);for(;c.entries.size>=32;){let a=c.entries.keys().next().value;if(void 0===a)break;c.entries.delete(a)}c.entries.set(a,{data:b,expiresAt:d+6e4})}return b}).finally(()=>{c.inFlight.get(a)===h&&c.inFlight.delete(a)});return c.inFlight.set(a,h),h}c.d(b,{Fw:()=>g,Mx:()=>f,kn:()=>e,rC:()=>h})},29021:a=>{"use strict";a.exports=require("fs")},29294:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},33873:a=>{"use strict";a.exports=require("path")},44870:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},53718:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.r(b),c.d(b,{GET:()=>h,PUT:()=>i,dynamic:()=>j});var e=c(23211),f=c(17551),g=a([f]);f=(g.then?(await g)():g)[0];let j="force-dynamic";async function h(){return e.NextResponse.json((0,f.V6)())}async function i(a){try{let b=await a.json();return(0,f.IX)(b),e.NextResponse.json({success:!0})}catch(a){return e.NextResponse.json({error:String(a)},{status:500})}}d()}catch(a){d(a)}})},55511:a=>{"use strict";a.exports=require("crypto")},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},73024:a=>{"use strict";a.exports=require("node:fs")},75430:a=>{"use strict";a.exports=import("@earendil-works/pi-coding-agent")},76760:a=>{"use strict";a.exports=require("node:path")},78335:()=>{},86439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},93191:(a,b,c)=>{"use strict";c.r(b),c.d(b,{handler:()=>z,patchFetch:()=>y,routeModule:()=>u,serverHooks:()=>x,workAsyncStorage:()=>v,workUnitAsyncStorage:()=>w});var d=c(19225),e=c(84006),f=c(8317),g=c(99373),h=c(34775),i=c(24235),j=c(261),k=c(54365),l=c(90771),m=c(73461),n=c(67798),o=c(92280),p=c(62018),q=c(45696),r=c(47929),s=c(86439),t=c(37527);let u=new d.AppRouteRouteModule({definition:{kind:e.RouteKind.APP_ROUTE,page:"/api/models-config/route",pathname:"/api/models-config",filename:"route",bundlePath:"app/api/models-config/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/home/runner/work/pi-web/pi-web/app/api/models-config/route.ts",nextConfigOutput:"",userland:()=>c(53718),...{}}),{workAsyncStorage:v,workUnitAsyncStorage:w,serverHooks:x}=u;function y(){return(0,f.patchFetch)({workAsyncStorage:v,workUnitAsyncStorage:w})}async function z(a,b,c){c.requestMeta&&(0,g.setRequestMeta)(a,c.requestMeta),u.isDev&&(0,g.addRequestMeta)(a,"devRequestTimingInternalsEnd",process.hrtime.bigint());let d="/api/models-config/route";"/index"===d&&(d="/");let f=await u.prepare(a,b,{srcPage:d,multiZoneDraftMode:!1});if(!f)return b.statusCode=400,b.end("Bad Request"),null==c.waitUntil||c.waitUntil.call(c,Promise.resolve()),null;let{buildId:v,deploymentId:w,params:x,nextConfig:y,parsedUrl:z,isDraftMode:A,prerenderManifest:B,routerServerContext:C,isOnDemandRevalidate:D,revalidateOnlyGenerated:E,resolvedPathname:F,clientReferenceManifest:G,serverActionsManifest:H}=f,I=(0,j.normalizeAppPath)(d),J=!!(B.dynamicRoutes[I]||B.routes[F]),K=async()=>((null==C?void 0:C.render404)?await C.render404(a,b,z,!1):b.end("This page could not be found"),null);if(J&&!A){let a=!!B.routes[F],b=B.dynamicRoutes[I];if(b&&!1===b.fallback&&!a){if(y.adapterPath)return await K();throw new s.NoFallbackError}}let L=null;!J||u.isDev||A||(L="/index"===(L=F)?"/":L);let M=!0===u.isDev||!J,N=J&&!M;H&&G&&(0,i.setManifestsSingleton)({page:d,clientReferenceManifest:G,serverActionsManifest:H});let O=a.method||"GET",P=(0,h.getTracer)(),Q=P.getActiveScopeSpan(),R=!!(null==C?void 0:C.isWrappedByNextServer),S=!!(0,g.getRequestMeta)(a,"minimalMode"),T=(0,g.getRequestMeta)(a,"incrementalCache")||await u.getIncrementalCache(a,y,B,S);null==T||T.resetRequestCache(),globalThis.__incrementalCache=T;let U={params:x,previewProps:B.preview,renderOpts:{experimental:{authInterrupts:!!y.experimental.authInterrupts,useCacheTimeout:y.experimental.useCacheTimeout},cacheComponents:!!y.cacheComponents,validationLevel:y.experimental.instantInsights.validationLevel,supportsDynamicResponse:M,incrementalCache:T,hmrRefreshHash:(0,g.getRequestMeta)(a,"hmrRefreshHash"),cacheLifeProfiles:y.cacheLife,staticPageGenerationTimeout:y.staticPageGenerationTimeout,waitUntil:c.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:void 0,onInstrumentationRequestError:(b,c,d,e)=>u.onRequestError(a,b,d,e,C)},sharedContext:{buildId:v,deploymentId:w}},V=new k.NodeNextRequest(a),W=new k.NodeNextResponse(b),X=l.NextRequestAdapter.fromNodeNextRequest(V,(0,l.signalFromNodeResponse)(b)),Y=async({previousCacheEntry:e})=>{try{if(!S&&D&&E&&!e)return b.statusCode=404,b.setHeader("x-nextjs-cache","REVALIDATED"),b.end("This page could not be found"),null;let d=await u.handle(X,U);a.fetchMetrics=U.renderOpts.fetchMetrics;let f=U.renderOpts.pendingWaitUntil;f&&c.waitUntil&&(c.waitUntil(f),f=void 0);let g=U.renderOpts.collectedTags;if(!J)return await (0,o.I)(V,W,d,f),null;{let a=await d.blob(),b=(0,p.toNodeOutgoingHttpHeaders)(d.headers);g&&(b[r.NEXT_CACHE_TAGS_HEADER]=g),!b["content-type"]&&a.type&&(b["content-type"]=a.type);let c=void 0!==U.renderOpts.collectedRevalidate&&!(U.renderOpts.collectedRevalidate>=r.INFINITE_CACHE)&&U.renderOpts.collectedRevalidate,e=void 0===U.renderOpts.collectedExpire||U.renderOpts.collectedExpire>=r.INFINITE_CACHE?!1!==c&&c>0?y.expireTime:void 0:U.renderOpts.collectedExpire;return{value:{kind:t.CachedRouteKind.APP_ROUTE,status:d.status,body:Buffer.from(await a.arrayBuffer()),headers:b},cacheControl:{revalidate:c,expire:e}}}}catch(b){throw(null==e?void 0:e.isStale)&&await u.onRequestError(a,b,{routerKind:"App Router",routePath:d,routeType:"route",revalidateReason:(0,n.getRevalidateReason)({isStaticGeneration:N,isOnDemandRevalidate:D})},!1,C),b}},Z=async(d,f)=>{try{var g,i;let d=await u.handleResponse({req:a,nextConfig:y,cacheKey:L,routeKind:e.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:B,isRoutePPREnabled:!1,isOnDemandRevalidate:D,revalidateOnlyGenerated:E,responseGenerator:Y,waitUntil:c.waitUntil,isMinimalMode:S});if(!J)return;if((null==d||null==(g=d.value)?void 0:g.kind)!==t.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==d||null==(i=d.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});S||b.setHeader("x-nextjs-cache",D?"REVALIDATED":d.isMiss?"MISS":d.isStale?"STALE":"HIT"),A&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let f=(0,p.fromNodeOutgoingHttpHeaders)(d.value.headers);S&&J||f.delete(r.NEXT_CACHE_TAGS_HEADER),!d.cacheControl||b.getHeader("Cache-Control")||f.get("Cache-Control")||f.set("Cache-Control",(0,q.getCacheControlHeader)(d.cacheControl)),await (0,o.I)(V,W,new Response(d.value.body,{headers:f,status:d.value.status||200}));return}catch(b){if(b instanceof s.NoFallbackError||await u.onRequestError(a,b,{routerKind:"App Router",routePath:I,routeType:"route",revalidateReason:(0,n.getRevalidateReason)({isStaticGeneration:N,isOnDemandRevalidate:D})},!1,C),J)throw b;await (0,o.I)(V,W,new Response(null,{status:500}));return}finally{(()=>{if(!d)return;let a=b.statusCode;d.setAttributes({"http.status_code":a,"next.rsc":!1}),a&&a>=500&&(d.setStatus({code:h.SpanStatusCode.ERROR}),d.setAttribute("error.type",a.toString()));let c=P.getRootSpanAttributes();if(!c)return;if(c.get("next.span_type")!==m.BaseServerSpan.handleRequest)return console.warn(`Unexpected root span type '${c.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let e=c.get("next.route")||I,g=`${O} ${e}`;d.setAttributes({"next.route":e,"http.route":e,"next.span_name":g}),d.updateName(g),f&&f!==d&&(f.setAttribute("http.route",e),f.updateName(g))})()}};if(R&&Q)await Z(Q,void 0);else{let b=P.getActiveScopeSpan();await P.withPropagatedContext(a.headers,()=>P.trace(m.BaseServerSpan.handleRequest,{spanName:`${O} ${d}`,kind:h.SpanKind.SERVER,attributes:{"http.method":O,"http.target":a.url}},a=>Z(a,b)),void 0,!R)}}},96487:()=>{}};var b=require("../../../webpack-runtime.js");b.C(a);var c=b.X(0,[4741,1813],()=>b(b.s=93191));module.exports=c})();
@@ -1 +1 @@
1
- (()=>{var a={};a.id=8658,a.ids=[8658],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},8128:a=>{"use strict";a.exports=require("next/dist/server/runtime-reacts.external.js")},10846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},12773:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.r(b),c.d(b,{POST:()=>n,dynamic:()=>o});var e=c(23211),f=c(29021),g=c(21820),h=c(33873),i=c(19821),j=c(75430),k=c(66544),l=a([i,j]);[i,j]=l.then?(await l)():l;let o="force-dynamic";function m(a){return"object"==typeof a&&null!==a&&!Array.isArray(a)}async function n(a){let b;if(!(0,k.EN)(a))return e.NextResponse.json({ok:!1,error:"Untrusted API request"},{status:403});if(!(0,k.E2)(a))return e.NextResponse.json({ok:!1,error:"Content-Type must be application/json"},{status:415});try{let c,d=await a.json(),k="string"==typeof d.providerName?d.providerName.trim():"";if(!k)return e.NextResponse.json({ok:!1,error:"providerName is required"},{status:400});if(!m(d.provider))return e.NextResponse.json({ok:!1,error:"provider is required"},{status:400});if(!m(d.model))return e.NextResponse.json({ok:!1,error:"model is required"},{status:400});let l="string"==typeof d.model.id?d.model.id.trim():"";if(!l)return e.NextResponse.json({ok:!1,error:"Model ID is required"},{status:400});b=(0,f.mkdtempSync)((0,h.join)((0,g.tmpdir)(),"pi-web-model-test-"));let n=(0,h.join)(b,"models.json");(0,f.writeFileSync)(n,JSON.stringify({providers:{[k]:{...d.provider,models:[{...d.model,id:l}]}}},null,2),"utf8");let o=await j.ModelRuntime.create({modelsPath:n}),p=o.getError();if(p)return e.NextResponse.json({ok:!1,error:p});let q=o.getModel(k,l);if(!q)return e.NextResponse.json({ok:!1,error:`Model not found: ${k}/${l}`});let r=await o.getAuth(q);if(!r?.auth.apiKey)return e.NextResponse.json({ok:!1,error:`No API key found for "${k}"`});let s=new AbortController,t=setTimeout(()=>s.abort(),2e4),u=Date.now();try{let a=await (0,i.completeSimple)(q,{messages:[{role:"user",content:"Reply with OK only.",timestamp:Date.now()}]},{apiKey:r.auth.apiKey,headers:r.auth.headers,maxTokens:16,timeoutMs:2e4,maxRetries:0,cacheRetention:"none",signal:s.signal,onResponse:a=>{c=a.status}}),b=Date.now()-u;if("error"===a.stopReason||"aborted"===a.stopReason)return e.NextResponse.json({ok:!1,error:a.errorMessage??(s.signal.aborted?"Test timed out":"Model returned an error"),latencyMs:b,status:c});return e.NextResponse.json({ok:!0,latencyMs:b,status:c,responseText:a.content.filter(a=>"text"===a.type).map(a=>a.text).join("").slice(0,300)})}finally{clearTimeout(t)}}catch(a){return e.NextResponse.json({ok:!1,error:a instanceof Error?a.message:String(a)},{status:500})}finally{b&&(0,f.rmSync)(b,{recursive:!0,force:!0})}}d()}catch(a){d(a)}})},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},19821:a=>{"use strict";a.exports=import("@earendil-works/pi-ai/compat")},21820:a=>{"use strict";a.exports=require("os")},29021:a=>{"use strict";a.exports=require("fs")},29294:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},33873:a=>{"use strict";a.exports=require("path")},44870:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},51749:(a,b,c)=>{"use strict";c.r(b),c.d(b,{handler:()=>z,patchFetch:()=>y,routeModule:()=>u,serverHooks:()=>x,workAsyncStorage:()=>v,workUnitAsyncStorage:()=>w});var d=c(19225),e=c(84006),f=c(8317),g=c(99373),h=c(34775),i=c(24235),j=c(261),k=c(54365),l=c(90771),m=c(73461),n=c(67798),o=c(92280),p=c(62018),q=c(45696),r=c(47929),s=c(86439),t=c(37527);let u=new d.AppRouteRouteModule({definition:{kind:e.RouteKind.APP_ROUTE,page:"/api/models-config/test/route",pathname:"/api/models-config/test",filename:"route",bundlePath:"app/api/models-config/test/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/home/runner/work/pi-web/pi-web/app/api/models-config/test/route.ts",nextConfigOutput:"",userland:()=>c(12773),...{}}),{workAsyncStorage:v,workUnitAsyncStorage:w,serverHooks:x}=u;function y(){return(0,f.patchFetch)({workAsyncStorage:v,workUnitAsyncStorage:w})}async function z(a,b,c){c.requestMeta&&(0,g.setRequestMeta)(a,c.requestMeta),u.isDev&&(0,g.addRequestMeta)(a,"devRequestTimingInternalsEnd",process.hrtime.bigint());let d="/api/models-config/test/route";"/index"===d&&(d="/");let f=await u.prepare(a,b,{srcPage:d,multiZoneDraftMode:!1});if(!f)return b.statusCode=400,b.end("Bad Request"),null==c.waitUntil||c.waitUntil.call(c,Promise.resolve()),null;let{buildId:v,deploymentId:w,params:x,nextConfig:y,parsedUrl:z,isDraftMode:A,prerenderManifest:B,routerServerContext:C,isOnDemandRevalidate:D,revalidateOnlyGenerated:E,resolvedPathname:F,clientReferenceManifest:G,serverActionsManifest:H}=f,I=(0,j.normalizeAppPath)(d),J=!!(B.dynamicRoutes[I]||B.routes[F]),K=async()=>((null==C?void 0:C.render404)?await C.render404(a,b,z,!1):b.end("This page could not be found"),null);if(J&&!A){let a=!!B.routes[F],b=B.dynamicRoutes[I];if(b&&!1===b.fallback&&!a){if(y.adapterPath)return await K();throw new s.NoFallbackError}}let L=null;!J||u.isDev||A||(L="/index"===(L=F)?"/":L);let M=!0===u.isDev||!J,N=J&&!M;H&&G&&(0,i.setManifestsSingleton)({page:d,clientReferenceManifest:G,serverActionsManifest:H});let O=a.method||"GET",P=(0,h.getTracer)(),Q=P.getActiveScopeSpan(),R=!!(null==C?void 0:C.isWrappedByNextServer),S=!!(0,g.getRequestMeta)(a,"minimalMode"),T=(0,g.getRequestMeta)(a,"incrementalCache")||await u.getIncrementalCache(a,y,B,S);null==T||T.resetRequestCache(),globalThis.__incrementalCache=T;let U={params:x,previewProps:B.preview,renderOpts:{experimental:{authInterrupts:!!y.experimental.authInterrupts,useCacheTimeout:y.experimental.useCacheTimeout},cacheComponents:!!y.cacheComponents,validationLevel:y.experimental.instantInsights.validationLevel,supportsDynamicResponse:M,incrementalCache:T,hmrRefreshHash:(0,g.getRequestMeta)(a,"hmrRefreshHash"),cacheLifeProfiles:y.cacheLife,staticPageGenerationTimeout:y.staticPageGenerationTimeout,waitUntil:c.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:void 0,onInstrumentationRequestError:(b,c,d,e)=>u.onRequestError(a,b,d,e,C)},sharedContext:{buildId:v,deploymentId:w}},V=new k.NodeNextRequest(a),W=new k.NodeNextResponse(b),X=l.NextRequestAdapter.fromNodeNextRequest(V,(0,l.signalFromNodeResponse)(b)),Y=async({previousCacheEntry:e})=>{try{if(!S&&D&&E&&!e)return b.statusCode=404,b.setHeader("x-nextjs-cache","REVALIDATED"),b.end("This page could not be found"),null;let d=await u.handle(X,U);a.fetchMetrics=U.renderOpts.fetchMetrics;let f=U.renderOpts.pendingWaitUntil;f&&c.waitUntil&&(c.waitUntil(f),f=void 0);let g=U.renderOpts.collectedTags;if(!J)return await (0,o.I)(V,W,d,f),null;{let a=await d.blob(),b=(0,p.toNodeOutgoingHttpHeaders)(d.headers);g&&(b[r.NEXT_CACHE_TAGS_HEADER]=g),!b["content-type"]&&a.type&&(b["content-type"]=a.type);let c=void 0!==U.renderOpts.collectedRevalidate&&!(U.renderOpts.collectedRevalidate>=r.INFINITE_CACHE)&&U.renderOpts.collectedRevalidate,e=void 0===U.renderOpts.collectedExpire||U.renderOpts.collectedExpire>=r.INFINITE_CACHE?!1!==c&&c>0?y.expireTime:void 0:U.renderOpts.collectedExpire;return{value:{kind:t.CachedRouteKind.APP_ROUTE,status:d.status,body:Buffer.from(await a.arrayBuffer()),headers:b},cacheControl:{revalidate:c,expire:e}}}}catch(b){throw(null==e?void 0:e.isStale)&&await u.onRequestError(a,b,{routerKind:"App Router",routePath:d,routeType:"route",revalidateReason:(0,n.getRevalidateReason)({isStaticGeneration:N,isOnDemandRevalidate:D})},!1,C),b}},Z=async(d,f)=>{try{var g,i;let d=await u.handleResponse({req:a,nextConfig:y,cacheKey:L,routeKind:e.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:B,isRoutePPREnabled:!1,isOnDemandRevalidate:D,revalidateOnlyGenerated:E,responseGenerator:Y,waitUntil:c.waitUntil,isMinimalMode:S});if(!J)return;if((null==d||null==(g=d.value)?void 0:g.kind)!==t.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==d||null==(i=d.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});S||b.setHeader("x-nextjs-cache",D?"REVALIDATED":d.isMiss?"MISS":d.isStale?"STALE":"HIT"),A&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let f=(0,p.fromNodeOutgoingHttpHeaders)(d.value.headers);S&&J||f.delete(r.NEXT_CACHE_TAGS_HEADER),!d.cacheControl||b.getHeader("Cache-Control")||f.get("Cache-Control")||f.set("Cache-Control",(0,q.getCacheControlHeader)(d.cacheControl)),await (0,o.I)(V,W,new Response(d.value.body,{headers:f,status:d.value.status||200}));return}catch(b){if(b instanceof s.NoFallbackError||await u.onRequestError(a,b,{routerKind:"App Router",routePath:I,routeType:"route",revalidateReason:(0,n.getRevalidateReason)({isStaticGeneration:N,isOnDemandRevalidate:D})},!1,C),J)throw b;await (0,o.I)(V,W,new Response(null,{status:500}));return}finally{(()=>{if(!d)return;let a=b.statusCode;d.setAttributes({"http.status_code":a,"next.rsc":!1}),a&&a>=500&&(d.setStatus({code:h.SpanStatusCode.ERROR}),d.setAttribute("error.type",a.toString()));let c=P.getRootSpanAttributes();if(!c)return;if(c.get("next.span_type")!==m.BaseServerSpan.handleRequest)return console.warn(`Unexpected root span type '${c.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let e=c.get("next.route")||I,g=`${O} ${e}`;d.setAttributes({"next.route":e,"http.route":e,"next.span_name":g}),d.updateName(g),f&&f!==d&&(f.setAttribute("http.route",e),f.updateName(g))})()}};if(R&&Q)await Z(Q,void 0);else{let b=P.getActiveScopeSpan();await P.withPropagatedContext(a.headers,()=>P.trace(m.BaseServerSpan.handleRequest,{spanName:`${O} ${d}`,kind:h.SpanKind.SERVER,attributes:{"http.method":O,"http.target":a.url}},a=>Z(a,b)),void 0,!R)}}},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},66544:(a,b,c)=>{"use strict";c.d(b,{E2:()=>k,EN:()=>j});var d=c(77030);function e(a){return(a.startsWith("[")&&a.endsWith("]")?a.slice(1,-1):a).toLowerCase().replace(/\.$/,"")}function f(a){if(!a||/[\s/@\\]/.test(a))return null;try{let b=new URL(`http://${a}`);if(b.username||b.password||"/"!==b.pathname||b.search||b.hash)return null;return e(b.hostname)}catch{return null}}function g(a){if(!a||/[\s/@\\]/.test(a))return null;try{let b=new URL(`http://${a}`);if(b.username||b.password||"/"!==b.pathname||b.search||b.hash)return null;let c=e(b.hostname);return b.port?`${c}:${b.port}`:c}catch{return null}}function h(){return[process.env.PI_WEB_HOSTNAME,...process.env.PI_WEB_ALLOWED_HOSTS?.split(",")??[]].filter(a=>!!a?.trim())}function i(a){try{return new URL(a).origin}catch{return null}}function j(a,b=h()){return!!function(a,b=h()){let c=a.headers.get("host"),g=c?f(c):null;return!!g&&(!!("localhost"===g||g.endsWith(".localhost")||(0,d.isIP)(g))||b.some(a=>{let b;return((b=a?.trim())?(0,d.isIP)(b)?e(b):f(b):null)===g}))}(a,b)&&(!!function(a){if("GET"!==a.method||"navigate"!==a.headers.get("sec-fetch-mode")||"document"!==a.headers.get("sec-fetch-dest")||"?1"!==a.headers.get("sec-fetch-user"))return!1;try{return/^\/api\/sessions\/[^/]+\/export$/.test(new URL(a.url).pathname)}catch{return!1}}(a)||!(a.headers.has("origin")||a.headers.has("sec-fetch-site"))||function(a){let b,c,d,e=a.headers.get("origin");if("cross-site"===a.headers.get("sec-fetch-site"))return!1;if(!e)return!0;let f=(b=new URL(a.url),(c=a.headers.get("host"))?i(`${b.protocol}//${c}`):null);if(null!==f&&i(e)===f)return!0;if("same-origin"!==a.headers.get("sec-fetch-site")||!a.headers.get("x-forwarded-proto"))return!1;let h=a.headers.get("host");if(!h)return!1;try{d=new URL(e).host}catch{return!1}let j=g(d);return null!==j&&j===g(h)}(a))}function k(a){let b=a.headers.get("content-type")?.split(";",1)[0]?.trim().toLowerCase();return"application/json"===b||!!(b?.startsWith("application/")&&b.endsWith("+json"))}},75430:a=>{"use strict";a.exports=import("@earendil-works/pi-coding-agent")},77030:a=>{"use strict";a.exports=require("node:net")},78335:()=>{},86439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},96487:()=>{}};var b=require("../../../../webpack-runtime.js");b.C(a);var c=b.X(0,[4741,1813],()=>b(b.s=51749));module.exports=c})();
1
+ (()=>{var a={};a.id=8658,a.ids=[8658],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},8128:a=>{"use strict";a.exports=require("next/dist/server/runtime-reacts.external.js")},10846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},12773:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.r(b),c.d(b,{POST:()=>n,dynamic:()=>o});var e=c(23211),f=c(29021),g=c(21820),h=c(33873),i=c(19821),j=c(75430),k=c(66544),l=a([i,j]);[i,j]=l.then?(await l)():l;let o="force-dynamic";function m(a){return"object"==typeof a&&null!==a&&!Array.isArray(a)}async function n(a){let b;if(!(0,k.EN)(a))return e.NextResponse.json({ok:!1,error:"Untrusted API request"},{status:403});if(!(0,k.E2)(a))return e.NextResponse.json({ok:!1,error:"Content-Type must be application/json"},{status:415});try{let c,d=await a.json(),k="string"==typeof d.providerName?d.providerName.trim():"";if(!k)return e.NextResponse.json({ok:!1,error:"providerName is required"},{status:400});if(!m(d.provider))return e.NextResponse.json({ok:!1,error:"provider is required"},{status:400});if(!m(d.model))return e.NextResponse.json({ok:!1,error:"model is required"},{status:400});let l="string"==typeof d.model.id?d.model.id.trim():"";if(!l)return e.NextResponse.json({ok:!1,error:"Model ID is required"},{status:400});b=(0,f.mkdtempSync)((0,h.join)((0,g.tmpdir)(),"pi-web-model-test-"));let n=(0,h.join)(b,"models.json");(0,f.writeFileSync)(n,JSON.stringify({providers:{[k]:{...d.provider,models:[{...d.model,id:l}]}}},null,2),"utf8");let o=await j.ModelRuntime.create({modelsPath:n}),p=o.getError();if(p)return e.NextResponse.json({ok:!1,error:p});let q=o.getModel(k,l);if(!q)return e.NextResponse.json({ok:!1,error:`Model not found: ${k}/${l}`});let r=await o.getAuth(q);if(!r?.auth.apiKey)return e.NextResponse.json({ok:!1,error:`No API key found for "${k}"`});let s=new AbortController,t=setTimeout(()=>s.abort(),2e4),u=Date.now();try{let a=await (0,i.completeSimple)(q,{messages:[{role:"user",content:"Reply with OK only.",timestamp:Date.now()}]},{apiKey:r.auth.apiKey,headers:r.auth.headers,maxTokens:16,timeoutMs:2e4,maxRetries:0,cacheRetention:"none",signal:s.signal,onResponse:a=>{c=a.status}}),b=Date.now()-u;if("error"===a.stopReason||"aborted"===a.stopReason)return e.NextResponse.json({ok:!1,error:a.errorMessage??(s.signal.aborted?"Test timed out":"Model returned an error"),latencyMs:b,status:c});return e.NextResponse.json({ok:!0,latencyMs:b,status:c,responseText:a.content.filter(a=>"text"===a.type).map(a=>a.text).join("").slice(0,300)})}finally{clearTimeout(t)}}catch(a){return e.NextResponse.json({ok:!1,error:a instanceof Error?a.message:String(a)},{status:500})}finally{b&&(0,f.rmSync)(b,{recursive:!0,force:!0})}}d()}catch(a){d(a)}})},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},19821:a=>{"use strict";a.exports=import("@earendil-works/pi-ai/compat")},21820:a=>{"use strict";a.exports=require("os")},29021:a=>{"use strict";a.exports=require("fs")},29294:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},33873:a=>{"use strict";a.exports=require("path")},44870:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},49801:(a,b,c)=>{"use strict";c.r(b),c.d(b,{handler:()=>z,patchFetch:()=>y,routeModule:()=>u,serverHooks:()=>x,workAsyncStorage:()=>v,workUnitAsyncStorage:()=>w});var d=c(19225),e=c(84006),f=c(8317),g=c(99373),h=c(34775),i=c(24235),j=c(261),k=c(54365),l=c(90771),m=c(73461),n=c(67798),o=c(92280),p=c(62018),q=c(45696),r=c(47929),s=c(86439),t=c(37527);let u=new d.AppRouteRouteModule({definition:{kind:e.RouteKind.APP_ROUTE,page:"/api/models-config/test/route",pathname:"/api/models-config/test",filename:"route",bundlePath:"app/api/models-config/test/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/home/runner/work/pi-web/pi-web/app/api/models-config/test/route.ts",nextConfigOutput:"",userland:()=>c(12773),...{}}),{workAsyncStorage:v,workUnitAsyncStorage:w,serverHooks:x}=u;function y(){return(0,f.patchFetch)({workAsyncStorage:v,workUnitAsyncStorage:w})}async function z(a,b,c){c.requestMeta&&(0,g.setRequestMeta)(a,c.requestMeta),u.isDev&&(0,g.addRequestMeta)(a,"devRequestTimingInternalsEnd",process.hrtime.bigint());let d="/api/models-config/test/route";"/index"===d&&(d="/");let f=await u.prepare(a,b,{srcPage:d,multiZoneDraftMode:!1});if(!f)return b.statusCode=400,b.end("Bad Request"),null==c.waitUntil||c.waitUntil.call(c,Promise.resolve()),null;let{buildId:v,deploymentId:w,params:x,nextConfig:y,parsedUrl:z,isDraftMode:A,prerenderManifest:B,routerServerContext:C,isOnDemandRevalidate:D,revalidateOnlyGenerated:E,resolvedPathname:F,clientReferenceManifest:G,serverActionsManifest:H}=f,I=(0,j.normalizeAppPath)(d),J=!!(B.dynamicRoutes[I]||B.routes[F]),K=async()=>((null==C?void 0:C.render404)?await C.render404(a,b,z,!1):b.end("This page could not be found"),null);if(J&&!A){let a=!!B.routes[F],b=B.dynamicRoutes[I];if(b&&!1===b.fallback&&!a){if(y.adapterPath)return await K();throw new s.NoFallbackError}}let L=null;!J||u.isDev||A||(L="/index"===(L=F)?"/":L);let M=!0===u.isDev||!J,N=J&&!M;H&&G&&(0,i.setManifestsSingleton)({page:d,clientReferenceManifest:G,serverActionsManifest:H});let O=a.method||"GET",P=(0,h.getTracer)(),Q=P.getActiveScopeSpan(),R=!!(null==C?void 0:C.isWrappedByNextServer),S=!!(0,g.getRequestMeta)(a,"minimalMode"),T=(0,g.getRequestMeta)(a,"incrementalCache")||await u.getIncrementalCache(a,y,B,S);null==T||T.resetRequestCache(),globalThis.__incrementalCache=T;let U={params:x,previewProps:B.preview,renderOpts:{experimental:{authInterrupts:!!y.experimental.authInterrupts,useCacheTimeout:y.experimental.useCacheTimeout},cacheComponents:!!y.cacheComponents,validationLevel:y.experimental.instantInsights.validationLevel,supportsDynamicResponse:M,incrementalCache:T,hmrRefreshHash:(0,g.getRequestMeta)(a,"hmrRefreshHash"),cacheLifeProfiles:y.cacheLife,staticPageGenerationTimeout:y.staticPageGenerationTimeout,waitUntil:c.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:void 0,onInstrumentationRequestError:(b,c,d,e)=>u.onRequestError(a,b,d,e,C)},sharedContext:{buildId:v,deploymentId:w}},V=new k.NodeNextRequest(a),W=new k.NodeNextResponse(b),X=l.NextRequestAdapter.fromNodeNextRequest(V,(0,l.signalFromNodeResponse)(b)),Y=async({previousCacheEntry:e})=>{try{if(!S&&D&&E&&!e)return b.statusCode=404,b.setHeader("x-nextjs-cache","REVALIDATED"),b.end("This page could not be found"),null;let d=await u.handle(X,U);a.fetchMetrics=U.renderOpts.fetchMetrics;let f=U.renderOpts.pendingWaitUntil;f&&c.waitUntil&&(c.waitUntil(f),f=void 0);let g=U.renderOpts.collectedTags;if(!J)return await (0,o.I)(V,W,d,f),null;{let a=await d.blob(),b=(0,p.toNodeOutgoingHttpHeaders)(d.headers);g&&(b[r.NEXT_CACHE_TAGS_HEADER]=g),!b["content-type"]&&a.type&&(b["content-type"]=a.type);let c=void 0!==U.renderOpts.collectedRevalidate&&!(U.renderOpts.collectedRevalidate>=r.INFINITE_CACHE)&&U.renderOpts.collectedRevalidate,e=void 0===U.renderOpts.collectedExpire||U.renderOpts.collectedExpire>=r.INFINITE_CACHE?!1!==c&&c>0?y.expireTime:void 0:U.renderOpts.collectedExpire;return{value:{kind:t.CachedRouteKind.APP_ROUTE,status:d.status,body:Buffer.from(await a.arrayBuffer()),headers:b},cacheControl:{revalidate:c,expire:e}}}}catch(b){throw(null==e?void 0:e.isStale)&&await u.onRequestError(a,b,{routerKind:"App Router",routePath:d,routeType:"route",revalidateReason:(0,n.getRevalidateReason)({isStaticGeneration:N,isOnDemandRevalidate:D})},!1,C),b}},Z=async(d,f)=>{try{var g,i;let d=await u.handleResponse({req:a,nextConfig:y,cacheKey:L,routeKind:e.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:B,isRoutePPREnabled:!1,isOnDemandRevalidate:D,revalidateOnlyGenerated:E,responseGenerator:Y,waitUntil:c.waitUntil,isMinimalMode:S});if(!J)return;if((null==d||null==(g=d.value)?void 0:g.kind)!==t.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==d||null==(i=d.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});S||b.setHeader("x-nextjs-cache",D?"REVALIDATED":d.isMiss?"MISS":d.isStale?"STALE":"HIT"),A&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let f=(0,p.fromNodeOutgoingHttpHeaders)(d.value.headers);S&&J||f.delete(r.NEXT_CACHE_TAGS_HEADER),!d.cacheControl||b.getHeader("Cache-Control")||f.get("Cache-Control")||f.set("Cache-Control",(0,q.getCacheControlHeader)(d.cacheControl)),await (0,o.I)(V,W,new Response(d.value.body,{headers:f,status:d.value.status||200}));return}catch(b){if(b instanceof s.NoFallbackError||await u.onRequestError(a,b,{routerKind:"App Router",routePath:I,routeType:"route",revalidateReason:(0,n.getRevalidateReason)({isStaticGeneration:N,isOnDemandRevalidate:D})},!1,C),J)throw b;await (0,o.I)(V,W,new Response(null,{status:500}));return}finally{(()=>{if(!d)return;let a=b.statusCode;d.setAttributes({"http.status_code":a,"next.rsc":!1}),a&&a>=500&&(d.setStatus({code:h.SpanStatusCode.ERROR}),d.setAttribute("error.type",a.toString()));let c=P.getRootSpanAttributes();if(!c)return;if(c.get("next.span_type")!==m.BaseServerSpan.handleRequest)return console.warn(`Unexpected root span type '${c.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let e=c.get("next.route")||I,g=`${O} ${e}`;d.setAttributes({"next.route":e,"http.route":e,"next.span_name":g}),d.updateName(g),f&&f!==d&&(f.setAttribute("http.route",e),f.updateName(g))})()}};if(R&&Q)await Z(Q,void 0);else{let b=P.getActiveScopeSpan();await P.withPropagatedContext(a.headers,()=>P.trace(m.BaseServerSpan.handleRequest,{spanName:`${O} ${d}`,kind:h.SpanKind.SERVER,attributes:{"http.method":O,"http.target":a.url}},a=>Z(a,b)),void 0,!R)}}},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},66544:(a,b,c)=>{"use strict";c.d(b,{E2:()=>k,EN:()=>j});var d=c(77030);function e(a){return(a.startsWith("[")&&a.endsWith("]")?a.slice(1,-1):a).toLowerCase().replace(/\.$/,"")}function f(a){if(!a||/[\s/@\\]/.test(a))return null;try{let b=new URL(`http://${a}`);if(b.username||b.password||"/"!==b.pathname||b.search||b.hash)return null;return e(b.hostname)}catch{return null}}function g(a){if(!a||/[\s/@\\]/.test(a))return null;try{let b=new URL(`http://${a}`);if(b.username||b.password||"/"!==b.pathname||b.search||b.hash)return null;let c=e(b.hostname);return b.port?`${c}:${b.port}`:c}catch{return null}}function h(){return[process.env.PI_WEB_HOSTNAME,...process.env.PI_WEB_ALLOWED_HOSTS?.split(",")??[]].filter(a=>!!a?.trim())}function i(a){try{return new URL(a).origin}catch{return null}}function j(a,b=h()){return!!function(a,b=h()){let c=a.headers.get("host"),g=c?f(c):null;return!!g&&(!!("localhost"===g||g.endsWith(".localhost")||(0,d.isIP)(g))||b.some(a=>{let b;return((b=a?.trim())?(0,d.isIP)(b)?e(b):f(b):null)===g}))}(a,b)&&(!!function(a){if("GET"!==a.method||"navigate"!==a.headers.get("sec-fetch-mode")||"document"!==a.headers.get("sec-fetch-dest")||"?1"!==a.headers.get("sec-fetch-user"))return!1;try{return/^\/api\/sessions\/[^/]+\/export$/.test(new URL(a.url).pathname)}catch{return!1}}(a)||!(a.headers.has("origin")||a.headers.has("sec-fetch-site"))||function(a){let b,c,d,e=a.headers.get("origin");if("cross-site"===a.headers.get("sec-fetch-site"))return!1;if(!e)return!0;let f=(b=new URL(a.url),(c=a.headers.get("host"))?i(`${b.protocol}//${c}`):null);if(null!==f&&i(e)===f)return!0;if("same-origin"!==a.headers.get("sec-fetch-site")||!a.headers.get("x-forwarded-proto"))return!1;let h=a.headers.get("host");if(!h)return!1;try{d=new URL(e).host}catch{return!1}let j=g(d);return null!==j&&j===g(h)}(a))}function k(a){let b=a.headers.get("content-type")?.split(";",1)[0]?.trim().toLowerCase();return"application/json"===b||!!(b?.startsWith("application/")&&b.endsWith("+json"))}},75430:a=>{"use strict";a.exports=import("@earendil-works/pi-coding-agent")},77030:a=>{"use strict";a.exports=require("node:net")},78335:()=>{},86439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},96487:()=>{}};var b=require("../../../../webpack-runtime.js");b.C(a);var c=b.X(0,[4741,1813],()=>b(b.s=49801));module.exports=c})();
@@ -1 +1 @@
1
- (()=>{var a={};a.id=7394,a.ids=[7394],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},8102:(a,b,c)=>{"use strict";c.d(b,{$:()=>g});var d=c(55511),e=c(29021),f=c(33873);function g(a,b){let c=(0,f.dirname)(a),g=(0,f.join)(c,`.${(0,f.basename)(a)}-${(0,d.randomUUID)()}.tmp`),h=!1;try{(0,e.writeFileSync)(g,b,{encoding:"utf8",flag:"wx",mode:384,flush:!0}),(0,e.renameSync)(g,a)}catch(a){throw h=!0,a}finally{try{(0,e.unlinkSync)(g)}catch(a){if("ENOENT"!==a.code&&!h)throw a}}}},8128:a=>{"use strict";a.exports=require("next/dist/server/runtime-reacts.external.js")},10846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},12412:a=>{"use strict";a.exports=require("assert")},14405:(a,b,c)=>{"use strict";c.r(b),c.d(b,{handler:()=>z,patchFetch:()=>y,routeModule:()=>u,serverHooks:()=>x,workAsyncStorage:()=>v,workUnitAsyncStorage:()=>w});var d=c(19225),e=c(84006),f=c(8317),g=c(99373),h=c(34775),i=c(24235),j=c(261),k=c(54365),l=c(90771),m=c(73461),n=c(67798),o=c(92280),p=c(62018),q=c(45696),r=c(47929),s=c(86439),t=c(37527);let u=new d.AppRouteRouteModule({definition:{kind:e.RouteKind.APP_ROUTE,page:"/api/pins/route",pathname:"/api/pins",filename:"route",bundlePath:"app/api/pins/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/home/runner/work/pi-web/pi-web/app/api/pins/route.ts",nextConfigOutput:"",userland:()=>c(77281),...{}}),{workAsyncStorage:v,workUnitAsyncStorage:w,serverHooks:x}=u;function y(){return(0,f.patchFetch)({workAsyncStorage:v,workUnitAsyncStorage:w})}async function z(a,b,c){c.requestMeta&&(0,g.setRequestMeta)(a,c.requestMeta),u.isDev&&(0,g.addRequestMeta)(a,"devRequestTimingInternalsEnd",process.hrtime.bigint());let d="/api/pins/route";"/index"===d&&(d="/");let f=await u.prepare(a,b,{srcPage:d,multiZoneDraftMode:!1});if(!f)return b.statusCode=400,b.end("Bad Request"),null==c.waitUntil||c.waitUntil.call(c,Promise.resolve()),null;let{buildId:v,deploymentId:w,params:x,nextConfig:y,parsedUrl:z,isDraftMode:A,prerenderManifest:B,routerServerContext:C,isOnDemandRevalidate:D,revalidateOnlyGenerated:E,resolvedPathname:F,clientReferenceManifest:G,serverActionsManifest:H}=f,I=(0,j.normalizeAppPath)(d),J=!!(B.dynamicRoutes[I]||B.routes[F]),K=async()=>((null==C?void 0:C.render404)?await C.render404(a,b,z,!1):b.end("This page could not be found"),null);if(J&&!A){let a=!!B.routes[F],b=B.dynamicRoutes[I];if(b&&!1===b.fallback&&!a){if(y.adapterPath)return await K();throw new s.NoFallbackError}}let L=null;!J||u.isDev||A||(L="/index"===(L=F)?"/":L);let M=!0===u.isDev||!J,N=J&&!M;H&&G&&(0,i.setManifestsSingleton)({page:d,clientReferenceManifest:G,serverActionsManifest:H});let O=a.method||"GET",P=(0,h.getTracer)(),Q=P.getActiveScopeSpan(),R=!!(null==C?void 0:C.isWrappedByNextServer),S=!!(0,g.getRequestMeta)(a,"minimalMode"),T=(0,g.getRequestMeta)(a,"incrementalCache")||await u.getIncrementalCache(a,y,B,S);null==T||T.resetRequestCache(),globalThis.__incrementalCache=T;let U={params:x,previewProps:B.preview,renderOpts:{experimental:{authInterrupts:!!y.experimental.authInterrupts,useCacheTimeout:y.experimental.useCacheTimeout},cacheComponents:!!y.cacheComponents,validationLevel:y.experimental.instantInsights.validationLevel,supportsDynamicResponse:M,incrementalCache:T,hmrRefreshHash:(0,g.getRequestMeta)(a,"hmrRefreshHash"),cacheLifeProfiles:y.cacheLife,staticPageGenerationTimeout:y.staticPageGenerationTimeout,waitUntil:c.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:void 0,onInstrumentationRequestError:(b,c,d,e)=>u.onRequestError(a,b,d,e,C)},sharedContext:{buildId:v,deploymentId:w}},V=new k.NodeNextRequest(a),W=new k.NodeNextResponse(b),X=l.NextRequestAdapter.fromNodeNextRequest(V,(0,l.signalFromNodeResponse)(b)),Y=async({previousCacheEntry:e})=>{try{if(!S&&D&&E&&!e)return b.statusCode=404,b.setHeader("x-nextjs-cache","REVALIDATED"),b.end("This page could not be found"),null;let d=await u.handle(X,U);a.fetchMetrics=U.renderOpts.fetchMetrics;let f=U.renderOpts.pendingWaitUntil;f&&c.waitUntil&&(c.waitUntil(f),f=void 0);let g=U.renderOpts.collectedTags;if(!J)return await (0,o.I)(V,W,d,f),null;{let a=await d.blob(),b=(0,p.toNodeOutgoingHttpHeaders)(d.headers);g&&(b[r.NEXT_CACHE_TAGS_HEADER]=g),!b["content-type"]&&a.type&&(b["content-type"]=a.type);let c=void 0!==U.renderOpts.collectedRevalidate&&!(U.renderOpts.collectedRevalidate>=r.INFINITE_CACHE)&&U.renderOpts.collectedRevalidate,e=void 0===U.renderOpts.collectedExpire||U.renderOpts.collectedExpire>=r.INFINITE_CACHE?!1!==c&&c>0?y.expireTime:void 0:U.renderOpts.collectedExpire;return{value:{kind:t.CachedRouteKind.APP_ROUTE,status:d.status,body:Buffer.from(await a.arrayBuffer()),headers:b},cacheControl:{revalidate:c,expire:e}}}}catch(b){throw(null==e?void 0:e.isStale)&&await u.onRequestError(a,b,{routerKind:"App Router",routePath:d,routeType:"route",revalidateReason:(0,n.getRevalidateReason)({isStaticGeneration:N,isOnDemandRevalidate:D})},!1,C),b}},Z=async(d,f)=>{try{var g,i;let d=await u.handleResponse({req:a,nextConfig:y,cacheKey:L,routeKind:e.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:B,isRoutePPREnabled:!1,isOnDemandRevalidate:D,revalidateOnlyGenerated:E,responseGenerator:Y,waitUntil:c.waitUntil,isMinimalMode:S});if(!J)return;if((null==d||null==(g=d.value)?void 0:g.kind)!==t.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==d||null==(i=d.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});S||b.setHeader("x-nextjs-cache",D?"REVALIDATED":d.isMiss?"MISS":d.isStale?"STALE":"HIT"),A&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let f=(0,p.fromNodeOutgoingHttpHeaders)(d.value.headers);S&&J||f.delete(r.NEXT_CACHE_TAGS_HEADER),!d.cacheControl||b.getHeader("Cache-Control")||f.get("Cache-Control")||f.set("Cache-Control",(0,q.getCacheControlHeader)(d.cacheControl)),await (0,o.I)(V,W,new Response(d.value.body,{headers:f,status:d.value.status||200}));return}catch(b){if(b instanceof s.NoFallbackError||await u.onRequestError(a,b,{routerKind:"App Router",routePath:I,routeType:"route",revalidateReason:(0,n.getRevalidateReason)({isStaticGeneration:N,isOnDemandRevalidate:D})},!1,C),J)throw b;await (0,o.I)(V,W,new Response(null,{status:500}));return}finally{(()=>{if(!d)return;let a=b.statusCode;d.setAttributes({"http.status_code":a,"next.rsc":!1}),a&&a>=500&&(d.setStatus({code:h.SpanStatusCode.ERROR}),d.setAttribute("error.type",a.toString()));let c=P.getRootSpanAttributes();if(!c)return;if(c.get("next.span_type")!==m.BaseServerSpan.handleRequest)return console.warn(`Unexpected root span type '${c.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let e=c.get("next.route")||I,g=`${O} ${e}`;d.setAttributes({"next.route":e,"http.route":e,"next.span_name":g}),d.updateName(g),f&&f!==d&&(f.setAttribute("http.route",e),f.updateName(g))})()}};if(R&&Q)await Z(Q,void 0);else{let b=P.getActiveScopeSpan();await P.withPropagatedContext(a.headers,()=>P.trace(m.BaseServerSpan.handleRequest,{spanName:`${O} ${d}`,kind:h.SpanKind.SERVER,attributes:{"http.method":O,"http.target":a.url}},a=>Z(a,b)),void 0,!R)}}},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},24598:(a,b,c)=>{"use strict";c.d(b,{cb:()=>i,eZ:()=>g,pU:()=>h,tE:()=>d,yO:()=>f});let d=500;function e(a){return Object.keys(a).sort()}function f(a,b){return{sessions:e(a),projects:e(b)}}function g(a){if("string"!=typeof a)return null;let b=a.trim();return!b||b.length>512?null:b}function h(a){return"session"===a||"project"===a?a:null}function i(a,b){let c=0,d={};for(let[e,f]of Object.entries(a))b.has(e)?d[e]=f:c+=1;return c>0?{map:d,removed:c}:{map:a,removed:0}}},27910:a=>{"use strict";a.exports=require("stream")},28354:a=>{"use strict";a.exports=require("util")},29021:a=>{"use strict";a.exports=require("fs")},29294:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},33873:a=>{"use strict";a.exports=require("path")},44870:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},55511:a=>{"use strict";a.exports=require("crypto")},61815:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{DC:()=>v,TC:()=>s,oW:()=>u});var e=c(73024),f=c(76760),g=c(75430),h=c(80974),i=c.n(h),j=c(8102),k=c(24598),l=a([g]);function m(a=(0,g.getAgentDir)()){return(0,f.join)(a,"pi-web","pins.json")}function n(){return{version:1,sessions:{},projects:{}}}function o(a){if(!a||"object"!=typeof a)return{};let b={};for(let[c,d]of Object.entries(a)){if(!c)continue;let a=d&&"object"==typeof d?d:null,e="string"==typeof a?.pinnedAt?a.pinnedAt:"";b[c]={pinnedAt:e}}return b}g=(l.then?(await l)():l)[0];let w=new Map;function p(a){try{let b=(0,e.statSync)(a);return{mtimeMs:b.mtimeMs,size:b.size}}catch{return null}}function q(a){try{var b=(0,e.readFileSync)(a,"utf8");try{let a=JSON.parse(b);if(!a||"object"!=typeof a)return n();return{version:"number"==typeof a.version?a.version:1,sessions:o(a.sessions),projects:o(a.projects)}}catch{return n()}}catch{return n()}}function r(a=(0,g.getAgentDir)()){let b=m(a),c=p(b);if(!c)return n();let d=w.get(b);if(d&&d.mtimeMs===c.mtimeMs&&d.size===c.size)return d.store;let e=q(b);return w.set(b,{...c,store:e}),e}function s(a=(0,g.getAgentDir)()){let b=r(a);return(0,k.yO)(b.sessions,b.projects)}async function t(a,b){let c=m(a),d=(0,f.dirname)(c);(0,e.existsSync)(d)||(0,e.mkdirSync)(d,{recursive:!0,mode:448});try{(0,e.writeFileSync)(c,"{}",{flag:"wx",mode:384})}catch(a){if("EEXIST"!==a.code)throw a}let g=await i().lock(c,{realpath:!1,retries:10});try{let a=b(q(c));if(!a.changed)return;(0,j.$)(c,JSON.stringify(a.store,null,2));try{(0,e.chmodSync)(c,384)}catch{}let d=p(c);d?w.set(c,{...d,store:a.store}):w.delete(c)}finally{await g()}}async function u(a){let{kind:b,key:c,pinned:d}=a,e=a.agentDir??(0,g.getAgentDir)();return await t(e,a=>{let e="session"===b?a.sessions:a.projects,f=Object.prototype.hasOwnProperty.call(e,c);if(d===f)return{store:a,changed:!1};let g={...e};if(d){if(Object.keys(g).length>=k.tE)throw Error(`Cannot pin more than ${k.tE} ${b}s`);g[c]={pinnedAt:new Date().toISOString()}}else delete g[c];return{store:"session"===b?{...a,sessions:g}:{...a,projects:g},changed:!0}}),s(e)}async function v(a){let b=a.agentDir??(0,g.getAgentDir)();if(!(0,e.existsSync)(m(b)))return!1;let c=new Set(a.sessionIds),d=new Set(a.projectKeys),f=r(b),h=(0,k.cb)(f.sessions,c),i=(0,k.cb)(f.projects,d);if(0===h.removed&&0===i.removed)return!1;try{return await t(b,a=>{let b=(0,k.cb)(a.sessions,c),e=(0,k.cb)(a.projects,d);return 0===b.removed&&0===e.removed?{store:a,changed:!1}:{store:{...a,sessions:b.map,projects:e.map},changed:!0}}),!0}catch{return!1}}d()}catch(a){d(a)}})},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},73024:a=>{"use strict";a.exports=require("node:fs")},75430:a=>{"use strict";a.exports=import("@earendil-works/pi-coding-agent")},76760:a=>{"use strict";a.exports=require("node:path")},77281:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.r(b),c.d(b,{GET:()=>i,POST:()=>j,dynamic:()=>k});var e=c(23211),f=c(61815),g=c(24598),h=a([f]);f=(h.then?(await h)():h)[0];let k="force-dynamic";async function i(){try{return e.NextResponse.json((0,f.TC)(),{headers:{"Cache-Control":"no-store"}})}catch(a){return e.NextResponse.json({error:String(a)},{status:500})}}async function j(a){let b;try{b=await a.json()}catch{return e.NextResponse.json({error:"Invalid JSON body"},{status:400})}let c=b,d=(0,g.pU)(c.kind);if(!d)return e.NextResponse.json({error:'kind must be "session" or "project"'},{status:400});let h=(0,g.eZ)(c.key);if(!h)return e.NextResponse.json({error:"key must be a non-empty string"},{status:400});try{let a="boolean"==typeof c.pinned?c.pinned:void 0;if(void 0===a){let b=(0,f.TC)();a=!("session"===d?b.sessions:b.projects).includes(h)}let b=await (0,f.oW)({kind:d,key:h,pinned:a});return e.NextResponse.json(b,{headers:{"Cache-Control":"no-store"}})}catch(b){let a=b instanceof Error?b.message:String(b);return e.NextResponse.json({error:a},{status:409})}}d()}catch(a){d(a)}})},78335:()=>{},81115:a=>{"use strict";a.exports=require("constants")},86439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},94735:a=>{"use strict";a.exports=require("events")},96487:()=>{}};var b=require("../../../webpack-runtime.js");b.C(a);var c=b.X(0,[4741,1813,974],()=>b(b.s=14405));module.exports=c})();
1
+ (()=>{var a={};a.id=7394,a.ids=[7394],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},8102:(a,b,c)=>{"use strict";c.d(b,{$:()=>g});var d=c(55511),e=c(29021),f=c(33873);function g(a,b){let c=(0,f.dirname)(a),g=(0,f.join)(c,`.${(0,f.basename)(a)}-${(0,d.randomUUID)()}.tmp`),h=!1;try{(0,e.writeFileSync)(g,b,{encoding:"utf8",flag:"wx",mode:384,flush:!0}),(0,e.renameSync)(g,a)}catch(a){throw h=!0,a}finally{try{(0,e.unlinkSync)(g)}catch(a){if("ENOENT"!==a.code&&!h)throw a}}}},8128:a=>{"use strict";a.exports=require("next/dist/server/runtime-reacts.external.js")},10846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},12412:a=>{"use strict";a.exports=require("assert")},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},24598:(a,b,c)=>{"use strict";c.d(b,{cb:()=>i,eZ:()=>g,pU:()=>h,tE:()=>d,yO:()=>f});let d=500;function e(a){return Object.keys(a).sort()}function f(a,b){return{sessions:e(a),projects:e(b)}}function g(a){if("string"!=typeof a)return null;let b=a.trim();return!b||b.length>512?null:b}function h(a){return"session"===a||"project"===a?a:null}function i(a,b){let c=0,d={};for(let[e,f]of Object.entries(a))b.has(e)?d[e]=f:c+=1;return c>0?{map:d,removed:c}:{map:a,removed:0}}},27910:a=>{"use strict";a.exports=require("stream")},28354:a=>{"use strict";a.exports=require("util")},29021:a=>{"use strict";a.exports=require("fs")},29294:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},33873:a=>{"use strict";a.exports=require("path")},44870:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},55511:a=>{"use strict";a.exports=require("crypto")},60297:(a,b,c)=>{"use strict";c.r(b),c.d(b,{handler:()=>z,patchFetch:()=>y,routeModule:()=>u,serverHooks:()=>x,workAsyncStorage:()=>v,workUnitAsyncStorage:()=>w});var d=c(19225),e=c(84006),f=c(8317),g=c(99373),h=c(34775),i=c(24235),j=c(261),k=c(54365),l=c(90771),m=c(73461),n=c(67798),o=c(92280),p=c(62018),q=c(45696),r=c(47929),s=c(86439),t=c(37527);let u=new d.AppRouteRouteModule({definition:{kind:e.RouteKind.APP_ROUTE,page:"/api/pins/route",pathname:"/api/pins",filename:"route",bundlePath:"app/api/pins/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/home/runner/work/pi-web/pi-web/app/api/pins/route.ts",nextConfigOutput:"",userland:()=>c(77281),...{}}),{workAsyncStorage:v,workUnitAsyncStorage:w,serverHooks:x}=u;function y(){return(0,f.patchFetch)({workAsyncStorage:v,workUnitAsyncStorage:w})}async function z(a,b,c){c.requestMeta&&(0,g.setRequestMeta)(a,c.requestMeta),u.isDev&&(0,g.addRequestMeta)(a,"devRequestTimingInternalsEnd",process.hrtime.bigint());let d="/api/pins/route";"/index"===d&&(d="/");let f=await u.prepare(a,b,{srcPage:d,multiZoneDraftMode:!1});if(!f)return b.statusCode=400,b.end("Bad Request"),null==c.waitUntil||c.waitUntil.call(c,Promise.resolve()),null;let{buildId:v,deploymentId:w,params:x,nextConfig:y,parsedUrl:z,isDraftMode:A,prerenderManifest:B,routerServerContext:C,isOnDemandRevalidate:D,revalidateOnlyGenerated:E,resolvedPathname:F,clientReferenceManifest:G,serverActionsManifest:H}=f,I=(0,j.normalizeAppPath)(d),J=!!(B.dynamicRoutes[I]||B.routes[F]),K=async()=>((null==C?void 0:C.render404)?await C.render404(a,b,z,!1):b.end("This page could not be found"),null);if(J&&!A){let a=!!B.routes[F],b=B.dynamicRoutes[I];if(b&&!1===b.fallback&&!a){if(y.adapterPath)return await K();throw new s.NoFallbackError}}let L=null;!J||u.isDev||A||(L="/index"===(L=F)?"/":L);let M=!0===u.isDev||!J,N=J&&!M;H&&G&&(0,i.setManifestsSingleton)({page:d,clientReferenceManifest:G,serverActionsManifest:H});let O=a.method||"GET",P=(0,h.getTracer)(),Q=P.getActiveScopeSpan(),R=!!(null==C?void 0:C.isWrappedByNextServer),S=!!(0,g.getRequestMeta)(a,"minimalMode"),T=(0,g.getRequestMeta)(a,"incrementalCache")||await u.getIncrementalCache(a,y,B,S);null==T||T.resetRequestCache(),globalThis.__incrementalCache=T;let U={params:x,previewProps:B.preview,renderOpts:{experimental:{authInterrupts:!!y.experimental.authInterrupts,useCacheTimeout:y.experimental.useCacheTimeout},cacheComponents:!!y.cacheComponents,validationLevel:y.experimental.instantInsights.validationLevel,supportsDynamicResponse:M,incrementalCache:T,hmrRefreshHash:(0,g.getRequestMeta)(a,"hmrRefreshHash"),cacheLifeProfiles:y.cacheLife,staticPageGenerationTimeout:y.staticPageGenerationTimeout,waitUntil:c.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:void 0,onInstrumentationRequestError:(b,c,d,e)=>u.onRequestError(a,b,d,e,C)},sharedContext:{buildId:v,deploymentId:w}},V=new k.NodeNextRequest(a),W=new k.NodeNextResponse(b),X=l.NextRequestAdapter.fromNodeNextRequest(V,(0,l.signalFromNodeResponse)(b)),Y=async({previousCacheEntry:e})=>{try{if(!S&&D&&E&&!e)return b.statusCode=404,b.setHeader("x-nextjs-cache","REVALIDATED"),b.end("This page could not be found"),null;let d=await u.handle(X,U);a.fetchMetrics=U.renderOpts.fetchMetrics;let f=U.renderOpts.pendingWaitUntil;f&&c.waitUntil&&(c.waitUntil(f),f=void 0);let g=U.renderOpts.collectedTags;if(!J)return await (0,o.I)(V,W,d,f),null;{let a=await d.blob(),b=(0,p.toNodeOutgoingHttpHeaders)(d.headers);g&&(b[r.NEXT_CACHE_TAGS_HEADER]=g),!b["content-type"]&&a.type&&(b["content-type"]=a.type);let c=void 0!==U.renderOpts.collectedRevalidate&&!(U.renderOpts.collectedRevalidate>=r.INFINITE_CACHE)&&U.renderOpts.collectedRevalidate,e=void 0===U.renderOpts.collectedExpire||U.renderOpts.collectedExpire>=r.INFINITE_CACHE?!1!==c&&c>0?y.expireTime:void 0:U.renderOpts.collectedExpire;return{value:{kind:t.CachedRouteKind.APP_ROUTE,status:d.status,body:Buffer.from(await a.arrayBuffer()),headers:b},cacheControl:{revalidate:c,expire:e}}}}catch(b){throw(null==e?void 0:e.isStale)&&await u.onRequestError(a,b,{routerKind:"App Router",routePath:d,routeType:"route",revalidateReason:(0,n.getRevalidateReason)({isStaticGeneration:N,isOnDemandRevalidate:D})},!1,C),b}},Z=async(d,f)=>{try{var g,i;let d=await u.handleResponse({req:a,nextConfig:y,cacheKey:L,routeKind:e.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:B,isRoutePPREnabled:!1,isOnDemandRevalidate:D,revalidateOnlyGenerated:E,responseGenerator:Y,waitUntil:c.waitUntil,isMinimalMode:S});if(!J)return;if((null==d||null==(g=d.value)?void 0:g.kind)!==t.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==d||null==(i=d.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});S||b.setHeader("x-nextjs-cache",D?"REVALIDATED":d.isMiss?"MISS":d.isStale?"STALE":"HIT"),A&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let f=(0,p.fromNodeOutgoingHttpHeaders)(d.value.headers);S&&J||f.delete(r.NEXT_CACHE_TAGS_HEADER),!d.cacheControl||b.getHeader("Cache-Control")||f.get("Cache-Control")||f.set("Cache-Control",(0,q.getCacheControlHeader)(d.cacheControl)),await (0,o.I)(V,W,new Response(d.value.body,{headers:f,status:d.value.status||200}));return}catch(b){if(b instanceof s.NoFallbackError||await u.onRequestError(a,b,{routerKind:"App Router",routePath:I,routeType:"route",revalidateReason:(0,n.getRevalidateReason)({isStaticGeneration:N,isOnDemandRevalidate:D})},!1,C),J)throw b;await (0,o.I)(V,W,new Response(null,{status:500}));return}finally{(()=>{if(!d)return;let a=b.statusCode;d.setAttributes({"http.status_code":a,"next.rsc":!1}),a&&a>=500&&(d.setStatus({code:h.SpanStatusCode.ERROR}),d.setAttribute("error.type",a.toString()));let c=P.getRootSpanAttributes();if(!c)return;if(c.get("next.span_type")!==m.BaseServerSpan.handleRequest)return console.warn(`Unexpected root span type '${c.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let e=c.get("next.route")||I,g=`${O} ${e}`;d.setAttributes({"next.route":e,"http.route":e,"next.span_name":g}),d.updateName(g),f&&f!==d&&(f.setAttribute("http.route",e),f.updateName(g))})()}};if(R&&Q)await Z(Q,void 0);else{let b=P.getActiveScopeSpan();await P.withPropagatedContext(a.headers,()=>P.trace(m.BaseServerSpan.handleRequest,{spanName:`${O} ${d}`,kind:h.SpanKind.SERVER,attributes:{"http.method":O,"http.target":a.url}},a=>Z(a,b)),void 0,!R)}}},61815:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{DC:()=>v,TC:()=>s,oW:()=>u});var e=c(73024),f=c(76760),g=c(75430),h=c(80974),i=c.n(h),j=c(8102),k=c(24598),l=a([g]);function m(a=(0,g.getAgentDir)()){return(0,f.join)(a,"pi-web","pins.json")}function n(){return{version:1,sessions:{},projects:{}}}function o(a){if(!a||"object"!=typeof a)return{};let b={};for(let[c,d]of Object.entries(a)){if(!c)continue;let a=d&&"object"==typeof d?d:null,e="string"==typeof a?.pinnedAt?a.pinnedAt:"";b[c]={pinnedAt:e}}return b}g=(l.then?(await l)():l)[0];let w=new Map;function p(a){try{let b=(0,e.statSync)(a);return{mtimeMs:b.mtimeMs,size:b.size}}catch{return null}}function q(a){try{var b=(0,e.readFileSync)(a,"utf8");try{let a=JSON.parse(b);if(!a||"object"!=typeof a)return n();return{version:"number"==typeof a.version?a.version:1,sessions:o(a.sessions),projects:o(a.projects)}}catch{return n()}}catch{return n()}}function r(a=(0,g.getAgentDir)()){let b=m(a),c=p(b);if(!c)return n();let d=w.get(b);if(d&&d.mtimeMs===c.mtimeMs&&d.size===c.size)return d.store;let e=q(b);return w.set(b,{...c,store:e}),e}function s(a=(0,g.getAgentDir)()){let b=r(a);return(0,k.yO)(b.sessions,b.projects)}async function t(a,b){let c=m(a),d=(0,f.dirname)(c);(0,e.existsSync)(d)||(0,e.mkdirSync)(d,{recursive:!0,mode:448});try{(0,e.writeFileSync)(c,"{}",{flag:"wx",mode:384})}catch(a){if("EEXIST"!==a.code)throw a}let g=await i().lock(c,{realpath:!1,retries:10});try{let a=b(q(c));if(!a.changed)return;(0,j.$)(c,JSON.stringify(a.store,null,2));try{(0,e.chmodSync)(c,384)}catch{}let d=p(c);d?w.set(c,{...d,store:a.store}):w.delete(c)}finally{await g()}}async function u(a){let{kind:b,key:c,pinned:d}=a,e=a.agentDir??(0,g.getAgentDir)();return await t(e,a=>{let e="session"===b?a.sessions:a.projects,f=Object.prototype.hasOwnProperty.call(e,c);if(d===f)return{store:a,changed:!1};let g={...e};if(d){if(Object.keys(g).length>=k.tE)throw Error(`Cannot pin more than ${k.tE} ${b}s`);g[c]={pinnedAt:new Date().toISOString()}}else delete g[c];return{store:"session"===b?{...a,sessions:g}:{...a,projects:g},changed:!0}}),s(e)}async function v(a){let b=a.agentDir??(0,g.getAgentDir)();if(!(0,e.existsSync)(m(b)))return!1;let c=new Set(a.sessionIds),d=new Set(a.projectKeys),f=r(b),h=(0,k.cb)(f.sessions,c),i=(0,k.cb)(f.projects,d);if(0===h.removed&&0===i.removed)return!1;try{return await t(b,a=>{let b=(0,k.cb)(a.sessions,c),e=(0,k.cb)(a.projects,d);return 0===b.removed&&0===e.removed?{store:a,changed:!1}:{store:{...a,sessions:b.map,projects:e.map},changed:!0}}),!0}catch{return!1}}d()}catch(a){d(a)}})},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},73024:a=>{"use strict";a.exports=require("node:fs")},75430:a=>{"use strict";a.exports=import("@earendil-works/pi-coding-agent")},76760:a=>{"use strict";a.exports=require("node:path")},77281:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.r(b),c.d(b,{GET:()=>i,POST:()=>j,dynamic:()=>k});var e=c(23211),f=c(61815),g=c(24598),h=a([f]);f=(h.then?(await h)():h)[0];let k="force-dynamic";async function i(){try{return e.NextResponse.json((0,f.TC)(),{headers:{"Cache-Control":"no-store"}})}catch(a){return e.NextResponse.json({error:String(a)},{status:500})}}async function j(a){let b;try{b=await a.json()}catch{return e.NextResponse.json({error:"Invalid JSON body"},{status:400})}let c=b,d=(0,g.pU)(c.kind);if(!d)return e.NextResponse.json({error:'kind must be "session" or "project"'},{status:400});let h=(0,g.eZ)(c.key);if(!h)return e.NextResponse.json({error:"key must be a non-empty string"},{status:400});try{let a="boolean"==typeof c.pinned?c.pinned:void 0;if(void 0===a){let b=(0,f.TC)();a=!("session"===d?b.sessions:b.projects).includes(h)}let b=await (0,f.oW)({kind:d,key:h,pinned:a});return e.NextResponse.json(b,{headers:{"Cache-Control":"no-store"}})}catch(b){let a=b instanceof Error?b.message:String(b);return e.NextResponse.json({error:a},{status:409})}}d()}catch(a){d(a)}})},78335:()=>{},81115:a=>{"use strict";a.exports=require("constants")},86439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},94735:a=>{"use strict";a.exports=require("events")},96487:()=>{}};var b=require("../../../webpack-runtime.js");b.C(a);var c=b.X(0,[4741,1813,974],()=>b(b.s=60297));module.exports=c})();
@@ -1 +1 @@
1
- "use strict";(()=>{var a={};a.id=2403,a.ids=[2403],a.modules={261:a=>{a.exports=require("next/dist/shared/lib/router/utils/app-paths")},2455:(a,b,c)=>{c.r(b),c.d(b,{handler:()=>z,patchFetch:()=>y,routeModule:()=>u,serverHooks:()=>x,workAsyncStorage:()=>v,workUnitAsyncStorage:()=>w});var d=c(19225),e=c(84006),f=c(8317),g=c(99373),h=c(34775),i=c(24235),j=c(261),k=c(54365),l=c(90771),m=c(73461),n=c(67798),o=c(92280),p=c(62018),q=c(45696),r=c(47929),s=c(86439),t=c(37527);let u=new d.AppRouteRouteModule({definition:{kind:e.RouteKind.APP_ROUTE,page:"/api/plugins/check/route",pathname:"/api/plugins/check",filename:"route",bundlePath:"app/api/plugins/check/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/home/runner/work/pi-web/pi-web/app/api/plugins/check/route.ts",nextConfigOutput:"",userland:()=>c(97982),...{}}),{workAsyncStorage:v,workUnitAsyncStorage:w,serverHooks:x}=u;function y(){return(0,f.patchFetch)({workAsyncStorage:v,workUnitAsyncStorage:w})}async function z(a,b,c){c.requestMeta&&(0,g.setRequestMeta)(a,c.requestMeta),u.isDev&&(0,g.addRequestMeta)(a,"devRequestTimingInternalsEnd",process.hrtime.bigint());let d="/api/plugins/check/route";"/index"===d&&(d="/");let f=await u.prepare(a,b,{srcPage:d,multiZoneDraftMode:!1});if(!f)return b.statusCode=400,b.end("Bad Request"),null==c.waitUntil||c.waitUntil.call(c,Promise.resolve()),null;let{buildId:v,deploymentId:w,params:x,nextConfig:y,parsedUrl:z,isDraftMode:A,prerenderManifest:B,routerServerContext:C,isOnDemandRevalidate:D,revalidateOnlyGenerated:E,resolvedPathname:F,clientReferenceManifest:G,serverActionsManifest:H}=f,I=(0,j.normalizeAppPath)(d),J=!!(B.dynamicRoutes[I]||B.routes[F]),K=async()=>((null==C?void 0:C.render404)?await C.render404(a,b,z,!1):b.end("This page could not be found"),null);if(J&&!A){let a=!!B.routes[F],b=B.dynamicRoutes[I];if(b&&!1===b.fallback&&!a){if(y.adapterPath)return await K();throw new s.NoFallbackError}}let L=null;!J||u.isDev||A||(L="/index"===(L=F)?"/":L);let M=!0===u.isDev||!J,N=J&&!M;H&&G&&(0,i.setManifestsSingleton)({page:d,clientReferenceManifest:G,serverActionsManifest:H});let O=a.method||"GET",P=(0,h.getTracer)(),Q=P.getActiveScopeSpan(),R=!!(null==C?void 0:C.isWrappedByNextServer),S=!!(0,g.getRequestMeta)(a,"minimalMode"),T=(0,g.getRequestMeta)(a,"incrementalCache")||await u.getIncrementalCache(a,y,B,S);null==T||T.resetRequestCache(),globalThis.__incrementalCache=T;let U={params:x,previewProps:B.preview,renderOpts:{experimental:{authInterrupts:!!y.experimental.authInterrupts,useCacheTimeout:y.experimental.useCacheTimeout},cacheComponents:!!y.cacheComponents,validationLevel:y.experimental.instantInsights.validationLevel,supportsDynamicResponse:M,incrementalCache:T,hmrRefreshHash:(0,g.getRequestMeta)(a,"hmrRefreshHash"),cacheLifeProfiles:y.cacheLife,staticPageGenerationTimeout:y.staticPageGenerationTimeout,waitUntil:c.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:void 0,onInstrumentationRequestError:(b,c,d,e)=>u.onRequestError(a,b,d,e,C)},sharedContext:{buildId:v,deploymentId:w}},V=new k.NodeNextRequest(a),W=new k.NodeNextResponse(b),X=l.NextRequestAdapter.fromNodeNextRequest(V,(0,l.signalFromNodeResponse)(b)),Y=async({previousCacheEntry:e})=>{try{if(!S&&D&&E&&!e)return b.statusCode=404,b.setHeader("x-nextjs-cache","REVALIDATED"),b.end("This page could not be found"),null;let d=await u.handle(X,U);a.fetchMetrics=U.renderOpts.fetchMetrics;let f=U.renderOpts.pendingWaitUntil;f&&c.waitUntil&&(c.waitUntil(f),f=void 0);let g=U.renderOpts.collectedTags;if(!J)return await (0,o.I)(V,W,d,f),null;{let a=await d.blob(),b=(0,p.toNodeOutgoingHttpHeaders)(d.headers);g&&(b[r.NEXT_CACHE_TAGS_HEADER]=g),!b["content-type"]&&a.type&&(b["content-type"]=a.type);let c=void 0!==U.renderOpts.collectedRevalidate&&!(U.renderOpts.collectedRevalidate>=r.INFINITE_CACHE)&&U.renderOpts.collectedRevalidate,e=void 0===U.renderOpts.collectedExpire||U.renderOpts.collectedExpire>=r.INFINITE_CACHE?!1!==c&&c>0?y.expireTime:void 0:U.renderOpts.collectedExpire;return{value:{kind:t.CachedRouteKind.APP_ROUTE,status:d.status,body:Buffer.from(await a.arrayBuffer()),headers:b},cacheControl:{revalidate:c,expire:e}}}}catch(b){throw(null==e?void 0:e.isStale)&&await u.onRequestError(a,b,{routerKind:"App Router",routePath:d,routeType:"route",revalidateReason:(0,n.getRevalidateReason)({isStaticGeneration:N,isOnDemandRevalidate:D})},!1,C),b}},Z=async(d,f)=>{try{var g,i;let d=await u.handleResponse({req:a,nextConfig:y,cacheKey:L,routeKind:e.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:B,isRoutePPREnabled:!1,isOnDemandRevalidate:D,revalidateOnlyGenerated:E,responseGenerator:Y,waitUntil:c.waitUntil,isMinimalMode:S});if(!J)return;if((null==d||null==(g=d.value)?void 0:g.kind)!==t.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==d||null==(i=d.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});S||b.setHeader("x-nextjs-cache",D?"REVALIDATED":d.isMiss?"MISS":d.isStale?"STALE":"HIT"),A&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let f=(0,p.fromNodeOutgoingHttpHeaders)(d.value.headers);S&&J||f.delete(r.NEXT_CACHE_TAGS_HEADER),!d.cacheControl||b.getHeader("Cache-Control")||f.get("Cache-Control")||f.set("Cache-Control",(0,q.getCacheControlHeader)(d.cacheControl)),await (0,o.I)(V,W,new Response(d.value.body,{headers:f,status:d.value.status||200}));return}catch(b){if(b instanceof s.NoFallbackError||await u.onRequestError(a,b,{routerKind:"App Router",routePath:I,routeType:"route",revalidateReason:(0,n.getRevalidateReason)({isStaticGeneration:N,isOnDemandRevalidate:D})},!1,C),J)throw b;await (0,o.I)(V,W,new Response(null,{status:500}));return}finally{(()=>{if(!d)return;let a=b.statusCode;d.setAttributes({"http.status_code":a,"next.rsc":!1}),a&&a>=500&&(d.setStatus({code:h.SpanStatusCode.ERROR}),d.setAttribute("error.type",a.toString()));let c=P.getRootSpanAttributes();if(!c)return;if(c.get("next.span_type")!==m.BaseServerSpan.handleRequest)return console.warn(`Unexpected root span type '${c.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let e=c.get("next.route")||I,g=`${O} ${e}`;d.setAttributes({"next.route":e,"http.route":e,"next.span_name":g}),d.updateName(g),f&&f!==d&&(f.setAttribute("http.route",e),f.updateName(g))})()}};if(R&&Q)await Z(Q,void 0);else{let b=P.getActiveScopeSpan();await P.withPropagatedContext(a.headers,()=>P.trace(m.BaseServerSpan.handleRequest,{spanName:`${O} ${d}`,kind:h.SpanKind.SERVER,attributes:{"http.method":O,"http.target":a.url}},a=>Z(a,b)),void 0,!R)}}},3295:a=>{a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},8128:a=>{a.exports=require("next/dist/server/runtime-reacts.external.js")},10846:a=>{a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},19121:a=>{a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},21820:a=>{a.exports=require("os")},28354:a=>{a.exports=require("util")},29021:a=>{a.exports=require("fs")},29294:a=>{a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},33873:a=>{a.exports=require("path")},44870:a=>{a.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},51455:a=>{a.exports=require("node:fs/promises")},55511:a=>{a.exports=require("crypto")},63033:a=>{a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},65742:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.d(b,{Q:()=>t,t:()=>o});var e=c(79646),f=c(29021),g=c(33873),h=c(28354),i=c(75430),j=c(43618),k=c(72498),l=a([i,k]);[i,k]=l.then?(await l)():l;let u=(0,h.promisify)(e.execFile);function m(a){return"project"===a?"project":"global"}function n(a){if(!a.startsWith("npm:"))return;let b=a.slice(4).trim(),c=b.match(/^(@?[^@]+(?:\/[^@]+)?)(?:@(.+))?$/);return{name:c?.[1]??b,spec:b,version:c?.[2]}}function o(a){let b=n(a);return b?null===(0,j.valid)(b.version??""):!!(a.startsWith("git:")||/^(https?|ssh|git):\/\//i.test(a))&&!function(a){let b=a.startsWith("git:")?a.slice(4).trim():a.trim(),c=b.match(/^git@[^:]+:(.+)$/)?.[1];if(c)return c.includes("@");if(b.includes("://"))try{return new URL(b).pathname.replace(/^\/+/,"").includes("@")}catch{return!1}let d=b.indexOf("/");return d>=0&&b.slice(d+1).includes("@")}(a)}function p(a,b,c){let d=n(a.source);return{source:a.source,scope:m(a.scope),displayName:d?.name??a.source,type:d?"npm":"git",state:b,message:c}}async function q(a,b,c){let{stdout:d}=await u(a,b,{cwd:c.cwd,env:c.env?{...process.env,...c.env}:process.env,encoding:"utf8",timeout:1e4});return d}async function r(a,b,c,d){if(!a.installedPath||!(0,f.existsSync)(a.installedPath))return p(a,"error","Package is not installed.");let e=n(a.source);if(!e)return p(a,"unsupported");let[h="npm",...i]=c??[];if(!h)return p(a,"error","Invalid npmCommand.");let k=function(a){let b=JSON.parse((0,f.readFileSync)((0,g.join)(a,"package.json"),"utf8"));if("string"!=typeof b.version||!(0,j.valid)(b.version))throw Error("Installed package version is unavailable.");return b.version}(a.installedPath),l=await d(h,[...i,"view",e.spec,"version","--json"],{cwd:b}),m=e.version?(0,j.validRange)(e.version)??void 0:void 0,o=function(a,b){let c=JSON.parse(a.trim());if("string"==typeof c&&(0,j.valid)(c))return c;if(Array.isArray(c)){let a=c.filter(a=>"string"==typeof a&&null!==(0,j.valid)(a)),d=b?(0,j.maxSatisfying)(a,b):a.sort(j.rcompare)[0];if(d)return d}throw Error("Unexpected response from npm view.")}(l,m);return p(a,(0,j.gt)(o,k)?"update-available":"up-to-date")}async function s(a,b){if(!a.installedPath||!(0,f.existsSync)(a.installedPath))return p(a,"error","Package is not installed.");let c={cwd:a.installedPath,env:{...process.env,GIT_TERMINAL_PROMPT:"0"}},d=(await b("git",["rev-parse","HEAD"],c)).trim(),e=await b("git",["rev-parse","--abbrev-ref","@{upstream}"],c).then(a=>a.trim()).catch(()=>""),g=e.startsWith("origin/")?`refs/heads/${e.slice(7)}`:"HEAD",h=await b("git",["ls-remote","origin",g],c),i=h.match(/^([0-9a-f]{40,64})\s+/m)?.[1];if(!i)throw Error(`Failed to determine remote ${g}.`);return p(a,d===i?"up-to-date":"update-available")}async function t(a,b,c={}){let d=c.packages,e=c.npmCommand;if(!d){let b=(0,i.getAgentDir)(),c=(0,k.Y1)(a,b),f=i.SettingsManager.create(a,b,{projectTrusted:c.trusted});d=new i.DefaultPackageManager({cwd:a,agentDir:b,settingsManager:f}).listConfiguredPackages(),e??=f.getNpmCommand()}let f=d.filter(a=>!b?.source||a.source===b.source&&m(a.scope)===b.scope),g=c.runCommand??q;return Promise.all(f.map(async b=>{if(!o(b.source))return p(b,"unsupported","Pinned or local packages cannot be checked automatically.");if(/^(1|true|yes)$/i.test(process.env.PI_OFFLINE??""))return p(b,"error","Update checks are disabled while PI_OFFLINE=1.");try{return n(b.source)?await r(b,a,e,g):await s(b,g)}catch(a){return p(b,"error",a instanceof Error?a.message:String(a))}}))}d()}catch(a){d(a)}})},72498:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.d(b,{Fk:()=>i,Y1:()=>g,er:()=>h});var e=c(75430),f=a([e]);function g(a,b){if(!(a&&(0,e.hasTrustRequiringProjectResources)(a)))return{requiresTrust:!1,trusted:!0};let c=new e.ProjectTrustStore(b);return{requiresTrust:!0,trusted:!0===c.get(a)}}function h(a,b){let c=g(a,b);return c.requiresTrust?(new e.ProjectTrustStore(b).set(a,!0),{requiresTrust:!0,trusted:!0}):c}function i(a,b){if(!g(a,b).requiresTrust)return;let c=new e.ProjectTrustStore(b);return{resolveProjectTrust:async()=>!0===c.get(a)}}e=(f.then?(await f)():f)[0],d()}catch(a){d(a)}})},73024:a=>{a.exports=require("node:fs")},75430:a=>{a.exports=import("@earendil-works/pi-coding-agent")},76760:a=>{a.exports=require("node:path")},79646:a=>{a.exports=require("child_process")},79748:a=>{a.exports=require("fs/promises")},80481:a=>{a.exports=require("node:readline")},80547:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.d(b,{A$:()=>o,B7:()=>p,mc:()=>n,uK:()=>l.uK,wz:()=>i.wz});var e=c(29021),f=c(21820),g=c(33873),h=c.n(g),i=c(25252),j=c(82536),k=c(40402),l=c(58864),m=a([k]);async function n(){let a=Date.now(),b=globalThis.__piAllowedRootsCache;if(b&&b.expiresAt>a)return b.roots;let c=await (0,k.dQ)(),d=new Set;for(let a of c)a.cwd&&d.add((0,i.Nw)(a.cwd)),a.projectRoot&&d.add((0,i.Nw)(a.projectRoot));try{for(let a of(0,e.readdirSync)((0,f.homedir)()))/^pi-cwd-\d{8}$/.test(a)&&d.add((0,i.Nw)(h().join((0,f.homedir)(),a)))}catch{}for(let a of(0,i.HM)())d.add(a);return globalThis.__piAllowedRootsCache={roots:d,expiresAt:a+5e3},d}function o(a,b){return(0,j.o)(a,b)}function p(a,b){return(0,j.x)(a,b)}k=(m.then?(await m)():m)[0],d()}catch(a){d(a)}})},86439:a=>{a.exports=require("next/dist/shared/lib/no-fallback-error.external")},97982:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.r(b),c.d(b,{POST:()=>i,dynamic:()=>j});var e=c(23211),f=c(80547),g=c(65742),h=a([f,g]);[f,g]=h.then?(await h)():h;let j="force-dynamic";async function i(a){try{let b=await a.json(),c="string"==typeof b.cwd?b.cwd:"";if(!c)return e.NextResponse.json({error:"cwd required"},{status:400});let d=await (0,f.mc)();if(!(0,f.B7)(c,d))return e.NextResponse.json({error:"Access denied"},{status:403});let h="string"==typeof b.source?b.source:void 0,i="global"===b.scope||"project"===b.scope?b.scope:void 0;if(h&&!i||!h&&i)return e.NextResponse.json({error:"source and scope must be provided together"},{status:400});let j=await (0,g.Q)(c,h&&i?{source:h,scope:i}:void 0);if(h&&i&&0===j.length)return e.NextResponse.json({error:"Configured package not found"},{status:404});return e.NextResponse.json({updates:j})}catch(a){return e.NextResponse.json({error:a instanceof Error?a.message:String(a)},{status:500})}}d()}catch(a){d(a)}})}};var b=require("../../../../webpack-runtime.js");b.C(a);var c=b.X(0,[4741,1813,426,3618,5582],()=>b(b.s=2455));module.exports=c})();
1
+ "use strict";(()=>{var a={};a.id=2403,a.ids=[2403],a.modules={261:a=>{a.exports=require("next/dist/shared/lib/router/utils/app-paths")},3295:a=>{a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},8128:a=>{a.exports=require("next/dist/server/runtime-reacts.external.js")},10846:a=>{a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},19121:a=>{a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},21820:a=>{a.exports=require("os")},28354:a=>{a.exports=require("util")},29021:a=>{a.exports=require("fs")},29294:a=>{a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},32351:(a,b,c)=>{c.r(b),c.d(b,{handler:()=>z,patchFetch:()=>y,routeModule:()=>u,serverHooks:()=>x,workAsyncStorage:()=>v,workUnitAsyncStorage:()=>w});var d=c(19225),e=c(84006),f=c(8317),g=c(99373),h=c(34775),i=c(24235),j=c(261),k=c(54365),l=c(90771),m=c(73461),n=c(67798),o=c(92280),p=c(62018),q=c(45696),r=c(47929),s=c(86439),t=c(37527);let u=new d.AppRouteRouteModule({definition:{kind:e.RouteKind.APP_ROUTE,page:"/api/plugins/check/route",pathname:"/api/plugins/check",filename:"route",bundlePath:"app/api/plugins/check/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/home/runner/work/pi-web/pi-web/app/api/plugins/check/route.ts",nextConfigOutput:"",userland:()=>c(97982),...{}}),{workAsyncStorage:v,workUnitAsyncStorage:w,serverHooks:x}=u;function y(){return(0,f.patchFetch)({workAsyncStorage:v,workUnitAsyncStorage:w})}async function z(a,b,c){c.requestMeta&&(0,g.setRequestMeta)(a,c.requestMeta),u.isDev&&(0,g.addRequestMeta)(a,"devRequestTimingInternalsEnd",process.hrtime.bigint());let d="/api/plugins/check/route";"/index"===d&&(d="/");let f=await u.prepare(a,b,{srcPage:d,multiZoneDraftMode:!1});if(!f)return b.statusCode=400,b.end("Bad Request"),null==c.waitUntil||c.waitUntil.call(c,Promise.resolve()),null;let{buildId:v,deploymentId:w,params:x,nextConfig:y,parsedUrl:z,isDraftMode:A,prerenderManifest:B,routerServerContext:C,isOnDemandRevalidate:D,revalidateOnlyGenerated:E,resolvedPathname:F,clientReferenceManifest:G,serverActionsManifest:H}=f,I=(0,j.normalizeAppPath)(d),J=!!(B.dynamicRoutes[I]||B.routes[F]),K=async()=>((null==C?void 0:C.render404)?await C.render404(a,b,z,!1):b.end("This page could not be found"),null);if(J&&!A){let a=!!B.routes[F],b=B.dynamicRoutes[I];if(b&&!1===b.fallback&&!a){if(y.adapterPath)return await K();throw new s.NoFallbackError}}let L=null;!J||u.isDev||A||(L="/index"===(L=F)?"/":L);let M=!0===u.isDev||!J,N=J&&!M;H&&G&&(0,i.setManifestsSingleton)({page:d,clientReferenceManifest:G,serverActionsManifest:H});let O=a.method||"GET",P=(0,h.getTracer)(),Q=P.getActiveScopeSpan(),R=!!(null==C?void 0:C.isWrappedByNextServer),S=!!(0,g.getRequestMeta)(a,"minimalMode"),T=(0,g.getRequestMeta)(a,"incrementalCache")||await u.getIncrementalCache(a,y,B,S);null==T||T.resetRequestCache(),globalThis.__incrementalCache=T;let U={params:x,previewProps:B.preview,renderOpts:{experimental:{authInterrupts:!!y.experimental.authInterrupts,useCacheTimeout:y.experimental.useCacheTimeout},cacheComponents:!!y.cacheComponents,validationLevel:y.experimental.instantInsights.validationLevel,supportsDynamicResponse:M,incrementalCache:T,hmrRefreshHash:(0,g.getRequestMeta)(a,"hmrRefreshHash"),cacheLifeProfiles:y.cacheLife,staticPageGenerationTimeout:y.staticPageGenerationTimeout,waitUntil:c.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:void 0,onInstrumentationRequestError:(b,c,d,e)=>u.onRequestError(a,b,d,e,C)},sharedContext:{buildId:v,deploymentId:w}},V=new k.NodeNextRequest(a),W=new k.NodeNextResponse(b),X=l.NextRequestAdapter.fromNodeNextRequest(V,(0,l.signalFromNodeResponse)(b)),Y=async({previousCacheEntry:e})=>{try{if(!S&&D&&E&&!e)return b.statusCode=404,b.setHeader("x-nextjs-cache","REVALIDATED"),b.end("This page could not be found"),null;let d=await u.handle(X,U);a.fetchMetrics=U.renderOpts.fetchMetrics;let f=U.renderOpts.pendingWaitUntil;f&&c.waitUntil&&(c.waitUntil(f),f=void 0);let g=U.renderOpts.collectedTags;if(!J)return await (0,o.I)(V,W,d,f),null;{let a=await d.blob(),b=(0,p.toNodeOutgoingHttpHeaders)(d.headers);g&&(b[r.NEXT_CACHE_TAGS_HEADER]=g),!b["content-type"]&&a.type&&(b["content-type"]=a.type);let c=void 0!==U.renderOpts.collectedRevalidate&&!(U.renderOpts.collectedRevalidate>=r.INFINITE_CACHE)&&U.renderOpts.collectedRevalidate,e=void 0===U.renderOpts.collectedExpire||U.renderOpts.collectedExpire>=r.INFINITE_CACHE?!1!==c&&c>0?y.expireTime:void 0:U.renderOpts.collectedExpire;return{value:{kind:t.CachedRouteKind.APP_ROUTE,status:d.status,body:Buffer.from(await a.arrayBuffer()),headers:b},cacheControl:{revalidate:c,expire:e}}}}catch(b){throw(null==e?void 0:e.isStale)&&await u.onRequestError(a,b,{routerKind:"App Router",routePath:d,routeType:"route",revalidateReason:(0,n.getRevalidateReason)({isStaticGeneration:N,isOnDemandRevalidate:D})},!1,C),b}},Z=async(d,f)=>{try{var g,i;let d=await u.handleResponse({req:a,nextConfig:y,cacheKey:L,routeKind:e.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:B,isRoutePPREnabled:!1,isOnDemandRevalidate:D,revalidateOnlyGenerated:E,responseGenerator:Y,waitUntil:c.waitUntil,isMinimalMode:S});if(!J)return;if((null==d||null==(g=d.value)?void 0:g.kind)!==t.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==d||null==(i=d.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});S||b.setHeader("x-nextjs-cache",D?"REVALIDATED":d.isMiss?"MISS":d.isStale?"STALE":"HIT"),A&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let f=(0,p.fromNodeOutgoingHttpHeaders)(d.value.headers);S&&J||f.delete(r.NEXT_CACHE_TAGS_HEADER),!d.cacheControl||b.getHeader("Cache-Control")||f.get("Cache-Control")||f.set("Cache-Control",(0,q.getCacheControlHeader)(d.cacheControl)),await (0,o.I)(V,W,new Response(d.value.body,{headers:f,status:d.value.status||200}));return}catch(b){if(b instanceof s.NoFallbackError||await u.onRequestError(a,b,{routerKind:"App Router",routePath:I,routeType:"route",revalidateReason:(0,n.getRevalidateReason)({isStaticGeneration:N,isOnDemandRevalidate:D})},!1,C),J)throw b;await (0,o.I)(V,W,new Response(null,{status:500}));return}finally{(()=>{if(!d)return;let a=b.statusCode;d.setAttributes({"http.status_code":a,"next.rsc":!1}),a&&a>=500&&(d.setStatus({code:h.SpanStatusCode.ERROR}),d.setAttribute("error.type",a.toString()));let c=P.getRootSpanAttributes();if(!c)return;if(c.get("next.span_type")!==m.BaseServerSpan.handleRequest)return console.warn(`Unexpected root span type '${c.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let e=c.get("next.route")||I,g=`${O} ${e}`;d.setAttributes({"next.route":e,"http.route":e,"next.span_name":g}),d.updateName(g),f&&f!==d&&(f.setAttribute("http.route",e),f.updateName(g))})()}};if(R&&Q)await Z(Q,void 0);else{let b=P.getActiveScopeSpan();await P.withPropagatedContext(a.headers,()=>P.trace(m.BaseServerSpan.handleRequest,{spanName:`${O} ${d}`,kind:h.SpanKind.SERVER,attributes:{"http.method":O,"http.target":a.url}},a=>Z(a,b)),void 0,!R)}}},33873:a=>{a.exports=require("path")},44870:a=>{a.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},51455:a=>{a.exports=require("node:fs/promises")},55511:a=>{a.exports=require("crypto")},63033:a=>{a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},65742:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.d(b,{Q:()=>t,t:()=>o});var e=c(79646),f=c(29021),g=c(33873),h=c(28354),i=c(75430),j=c(43618),k=c(72498),l=a([i,k]);[i,k]=l.then?(await l)():l;let u=(0,h.promisify)(e.execFile);function m(a){return"project"===a?"project":"global"}function n(a){if(!a.startsWith("npm:"))return;let b=a.slice(4).trim(),c=b.match(/^(@?[^@]+(?:\/[^@]+)?)(?:@(.+))?$/);return{name:c?.[1]??b,spec:b,version:c?.[2]}}function o(a){let b=n(a);return b?null===(0,j.valid)(b.version??""):!!(a.startsWith("git:")||/^(https?|ssh|git):\/\//i.test(a))&&!function(a){let b=a.startsWith("git:")?a.slice(4).trim():a.trim(),c=b.match(/^git@[^:]+:(.+)$/)?.[1];if(c)return c.includes("@");if(b.includes("://"))try{return new URL(b).pathname.replace(/^\/+/,"").includes("@")}catch{return!1}let d=b.indexOf("/");return d>=0&&b.slice(d+1).includes("@")}(a)}function p(a,b,c){let d=n(a.source);return{source:a.source,scope:m(a.scope),displayName:d?.name??a.source,type:d?"npm":"git",state:b,message:c}}async function q(a,b,c){let{stdout:d}=await u(a,b,{cwd:c.cwd,env:c.env?{...process.env,...c.env}:process.env,encoding:"utf8",timeout:1e4});return d}async function r(a,b,c,d){if(!a.installedPath||!(0,f.existsSync)(a.installedPath))return p(a,"error","Package is not installed.");let e=n(a.source);if(!e)return p(a,"unsupported");let[h="npm",...i]=c??[];if(!h)return p(a,"error","Invalid npmCommand.");let k=function(a){let b=JSON.parse((0,f.readFileSync)((0,g.join)(a,"package.json"),"utf8"));if("string"!=typeof b.version||!(0,j.valid)(b.version))throw Error("Installed package version is unavailable.");return b.version}(a.installedPath),l=await d(h,[...i,"view",e.spec,"version","--json"],{cwd:b}),m=e.version?(0,j.validRange)(e.version)??void 0:void 0,o=function(a,b){let c=JSON.parse(a.trim());if("string"==typeof c&&(0,j.valid)(c))return c;if(Array.isArray(c)){let a=c.filter(a=>"string"==typeof a&&null!==(0,j.valid)(a)),d=b?(0,j.maxSatisfying)(a,b):a.sort(j.rcompare)[0];if(d)return d}throw Error("Unexpected response from npm view.")}(l,m);return p(a,(0,j.gt)(o,k)?"update-available":"up-to-date")}async function s(a,b){if(!a.installedPath||!(0,f.existsSync)(a.installedPath))return p(a,"error","Package is not installed.");let c={cwd:a.installedPath,env:{...process.env,GIT_TERMINAL_PROMPT:"0"}},d=(await b("git",["rev-parse","HEAD"],c)).trim(),e=await b("git",["rev-parse","--abbrev-ref","@{upstream}"],c).then(a=>a.trim()).catch(()=>""),g=e.startsWith("origin/")?`refs/heads/${e.slice(7)}`:"HEAD",h=await b("git",["ls-remote","origin",g],c),i=h.match(/^([0-9a-f]{40,64})\s+/m)?.[1];if(!i)throw Error(`Failed to determine remote ${g}.`);return p(a,d===i?"up-to-date":"update-available")}async function t(a,b,c={}){let d=c.packages,e=c.npmCommand;if(!d){let b=(0,i.getAgentDir)(),c=(0,k.Y1)(a,b),f=i.SettingsManager.create(a,b,{projectTrusted:c.trusted});d=new i.DefaultPackageManager({cwd:a,agentDir:b,settingsManager:f}).listConfiguredPackages(),e??=f.getNpmCommand()}let f=d.filter(a=>!b?.source||a.source===b.source&&m(a.scope)===b.scope),g=c.runCommand??q;return Promise.all(f.map(async b=>{if(!o(b.source))return p(b,"unsupported","Pinned or local packages cannot be checked automatically.");if(/^(1|true|yes)$/i.test(process.env.PI_OFFLINE??""))return p(b,"error","Update checks are disabled while PI_OFFLINE=1.");try{return n(b.source)?await r(b,a,e,g):await s(b,g)}catch(a){return p(b,"error",a instanceof Error?a.message:String(a))}}))}d()}catch(a){d(a)}})},72498:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.d(b,{Fk:()=>i,Y1:()=>g,er:()=>h});var e=c(75430),f=a([e]);function g(a,b){if(!(a&&(0,e.hasTrustRequiringProjectResources)(a)))return{requiresTrust:!1,trusted:!0};let c=new e.ProjectTrustStore(b);return{requiresTrust:!0,trusted:!0===c.get(a)}}function h(a,b){let c=g(a,b);return c.requiresTrust?(new e.ProjectTrustStore(b).set(a,!0),{requiresTrust:!0,trusted:!0}):c}function i(a,b){if(!g(a,b).requiresTrust)return;let c=new e.ProjectTrustStore(b);return{resolveProjectTrust:async()=>!0===c.get(a)}}e=(f.then?(await f)():f)[0],d()}catch(a){d(a)}})},73024:a=>{a.exports=require("node:fs")},75430:a=>{a.exports=import("@earendil-works/pi-coding-agent")},76760:a=>{a.exports=require("node:path")},79646:a=>{a.exports=require("child_process")},79748:a=>{a.exports=require("fs/promises")},80481:a=>{a.exports=require("node:readline")},80547:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.d(b,{A$:()=>o,B7:()=>p,mc:()=>n,uK:()=>l.uK,wz:()=>i.wz});var e=c(29021),f=c(21820),g=c(33873),h=c.n(g),i=c(25252),j=c(82536),k=c(40402),l=c(58864),m=a([k]);async function n(){let a=Date.now(),b=globalThis.__piAllowedRootsCache;if(b&&b.expiresAt>a)return b.roots;let c=await (0,k.dQ)(),d=new Set;for(let a of c)a.cwd&&d.add((0,i.Nw)(a.cwd)),a.projectRoot&&d.add((0,i.Nw)(a.projectRoot));try{for(let a of(0,e.readdirSync)((0,f.homedir)()))/^pi-cwd-\d{8}$/.test(a)&&d.add((0,i.Nw)(h().join((0,f.homedir)(),a)))}catch{}for(let a of(0,i.HM)())d.add(a);return globalThis.__piAllowedRootsCache={roots:d,expiresAt:a+5e3},d}function o(a,b){return(0,j.o)(a,b)}function p(a,b){return(0,j.x)(a,b)}k=(m.then?(await m)():m)[0],d()}catch(a){d(a)}})},86439:a=>{a.exports=require("next/dist/shared/lib/no-fallback-error.external")},97982:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.r(b),c.d(b,{POST:()=>i,dynamic:()=>j});var e=c(23211),f=c(80547),g=c(65742),h=a([f,g]);[f,g]=h.then?(await h)():h;let j="force-dynamic";async function i(a){try{let b=await a.json(),c="string"==typeof b.cwd?b.cwd:"";if(!c)return e.NextResponse.json({error:"cwd required"},{status:400});let d=await (0,f.mc)();if(!(0,f.B7)(c,d))return e.NextResponse.json({error:"Access denied"},{status:403});let h="string"==typeof b.source?b.source:void 0,i="global"===b.scope||"project"===b.scope?b.scope:void 0;if(h&&!i||!h&&i)return e.NextResponse.json({error:"source and scope must be provided together"},{status:400});let j=await (0,g.Q)(c,h&&i?{source:h,scope:i}:void 0);if(h&&i&&0===j.length)return e.NextResponse.json({error:"Configured package not found"},{status:404});return e.NextResponse.json({updates:j})}catch(a){return e.NextResponse.json({error:a instanceof Error?a.message:String(a)},{status:500})}}d()}catch(a){d(a)}})}};var b=require("../../../../webpack-runtime.js");b.C(a);var c=b.X(0,[4741,1813,426,3618,5582],()=>b(b.s=32351));module.exports=c})();
@@ -1 +1 @@
1
- "use strict";(()=>{var a={};a.id=9742,a.ids=[9742],a.modules={261:a=>{a.exports=require("next/dist/shared/lib/router/utils/app-paths")},3295:a=>{a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},8128:a=>{a.exports=require("next/dist/server/runtime-reacts.external.js")},10846:a=>{a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},19121:a=>{a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},21820:a=>{a.exports=require("os")},28354:a=>{a.exports=require("util")},29021:a=>{a.exports=require("fs")},29294:a=>{a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},32493:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.r(b),c.d(b,{GET:()=>w,POST:()=>x,dynamic:()=>y});var e=c(23211),f=c(29021),g=c(33873),h=c(75430),i=c(80547),j=c(66544),k=c(72498),l=c(65742),m=a([h,i,k,l]);[h,i,k,l]=m.then?(await m)():m;let y="force-dynamic";function n(){return{extensions:0,skills:0,prompts:0,themes:0}}function o(a){return"project"===a?"project":"global"}function p(a,b){return`${b}\0${a}`}function q(a){return"string"==typeof a?a:a.source}function r(a){return"string"!=typeof a&&Array.isArray(a.extensions)&&0===a.extensions.length&&Array.isArray(a.skills)&&0===a.skills.length&&Array.isArray(a.prompts)&&0===a.prompts.length&&Array.isArray(a.themes)&&0===a.themes.length}function s(a,b,c,d){let e="project"===c?a.getProjectSettings().packages??[]:a.getGlobalSettings().packages??[],f=!1,g=e.map(a=>q(a)!==b?a:(f=!0,d)?{..."string"==typeof a?{source:a}:a,extensions:[],skills:[],prompts:[],themes:[]}:q(a));return!!f&&("project"===c?a.setProjectPackages(g):a.setPackages(g),!0)}function t(a,b){var c,d;let e,f;return{kind:b,name:(c=a.path,d=b,e=(0,g.basename)(c),f=(0,g.extname)(e),"skill"===d&&"skill.md"===e.toLowerCase()?(0,g.basename)((0,g.dirname)(c)):("extension"===d||"theme"===d||"prompt"===d)&&f?"extension"===d&&/^index\.(ts|js)$/.test(e)?(0,g.basename)((0,g.dirname)(c)):e.slice(0,-f.length):e),path:a.path,relativePath:function(a){let b=a.metadata.baseDir;if(!b)return a.path;let c=(0,g.relative)(b,a.path);return c&&!c.startsWith("..")?c:a.path}(a)}}function u(a,b,c,d,e){if(!a.enabled||"package"!==a.metadata.origin)return;let f=a.metadata.source,g=o(a.metadata.scope),h=p(f,g),i=c.get(h)??n();i[b]+=1,e[b]+=1,c.set(h,i);let j=d.get(h)??[];j.push(t(a,"extensions"===b?"extension":"skills"===b?"skill":"prompts"===b?"prompt":"theme")),d.set(h,j)}async function v(a){let b=(0,h.getAgentDir)(),c=(0,k.Y1)(a,b),d=h.SettingsManager.create(a,b,{projectTrusted:c.trusted}),e=new h.DefaultPackageManager({cwd:a,agentDir:b,settingsManager:d}),i=[],j=new Map,m=new Map,s=[],v=n(),w=function(a){let b=new Map;for(let c of a.getGlobalSettings().packages??[])b.set(p(q(c),"global"),r(c));for(let c of a.getProjectSettings().packages??[])b.set(p(q(c),"project"),r(c));return b}(d);try{let a=await e.resolve(async a=>(i.push({type:"warning",source:a,message:"Package is configured but not installed yet."}),"skip"));({countsByPackage:j,resourcesByPackage:m,standaloneExtensions:s,totals:v}=function(a){let b=new Map,c=new Map,d=n();for(let e of a.extensions)u(e,"extensions",b,c,d);for(let e of a.skills)u(e,"skills",b,c,d);for(let e of a.prompts)u(e,"prompts",b,c,d);for(let e of a.themes)u(e,"themes",b,c,d);let e=a.extensions.filter(a=>"top-level"===a.metadata.origin).map(a=>({...t(a,"extension"),kind:"extension",scope:o(a.metadata.scope),enabled:a.enabled}));return d.extensions+=e.filter(a=>a.enabled).length,{countsByPackage:b,resourcesByPackage:c,standaloneExtensions:e,totals:d}}(a))}catch(a){i.push({type:"error",message:a instanceof Error?a.message:String(a)})}return{packages:e.listConfiguredPackages().map(a=>{let b=o(a.scope),c=p(a.source,b),d=w.get(c)??!1,e=j.get(c)??n(),h=m.get(c)??[],k=e.extensions+e.skills+e.prompts+e.themes,q=function(a){if(!a)return{};try{let b=(0,f.statSync)(a).isDirectory()?(0,g.join)(a,"package.json"):(0,g.join)((0,g.dirname)(a),"package.json");if(!(0,f.existsSync)(b))return{};let c=JSON.parse((0,f.readFileSync)(b,"utf8"));return{packageName:"string"==typeof c.name?c.name:void 0,version:"string"==typeof c.version?c.version:void 0}}catch{return{}}}(a.installedPath);return a.installedPath||i.push({type:"warning",source:a.source,message:"Configured package path was not found."}),{source:a.source,scope:b,canCheckForUpdates:(0,l.t)(a.source),filtered:a.filtered,disabled:d,installedPath:a.installedPath,packageName:q.packageName,version:q.version,configuredVersion:function(a){let b=a.startsWith("npm:")?a.slice(4):void 0;if(b){let a=b.lastIndexOf("@"),c=b.startsWith("@")?b.indexOf("/",1):0;return a>c&&b.slice(a+1)||void 0}if(a.startsWith("git:")||/^[a-z]+:\/\//.test(a)){let b=a.lastIndexOf("@"),c=a.lastIndexOf("/"),d=a.lastIndexOf(":");if(b>Math.max(c,d))return a.slice(b+1)||void 0}}(a.source),counts:e,resources:h,status:d?"disabled":k>0?"loaded":a.installedPath?"installed":"missing"}}),standaloneExtensions:s,totals:v,diagnostics:i,projectResourcesLoaded:c.trusted}}async function w(a){let{searchParams:b}=new URL(a.url),c=b.get("cwd");if(!c)return e.NextResponse.json({error:"cwd required"},{status:400});try{let a=await (0,i.mc)();if(!(0,i.B7)(c,a))return e.NextResponse.json({error:"Access denied"},{status:403});return e.NextResponse.json(await v(c))}catch(a){return e.NextResponse.json({error:String(a)},{status:500})}}async function x(a){if(!(0,j.EN)(a))return e.NextResponse.json({error:"Untrusted API request"},{status:403});if(!(0,j.E2)(a))return e.NextResponse.json({error:"Content-Type must be application/json"},{status:415});try{var b;let c=await a.json();if(!c.cwd)return e.NextResponse.json({error:"cwd required"},{status:400});if(!c.action)return e.NextResponse.json({error:"action required"},{status:400});let d=await (0,i.mc)();if(!(0,i.B7)(c.cwd,d))return e.NextResponse.json({error:"Access denied"},{status:403});let f=(0,h.getAgentDir)(),g=(0,k.Y1)(c.cwd,f),j=h.SettingsManager.create(c.cwd,f,{projectTrusted:g.trusted}),l=(b=c.scope,"project"===b?"project":"global");if("project"===l&&!g.trusted)return e.NextResponse.json({error:"Project resources must be trusted before modifying project plugins"},{status:403});let m=new h.DefaultPackageManager({cwd:c.cwd,agentDir:f,settingsManager:j}),n=c.source?.trim(),o="project"===l;if("install"===c.action){if(!n)return e.NextResponse.json({error:"source required"},{status:400});await m.installAndPersist(n,{local:o})}else if("remove"===c.action){if(!n)return e.NextResponse.json({error:"source required"},{status:400});await m.removeAndPersist(n,{local:o})}else if("update"===c.action){if(!n&&!g.trusted&&m.listConfiguredPackages().some(a=>"project"===a.scope))return e.NextResponse.json({error:"Project resources must be trusted before updating project plugins"},{status:403});await m.update(n)}else if("disable"===c.action){if(!n)return e.NextResponse.json({error:"source required"},{status:400});s(j,n,l,!0),await j.flush()}else{if("enable"!==c.action)return e.NextResponse.json({error:`Unsupported action: ${c.action}`},{status:400});if(!n)return e.NextResponse.json({error:"source required"},{status:400});s(j,n,l,!1),await j.flush()}return e.NextResponse.json(await v(c.cwd))}catch(a){return e.NextResponse.json({error:a instanceof Error?a.message:String(a)},{status:500})}}d()}catch(a){d(a)}})},33873:a=>{a.exports=require("path")},40117:(a,b,c)=>{c.r(b),c.d(b,{handler:()=>z,patchFetch:()=>y,routeModule:()=>u,serverHooks:()=>x,workAsyncStorage:()=>v,workUnitAsyncStorage:()=>w});var d=c(19225),e=c(84006),f=c(8317),g=c(99373),h=c(34775),i=c(24235),j=c(261),k=c(54365),l=c(90771),m=c(73461),n=c(67798),o=c(92280),p=c(62018),q=c(45696),r=c(47929),s=c(86439),t=c(37527);let u=new d.AppRouteRouteModule({definition:{kind:e.RouteKind.APP_ROUTE,page:"/api/plugins/route",pathname:"/api/plugins",filename:"route",bundlePath:"app/api/plugins/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/home/runner/work/pi-web/pi-web/app/api/plugins/route.ts",nextConfigOutput:"",userland:()=>c(32493),...{}}),{workAsyncStorage:v,workUnitAsyncStorage:w,serverHooks:x}=u;function y(){return(0,f.patchFetch)({workAsyncStorage:v,workUnitAsyncStorage:w})}async function z(a,b,c){c.requestMeta&&(0,g.setRequestMeta)(a,c.requestMeta),u.isDev&&(0,g.addRequestMeta)(a,"devRequestTimingInternalsEnd",process.hrtime.bigint());let d="/api/plugins/route";"/index"===d&&(d="/");let f=await u.prepare(a,b,{srcPage:d,multiZoneDraftMode:!1});if(!f)return b.statusCode=400,b.end("Bad Request"),null==c.waitUntil||c.waitUntil.call(c,Promise.resolve()),null;let{buildId:v,deploymentId:w,params:x,nextConfig:y,parsedUrl:z,isDraftMode:A,prerenderManifest:B,routerServerContext:C,isOnDemandRevalidate:D,revalidateOnlyGenerated:E,resolvedPathname:F,clientReferenceManifest:G,serverActionsManifest:H}=f,I=(0,j.normalizeAppPath)(d),J=!!(B.dynamicRoutes[I]||B.routes[F]),K=async()=>((null==C?void 0:C.render404)?await C.render404(a,b,z,!1):b.end("This page could not be found"),null);if(J&&!A){let a=!!B.routes[F],b=B.dynamicRoutes[I];if(b&&!1===b.fallback&&!a){if(y.adapterPath)return await K();throw new s.NoFallbackError}}let L=null;!J||u.isDev||A||(L="/index"===(L=F)?"/":L);let M=!0===u.isDev||!J,N=J&&!M;H&&G&&(0,i.setManifestsSingleton)({page:d,clientReferenceManifest:G,serverActionsManifest:H});let O=a.method||"GET",P=(0,h.getTracer)(),Q=P.getActiveScopeSpan(),R=!!(null==C?void 0:C.isWrappedByNextServer),S=!!(0,g.getRequestMeta)(a,"minimalMode"),T=(0,g.getRequestMeta)(a,"incrementalCache")||await u.getIncrementalCache(a,y,B,S);null==T||T.resetRequestCache(),globalThis.__incrementalCache=T;let U={params:x,previewProps:B.preview,renderOpts:{experimental:{authInterrupts:!!y.experimental.authInterrupts,useCacheTimeout:y.experimental.useCacheTimeout},cacheComponents:!!y.cacheComponents,validationLevel:y.experimental.instantInsights.validationLevel,supportsDynamicResponse:M,incrementalCache:T,hmrRefreshHash:(0,g.getRequestMeta)(a,"hmrRefreshHash"),cacheLifeProfiles:y.cacheLife,staticPageGenerationTimeout:y.staticPageGenerationTimeout,waitUntil:c.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:void 0,onInstrumentationRequestError:(b,c,d,e)=>u.onRequestError(a,b,d,e,C)},sharedContext:{buildId:v,deploymentId:w}},V=new k.NodeNextRequest(a),W=new k.NodeNextResponse(b),X=l.NextRequestAdapter.fromNodeNextRequest(V,(0,l.signalFromNodeResponse)(b)),Y=async({previousCacheEntry:e})=>{try{if(!S&&D&&E&&!e)return b.statusCode=404,b.setHeader("x-nextjs-cache","REVALIDATED"),b.end("This page could not be found"),null;let d=await u.handle(X,U);a.fetchMetrics=U.renderOpts.fetchMetrics;let f=U.renderOpts.pendingWaitUntil;f&&c.waitUntil&&(c.waitUntil(f),f=void 0);let g=U.renderOpts.collectedTags;if(!J)return await (0,o.I)(V,W,d,f),null;{let a=await d.blob(),b=(0,p.toNodeOutgoingHttpHeaders)(d.headers);g&&(b[r.NEXT_CACHE_TAGS_HEADER]=g),!b["content-type"]&&a.type&&(b["content-type"]=a.type);let c=void 0!==U.renderOpts.collectedRevalidate&&!(U.renderOpts.collectedRevalidate>=r.INFINITE_CACHE)&&U.renderOpts.collectedRevalidate,e=void 0===U.renderOpts.collectedExpire||U.renderOpts.collectedExpire>=r.INFINITE_CACHE?!1!==c&&c>0?y.expireTime:void 0:U.renderOpts.collectedExpire;return{value:{kind:t.CachedRouteKind.APP_ROUTE,status:d.status,body:Buffer.from(await a.arrayBuffer()),headers:b},cacheControl:{revalidate:c,expire:e}}}}catch(b){throw(null==e?void 0:e.isStale)&&await u.onRequestError(a,b,{routerKind:"App Router",routePath:d,routeType:"route",revalidateReason:(0,n.getRevalidateReason)({isStaticGeneration:N,isOnDemandRevalidate:D})},!1,C),b}},Z=async(d,f)=>{try{var g,i;let d=await u.handleResponse({req:a,nextConfig:y,cacheKey:L,routeKind:e.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:B,isRoutePPREnabled:!1,isOnDemandRevalidate:D,revalidateOnlyGenerated:E,responseGenerator:Y,waitUntil:c.waitUntil,isMinimalMode:S});if(!J)return;if((null==d||null==(g=d.value)?void 0:g.kind)!==t.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==d||null==(i=d.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});S||b.setHeader("x-nextjs-cache",D?"REVALIDATED":d.isMiss?"MISS":d.isStale?"STALE":"HIT"),A&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let f=(0,p.fromNodeOutgoingHttpHeaders)(d.value.headers);S&&J||f.delete(r.NEXT_CACHE_TAGS_HEADER),!d.cacheControl||b.getHeader("Cache-Control")||f.get("Cache-Control")||f.set("Cache-Control",(0,q.getCacheControlHeader)(d.cacheControl)),await (0,o.I)(V,W,new Response(d.value.body,{headers:f,status:d.value.status||200}));return}catch(b){if(b instanceof s.NoFallbackError||await u.onRequestError(a,b,{routerKind:"App Router",routePath:I,routeType:"route",revalidateReason:(0,n.getRevalidateReason)({isStaticGeneration:N,isOnDemandRevalidate:D})},!1,C),J)throw b;await (0,o.I)(V,W,new Response(null,{status:500}));return}finally{(()=>{if(!d)return;let a=b.statusCode;d.setAttributes({"http.status_code":a,"next.rsc":!1}),a&&a>=500&&(d.setStatus({code:h.SpanStatusCode.ERROR}),d.setAttribute("error.type",a.toString()));let c=P.getRootSpanAttributes();if(!c)return;if(c.get("next.span_type")!==m.BaseServerSpan.handleRequest)return console.warn(`Unexpected root span type '${c.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let e=c.get("next.route")||I,g=`${O} ${e}`;d.setAttributes({"next.route":e,"http.route":e,"next.span_name":g}),d.updateName(g),f&&f!==d&&(f.setAttribute("http.route",e),f.updateName(g))})()}};if(R&&Q)await Z(Q,void 0);else{let b=P.getActiveScopeSpan();await P.withPropagatedContext(a.headers,()=>P.trace(m.BaseServerSpan.handleRequest,{spanName:`${O} ${d}`,kind:h.SpanKind.SERVER,attributes:{"http.method":O,"http.target":a.url}},a=>Z(a,b)),void 0,!R)}}},44870:a=>{a.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},51455:a=>{a.exports=require("node:fs/promises")},55511:a=>{a.exports=require("crypto")},63033:a=>{a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},65742:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.d(b,{Q:()=>t,t:()=>o});var e=c(79646),f=c(29021),g=c(33873),h=c(28354),i=c(75430),j=c(43618),k=c(72498),l=a([i,k]);[i,k]=l.then?(await l)():l;let u=(0,h.promisify)(e.execFile);function m(a){return"project"===a?"project":"global"}function n(a){if(!a.startsWith("npm:"))return;let b=a.slice(4).trim(),c=b.match(/^(@?[^@]+(?:\/[^@]+)?)(?:@(.+))?$/);return{name:c?.[1]??b,spec:b,version:c?.[2]}}function o(a){let b=n(a);return b?null===(0,j.valid)(b.version??""):!!(a.startsWith("git:")||/^(https?|ssh|git):\/\//i.test(a))&&!function(a){let b=a.startsWith("git:")?a.slice(4).trim():a.trim(),c=b.match(/^git@[^:]+:(.+)$/)?.[1];if(c)return c.includes("@");if(b.includes("://"))try{return new URL(b).pathname.replace(/^\/+/,"").includes("@")}catch{return!1}let d=b.indexOf("/");return d>=0&&b.slice(d+1).includes("@")}(a)}function p(a,b,c){let d=n(a.source);return{source:a.source,scope:m(a.scope),displayName:d?.name??a.source,type:d?"npm":"git",state:b,message:c}}async function q(a,b,c){let{stdout:d}=await u(a,b,{cwd:c.cwd,env:c.env?{...process.env,...c.env}:process.env,encoding:"utf8",timeout:1e4});return d}async function r(a,b,c,d){if(!a.installedPath||!(0,f.existsSync)(a.installedPath))return p(a,"error","Package is not installed.");let e=n(a.source);if(!e)return p(a,"unsupported");let[h="npm",...i]=c??[];if(!h)return p(a,"error","Invalid npmCommand.");let k=function(a){let b=JSON.parse((0,f.readFileSync)((0,g.join)(a,"package.json"),"utf8"));if("string"!=typeof b.version||!(0,j.valid)(b.version))throw Error("Installed package version is unavailable.");return b.version}(a.installedPath),l=await d(h,[...i,"view",e.spec,"version","--json"],{cwd:b}),m=e.version?(0,j.validRange)(e.version)??void 0:void 0,o=function(a,b){let c=JSON.parse(a.trim());if("string"==typeof c&&(0,j.valid)(c))return c;if(Array.isArray(c)){let a=c.filter(a=>"string"==typeof a&&null!==(0,j.valid)(a)),d=b?(0,j.maxSatisfying)(a,b):a.sort(j.rcompare)[0];if(d)return d}throw Error("Unexpected response from npm view.")}(l,m);return p(a,(0,j.gt)(o,k)?"update-available":"up-to-date")}async function s(a,b){if(!a.installedPath||!(0,f.existsSync)(a.installedPath))return p(a,"error","Package is not installed.");let c={cwd:a.installedPath,env:{...process.env,GIT_TERMINAL_PROMPT:"0"}},d=(await b("git",["rev-parse","HEAD"],c)).trim(),e=await b("git",["rev-parse","--abbrev-ref","@{upstream}"],c).then(a=>a.trim()).catch(()=>""),g=e.startsWith("origin/")?`refs/heads/${e.slice(7)}`:"HEAD",h=await b("git",["ls-remote","origin",g],c),i=h.match(/^([0-9a-f]{40,64})\s+/m)?.[1];if(!i)throw Error(`Failed to determine remote ${g}.`);return p(a,d===i?"up-to-date":"update-available")}async function t(a,b,c={}){let d=c.packages,e=c.npmCommand;if(!d){let b=(0,i.getAgentDir)(),c=(0,k.Y1)(a,b),f=i.SettingsManager.create(a,b,{projectTrusted:c.trusted});d=new i.DefaultPackageManager({cwd:a,agentDir:b,settingsManager:f}).listConfiguredPackages(),e??=f.getNpmCommand()}let f=d.filter(a=>!b?.source||a.source===b.source&&m(a.scope)===b.scope),g=c.runCommand??q;return Promise.all(f.map(async b=>{if(!o(b.source))return p(b,"unsupported","Pinned or local packages cannot be checked automatically.");if(/^(1|true|yes)$/i.test(process.env.PI_OFFLINE??""))return p(b,"error","Update checks are disabled while PI_OFFLINE=1.");try{return n(b.source)?await r(b,a,e,g):await s(b,g)}catch(a){return p(b,"error",a instanceof Error?a.message:String(a))}}))}d()}catch(a){d(a)}})},66544:(a,b,c)=>{c.d(b,{E2:()=>k,EN:()=>j});var d=c(77030);function e(a){return(a.startsWith("[")&&a.endsWith("]")?a.slice(1,-1):a).toLowerCase().replace(/\.$/,"")}function f(a){if(!a||/[\s/@\\]/.test(a))return null;try{let b=new URL(`http://${a}`);if(b.username||b.password||"/"!==b.pathname||b.search||b.hash)return null;return e(b.hostname)}catch{return null}}function g(a){if(!a||/[\s/@\\]/.test(a))return null;try{let b=new URL(`http://${a}`);if(b.username||b.password||"/"!==b.pathname||b.search||b.hash)return null;let c=e(b.hostname);return b.port?`${c}:${b.port}`:c}catch{return null}}function h(){return[process.env.PI_WEB_HOSTNAME,...process.env.PI_WEB_ALLOWED_HOSTS?.split(",")??[]].filter(a=>!!a?.trim())}function i(a){try{return new URL(a).origin}catch{return null}}function j(a,b=h()){return!!function(a,b=h()){let c=a.headers.get("host"),g=c?f(c):null;return!!g&&(!!("localhost"===g||g.endsWith(".localhost")||(0,d.isIP)(g))||b.some(a=>{let b;return((b=a?.trim())?(0,d.isIP)(b)?e(b):f(b):null)===g}))}(a,b)&&(!!function(a){if("GET"!==a.method||"navigate"!==a.headers.get("sec-fetch-mode")||"document"!==a.headers.get("sec-fetch-dest")||"?1"!==a.headers.get("sec-fetch-user"))return!1;try{return/^\/api\/sessions\/[^/]+\/export$/.test(new URL(a.url).pathname)}catch{return!1}}(a)||!(a.headers.has("origin")||a.headers.has("sec-fetch-site"))||function(a){let b,c,d,e=a.headers.get("origin");if("cross-site"===a.headers.get("sec-fetch-site"))return!1;if(!e)return!0;let f=(b=new URL(a.url),(c=a.headers.get("host"))?i(`${b.protocol}//${c}`):null);if(null!==f&&i(e)===f)return!0;if("same-origin"!==a.headers.get("sec-fetch-site")||!a.headers.get("x-forwarded-proto"))return!1;let h=a.headers.get("host");if(!h)return!1;try{d=new URL(e).host}catch{return!1}let j=g(d);return null!==j&&j===g(h)}(a))}function k(a){let b=a.headers.get("content-type")?.split(";",1)[0]?.trim().toLowerCase();return"application/json"===b||!!(b?.startsWith("application/")&&b.endsWith("+json"))}},72498:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.d(b,{Fk:()=>i,Y1:()=>g,er:()=>h});var e=c(75430),f=a([e]);function g(a,b){if(!(a&&(0,e.hasTrustRequiringProjectResources)(a)))return{requiresTrust:!1,trusted:!0};let c=new e.ProjectTrustStore(b);return{requiresTrust:!0,trusted:!0===c.get(a)}}function h(a,b){let c=g(a,b);return c.requiresTrust?(new e.ProjectTrustStore(b).set(a,!0),{requiresTrust:!0,trusted:!0}):c}function i(a,b){if(!g(a,b).requiresTrust)return;let c=new e.ProjectTrustStore(b);return{resolveProjectTrust:async()=>!0===c.get(a)}}e=(f.then?(await f)():f)[0],d()}catch(a){d(a)}})},73024:a=>{a.exports=require("node:fs")},75430:a=>{a.exports=import("@earendil-works/pi-coding-agent")},76760:a=>{a.exports=require("node:path")},77030:a=>{a.exports=require("node:net")},79646:a=>{a.exports=require("child_process")},79748:a=>{a.exports=require("fs/promises")},80481:a=>{a.exports=require("node:readline")},80547:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.d(b,{A$:()=>o,B7:()=>p,mc:()=>n,uK:()=>l.uK,wz:()=>i.wz});var e=c(29021),f=c(21820),g=c(33873),h=c.n(g),i=c(25252),j=c(82536),k=c(40402),l=c(58864),m=a([k]);async function n(){let a=Date.now(),b=globalThis.__piAllowedRootsCache;if(b&&b.expiresAt>a)return b.roots;let c=await (0,k.dQ)(),d=new Set;for(let a of c)a.cwd&&d.add((0,i.Nw)(a.cwd)),a.projectRoot&&d.add((0,i.Nw)(a.projectRoot));try{for(let a of(0,e.readdirSync)((0,f.homedir)()))/^pi-cwd-\d{8}$/.test(a)&&d.add((0,i.Nw)(h().join((0,f.homedir)(),a)))}catch{}for(let a of(0,i.HM)())d.add(a);return globalThis.__piAllowedRootsCache={roots:d,expiresAt:a+5e3},d}function o(a,b){return(0,j.o)(a,b)}function p(a,b){return(0,j.x)(a,b)}k=(m.then?(await m)():m)[0],d()}catch(a){d(a)}})},86439:a=>{a.exports=require("next/dist/shared/lib/no-fallback-error.external")}};var b=require("../../../webpack-runtime.js");b.C(a);var c=b.X(0,[4741,1813,426,3618,5582],()=>b(b.s=40117));module.exports=c})();
1
+ "use strict";(()=>{var a={};a.id=9742,a.ids=[9742],a.modules={261:a=>{a.exports=require("next/dist/shared/lib/router/utils/app-paths")},3295:a=>{a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},8128:a=>{a.exports=require("next/dist/server/runtime-reacts.external.js")},10846:a=>{a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},19121:a=>{a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},21820:a=>{a.exports=require("os")},25593:(a,b,c)=>{c.r(b),c.d(b,{handler:()=>z,patchFetch:()=>y,routeModule:()=>u,serverHooks:()=>x,workAsyncStorage:()=>v,workUnitAsyncStorage:()=>w});var d=c(19225),e=c(84006),f=c(8317),g=c(99373),h=c(34775),i=c(24235),j=c(261),k=c(54365),l=c(90771),m=c(73461),n=c(67798),o=c(92280),p=c(62018),q=c(45696),r=c(47929),s=c(86439),t=c(37527);let u=new d.AppRouteRouteModule({definition:{kind:e.RouteKind.APP_ROUTE,page:"/api/plugins/route",pathname:"/api/plugins",filename:"route",bundlePath:"app/api/plugins/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/home/runner/work/pi-web/pi-web/app/api/plugins/route.ts",nextConfigOutput:"",userland:()=>c(32493),...{}}),{workAsyncStorage:v,workUnitAsyncStorage:w,serverHooks:x}=u;function y(){return(0,f.patchFetch)({workAsyncStorage:v,workUnitAsyncStorage:w})}async function z(a,b,c){c.requestMeta&&(0,g.setRequestMeta)(a,c.requestMeta),u.isDev&&(0,g.addRequestMeta)(a,"devRequestTimingInternalsEnd",process.hrtime.bigint());let d="/api/plugins/route";"/index"===d&&(d="/");let f=await u.prepare(a,b,{srcPage:d,multiZoneDraftMode:!1});if(!f)return b.statusCode=400,b.end("Bad Request"),null==c.waitUntil||c.waitUntil.call(c,Promise.resolve()),null;let{buildId:v,deploymentId:w,params:x,nextConfig:y,parsedUrl:z,isDraftMode:A,prerenderManifest:B,routerServerContext:C,isOnDemandRevalidate:D,revalidateOnlyGenerated:E,resolvedPathname:F,clientReferenceManifest:G,serverActionsManifest:H}=f,I=(0,j.normalizeAppPath)(d),J=!!(B.dynamicRoutes[I]||B.routes[F]),K=async()=>((null==C?void 0:C.render404)?await C.render404(a,b,z,!1):b.end("This page could not be found"),null);if(J&&!A){let a=!!B.routes[F],b=B.dynamicRoutes[I];if(b&&!1===b.fallback&&!a){if(y.adapterPath)return await K();throw new s.NoFallbackError}}let L=null;!J||u.isDev||A||(L="/index"===(L=F)?"/":L);let M=!0===u.isDev||!J,N=J&&!M;H&&G&&(0,i.setManifestsSingleton)({page:d,clientReferenceManifest:G,serverActionsManifest:H});let O=a.method||"GET",P=(0,h.getTracer)(),Q=P.getActiveScopeSpan(),R=!!(null==C?void 0:C.isWrappedByNextServer),S=!!(0,g.getRequestMeta)(a,"minimalMode"),T=(0,g.getRequestMeta)(a,"incrementalCache")||await u.getIncrementalCache(a,y,B,S);null==T||T.resetRequestCache(),globalThis.__incrementalCache=T;let U={params:x,previewProps:B.preview,renderOpts:{experimental:{authInterrupts:!!y.experimental.authInterrupts,useCacheTimeout:y.experimental.useCacheTimeout},cacheComponents:!!y.cacheComponents,validationLevel:y.experimental.instantInsights.validationLevel,supportsDynamicResponse:M,incrementalCache:T,hmrRefreshHash:(0,g.getRequestMeta)(a,"hmrRefreshHash"),cacheLifeProfiles:y.cacheLife,staticPageGenerationTimeout:y.staticPageGenerationTimeout,waitUntil:c.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:void 0,onInstrumentationRequestError:(b,c,d,e)=>u.onRequestError(a,b,d,e,C)},sharedContext:{buildId:v,deploymentId:w}},V=new k.NodeNextRequest(a),W=new k.NodeNextResponse(b),X=l.NextRequestAdapter.fromNodeNextRequest(V,(0,l.signalFromNodeResponse)(b)),Y=async({previousCacheEntry:e})=>{try{if(!S&&D&&E&&!e)return b.statusCode=404,b.setHeader("x-nextjs-cache","REVALIDATED"),b.end("This page could not be found"),null;let d=await u.handle(X,U);a.fetchMetrics=U.renderOpts.fetchMetrics;let f=U.renderOpts.pendingWaitUntil;f&&c.waitUntil&&(c.waitUntil(f),f=void 0);let g=U.renderOpts.collectedTags;if(!J)return await (0,o.I)(V,W,d,f),null;{let a=await d.blob(),b=(0,p.toNodeOutgoingHttpHeaders)(d.headers);g&&(b[r.NEXT_CACHE_TAGS_HEADER]=g),!b["content-type"]&&a.type&&(b["content-type"]=a.type);let c=void 0!==U.renderOpts.collectedRevalidate&&!(U.renderOpts.collectedRevalidate>=r.INFINITE_CACHE)&&U.renderOpts.collectedRevalidate,e=void 0===U.renderOpts.collectedExpire||U.renderOpts.collectedExpire>=r.INFINITE_CACHE?!1!==c&&c>0?y.expireTime:void 0:U.renderOpts.collectedExpire;return{value:{kind:t.CachedRouteKind.APP_ROUTE,status:d.status,body:Buffer.from(await a.arrayBuffer()),headers:b},cacheControl:{revalidate:c,expire:e}}}}catch(b){throw(null==e?void 0:e.isStale)&&await u.onRequestError(a,b,{routerKind:"App Router",routePath:d,routeType:"route",revalidateReason:(0,n.getRevalidateReason)({isStaticGeneration:N,isOnDemandRevalidate:D})},!1,C),b}},Z=async(d,f)=>{try{var g,i;let d=await u.handleResponse({req:a,nextConfig:y,cacheKey:L,routeKind:e.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:B,isRoutePPREnabled:!1,isOnDemandRevalidate:D,revalidateOnlyGenerated:E,responseGenerator:Y,waitUntil:c.waitUntil,isMinimalMode:S});if(!J)return;if((null==d||null==(g=d.value)?void 0:g.kind)!==t.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==d||null==(i=d.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});S||b.setHeader("x-nextjs-cache",D?"REVALIDATED":d.isMiss?"MISS":d.isStale?"STALE":"HIT"),A&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let f=(0,p.fromNodeOutgoingHttpHeaders)(d.value.headers);S&&J||f.delete(r.NEXT_CACHE_TAGS_HEADER),!d.cacheControl||b.getHeader("Cache-Control")||f.get("Cache-Control")||f.set("Cache-Control",(0,q.getCacheControlHeader)(d.cacheControl)),await (0,o.I)(V,W,new Response(d.value.body,{headers:f,status:d.value.status||200}));return}catch(b){if(b instanceof s.NoFallbackError||await u.onRequestError(a,b,{routerKind:"App Router",routePath:I,routeType:"route",revalidateReason:(0,n.getRevalidateReason)({isStaticGeneration:N,isOnDemandRevalidate:D})},!1,C),J)throw b;await (0,o.I)(V,W,new Response(null,{status:500}));return}finally{(()=>{if(!d)return;let a=b.statusCode;d.setAttributes({"http.status_code":a,"next.rsc":!1}),a&&a>=500&&(d.setStatus({code:h.SpanStatusCode.ERROR}),d.setAttribute("error.type",a.toString()));let c=P.getRootSpanAttributes();if(!c)return;if(c.get("next.span_type")!==m.BaseServerSpan.handleRequest)return console.warn(`Unexpected root span type '${c.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let e=c.get("next.route")||I,g=`${O} ${e}`;d.setAttributes({"next.route":e,"http.route":e,"next.span_name":g}),d.updateName(g),f&&f!==d&&(f.setAttribute("http.route",e),f.updateName(g))})()}};if(R&&Q)await Z(Q,void 0);else{let b=P.getActiveScopeSpan();await P.withPropagatedContext(a.headers,()=>P.trace(m.BaseServerSpan.handleRequest,{spanName:`${O} ${d}`,kind:h.SpanKind.SERVER,attributes:{"http.method":O,"http.target":a.url}},a=>Z(a,b)),void 0,!R)}}},28354:a=>{a.exports=require("util")},29021:a=>{a.exports=require("fs")},29294:a=>{a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},32493:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.r(b),c.d(b,{GET:()=>w,POST:()=>x,dynamic:()=>y});var e=c(23211),f=c(29021),g=c(33873),h=c(75430),i=c(80547),j=c(66544),k=c(72498),l=c(65742),m=a([h,i,k,l]);[h,i,k,l]=m.then?(await m)():m;let y="force-dynamic";function n(){return{extensions:0,skills:0,prompts:0,themes:0}}function o(a){return"project"===a?"project":"global"}function p(a,b){return`${b}\0${a}`}function q(a){return"string"==typeof a?a:a.source}function r(a){return"string"!=typeof a&&Array.isArray(a.extensions)&&0===a.extensions.length&&Array.isArray(a.skills)&&0===a.skills.length&&Array.isArray(a.prompts)&&0===a.prompts.length&&Array.isArray(a.themes)&&0===a.themes.length}function s(a,b,c,d){let e="project"===c?a.getProjectSettings().packages??[]:a.getGlobalSettings().packages??[],f=!1,g=e.map(a=>q(a)!==b?a:(f=!0,d)?{..."string"==typeof a?{source:a}:a,extensions:[],skills:[],prompts:[],themes:[]}:q(a));return!!f&&("project"===c?a.setProjectPackages(g):a.setPackages(g),!0)}function t(a,b){var c,d;let e,f;return{kind:b,name:(c=a.path,d=b,e=(0,g.basename)(c),f=(0,g.extname)(e),"skill"===d&&"skill.md"===e.toLowerCase()?(0,g.basename)((0,g.dirname)(c)):("extension"===d||"theme"===d||"prompt"===d)&&f?"extension"===d&&/^index\.(ts|js)$/.test(e)?(0,g.basename)((0,g.dirname)(c)):e.slice(0,-f.length):e),path:a.path,relativePath:function(a){let b=a.metadata.baseDir;if(!b)return a.path;let c=(0,g.relative)(b,a.path);return c&&!c.startsWith("..")?c:a.path}(a)}}function u(a,b,c,d,e){if(!a.enabled||"package"!==a.metadata.origin)return;let f=a.metadata.source,g=o(a.metadata.scope),h=p(f,g),i=c.get(h)??n();i[b]+=1,e[b]+=1,c.set(h,i);let j=d.get(h)??[];j.push(t(a,"extensions"===b?"extension":"skills"===b?"skill":"prompts"===b?"prompt":"theme")),d.set(h,j)}async function v(a){let b=(0,h.getAgentDir)(),c=(0,k.Y1)(a,b),d=h.SettingsManager.create(a,b,{projectTrusted:c.trusted}),e=new h.DefaultPackageManager({cwd:a,agentDir:b,settingsManager:d}),i=[],j=new Map,m=new Map,s=[],v=n(),w=function(a){let b=new Map;for(let c of a.getGlobalSettings().packages??[])b.set(p(q(c),"global"),r(c));for(let c of a.getProjectSettings().packages??[])b.set(p(q(c),"project"),r(c));return b}(d);try{let a=await e.resolve(async a=>(i.push({type:"warning",source:a,message:"Package is configured but not installed yet."}),"skip"));({countsByPackage:j,resourcesByPackage:m,standaloneExtensions:s,totals:v}=function(a){let b=new Map,c=new Map,d=n();for(let e of a.extensions)u(e,"extensions",b,c,d);for(let e of a.skills)u(e,"skills",b,c,d);for(let e of a.prompts)u(e,"prompts",b,c,d);for(let e of a.themes)u(e,"themes",b,c,d);let e=a.extensions.filter(a=>"top-level"===a.metadata.origin).map(a=>({...t(a,"extension"),kind:"extension",scope:o(a.metadata.scope),enabled:a.enabled}));return d.extensions+=e.filter(a=>a.enabled).length,{countsByPackage:b,resourcesByPackage:c,standaloneExtensions:e,totals:d}}(a))}catch(a){i.push({type:"error",message:a instanceof Error?a.message:String(a)})}return{packages:e.listConfiguredPackages().map(a=>{let b=o(a.scope),c=p(a.source,b),d=w.get(c)??!1,e=j.get(c)??n(),h=m.get(c)??[],k=e.extensions+e.skills+e.prompts+e.themes,q=function(a){if(!a)return{};try{let b=(0,f.statSync)(a).isDirectory()?(0,g.join)(a,"package.json"):(0,g.join)((0,g.dirname)(a),"package.json");if(!(0,f.existsSync)(b))return{};let c=JSON.parse((0,f.readFileSync)(b,"utf8"));return{packageName:"string"==typeof c.name?c.name:void 0,version:"string"==typeof c.version?c.version:void 0}}catch{return{}}}(a.installedPath);return a.installedPath||i.push({type:"warning",source:a.source,message:"Configured package path was not found."}),{source:a.source,scope:b,canCheckForUpdates:(0,l.t)(a.source),filtered:a.filtered,disabled:d,installedPath:a.installedPath,packageName:q.packageName,version:q.version,configuredVersion:function(a){let b=a.startsWith("npm:")?a.slice(4):void 0;if(b){let a=b.lastIndexOf("@"),c=b.startsWith("@")?b.indexOf("/",1):0;return a>c&&b.slice(a+1)||void 0}if(a.startsWith("git:")||/^[a-z]+:\/\//.test(a)){let b=a.lastIndexOf("@"),c=a.lastIndexOf("/"),d=a.lastIndexOf(":");if(b>Math.max(c,d))return a.slice(b+1)||void 0}}(a.source),counts:e,resources:h,status:d?"disabled":k>0?"loaded":a.installedPath?"installed":"missing"}}),standaloneExtensions:s,totals:v,diagnostics:i,projectResourcesLoaded:c.trusted}}async function w(a){let{searchParams:b}=new URL(a.url),c=b.get("cwd");if(!c)return e.NextResponse.json({error:"cwd required"},{status:400});try{let a=await (0,i.mc)();if(!(0,i.B7)(c,a))return e.NextResponse.json({error:"Access denied"},{status:403});return e.NextResponse.json(await v(c))}catch(a){return e.NextResponse.json({error:String(a)},{status:500})}}async function x(a){if(!(0,j.EN)(a))return e.NextResponse.json({error:"Untrusted API request"},{status:403});if(!(0,j.E2)(a))return e.NextResponse.json({error:"Content-Type must be application/json"},{status:415});try{var b;let c=await a.json();if(!c.cwd)return e.NextResponse.json({error:"cwd required"},{status:400});if(!c.action)return e.NextResponse.json({error:"action required"},{status:400});let d=await (0,i.mc)();if(!(0,i.B7)(c.cwd,d))return e.NextResponse.json({error:"Access denied"},{status:403});let f=(0,h.getAgentDir)(),g=(0,k.Y1)(c.cwd,f),j=h.SettingsManager.create(c.cwd,f,{projectTrusted:g.trusted}),l=(b=c.scope,"project"===b?"project":"global");if("project"===l&&!g.trusted)return e.NextResponse.json({error:"Project resources must be trusted before modifying project plugins"},{status:403});let m=new h.DefaultPackageManager({cwd:c.cwd,agentDir:f,settingsManager:j}),n=c.source?.trim(),o="project"===l;if("install"===c.action){if(!n)return e.NextResponse.json({error:"source required"},{status:400});await m.installAndPersist(n,{local:o})}else if("remove"===c.action){if(!n)return e.NextResponse.json({error:"source required"},{status:400});await m.removeAndPersist(n,{local:o})}else if("update"===c.action){if(!n&&!g.trusted&&m.listConfiguredPackages().some(a=>"project"===a.scope))return e.NextResponse.json({error:"Project resources must be trusted before updating project plugins"},{status:403});await m.update(n)}else if("disable"===c.action){if(!n)return e.NextResponse.json({error:"source required"},{status:400});s(j,n,l,!0),await j.flush()}else{if("enable"!==c.action)return e.NextResponse.json({error:`Unsupported action: ${c.action}`},{status:400});if(!n)return e.NextResponse.json({error:"source required"},{status:400});s(j,n,l,!1),await j.flush()}return e.NextResponse.json(await v(c.cwd))}catch(a){return e.NextResponse.json({error:a instanceof Error?a.message:String(a)},{status:500})}}d()}catch(a){d(a)}})},33873:a=>{a.exports=require("path")},44870:a=>{a.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},51455:a=>{a.exports=require("node:fs/promises")},55511:a=>{a.exports=require("crypto")},63033:a=>{a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},65742:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.d(b,{Q:()=>t,t:()=>o});var e=c(79646),f=c(29021),g=c(33873),h=c(28354),i=c(75430),j=c(43618),k=c(72498),l=a([i,k]);[i,k]=l.then?(await l)():l;let u=(0,h.promisify)(e.execFile);function m(a){return"project"===a?"project":"global"}function n(a){if(!a.startsWith("npm:"))return;let b=a.slice(4).trim(),c=b.match(/^(@?[^@]+(?:\/[^@]+)?)(?:@(.+))?$/);return{name:c?.[1]??b,spec:b,version:c?.[2]}}function o(a){let b=n(a);return b?null===(0,j.valid)(b.version??""):!!(a.startsWith("git:")||/^(https?|ssh|git):\/\//i.test(a))&&!function(a){let b=a.startsWith("git:")?a.slice(4).trim():a.trim(),c=b.match(/^git@[^:]+:(.+)$/)?.[1];if(c)return c.includes("@");if(b.includes("://"))try{return new URL(b).pathname.replace(/^\/+/,"").includes("@")}catch{return!1}let d=b.indexOf("/");return d>=0&&b.slice(d+1).includes("@")}(a)}function p(a,b,c){let d=n(a.source);return{source:a.source,scope:m(a.scope),displayName:d?.name??a.source,type:d?"npm":"git",state:b,message:c}}async function q(a,b,c){let{stdout:d}=await u(a,b,{cwd:c.cwd,env:c.env?{...process.env,...c.env}:process.env,encoding:"utf8",timeout:1e4});return d}async function r(a,b,c,d){if(!a.installedPath||!(0,f.existsSync)(a.installedPath))return p(a,"error","Package is not installed.");let e=n(a.source);if(!e)return p(a,"unsupported");let[h="npm",...i]=c??[];if(!h)return p(a,"error","Invalid npmCommand.");let k=function(a){let b=JSON.parse((0,f.readFileSync)((0,g.join)(a,"package.json"),"utf8"));if("string"!=typeof b.version||!(0,j.valid)(b.version))throw Error("Installed package version is unavailable.");return b.version}(a.installedPath),l=await d(h,[...i,"view",e.spec,"version","--json"],{cwd:b}),m=e.version?(0,j.validRange)(e.version)??void 0:void 0,o=function(a,b){let c=JSON.parse(a.trim());if("string"==typeof c&&(0,j.valid)(c))return c;if(Array.isArray(c)){let a=c.filter(a=>"string"==typeof a&&null!==(0,j.valid)(a)),d=b?(0,j.maxSatisfying)(a,b):a.sort(j.rcompare)[0];if(d)return d}throw Error("Unexpected response from npm view.")}(l,m);return p(a,(0,j.gt)(o,k)?"update-available":"up-to-date")}async function s(a,b){if(!a.installedPath||!(0,f.existsSync)(a.installedPath))return p(a,"error","Package is not installed.");let c={cwd:a.installedPath,env:{...process.env,GIT_TERMINAL_PROMPT:"0"}},d=(await b("git",["rev-parse","HEAD"],c)).trim(),e=await b("git",["rev-parse","--abbrev-ref","@{upstream}"],c).then(a=>a.trim()).catch(()=>""),g=e.startsWith("origin/")?`refs/heads/${e.slice(7)}`:"HEAD",h=await b("git",["ls-remote","origin",g],c),i=h.match(/^([0-9a-f]{40,64})\s+/m)?.[1];if(!i)throw Error(`Failed to determine remote ${g}.`);return p(a,d===i?"up-to-date":"update-available")}async function t(a,b,c={}){let d=c.packages,e=c.npmCommand;if(!d){let b=(0,i.getAgentDir)(),c=(0,k.Y1)(a,b),f=i.SettingsManager.create(a,b,{projectTrusted:c.trusted});d=new i.DefaultPackageManager({cwd:a,agentDir:b,settingsManager:f}).listConfiguredPackages(),e??=f.getNpmCommand()}let f=d.filter(a=>!b?.source||a.source===b.source&&m(a.scope)===b.scope),g=c.runCommand??q;return Promise.all(f.map(async b=>{if(!o(b.source))return p(b,"unsupported","Pinned or local packages cannot be checked automatically.");if(/^(1|true|yes)$/i.test(process.env.PI_OFFLINE??""))return p(b,"error","Update checks are disabled while PI_OFFLINE=1.");try{return n(b.source)?await r(b,a,e,g):await s(b,g)}catch(a){return p(b,"error",a instanceof Error?a.message:String(a))}}))}d()}catch(a){d(a)}})},66544:(a,b,c)=>{c.d(b,{E2:()=>k,EN:()=>j});var d=c(77030);function e(a){return(a.startsWith("[")&&a.endsWith("]")?a.slice(1,-1):a).toLowerCase().replace(/\.$/,"")}function f(a){if(!a||/[\s/@\\]/.test(a))return null;try{let b=new URL(`http://${a}`);if(b.username||b.password||"/"!==b.pathname||b.search||b.hash)return null;return e(b.hostname)}catch{return null}}function g(a){if(!a||/[\s/@\\]/.test(a))return null;try{let b=new URL(`http://${a}`);if(b.username||b.password||"/"!==b.pathname||b.search||b.hash)return null;let c=e(b.hostname);return b.port?`${c}:${b.port}`:c}catch{return null}}function h(){return[process.env.PI_WEB_HOSTNAME,...process.env.PI_WEB_ALLOWED_HOSTS?.split(",")??[]].filter(a=>!!a?.trim())}function i(a){try{return new URL(a).origin}catch{return null}}function j(a,b=h()){return!!function(a,b=h()){let c=a.headers.get("host"),g=c?f(c):null;return!!g&&(!!("localhost"===g||g.endsWith(".localhost")||(0,d.isIP)(g))||b.some(a=>{let b;return((b=a?.trim())?(0,d.isIP)(b)?e(b):f(b):null)===g}))}(a,b)&&(!!function(a){if("GET"!==a.method||"navigate"!==a.headers.get("sec-fetch-mode")||"document"!==a.headers.get("sec-fetch-dest")||"?1"!==a.headers.get("sec-fetch-user"))return!1;try{return/^\/api\/sessions\/[^/]+\/export$/.test(new URL(a.url).pathname)}catch{return!1}}(a)||!(a.headers.has("origin")||a.headers.has("sec-fetch-site"))||function(a){let b,c,d,e=a.headers.get("origin");if("cross-site"===a.headers.get("sec-fetch-site"))return!1;if(!e)return!0;let f=(b=new URL(a.url),(c=a.headers.get("host"))?i(`${b.protocol}//${c}`):null);if(null!==f&&i(e)===f)return!0;if("same-origin"!==a.headers.get("sec-fetch-site")||!a.headers.get("x-forwarded-proto"))return!1;let h=a.headers.get("host");if(!h)return!1;try{d=new URL(e).host}catch{return!1}let j=g(d);return null!==j&&j===g(h)}(a))}function k(a){let b=a.headers.get("content-type")?.split(";",1)[0]?.trim().toLowerCase();return"application/json"===b||!!(b?.startsWith("application/")&&b.endsWith("+json"))}},72498:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.d(b,{Fk:()=>i,Y1:()=>g,er:()=>h});var e=c(75430),f=a([e]);function g(a,b){if(!(a&&(0,e.hasTrustRequiringProjectResources)(a)))return{requiresTrust:!1,trusted:!0};let c=new e.ProjectTrustStore(b);return{requiresTrust:!0,trusted:!0===c.get(a)}}function h(a,b){let c=g(a,b);return c.requiresTrust?(new e.ProjectTrustStore(b).set(a,!0),{requiresTrust:!0,trusted:!0}):c}function i(a,b){if(!g(a,b).requiresTrust)return;let c=new e.ProjectTrustStore(b);return{resolveProjectTrust:async()=>!0===c.get(a)}}e=(f.then?(await f)():f)[0],d()}catch(a){d(a)}})},73024:a=>{a.exports=require("node:fs")},75430:a=>{a.exports=import("@earendil-works/pi-coding-agent")},76760:a=>{a.exports=require("node:path")},77030:a=>{a.exports=require("node:net")},79646:a=>{a.exports=require("child_process")},79748:a=>{a.exports=require("fs/promises")},80481:a=>{a.exports=require("node:readline")},80547:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.d(b,{A$:()=>o,B7:()=>p,mc:()=>n,uK:()=>l.uK,wz:()=>i.wz});var e=c(29021),f=c(21820),g=c(33873),h=c.n(g),i=c(25252),j=c(82536),k=c(40402),l=c(58864),m=a([k]);async function n(){let a=Date.now(),b=globalThis.__piAllowedRootsCache;if(b&&b.expiresAt>a)return b.roots;let c=await (0,k.dQ)(),d=new Set;for(let a of c)a.cwd&&d.add((0,i.Nw)(a.cwd)),a.projectRoot&&d.add((0,i.Nw)(a.projectRoot));try{for(let a of(0,e.readdirSync)((0,f.homedir)()))/^pi-cwd-\d{8}$/.test(a)&&d.add((0,i.Nw)(h().join((0,f.homedir)(),a)))}catch{}for(let a of(0,i.HM)())d.add(a);return globalThis.__piAllowedRootsCache={roots:d,expiresAt:a+5e3},d}function o(a,b){return(0,j.o)(a,b)}function p(a,b){return(0,j.x)(a,b)}k=(m.then?(await m)():m)[0],d()}catch(a){d(a)}})},86439:a=>{a.exports=require("next/dist/shared/lib/no-fallback-error.external")}};var b=require("../../../webpack-runtime.js");b.C(a);var c=b.X(0,[4741,1813,426,3618,5582],()=>b(b.s=25593));module.exports=c})();
@@ -1 +1 @@
1
- "use strict";(()=>{var a={};a.id=1960,a.ids=[1960],a.modules={261:a=>{a.exports=require("next/dist/shared/lib/router/utils/app-paths")},3295:a=>{a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},8128:a=>{a.exports=require("next/dist/server/runtime-reacts.external.js")},10846:a=>{a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},12412:a=>{a.exports=require("assert")},19121:a=>{a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},21820:a=>{a.exports=require("os")},24979:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.r(b),c.d(b,{GET:()=>o,POST:()=>p,dynamic:()=>q});var e=c(79748),f=c(33873),g=c(23211),h=c(75430),i=c(80547),j=c(28967),k=c(72498),l=c(56429),m=a([h,i,k,l]);[h,i,k,l]=m.then?(await m)():m;let q="force-dynamic";async function n(a){if("string"!=typeof a||!a.trim())return{response:g.NextResponse.json({error:"cwd required"},{status:400})};let b=(0,f.resolve)(a);try{if(!(await (0,e.stat)(b)).isDirectory())return{response:g.NextResponse.json({error:"cwd must be a directory"},{status:400})}}catch{return{response:g.NextResponse.json({error:"Directory does not exist"},{status:400})}}let c=await (0,i.mc)();return(0,i.B7)(b,c)?{cwd:b}:{response:g.NextResponse.json({error:"Access denied"},{status:403})}}async function o(a){let b=await n(new URL(a.url).searchParams.get("cwd"));return"response"in b?b.response:g.NextResponse.json((0,k.Y1)(b.cwd,(0,h.getAgentDir)()))}async function p(a){try{let b=await a.json(),c=await n(b.cwd);if("response"in c)return c.response;let d=(0,h.getAgentDir)();if(!(0,k.Y1)(c.cwd,d).requiresTrust)return g.NextResponse.json({error:"This project has no resources that require trust"},{status:409});if((0,l._I)(c.cwd))return g.NextResponse.json({error:"Wait for the active session to finish before trusting this project"},{status:409});let e=(0,k.er)(c.cwd,d);return(0,j.kn)(),await (0,l.oA)(c.cwd),g.NextResponse.json(e)}catch(a){return g.NextResponse.json({error:a instanceof Error?a.message:String(a)},{status:500})}}d()}catch(a){d(a)}})},27910:a=>{a.exports=require("stream")},28354:a=>{a.exports=require("util")},28802:a=>{a.exports=import("@earendil-works/pi-ai")},29021:a=>{a.exports=require("fs")},29294:a=>{a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},29862:a=>{a.exports=import("@earendil-works/pi-tui")},33873:a=>{a.exports=require("path")},44870:a=>{a.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},51181:a=>{a.exports=require("web-push")},51455:a=>{a.exports=require("node:fs/promises")},53321:(a,b,c)=>{c.r(b),c.d(b,{handler:()=>z,patchFetch:()=>y,routeModule:()=>u,serverHooks:()=>x,workAsyncStorage:()=>v,workUnitAsyncStorage:()=>w});var d=c(19225),e=c(84006),f=c(8317),g=c(99373),h=c(34775),i=c(24235),j=c(261),k=c(54365),l=c(90771),m=c(73461),n=c(67798),o=c(92280),p=c(62018),q=c(45696),r=c(47929),s=c(86439),t=c(37527);let u=new d.AppRouteRouteModule({definition:{kind:e.RouteKind.APP_ROUTE,page:"/api/project-trust/route",pathname:"/api/project-trust",filename:"route",bundlePath:"app/api/project-trust/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/home/runner/work/pi-web/pi-web/app/api/project-trust/route.ts",nextConfigOutput:"",userland:()=>c(24979),...{}}),{workAsyncStorage:v,workUnitAsyncStorage:w,serverHooks:x}=u;function y(){return(0,f.patchFetch)({workAsyncStorage:v,workUnitAsyncStorage:w})}async function z(a,b,c){c.requestMeta&&(0,g.setRequestMeta)(a,c.requestMeta),u.isDev&&(0,g.addRequestMeta)(a,"devRequestTimingInternalsEnd",process.hrtime.bigint());let d="/api/project-trust/route";"/index"===d&&(d="/");let f=await u.prepare(a,b,{srcPage:d,multiZoneDraftMode:!1});if(!f)return b.statusCode=400,b.end("Bad Request"),null==c.waitUntil||c.waitUntil.call(c,Promise.resolve()),null;let{buildId:v,deploymentId:w,params:x,nextConfig:y,parsedUrl:z,isDraftMode:A,prerenderManifest:B,routerServerContext:C,isOnDemandRevalidate:D,revalidateOnlyGenerated:E,resolvedPathname:F,clientReferenceManifest:G,serverActionsManifest:H}=f,I=(0,j.normalizeAppPath)(d),J=!!(B.dynamicRoutes[I]||B.routes[F]),K=async()=>((null==C?void 0:C.render404)?await C.render404(a,b,z,!1):b.end("This page could not be found"),null);if(J&&!A){let a=!!B.routes[F],b=B.dynamicRoutes[I];if(b&&!1===b.fallback&&!a){if(y.adapterPath)return await K();throw new s.NoFallbackError}}let L=null;!J||u.isDev||A||(L="/index"===(L=F)?"/":L);let M=!0===u.isDev||!J,N=J&&!M;H&&G&&(0,i.setManifestsSingleton)({page:d,clientReferenceManifest:G,serverActionsManifest:H});let O=a.method||"GET",P=(0,h.getTracer)(),Q=P.getActiveScopeSpan(),R=!!(null==C?void 0:C.isWrappedByNextServer),S=!!(0,g.getRequestMeta)(a,"minimalMode"),T=(0,g.getRequestMeta)(a,"incrementalCache")||await u.getIncrementalCache(a,y,B,S);null==T||T.resetRequestCache(),globalThis.__incrementalCache=T;let U={params:x,previewProps:B.preview,renderOpts:{experimental:{authInterrupts:!!y.experimental.authInterrupts,useCacheTimeout:y.experimental.useCacheTimeout},cacheComponents:!!y.cacheComponents,validationLevel:y.experimental.instantInsights.validationLevel,supportsDynamicResponse:M,incrementalCache:T,hmrRefreshHash:(0,g.getRequestMeta)(a,"hmrRefreshHash"),cacheLifeProfiles:y.cacheLife,staticPageGenerationTimeout:y.staticPageGenerationTimeout,waitUntil:c.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:void 0,onInstrumentationRequestError:(b,c,d,e)=>u.onRequestError(a,b,d,e,C)},sharedContext:{buildId:v,deploymentId:w}},V=new k.NodeNextRequest(a),W=new k.NodeNextResponse(b),X=l.NextRequestAdapter.fromNodeNextRequest(V,(0,l.signalFromNodeResponse)(b)),Y=async({previousCacheEntry:e})=>{try{if(!S&&D&&E&&!e)return b.statusCode=404,b.setHeader("x-nextjs-cache","REVALIDATED"),b.end("This page could not be found"),null;let d=await u.handle(X,U);a.fetchMetrics=U.renderOpts.fetchMetrics;let f=U.renderOpts.pendingWaitUntil;f&&c.waitUntil&&(c.waitUntil(f),f=void 0);let g=U.renderOpts.collectedTags;if(!J)return await (0,o.I)(V,W,d,f),null;{let a=await d.blob(),b=(0,p.toNodeOutgoingHttpHeaders)(d.headers);g&&(b[r.NEXT_CACHE_TAGS_HEADER]=g),!b["content-type"]&&a.type&&(b["content-type"]=a.type);let c=void 0!==U.renderOpts.collectedRevalidate&&!(U.renderOpts.collectedRevalidate>=r.INFINITE_CACHE)&&U.renderOpts.collectedRevalidate,e=void 0===U.renderOpts.collectedExpire||U.renderOpts.collectedExpire>=r.INFINITE_CACHE?!1!==c&&c>0?y.expireTime:void 0:U.renderOpts.collectedExpire;return{value:{kind:t.CachedRouteKind.APP_ROUTE,status:d.status,body:Buffer.from(await a.arrayBuffer()),headers:b},cacheControl:{revalidate:c,expire:e}}}}catch(b){throw(null==e?void 0:e.isStale)&&await u.onRequestError(a,b,{routerKind:"App Router",routePath:d,routeType:"route",revalidateReason:(0,n.getRevalidateReason)({isStaticGeneration:N,isOnDemandRevalidate:D})},!1,C),b}},Z=async(d,f)=>{try{var g,i;let d=await u.handleResponse({req:a,nextConfig:y,cacheKey:L,routeKind:e.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:B,isRoutePPREnabled:!1,isOnDemandRevalidate:D,revalidateOnlyGenerated:E,responseGenerator:Y,waitUntil:c.waitUntil,isMinimalMode:S});if(!J)return;if((null==d||null==(g=d.value)?void 0:g.kind)!==t.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==d||null==(i=d.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});S||b.setHeader("x-nextjs-cache",D?"REVALIDATED":d.isMiss?"MISS":d.isStale?"STALE":"HIT"),A&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let f=(0,p.fromNodeOutgoingHttpHeaders)(d.value.headers);S&&J||f.delete(r.NEXT_CACHE_TAGS_HEADER),!d.cacheControl||b.getHeader("Cache-Control")||f.get("Cache-Control")||f.set("Cache-Control",(0,q.getCacheControlHeader)(d.cacheControl)),await (0,o.I)(V,W,new Response(d.value.body,{headers:f,status:d.value.status||200}));return}catch(b){if(b instanceof s.NoFallbackError||await u.onRequestError(a,b,{routerKind:"App Router",routePath:I,routeType:"route",revalidateReason:(0,n.getRevalidateReason)({isStaticGeneration:N,isOnDemandRevalidate:D})},!1,C),J)throw b;await (0,o.I)(V,W,new Response(null,{status:500}));return}finally{(()=>{if(!d)return;let a=b.statusCode;d.setAttributes({"http.status_code":a,"next.rsc":!1}),a&&a>=500&&(d.setStatus({code:h.SpanStatusCode.ERROR}),d.setAttribute("error.type",a.toString()));let c=P.getRootSpanAttributes();if(!c)return;if(c.get("next.span_type")!==m.BaseServerSpan.handleRequest)return console.warn(`Unexpected root span type '${c.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let e=c.get("next.route")||I,g=`${O} ${e}`;d.setAttributes({"next.route":e,"http.route":e,"next.span_name":g}),d.updateName(g),f&&f!==d&&(f.setAttribute("http.route",e),f.updateName(g))})()}};if(R&&Q)await Z(Q,void 0);else{let b=P.getActiveScopeSpan();await P.withPropagatedContext(a.headers,()=>P.trace(m.BaseServerSpan.handleRequest,{spanName:`${O} ${d}`,kind:h.SpanKind.SERVER,attributes:{"http.method":O,"http.target":a.url}},a=>Z(a,b)),void 0,!R)}}},55511:a=>{a.exports=require("crypto")},63033:a=>{a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},73024:a=>{a.exports=require("node:fs")},75430:a=>{a.exports=import("@earendil-works/pi-coding-agent")},76760:a=>{a.exports=require("node:path")},77598:a=>{a.exports=require("node:crypto")},79646:a=>{a.exports=require("child_process")},79748:a=>{a.exports=require("fs/promises")},80481:a=>{a.exports=require("node:readline")},80547:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.d(b,{A$:()=>o,B7:()=>p,mc:()=>n,uK:()=>l.uK,wz:()=>i.wz});var e=c(29021),f=c(21820),g=c(33873),h=c.n(g),i=c(25252),j=c(82536),k=c(40402),l=c(58864),m=a([k]);async function n(){let a=Date.now(),b=globalThis.__piAllowedRootsCache;if(b&&b.expiresAt>a)return b.roots;let c=await (0,k.dQ)(),d=new Set;for(let a of c)a.cwd&&d.add((0,i.Nw)(a.cwd)),a.projectRoot&&d.add((0,i.Nw)(a.projectRoot));try{for(let a of(0,e.readdirSync)((0,f.homedir)()))/^pi-cwd-\d{8}$/.test(a)&&d.add((0,i.Nw)(h().join((0,f.homedir)(),a)))}catch{}for(let a of(0,i.HM)())d.add(a);return globalThis.__piAllowedRootsCache={roots:d,expiresAt:a+5e3},d}function o(a,b){return(0,j.o)(a,b)}function p(a,b){return(0,j.x)(a,b)}k=(m.then?(await m)():m)[0],d()}catch(a){d(a)}})},81115:a=>{a.exports=require("constants")},86439:a=>{a.exports=require("next/dist/shared/lib/no-fallback-error.external")},94735:a=>{a.exports=require("events")}};var b=require("../../../webpack-runtime.js");b.C(a);var c=b.X(0,[4741,1813,426,974,5582,2243,6429],()=>b(b.s=53321));module.exports=c})();
1
+ "use strict";(()=>{var a={};a.id=1960,a.ids=[1960],a.modules={261:a=>{a.exports=require("next/dist/shared/lib/router/utils/app-paths")},3295:a=>{a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},8128:a=>{a.exports=require("next/dist/server/runtime-reacts.external.js")},10846:a=>{a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},12412:a=>{a.exports=require("assert")},19121:a=>{a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},21820:a=>{a.exports=require("os")},24979:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.r(b),c.d(b,{GET:()=>o,POST:()=>p,dynamic:()=>q});var e=c(79748),f=c(33873),g=c(23211),h=c(75430),i=c(80547),j=c(28967),k=c(72498),l=c(56429),m=a([h,i,k,l]);[h,i,k,l]=m.then?(await m)():m;let q="force-dynamic";async function n(a){if("string"!=typeof a||!a.trim())return{response:g.NextResponse.json({error:"cwd required"},{status:400})};let b=(0,f.resolve)(a);try{if(!(await (0,e.stat)(b)).isDirectory())return{response:g.NextResponse.json({error:"cwd must be a directory"},{status:400})}}catch{return{response:g.NextResponse.json({error:"Directory does not exist"},{status:400})}}let c=await (0,i.mc)();return(0,i.B7)(b,c)?{cwd:b}:{response:g.NextResponse.json({error:"Access denied"},{status:403})}}async function o(a){let b=await n(new URL(a.url).searchParams.get("cwd"));return"response"in b?b.response:g.NextResponse.json((0,k.Y1)(b.cwd,(0,h.getAgentDir)()))}async function p(a){try{let b=await a.json(),c=await n(b.cwd);if("response"in c)return c.response;let d=(0,h.getAgentDir)();if(!(0,k.Y1)(c.cwd,d).requiresTrust)return g.NextResponse.json({error:"This project has no resources that require trust"},{status:409});if((0,l._I)(c.cwd))return g.NextResponse.json({error:"Wait for the active session to finish before trusting this project"},{status:409});let e=(0,k.er)(c.cwd,d);return(0,j.kn)(),await (0,l.oA)(c.cwd),g.NextResponse.json(e)}catch(a){return g.NextResponse.json({error:a instanceof Error?a.message:String(a)},{status:500})}}d()}catch(a){d(a)}})},27910:a=>{a.exports=require("stream")},28354:a=>{a.exports=require("util")},28802:a=>{a.exports=import("@earendil-works/pi-ai")},29021:a=>{a.exports=require("fs")},29294:a=>{a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},29862:a=>{a.exports=import("@earendil-works/pi-tui")},33873:a=>{a.exports=require("path")},42333:(a,b,c)=>{c.r(b),c.d(b,{handler:()=>z,patchFetch:()=>y,routeModule:()=>u,serverHooks:()=>x,workAsyncStorage:()=>v,workUnitAsyncStorage:()=>w});var d=c(19225),e=c(84006),f=c(8317),g=c(99373),h=c(34775),i=c(24235),j=c(261),k=c(54365),l=c(90771),m=c(73461),n=c(67798),o=c(92280),p=c(62018),q=c(45696),r=c(47929),s=c(86439),t=c(37527);let u=new d.AppRouteRouteModule({definition:{kind:e.RouteKind.APP_ROUTE,page:"/api/project-trust/route",pathname:"/api/project-trust",filename:"route",bundlePath:"app/api/project-trust/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/home/runner/work/pi-web/pi-web/app/api/project-trust/route.ts",nextConfigOutput:"",userland:()=>c(24979),...{}}),{workAsyncStorage:v,workUnitAsyncStorage:w,serverHooks:x}=u;function y(){return(0,f.patchFetch)({workAsyncStorage:v,workUnitAsyncStorage:w})}async function z(a,b,c){c.requestMeta&&(0,g.setRequestMeta)(a,c.requestMeta),u.isDev&&(0,g.addRequestMeta)(a,"devRequestTimingInternalsEnd",process.hrtime.bigint());let d="/api/project-trust/route";"/index"===d&&(d="/");let f=await u.prepare(a,b,{srcPage:d,multiZoneDraftMode:!1});if(!f)return b.statusCode=400,b.end("Bad Request"),null==c.waitUntil||c.waitUntil.call(c,Promise.resolve()),null;let{buildId:v,deploymentId:w,params:x,nextConfig:y,parsedUrl:z,isDraftMode:A,prerenderManifest:B,routerServerContext:C,isOnDemandRevalidate:D,revalidateOnlyGenerated:E,resolvedPathname:F,clientReferenceManifest:G,serverActionsManifest:H}=f,I=(0,j.normalizeAppPath)(d),J=!!(B.dynamicRoutes[I]||B.routes[F]),K=async()=>((null==C?void 0:C.render404)?await C.render404(a,b,z,!1):b.end("This page could not be found"),null);if(J&&!A){let a=!!B.routes[F],b=B.dynamicRoutes[I];if(b&&!1===b.fallback&&!a){if(y.adapterPath)return await K();throw new s.NoFallbackError}}let L=null;!J||u.isDev||A||(L="/index"===(L=F)?"/":L);let M=!0===u.isDev||!J,N=J&&!M;H&&G&&(0,i.setManifestsSingleton)({page:d,clientReferenceManifest:G,serverActionsManifest:H});let O=a.method||"GET",P=(0,h.getTracer)(),Q=P.getActiveScopeSpan(),R=!!(null==C?void 0:C.isWrappedByNextServer),S=!!(0,g.getRequestMeta)(a,"minimalMode"),T=(0,g.getRequestMeta)(a,"incrementalCache")||await u.getIncrementalCache(a,y,B,S);null==T||T.resetRequestCache(),globalThis.__incrementalCache=T;let U={params:x,previewProps:B.preview,renderOpts:{experimental:{authInterrupts:!!y.experimental.authInterrupts,useCacheTimeout:y.experimental.useCacheTimeout},cacheComponents:!!y.cacheComponents,validationLevel:y.experimental.instantInsights.validationLevel,supportsDynamicResponse:M,incrementalCache:T,hmrRefreshHash:(0,g.getRequestMeta)(a,"hmrRefreshHash"),cacheLifeProfiles:y.cacheLife,staticPageGenerationTimeout:y.staticPageGenerationTimeout,waitUntil:c.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:void 0,onInstrumentationRequestError:(b,c,d,e)=>u.onRequestError(a,b,d,e,C)},sharedContext:{buildId:v,deploymentId:w}},V=new k.NodeNextRequest(a),W=new k.NodeNextResponse(b),X=l.NextRequestAdapter.fromNodeNextRequest(V,(0,l.signalFromNodeResponse)(b)),Y=async({previousCacheEntry:e})=>{try{if(!S&&D&&E&&!e)return b.statusCode=404,b.setHeader("x-nextjs-cache","REVALIDATED"),b.end("This page could not be found"),null;let d=await u.handle(X,U);a.fetchMetrics=U.renderOpts.fetchMetrics;let f=U.renderOpts.pendingWaitUntil;f&&c.waitUntil&&(c.waitUntil(f),f=void 0);let g=U.renderOpts.collectedTags;if(!J)return await (0,o.I)(V,W,d,f),null;{let a=await d.blob(),b=(0,p.toNodeOutgoingHttpHeaders)(d.headers);g&&(b[r.NEXT_CACHE_TAGS_HEADER]=g),!b["content-type"]&&a.type&&(b["content-type"]=a.type);let c=void 0!==U.renderOpts.collectedRevalidate&&!(U.renderOpts.collectedRevalidate>=r.INFINITE_CACHE)&&U.renderOpts.collectedRevalidate,e=void 0===U.renderOpts.collectedExpire||U.renderOpts.collectedExpire>=r.INFINITE_CACHE?!1!==c&&c>0?y.expireTime:void 0:U.renderOpts.collectedExpire;return{value:{kind:t.CachedRouteKind.APP_ROUTE,status:d.status,body:Buffer.from(await a.arrayBuffer()),headers:b},cacheControl:{revalidate:c,expire:e}}}}catch(b){throw(null==e?void 0:e.isStale)&&await u.onRequestError(a,b,{routerKind:"App Router",routePath:d,routeType:"route",revalidateReason:(0,n.getRevalidateReason)({isStaticGeneration:N,isOnDemandRevalidate:D})},!1,C),b}},Z=async(d,f)=>{try{var g,i;let d=await u.handleResponse({req:a,nextConfig:y,cacheKey:L,routeKind:e.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:B,isRoutePPREnabled:!1,isOnDemandRevalidate:D,revalidateOnlyGenerated:E,responseGenerator:Y,waitUntil:c.waitUntil,isMinimalMode:S});if(!J)return;if((null==d||null==(g=d.value)?void 0:g.kind)!==t.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==d||null==(i=d.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});S||b.setHeader("x-nextjs-cache",D?"REVALIDATED":d.isMiss?"MISS":d.isStale?"STALE":"HIT"),A&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let f=(0,p.fromNodeOutgoingHttpHeaders)(d.value.headers);S&&J||f.delete(r.NEXT_CACHE_TAGS_HEADER),!d.cacheControl||b.getHeader("Cache-Control")||f.get("Cache-Control")||f.set("Cache-Control",(0,q.getCacheControlHeader)(d.cacheControl)),await (0,o.I)(V,W,new Response(d.value.body,{headers:f,status:d.value.status||200}));return}catch(b){if(b instanceof s.NoFallbackError||await u.onRequestError(a,b,{routerKind:"App Router",routePath:I,routeType:"route",revalidateReason:(0,n.getRevalidateReason)({isStaticGeneration:N,isOnDemandRevalidate:D})},!1,C),J)throw b;await (0,o.I)(V,W,new Response(null,{status:500}));return}finally{(()=>{if(!d)return;let a=b.statusCode;d.setAttributes({"http.status_code":a,"next.rsc":!1}),a&&a>=500&&(d.setStatus({code:h.SpanStatusCode.ERROR}),d.setAttribute("error.type",a.toString()));let c=P.getRootSpanAttributes();if(!c)return;if(c.get("next.span_type")!==m.BaseServerSpan.handleRequest)return console.warn(`Unexpected root span type '${c.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let e=c.get("next.route")||I,g=`${O} ${e}`;d.setAttributes({"next.route":e,"http.route":e,"next.span_name":g}),d.updateName(g),f&&f!==d&&(f.setAttribute("http.route",e),f.updateName(g))})()}};if(R&&Q)await Z(Q,void 0);else{let b=P.getActiveScopeSpan();await P.withPropagatedContext(a.headers,()=>P.trace(m.BaseServerSpan.handleRequest,{spanName:`${O} ${d}`,kind:h.SpanKind.SERVER,attributes:{"http.method":O,"http.target":a.url}},a=>Z(a,b)),void 0,!R)}}},44870:a=>{a.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},51181:a=>{a.exports=require("web-push")},51455:a=>{a.exports=require("node:fs/promises")},55511:a=>{a.exports=require("crypto")},63033:a=>{a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},73024:a=>{a.exports=require("node:fs")},75430:a=>{a.exports=import("@earendil-works/pi-coding-agent")},76760:a=>{a.exports=require("node:path")},77598:a=>{a.exports=require("node:crypto")},79646:a=>{a.exports=require("child_process")},79748:a=>{a.exports=require("fs/promises")},80481:a=>{a.exports=require("node:readline")},80547:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.d(b,{A$:()=>o,B7:()=>p,mc:()=>n,uK:()=>l.uK,wz:()=>i.wz});var e=c(29021),f=c(21820),g=c(33873),h=c.n(g),i=c(25252),j=c(82536),k=c(40402),l=c(58864),m=a([k]);async function n(){let a=Date.now(),b=globalThis.__piAllowedRootsCache;if(b&&b.expiresAt>a)return b.roots;let c=await (0,k.dQ)(),d=new Set;for(let a of c)a.cwd&&d.add((0,i.Nw)(a.cwd)),a.projectRoot&&d.add((0,i.Nw)(a.projectRoot));try{for(let a of(0,e.readdirSync)((0,f.homedir)()))/^pi-cwd-\d{8}$/.test(a)&&d.add((0,i.Nw)(h().join((0,f.homedir)(),a)))}catch{}for(let a of(0,i.HM)())d.add(a);return globalThis.__piAllowedRootsCache={roots:d,expiresAt:a+5e3},d}function o(a,b){return(0,j.o)(a,b)}function p(a,b){return(0,j.x)(a,b)}k=(m.then?(await m)():m)[0],d()}catch(a){d(a)}})},81115:a=>{a.exports=require("constants")},86439:a=>{a.exports=require("next/dist/shared/lib/no-fallback-error.external")},94735:a=>{a.exports=require("events")}};var b=require("../../../webpack-runtime.js");b.C(a);var c=b.X(0,[4741,1813,426,974,5582,2243,6429],()=>b(b.s=42333));module.exports=c})();
@@ -1 +1 @@
1
- (()=>{var a={};a.id=5322,a.ids=[5322],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},8128:a=>{"use strict";a.exports=require("next/dist/server/runtime-reacts.external.js")},10846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},20869:(a,b,c)=>{"use strict";c.r(b),c.d(b,{handler:()=>z,patchFetch:()=>y,routeModule:()=>u,serverHooks:()=>x,workAsyncStorage:()=>v,workUnitAsyncStorage:()=>w});var d=c(19225),e=c(84006),f=c(8317),g=c(99373),h=c(34775),i=c(24235),j=c(261),k=c(54365),l=c(90771),m=c(73461),n=c(67798),o=c(92280),p=c(62018),q=c(45696),r=c(47929),s=c(86439),t=c(37527);let u=new d.AppRouteRouteModule({definition:{kind:e.RouteKind.APP_ROUTE,page:"/api/provider-usage/query/route",pathname:"/api/provider-usage/query",filename:"route",bundlePath:"app/api/provider-usage/query/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/home/runner/work/pi-web/pi-web/app/api/provider-usage/query/route.ts",nextConfigOutput:"",userland:()=>c(76617),...{}}),{workAsyncStorage:v,workUnitAsyncStorage:w,serverHooks:x}=u;function y(){return(0,f.patchFetch)({workAsyncStorage:v,workUnitAsyncStorage:w})}async function z(a,b,c){c.requestMeta&&(0,g.setRequestMeta)(a,c.requestMeta),u.isDev&&(0,g.addRequestMeta)(a,"devRequestTimingInternalsEnd",process.hrtime.bigint());let d="/api/provider-usage/query/route";"/index"===d&&(d="/");let f=await u.prepare(a,b,{srcPage:d,multiZoneDraftMode:!1});if(!f)return b.statusCode=400,b.end("Bad Request"),null==c.waitUntil||c.waitUntil.call(c,Promise.resolve()),null;let{buildId:v,deploymentId:w,params:x,nextConfig:y,parsedUrl:z,isDraftMode:A,prerenderManifest:B,routerServerContext:C,isOnDemandRevalidate:D,revalidateOnlyGenerated:E,resolvedPathname:F,clientReferenceManifest:G,serverActionsManifest:H}=f,I=(0,j.normalizeAppPath)(d),J=!!(B.dynamicRoutes[I]||B.routes[F]),K=async()=>((null==C?void 0:C.render404)?await C.render404(a,b,z,!1):b.end("This page could not be found"),null);if(J&&!A){let a=!!B.routes[F],b=B.dynamicRoutes[I];if(b&&!1===b.fallback&&!a){if(y.adapterPath)return await K();throw new s.NoFallbackError}}let L=null;!J||u.isDev||A||(L="/index"===(L=F)?"/":L);let M=!0===u.isDev||!J,N=J&&!M;H&&G&&(0,i.setManifestsSingleton)({page:d,clientReferenceManifest:G,serverActionsManifest:H});let O=a.method||"GET",P=(0,h.getTracer)(),Q=P.getActiveScopeSpan(),R=!!(null==C?void 0:C.isWrappedByNextServer),S=!!(0,g.getRequestMeta)(a,"minimalMode"),T=(0,g.getRequestMeta)(a,"incrementalCache")||await u.getIncrementalCache(a,y,B,S);null==T||T.resetRequestCache(),globalThis.__incrementalCache=T;let U={params:x,previewProps:B.preview,renderOpts:{experimental:{authInterrupts:!!y.experimental.authInterrupts,useCacheTimeout:y.experimental.useCacheTimeout},cacheComponents:!!y.cacheComponents,validationLevel:y.experimental.instantInsights.validationLevel,supportsDynamicResponse:M,incrementalCache:T,hmrRefreshHash:(0,g.getRequestMeta)(a,"hmrRefreshHash"),cacheLifeProfiles:y.cacheLife,staticPageGenerationTimeout:y.staticPageGenerationTimeout,waitUntil:c.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:void 0,onInstrumentationRequestError:(b,c,d,e)=>u.onRequestError(a,b,d,e,C)},sharedContext:{buildId:v,deploymentId:w}},V=new k.NodeNextRequest(a),W=new k.NodeNextResponse(b),X=l.NextRequestAdapter.fromNodeNextRequest(V,(0,l.signalFromNodeResponse)(b)),Y=async({previousCacheEntry:e})=>{try{if(!S&&D&&E&&!e)return b.statusCode=404,b.setHeader("x-nextjs-cache","REVALIDATED"),b.end("This page could not be found"),null;let d=await u.handle(X,U);a.fetchMetrics=U.renderOpts.fetchMetrics;let f=U.renderOpts.pendingWaitUntil;f&&c.waitUntil&&(c.waitUntil(f),f=void 0);let g=U.renderOpts.collectedTags;if(!J)return await (0,o.I)(V,W,d,f),null;{let a=await d.blob(),b=(0,p.toNodeOutgoingHttpHeaders)(d.headers);g&&(b[r.NEXT_CACHE_TAGS_HEADER]=g),!b["content-type"]&&a.type&&(b["content-type"]=a.type);let c=void 0!==U.renderOpts.collectedRevalidate&&!(U.renderOpts.collectedRevalidate>=r.INFINITE_CACHE)&&U.renderOpts.collectedRevalidate,e=void 0===U.renderOpts.collectedExpire||U.renderOpts.collectedExpire>=r.INFINITE_CACHE?!1!==c&&c>0?y.expireTime:void 0:U.renderOpts.collectedExpire;return{value:{kind:t.CachedRouteKind.APP_ROUTE,status:d.status,body:Buffer.from(await a.arrayBuffer()),headers:b},cacheControl:{revalidate:c,expire:e}}}}catch(b){throw(null==e?void 0:e.isStale)&&await u.onRequestError(a,b,{routerKind:"App Router",routePath:d,routeType:"route",revalidateReason:(0,n.getRevalidateReason)({isStaticGeneration:N,isOnDemandRevalidate:D})},!1,C),b}},Z=async(d,f)=>{try{var g,i;let d=await u.handleResponse({req:a,nextConfig:y,cacheKey:L,routeKind:e.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:B,isRoutePPREnabled:!1,isOnDemandRevalidate:D,revalidateOnlyGenerated:E,responseGenerator:Y,waitUntil:c.waitUntil,isMinimalMode:S});if(!J)return;if((null==d||null==(g=d.value)?void 0:g.kind)!==t.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==d||null==(i=d.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});S||b.setHeader("x-nextjs-cache",D?"REVALIDATED":d.isMiss?"MISS":d.isStale?"STALE":"HIT"),A&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let f=(0,p.fromNodeOutgoingHttpHeaders)(d.value.headers);S&&J||f.delete(r.NEXT_CACHE_TAGS_HEADER),!d.cacheControl||b.getHeader("Cache-Control")||f.get("Cache-Control")||f.set("Cache-Control",(0,q.getCacheControlHeader)(d.cacheControl)),await (0,o.I)(V,W,new Response(d.value.body,{headers:f,status:d.value.status||200}));return}catch(b){if(b instanceof s.NoFallbackError||await u.onRequestError(a,b,{routerKind:"App Router",routePath:I,routeType:"route",revalidateReason:(0,n.getRevalidateReason)({isStaticGeneration:N,isOnDemandRevalidate:D})},!1,C),J)throw b;await (0,o.I)(V,W,new Response(null,{status:500}));return}finally{(()=>{if(!d)return;let a=b.statusCode;d.setAttributes({"http.status_code":a,"next.rsc":!1}),a&&a>=500&&(d.setStatus({code:h.SpanStatusCode.ERROR}),d.setAttribute("error.type",a.toString()));let c=P.getRootSpanAttributes();if(!c)return;if(c.get("next.span_type")!==m.BaseServerSpan.handleRequest)return console.warn(`Unexpected root span type '${c.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let e=c.get("next.route")||I,g=`${O} ${e}`;d.setAttributes({"next.route":e,"http.route":e,"next.span_name":g}),d.updateName(g),f&&f!==d&&(f.setAttribute("http.route",e),f.updateName(g))})()}};if(R&&Q)await Z(Q,void 0);else{let b=P.getActiveScopeSpan();await P.withPropagatedContext(a.headers,()=>P.trace(m.BaseServerSpan.handleRequest,{spanName:`${O} ${d}`,kind:h.SpanKind.SERVER,attributes:{"http.method":O,"http.target":a.url}},a=>Z(a,b)),void 0,!R)}}},29294:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},30853:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{H5:()=>h,eX:()=>f.e});var e=c(75430),f=c(83202),g=a([e]);e=(g.then?(await g)():g)[0];let t={"openai-codex":"https://chatgpt.com/backend-api/wham/usage",deepseek:"https://api.deepseek.com/user/balance",openrouter:"https://openrouter.ai/api/v1/key",moonshotai:"https://api.moonshot.ai/v1/users/me/balance","moonshotai-cn":"https://api.moonshot.cn/v1/users/me/balance",minimax:"https://api.minimax.io","minimax-cn":"https://api.minimaxi.com","vercel-ai-gateway":"https://ai-gateway.vercel.sh/v1/credits"},u={"openai-codex":"OpenAI Codex",deepseek:"DeepSeek",openrouter:"OpenRouter",moonshotai:"Moonshot AI","moonshotai-cn":"Moonshot AI CN",minimax:"MiniMax","minimax-cn":"MiniMax CN","vercel-ai-gateway":"Vercel AI Gateway"},v={moonshotai:"USD","moonshotai-cn":"CNY",minimax:"USD","minimax-cn":"CNY"};async function h(a){let b,c=await e.ModelRuntime.create({refreshOnCreate:!1}),d=c.getProvider(a);if(!d||!j(a,d.baseUrl))return{providerId:a,status:"query-failed",message:"The provider usage query failed."};try{b=await c.getAuth(a)}catch{return{providerId:a,status:"auth-unavailable",message:"Provider authentication is unavailable."}}if(!b)return{providerId:a,status:"auth-unavailable",message:"Connect this provider before querying usage."};try{let c=await i(a,b.auth),d=Date.now();return{providerId:a,status:"ready",report:function(a,b,c){switch(a){case"openai-codex":return function(a,b){let c=[],d=(a,b,d)=>{for(let[e,f]of[["primary",a.primary_window],["secondary",a.secondary_window]]){let a=m(f),g=o(a?.used_percent);if(void 0===g)continue;let h=o(a?.limit_window_seconds);c.push({id:`${d}:${e}`,label:function(a){if(!a||a<=0)return"Limit";let b=Math.ceil(a/60);return b>=10080?"Weekly":b>=60?`${Math.round(b/60)}h`:`${b}m`}(h),..."codex"===d?{}:{groupLabel:b},used:s(g),remaining:100-s(g),limit:100,unit:"percent",...h&&h>0?{windowMinutes:Math.ceil(h/60)}:{},...void 0!==o(a?.reset_at)?{resetsAt:o(a?.reset_at)}:{}})}},e=m(a.rate_limit);e&&d(e,"Codex","codex"),(Array.isArray(a.additional_rate_limits)?a.additional_rate_limits:[]).forEach((a,b)=>{let c=m(a),e=m(c?.rate_limit);e&&d(e,n(c?.limit_name)??`Limit ${b+1}`,n(c?.metered_feature)??`additional-${b}`)});let f=[],g=m(a.credits);if(g?.unlimited===!0?f.push({id:"credits",label:"Credits",value:"Unlimited"}):void 0!==o(g?.balance)&&f.push({id:"credits",label:"Credits",value:o(g?.balance),unit:"count"}),!c.length&&!f.length)throw Error("Codex returned no usage data.");return{providerId:"openai-codex",providerName:u["openai-codex"],capturedAt:b,buckets:c,metrics:f}}(b,c);case"deepseek":return function(a,b){let c=[{id:"availability",label:"API calls",value:!0===a.is_available?"Available":"Unavailable"}],d=Array.isArray(a.balance_infos)?a.balance_infos:[];for(let a of d){let b=m(a),d=b?.currency==="CNY"||b?.currency==="USD"?b.currency:void 0;if(d)for(let[a,e,f]of[["total","Total balance","total_balance"],["granted","Granted balance","granted_balance"],["topped-up","Topped-up balance","topped_up_balance"]]){let g=r(b?.[f]);void 0!==g&&c.push({id:`${d.toLowerCase()}-${a}`,label:e,value:g,unit:"currency",currency:d})}}if(0===d.length)throw Error("DeepSeek returned no balance data.");return{providerId:"deepseek",providerName:u.deepseek,capturedAt:b,buckets:[],metrics:c}}(b,c);case"openrouter":return function(a,b){let c=m(a.data);if(!c)throw Error("OpenRouter returned no key data.");let d=[],e=p(c.limit),f=p(c.limit_remaining);void 0!==e&&d.push({id:"key-limit",label:"Key limit",limit:e,...void 0!==f?{remaining:f,used:Math.max(0,e-f)}:{},unit:"currency",currency:"USD",...n(c.limit_reset)?{period:n(c.limit_reset)}:{}});let g=[];for(let[a,b,d]of[["daily","Usage today","usage_daily"],["weekly","Usage this week","usage_weekly"],["monthly","Usage this month","usage_monthly"],["total","All-time usage","usage"]]){let e=p(c[d]);void 0!==e&&g.push({id:a,label:b,value:e,unit:"currency",currency:"USD"})}if(!d.length&&!g.length)throw Error("OpenRouter returned no usage data.");return{providerId:"openrouter",providerName:u.openrouter,capturedAt:b,buckets:d,metrics:g}}(b,c);case"vercel-ai-gateway":var d=b,e=c;let f=r(d.balance),g=r(d.total_used);if(void 0===f&&void 0===g)throw Error("Vercel returned no credit data.");return{providerId:"vercel-ai-gateway",providerName:u["vercel-ai-gateway"],capturedAt:e,buckets:[],metrics:[...void 0!==f?[{id:"balance",label:"Credit balance",value:f,unit:"currency",currency:"USD"}]:[],...void 0!==g?[{id:"spent",label:"Lifetime spend",value:g,unit:"currency",currency:"USD"}]:[]]};case"moonshotai":case"moonshotai-cn":var h=a,i=b,j=c;let l=m(i.data);if(0!==i.code||!0!==i.status||!l)throw Error("Moonshot returned an unsuccessful response.");let q=[["available","Available balance",l.available_balance],["voucher","Voucher balance",l.voucher_balance],["cash","Cash balance",l.cash_balance]].flatMap(([a,b,c])=>{let d=o(c);return void 0===d?[]:[{id:String(a),label:String(b),value:String(d),unit:"currency",currency:v[h]}]});if(!q.length)throw Error("Moonshot returned no balance data.");return{providerId:h,providerName:u[h],capturedAt:j,buckets:[],metrics:q};case"minimax":case"minimax-cn":return function(a,b,c){let d=m(b.base_resp);if(d&&0!==d.status_code)throw Error("MiniMax returned an unsuccessful response.");if(Array.isArray(b.model_remains)){let d=[];for(let[a,c]of b.model_remains.entries()){let b=m(c);if(!b)continue;let e=n(b.model_name)??`Quota ${a+1}`;k(d,b,e,"interval","current_interval_remaining_percent","current_interval_usage_count","current_interval_total_count","end_time","start_time"),k(d,b,e,"weekly","current_weekly_remaining_percent","current_weekly_usage_count","current_weekly_total_count","weekly_end_time","weekly_start_time")}if(!d.length)throw Error("MiniMax returned no quota data.");return{providerId:a,providerName:u[a],capturedAt:c,buckets:d,metrics:[]}}let e=[["available","Available balance",b.available_amount],["cash","Cash balance",b.cash_balance],["voucher","Voucher balance",b.voucher_balance],["credit","Credit balance",b.credit_balance]].flatMap(([b,c,d])=>{let e=r(d);return void 0===e?[]:[{id:String(b),label:String(c),value:e,unit:"currency",currency:v[a]}]});if(!e.length)throw Error("MiniMax returned no balance data.");return{providerId:a,providerName:u[a],capturedAt:c,buckets:[],metrics:e}}(a,b,c)}}(a,c,d)}}catch{return{providerId:a,status:"query-failed",message:"The provider usage query failed."}}}async function i(a,b){if(b.baseUrl&&!j(a,b.baseUrl))throw Error("A custom provider origin cannot be used for official usage queries.");let c=new Headers;for(let[a,d]of Object.entries(b.headers??{}))"string"==typeof d&&c.set(a,d);!c.has("authorization")&&b.apiKey&&c.set("Authorization",`Bearer ${b.apiKey}`);let d=t[a];if("minimax"===a||"minimax-cn"===a){var e;let a,f=(e=c.get("authorization"),a=e?.match(/^Bearer\s+(.+)$/i),a?.[1]??b.apiKey);d+=f?.startsWith("sk-api-")?"/account/query_balance":"/v1/token_plan/remains"}let f=await fetch(d,{headers:c,redirect:"error",signal:AbortSignal.timeout(15e3)}),g=await f.text();if(g.length>65536)throw Error("Usage response was too large.");if(!f.ok)throw Error(`Usage endpoint returned ${f.status}.`);let h=JSON.parse(g);if(!l(h))throw Error("Usage response was not an object.");return h}function j(a,b){if(!b)return!1;try{return new URL(b).origin===new URL(t[a]).origin}catch{return!1}}function k(a,b,c,d,e,f,g,h,i){let j=o(b[`${"interval"===d?"current_interval":"current_weekly"}_status`]),k=o(b[h]),l=o(b[i]),m=p(b[e]);if(3===j)return void a.push({id:`${c}:${d}`,label:"weekly"===d?"Weekly":"Rolling",groupLabel:c,remaining:100,unit:"percent",period:"Unlimited"});let n=q(b[g]),r=q(b[f]);if(void 0===n&&void 0===m)return;let t=void 0!==k&&void 0!==l?Math.max(1,Math.round((k-l)/6e4)):void 0,u=void 0!==k?Math.floor(k/1e3):void 0;if(n&&void 0!==r){let b=r;if(void 0!==m){let a=r/n*100,c=(n-r)/n*100;Math.abs(c-m)<Math.abs(a-m)&&(b=n-r)}a.push({id:`${c}:${d}`,label:"weekly"===d?"Weekly":"Rolling",groupLabel:c,used:n-b,remaining:b,limit:n,unit:"count",...t?{windowMinutes:t}:{},...u?{resetsAt:u}:{}});return}a.push({id:`${c}:${d}`,label:"weekly"===d?"Weekly":"Rolling",groupLabel:c,used:100-s(m),remaining:s(m),limit:100,unit:"percent",...t?{windowMinutes:t}:{},...u?{resetsAt:u}:{}})}function l(a){return"object"==typeof a&&null!==a&&!Array.isArray(a)}function m(a){return l(a)?a:void 0}function n(a){if("string"==typeof a)return a.replace(/[\u0000-\u001f\u007f]/gu,"").trim().slice(0,80)||void 0}function o(a){return"number"==typeof a&&Number.isFinite(a)?a:"string"==typeof a&&a.trim()&&Number.isFinite(Number(a))?Number(a):void 0}function p(a){let b=o(a);return void 0!==b&&b>=0?b:void 0}function q(a){let b=p(a);return void 0!==b&&Number.isSafeInteger(b)?b:void 0}function r(a){return"number"==typeof a&&Number.isFinite(a)?String(a):"string"==typeof a&&/^-?(?:0|[1-9]\d*)(?:\.\d+)?$/u.test(a)&&a.length<=64?a:void 0}function s(a){return Math.min(100,Math.max(0,a))}d()}catch(a){d(a)}})},44870:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},66544:(a,b,c)=>{"use strict";c.d(b,{E2:()=>k,EN:()=>j});var d=c(77030);function e(a){return(a.startsWith("[")&&a.endsWith("]")?a.slice(1,-1):a).toLowerCase().replace(/\.$/,"")}function f(a){if(!a||/[\s/@\\]/.test(a))return null;try{let b=new URL(`http://${a}`);if(b.username||b.password||"/"!==b.pathname||b.search||b.hash)return null;return e(b.hostname)}catch{return null}}function g(a){if(!a||/[\s/@\\]/.test(a))return null;try{let b=new URL(`http://${a}`);if(b.username||b.password||"/"!==b.pathname||b.search||b.hash)return null;let c=e(b.hostname);return b.port?`${c}:${b.port}`:c}catch{return null}}function h(){return[process.env.PI_WEB_HOSTNAME,...process.env.PI_WEB_ALLOWED_HOSTS?.split(",")??[]].filter(a=>!!a?.trim())}function i(a){try{return new URL(a).origin}catch{return null}}function j(a,b=h()){return!!function(a,b=h()){let c=a.headers.get("host"),g=c?f(c):null;return!!g&&(!!("localhost"===g||g.endsWith(".localhost")||(0,d.isIP)(g))||b.some(a=>{let b;return((b=a?.trim())?(0,d.isIP)(b)?e(b):f(b):null)===g}))}(a,b)&&(!!function(a){if("GET"!==a.method||"navigate"!==a.headers.get("sec-fetch-mode")||"document"!==a.headers.get("sec-fetch-dest")||"?1"!==a.headers.get("sec-fetch-user"))return!1;try{return/^\/api\/sessions\/[^/]+\/export$/.test(new URL(a.url).pathname)}catch{return!1}}(a)||!(a.headers.has("origin")||a.headers.has("sec-fetch-site"))||function(a){let b,c,d,e=a.headers.get("origin");if("cross-site"===a.headers.get("sec-fetch-site"))return!1;if(!e)return!0;let f=(b=new URL(a.url),(c=a.headers.get("host"))?i(`${b.protocol}//${c}`):null);if(null!==f&&i(e)===f)return!0;if("same-origin"!==a.headers.get("sec-fetch-site")||!a.headers.get("x-forwarded-proto"))return!1;let h=a.headers.get("host");if(!h)return!1;try{d=new URL(e).host}catch{return!1}let j=g(d);return null!==j&&j===g(h)}(a))}function k(a){let b=a.headers.get("content-type")?.split(";",1)[0]?.trim().toLowerCase();return"application/json"===b||!!(b?.startsWith("application/")&&b.endsWith("+json"))}},75430:a=>{"use strict";a.exports=import("@earendil-works/pi-coding-agent")},76617:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.r(b),c.d(b,{POST:()=>i,dynamic:()=>j});var e=c(23211),f=c(66544),g=c(30853),h=a([g]);g=(h.then?(await h)():h)[0];let j="force-dynamic";async function i(a){let b;if(!(0,f.EN)(a))return e.NextResponse.json({error:"Untrusted API request"},{status:403});if(!(0,f.E2)(a))return e.NextResponse.json({error:"Content-Type must be application/json"},{status:415});try{b=await a.json()}catch{return e.NextResponse.json({error:"Invalid JSON"},{status:400})}let c="string"==typeof b.providerId?b.providerId:"";if(!(0,g.eX)(c))return e.NextResponse.json({error:"Unsupported provider"},{status:400});try{let a=await (0,g.H5)(c);return e.NextResponse.json(a)}catch{return e.NextResponse.json({providerId:c,status:"query-failed",message:"The provider usage query failed."})}}d()}catch(a){d(a)}})},77030:a=>{"use strict";a.exports=require("node:net")},78335:()=>{},83202:(a,b,c)=>{"use strict";c.d(b,{e:()=>e});let d=["openai-codex","deepseek","openrouter","moonshotai","moonshotai-cn","minimax","minimax-cn","vercel-ai-gateway"];function e(a){return d.includes(a)}},86439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},96487:()=>{}};var b=require("../../../../webpack-runtime.js");b.C(a);var c=b.X(0,[4741,1813],()=>b(b.s=20869));module.exports=c})();
1
+ (()=>{var a={};a.id=5322,a.ids=[5322],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},8128:a=>{"use strict";a.exports=require("next/dist/server/runtime-reacts.external.js")},10846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},19433:(a,b,c)=>{"use strict";c.r(b),c.d(b,{handler:()=>z,patchFetch:()=>y,routeModule:()=>u,serverHooks:()=>x,workAsyncStorage:()=>v,workUnitAsyncStorage:()=>w});var d=c(19225),e=c(84006),f=c(8317),g=c(99373),h=c(34775),i=c(24235),j=c(261),k=c(54365),l=c(90771),m=c(73461),n=c(67798),o=c(92280),p=c(62018),q=c(45696),r=c(47929),s=c(86439),t=c(37527);let u=new d.AppRouteRouteModule({definition:{kind:e.RouteKind.APP_ROUTE,page:"/api/provider-usage/query/route",pathname:"/api/provider-usage/query",filename:"route",bundlePath:"app/api/provider-usage/query/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/home/runner/work/pi-web/pi-web/app/api/provider-usage/query/route.ts",nextConfigOutput:"",userland:()=>c(76617),...{}}),{workAsyncStorage:v,workUnitAsyncStorage:w,serverHooks:x}=u;function y(){return(0,f.patchFetch)({workAsyncStorage:v,workUnitAsyncStorage:w})}async function z(a,b,c){c.requestMeta&&(0,g.setRequestMeta)(a,c.requestMeta),u.isDev&&(0,g.addRequestMeta)(a,"devRequestTimingInternalsEnd",process.hrtime.bigint());let d="/api/provider-usage/query/route";"/index"===d&&(d="/");let f=await u.prepare(a,b,{srcPage:d,multiZoneDraftMode:!1});if(!f)return b.statusCode=400,b.end("Bad Request"),null==c.waitUntil||c.waitUntil.call(c,Promise.resolve()),null;let{buildId:v,deploymentId:w,params:x,nextConfig:y,parsedUrl:z,isDraftMode:A,prerenderManifest:B,routerServerContext:C,isOnDemandRevalidate:D,revalidateOnlyGenerated:E,resolvedPathname:F,clientReferenceManifest:G,serverActionsManifest:H}=f,I=(0,j.normalizeAppPath)(d),J=!!(B.dynamicRoutes[I]||B.routes[F]),K=async()=>((null==C?void 0:C.render404)?await C.render404(a,b,z,!1):b.end("This page could not be found"),null);if(J&&!A){let a=!!B.routes[F],b=B.dynamicRoutes[I];if(b&&!1===b.fallback&&!a){if(y.adapterPath)return await K();throw new s.NoFallbackError}}let L=null;!J||u.isDev||A||(L="/index"===(L=F)?"/":L);let M=!0===u.isDev||!J,N=J&&!M;H&&G&&(0,i.setManifestsSingleton)({page:d,clientReferenceManifest:G,serverActionsManifest:H});let O=a.method||"GET",P=(0,h.getTracer)(),Q=P.getActiveScopeSpan(),R=!!(null==C?void 0:C.isWrappedByNextServer),S=!!(0,g.getRequestMeta)(a,"minimalMode"),T=(0,g.getRequestMeta)(a,"incrementalCache")||await u.getIncrementalCache(a,y,B,S);null==T||T.resetRequestCache(),globalThis.__incrementalCache=T;let U={params:x,previewProps:B.preview,renderOpts:{experimental:{authInterrupts:!!y.experimental.authInterrupts,useCacheTimeout:y.experimental.useCacheTimeout},cacheComponents:!!y.cacheComponents,validationLevel:y.experimental.instantInsights.validationLevel,supportsDynamicResponse:M,incrementalCache:T,hmrRefreshHash:(0,g.getRequestMeta)(a,"hmrRefreshHash"),cacheLifeProfiles:y.cacheLife,staticPageGenerationTimeout:y.staticPageGenerationTimeout,waitUntil:c.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:void 0,onInstrumentationRequestError:(b,c,d,e)=>u.onRequestError(a,b,d,e,C)},sharedContext:{buildId:v,deploymentId:w}},V=new k.NodeNextRequest(a),W=new k.NodeNextResponse(b),X=l.NextRequestAdapter.fromNodeNextRequest(V,(0,l.signalFromNodeResponse)(b)),Y=async({previousCacheEntry:e})=>{try{if(!S&&D&&E&&!e)return b.statusCode=404,b.setHeader("x-nextjs-cache","REVALIDATED"),b.end("This page could not be found"),null;let d=await u.handle(X,U);a.fetchMetrics=U.renderOpts.fetchMetrics;let f=U.renderOpts.pendingWaitUntil;f&&c.waitUntil&&(c.waitUntil(f),f=void 0);let g=U.renderOpts.collectedTags;if(!J)return await (0,o.I)(V,W,d,f),null;{let a=await d.blob(),b=(0,p.toNodeOutgoingHttpHeaders)(d.headers);g&&(b[r.NEXT_CACHE_TAGS_HEADER]=g),!b["content-type"]&&a.type&&(b["content-type"]=a.type);let c=void 0!==U.renderOpts.collectedRevalidate&&!(U.renderOpts.collectedRevalidate>=r.INFINITE_CACHE)&&U.renderOpts.collectedRevalidate,e=void 0===U.renderOpts.collectedExpire||U.renderOpts.collectedExpire>=r.INFINITE_CACHE?!1!==c&&c>0?y.expireTime:void 0:U.renderOpts.collectedExpire;return{value:{kind:t.CachedRouteKind.APP_ROUTE,status:d.status,body:Buffer.from(await a.arrayBuffer()),headers:b},cacheControl:{revalidate:c,expire:e}}}}catch(b){throw(null==e?void 0:e.isStale)&&await u.onRequestError(a,b,{routerKind:"App Router",routePath:d,routeType:"route",revalidateReason:(0,n.getRevalidateReason)({isStaticGeneration:N,isOnDemandRevalidate:D})},!1,C),b}},Z=async(d,f)=>{try{var g,i;let d=await u.handleResponse({req:a,nextConfig:y,cacheKey:L,routeKind:e.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:B,isRoutePPREnabled:!1,isOnDemandRevalidate:D,revalidateOnlyGenerated:E,responseGenerator:Y,waitUntil:c.waitUntil,isMinimalMode:S});if(!J)return;if((null==d||null==(g=d.value)?void 0:g.kind)!==t.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==d||null==(i=d.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});S||b.setHeader("x-nextjs-cache",D?"REVALIDATED":d.isMiss?"MISS":d.isStale?"STALE":"HIT"),A&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let f=(0,p.fromNodeOutgoingHttpHeaders)(d.value.headers);S&&J||f.delete(r.NEXT_CACHE_TAGS_HEADER),!d.cacheControl||b.getHeader("Cache-Control")||f.get("Cache-Control")||f.set("Cache-Control",(0,q.getCacheControlHeader)(d.cacheControl)),await (0,o.I)(V,W,new Response(d.value.body,{headers:f,status:d.value.status||200}));return}catch(b){if(b instanceof s.NoFallbackError||await u.onRequestError(a,b,{routerKind:"App Router",routePath:I,routeType:"route",revalidateReason:(0,n.getRevalidateReason)({isStaticGeneration:N,isOnDemandRevalidate:D})},!1,C),J)throw b;await (0,o.I)(V,W,new Response(null,{status:500}));return}finally{(()=>{if(!d)return;let a=b.statusCode;d.setAttributes({"http.status_code":a,"next.rsc":!1}),a&&a>=500&&(d.setStatus({code:h.SpanStatusCode.ERROR}),d.setAttribute("error.type",a.toString()));let c=P.getRootSpanAttributes();if(!c)return;if(c.get("next.span_type")!==m.BaseServerSpan.handleRequest)return console.warn(`Unexpected root span type '${c.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let e=c.get("next.route")||I,g=`${O} ${e}`;d.setAttributes({"next.route":e,"http.route":e,"next.span_name":g}),d.updateName(g),f&&f!==d&&(f.setAttribute("http.route",e),f.updateName(g))})()}};if(R&&Q)await Z(Q,void 0);else{let b=P.getActiveScopeSpan();await P.withPropagatedContext(a.headers,()=>P.trace(m.BaseServerSpan.handleRequest,{spanName:`${O} ${d}`,kind:h.SpanKind.SERVER,attributes:{"http.method":O,"http.target":a.url}},a=>Z(a,b)),void 0,!R)}}},29294:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},30853:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{H5:()=>h,eX:()=>f.e});var e=c(75430),f=c(83202),g=a([e]);e=(g.then?(await g)():g)[0];let t={"openai-codex":"https://chatgpt.com/backend-api/wham/usage",deepseek:"https://api.deepseek.com/user/balance",openrouter:"https://openrouter.ai/api/v1/key",moonshotai:"https://api.moonshot.ai/v1/users/me/balance","moonshotai-cn":"https://api.moonshot.cn/v1/users/me/balance",minimax:"https://api.minimax.io","minimax-cn":"https://api.minimaxi.com","vercel-ai-gateway":"https://ai-gateway.vercel.sh/v1/credits"},u={"openai-codex":"OpenAI Codex",deepseek:"DeepSeek",openrouter:"OpenRouter",moonshotai:"Moonshot AI","moonshotai-cn":"Moonshot AI CN",minimax:"MiniMax","minimax-cn":"MiniMax CN","vercel-ai-gateway":"Vercel AI Gateway"},v={moonshotai:"USD","moonshotai-cn":"CNY",minimax:"USD","minimax-cn":"CNY"};async function h(a){let b,c=await e.ModelRuntime.create({refreshOnCreate:!1}),d=c.getProvider(a);if(!d||!j(a,d.baseUrl))return{providerId:a,status:"query-failed",message:"The provider usage query failed."};try{b=await c.getAuth(a)}catch{return{providerId:a,status:"auth-unavailable",message:"Provider authentication is unavailable."}}if(!b)return{providerId:a,status:"auth-unavailable",message:"Connect this provider before querying usage."};try{let c=await i(a,b.auth),d=Date.now();return{providerId:a,status:"ready",report:function(a,b,c){switch(a){case"openai-codex":return function(a,b){let c=[],d=(a,b,d)=>{for(let[e,f]of[["primary",a.primary_window],["secondary",a.secondary_window]]){let a=m(f),g=o(a?.used_percent);if(void 0===g)continue;let h=o(a?.limit_window_seconds);c.push({id:`${d}:${e}`,label:function(a){if(!a||a<=0)return"Limit";let b=Math.ceil(a/60);return b>=10080?"Weekly":b>=60?`${Math.round(b/60)}h`:`${b}m`}(h),..."codex"===d?{}:{groupLabel:b},used:s(g),remaining:100-s(g),limit:100,unit:"percent",...h&&h>0?{windowMinutes:Math.ceil(h/60)}:{},...void 0!==o(a?.reset_at)?{resetsAt:o(a?.reset_at)}:{}})}},e=m(a.rate_limit);e&&d(e,"Codex","codex"),(Array.isArray(a.additional_rate_limits)?a.additional_rate_limits:[]).forEach((a,b)=>{let c=m(a),e=m(c?.rate_limit);e&&d(e,n(c?.limit_name)??`Limit ${b+1}`,n(c?.metered_feature)??`additional-${b}`)});let f=[],g=m(a.credits);if(g?.unlimited===!0?f.push({id:"credits",label:"Credits",value:"Unlimited"}):void 0!==o(g?.balance)&&f.push({id:"credits",label:"Credits",value:o(g?.balance),unit:"count"}),!c.length&&!f.length)throw Error("Codex returned no usage data.");return{providerId:"openai-codex",providerName:u["openai-codex"],capturedAt:b,buckets:c,metrics:f}}(b,c);case"deepseek":return function(a,b){let c=[{id:"availability",label:"API calls",value:!0===a.is_available?"Available":"Unavailable"}],d=Array.isArray(a.balance_infos)?a.balance_infos:[];for(let a of d){let b=m(a),d=b?.currency==="CNY"||b?.currency==="USD"?b.currency:void 0;if(d)for(let[a,e,f]of[["total","Total balance","total_balance"],["granted","Granted balance","granted_balance"],["topped-up","Topped-up balance","topped_up_balance"]]){let g=r(b?.[f]);void 0!==g&&c.push({id:`${d.toLowerCase()}-${a}`,label:e,value:g,unit:"currency",currency:d})}}if(0===d.length)throw Error("DeepSeek returned no balance data.");return{providerId:"deepseek",providerName:u.deepseek,capturedAt:b,buckets:[],metrics:c}}(b,c);case"openrouter":return function(a,b){let c=m(a.data);if(!c)throw Error("OpenRouter returned no key data.");let d=[],e=p(c.limit),f=p(c.limit_remaining);void 0!==e&&d.push({id:"key-limit",label:"Key limit",limit:e,...void 0!==f?{remaining:f,used:Math.max(0,e-f)}:{},unit:"currency",currency:"USD",...n(c.limit_reset)?{period:n(c.limit_reset)}:{}});let g=[];for(let[a,b,d]of[["daily","Usage today","usage_daily"],["weekly","Usage this week","usage_weekly"],["monthly","Usage this month","usage_monthly"],["total","All-time usage","usage"]]){let e=p(c[d]);void 0!==e&&g.push({id:a,label:b,value:e,unit:"currency",currency:"USD"})}if(!d.length&&!g.length)throw Error("OpenRouter returned no usage data.");return{providerId:"openrouter",providerName:u.openrouter,capturedAt:b,buckets:d,metrics:g}}(b,c);case"vercel-ai-gateway":var d=b,e=c;let f=r(d.balance),g=r(d.total_used);if(void 0===f&&void 0===g)throw Error("Vercel returned no credit data.");return{providerId:"vercel-ai-gateway",providerName:u["vercel-ai-gateway"],capturedAt:e,buckets:[],metrics:[...void 0!==f?[{id:"balance",label:"Credit balance",value:f,unit:"currency",currency:"USD"}]:[],...void 0!==g?[{id:"spent",label:"Lifetime spend",value:g,unit:"currency",currency:"USD"}]:[]]};case"moonshotai":case"moonshotai-cn":var h=a,i=b,j=c;let l=m(i.data);if(0!==i.code||!0!==i.status||!l)throw Error("Moonshot returned an unsuccessful response.");let q=[["available","Available balance",l.available_balance],["voucher","Voucher balance",l.voucher_balance],["cash","Cash balance",l.cash_balance]].flatMap(([a,b,c])=>{let d=o(c);return void 0===d?[]:[{id:String(a),label:String(b),value:String(d),unit:"currency",currency:v[h]}]});if(!q.length)throw Error("Moonshot returned no balance data.");return{providerId:h,providerName:u[h],capturedAt:j,buckets:[],metrics:q};case"minimax":case"minimax-cn":return function(a,b,c){let d=m(b.base_resp);if(d&&0!==d.status_code)throw Error("MiniMax returned an unsuccessful response.");if(Array.isArray(b.model_remains)){let d=[];for(let[a,c]of b.model_remains.entries()){let b=m(c);if(!b)continue;let e=n(b.model_name)??`Quota ${a+1}`;k(d,b,e,"interval","current_interval_remaining_percent","current_interval_usage_count","current_interval_total_count","end_time","start_time"),k(d,b,e,"weekly","current_weekly_remaining_percent","current_weekly_usage_count","current_weekly_total_count","weekly_end_time","weekly_start_time")}if(!d.length)throw Error("MiniMax returned no quota data.");return{providerId:a,providerName:u[a],capturedAt:c,buckets:d,metrics:[]}}let e=[["available","Available balance",b.available_amount],["cash","Cash balance",b.cash_balance],["voucher","Voucher balance",b.voucher_balance],["credit","Credit balance",b.credit_balance]].flatMap(([b,c,d])=>{let e=r(d);return void 0===e?[]:[{id:String(b),label:String(c),value:e,unit:"currency",currency:v[a]}]});if(!e.length)throw Error("MiniMax returned no balance data.");return{providerId:a,providerName:u[a],capturedAt:c,buckets:[],metrics:e}}(a,b,c)}}(a,c,d)}}catch{return{providerId:a,status:"query-failed",message:"The provider usage query failed."}}}async function i(a,b){if(b.baseUrl&&!j(a,b.baseUrl))throw Error("A custom provider origin cannot be used for official usage queries.");let c=new Headers;for(let[a,d]of Object.entries(b.headers??{}))"string"==typeof d&&c.set(a,d);!c.has("authorization")&&b.apiKey&&c.set("Authorization",`Bearer ${b.apiKey}`);let d=t[a];if("minimax"===a||"minimax-cn"===a){var e;let a,f=(e=c.get("authorization"),a=e?.match(/^Bearer\s+(.+)$/i),a?.[1]??b.apiKey);d+=f?.startsWith("sk-api-")?"/account/query_balance":"/v1/token_plan/remains"}let f=await fetch(d,{headers:c,redirect:"error",signal:AbortSignal.timeout(15e3)}),g=await f.text();if(g.length>65536)throw Error("Usage response was too large.");if(!f.ok)throw Error(`Usage endpoint returned ${f.status}.`);let h=JSON.parse(g);if(!l(h))throw Error("Usage response was not an object.");return h}function j(a,b){if(!b)return!1;try{return new URL(b).origin===new URL(t[a]).origin}catch{return!1}}function k(a,b,c,d,e,f,g,h,i){let j=o(b[`${"interval"===d?"current_interval":"current_weekly"}_status`]),k=o(b[h]),l=o(b[i]),m=p(b[e]);if(3===j)return void a.push({id:`${c}:${d}`,label:"weekly"===d?"Weekly":"Rolling",groupLabel:c,remaining:100,unit:"percent",period:"Unlimited"});let n=q(b[g]),r=q(b[f]);if(void 0===n&&void 0===m)return;let t=void 0!==k&&void 0!==l?Math.max(1,Math.round((k-l)/6e4)):void 0,u=void 0!==k?Math.floor(k/1e3):void 0;if(n&&void 0!==r){let b=r;if(void 0!==m){let a=r/n*100,c=(n-r)/n*100;Math.abs(c-m)<Math.abs(a-m)&&(b=n-r)}a.push({id:`${c}:${d}`,label:"weekly"===d?"Weekly":"Rolling",groupLabel:c,used:n-b,remaining:b,limit:n,unit:"count",...t?{windowMinutes:t}:{},...u?{resetsAt:u}:{}});return}a.push({id:`${c}:${d}`,label:"weekly"===d?"Weekly":"Rolling",groupLabel:c,used:100-s(m),remaining:s(m),limit:100,unit:"percent",...t?{windowMinutes:t}:{},...u?{resetsAt:u}:{}})}function l(a){return"object"==typeof a&&null!==a&&!Array.isArray(a)}function m(a){return l(a)?a:void 0}function n(a){if("string"==typeof a)return a.replace(/[\u0000-\u001f\u007f]/gu,"").trim().slice(0,80)||void 0}function o(a){return"number"==typeof a&&Number.isFinite(a)?a:"string"==typeof a&&a.trim()&&Number.isFinite(Number(a))?Number(a):void 0}function p(a){let b=o(a);return void 0!==b&&b>=0?b:void 0}function q(a){let b=p(a);return void 0!==b&&Number.isSafeInteger(b)?b:void 0}function r(a){return"number"==typeof a&&Number.isFinite(a)?String(a):"string"==typeof a&&/^-?(?:0|[1-9]\d*)(?:\.\d+)?$/u.test(a)&&a.length<=64?a:void 0}function s(a){return Math.min(100,Math.max(0,a))}d()}catch(a){d(a)}})},44870:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},66544:(a,b,c)=>{"use strict";c.d(b,{E2:()=>k,EN:()=>j});var d=c(77030);function e(a){return(a.startsWith("[")&&a.endsWith("]")?a.slice(1,-1):a).toLowerCase().replace(/\.$/,"")}function f(a){if(!a||/[\s/@\\]/.test(a))return null;try{let b=new URL(`http://${a}`);if(b.username||b.password||"/"!==b.pathname||b.search||b.hash)return null;return e(b.hostname)}catch{return null}}function g(a){if(!a||/[\s/@\\]/.test(a))return null;try{let b=new URL(`http://${a}`);if(b.username||b.password||"/"!==b.pathname||b.search||b.hash)return null;let c=e(b.hostname);return b.port?`${c}:${b.port}`:c}catch{return null}}function h(){return[process.env.PI_WEB_HOSTNAME,...process.env.PI_WEB_ALLOWED_HOSTS?.split(",")??[]].filter(a=>!!a?.trim())}function i(a){try{return new URL(a).origin}catch{return null}}function j(a,b=h()){return!!function(a,b=h()){let c=a.headers.get("host"),g=c?f(c):null;return!!g&&(!!("localhost"===g||g.endsWith(".localhost")||(0,d.isIP)(g))||b.some(a=>{let b;return((b=a?.trim())?(0,d.isIP)(b)?e(b):f(b):null)===g}))}(a,b)&&(!!function(a){if("GET"!==a.method||"navigate"!==a.headers.get("sec-fetch-mode")||"document"!==a.headers.get("sec-fetch-dest")||"?1"!==a.headers.get("sec-fetch-user"))return!1;try{return/^\/api\/sessions\/[^/]+\/export$/.test(new URL(a.url).pathname)}catch{return!1}}(a)||!(a.headers.has("origin")||a.headers.has("sec-fetch-site"))||function(a){let b,c,d,e=a.headers.get("origin");if("cross-site"===a.headers.get("sec-fetch-site"))return!1;if(!e)return!0;let f=(b=new URL(a.url),(c=a.headers.get("host"))?i(`${b.protocol}//${c}`):null);if(null!==f&&i(e)===f)return!0;if("same-origin"!==a.headers.get("sec-fetch-site")||!a.headers.get("x-forwarded-proto"))return!1;let h=a.headers.get("host");if(!h)return!1;try{d=new URL(e).host}catch{return!1}let j=g(d);return null!==j&&j===g(h)}(a))}function k(a){let b=a.headers.get("content-type")?.split(";",1)[0]?.trim().toLowerCase();return"application/json"===b||!!(b?.startsWith("application/")&&b.endsWith("+json"))}},75430:a=>{"use strict";a.exports=import("@earendil-works/pi-coding-agent")},76617:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.r(b),c.d(b,{POST:()=>i,dynamic:()=>j});var e=c(23211),f=c(66544),g=c(30853),h=a([g]);g=(h.then?(await h)():h)[0];let j="force-dynamic";async function i(a){let b;if(!(0,f.EN)(a))return e.NextResponse.json({error:"Untrusted API request"},{status:403});if(!(0,f.E2)(a))return e.NextResponse.json({error:"Content-Type must be application/json"},{status:415});try{b=await a.json()}catch{return e.NextResponse.json({error:"Invalid JSON"},{status:400})}let c="string"==typeof b.providerId?b.providerId:"";if(!(0,g.eX)(c))return e.NextResponse.json({error:"Unsupported provider"},{status:400});try{let a=await (0,g.H5)(c);return e.NextResponse.json(a)}catch{return e.NextResponse.json({providerId:c,status:"query-failed",message:"The provider usage query failed."})}}d()}catch(a){d(a)}})},77030:a=>{"use strict";a.exports=require("node:net")},78335:()=>{},83202:(a,b,c)=>{"use strict";c.d(b,{e:()=>e});let d=["openai-codex","deepseek","openrouter","moonshotai","moonshotai-cn","minimax","minimax-cn","vercel-ai-gateway"];function e(a){return d.includes(a)}},86439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},96487:()=>{}};var b=require("../../../../webpack-runtime.js");b.C(a);var c=b.X(0,[4741,1813],()=>b(b.s=19433));module.exports=c})();