@calmabacus/pi-web 1.2.4 → 1.2.6

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 (263) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-path-routes-manifest.json +11 -10
  3. package/.next/build-manifest.json +3 -3
  4. package/.next/prerender-manifest.json +6 -6
  5. package/.next/required-server-files.js +1 -1
  6. package/.next/required-server-files.json +1 -1
  7. package/.next/routes-manifest.json +6 -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 +4 -4
  19. package/.next/server/app/_not-found.segments/_full.segment.rsc +4 -4
  20. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +8 -9
  21. package/.next/server/app/_not-found.segments/_tree.segment.rsc +3 -3
  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/auth/api-key/[provider]/route.js +1 -1
  30. package/.next/server/app/api/auth/login/[provider]/route.js +2 -2
  31. package/.next/server/app/api/auth/logout/[provider]/route.js +1 -1
  32. package/.next/server/app/api/auth/providers/route.js +1 -1
  33. package/.next/server/app/api/cwd/browse/route.js +1 -1
  34. package/.next/server/app/api/cwd/validate/route.js +1 -1
  35. package/.next/server/app/api/default-cwd/route.js +1 -1
  36. package/.next/server/app/api/file-index/route.js +1 -1
  37. package/.next/server/app/api/files/[...path]/route.js +1 -1
  38. package/.next/server/app/api/git/diff/route.js +2 -2
  39. package/.next/server/app/api/git/status/route.js +1 -1
  40. package/.next/server/app/api/home/route.js +1 -1
  41. package/.next/server/app/api/image-generation/route.js +1 -1
  42. package/.next/server/app/api/image-generation/settings/connections/route.js +1 -1
  43. package/.next/server/app/api/image-generation/settings/route.js +1 -1
  44. package/.next/server/app/api/models/route.js +1 -1
  45. package/.next/server/app/api/models-config/catalog/route.js +1 -1
  46. package/.next/server/app/api/models-config/discover/route.js +1 -1
  47. package/.next/server/app/api/models-config/picker/route.js +1 -1
  48. package/.next/server/app/api/models-config/route.js +1 -1
  49. package/.next/server/app/api/models-config/runtime/route.js +1 -1
  50. package/.next/server/app/api/models-config/test/route.js +1 -1
  51. package/.next/server/app/api/plugins/check/route.js +1 -1
  52. package/.next/server/app/api/plugins/route.js +1 -1
  53. package/.next/server/app/api/project-trust/route.js +1 -1
  54. package/.next/server/app/api/projects/route.js +1 -1
  55. package/.next/server/app/api/push/config/route.js +1 -1
  56. package/.next/server/app/api/push/subscribe/route.js +1 -1
  57. package/.next/server/app/api/sessions/[id]/auto-name/route.js +2 -2
  58. package/.next/server/app/api/sessions/[id]/context/route.js +1 -1
  59. package/.next/server/app/api/sessions/[id]/entries/[entryId]/thinking/route.js +1 -1
  60. package/.next/server/app/api/sessions/[id]/entries/[entryId]/tool-result-image/route.js +1 -1
  61. package/.next/server/app/api/sessions/[id]/export/route.js +3 -3
  62. package/.next/server/app/api/sessions/[id]/outline/route.js +1 -1
  63. package/.next/server/app/api/sessions/[id]/route.js +1 -1
  64. package/.next/server/app/api/sessions/[id]/state/route.js +1 -1
  65. package/.next/server/app/api/sessions/route.js +1 -1
  66. package/.next/server/app/api/sessions/search/route.js +1 -1
  67. package/.next/server/app/api/skills/check/route.js +1 -1
  68. package/.next/server/app/api/skills/install/route.js +1 -1
  69. package/.next/server/app/api/skills/route.js +1 -1
  70. package/.next/server/app/api/skills/search/route.js +1 -1
  71. package/.next/server/app/api/skills/update/route.js +1 -1
  72. package/.next/server/app/api/subagents/[id]/route.js +1 -1
  73. package/.next/server/app/api/subagents/profiles/route.js +1 -1
  74. package/.next/server/app/api/subagents/settings/route.js +1 -1
  75. package/.next/server/app/api/terminal/[id]/events/route.js +1 -1
  76. package/.next/server/app/api/terminal/[id]/route.js +1 -1
  77. package/.next/server/app/api/terminal/route.js +1 -1
  78. package/.next/server/app/api/tools/settings/route.js +1 -1
  79. package/.next/server/app/api/usage/route.js +1 -0
  80. package/.next/server/app/api/usage/route.js.nft.json +1 -0
  81. package/.next/server/app/api/usage/route_client-reference-manifest.js +1 -0
  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/index.html +1 -1
  85. package/.next/server/app/index.rsc +6 -6
  86. package/.next/server/app/index.segments/__PAGE__.segment.rsc +7 -7
  87. package/.next/server/app/index.segments/_full.segment.rsc +6 -6
  88. package/.next/server/app/index.segments/_tree.segment.rsc +3 -3
  89. package/.next/server/app/login/page.js +2 -2
  90. package/.next/server/app/login/page.js.nft.json +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 +5 -5
  94. package/.next/server/app/login.segments/_full.segment.rsc +5 -5
  95. package/.next/server/app/login.segments/_tree.segment.rsc +3 -3
  96. package/.next/server/app/login.segments/login/__PAGE__.segment.rsc +11 -10
  97. package/.next/server/app/manifest.webmanifest/route.js +2 -2
  98. package/.next/server/app/page.js +22 -42
  99. package/.next/server/app/page.js.nft.json +1 -1
  100. package/.next/server/app/page_client-reference-manifest.js +1 -1
  101. package/.next/server/app-paths-manifest.json +11 -10
  102. package/.next/server/chunks/2243.js +1 -1
  103. package/.next/server/chunks/6429.js +3 -3
  104. package/.next/server/chunks/7147.js +1 -0
  105. package/.next/server/middleware-build-manifest.js +1 -1
  106. package/.next/server/pages/404.html +1 -1
  107. package/.next/server/pages/500.html +1 -1
  108. package/.next/server/server-reference-manifest.json +1 -1
  109. package/.next/static/MDb2LB-Z_zct3nN560IVj/_buildManifest.js +1 -0
  110. package/.next/static/chunks/2981-874f5628c1338197.js +1 -0
  111. package/.next/static/chunks/app/_global-error/{page-23d34c24c42472d2.js → page-65c0cd7526c36b6b.js} +1 -1
  112. package/.next/static/chunks/app/api/agent/[id]/bash-output/{route-23d34c24c42472d2.js → route-65c0cd7526c36b6b.js} +1 -1
  113. package/.next/static/chunks/app/api/agent/[id]/events/{route-23d34c24c42472d2.js → route-65c0cd7526c36b6b.js} +1 -1
  114. package/.next/static/chunks/app/api/agent/[id]/lease/{route-23d34c24c42472d2.js → route-65c0cd7526c36b6b.js} +1 -1
  115. package/.next/static/chunks/app/api/agent/[id]/route-65c0cd7526c36b6b.js +1 -0
  116. package/.next/static/chunks/app/api/agent/new/route-65c0cd7526c36b6b.js +1 -0
  117. package/.next/static/chunks/app/api/agent/running/route-65c0cd7526c36b6b.js +1 -0
  118. package/.next/static/chunks/app/api/app-update/route-65c0cd7526c36b6b.js +1 -0
  119. package/.next/static/chunks/app/api/auth/api-key/[provider]/route-65c0cd7526c36b6b.js +1 -0
  120. package/.next/static/chunks/app/api/auth/login/[provider]/route-65c0cd7526c36b6b.js +1 -0
  121. package/.next/static/chunks/app/api/auth/logout/[provider]/route-65c0cd7526c36b6b.js +1 -0
  122. package/.next/static/chunks/app/api/auth/providers/route-65c0cd7526c36b6b.js +1 -0
  123. package/.next/static/chunks/app/api/cwd/browse/route-65c0cd7526c36b6b.js +1 -0
  124. package/.next/static/chunks/app/api/cwd/validate/route-65c0cd7526c36b6b.js +1 -0
  125. package/.next/static/chunks/app/api/default-cwd/route-65c0cd7526c36b6b.js +1 -0
  126. package/.next/static/chunks/app/api/file-index/route-65c0cd7526c36b6b.js +1 -0
  127. package/.next/static/chunks/app/api/files/[...path]/route-65c0cd7526c36b6b.js +1 -0
  128. package/.next/static/chunks/app/api/git/diff/route-65c0cd7526c36b6b.js +1 -0
  129. package/.next/static/chunks/app/api/git/status/route-65c0cd7526c36b6b.js +1 -0
  130. package/.next/static/chunks/app/api/home/route-65c0cd7526c36b6b.js +1 -0
  131. package/.next/static/chunks/app/api/image-generation/route-65c0cd7526c36b6b.js +1 -0
  132. package/.next/static/chunks/app/api/image-generation/settings/connections/route-65c0cd7526c36b6b.js +1 -0
  133. package/.next/static/chunks/app/api/image-generation/settings/route-65c0cd7526c36b6b.js +1 -0
  134. package/.next/static/chunks/app/api/models/route-65c0cd7526c36b6b.js +1 -0
  135. package/.next/static/chunks/app/api/models-config/catalog/route-65c0cd7526c36b6b.js +1 -0
  136. package/.next/static/chunks/app/api/models-config/discover/route-65c0cd7526c36b6b.js +1 -0
  137. package/.next/static/chunks/app/api/models-config/picker/route-65c0cd7526c36b6b.js +1 -0
  138. package/.next/static/chunks/app/api/models-config/route-65c0cd7526c36b6b.js +1 -0
  139. package/.next/static/chunks/app/api/models-config/runtime/route-65c0cd7526c36b6b.js +1 -0
  140. package/.next/static/chunks/app/api/models-config/test/route-65c0cd7526c36b6b.js +1 -0
  141. package/.next/static/chunks/app/api/plugins/check/route-65c0cd7526c36b6b.js +1 -0
  142. package/.next/static/chunks/app/api/plugins/route-65c0cd7526c36b6b.js +1 -0
  143. package/.next/static/chunks/app/api/project-trust/route-65c0cd7526c36b6b.js +1 -0
  144. package/.next/static/chunks/app/api/projects/route-65c0cd7526c36b6b.js +1 -0
  145. package/.next/static/chunks/app/api/push/config/route-65c0cd7526c36b6b.js +1 -0
  146. package/.next/static/chunks/app/api/push/subscribe/route-65c0cd7526c36b6b.js +1 -0
  147. package/.next/static/chunks/app/api/sessions/[id]/auto-name/route-65c0cd7526c36b6b.js +1 -0
  148. package/.next/static/chunks/app/api/sessions/[id]/context/route-65c0cd7526c36b6b.js +1 -0
  149. package/.next/static/chunks/app/api/sessions/[id]/entries/[entryId]/thinking/route-65c0cd7526c36b6b.js +1 -0
  150. package/.next/static/chunks/app/api/sessions/[id]/entries/[entryId]/tool-result-image/route-65c0cd7526c36b6b.js +1 -0
  151. package/.next/static/chunks/app/api/sessions/[id]/export/route-65c0cd7526c36b6b.js +1 -0
  152. package/.next/static/chunks/app/api/sessions/[id]/outline/route-65c0cd7526c36b6b.js +1 -0
  153. package/.next/static/chunks/app/api/sessions/[id]/route-65c0cd7526c36b6b.js +1 -0
  154. package/.next/static/chunks/app/api/sessions/[id]/state/route-65c0cd7526c36b6b.js +1 -0
  155. package/.next/static/chunks/app/api/sessions/route-65c0cd7526c36b6b.js +1 -0
  156. package/.next/static/chunks/app/api/sessions/search/route-65c0cd7526c36b6b.js +1 -0
  157. package/.next/static/chunks/app/api/skills/check/route-65c0cd7526c36b6b.js +1 -0
  158. package/.next/static/chunks/app/api/skills/install/route-65c0cd7526c36b6b.js +1 -0
  159. package/.next/static/chunks/app/api/skills/route-65c0cd7526c36b6b.js +1 -0
  160. package/.next/static/chunks/app/api/skills/search/route-65c0cd7526c36b6b.js +1 -0
  161. package/.next/static/chunks/app/api/skills/update/route-65c0cd7526c36b6b.js +1 -0
  162. package/.next/static/chunks/app/api/subagents/[id]/route-65c0cd7526c36b6b.js +1 -0
  163. package/.next/static/chunks/app/api/subagents/profiles/route-65c0cd7526c36b6b.js +1 -0
  164. package/.next/static/chunks/app/api/subagents/settings/route-65c0cd7526c36b6b.js +1 -0
  165. package/.next/static/chunks/app/api/terminal/[id]/events/route-65c0cd7526c36b6b.js +1 -0
  166. package/.next/static/chunks/app/api/terminal/[id]/route-65c0cd7526c36b6b.js +1 -0
  167. package/.next/static/chunks/app/api/terminal/route-65c0cd7526c36b6b.js +1 -0
  168. package/.next/static/chunks/app/api/tools/settings/route-65c0cd7526c36b6b.js +1 -0
  169. package/.next/static/chunks/app/api/usage/route-65c0cd7526c36b6b.js +1 -0
  170. package/.next/static/chunks/app/api/web-auth/route-65c0cd7526c36b6b.js +1 -0
  171. package/.next/static/chunks/app/api/worktrees/route-65c0cd7526c36b6b.js +1 -0
  172. package/.next/static/chunks/app/layout-88c288a10e9226d8.js +1 -0
  173. package/.next/static/chunks/app/login/{page-9884c98b0e836d8e.js → page-724f763dcaedfc0b.js} +1 -1
  174. package/.next/static/chunks/app/manifest.webmanifest/route-65c0cd7526c36b6b.js +1 -0
  175. package/.next/static/chunks/app/page-6442cebdd02ecfec.js +212 -0
  176. package/.next/static/chunks/next/dist/client/components/builtin/app-error-65c0cd7526c36b6b.js +1 -0
  177. package/.next/static/chunks/next/dist/client/components/builtin/forbidden-65c0cd7526c36b6b.js +1 -0
  178. package/.next/static/chunks/next/dist/client/components/builtin/not-found-65c0cd7526c36b6b.js +1 -0
  179. package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-65c0cd7526c36b6b.js +1 -0
  180. package/.next/static/chunks/{webpack-1b16208bb4ccd9c1.js → webpack-851d3c4d1f2809e4.js} +1 -1
  181. package/.next/static/css/1a6a041bd877a737.css +1 -0
  182. package/.next/static/css/b3798dc89672ccdb.css +1 -0
  183. package/.next/trace +7 -6
  184. package/.next/trace-build +1 -1
  185. package/.next/types/app/api/usage/route.ts +353 -0
  186. package/.next/types/routes.d.ts +2 -1
  187. package/.next/types/validator.ts +9 -0
  188. package/package.json +1 -1
  189. package/public/fonts/NotoSerifSC-OFL.txt +94 -0
  190. package/public/fonts/NotoSerifSC.woff2 +0 -0
  191. package/public/fonts/SarasaUiSC-Regular.woff2 +0 -0
  192. package/public/fonts/SarasaUiSC-SemiBold.woff2 +0 -0
  193. package/public/fonts/SourceSerif4-Latin.woff2 +0 -0
  194. package/public/fonts/SourceSerif4-OFL.txt +93 -0
  195. package/.next/server/chunks/8759.js +0 -1
  196. package/.next/static/UylB2w8ptEUlB8P_tuCUs/_buildManifest.js +0 -1
  197. package/.next/static/chunks/1278-cee1a583acfdbbe3.js +0 -1
  198. package/.next/static/chunks/app/api/agent/[id]/route-23d34c24c42472d2.js +0 -1
  199. package/.next/static/chunks/app/api/agent/new/route-23d34c24c42472d2.js +0 -1
  200. package/.next/static/chunks/app/api/agent/running/route-23d34c24c42472d2.js +0 -1
  201. package/.next/static/chunks/app/api/app-update/route-23d34c24c42472d2.js +0 -1
  202. package/.next/static/chunks/app/api/auth/api-key/[provider]/route-23d34c24c42472d2.js +0 -1
  203. package/.next/static/chunks/app/api/auth/login/[provider]/route-23d34c24c42472d2.js +0 -1
  204. package/.next/static/chunks/app/api/auth/logout/[provider]/route-23d34c24c42472d2.js +0 -1
  205. package/.next/static/chunks/app/api/auth/providers/route-23d34c24c42472d2.js +0 -1
  206. package/.next/static/chunks/app/api/cwd/browse/route-23d34c24c42472d2.js +0 -1
  207. package/.next/static/chunks/app/api/cwd/validate/route-23d34c24c42472d2.js +0 -1
  208. package/.next/static/chunks/app/api/default-cwd/route-23d34c24c42472d2.js +0 -1
  209. package/.next/static/chunks/app/api/file-index/route-23d34c24c42472d2.js +0 -1
  210. package/.next/static/chunks/app/api/files/[...path]/route-23d34c24c42472d2.js +0 -1
  211. package/.next/static/chunks/app/api/git/diff/route-23d34c24c42472d2.js +0 -1
  212. package/.next/static/chunks/app/api/git/status/route-23d34c24c42472d2.js +0 -1
  213. package/.next/static/chunks/app/api/home/route-23d34c24c42472d2.js +0 -1
  214. package/.next/static/chunks/app/api/image-generation/route-23d34c24c42472d2.js +0 -1
  215. package/.next/static/chunks/app/api/image-generation/settings/connections/route-23d34c24c42472d2.js +0 -1
  216. package/.next/static/chunks/app/api/image-generation/settings/route-23d34c24c42472d2.js +0 -1
  217. package/.next/static/chunks/app/api/models/route-23d34c24c42472d2.js +0 -1
  218. package/.next/static/chunks/app/api/models-config/catalog/route-23d34c24c42472d2.js +0 -1
  219. package/.next/static/chunks/app/api/models-config/discover/route-23d34c24c42472d2.js +0 -1
  220. package/.next/static/chunks/app/api/models-config/picker/route-23d34c24c42472d2.js +0 -1
  221. package/.next/static/chunks/app/api/models-config/route-23d34c24c42472d2.js +0 -1
  222. package/.next/static/chunks/app/api/models-config/runtime/route-23d34c24c42472d2.js +0 -1
  223. package/.next/static/chunks/app/api/models-config/test/route-23d34c24c42472d2.js +0 -1
  224. package/.next/static/chunks/app/api/plugins/check/route-23d34c24c42472d2.js +0 -1
  225. package/.next/static/chunks/app/api/plugins/route-23d34c24c42472d2.js +0 -1
  226. package/.next/static/chunks/app/api/project-trust/route-23d34c24c42472d2.js +0 -1
  227. package/.next/static/chunks/app/api/projects/route-23d34c24c42472d2.js +0 -1
  228. package/.next/static/chunks/app/api/push/config/route-23d34c24c42472d2.js +0 -1
  229. package/.next/static/chunks/app/api/push/subscribe/route-23d34c24c42472d2.js +0 -1
  230. package/.next/static/chunks/app/api/sessions/[id]/auto-name/route-23d34c24c42472d2.js +0 -1
  231. package/.next/static/chunks/app/api/sessions/[id]/context/route-23d34c24c42472d2.js +0 -1
  232. package/.next/static/chunks/app/api/sessions/[id]/entries/[entryId]/thinking/route-23d34c24c42472d2.js +0 -1
  233. package/.next/static/chunks/app/api/sessions/[id]/entries/[entryId]/tool-result-image/route-23d34c24c42472d2.js +0 -1
  234. package/.next/static/chunks/app/api/sessions/[id]/export/route-23d34c24c42472d2.js +0 -1
  235. package/.next/static/chunks/app/api/sessions/[id]/outline/route-23d34c24c42472d2.js +0 -1
  236. package/.next/static/chunks/app/api/sessions/[id]/route-23d34c24c42472d2.js +0 -1
  237. package/.next/static/chunks/app/api/sessions/[id]/state/route-23d34c24c42472d2.js +0 -1
  238. package/.next/static/chunks/app/api/sessions/route-23d34c24c42472d2.js +0 -1
  239. package/.next/static/chunks/app/api/sessions/search/route-23d34c24c42472d2.js +0 -1
  240. package/.next/static/chunks/app/api/skills/check/route-23d34c24c42472d2.js +0 -1
  241. package/.next/static/chunks/app/api/skills/install/route-23d34c24c42472d2.js +0 -1
  242. package/.next/static/chunks/app/api/skills/route-23d34c24c42472d2.js +0 -1
  243. package/.next/static/chunks/app/api/skills/search/route-23d34c24c42472d2.js +0 -1
  244. package/.next/static/chunks/app/api/skills/update/route-23d34c24c42472d2.js +0 -1
  245. package/.next/static/chunks/app/api/subagents/[id]/route-23d34c24c42472d2.js +0 -1
  246. package/.next/static/chunks/app/api/subagents/profiles/route-23d34c24c42472d2.js +0 -1
  247. package/.next/static/chunks/app/api/subagents/settings/route-23d34c24c42472d2.js +0 -1
  248. package/.next/static/chunks/app/api/terminal/[id]/events/route-23d34c24c42472d2.js +0 -1
  249. package/.next/static/chunks/app/api/terminal/[id]/route-23d34c24c42472d2.js +0 -1
  250. package/.next/static/chunks/app/api/terminal/route-23d34c24c42472d2.js +0 -1
  251. package/.next/static/chunks/app/api/tools/settings/route-23d34c24c42472d2.js +0 -1
  252. package/.next/static/chunks/app/api/web-auth/route-23d34c24c42472d2.js +0 -1
  253. package/.next/static/chunks/app/api/worktrees/route-23d34c24c42472d2.js +0 -1
  254. package/.next/static/chunks/app/layout-0111ed4c481a1536.js +0 -1
  255. package/.next/static/chunks/app/manifest.webmanifest/route-23d34c24c42472d2.js +0 -1
  256. package/.next/static/chunks/app/page-1e80658f186c8da2.js +0 -232
  257. package/.next/static/chunks/next/dist/client/components/builtin/app-error-23d34c24c42472d2.js +0 -1
  258. package/.next/static/chunks/next/dist/client/components/builtin/forbidden-23d34c24c42472d2.js +0 -1
  259. package/.next/static/chunks/next/dist/client/components/builtin/not-found-23d34c24c42472d2.js +0 -1
  260. package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-23d34c24c42472d2.js +0 -1
  261. package/.next/static/css/491a0a5a0e53b1a3.css +0 -1
  262. package/.next/static/css/f6563ce2470fc1af.css +0 -1
  263. /package/.next/static/{UylB2w8ptEUlB8P_tuCUs → MDb2LB-Z_zct3nN560IVj}/_ssgManifest.js +0 -0
@@ -1 +1 @@
1
- (()=>{var a={};a.id=4524,a.ids=[3968,4524],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")},10847:(a,b,c)=>{"use strict";c.r(b),c.d(b,{DELETE:()=>j,GET:()=>h,POST:()=>i,dynamic:()=>f,runtime:()=>g});var d=c(23211),e=c(73968);let f="force-dynamic",g="nodejs";async function h(a,{params:b}){let{id:c}=await b,f=(0,e.getTerminalCwd)(c);return f?d.NextResponse.json({id:c,cwd:f}):d.NextResponse.json({error:"Terminal expired or closed"},{status:404})}async function i(a,{params:b}){try{let{id:c}=await b,f=await a.json();if("input"===f.type&&"string"==typeof f.data&&f.data.length<=65536)return(0,e.writeTerminal)(c,f.data)?d.NextResponse.json({success:!0}):d.NextResponse.json({error:"Terminal not found"},{status:404});if("resize"===f.type&&Number.isInteger(f.cols)&&Number.isInteger(f.rows)&&f.cols>=2&&f.cols<=1e3&&f.rows>=2&&f.rows<=1e3)return(0,e.resizeTerminal)(c,f.cols,f.rows)?d.NextResponse.json({success:!0}):d.NextResponse.json({error:"Terminal not found"},{status:404});return d.NextResponse.json({error:"Invalid terminal command"},{status:400})}catch(a){return d.NextResponse.json({error:a instanceof Error?a.message:String(a)},{status:500})}}async function j(a,{params:b}){let{id:c}=await b;return(0,e.killTerminal)(c),d.NextResponse.json({success:!0})}},14566:a=>{"use strict";a.exports=require("node-pty")},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},21820:a=>{"use strict";a.exports=require("os")},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")},58864:(a,b,c)=>{"use strict";c.d(b,{A_:()=>g,Eb:()=>k,W3:()=>i,gB:()=>h,uK:()=>f});var d=c(33873);let e=/^[a-zA-Z]:[\\/]/;function f(a){return e.test(a)||a.startsWith("\\\\")||a.startsWith("//")}function g(a){let b=a.join("/"),c=i(b);return/^[a-zA-Z]:$/.test(c)?`${c}/`:f(c)?c:"/"+b.replace(/^\/+/,"")}function h(a){return a&&"win32"===process.platform?(0,d.normalize)(a):a}function i(a){return a.replace(/\\/g,"/")}function j(a){let b=(0,d.normalize)(h(a)),c=(0,d.parse)(b).root.length,e=b.length;for(;e>c&&b[e-1]===d.sep;)e--;return b.slice(0,e)}function k(a,b){if(a===b)return!0;if(!a||!b)return!1;let c=j(a),d=j(b);return"win32"===process.platform?c.toLowerCase()===d.toLowerCase():c===d}},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},73968:(a,b,c)=>{"use strict";c.r(b),c.d(b,{TERMINAL_RECONNECT_MS:()=>h,createTerminal:()=>p,getTerminalCwd:()=>r,hasAppUpdateBlockingTerminals:()=>o,hasTerminal:()=>q,killTerminal:()=>v,resizeTerminal:()=>u,shellEnvironment:()=>k,subscribeTerminal:()=>s,writeTerminal:()=>t});var d=c(98469),e=c(55511),f=c(21820),g=c(58864);let h=12e4;function i(){if(!globalThis.__piWebTerminals){globalThis.__piWebTerminals=new Map;let a=()=>{for(let a of globalThis.__piWebTerminals.keys())v(a,!0)};process.once("exit",a),process.once("SIGINT",a),process.once("SIGTERM",a)}return globalThis.__piWebTerminals}let j=/^(PI_WEB_CAN_UPDATE|PI_WEB_UPDATE_BLOCKED|__NEXT_PRIVATE_.*)$/;function k(){let a={};for(let[b,c]of Object.entries(process.env))void 0===c||j.test(b)||(a[b]=c);return a.TERM="xterm-256color",a.COLORTERM="truecolor",process.env.LANG||process.env.LC_ALL||process.env.LC_CTYPE||(a.LANG="C.UTF-8"),a}function l(a,b){for(let c of a.listeners)c(b)}function m(a,b){b.cleanupTimer||b.listeners.size||i().get(a)!==b||(b.cleanupTimer=setTimeout(()=>v(a),h),b.cleanupTimer.unref?.())}function n(a,b){return Math.min(1e3,Math.max(2,Number.isFinite(a)?Math.floor(a):b))}function o(){return[...i().values()].some(a=>!a.exited)}function p(a,b,h,j=(0,e.randomUUID)()){let o;(0,d.b)();let q=i().get(j);if(q){if(!(0,g.Eb)(q.cwd,a))throw Error("Terminal belongs to a different workspace");return j}try{({spawn:o}=c(14566))}catch(a){throw Error(`Cannot load the node-pty native terminal module for ${process.platform}-${process.arch}. The binary may be missing or incompatible. In the pi-web installation directory (the npx cache directory when using npx), run: npm rebuild node-pty --build-from-source --ignore-scripts=false --foreground-scripts. On Debian/Ubuntu, install build tools first: sudo apt-get install -y python3 build-essential. Then restart pi-web. Original error: ${a instanceof Error?a.message:String(a)}`,{cause:a})}let r=o("win32"===process.platform?process.env.ComSpec??"cmd.exe":process.env.SHELL||"/bin/sh","win32"===process.platform?[]:["-l"],{name:"xterm-256color",cols:n(b,80),rows:n(h,24),cwd:a||(0,f.homedir)(),env:k()}),s={pty:r,cwd:a,listeners:new Set,backlog:"",offset:0,exited:!1,exitCode:null,cleanupTimer:null};return i().set(j,s),m(j,s),r.onData(a=>{s.backlog=(s.backlog+a).slice(-131072),s.offset+=a.length,l(s,{type:"output",data:a,offset:s.offset})}),r.onExit(({exitCode:a})=>{s.cleanupTimer&&clearTimeout(s.cleanupTimer),s.cleanupTimer=null,s.exited=!0,s.exitCode=a,l(s,{type:"exit",exitCode:a}),m(j,s)}),j}function q(a){return i().has(a)}function r(a){return i().get(a)?.cwd}function s(a,b,c){let d=i().get(a);if(!d)return null;d.listeners.add(b),d.cleanupTimer&&clearTimeout(d.cleanupTimer),d.cleanupTimer=null;let e=d.offset-d.backlog.length,f=void 0===c||c<e||c>d.offset;return{output:{type:"output",data:f?d.backlog:d.backlog.slice(c-e),offset:d.offset,reset:f},exited:d.exited,exitCode:d.exitCode,unsubscribe:()=>{d.listeners.delete(b),m(a,d)}}}function t(a,b){let c=i().get(a);return!!c&&!c.exited&&(c.pty.write(b),!0)}function u(a,b,c){let d=i().get(a);return!!d&&!d.exited&&(d.pty.resize(n(b,80),n(c,24)),!0)}function v(a,b=!1){let c=i().get(a);return!!c&&(c.cleanupTimer&&clearTimeout(c.cleanupTimer),i().delete(a),!c.exited&&(c.pty.kill(b?"SIGKILL":void 0),b||(c.cleanupTimer=setTimeout(()=>{c.exited||c.pty.kill("SIGKILL")},2e3),c.cleanupTimer.unref?.())),l(c,{type:"closed"}),c.listeners.clear(),!0)}},78335:()=>{},86439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},96487:()=>{},97892:(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/terminal/[id]/route",pathname:"/api/terminal/[id]",filename:"route",bundlePath:"app/api/terminal/[id]/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/home/zhujunshen/pi-web/app/api/terminal/[id]/route.ts",nextConfigOutput:"",userland:()=>c(10847),...{}}),{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/terminal/[id]/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)}}},98469:(a,b,c)=>{"use strict";function d(){if(globalThis.__piWebUpdating)throw Error("Pi Web is updating. Please wait for the restart.")}c.d(b,{b:()=>d})}};var b=require("../../../../webpack-runtime.js");b.C(a);var c=b.X(0,[4741,1813],()=>b(b.s=97892));module.exports=c})();
1
+ (()=>{var a={};a.id=4524,a.ids=[3968,4524],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")},10847:(a,b,c)=>{"use strict";c.r(b),c.d(b,{DELETE:()=>j,GET:()=>h,POST:()=>i,dynamic:()=>f,runtime:()=>g});var d=c(23211),e=c(73968);let f="force-dynamic",g="nodejs";async function h(a,{params:b}){let{id:c}=await b,f=(0,e.getTerminalCwd)(c);return f?d.NextResponse.json({id:c,cwd:f}):d.NextResponse.json({error:"Terminal expired or closed"},{status:404})}async function i(a,{params:b}){try{let{id:c}=await b,f=await a.json();if("input"===f.type&&"string"==typeof f.data&&f.data.length<=65536)return(0,e.writeTerminal)(c,f.data)?d.NextResponse.json({success:!0}):d.NextResponse.json({error:"Terminal not found"},{status:404});if("resize"===f.type&&Number.isInteger(f.cols)&&Number.isInteger(f.rows)&&f.cols>=2&&f.cols<=1e3&&f.rows>=2&&f.rows<=1e3)return(0,e.resizeTerminal)(c,f.cols,f.rows)?d.NextResponse.json({success:!0}):d.NextResponse.json({error:"Terminal not found"},{status:404});return d.NextResponse.json({error:"Invalid terminal command"},{status:400})}catch(a){return d.NextResponse.json({error:a instanceof Error?a.message:String(a)},{status:500})}}async function j(a,{params:b}){let{id:c}=await b;return(0,e.killTerminal)(c),d.NextResponse.json({success:!0})}},14566:a=>{"use strict";a.exports=require("node-pty")},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},21820:a=>{"use strict";a.exports=require("os")},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")},58864:(a,b,c)=>{"use strict";c.d(b,{A_:()=>g,Eb:()=>k,W3:()=>i,gB:()=>h,uK:()=>f});var d=c(33873);let e=/^[a-zA-Z]:[\\/]/;function f(a){return e.test(a)||a.startsWith("\\\\")||a.startsWith("//")}function g(a){let b=a.join("/"),c=i(b);return/^[a-zA-Z]:$/.test(c)?`${c}/`:f(c)?c:"/"+b.replace(/^\/+/,"")}function h(a){return a&&"win32"===process.platform?(0,d.normalize)(a):a}function i(a){return a.replace(/\\/g,"/")}function j(a){let b=(0,d.normalize)(h(a)),c=(0,d.parse)(b).root.length,e=b.length;for(;e>c&&b[e-1]===d.sep;)e--;return b.slice(0,e)}function k(a,b){if(a===b)return!0;if(!a||!b)return!1;let c=j(a),d=j(b);return"win32"===process.platform?c.toLowerCase()===d.toLowerCase():c===d}},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},73968:(a,b,c)=>{"use strict";c.r(b),c.d(b,{TERMINAL_RECONNECT_MS:()=>h,createTerminal:()=>p,getTerminalCwd:()=>r,hasAppUpdateBlockingTerminals:()=>o,hasTerminal:()=>q,killTerminal:()=>v,resizeTerminal:()=>u,shellEnvironment:()=>k,subscribeTerminal:()=>s,writeTerminal:()=>t});var d=c(98469),e=c(55511),f=c(21820),g=c(58864);let h=12e4;function i(){if(!globalThis.__piWebTerminals){globalThis.__piWebTerminals=new Map;let a=()=>{for(let a of globalThis.__piWebTerminals.keys())v(a,!0)};process.once("exit",a),process.once("SIGINT",a),process.once("SIGTERM",a)}return globalThis.__piWebTerminals}let j=/^(PI_WEB_CAN_UPDATE|PI_WEB_UPDATE_BLOCKED|__NEXT_PRIVATE_.*)$/;function k(){let a={};for(let[b,c]of Object.entries(process.env))void 0===c||j.test(b)||(a[b]=c);return a.TERM="xterm-256color",a.COLORTERM="truecolor",process.env.LANG||process.env.LC_ALL||process.env.LC_CTYPE||(a.LANG="C.UTF-8"),a}function l(a,b){for(let c of a.listeners)c(b)}function m(a,b){b.cleanupTimer||b.listeners.size||i().get(a)!==b||(b.cleanupTimer=setTimeout(()=>v(a),h),b.cleanupTimer.unref?.())}function n(a,b){return Math.min(1e3,Math.max(2,Number.isFinite(a)?Math.floor(a):b))}function o(){return[...i().values()].some(a=>!a.exited)}function p(a,b,h,j=(0,e.randomUUID)()){let o;(0,d.b)();let q=i().get(j);if(q){if(!(0,g.Eb)(q.cwd,a))throw Error("Terminal belongs to a different workspace");return j}try{({spawn:o}=c(14566))}catch(a){throw Error(`Cannot load the node-pty native terminal module for ${process.platform}-${process.arch}. The binary may be missing or incompatible. In the pi-web installation directory (the npx cache directory when using npx), run: npm rebuild node-pty --build-from-source --ignore-scripts=false --foreground-scripts. On Debian/Ubuntu, install build tools first: sudo apt-get install -y python3 build-essential. Then restart pi-web. Original error: ${a instanceof Error?a.message:String(a)}`,{cause:a})}let r=o("win32"===process.platform?process.env.ComSpec??"cmd.exe":process.env.SHELL||"/bin/sh","win32"===process.platform?[]:["-l"],{name:"xterm-256color",cols:n(b,80),rows:n(h,24),cwd:a||(0,f.homedir)(),env:k()}),s={pty:r,cwd:a,listeners:new Set,backlog:"",offset:0,exited:!1,exitCode:null,cleanupTimer:null};return i().set(j,s),m(j,s),r.onData(a=>{s.backlog=(s.backlog+a).slice(-131072),s.offset+=a.length,l(s,{type:"output",data:a,offset:s.offset})}),r.onExit(({exitCode:a})=>{s.cleanupTimer&&clearTimeout(s.cleanupTimer),s.cleanupTimer=null,s.exited=!0,s.exitCode=a,l(s,{type:"exit",exitCode:a}),m(j,s)}),j}function q(a){return i().has(a)}function r(a){return i().get(a)?.cwd}function s(a,b,c){let d=i().get(a);if(!d)return null;d.listeners.add(b),d.cleanupTimer&&clearTimeout(d.cleanupTimer),d.cleanupTimer=null;let e=d.offset-d.backlog.length,f=void 0===c||c<e||c>d.offset;return{output:{type:"output",data:f?d.backlog:d.backlog.slice(c-e),offset:d.offset,reset:f},exited:d.exited,exitCode:d.exitCode,unsubscribe:()=>{d.listeners.delete(b),m(a,d)}}}function t(a,b){let c=i().get(a);return!!c&&!c.exited&&(c.pty.write(b),!0)}function u(a,b,c){let d=i().get(a);return!!d&&!d.exited&&(d.pty.resize(n(b,80),n(c,24)),!0)}function v(a,b=!1){let c=i().get(a);return!!c&&(c.cleanupTimer&&clearTimeout(c.cleanupTimer),i().delete(a),!c.exited&&(c.pty.kill(b?"SIGKILL":void 0),b||(c.cleanupTimer=setTimeout(()=>{c.exited||c.pty.kill("SIGKILL")},2e3),c.cleanupTimer.unref?.())),l(c,{type:"closed"}),c.listeners.clear(),!0)}},78335:()=>{},84393:(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/terminal/[id]/route",pathname:"/api/terminal/[id]",filename:"route",bundlePath:"app/api/terminal/[id]/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/home/zhujunshen/pi-web/app/api/terminal/[id]/route.ts",nextConfigOutput:"",userland:()=>c(10847),...{}}),{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/terminal/[id]/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)}}},86439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},96487:()=>{},98469:(a,b,c)=>{"use strict";function d(){if(globalThis.__piWebUpdating)throw Error("Pi Web is updating. Please wait for the restart.")}c.d(b,{b:()=>d})}};var b=require("../../../../webpack-runtime.js");b.C(a);var c=b.X(0,[4741,1813],()=>b(b.s=84393));module.exports=c})();
@@ -1 +1 @@
1
- (()=>{var a={};a.id=2614,a.ids=[2614],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")},14566:a=>{"use strict";a.exports=require("node-pty")},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},21820:a=>{"use strict";a.exports=require("os")},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")},30986:(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/terminal/route",pathname:"/api/terminal",filename:"route",bundlePath:"app/api/terminal/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/home/zhujunshen/pi-web/app/api/terminal/route.ts",nextConfigOutput:"",userland:()=>c(47709),...{}}),{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/terminal/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=>{"use strict";a.exports=require("path")},44870:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},47709:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.r(b),c.d(b,{POST:()=>k,dynamic:()=>l,runtime:()=>m});var e=c(79748),f=c(33873),g=c(23211),h=c(80547),i=c(73968),j=a([h]);h=(j.then?(await j)():j)[0];let l="force-dynamic",m="nodejs";async function k(a){try{let b=await a.json();if(void 0!==b.id&&("string"!=typeof b.id||!/^[a-f0-9]{32}$/.test(b.id)))return g.NextResponse.json({error:"Invalid terminal id"},{status:400});if("string"!=typeof b.cwd||!b.cwd.trim())return g.NextResponse.json({error:"cwd required"},{status:400});let c=(0,f.resolve)(b.cwd);if(!(await (0,e.stat)(c)).isDirectory())return g.NextResponse.json({error:"cwd must be a directory"},{status:400});let d=await (0,h.mc)();if(!(0,h.B7)(c,d))return g.NextResponse.json({error:"Access denied"},{status:403});let j=(0,i.createTerminal)(c,"number"==typeof b.cols?b.cols:80,"number"==typeof b.rows?b.rows:24,b.id);return g.NextResponse.json({id:j})}catch(a){return g.NextResponse.json({error:a instanceof Error?a.message:String(a)},{status:500})}}d()}catch(a){d(a)}})},51455:a=>{"use strict";a.exports=require("node:fs/promises")},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")},73968:(a,b,c)=>{"use strict";c.r(b),c.d(b,{TERMINAL_RECONNECT_MS:()=>h,createTerminal:()=>p,getTerminalCwd:()=>r,hasAppUpdateBlockingTerminals:()=>o,hasTerminal:()=>q,killTerminal:()=>v,resizeTerminal:()=>u,shellEnvironment:()=>k,subscribeTerminal:()=>s,writeTerminal:()=>t});var d=c(98469),e=c(55511),f=c(21820),g=c(58864);let h=12e4;function i(){if(!globalThis.__piWebTerminals){globalThis.__piWebTerminals=new Map;let a=()=>{for(let a of globalThis.__piWebTerminals.keys())v(a,!0)};process.once("exit",a),process.once("SIGINT",a),process.once("SIGTERM",a)}return globalThis.__piWebTerminals}let j=/^(PI_WEB_CAN_UPDATE|PI_WEB_UPDATE_BLOCKED|__NEXT_PRIVATE_.*)$/;function k(){let a={};for(let[b,c]of Object.entries(process.env))void 0===c||j.test(b)||(a[b]=c);return a.TERM="xterm-256color",a.COLORTERM="truecolor",process.env.LANG||process.env.LC_ALL||process.env.LC_CTYPE||(a.LANG="C.UTF-8"),a}function l(a,b){for(let c of a.listeners)c(b)}function m(a,b){b.cleanupTimer||b.listeners.size||i().get(a)!==b||(b.cleanupTimer=setTimeout(()=>v(a),h),b.cleanupTimer.unref?.())}function n(a,b){return Math.min(1e3,Math.max(2,Number.isFinite(a)?Math.floor(a):b))}function o(){return[...i().values()].some(a=>!a.exited)}function p(a,b,h,j=(0,e.randomUUID)()){let o;(0,d.b)();let q=i().get(j);if(q){if(!(0,g.Eb)(q.cwd,a))throw Error("Terminal belongs to a different workspace");return j}try{({spawn:o}=c(14566))}catch(a){throw Error(`Cannot load the node-pty native terminal module for ${process.platform}-${process.arch}. The binary may be missing or incompatible. In the pi-web installation directory (the npx cache directory when using npx), run: npm rebuild node-pty --build-from-source --ignore-scripts=false --foreground-scripts. On Debian/Ubuntu, install build tools first: sudo apt-get install -y python3 build-essential. Then restart pi-web. Original error: ${a instanceof Error?a.message:String(a)}`,{cause:a})}let r=o("win32"===process.platform?process.env.ComSpec??"cmd.exe":process.env.SHELL||"/bin/sh","win32"===process.platform?[]:["-l"],{name:"xterm-256color",cols:n(b,80),rows:n(h,24),cwd:a||(0,f.homedir)(),env:k()}),s={pty:r,cwd:a,listeners:new Set,backlog:"",offset:0,exited:!1,exitCode:null,cleanupTimer:null};return i().set(j,s),m(j,s),r.onData(a=>{s.backlog=(s.backlog+a).slice(-131072),s.offset+=a.length,l(s,{type:"output",data:a,offset:s.offset})}),r.onExit(({exitCode:a})=>{s.cleanupTimer&&clearTimeout(s.cleanupTimer),s.cleanupTimer=null,s.exited=!0,s.exitCode=a,l(s,{type:"exit",exitCode:a}),m(j,s)}),j}function q(a){return i().has(a)}function r(a){return i().get(a)?.cwd}function s(a,b,c){let d=i().get(a);if(!d)return null;d.listeners.add(b),d.cleanupTimer&&clearTimeout(d.cleanupTimer),d.cleanupTimer=null;let e=d.offset-d.backlog.length,f=void 0===c||c<e||c>d.offset;return{output:{type:"output",data:f?d.backlog:d.backlog.slice(c-e),offset:d.offset,reset:f},exited:d.exited,exitCode:d.exitCode,unsubscribe:()=>{d.listeners.delete(b),m(a,d)}}}function t(a,b){let c=i().get(a);return!!c&&!c.exited&&(c.pty.write(b),!0)}function u(a,b,c){let d=i().get(a);return!!d&&!d.exited&&(d.pty.resize(n(b,80),n(c,24)),!0)}function v(a,b=!1){let c=i().get(a);return!!c&&(c.cleanupTimer&&clearTimeout(c.cleanupTimer),i().delete(a),!c.exited&&(c.pty.kill(b?"SIGKILL":void 0),b||(c.cleanupTimer=setTimeout(()=>{c.exited||c.pty.kill("SIGKILL")},2e3),c.cleanupTimer.unref?.())),l(c,{type:"closed"}),c.listeners.clear(),!0)}},75430:a=>{"use strict";a.exports=import("@earendil-works/pi-coding-agent")},76760:a=>{"use strict";a.exports=require("node:path")},78335:()=>{},79646:a=>{"use strict";a.exports=require("child_process")},79748:a=>{"use strict";a.exports=require("fs/promises")},80481:a=>{"use strict";a.exports=require("node:readline")},80547:(a,b,c)=>{"use strict";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=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},96487:()=>{},98469:(a,b,c)=>{"use strict";function d(){if(globalThis.__piWebUpdating)throw Error("Pi Web is updating. Please wait for the restart.")}c.d(b,{b:()=>d})}};var b=require("../../../webpack-runtime.js");b.C(a);var c=b.X(0,[4741,1813,426,402],()=>b(b.s=30986));module.exports=c})();
1
+ (()=>{var a={};a.id=2614,a.ids=[2614],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")},14566:a=>{"use strict";a.exports=require("node-pty")},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},21820:a=>{"use strict";a.exports=require("os")},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")},32475:(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/terminal/route",pathname:"/api/terminal",filename:"route",bundlePath:"app/api/terminal/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/home/zhujunshen/pi-web/app/api/terminal/route.ts",nextConfigOutput:"",userland:()=>c(47709),...{}}),{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/terminal/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=>{"use strict";a.exports=require("path")},44870:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},47709:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.r(b),c.d(b,{POST:()=>k,dynamic:()=>l,runtime:()=>m});var e=c(79748),f=c(33873),g=c(23211),h=c(80547),i=c(73968),j=a([h]);h=(j.then?(await j)():j)[0];let l="force-dynamic",m="nodejs";async function k(a){try{let b=await a.json();if(void 0!==b.id&&("string"!=typeof b.id||!/^[a-f0-9]{32}$/.test(b.id)))return g.NextResponse.json({error:"Invalid terminal id"},{status:400});if("string"!=typeof b.cwd||!b.cwd.trim())return g.NextResponse.json({error:"cwd required"},{status:400});let c=(0,f.resolve)(b.cwd);if(!(await (0,e.stat)(c)).isDirectory())return g.NextResponse.json({error:"cwd must be a directory"},{status:400});let d=await (0,h.mc)();if(!(0,h.B7)(c,d))return g.NextResponse.json({error:"Access denied"},{status:403});let j=(0,i.createTerminal)(c,"number"==typeof b.cols?b.cols:80,"number"==typeof b.rows?b.rows:24,b.id);return g.NextResponse.json({id:j})}catch(a){return g.NextResponse.json({error:a instanceof Error?a.message:String(a)},{status:500})}}d()}catch(a){d(a)}})},51455:a=>{"use strict";a.exports=require("node:fs/promises")},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")},73968:(a,b,c)=>{"use strict";c.r(b),c.d(b,{TERMINAL_RECONNECT_MS:()=>h,createTerminal:()=>p,getTerminalCwd:()=>r,hasAppUpdateBlockingTerminals:()=>o,hasTerminal:()=>q,killTerminal:()=>v,resizeTerminal:()=>u,shellEnvironment:()=>k,subscribeTerminal:()=>s,writeTerminal:()=>t});var d=c(98469),e=c(55511),f=c(21820),g=c(58864);let h=12e4;function i(){if(!globalThis.__piWebTerminals){globalThis.__piWebTerminals=new Map;let a=()=>{for(let a of globalThis.__piWebTerminals.keys())v(a,!0)};process.once("exit",a),process.once("SIGINT",a),process.once("SIGTERM",a)}return globalThis.__piWebTerminals}let j=/^(PI_WEB_CAN_UPDATE|PI_WEB_UPDATE_BLOCKED|__NEXT_PRIVATE_.*)$/;function k(){let a={};for(let[b,c]of Object.entries(process.env))void 0===c||j.test(b)||(a[b]=c);return a.TERM="xterm-256color",a.COLORTERM="truecolor",process.env.LANG||process.env.LC_ALL||process.env.LC_CTYPE||(a.LANG="C.UTF-8"),a}function l(a,b){for(let c of a.listeners)c(b)}function m(a,b){b.cleanupTimer||b.listeners.size||i().get(a)!==b||(b.cleanupTimer=setTimeout(()=>v(a),h),b.cleanupTimer.unref?.())}function n(a,b){return Math.min(1e3,Math.max(2,Number.isFinite(a)?Math.floor(a):b))}function o(){return[...i().values()].some(a=>!a.exited)}function p(a,b,h,j=(0,e.randomUUID)()){let o;(0,d.b)();let q=i().get(j);if(q){if(!(0,g.Eb)(q.cwd,a))throw Error("Terminal belongs to a different workspace");return j}try{({spawn:o}=c(14566))}catch(a){throw Error(`Cannot load the node-pty native terminal module for ${process.platform}-${process.arch}. The binary may be missing or incompatible. In the pi-web installation directory (the npx cache directory when using npx), run: npm rebuild node-pty --build-from-source --ignore-scripts=false --foreground-scripts. On Debian/Ubuntu, install build tools first: sudo apt-get install -y python3 build-essential. Then restart pi-web. Original error: ${a instanceof Error?a.message:String(a)}`,{cause:a})}let r=o("win32"===process.platform?process.env.ComSpec??"cmd.exe":process.env.SHELL||"/bin/sh","win32"===process.platform?[]:["-l"],{name:"xterm-256color",cols:n(b,80),rows:n(h,24),cwd:a||(0,f.homedir)(),env:k()}),s={pty:r,cwd:a,listeners:new Set,backlog:"",offset:0,exited:!1,exitCode:null,cleanupTimer:null};return i().set(j,s),m(j,s),r.onData(a=>{s.backlog=(s.backlog+a).slice(-131072),s.offset+=a.length,l(s,{type:"output",data:a,offset:s.offset})}),r.onExit(({exitCode:a})=>{s.cleanupTimer&&clearTimeout(s.cleanupTimer),s.cleanupTimer=null,s.exited=!0,s.exitCode=a,l(s,{type:"exit",exitCode:a}),m(j,s)}),j}function q(a){return i().has(a)}function r(a){return i().get(a)?.cwd}function s(a,b,c){let d=i().get(a);if(!d)return null;d.listeners.add(b),d.cleanupTimer&&clearTimeout(d.cleanupTimer),d.cleanupTimer=null;let e=d.offset-d.backlog.length,f=void 0===c||c<e||c>d.offset;return{output:{type:"output",data:f?d.backlog:d.backlog.slice(c-e),offset:d.offset,reset:f},exited:d.exited,exitCode:d.exitCode,unsubscribe:()=>{d.listeners.delete(b),m(a,d)}}}function t(a,b){let c=i().get(a);return!!c&&!c.exited&&(c.pty.write(b),!0)}function u(a,b,c){let d=i().get(a);return!!d&&!d.exited&&(d.pty.resize(n(b,80),n(c,24)),!0)}function v(a,b=!1){let c=i().get(a);return!!c&&(c.cleanupTimer&&clearTimeout(c.cleanupTimer),i().delete(a),!c.exited&&(c.pty.kill(b?"SIGKILL":void 0),b||(c.cleanupTimer=setTimeout(()=>{c.exited||c.pty.kill("SIGKILL")},2e3),c.cleanupTimer.unref?.())),l(c,{type:"closed"}),c.listeners.clear(),!0)}},75430:a=>{"use strict";a.exports=import("@earendil-works/pi-coding-agent")},76760:a=>{"use strict";a.exports=require("node:path")},78335:()=>{},79646:a=>{"use strict";a.exports=require("child_process")},79748:a=>{"use strict";a.exports=require("fs/promises")},80481:a=>{"use strict";a.exports=require("node:readline")},80547:(a,b,c)=>{"use strict";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=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},96487:()=>{},98469:(a,b,c)=>{"use strict";function d(){if(globalThis.__piWebUpdating)throw Error("Pi Web is updating. Please wait for the restart.")}c.d(b,{b:()=>d})}};var b=require("../../../webpack-runtime.js");b.C(a);var c=b.X(0,[4741,1813,426,402],()=>b(b.s=32475));module.exports=c})();
@@ -1 +1 @@
1
- (()=>{var a={};a.id=6293,a.ids=[6293],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},305:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{Up:()=>r,dp:()=>q,wQ:()=>m});var e=c(73024),f=c(76760),g=c(75430),h=c(80974),i=c.n(h),j=a([g]);g=(j.then?(await j)():j)[0];let s=["read","bash","edit","write"],t=new Set(["bash","powershell"]);function k(a,b=process.platform){return"win32"===b&&a?.includes("powershell")===!0&&!a.includes("bash")}function l(a,b){let c=b?"powershell":"bash",d=[];for(let b of a){let a=t.has(b)?c:b;d.includes(a)||d.push(a)}return d}function m(a,b,c=process.platform){return l(a,k(b,c))}function n(a=(0,g.getAgentDir)()){return(0,f.join)(a,"settings.json")}function o(a){if(!(0,e.existsSync)(a))return{};let b=JSON.parse((0,e.readFileSync)(a,"utf8"));if("object"!=typeof b||null===b||Array.isArray(b))throw Error("Invalid settings.json: expected an object");return b}function p(a){if(void 0!==a.defaultTools){if(!Array.isArray(a.defaultTools)||a.defaultTools.some(a=>"string"!=typeof a))throw Error("Invalid settings.json: defaultTools must be an array of strings");return a.defaultTools}}async function q(a=n(),b=process.platform){if(!(0,e.existsSync)(a))return!1;let c=await i().lock(a,{realpath:!1,retries:10});try{return k(p(o(a)),b)}finally{await c()}}async function r(a,b=n(),c=process.platform){if("win32"!==c)throw Error("PowerShell tool settings are only available on Windows");(0,e.mkdirSync)((0,f.dirname)(b),{recursive:!0});try{(0,e.writeFileSync)(b,"{}",{flag:"wx",mode:384})}catch(a){if("EEXIST"!==a.code)throw a}let d=await i().lock(b,{realpath:!1,retries:10});try{let c=o(b),d=p(c)??s,f=l(d,a);d.some(a=>t.has(a))||f.push(a?"powershell":"bash"),c.defaultTools=f,(0,e.writeFileSync)(b,JSON.stringify(c,null,2),"utf8"),(0,e.chmodSync)(b,384)}finally{await d()}return a}d()}catch(a){d(a)}})},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")},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")},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")},32280:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.r(b),c.d(b,{GET:()=>i,PUT:()=>j,dynamic:()=>k});var e=c(23211),f=c(66544),g=c(305),h=a([g]);g=(h.then?(await h)():h)[0];let k="force-dynamic";async function i(){try{return e.NextResponse.json({isWindows:"win32"===process.platform,powerShellEnabled:await (0,g.dp)()})}catch(a){return e.NextResponse.json({error:a instanceof Error?a.message:String(a)},{status:500})}}async function j(a){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});if("win32"!==process.platform)return e.NextResponse.json({error:"PowerShell tool settings are only available on Windows"},{status:404});try{let b=await a.json();if("boolean"!=typeof b.enabled)return e.NextResponse.json({error:"enabled must be a boolean"},{status:400});return e.NextResponse.json({isWindows:!0,powerShellEnabled:await (0,g.Up)(b.enabled)})}catch(a){return e.NextResponse.json({error:a instanceof Error?a.message:String(a)},{status:500})}}d()}catch(a){d(a)}})},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")},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"))}},72052:(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/tools/settings/route",pathname:"/api/tools/settings",filename:"route",bundlePath:"app/api/tools/settings/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/home/zhujunshen/pi-web/app/api/tools/settings/route.ts",nextConfigOutput:"",userland:()=>c(32280),...{}}),{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/tools/settings/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)}}},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")},77030:a=>{"use strict";a.exports=require("node:net")},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=72052));module.exports=c})();
1
+ (()=>{var a={};a.id=6293,a.ids=[6293],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},305:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{Up:()=>r,dp:()=>q,wQ:()=>m});var e=c(73024),f=c(76760),g=c(75430),h=c(80974),i=c.n(h),j=a([g]);g=(j.then?(await j)():j)[0];let s=["read","bash","edit","write"],t=new Set(["bash","powershell"]);function k(a,b=process.platform){return"win32"===b&&a?.includes("powershell")===!0&&!a.includes("bash")}function l(a,b){let c=b?"powershell":"bash",d=[];for(let b of a){let a=t.has(b)?c:b;d.includes(a)||d.push(a)}return d}function m(a,b,c=process.platform){return l(a,k(b,c))}function n(a=(0,g.getAgentDir)()){return(0,f.join)(a,"settings.json")}function o(a){if(!(0,e.existsSync)(a))return{};let b=JSON.parse((0,e.readFileSync)(a,"utf8"));if("object"!=typeof b||null===b||Array.isArray(b))throw Error("Invalid settings.json: expected an object");return b}function p(a){if(void 0!==a.defaultTools){if(!Array.isArray(a.defaultTools)||a.defaultTools.some(a=>"string"!=typeof a))throw Error("Invalid settings.json: defaultTools must be an array of strings");return a.defaultTools}}async function q(a=n(),b=process.platform){if(!(0,e.existsSync)(a))return!1;let c=await i().lock(a,{realpath:!1,retries:10});try{return k(p(o(a)),b)}finally{await c()}}async function r(a,b=n(),c=process.platform){if("win32"!==c)throw Error("PowerShell tool settings are only available on Windows");(0,e.mkdirSync)((0,f.dirname)(b),{recursive:!0});try{(0,e.writeFileSync)(b,"{}",{flag:"wx",mode:384})}catch(a){if("EEXIST"!==a.code)throw a}let d=await i().lock(b,{realpath:!1,retries:10});try{let c=o(b),d=p(c)??s,f=l(d,a);d.some(a=>t.has(a))||f.push(a?"powershell":"bash"),c.defaultTools=f,(0,e.writeFileSync)(b,JSON.stringify(c,null,2),"utf8"),(0,e.chmodSync)(b,384)}finally{await d()}return a}d()}catch(a){d(a)}})},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")},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")},23673:(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/tools/settings/route",pathname:"/api/tools/settings",filename:"route",bundlePath:"app/api/tools/settings/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/home/zhujunshen/pi-web/app/api/tools/settings/route.ts",nextConfigOutput:"",userland:()=>c(32280),...{}}),{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/tools/settings/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)}}},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")},32280:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.r(b),c.d(b,{GET:()=>i,PUT:()=>j,dynamic:()=>k});var e=c(23211),f=c(66544),g=c(305),h=a([g]);g=(h.then?(await h)():h)[0];let k="force-dynamic";async function i(){try{return e.NextResponse.json({isWindows:"win32"===process.platform,powerShellEnabled:await (0,g.dp)()})}catch(a){return e.NextResponse.json({error:a instanceof Error?a.message:String(a)},{status:500})}}async function j(a){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});if("win32"!==process.platform)return e.NextResponse.json({error:"PowerShell tool settings are only available on Windows"},{status:404});try{let b=await a.json();if("boolean"!=typeof b.enabled)return e.NextResponse.json({error:"enabled must be a boolean"},{status:400});return e.NextResponse.json({isWindows:!0,powerShellEnabled:await (0,g.Up)(b.enabled)})}catch(a){return e.NextResponse.json({error:a instanceof Error?a.message:String(a)},{status:500})}}d()}catch(a){d(a)}})},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")},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"))}},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")},77030:a=>{"use strict";a.exports=require("node:net")},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=23673));module.exports=c})();
@@ -0,0 +1 @@
1
+ (()=>{var a={};a.id=7347,a.ids=[7347],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")},6093:(a,b,c)=>{"use strict";c.d(b,{EL:()=>e});let d=a=>String(a).padStart(2,"0"),e=a=>`${a.getFullYear()}-${d(a.getMonth()+1)}-${d(a.getDate())}`},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")},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},24923:(a,b,c)=>{"use strict";c.d(b,{IL:()=>t,KI:()=>n,P9:()=>p,l:()=>s,xw:()=>r});var d=c(79646),e=c(29021),f=c(33873),g=c(28354),h=c(25252),i=c(58864);let j=(0,g.promisify)(d.execFile);function k(){globalThis.__piProjectCache?.clear()}async function l(a,b,c=1e4){let{stdout:d}=await j("git",["-C",a,...b],{timeout:c,maxBuffer:1048576,env:{...process.env,LC_ALL:"C"}});return d.trim()}function m(a){try{return(0,e.realpathSync)(a)}catch{return a}}async function n(a){let b,c=(globalThis.__piProjectCache||(globalThis.__piProjectCache=new Map),globalThis.__piProjectCache),d=c.get(a);if(d&&d.expiresAt>Date.now())return d.info;try{if(!(0,e.existsSync)(a))return b=function(a){let b=(0,f.dirname)(a);if(!b.endsWith("-worktrees"))return null;let c=b.slice(0,-10);return c&&(0,e.existsSync)((0,f.join)(c,".git"))?{projectRoot:m(c),branch:(0,f.basename)(a),isWorktree:!0,isTopLevel:!0}:null}(a)??{projectRoot:a,branch:null,isWorktree:!1,isTopLevel:!1},c.set(a,{info:b,expiresAt:Date.now()+6e4}),b;let[d,g,h,j]=(await l(a,["rev-parse","--path-format=absolute","--git-common-dir","--git-dir","--show-toplevel","--abbrev-ref","HEAD"])).split("\n").map(a=>a.trim()),[k,n,o]=[d,g,h].map(i.gB),p=m(a),q=(0,i.Eb)(o,p),r=!(0,i.Eb)(n,k)&&q,s=r?(0,f.dirname)(k):o;b={projectRoot:q?m(s):a,branch:j&&"HEAD"!==j?j:null,isWorktree:r,isTopLevel:q}}catch{b={projectRoot:a,branch:null,isWorktree:!1,isTopLevel:!1}}return c.set(a,{info:b,expiresAt:Date.now()+6e4}),b}async function o(a){let b=await l(a,["rev-parse","--path-format=absolute","--git-common-dir"]);return m((0,f.dirname)((0,i.gB)(b)))}async function p(a){let b=await l(a,["worktree","list","--porcelain"]),c=[],d=null,g=()=>{var a;d?.path&&!d.prunable&&(0,e.existsSync)(d.path)&&(a=d.path,!(0,f.basename)(a).startsWith("pi-web-agent-"))&&c.push({path:d.path,branch:d.branch??null,isMain:0===c.length}),d=null};for(let a of b.split("\n"))a.startsWith("worktree ")?(g(),d={path:(0,i.gB)(a.slice(9).trim())}):a.startsWith("branch ")&&d?d.branch=a.slice(7).trim().replace(/^refs\/heads\//,""):a.startsWith("prunable")&&d?d.prunable=!0:""===a.trim()&&g();return g(),c}function q(a,b){return a.find(a=>(0,i.Eb)(a.path,b))}function r(a,b){return q(a,m(b))?.path??null}async function s(a,b){let c=b.trim();if(!c)throw Error("Branch name is required");let d=c.replace(/[\/\\:*?"<>|\s]+/g,"-").replace(/^-+|-+$/g,"");if(!d)throw Error(`Invalid branch name: ${b}`);let g=await o(a),i=`${(0,f.resolve)(g)}-worktrees`,j=(0,f.join)(i,d);if((0,e.existsSync)(j))throw Error(`Directory already exists: ${j}`);(0,e.mkdirSync)(i,{recursive:!0});let m=!1;try{await l(g,["rev-parse","--verify","--quiet",`refs/heads/${c}`]),m=!0}catch{m=!1}let n=null;if(!m)try{await l(g,["rev-parse","--verify","--quiet",`refs/remotes/origin/${c}`]),n=`refs/remotes/origin/${c}`}catch{n=null}try{m?await l(g,["worktree","add","--",j,c],3e5):n?await l(g,["worktree","add","-b",c,"--",j,n],3e5):await l(g,["worktree","add","-b",c,"--",j],3e5)}catch(a){throw Error(u(a))}return(0,h.wz)(j),k(),{path:j,branch:c}}async function t(a,b,c=!1){let d=q(await p(a),b);if(!d)throw Error(`Not a worktree of this repository: ${b}`);if(d.isMain)throw Error("Cannot remove the main worktree");try{await l(a,["worktree","remove",...c?["--force"]:[],d.path])}catch(a){throw Error(u(a))}k()}function u(a){let b=a.stderr;return"string"==typeof b&&b.trim()?b.trim():a instanceof Error?a.message:String(a)}},25252:(a,b,c)=>{"use strict";c.d(b,{HM:()=>f,Nw:()=>e,wz:()=>g});var d=c(58864);function e(a){return(0,d.W3)(a)}function f(){return globalThis.__piAdditionalAllowedRoots||(globalThis.__piAdditionalAllowedRoots=new Set),globalThis.__piAdditionalAllowedRoots}function g(a){if(!a)return;let b=e(a);f().add(b),globalThis.__piAllowedRootsCache?.roots.add(b)}},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")},44508:(a,b,c)=>{"use strict";c.d(b,{J:()=>g,N:()=>e});var d=c(76851);let e="https://models.dev/api.json";async function f(){let a=await fetch(e,{cache:"no-store",headers:{Accept:"application/json"},signal:AbortSignal.timeout(15e3)});if(!a.ok)throw Error(`models.dev returned HTTP ${a.status}`);let b=(0,d.Zw)(await a.json());if(0===b.length)throw Error("models.dev returned an empty catalog");return b}async function g(){let a=globalThis.__piModelsDevCatalogCache??={entries:[],expiresAt:0};if(a.entries.length>0&&a.expiresAt>Date.now())return a.entries;a.inFlight||(a.inFlight=f().then(b=>(a.entries=b,a.expiresAt=Date.now()+36e5,b)).finally(()=>{a.inFlight=void 0}));try{return await a.inFlight}catch(b){if(a.entries.length>0)return a.entries;throw b}}},44870:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},45902:(a,b,c)=>{"use strict";c.d(b,{$:()=>f});var d=c(76760),e=c.n(d);function f(a,b=process.platform){let c="win32"===b?e().win32.normalize(a):e().posix.normalize(a);return"win32"===b?c.toLowerCase():c}},50842:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.r(b),c.d(b,{GET:()=>l,dynamic:()=>m});var e=c(23211),f=c(75430),g=c(76851),h=c(44508),i=c(74313),j=c(24923),k=a([f,i]);[f,i]=k.then?(await k)():k;let m="force-dynamic",n=a=>!!(a&&(a.input>0||a.output>0));async function l(){try{let a=(0,i.xh)(),[b,c,d]=await Promise.all([a.planned.then(()=>Promise.race([a.promise.then(()=>!0),new Promise(a=>setTimeout(a,1500,!1))])),f.ModelRuntime.create(),(0,h.J)().catch(()=>[])]),k=(0,i.o7)(),l=new Map;await Promise.all([...new Set(k.map(a=>a.cwd))].map(async a=>{l.set(a,a?(await (0,j.KI)(a)).projectRoot:"")}));let m=c.getModels(),o={records:(0,i.O6)(k,(a,b)=>{let e=c.getModel(a,b)?.cost;if(n(e))return e;let f=m.find(a=>a.id===b&&n(a.cost))?.cost;if(f)return f;let h=(0,g._$)(d,b,a).price;return"reliable"===h.status?h.cost:null},a=>l.get(a)??a),scan:b||0===a.total?null:{done:a.done,total:a.total}};return e.NextResponse.json(o)}catch(a){return e.NextResponse.json({error:a instanceof Error?a.message:String(a)},{status:500})}}d()}catch(a){d(a)}})},55511:a=>{"use strict";a.exports=require("crypto")},58864:(a,b,c)=>{"use strict";c.d(b,{A_:()=>g,Eb:()=>k,W3:()=>i,gB:()=>h,uK:()=>f});var d=c(33873);let e=/^[a-zA-Z]:[\\/]/;function f(a){return e.test(a)||a.startsWith("\\\\")||a.startsWith("//")}function g(a){let b=a.join("/"),c=i(b);return/^[a-zA-Z]:$/.test(c)?`${c}/`:f(c)?c:"/"+b.replace(/^\/+/,"")}function h(a){return a&&"win32"===process.platform?(0,d.normalize)(a):a}function i(a){return a.replace(/\\/g,"/")}function j(a){let b=(0,d.normalize)(h(a)),c=(0,d.parse)(b).root.length,e=b.length;for(;e>c&&b[e-1]===d.sep;)e--;return b.slice(0,e)}function k(a,b){if(a===b)return!0;if(!a||!b)return!1;let c=j(a),d=j(b);return"win32"===process.platform?c.toLowerCase()===d.toLowerCase():c===d}},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},74313:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{H2:()=>w,O6:()=>n,o7:()=>v,xh:()=>u});var e=c(29021),f=c(79748),g=c(33873),h=c(75430),i=c(8102),j=c(45902),k=c(6093),l=a([h]);function m(a){let b,c=a.split("\n");try{b=JSON.parse(c[0])}catch{return{cwd:"",rows:[]}}let d="string"==typeof b.cwd?b.cwd:"",e=Date.parse(b.timestamp??"");if(!Number.isFinite(e))return{cwd:d,rows:[]};let f=new Map;for(let a of c){let b;if(!a.includes('"usage"'))continue;try{b=JSON.parse(a)}catch{continue}let c=b.message,d=c?.usage;if(c?.role!=="assistant"||!d)continue;let g="number"==typeof c.timestamp?c.timestamp:Date.parse(b.timestamp??"");if(!Number.isFinite(g)||g<e)continue;let h=new Date(g),i=(0,k.EL)(h),j=h.getHours(),l=String(c.provider??""),m=String(c.model??""),n=`${i}\0${j}\0${l}\0${m}`,o=f.get(n);o||(o={day:i,hour:j,provider:l,model:m,messages:0,input:0,output:0,cacheRead:0,cacheWrite:0,recordedCost:0},f.set(n,o)),o.messages+=1,o.input+=d.input??0,o.output+=d.output??0,o.cacheRead+=d.cacheRead??0,o.cacheWrite+=d.cacheWrite??0,o.recordedCost+=d.cost?.total??0}return{cwd:d,rows:[...f.values()]}}function n(a,b,c){let d=new Map,e=new Map;for(let f of a){let a=c(f.cwd);for(let c of f.rows){let f=`${c.provider}\0${c.model}`;d.has(f)||d.set(f,b(c.provider,c.model));let g=d.get(f),h=c.hour??null,i=c.model.slice(c.model.lastIndexOf("/")+1),j=`${c.day}\0${h}\0${i}\0${a}`,k=e.get(j);k||(k={day:c.day,hour:h,model:i,project:a,messages:0,input:0,output:0,cacheRead:0,cacheWrite:0,cost:0,unpriced:0},e.set(j,k)),k.messages+=c.messages,k.input+=c.input,k.output+=c.output,k.cacheRead+=c.cacheRead,k.cacheWrite+=c.cacheWrite,k.cost+=g?(c.input*g.input+c.output*g.output+c.cacheRead*g.cacheRead+c.cacheWrite*g.cacheWrite)/1e6:c.recordedCost,g||0!==c.recordedCost||(k.unpriced+=c.messages)}}return[...e.values()]}function o(){return(0,g.join)((0,h.getAgentDir)(),"pi-web-usage-cache.json")}function p(){try{let a=JSON.parse((0,e.readFileSync)(o(),"utf8"));if(!a.files)return new Map;if(2===a.version)return new Map(Object.entries(a.files));if(1===a.version)return new Map(Object.entries(a.files).map(([a,{size:b,mtimeMs:c,rows:d}])=>[a,{size:b,mtimeMs:c,rows:d}]))}catch{}return new Map}function q(){return globalThis.__piUsageCache??=p()}function r(a){for(let[b,c]of p())a.has(b)||a.set(b,c);(0,i.$)(o(),JSON.stringify({version:2,files:Object.fromEntries(a)}))}h=(l.then?(await l)():l)[0];let x=(a,b,c)=>void 0!==a&&void 0!==a.cwd&&a.size===b&&a.mtimeMs===c;async function s(){let a=(0,g.join)((0,h.getAgentDir)(),"sessions");try{return(await (0,f.readdir)(a,{recursive:!0})).filter(a=>a.endsWith(".jsonl")).map(b=>(0,g.join)(a,b))}catch{return[]}}async function t(a,b){let c=q(),d=(await Promise.all((await s()).map(async a=>{try{let{size:b,mtimeMs:c}=await (0,f.stat)(a);return{path:a,key:(0,j.$)(a),size:b,mtimeMs:c}}catch{return null}}))).filter(a=>null!==a&&!x(c.get(a.key),a.size,a.mtimeMs));for(let e of(a.total=d.length,b(),d)){try{c.set(e.key,{size:e.size,mtimeMs:e.mtimeMs,...m(await (0,f.readFile)(e.path,"utf8"))})}catch{}a.done+=1}d.length>0&&r(c)}function u(){let a;if(globalThis.__piUsageScanState)return globalThis.__piUsageScanState;let b={done:0,total:0,planned:new Promise(b=>{a=b}),promise:Promise.resolve()};return b.promise=t(b,a).finally(()=>{a(),globalThis.__piUsageScanState=void 0}),globalThis.__piUsageScanState=b}function v(){return[...q().values()].map(a=>({cwd:a.cwd??"",rows:a.rows}))}function w(a){let b=q(),c=!1;for(let d of a){if(!(0,e.existsSync)(d))continue;let a=(0,j.$)(d),{size:f,mtimeMs:g}=(0,e.statSync)(d);x(b.get(a),f,g)||(b.set(a,{size:f,mtimeMs:g,...m((0,e.readFileSync)(d,"utf8"))}),c=!0)}c&&r(b)}d()}catch(a){d(a)}})},75430:a=>{"use strict";a.exports=import("@earendil-works/pi-coding-agent")},76760:a=>{"use strict";a.exports=require("node:path")},76851:(a,b,c)=>{"use strict";c.d(b,{VO:()=>s,Zw:()=>q,_$:()=>r});let d={anthropic:["api.anthropic.com"],google:["generativelanguage.googleapis.com"],openai:["api.openai.com"],openrouter:["openrouter.ai"]},e=new Set(["text","image"]);function f(a){return"object"==typeof a&&null!==a&&!Array.isArray(a)}function g(a){return"string"==typeof a&&a.trim()?a.trim():void 0}function h(a){return"number"==typeof a&&Number.isFinite(a)&&a>=0?a:void 0}function i(a){return"number"==typeof a&&Number.isFinite(a)&&a>0?a:void 0}function j(a){return a.trim().toLocaleLowerCase().replace(/[^a-z0-9]/g,"")}function k(a){return a.trim().toLocaleLowerCase().replace(/^models\//,"")}function l(a){if(a)try{return new URL(a).hostname.toLocaleLowerCase().replace(/\.$/,"")}catch{return}}function m(a){return void 0!==a.cost.input&&void 0!==a.cost.output}function n(a,b,c){if(0===a.length||b<=0)return;let d=new Map;for(let b of a){let a=c(b),e=d.get(a);e?e.count+=1:d.set(a,{value:b,count:1})}let e=[...d.values()].sort((a,b)=>b.count-a.count),f=e[0];if(f&&!(f.count/b<.6)&&e[1]?.count!==f.count)return f.value}function o(a){if(0===a.length)return;let b=new Map;for(let c of a)b.set(c,(b.get(c)??0)+1);let c=[...b.entries()].sort((a,b)=>b[1]-a[1]);if(c[0]&&c[1]?.[1]!==c[0][1])return c[0][0]}function p(a,b){return{status:"reliable",method:b,cost:{input:a.cost.input,output:a.cost.output,cacheRead:a.cost.cacheRead??0,cacheWrite:a.cost.cacheWrite??0},providerId:a.providerId,providerName:a.providerName,support:1,total:1}}function q(a){if(!f(a))return[];let b=[];for(let[d,j]of Object.entries(a)){if(!f(j)||!f(j.models))continue;let a=g(j.name)??d,k=g(j.api);for(let[l,m]of Object.entries(j.models)){var c;if(!f(m))continue;let j=g(m.id)??l;if(!j)continue;let n=g(m.name)??j,o={key:`${d}/${j}`,providerId:d,providerName:a,id:j,name:n,cost:f(c=m.cost)?{input:h(c.input),output:h(c.output),cacheRead:h(c.cache_read),cacheWrite:h(c.cache_write)}:{}};k&&(o.providerBaseUrl=k),"boolean"==typeof m.reasoning&&(o.reasoning=m.reasoning);let p=function(a){if(!f(a)||!Array.isArray(a.input))return;let b=Array.from(new Set(a.input.filter(a=>"string"==typeof a).map(a=>a.trim().toLocaleLowerCase()).filter(a=>e.has(a))));return b.length?b:void 0}(m.modalities);if(p&&(o.input=p),f(m.limit)){let a=i(m.limit.context),b=i(m.limit.output);void 0!==a&&(o.contextWindow=a),void 0!==b&&(o.maxTokens=b)}b.push(o)}}return b}function r(a,b,c="",e=""){let f,g=a.filter(a=>(function(a,b){let c=k(b);if(!c)return!1;let d=k(a.id),e=`${a.providerId.toLocaleLowerCase()}/${d}`;return d===c||e===c})(a,b));if(0===g.length)return{exactMatches:0,metadataMethod:"none",preset:{},price:{status:"unreliable",reason:"no-exact-match",support:0,total:0}};let h=g.filter(a=>{let b;return!!(b=j(c))&&(j(a.providerId)===b||j(a.providerName)===b)}),i=g.filter(a=>(function(a,b){let c=l(b);if(!c)return!1;let e=d[j(a.providerId)]??[],f=l(a.providerBaseUrl);return[...e,...f?[f]:[]].some(a=>c===a||c.endsWith(`.${a}`))})(a,e)),q=h[0]??i[0],s=h.length?"provider":i.length?"base-url":"consensus",t=q?{name:q.name,reasoning:q.reasoning,input:q.input,contextWindow:q.contextWindow,maxTokens:q.maxTokens}:(f=g.length,{name:n(g.map(a=>a.name),f,a=>a.toLocaleLowerCase()),reasoning:n(g.flatMap(a=>void 0===a.reasoning?[]:[a.reasoning]),f,String),input:n(g.flatMap(a=>a.input?[a.input]:[]),f,a=>[...a].sort().join(",")),contextWindow:n(g.flatMap(a=>void 0===a.contextWindow?[]:[a.contextWindow]),f,String),maxTokens:n(g.flatMap(a=>void 0===a.maxTokens?[]:[a.maxTokens]),f,String)}),u=h.find(m),v=i.find(m),w=u?p(u,"provider"):v?p(v,"base-url"):function(a){let b=a.filter(m);if(0===b.length)return{status:"unreliable",reason:"no-valid-price",support:0,total:0};if(1===b.length)return{status:"unreliable",reason:"insufficient-support",support:1,total:1};let c=new Map;for(let a of b){let b=JSON.stringify([a.cost.input,a.cost.output]),d=c.get(b);d?d.push(a):c.set(b,[a])}let d=[...c.values()].sort((a,b)=>b.length-a.length),e=d[0];if(!e)return{status:"unreliable",reason:"no-valid-price",support:0,total:b.length};let f=e.length/b.length>=.6||e.length>=5;if(d[1]?.length===e.length||!f)return{status:"unreliable",reason:"conflict",support:e.length,total:b.length};let g=o(e.map(a=>a.cost.cacheRead??0))??0,h=o(e.map(a=>a.cost.cacheWrite??0))??0;return{status:"reliable",method:"consensus",cost:{input:e[0].cost.input,output:e[0].cost.output,cacheRead:g,cacheWrite:h},support:e.length,total:b.length}}(g);return"reliable"===w.status&&(t.cost=w.cost),{exactMatches:g.length,metadataMethod:s,matchedProviderId:q?.providerId,matchedProviderName:q?.providerName,preset:t,price:w}}function s(a,b,c="",d=50){let e=b.trim().toLocaleLowerCase(),f=c.trim().toLocaleLowerCase(),g=Math.max(1,Math.min(100,Math.floor(d)||50));return a.map(a=>{let b,c,d,g,h,i;return{entry:a,rank:(b=a.id.toLocaleLowerCase(),c=a.name.toLocaleLowerCase(),d=a.providerId.toLocaleLowerCase(),g=a.providerName.toLocaleLowerCase(),h=`${d}/${b}`,i=20,e?b===e||h===e?i=0:c===e?i=1:b.startsWith(e)||c.startsWith(e)?i=2:h.startsWith(e)||d===e||g===e?i=3:b.includes(e)||c.includes(e)?i=4:(h.includes(e)||g.includes(e))&&(i=5):i=10,i<20&&f&&(d===f||g===f)&&(i-=.5),i)}}).filter(({rank:a})=>!e||a<20).sort((a,b)=>a.rank-b.rank||a.entry.providerName.localeCompare(b.entry.providerName,void 0,{sensitivity:"base"})||a.entry.name.localeCompare(b.entry.name,void 0,{numeric:!0,sensitivity:"base"})||a.entry.id.localeCompare(b.entry.id,void 0,{numeric:!0,sensitivity:"base"})).slice(0,g).map(({entry:a})=>a)}},78335:()=>{},79407:(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/usage/route",pathname:"/api/usage",filename:"route",bundlePath:"app/api/usage/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/home/zhujunshen/pi-web/app/api/usage/route.ts",nextConfigOutput:"",userland:()=>c(50842),...{}}),{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/usage/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)}}},79646:a=>{"use strict";a.exports=require("child_process")},79748:a=>{"use strict";a.exports=require("fs/promises")},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=79407));module.exports=c})();