@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=6849,a.ids=[6849],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},1932:a=>{"use strict";a.exports=require("url")},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},4573:a=>{"use strict";a.exports=require("node:buffer")},4896:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{a:()=>i});var e=c(75430),f=a([e]);function g(a){return a?"totalTokens"in a&&"number"==typeof a.totalTokens&&a.totalTokens>0?a.totalTokens:(a.input??0)+(a.output??0)+(a.cacheRead??0)+(a.cacheWrite??0):0}async function h(a,b,c){if(!b)return 0;try{let d=c??await (!globalThis.__piStaticModelRuntime&&(globalThis.__piStaticModelRuntime=e.ModelRuntime.create().catch(a=>{throw delete globalThis.__piStaticModelRuntime,a})),globalThis.__piStaticModelRuntime),f=d.getModel(a,b);if(f?.contextWindow&&f.contextWindow>0)return f.contextWindow;let g=d.getModels(),h=g.find(a=>a.id===b&&a.contextWindow>0);if(h?.contextWindow)return h.contextWindow;let i=g.find(a=>(a.id.endsWith(`/${b}`)||b.endsWith(`/${a.id}`))&&a.contextWindow>0);if(i?.contextWindow)return i.contextWindow;let j=b.toLowerCase();if(j.includes("gemini"))return 1048576;if(j.includes("claude-3-7")||j.includes("claude-sonnet-4")||j.includes("claude-opus-4"))return j.includes("opus-4-6")||j.includes("sonnet-4-6")?1e6:2e5;if(j.includes("gpt-4o")||j.includes("o1")||j.includes("o3"))return 128e3;if(j.includes("deepseek"))return 64e3}catch{}return 0}async function i(a,b,c){try{let d;if(Array.isArray(a))if(b){let c=new Map;for(let b of a)"id"in b&&"string"==typeof b.id&&c.set(b.id,b);let e=[],f=b;for(;f;){let a=c.get(f);if(!a)break;e.push(a),f="parentId"in a?a.parentId:void 0}e.reverse(),d=e}else d=a;else d="getBranch"in a&&"function"==typeof a.getBranch?b?a.getBranch(b):a.getBranch():"getEntries"in a&&"function"==typeof a.getEntries?a.getEntries()??[]:[];if(0===d.length)return null;let f=function(a){for(let b=a.length-1;b>=0;b--){let c=a[b];if("model_change"===c.type&&c.modelId)return{provider:c.provider||"",modelId:c.modelId};if("message"===c.type&&"assistant"===c.message.role&&c.message.model)return{provider:c.message.provider||"",modelId:c.message.model}}return null}(d),i=f?await h(f.provider,f.modelId,c):0,j=function(a){for(let b=a.length-1;b>=0;b--)if("compaction"===a[b].type)return a[b];return null}(d);if(j){let a=d.lastIndexOf(j),b=!1;for(let c=d.length-1;c>a;c--){let a=d[c];if("message"===a.type&&"assistant"===a.message.role){let c=a.message.usage;if(c&&g(c)>0){b=!0;break}}}if(!b)return i>0?{tokens:null,contextWindow:i,percent:null}:null}let k=(0,e.getLastAssistantUsage)(d),l=k?g(k):null;if(null===l&&i<=0)return null;let m=null!==l&&i>0?Math.min(100,Math.round(l/i*1e3)/10):null;return{tokens:l,contextWindow:i,percent:m}}catch{return null}}e=(f.then?(await f)():f)[0],d()}catch(a){d(a)}})},8128:a=>{"use strict";a.exports=require("next/dist/server/runtime-reacts.external.js")},10846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},12412:a=>{"use strict";a.exports=require("assert")},14858:(a,b,c)=>{"use strict";function d(a){return"object"==typeof a&&null!==a&&!Array.isArray(a)}function e(a,b){if("string"!=typeof b||a.length>40)return a;let c=b.replace(/\s+/g," ").trim();if(!c)return a;let d=a?" ":"",e=a+d;if(e.length>=41)return e.slice(0,41);let f=41-e.length;return e+c.slice(0,f)}function f(a){if("message"!==a.type||!d(a.message)||"string"!=typeof a.message.role||"system"===a.message.role)return;let b=a.message.content,c="",f=!1;if("string"==typeof b)c=e(c,b);else if(Array.isArray(b)){for(let a of b)if(d(a)&&("image"===a.type&&(f=!0),"text"===a.type&&(c=e(c,a.text)),c.length>40))break}c.length>40?c=c.slice(0,40)+"…":c||(c=f?"[image]":"assistant"===a.message.role?"[assistant]":"message");let g="user"===a.message.role||"assistant"===a.message.role?a.message.role:void 0;return{...g?{role:g}:{},text:c}}function g(a){let b=new Set,c=new Set(a),d=new Set,e=[...a];for(;e.length>0;){let a=e.pop();if(!d.has(a))for(let f of(d.add(a),(c.has(a)||1!==a.children.length)&&b.add(a),a.children))e.push(f)}let g=(a,b,c)=>({...a,children:[],...b?.length?{compressedEntryIds:b}:{},...c?{branchPreview:c}:{}}),h=a.map(a=>g(a,void 0,f(a.entry))),i=a.map((a,b)=>({source:a,projected:h[b],depth:1})),j=(a,c)=>{let d=[{node:a,compressedEntryIds:[],branchPreview:void 0}],e=new Set;for(;d.length>0;){let{node:a,compressedEntryIds:h,branchPreview:i}=d.pop();if(e.has(a))continue;e.add(a);let j=i??f(a.entry);b.has(a)&&c.children.push(g(a,h,j));for(let c=a.children.length-1;c>=0;c--)d.push({node:a.children[c],compressedEntryIds:b.has(a)?[]:[...h,a.entry.id],branchPreview:b.has(a)?void 0:j})}};for(;i.length>0;){let{source:a,projected:c,depth:d}=i.pop();for(let e of a.children){let a=e;if(d>=200){j(a,c);continue}let h=[],k=f(a.entry);for(;!b.has(a)&&1===a.children.length;)h.push(a.entry.id),a=a.children[0],k??=f(a.entry);if(!b.has(a))continue;let l=g(a,h,k);c.children.push(l),i.push({source:a,projected:l,depth:d+1})}}return h}c.d(b,{y:()=>g})},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},21906:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{CQ:()=>k,GW:()=>m,JS:()=>l});var e=c(55511),f=c(29021),g=c(33873),h=c(45902),i=c(7048),j=a([i]);function k(a){let b=(0,f.readFileSync)(a,"utf8"),c=b.split("\n"),d=c.map(a=>{if(!a.trim())return null;try{return JSON.parse(a)}catch{return null}}),e=d[0];if(e?.type!=="session"||"string"!=typeof e.id)return null;let g=d.slice(1).filter(a=>null!==a);return{path:a,pathKey:(0,h.$)(a),id:e.id,parentPath:"string"==typeof e.parentSession?e.parentSession:void 0,lines:c,entries:g,original:b,isSubagent:!!(0,i.$u)(g,e.id,a)}}function l(a,b,c){let d=[...a.lines],e=JSON.parse(d[0]);if(b?e.parentSession=b:delete e.parentSession,d[0]=JSON.stringify(e),a.isSubagent){if(!b||!c)throw Error("Cannot reparent a subagent without a valid parent session");for(let a=1;a<d.length;a+=1){let e;try{e=JSON.parse(d[a])}catch{continue}"custom"!==e.type||e.customType!==i.tP||"object"!=typeof e.data||null===e.data||Array.isArray(e.data)||(e.data={...e.data,parentSessionId:c,parentSessionPath:b},d[a]=JSON.stringify(e))}}return d.join("\n")}function m(a){let b=[];try{for(let c of a){if(!(0,f.existsSync)(c))continue;let a=(0,g.join)((0,g.dirname)(c),`.${(0,g.basename)(c)}-${(0,e.randomUUID)()}.deleting`);try{(0,f.renameSync)(c,a)}catch(a){if("ENOENT"===a.code)continue;throw a}b.push({original:c,staged:a})}}catch(a){for(let a of b.reverse())try{(0,f.renameSync)(a.staged,a.original)}catch{}throw a}for(let a of b)try{(0,f.unlinkSync)(a.staged)}catch{}}i=(j.then?(await j)():j)[0],d()}catch(a){d(a)}})},27910:a=>{"use strict";a.exports=require("stream")},28354:a=>{"use strict";a.exports=require("util")},28802:a=>{"use strict";a.exports=import("@earendil-works/pi-ai")},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")},29862:a=>{"use strict";a.exports=import("@earendil-works/pi-tui")},31421:a=>{"use strict";a.exports=require("node:child_process")},33873:a=>{"use strict";a.exports=require("path")},33920:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{Zg:()=>k,fi:()=>l});var e=c(29021),f=c(33873),g=c(75430),h=c(8102),i=a([g]);function j(a=(0,g.getAgentDir)()){return(0,f.join)(a,"pi-web","pinned-sessions.json")}function k(a=j()){let b;try{b=(0,e.readFileSync)(a,"utf8")}catch(a){if("ENOENT"===a.code)return[];throw a}let c=JSON.parse(b);return Array.isArray(c)?c.filter(a=>"string"==typeof a):[]}function l(a,b,c=j()){let d=k(c).filter(b=>b!==a);return b&&d.push(a),(0,e.mkdirSync)((0,f.dirname)(c),{recursive:!0}),(0,h.$)(c,JSON.stringify(d)),d}g=(i.then?(await i)():i)[0],d()}catch(a){d(a)}})},44870:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},48161:a=>{"use strict";a.exports=require("node:os")},51181:a=>{"use strict";a.exports=require("web-push")},51455:a=>{"use strict";a.exports=require("node:fs/promises")},55511:a=>{"use strict";a.exports=require("crypto")},57975:a=>{"use strict";a.exports=require("node:util")},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},63406:(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/sessions/[id]/route",pathname:"/api/sessions/[id]",filename:"route",bundlePath:"app/api/sessions/[id]/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/home/zhujunshen/pi-web/app/api/sessions/[id]/route.ts",nextConfigOutput:"",userland:()=>c(98192),...{}}),{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/sessions/[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)}}},72322:a=>{"use strict";a.exports=import("@earendil-works/pi-ai/utils/pi-user-agent")},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")},77598:a=>{"use strict";a.exports=require("node:crypto")},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")},81115:a=>{"use strict";a.exports=require("constants")},86439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},89691:(a,b,c)=>{"use strict";function d(a){let b,c=0;for(let e of a){var d;if("message"!==(d=e.type)&&"compaction"!==d&&"branch_summary"!==d&&"custom_message"!==d)continue;let a=Date.parse(e.timestamp);if(!Number.isFinite(a))continue;let f="message"===e.type?e.message?.role:void 0;if("user"===f||"bashExecution"===f){b=a;continue}void 0!==b&&a>b&&(c+=a-b),b=a}return c}c.d(b,{c:()=>d})},94735:a=>{"use strict";a.exports=require("events")},96487:()=>{},98192:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.r(b),c.d(b,{DELETE:()=>x,GET:()=>v,PATCH:()=>w});var e=c(23211),f=c(29021),g=c(33873),h=c(21906),i=c(75430),j=c(40402),k=c(45902),l=c(56429),m=c(14858),n=c(89691),o=c(88914),p=c(4896),q=c(7048),r=c(21560),s=c(8102),t=c(33920),u=a([h,i,j,l,p,q,t]);async function v(a,{params:b}){let{id:c}=await b;try{let b,d="1"===new URL(a.url).searchParams.get("force"),g=function(a,b){let c=(0,l.getRpcSession)(a);if(!c?.isAlive())return;if(!b)return c;let d=c.sessionFile;if(!d||c.isRunning())return c;let e=(0,j.xL)(d);return e.overlongLine?(console.log(`[pi-web] session ${a} tail exceeds the probe window; rebuilding from the file`),(0,l.releaseRpcSessionForExternalWrite)(a)?void 0:c):!e.entryId||c.inner.sessionManager.getEntries().some(a=>a?.id===e.entryId)?c:(console.log(`[pi-web] session ${a} changed on disk; rebuilding from the file`),(0,l.releaseRpcSessionForExternalWrite)(a)?void 0:c)}(c,d),h=g?null:await (0,j.os)(c);if(!g&&!h)return e.NextResponse.json({error:"Session not found"},{status:404});let k=g?.inner.sessionManager??i.SessionManager.open(h),s=g?.sessionFile||k.getSessionFile()||h||"",t=k.getEntries(),u=k.getLeafId(),v=(0,m.y)(k.getTree()),w=new URL(a.url).searchParams,x=w.has("deferThinking"),y=w.has("deferMedia"),z=Number(w.get("tail")),A=Number.isFinite(z)&&z>0?Math.min(z,1e3):200,B=(0,j.Uv)(t,u,{deferThinking:x,deferToolResultImages:y,tail:A,sessionId:c}),C=(0,n.c)(t),D=(0,o.P)(t),E=g?.inner?.getContextUsage?.()??await (0,p.a)(k,u),F=k.getSessionName(),G=t.find(a=>"message"===a.type&&"user"===a.message.role),H=G?.type==="message"?G.message:void 0,I=k.getHeader(),J=I?.timestamp??new Date().toISOString();try{J=(0,f.statSync)(s).mtime.toISOString()}catch{}let K=I?.parentSession?await (0,j.u1)(I.parentSession):void 0,L=I?(0,q.$u)(t,I.id,s):null,M=L?await (0,l.getSubagentRun)(c):null,N=(0,q.ph)(t)?.tools??(0,r.dS)(t),O=I?(await (0,j.zH)([{path:s,id:I.id,cwd:I.cwd??"",name:F,created:I.timestamp,modified:J,messageCount:D.totalMessages,firstMessage:H?(b=H.content,"string"==typeof b?b:(Array.isArray(b)?b.find(a=>"text"===a.type)?.text??"":"")||"(no messages)"):"(no messages)",parentSessionId:K,...L?{relation:{kind:"subagent",parentSessionId:L.parentSessionId,profile:L.profile,description:L.description,status:M?.status??L.status}}:I.parentSession?{relation:{kind:"fork",...K?{originSessionId:K}:{}}}:{},transient:!s||!(0,f.existsSync)(s)}]))[0]:null;return e.NextResponse.json({sessionId:c,filePath:s,info:O,leafId:u,tree:v,context:B,stats:D,...E?{contextUsage:E}:{},totalActiveMs:C,...void 0!==N?{toolNames:N}:{}})}catch(a){return e.NextResponse.json({error:String(a)},{status:500})}}async function w(a,{params:b}){let{id:c}=await b;try{let{name:b,pinned:d}=await a.json();if("string"!=typeof b&&"boolean"!=typeof d)return e.NextResponse.json({error:"name or pinned is required"},{status:400});let f=await (0,j.os)(c);if(!f)return e.NextResponse.json({error:"Session not found"},{status:404});return"boolean"==typeof d&&(0,t.fi)(c,d),"string"==typeof b&&i.SessionManager.open(f).appendSessionInfo(b.trim()),(0,j.mD)(),e.NextResponse.json({ok:!0})}catch(a){return e.NextResponse.json({error:String(a)},{status:500})}}async function x(a,{params:b}){let{id:c}=await b;try{let a,b=await (0,j.os)(c);if(!b||!(0,f.existsSync)(b)){let a=(0,l.getRpcSession)(c);if(!a)return b&&(0,j.BR)(c),e.NextResponse.json({error:"Session not found"},{status:404});let d=a.sessionFile||b;if(await a.shutdown(),d)try{(0,f.unlinkSync)(d)}catch(a){if("ENOENT"!==a.code)throw a}return(0,j.BR)(c),(0,j.mD)(),e.NextResponse.json({ok:!0})}let d=(0,j.eP)(b)?.parentSession;if(d)try{a=(0,j.eP)(d)?.id}catch{a=void 0}let i=(0,k.$)(b),m=(0,g.dirname)(b),n=(0,f.readdirSync)(m).filter(a=>a.endsWith(".jsonl")).map(a=>(0,h.CQ)((0,g.join)(m,a))).filter(a=>null!==a),o=n.find(a=>a.pathKey===i);if(!o||o.id!==c)return e.NextResponse.json({error:"Session changed while preparing deletion"},{status:409});let p=new Map;for(let a of n){if(!a.parentPath)continue;let b=(0,k.$)(a.parentPath);p.set(b,[...p.get(b)??[],a])}let q=p.get(i)??[],r=new Set;if(!d){let a=q.filter(a=>a.isSubagent);for(;a.length>0;){let b=a.shift();r.has(b.pathKey)||(r.add(b.pathKey),a.push(...p.get(b.pathKey)??[]))}}let t=n.filter(a=>r.has(a.pathKey)),u=q.filter(a=>!r.has(a.pathKey));if(u.some(a=>a.isSubagent)&&(!d||!a))return e.NextResponse.json({error:"Cannot reparent subagent session"},{status:409});let v=[o,...t,...u],w=await (0,l.reserveRpcSessionFileMutation)(v.map(a=>a.id));if(!w)return e.NextResponse.json({error:"Session is busy"},{status:409});try{if(v.some(a=>{try{return(0,f.readFileSync)(a.path,"utf8")!==a.original}catch{return!0}}))return e.NextResponse.json({error:"Session changed while preparing deletion"},{status:409});let g=u.map(b=>({record:b,updated:(0,h.JS)(b,d,a)})),i=[];try{for(let{record:a,updated:b}of g)(0,s.$)(a.path,b),i.push(a);(0,h.GW)([b,...t.map(a=>a.path)])}catch(a){for(let a of i.reverse())try{(0,s.$)(a.path,a.original)}catch{}throw a}for(let a of((0,j.BR)(c),t))(0,j.BR)(a.id);return(0,j.mD)(),e.NextResponse.json({ok:!0})}finally{w()}}catch(a){return e.NextResponse.json({error:String(a)},{status:500})}}[h,i,j,l,p,q,t]=u.then?(await u)():u,d()}catch(a){d(a)}})}};var b=require("../../../../webpack-runtime.js");b.C(a);var c=b.X(0,[4741,1813,426,974,402,6759,2243,6429],()=>b(b.s=63406));module.exports=c})();
1
+ (()=>{var a={};a.id=6849,a.ids=[6849],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},1932:a=>{"use strict";a.exports=require("url")},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},4573:a=>{"use strict";a.exports=require("node:buffer")},4896:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{a:()=>i});var e=c(75430),f=a([e]);function g(a){return a?"totalTokens"in a&&"number"==typeof a.totalTokens&&a.totalTokens>0?a.totalTokens:(a.input??0)+(a.output??0)+(a.cacheRead??0)+(a.cacheWrite??0):0}async function h(a,b,c){if(!b)return 0;try{let d=c??await (!globalThis.__piStaticModelRuntime&&(globalThis.__piStaticModelRuntime=e.ModelRuntime.create().catch(a=>{throw delete globalThis.__piStaticModelRuntime,a})),globalThis.__piStaticModelRuntime),f=d.getModel(a,b);if(f?.contextWindow&&f.contextWindow>0)return f.contextWindow;let g=d.getModels(),h=g.find(a=>a.id===b&&a.contextWindow>0);if(h?.contextWindow)return h.contextWindow;let i=g.find(a=>(a.id.endsWith(`/${b}`)||b.endsWith(`/${a.id}`))&&a.contextWindow>0);if(i?.contextWindow)return i.contextWindow;let j=b.toLowerCase();if(j.includes("gemini"))return 1048576;if(j.includes("claude-3-7")||j.includes("claude-sonnet-4")||j.includes("claude-opus-4"))return j.includes("opus-4-6")||j.includes("sonnet-4-6")?1e6:2e5;if(j.includes("gpt-4o")||j.includes("o1")||j.includes("o3"))return 128e3;if(j.includes("deepseek"))return 64e3}catch{}return 0}async function i(a,b,c){try{let d;if(Array.isArray(a))if(b){let c=new Map;for(let b of a)"id"in b&&"string"==typeof b.id&&c.set(b.id,b);let e=[],f=b;for(;f;){let a=c.get(f);if(!a)break;e.push(a),f="parentId"in a?a.parentId:void 0}e.reverse(),d=e}else d=a;else d="getBranch"in a&&"function"==typeof a.getBranch?b?a.getBranch(b):a.getBranch():"getEntries"in a&&"function"==typeof a.getEntries?a.getEntries()??[]:[];if(0===d.length)return null;let f=function(a){for(let b=a.length-1;b>=0;b--){let c=a[b];if("model_change"===c.type&&c.modelId)return{provider:c.provider||"",modelId:c.modelId};if("message"===c.type&&"assistant"===c.message.role&&c.message.model)return{provider:c.message.provider||"",modelId:c.message.model}}return null}(d),i=f?await h(f.provider,f.modelId,c):0,j=function(a){for(let b=a.length-1;b>=0;b--)if("compaction"===a[b].type)return a[b];return null}(d);if(j){let a=d.lastIndexOf(j),b=!1;for(let c=d.length-1;c>a;c--){let a=d[c];if("message"===a.type&&"assistant"===a.message.role){let c=a.message.usage;if(c&&g(c)>0){b=!0;break}}}if(!b)return i>0?{tokens:null,contextWindow:i,percent:null}:null}let k=(0,e.getLastAssistantUsage)(d),l=k?g(k):null;if(null===l&&i<=0)return null;let m=null!==l&&i>0?Math.min(100,Math.round(l/i*1e3)/10):null;return{tokens:l,contextWindow:i,percent:m}}catch{return null}}e=(f.then?(await f)():f)[0],d()}catch(a){d(a)}})},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())}`},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")},14858:(a,b,c)=>{"use strict";function d(a){return"object"==typeof a&&null!==a&&!Array.isArray(a)}function e(a,b){if("string"!=typeof b||a.length>40)return a;let c=b.replace(/\s+/g," ").trim();if(!c)return a;let d=a?" ":"",e=a+d;if(e.length>=41)return e.slice(0,41);let f=41-e.length;return e+c.slice(0,f)}function f(a){if("message"!==a.type||!d(a.message)||"string"!=typeof a.message.role||"system"===a.message.role)return;let b=a.message.content,c="",f=!1;if("string"==typeof b)c=e(c,b);else if(Array.isArray(b)){for(let a of b)if(d(a)&&("image"===a.type&&(f=!0),"text"===a.type&&(c=e(c,a.text)),c.length>40))break}c.length>40?c=c.slice(0,40)+"…":c||(c=f?"[image]":"assistant"===a.message.role?"[assistant]":"message");let g="user"===a.message.role||"assistant"===a.message.role?a.message.role:void 0;return{...g?{role:g}:{},text:c}}function g(a){let b=new Set,c=new Set(a),d=new Set,e=[...a];for(;e.length>0;){let a=e.pop();if(!d.has(a))for(let f of(d.add(a),(c.has(a)||1!==a.children.length)&&b.add(a),a.children))e.push(f)}let g=(a,b,c)=>({...a,children:[],...b?.length?{compressedEntryIds:b}:{},...c?{branchPreview:c}:{}}),h=a.map(a=>g(a,void 0,f(a.entry))),i=a.map((a,b)=>({source:a,projected:h[b],depth:1})),j=(a,c)=>{let d=[{node:a,compressedEntryIds:[],branchPreview:void 0}],e=new Set;for(;d.length>0;){let{node:a,compressedEntryIds:h,branchPreview:i}=d.pop();if(e.has(a))continue;e.add(a);let j=i??f(a.entry);b.has(a)&&c.children.push(g(a,h,j));for(let c=a.children.length-1;c>=0;c--)d.push({node:a.children[c],compressedEntryIds:b.has(a)?[]:[...h,a.entry.id],branchPreview:b.has(a)?void 0:j})}};for(;i.length>0;){let{source:a,projected:c,depth:d}=i.pop();for(let e of a.children){let a=e;if(d>=200){j(a,c);continue}let h=[],k=f(a.entry);for(;!b.has(a)&&1===a.children.length;)h.push(a.entry.id),a=a.children[0],k??=f(a.entry);if(!b.has(a))continue;let l=g(a,h,k);c.children.push(l),i.push({source:a,projected:l,depth:d+1})}}return h}c.d(b,{y:()=>g})},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},21906:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{CQ:()=>l,GW:()=>n,JS:()=>m});var e=c(55511),f=c(29021),g=c(33873),h=c(45902),i=c(7048),j=c(74313),k=a([i,j]);function l(a){let b=(0,f.readFileSync)(a,"utf8"),c=b.split("\n"),d=c.map(a=>{if(!a.trim())return null;try{return JSON.parse(a)}catch{return null}}),e=d[0];if(e?.type!=="session"||"string"!=typeof e.id)return null;let g=d.slice(1).filter(a=>null!==a);return{path:a,pathKey:(0,h.$)(a),id:e.id,parentPath:"string"==typeof e.parentSession?e.parentSession:void 0,lines:c,entries:g,original:b,isSubagent:!!(0,i.$u)(g,e.id,a)}}function m(a,b,c){let d=[...a.lines],e=JSON.parse(d[0]);if(b?e.parentSession=b:delete e.parentSession,d[0]=JSON.stringify(e),a.isSubagent){if(!b||!c)throw Error("Cannot reparent a subagent without a valid parent session");for(let a=1;a<d.length;a+=1){let e;try{e=JSON.parse(d[a])}catch{continue}"custom"!==e.type||e.customType!==i.tP||"object"!=typeof e.data||null===e.data||Array.isArray(e.data)||(e.data={...e.data,parentSessionId:c,parentSessionPath:b},d[a]=JSON.stringify(e))}}return d.join("\n")}function n(a){try{(0,j.H2)(a)}catch{}let b=[];try{for(let c of a){if(!(0,f.existsSync)(c))continue;let a=(0,g.join)((0,g.dirname)(c),`.${(0,g.basename)(c)}-${(0,e.randomUUID)()}.deleting`);try{(0,f.renameSync)(c,a)}catch(a){if("ENOENT"===a.code)continue;throw a}b.push({original:c,staged:a})}}catch(a){for(let a of b.reverse())try{(0,f.renameSync)(a.staged,a.original)}catch{}throw a}for(let a of b)try{(0,f.unlinkSync)(a.staged)}catch{}}[i,j]=k.then?(await k)():k,d()}catch(a){d(a)}})},27910:a=>{"use strict";a.exports=require("stream")},28354:a=>{"use strict";a.exports=require("util")},28802:a=>{"use strict";a.exports=import("@earendil-works/pi-ai")},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")},29862:a=>{"use strict";a.exports=import("@earendil-works/pi-tui")},31421:a=>{"use strict";a.exports=require("node:child_process")},33873:a=>{"use strict";a.exports=require("path")},33920:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{Zg:()=>k,fi:()=>l});var e=c(29021),f=c(33873),g=c(75430),h=c(8102),i=a([g]);function j(a=(0,g.getAgentDir)()){return(0,f.join)(a,"pi-web","pinned-sessions.json")}function k(a=j()){let b;try{b=(0,e.readFileSync)(a,"utf8")}catch(a){if("ENOENT"===a.code)return[];throw a}let c=JSON.parse(b);return Array.isArray(c)?c.filter(a=>"string"==typeof a):[]}function l(a,b,c=j()){let d=k(c).filter(b=>b!==a);return b&&d.push(a),(0,e.mkdirSync)((0,f.dirname)(c),{recursive:!0}),(0,h.$)(c,JSON.stringify(d)),d}g=(i.then?(await i)():i)[0],d()}catch(a){d(a)}})},44870:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},47207:(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/sessions/[id]/route",pathname:"/api/sessions/[id]",filename:"route",bundlePath:"app/api/sessions/[id]/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/home/zhujunshen/pi-web/app/api/sessions/[id]/route.ts",nextConfigOutput:"",userland:()=>c(98192),...{}}),{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/sessions/[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)}}},48161:a=>{"use strict";a.exports=require("node:os")},51181:a=>{"use strict";a.exports=require("web-push")},51455:a=>{"use strict";a.exports=require("node:fs/promises")},55511:a=>{"use strict";a.exports=require("crypto")},57975:a=>{"use strict";a.exports=require("node:util")},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},72322:a=>{"use strict";a.exports=import("@earendil-works/pi-ai/utils/pi-user-agent")},73024:a=>{"use strict";a.exports=require("node:fs")},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")},77598:a=>{"use strict";a.exports=require("node:crypto")},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")},81115:a=>{"use strict";a.exports=require("constants")},86439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},89691:(a,b,c)=>{"use strict";function d(a){let b,c=0;for(let e of a){var d;if("message"!==(d=e.type)&&"compaction"!==d&&"branch_summary"!==d&&"custom_message"!==d)continue;let a=Date.parse(e.timestamp);if(!Number.isFinite(a))continue;let f="message"===e.type?e.message?.role:void 0;if("user"===f||"bashExecution"===f){b=a;continue}void 0!==b&&a>b&&(c+=a-b),b=a}return c}c.d(b,{c:()=>d})},94735:a=>{"use strict";a.exports=require("events")},96487:()=>{},98192:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.r(b),c.d(b,{DELETE:()=>x,GET:()=>v,PATCH:()=>w});var e=c(23211),f=c(29021),g=c(33873),h=c(21906),i=c(75430),j=c(40402),k=c(45902),l=c(56429),m=c(14858),n=c(89691),o=c(88914),p=c(4896),q=c(7048),r=c(21560),s=c(8102),t=c(33920),u=a([h,i,j,l,p,q,t]);async function v(a,{params:b}){let{id:c}=await b;try{let b,d="1"===new URL(a.url).searchParams.get("force"),g=function(a,b){let c=(0,l.getRpcSession)(a);if(!c?.isAlive())return;if(!b)return c;let d=c.sessionFile;if(!d||c.isRunning())return c;let e=(0,j.xL)(d);return e.overlongLine?(console.log(`[pi-web] session ${a} tail exceeds the probe window; rebuilding from the file`),(0,l.releaseRpcSessionForExternalWrite)(a)?void 0:c):!e.entryId||c.inner.sessionManager.getEntries().some(a=>a?.id===e.entryId)?c:(console.log(`[pi-web] session ${a} changed on disk; rebuilding from the file`),(0,l.releaseRpcSessionForExternalWrite)(a)?void 0:c)}(c,d),h=g?null:await (0,j.os)(c);if(!g&&!h)return e.NextResponse.json({error:"Session not found"},{status:404});let k=g?.inner.sessionManager??i.SessionManager.open(h),s=g?.sessionFile||k.getSessionFile()||h||"",t=k.getEntries(),u=k.getLeafId(),v=(0,m.y)(k.getTree()),w=new URL(a.url).searchParams,x=w.has("deferThinking"),y=w.has("deferMedia"),z=Number(w.get("tail")),A=Number.isFinite(z)&&z>0?Math.min(z,1e3):200,B=(0,j.Uv)(t,u,{deferThinking:x,deferToolResultImages:y,tail:A,sessionId:c}),C=(0,n.c)(t),D=(0,o.P)(t),E=g?.inner?.getContextUsage?.()??await (0,p.a)(k,u),F=k.getSessionName(),G=t.find(a=>"message"===a.type&&"user"===a.message.role),H=G?.type==="message"?G.message:void 0,I=k.getHeader(),J=I?.timestamp??new Date().toISOString();try{J=(0,f.statSync)(s).mtime.toISOString()}catch{}let K=I?.parentSession?await (0,j.u1)(I.parentSession):void 0,L=I?(0,q.$u)(t,I.id,s):null,M=L?await (0,l.getSubagentRun)(c):null,N=(0,q.ph)(t)?.tools??(0,r.dS)(t),O=I?(await (0,j.zH)([{path:s,id:I.id,cwd:I.cwd??"",name:F,created:I.timestamp,modified:J,messageCount:D.totalMessages,firstMessage:H?(b=H.content,"string"==typeof b?b:(Array.isArray(b)?b.find(a=>"text"===a.type)?.text??"":"")||"(no messages)"):"(no messages)",parentSessionId:K,...L?{relation:{kind:"subagent",parentSessionId:L.parentSessionId,profile:L.profile,description:L.description,status:M?.status??L.status}}:I.parentSession?{relation:{kind:"fork",...K?{originSessionId:K}:{}}}:{},transient:!s||!(0,f.existsSync)(s)}]))[0]:null;return e.NextResponse.json({sessionId:c,filePath:s,info:O,leafId:u,tree:v,context:B,stats:D,...E?{contextUsage:E}:{},totalActiveMs:C,...void 0!==N?{toolNames:N}:{}})}catch(a){return e.NextResponse.json({error:String(a)},{status:500})}}async function w(a,{params:b}){let{id:c}=await b;try{let{name:b,pinned:d}=await a.json();if("string"!=typeof b&&"boolean"!=typeof d)return e.NextResponse.json({error:"name or pinned is required"},{status:400});let f=await (0,j.os)(c);if(!f)return e.NextResponse.json({error:"Session not found"},{status:404});return"boolean"==typeof d&&(0,t.fi)(c,d),"string"==typeof b&&i.SessionManager.open(f).appendSessionInfo(b.trim()),(0,j.mD)(),e.NextResponse.json({ok:!0})}catch(a){return e.NextResponse.json({error:String(a)},{status:500})}}async function x(a,{params:b}){let{id:c}=await b;try{let a,b=await (0,j.os)(c);if(!b||!(0,f.existsSync)(b)){let a=(0,l.getRpcSession)(c);if(!a)return b&&(0,j.BR)(c),e.NextResponse.json({error:"Session not found"},{status:404});let d=a.sessionFile||b;return await a.shutdown(),d&&(0,h.GW)([d]),(0,j.BR)(c),(0,j.mD)(),e.NextResponse.json({ok:!0})}let d=(0,j.eP)(b)?.parentSession;if(d)try{a=(0,j.eP)(d)?.id}catch{a=void 0}let i=(0,k.$)(b),m=(0,g.dirname)(b),n=(0,f.readdirSync)(m).filter(a=>a.endsWith(".jsonl")).map(a=>(0,h.CQ)((0,g.join)(m,a))).filter(a=>null!==a),o=n.find(a=>a.pathKey===i);if(!o||o.id!==c)return e.NextResponse.json({error:"Session changed while preparing deletion"},{status:409});let p=new Map;for(let a of n){if(!a.parentPath)continue;let b=(0,k.$)(a.parentPath);p.set(b,[...p.get(b)??[],a])}let q=p.get(i)??[],r=new Set;if(!d){let a=q.filter(a=>a.isSubagent);for(;a.length>0;){let b=a.shift();r.has(b.pathKey)||(r.add(b.pathKey),a.push(...p.get(b.pathKey)??[]))}}let t=n.filter(a=>r.has(a.pathKey)),u=q.filter(a=>!r.has(a.pathKey));if(u.some(a=>a.isSubagent)&&(!d||!a))return e.NextResponse.json({error:"Cannot reparent subagent session"},{status:409});let v=[o,...t,...u],w=await (0,l.reserveRpcSessionFileMutation)(v.map(a=>a.id));if(!w)return e.NextResponse.json({error:"Session is busy"},{status:409});try{if(v.some(a=>{try{return(0,f.readFileSync)(a.path,"utf8")!==a.original}catch{return!0}}))return e.NextResponse.json({error:"Session changed while preparing deletion"},{status:409});let g=u.map(b=>({record:b,updated:(0,h.JS)(b,d,a)})),i=[];try{for(let{record:a,updated:b}of g)(0,s.$)(a.path,b),i.push(a);(0,h.GW)([b,...t.map(a=>a.path)])}catch(a){for(let a of i.reverse())try{(0,s.$)(a.path,a.original)}catch{}throw a}for(let a of((0,j.BR)(c),t))(0,j.BR)(a.id);return(0,j.mD)(),e.NextResponse.json({ok:!0})}finally{w()}}catch(a){return e.NextResponse.json({error:String(a)},{status:500})}}[h,i,j,l,p,q,t]=u.then?(await u)():u,d()}catch(a){d(a)}})}};var b=require("../../../../webpack-runtime.js");b.C(a);var c=b.X(0,[4741,1813,426,974,402,6759,2243,6429],()=>b(b.s=47207));module.exports=c})();
@@ -1 +1 @@
1
- (()=>{var a={};a.id=3943,a.ids=[3943],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},1932:a=>{"use strict";a.exports=require("url")},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},4573:a=>{"use strict";a.exports=require("node:buffer")},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")},21998:(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/sessions/[id]/state/route",pathname:"/api/sessions/[id]/state",filename:"route",bundlePath:"app/api/sessions/[id]/state/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/home/zhujunshen/pi-web/app/api/sessions/[id]/state/route.ts",nextConfigOutput:"",userland:()=>c(87230),...{}}),{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/sessions/[id]/state/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")},28802:a=>{"use strict";a.exports=import("@earendil-works/pi-ai")},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")},29862:a=>{"use strict";a.exports=import("@earendil-works/pi-tui")},31421:a=>{"use strict";a.exports=require("node:child_process")},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")},48161:a=>{"use strict";a.exports=require("node:os")},51181:a=>{"use strict";a.exports=require("web-push")},51455:a=>{"use strict";a.exports=require("node:fs/promises")},55511:a=>{"use strict";a.exports=require("crypto")},57975:a=>{"use strict";a.exports=require("node:util")},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},72322:a=>{"use strict";a.exports=import("@earendil-works/pi-ai/utils/pi-user-agent")},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")},77598:a=>{"use strict";a.exports=require("node:crypto")},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")},81115:a=>{"use strict";a.exports=require("constants")},86439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},87230:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.r(b),c.d(b,{GET:()=>i});var e=c(23211),f=c(56429),g=c(40402),h=a([f,g]);async function i(a,{params:b}){let{id:c}=await b;try{let a=(0,f.getRpcSession)(c);if(a?.isAlive()){let b=await a.send({type:"get_state"});return e.NextResponse.json({running:!0,state:b})}if(!await (0,g.os)(c))return e.NextResponse.json({error:"Session not found"},{status:404});return e.NextResponse.json({running:!1})}catch(a){return e.NextResponse.json({error:String(a)},{status:500})}}[f,g]=h.then?(await h)():h,d()}catch(a){d(a)}})},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,426,974,402,6759,2243,6429],()=>b(b.s=21998));module.exports=c})();
1
+ (()=>{var a={};a.id=3943,a.ids=[3943],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},1932:a=>{"use strict";a.exports=require("url")},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},4573:a=>{"use strict";a.exports=require("node:buffer")},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")},28802:a=>{"use strict";a.exports=import("@earendil-works/pi-ai")},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")},29862:a=>{"use strict";a.exports=import("@earendil-works/pi-tui")},31421:a=>{"use strict";a.exports=require("node:child_process")},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")},48161:a=>{"use strict";a.exports=require("node:os")},51181:a=>{"use strict";a.exports=require("web-push")},51455:a=>{"use strict";a.exports=require("node:fs/promises")},55511:a=>{"use strict";a.exports=require("crypto")},57975:a=>{"use strict";a.exports=require("node:util")},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},72322:a=>{"use strict";a.exports=import("@earendil-works/pi-ai/utils/pi-user-agent")},73024:a=>{"use strict";a.exports=require("node:fs")},74215:(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/sessions/[id]/state/route",pathname:"/api/sessions/[id]/state",filename:"route",bundlePath:"app/api/sessions/[id]/state/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/home/zhujunshen/pi-web/app/api/sessions/[id]/state/route.ts",nextConfigOutput:"",userland:()=>c(87230),...{}}),{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/sessions/[id]/state/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)}}},75430:a=>{"use strict";a.exports=import("@earendil-works/pi-coding-agent")},76760:a=>{"use strict";a.exports=require("node:path")},77598:a=>{"use strict";a.exports=require("node:crypto")},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")},81115:a=>{"use strict";a.exports=require("constants")},86439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},87230:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.r(b),c.d(b,{GET:()=>i});var e=c(23211),f=c(56429),g=c(40402),h=a([f,g]);async function i(a,{params:b}){let{id:c}=await b;try{let a=(0,f.getRpcSession)(c);if(a?.isAlive()){let b=await a.send({type:"get_state"});return e.NextResponse.json({running:!0,state:b})}if(!await (0,g.os)(c))return e.NextResponse.json({error:"Session not found"},{status:404});return e.NextResponse.json({running:!1})}catch(a){return e.NextResponse.json({error:String(a)},{status:500})}}[f,g]=h.then?(await h)():h,d()}catch(a){d(a)}})},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,426,974,402,6759,2243,6429],()=>b(b.s=74215));module.exports=c})();
@@ -1 +1 @@
1
- (()=>{var a={};a.id=1097,a.ids=[1097],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},1932:a=>{"use strict";a.exports=require("url")},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},4573:a=>{"use strict";a.exports=require("node:buffer")},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")},28802:a=>{"use strict";a.exports=import("@earendil-works/pi-ai")},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")},29862:a=>{"use strict";a.exports=import("@earendil-works/pi-tui")},31421:a=>{"use strict";a.exports=require("node:child_process")},33873:a=>{"use strict";a.exports=require("path")},33920:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{Zg:()=>k,fi:()=>l});var e=c(29021),f=c(33873),g=c(75430),h=c(8102),i=a([g]);function j(a=(0,g.getAgentDir)()){return(0,f.join)(a,"pi-web","pinned-sessions.json")}function k(a=j()){let b;try{b=(0,e.readFileSync)(a,"utf8")}catch(a){if("ENOENT"===a.code)return[];throw a}let c=JSON.parse(b);return Array.isArray(c)?c.filter(a=>"string"==typeof a):[]}function l(a,b,c=j()){let d=k(c).filter(b=>b!==a);return b&&d.push(a),(0,e.mkdirSync)((0,f.dirname)(c),{recursive:!0}),(0,h.$)(c,JSON.stringify(d)),d}g=(i.then?(await i)():i)[0],d()}catch(a){d(a)}})},40228:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.r(b),c.d(b,{GET:()=>j,dynamic:()=>k});var e=c(23211),f=c(40402),g=c(56429),h=c(33920),i=a([f,g,h]);[f,g,h]=i.then?(await i)():i;let k="force-dynamic";async function j(a){try{let b="1"===new URL(a.url).searchParams.get("force"),c=(0,f.dQ)({force:b}),d=(0,f.bA)(),[i,j]=await Promise.all([c,(0,f.zH)((0,g.getRpcSessionInfos)())]),k=(0,f.O5)(i,j);return e.NextResponse.json({sessions:k,sessionListVersion:d,pinnedSessionIds:(0,h.Zg)(),runningSessionIds:(0,g.getRunningRpcSessionIds)(),completionNotificationSuppressedSessionIds:(0,g.getCompletionNotificationSuppressedRpcSessionIds)()},{headers:{"Cache-Control":"no-store"}})}catch(a){return e.NextResponse.json({error:String(a)},{status:500,headers:{"Cache-Control":"no-store"}})}}d()}catch(a){d(a)}})},44870:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},48161:a=>{"use strict";a.exports=require("node:os")},51181:a=>{"use strict";a.exports=require("web-push")},51455:a=>{"use strict";a.exports=require("node:fs/promises")},55511:a=>{"use strict";a.exports=require("crypto")},57975:a=>{"use strict";a.exports=require("node:util")},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},68568:(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/sessions/route",pathname:"/api/sessions",filename:"route",bundlePath:"app/api/sessions/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/home/zhujunshen/pi-web/app/api/sessions/route.ts",nextConfigOutput:"",userland:()=>c(40228),...{}}),{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/sessions/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)}}},72322:a=>{"use strict";a.exports=import("@earendil-works/pi-ai/utils/pi-user-agent")},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")},77598:a=>{"use strict";a.exports=require("node:crypto")},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")},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,426,974,402,6759,2243,6429],()=>b(b.s=68568));module.exports=c})();
1
+ (()=>{var a={};a.id=1097,a.ids=[1097],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},1932:a=>{"use strict";a.exports=require("url")},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},4573:a=>{"use strict";a.exports=require("node:buffer")},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")},28802:a=>{"use strict";a.exports=import("@earendil-works/pi-ai")},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")},29862:a=>{"use strict";a.exports=import("@earendil-works/pi-tui")},31421:a=>{"use strict";a.exports=require("node:child_process")},33873:a=>{"use strict";a.exports=require("path")},33920:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{Zg:()=>k,fi:()=>l});var e=c(29021),f=c(33873),g=c(75430),h=c(8102),i=a([g]);function j(a=(0,g.getAgentDir)()){return(0,f.join)(a,"pi-web","pinned-sessions.json")}function k(a=j()){let b;try{b=(0,e.readFileSync)(a,"utf8")}catch(a){if("ENOENT"===a.code)return[];throw a}let c=JSON.parse(b);return Array.isArray(c)?c.filter(a=>"string"==typeof a):[]}function l(a,b,c=j()){let d=k(c).filter(b=>b!==a);return b&&d.push(a),(0,e.mkdirSync)((0,f.dirname)(c),{recursive:!0}),(0,h.$)(c,JSON.stringify(d)),d}g=(i.then?(await i)():i)[0],d()}catch(a){d(a)}})},40228:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.r(b),c.d(b,{GET:()=>j,dynamic:()=>k});var e=c(23211),f=c(40402),g=c(56429),h=c(33920),i=a([f,g,h]);[f,g,h]=i.then?(await i)():i;let k="force-dynamic";async function j(a){try{let b="1"===new URL(a.url).searchParams.get("force"),c=(0,f.dQ)({force:b}),d=(0,f.bA)(),[i,j]=await Promise.all([c,(0,f.zH)((0,g.getRpcSessionInfos)())]),k=(0,f.O5)(i,j);return e.NextResponse.json({sessions:k,sessionListVersion:d,pinnedSessionIds:(0,h.Zg)(),runningSessionIds:(0,g.getRunningRpcSessionIds)(),completionNotificationSuppressedSessionIds:(0,g.getCompletionNotificationSuppressedRpcSessionIds)()},{headers:{"Cache-Control":"no-store"}})}catch(a){return e.NextResponse.json({error:String(a)},{status:500,headers:{"Cache-Control":"no-store"}})}}d()}catch(a){d(a)}})},44870:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},48161:a=>{"use strict";a.exports=require("node:os")},51181:a=>{"use strict";a.exports=require("web-push")},51455:a=>{"use strict";a.exports=require("node:fs/promises")},55511:a=>{"use strict";a.exports=require("crypto")},57975:a=>{"use strict";a.exports=require("node:util")},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},72322:a=>{"use strict";a.exports=import("@earendil-works/pi-ai/utils/pi-user-agent")},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")},77598:a=>{"use strict";a.exports=require("node:crypto")},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")},81115:a=>{"use strict";a.exports=require("constants")},86439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},88373:(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/sessions/route",pathname:"/api/sessions",filename:"route",bundlePath:"app/api/sessions/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/home/zhujunshen/pi-web/app/api/sessions/route.ts",nextConfigOutput:"",userland:()=>c(40228),...{}}),{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/sessions/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)}}},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,426,974,402,6759,2243,6429],()=>b(b.s=88373));module.exports=c})();
@@ -1 +1 @@
1
- (()=>{var a={};a.id=6444,a.ids=[6444],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},1031:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.r(b),c.d(b,{GET:()=>i,dynamic:()=>j});var e=c(23211),f=c(40402),g=c(61809),h=a([f]);f=(h.then?(await h)():h)[0];let j="force-dynamic";async function i(a){let b=(new URL(a.url).searchParams.get("q")??"").trim(),c={"Cache-Control":"no-store"};if(b.length>200)return e.NextResponse.json({error:"Search query exceeds 200 characters"},{status:400,headers:c});try{let d=b&&!a.signal.aborted?await (0,f.dQ)():[];return e.NextResponse.json(await (0,g.H)(d,b,a.signal),{headers:c})}catch(a){return e.NextResponse.json({error:String(a)},{status:500,headers:c})}}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")},9904:(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/sessions/search/route",pathname:"/api/sessions/search",filename:"route",bundlePath:"app/api/sessions/search/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/home/zhujunshen/pi-web/app/api/sessions/search/route.ts",nextConfigOutput:"",userland:()=>c(1031),...{}}),{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/sessions/search/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)}}},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")},28354:a=>{"use strict";a.exports=require("util")},29021:a=>{"use strict";a.exports=require("fs")},29294:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},33873:a=>{"use strict";a.exports=require("path")},44870:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},51455:a=>{"use strict";a.exports=require("node:fs/promises")},55511:a=>{"use strict";a.exports=require("crypto")},61809:(a,b,c)=>{"use strict";c.d(b,{H:()=>f});var d=c(73024),e=c(80481);async function f(a,b,c){let f={results:[],truncated:!1},g=b.trim();if(!g)return f;if(g.length>200)throw RangeError("Search query exceeds 200 characters");let h=RegExp(g.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"i"),i=Date.now()+3e3,j=AbortSignal.timeout(3e3),k=c?AbortSignal.any([c,j]):j;for(let[b,c]of a.filter(a=>!a.transient&&a.path).sort((a,b)=>b.modified.localeCompare(a.modified)).entries()){if(b>=500||f.results.length>=30||k.aborted||Date.now()>=i){f.truncated=!0;break}let a=(0,d.createReadStream)(c.path,{encoding:"utf8",end:0xffffff,signal:k}),g=(0,e.createInterface)({input:a,crlfDelay:1/0}),j=!1;try{for await(let a of g){let b;if(k.aborted||Date.now()>=i){f.truncated=!0;break}if(a.length>1048576){f.truncated=!0;continue}try{b=JSON.parse(a)}catch{continue}if(b?.type!=="message"||!["user","assistant"].includes(b.message?.role))continue;let d=b.message.content,e=("string"==typeof d?[{type:"text",text:d}]:Array.isArray(d)?d:[]).flatMap((a,b)=>a?.type==="text"&&"string"==typeof a.text?[{text:a.text,blockIndex:b}]:[]),g=e.map(a=>a.text).join("\n"),l=h.exec(g);if(!l)continue;let m=l.index,n=m+l[0].length,o=0,p=e.find(a=>{let b=o+a.text.length;return o=b+1,m<=b});f.results.push({session:c,..."string"==typeof b.id?{entryId:b.id}:{},blockIndex:p.blockIndex,before:(m>80?"...":"")+g.slice(Math.max(0,m-80),m).replace(/\s+/g," ").trimStart(),match:l[0].replace(/\s+/g," "),after:g.slice(n,n+80).replace(/\s+/g," ").trimEnd()+(n+80<g.length?"...":"")}),j=!0;break}}catch{f.truncated=!0}finally{g.close(),a.destroy()}!j&&a.bytesRead>=0x1000000&&(f.truncated=!0)}return f}},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},73024:a=>{"use strict";a.exports=require("node:fs")},75430:a=>{"use strict";a.exports=import("@earendil-works/pi-coding-agent")},76760:a=>{"use strict";a.exports=require("node:path")},78335:()=>{},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")},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,426,402],()=>b(b.s=9904));module.exports=c})();
1
+ (()=>{var a={};a.id=6444,a.ids=[6444],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},1031:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.r(b),c.d(b,{GET:()=>i,dynamic:()=>j});var e=c(23211),f=c(40402),g=c(61809),h=a([f]);f=(h.then?(await h)():h)[0];let j="force-dynamic";async function i(a){let b=(new URL(a.url).searchParams.get("q")??"").trim(),c={"Cache-Control":"no-store"};if(b.length>200)return e.NextResponse.json({error:"Search query exceeds 200 characters"},{status:400,headers:c});try{let d=b&&!a.signal.aborted?await (0,f.dQ)():[];return e.NextResponse.json(await (0,g.H)(d,b,a.signal),{headers:c})}catch(a){return e.NextResponse.json({error:String(a)},{status:500,headers:c})}}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")},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},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")},41677:(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/sessions/search/route",pathname:"/api/sessions/search",filename:"route",bundlePath:"app/api/sessions/search/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/home/zhujunshen/pi-web/app/api/sessions/search/route.ts",nextConfigOutput:"",userland:()=>c(1031),...{}}),{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/sessions/search/route";"/index"===d&&(d="/");let f=await u.prepare(a,b,{srcPage:d,multiZoneDraftMode:!1});if(!f)return b.statusCode=400,b.end("Bad Request"),null==c.waitUntil||c.waitUntil.call(c,Promise.resolve()),null;let{buildId:v,deploymentId:w,params:x,nextConfig:y,parsedUrl:z,isDraftMode:A,prerenderManifest:B,routerServerContext:C,isOnDemandRevalidate:D,revalidateOnlyGenerated:E,resolvedPathname:F,clientReferenceManifest:G,serverActionsManifest:H}=f,I=(0,j.normalizeAppPath)(d),J=!!(B.dynamicRoutes[I]||B.routes[F]),K=async()=>((null==C?void 0:C.render404)?await C.render404(a,b,z,!1):b.end("This page could not be found"),null);if(J&&!A){let a=!!B.routes[F],b=B.dynamicRoutes[I];if(b&&!1===b.fallback&&!a){if(y.adapterPath)return await K();throw new s.NoFallbackError}}let L=null;!J||u.isDev||A||(L="/index"===(L=F)?"/":L);let M=!0===u.isDev||!J,N=J&&!M;H&&G&&(0,i.setManifestsSingleton)({page:d,clientReferenceManifest:G,serverActionsManifest:H});let O=a.method||"GET",P=(0,h.getTracer)(),Q=P.getActiveScopeSpan(),R=!!(null==C?void 0:C.isWrappedByNextServer),S=!!(0,g.getRequestMeta)(a,"minimalMode"),T=(0,g.getRequestMeta)(a,"incrementalCache")||await u.getIncrementalCache(a,y,B,S);null==T||T.resetRequestCache(),globalThis.__incrementalCache=T;let U={params:x,previewProps:B.preview,renderOpts:{experimental:{authInterrupts:!!y.experimental.authInterrupts,useCacheTimeout:y.experimental.useCacheTimeout},cacheComponents:!!y.cacheComponents,validationLevel:y.experimental.instantInsights.validationLevel,supportsDynamicResponse:M,incrementalCache:T,hmrRefreshHash:(0,g.getRequestMeta)(a,"hmrRefreshHash"),cacheLifeProfiles:y.cacheLife,staticPageGenerationTimeout:y.staticPageGenerationTimeout,waitUntil:c.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:void 0,onInstrumentationRequestError:(b,c,d,e)=>u.onRequestError(a,b,d,e,C)},sharedContext:{buildId:v,deploymentId:w}},V=new k.NodeNextRequest(a),W=new k.NodeNextResponse(b),X=l.NextRequestAdapter.fromNodeNextRequest(V,(0,l.signalFromNodeResponse)(b)),Y=async({previousCacheEntry:e})=>{try{if(!S&&D&&E&&!e)return b.statusCode=404,b.setHeader("x-nextjs-cache","REVALIDATED"),b.end("This page could not be found"),null;let d=await u.handle(X,U);a.fetchMetrics=U.renderOpts.fetchMetrics;let f=U.renderOpts.pendingWaitUntil;f&&c.waitUntil&&(c.waitUntil(f),f=void 0);let g=U.renderOpts.collectedTags;if(!J)return await (0,o.I)(V,W,d,f),null;{let a=await d.blob(),b=(0,p.toNodeOutgoingHttpHeaders)(d.headers);g&&(b[r.NEXT_CACHE_TAGS_HEADER]=g),!b["content-type"]&&a.type&&(b["content-type"]=a.type);let c=void 0!==U.renderOpts.collectedRevalidate&&!(U.renderOpts.collectedRevalidate>=r.INFINITE_CACHE)&&U.renderOpts.collectedRevalidate,e=void 0===U.renderOpts.collectedExpire||U.renderOpts.collectedExpire>=r.INFINITE_CACHE?!1!==c&&c>0?y.expireTime:void 0:U.renderOpts.collectedExpire;return{value:{kind:t.CachedRouteKind.APP_ROUTE,status:d.status,body:Buffer.from(await a.arrayBuffer()),headers:b},cacheControl:{revalidate:c,expire:e}}}}catch(b){throw(null==e?void 0:e.isStale)&&await u.onRequestError(a,b,{routerKind:"App Router",routePath:d,routeType:"route",revalidateReason:(0,n.getRevalidateReason)({isStaticGeneration:N,isOnDemandRevalidate:D})},!1,C),b}},Z=async(d,f)=>{try{var g,i;let d=await u.handleResponse({req:a,nextConfig:y,cacheKey:L,routeKind:e.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:B,isRoutePPREnabled:!1,isOnDemandRevalidate:D,revalidateOnlyGenerated:E,responseGenerator:Y,waitUntil:c.waitUntil,isMinimalMode:S});if(!J)return;if((null==d||null==(g=d.value)?void 0:g.kind)!==t.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==d||null==(i=d.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});S||b.setHeader("x-nextjs-cache",D?"REVALIDATED":d.isMiss?"MISS":d.isStale?"STALE":"HIT"),A&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let f=(0,p.fromNodeOutgoingHttpHeaders)(d.value.headers);S&&J||f.delete(r.NEXT_CACHE_TAGS_HEADER),!d.cacheControl||b.getHeader("Cache-Control")||f.get("Cache-Control")||f.set("Cache-Control",(0,q.getCacheControlHeader)(d.cacheControl)),await (0,o.I)(V,W,new Response(d.value.body,{headers:f,status:d.value.status||200}));return}catch(b){if(b instanceof s.NoFallbackError||await u.onRequestError(a,b,{routerKind:"App Router",routePath:I,routeType:"route",revalidateReason:(0,n.getRevalidateReason)({isStaticGeneration:N,isOnDemandRevalidate:D})},!1,C),J)throw b;await (0,o.I)(V,W,new Response(null,{status:500}));return}finally{(()=>{if(!d)return;let a=b.statusCode;d.setAttributes({"http.status_code":a,"next.rsc":!1}),a&&a>=500&&(d.setStatus({code:h.SpanStatusCode.ERROR}),d.setAttribute("error.type",a.toString()));let c=P.getRootSpanAttributes();if(!c)return;if(c.get("next.span_type")!==m.BaseServerSpan.handleRequest)return console.warn(`Unexpected root span type '${c.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let e=c.get("next.route")||I,g=`${O} ${e}`;d.setAttributes({"next.route":e,"http.route":e,"next.span_name":g}),d.updateName(g),f&&f!==d&&(f.setAttribute("http.route",e),f.updateName(g))})()}};if(R&&Q)await Z(Q,void 0);else{let b=P.getActiveScopeSpan();await P.withPropagatedContext(a.headers,()=>P.trace(m.BaseServerSpan.handleRequest,{spanName:`${O} ${d}`,kind:h.SpanKind.SERVER,attributes:{"http.method":O,"http.target":a.url}},a=>Z(a,b)),void 0,!R)}}},44870:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},51455:a=>{"use strict";a.exports=require("node:fs/promises")},55511:a=>{"use strict";a.exports=require("crypto")},61809:(a,b,c)=>{"use strict";c.d(b,{H:()=>f});var d=c(73024),e=c(80481);async function f(a,b,c){let f={results:[],truncated:!1},g=b.trim();if(!g)return f;if(g.length>200)throw RangeError("Search query exceeds 200 characters");let h=RegExp(g.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"i"),i=Date.now()+3e3,j=AbortSignal.timeout(3e3),k=c?AbortSignal.any([c,j]):j;for(let[b,c]of a.filter(a=>!a.transient&&a.path).sort((a,b)=>b.modified.localeCompare(a.modified)).entries()){if(b>=500||f.results.length>=30||k.aborted||Date.now()>=i){f.truncated=!0;break}let a=(0,d.createReadStream)(c.path,{encoding:"utf8",end:0xffffff,signal:k}),g=(0,e.createInterface)({input:a,crlfDelay:1/0}),j=!1;try{for await(let a of g){let b;if(k.aborted||Date.now()>=i){f.truncated=!0;break}if(a.length>1048576){f.truncated=!0;continue}try{b=JSON.parse(a)}catch{continue}if(b?.type!=="message"||!["user","assistant"].includes(b.message?.role))continue;let d=b.message.content,e=("string"==typeof d?[{type:"text",text:d}]:Array.isArray(d)?d:[]).flatMap((a,b)=>a?.type==="text"&&"string"==typeof a.text?[{text:a.text,blockIndex:b}]:[]),g=e.map(a=>a.text).join("\n"),l=h.exec(g);if(!l)continue;let m=l.index,n=m+l[0].length,o=0,p=e.find(a=>{let b=o+a.text.length;return o=b+1,m<=b});f.results.push({session:c,..."string"==typeof b.id?{entryId:b.id}:{},blockIndex:p.blockIndex,before:(m>80?"...":"")+g.slice(Math.max(0,m-80),m).replace(/\s+/g," ").trimStart(),match:l[0].replace(/\s+/g," "),after:g.slice(n,n+80).replace(/\s+/g," ").trimEnd()+(n+80<g.length?"...":"")}),j=!0;break}}catch{f.truncated=!0}finally{g.close(),a.destroy()}!j&&a.bytesRead>=0x1000000&&(f.truncated=!0)}return f}},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},73024:a=>{"use strict";a.exports=require("node:fs")},75430:a=>{"use strict";a.exports=import("@earendil-works/pi-coding-agent")},76760:a=>{"use strict";a.exports=require("node:path")},78335:()=>{},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")},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,426,402],()=>b(b.s=41677));module.exports=c})();
@@ -1 +1 @@
1
- (()=>{var a={};a.id=2053,a.ids=[2053],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")},5384:(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/skills/check/route",pathname:"/api/skills/check",filename:"route",bundlePath:"app/api/skills/check/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/home/zhujunshen/pi-web/app/api/skills/check/route.ts",nextConfigOutput:"",userland:()=>c(21972),...{}}),{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/skills/check/route";"/index"===d&&(d="/");let f=await u.prepare(a,b,{srcPage:d,multiZoneDraftMode:!1});if(!f)return b.statusCode=400,b.end("Bad Request"),null==c.waitUntil||c.waitUntil.call(c,Promise.resolve()),null;let{buildId:v,deploymentId:w,params:x,nextConfig:y,parsedUrl:z,isDraftMode:A,prerenderManifest:B,routerServerContext:C,isOnDemandRevalidate:D,revalidateOnlyGenerated:E,resolvedPathname:F,clientReferenceManifest:G,serverActionsManifest:H}=f,I=(0,j.normalizeAppPath)(d),J=!!(B.dynamicRoutes[I]||B.routes[F]),K=async()=>((null==C?void 0:C.render404)?await C.render404(a,b,z,!1):b.end("This page could not be found"),null);if(J&&!A){let a=!!B.routes[F],b=B.dynamicRoutes[I];if(b&&!1===b.fallback&&!a){if(y.adapterPath)return await K();throw new s.NoFallbackError}}let L=null;!J||u.isDev||A||(L="/index"===(L=F)?"/":L);let M=!0===u.isDev||!J,N=J&&!M;H&&G&&(0,i.setManifestsSingleton)({page:d,clientReferenceManifest:G,serverActionsManifest:H});let O=a.method||"GET",P=(0,h.getTracer)(),Q=P.getActiveScopeSpan(),R=!!(null==C?void 0:C.isWrappedByNextServer),S=!!(0,g.getRequestMeta)(a,"minimalMode"),T=(0,g.getRequestMeta)(a,"incrementalCache")||await u.getIncrementalCache(a,y,B,S);null==T||T.resetRequestCache(),globalThis.__incrementalCache=T;let U={params:x,previewProps:B.preview,renderOpts:{experimental:{authInterrupts:!!y.experimental.authInterrupts,useCacheTimeout:y.experimental.useCacheTimeout},cacheComponents:!!y.cacheComponents,validationLevel:y.experimental.instantInsights.validationLevel,supportsDynamicResponse:M,incrementalCache:T,hmrRefreshHash:(0,g.getRequestMeta)(a,"hmrRefreshHash"),cacheLifeProfiles:y.cacheLife,staticPageGenerationTimeout:y.staticPageGenerationTimeout,waitUntil:c.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:void 0,onInstrumentationRequestError:(b,c,d,e)=>u.onRequestError(a,b,d,e,C)},sharedContext:{buildId:v,deploymentId:w}},V=new k.NodeNextRequest(a),W=new k.NodeNextResponse(b),X=l.NextRequestAdapter.fromNodeNextRequest(V,(0,l.signalFromNodeResponse)(b)),Y=async({previousCacheEntry:e})=>{try{if(!S&&D&&E&&!e)return b.statusCode=404,b.setHeader("x-nextjs-cache","REVALIDATED"),b.end("This page could not be found"),null;let d=await u.handle(X,U);a.fetchMetrics=U.renderOpts.fetchMetrics;let f=U.renderOpts.pendingWaitUntil;f&&c.waitUntil&&(c.waitUntil(f),f=void 0);let g=U.renderOpts.collectedTags;if(!J)return await (0,o.I)(V,W,d,f),null;{let a=await d.blob(),b=(0,p.toNodeOutgoingHttpHeaders)(d.headers);g&&(b[r.NEXT_CACHE_TAGS_HEADER]=g),!b["content-type"]&&a.type&&(b["content-type"]=a.type);let c=void 0!==U.renderOpts.collectedRevalidate&&!(U.renderOpts.collectedRevalidate>=r.INFINITE_CACHE)&&U.renderOpts.collectedRevalidate,e=void 0===U.renderOpts.collectedExpire||U.renderOpts.collectedExpire>=r.INFINITE_CACHE?!1!==c&&c>0?y.expireTime:void 0:U.renderOpts.collectedExpire;return{value:{kind:t.CachedRouteKind.APP_ROUTE,status:d.status,body:Buffer.from(await a.arrayBuffer()),headers:b},cacheControl:{revalidate:c,expire:e}}}}catch(b){throw(null==e?void 0:e.isStale)&&await u.onRequestError(a,b,{routerKind:"App Router",routePath:d,routeType:"route",revalidateReason:(0,n.getRevalidateReason)({isStaticGeneration:N,isOnDemandRevalidate:D})},!1,C),b}},Z=async(d,f)=>{try{var g,i;let d=await u.handleResponse({req:a,nextConfig:y,cacheKey:L,routeKind:e.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:B,isRoutePPREnabled:!1,isOnDemandRevalidate:D,revalidateOnlyGenerated:E,responseGenerator:Y,waitUntil:c.waitUntil,isMinimalMode:S});if(!J)return;if((null==d||null==(g=d.value)?void 0:g.kind)!==t.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==d||null==(i=d.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});S||b.setHeader("x-nextjs-cache",D?"REVALIDATED":d.isMiss?"MISS":d.isStale?"STALE":"HIT"),A&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let f=(0,p.fromNodeOutgoingHttpHeaders)(d.value.headers);S&&J||f.delete(r.NEXT_CACHE_TAGS_HEADER),!d.cacheControl||b.getHeader("Cache-Control")||f.get("Cache-Control")||f.set("Cache-Control",(0,q.getCacheControlHeader)(d.cacheControl)),await (0,o.I)(V,W,new Response(d.value.body,{headers:f,status:d.value.status||200}));return}catch(b){if(b instanceof s.NoFallbackError||await u.onRequestError(a,b,{routerKind:"App Router",routePath:I,routeType:"route",revalidateReason:(0,n.getRevalidateReason)({isStaticGeneration:N,isOnDemandRevalidate:D})},!1,C),J)throw b;await (0,o.I)(V,W,new Response(null,{status:500}));return}finally{(()=>{if(!d)return;let a=b.statusCode;d.setAttributes({"http.status_code":a,"next.rsc":!1}),a&&a>=500&&(d.setStatus({code:h.SpanStatusCode.ERROR}),d.setAttribute("error.type",a.toString()));let c=P.getRootSpanAttributes();if(!c)return;if(c.get("next.span_type")!==m.BaseServerSpan.handleRequest)return console.warn(`Unexpected root span type '${c.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let e=c.get("next.route")||I,g=`${O} ${e}`;d.setAttributes({"next.route":e,"http.route":e,"next.span_name":g}),d.updateName(g),f&&f!==d&&(f.setAttribute("http.route",e),f.updateName(g))})()}};if(R&&Q)await Z(Q,void 0);else{let b=P.getActiveScopeSpan();await P.withPropagatedContext(a.headers,()=>P.trace(m.BaseServerSpan.handleRequest,{spanName:`${O} ${d}`,kind:h.SpanKind.SERVER,attributes:{"http.method":O,"http.target":a.url}},a=>Z(a,b)),void 0,!R)}}},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")},19038:(a,b,c)=>{"use strict";c.d(b,{CU:()=>l,S7:()=>u});var d=c(79646),e=c(79748),f=c(21820),g=c(33873),h=c(28354);let i=process.env.SKILLS_API_URL||"https://skills.sh",j=(0,h.promisify)(d.execFile);class k extends Error{constructor(a){super(`HTTP ${a}`),this.status=a}}function l(a){let b=n(a.skillPath??""),c=b?`${a.source}/${b}`:a.source,d=a.ref?`#${encodeURIComponent(a.ref)}`:"",e=["skills","add",`${c}${d}`,"--skill",m(a.package),"-y","--agent","pi"];return"global"===a.scope&&e.push("-g"),e}function m(a){let b=a.lastIndexOf("@");return b>=0?a.slice(b+1):a}function n(a){let b=a.replace(/\\/g,"/");return b.toLowerCase().endsWith("/skill.md")?b=b.slice(0,-9):b.toLowerCase().endsWith("skill.md")&&(b=b.slice(0,-8)),b.replace(/\/$/,"")}function o(a,b,c,d){return{package:a.package,scope:a.scope,state:b,currentVersion:a.versionHash,latestVersion:c,message:d}}async function p(a,b,c){let d=await b(a,{cache:"no-store",headers:c,signal:AbortSignal.timeout(15e3)});if(!d.ok)throw new k(d.status);return d.json()}async function q(a){let b=`https://github.com/${a.source}.git`,c=a.ref||"HEAD",d=n(a.skillPath),h=await (0,e.mkdtemp)((0,g.join)((0,f.tmpdir)(),"pi-web-skill-check-"));try{await j("git",["init","--bare",h],{timeout:3e4}),await j("git",[`--git-dir=${h}`,"fetch","--depth=1","--filter=blob:none","--no-tags",b,c],{timeout:3e4});let a=d?`FETCH_HEAD:${d}`:"FETCH_HEAD^{tree}",{stdout:e}=await j("git",[`--git-dir=${h}`,"rev-parse",a],{timeout:3e4}),f=e.trim();if(!/^[0-9a-f]{40}$/i.test(f))throw Error("Invalid Git tree hash");return f}finally{await (0,e.rm)(h,{recursive:!0,force:!0})}}async function r(a,b){let c,d=a.ref||"HEAD",e=`https://api.github.com/repos/${a.source}/git/trees/${encodeURIComponent(d)}?recursive=1`,f={Accept:"application/vnd.github.v3+json","User-Agent":"pi-web"};b.githubToken&&(f.Authorization=`Bearer ${b.githubToken}`);let g=n(a.skillPath);try{let a=await p(e,b.fetcher,f);if(c="string"!=typeof a.sha||g?void 0:a.sha,g&&Array.isArray(a.tree)){let b=a.tree.find(a=>"tree"===a.type&&a.path===g);b&&"string"==typeof b.sha&&(c=b.sha)}}catch(d){if(!(d instanceof k)||![401,403,429].includes(d.status))throw d;c=await b.resolveGitTreeHash(a)}return c?o(a,c===a.versionHash?"up-to-date":"update-available",c):o(a,"error",void 0,"Remote skill path was not found.")}async function s(a,b){let[c,d]=a.source.split("/"),e=m(a.package).toLowerCase().replace(/[\s_]+/g,"-").replace(/[^a-z0-9-]/g,"").replace(/-+/g,"-").replace(/^-|-$/g,""),f=`${b.skillsApiBase}/api/download/${encodeURIComponent(c)}/${encodeURIComponent(d)}/${encodeURIComponent(e)}`,g=await p(f,b.fetcher),h="string"==typeof g.hash?g.hash:void 0;return h?o(a,h===a.versionHash?"up-to-date":"update-available",h):o(a,"error",void 0,"skills.sh did not return a version hash.")}async function t(a,b={}){if(!a.canCheckForUpdates||!a.versionHash||!a.skillPath)return o(a,"unsupported",void 0,"This lock entry cannot be checked automatically.");let c={...b,fetcher:b.fetcher??fetch,skillsApiBase:b.skillsApiBase??i,resolveGitTreeHash:b.resolveGitTreeHash??q};try{return"global"===a.scope?await r(a,c):await s(a,c)}catch(b){return o(a,"error",void 0,b instanceof Error?b.message:String(b))}}async function u(a,b={}){let c=b.fetcher??fetch,d=new Map,e=async(a,b)=>{let e=d.get(a);return e||(e=c(a,b),d.set(a,e)),(await e).clone()};return Promise.all(a.map(a=>t(a,{...b,fetcher:e})))}},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},21278:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{y:()=>j});var e=c(75430),f=c(75805),g=c(49401),h=c(72498),i=a([e,h]);async function j(a){let b=(0,e.getAgentDir)(),c=new e.DefaultResourceLoader({cwd:a,agentDir:b});await c.reload((0,h.Fk)(a,b));let{skills:d,diagnostics:i}=c.getSkills();return{skills:(0,f._)(d,{cwd:a,agentDir:b}).map(c=>({...c,removable:null!==(0,g.T)(c.filePath,a,b)})),diagnostics:i,projectResourcesLoaded:(0,h.Y1)(a,b).trusted}}[e,h]=i.then?(await i)():i,d()}catch(a){d(a)}})},21820:a=>{"use strict";a.exports=require("os")},21972:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.r(b),c.d(b,{POST:()=>j,dynamic:()=>k});var e=c(23211),f=c(19038),g=c(21278),h=c(80547),i=a([g,h]);[g,h]=i.then?(await i)():i;let k="force-dynamic";async function j(a){try{let b=await a.json(),c="string"==typeof b.cwd?b.cwd:"";if(!c)return e.NextResponse.json({error:"cwd required"},{status:400});let d=await (0,h.mc)();if(!(0,h.B7)(c,d))return e.NextResponse.json({error:"Access denied"},{status:403});let i="string"==typeof b.package?b.package:void 0,j="global"===b.scope||"project"===b.scope?b.scope:void 0;if(i&&!j||!i&&j)return e.NextResponse.json({error:"package and scope must be provided together"},{status:400});let{skills:k}=await (0,g.y)(c),l=k.map(a=>a.install).filter(a=>!!a).filter(a=>!i||a.package===i&&a.scope===j);if(i&&0===l.length)return e.NextResponse.json({error:"Installed skill not found"},{status:404});let m=await (0,f.S7)(l,{githubToken:process.env.GITHUB_TOKEN||process.env.GH_TOKEN});return e.NextResponse.json({updates:m})}catch(a){return e.NextResponse.json({error:a instanceof Error?a.message:String(a)},{status:500})}}d()}catch(a){d(a)}})},28354:a=>{"use strict";a.exports=require("util")},29021:a=>{"use strict";a.exports=require("fs")},29294:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},33873:a=>{"use strict";a.exports=require("path")},44870:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},49401:(a,b,c)=>{"use strict";c.d(b,{T:()=>h,k:()=>i});var d=c(29021),e=c(21820),f=c(33873),g=c(58864);function h(a,b,c){let d="SKILL.md"===(0,f.basename)(a)?(0,f.dirname)(a):a,h=(0,f.dirname)(d);return(0,g.Eb)(h,(0,f.join)(c,"skills"))||(0,g.Eb)(h,(0,f.join)(b,".pi","skills"))||(0,g.Eb)(h,(0,f.join)((0,e.homedir)(),".agents","skills"))||"skills"===(0,f.basename)(h)&&".agents"===(0,f.basename)((0,f.dirname)(h))?d:null}function i(a){(0,d.lstatSync)(a).isSymbolicLink()?(0,d.unlinkSync)(a):(0,d.rmSync)(a,{recursive:!0})}},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")},72498:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{Fk:()=>i,Y1:()=>g,er:()=>h});var e=c(75430),f=a([e]);function g(a,b){if(!(a&&(0,e.hasTrustRequiringProjectResources)(a)))return{requiresTrust:!1,trusted:!0};let c=new e.ProjectTrustStore(b);return{requiresTrust:!0,trusted:!0===c.get(a)}}function h(a,b){let c=g(a,b);return c.requiresTrust?(new e.ProjectTrustStore(b).set(a,!0),{requiresTrust:!0,trusted:!0}):c}function i(a,b){if(!g(a,b).requiresTrust)return;let c=new e.ProjectTrustStore(b);return{resolveProjectTrust:async()=>!0===c.get(a)}}e=(f.then?(await f)():f)[0],d()}catch(a){d(a)}})},73024:a=>{"use strict";a.exports=require("node:fs")},75430:a=>{"use strict";a.exports=import("@earendil-works/pi-coding-agent")},75805:(a,b,c)=>{"use strict";c.d(b,{_:()=>j});var d=c(29021),e=c(21820),f=c(33873);function g(a){try{let b=JSON.parse((0,d.readFileSync)(a,"utf8"));return b.skills&&"object"==typeof b.skills?b.skills:{}}catch{return{}}}function h(a,b){let c=(0,f.relative)((0,f.resolve)(b),(0,f.resolve)(a));return""!==c&&".."!==c&&!c.startsWith(`..${f.sep}`)&&!(0,f.isAbsolute)(c)}function i(a,b,c){var d;let e=function(a,b){if(a[b])return a[b];let c=b.toLowerCase(),d=Object.keys(a).find(a=>a.toLowerCase()===c);return d?a[d]:void 0}(a,b);if(!e||"string"!=typeof e.source||!e.source.trim())return;let f="string"==typeof e.sourceType?e.sourceType:void 0,g=(d=e.source.trim(),"github"!==f?d.replace(/\/$/,""):d.replace(/^git\+/,"").replace(/^https?:\/\/github\.com\//,"").replace(/^git@github\.com:/,"").replace(/\.git$/,"").replace(/\/$/,""));if(!g)return;let h="string"==typeof e.skillPath?e.skillPath:void 0,i="string"==typeof e.ref?e.ref:void 0,j="global"===c?e.skillFolderHash:e.computedHash,k="string"==typeof j&&j?j:void 0,l="github"===f&&/^[\w.-]+\/[\w.-]+$/.test(g);return{package:`${g}@${b}`,scope:c,source:g,sourceType:f,skillsShUrl:"local"===f?void 0:function(a,b){if(!a||a.includes("://")||a.startsWith("git@"))return;let c=a.split("/").filter(Boolean).map(encodeURIComponent).join("/");if(c)return`https://skills.sh/${c}/${encodeURIComponent(b)}`}(g,b),...h&&{skillPath:h},...i&&{ref:i},...k&&{versionHash:k},canCheckForUpdates:!!(l&&h&&k&&("global"===c||!i))}}function j(a,{cwd:b,agentDir:c,globalLockPath:k=function({homeDir:a=(0,e.homedir)(),xdgStateHome:b=process.env.XDG_STATE_HOME}={}){return b?(0,f.join)(b,"skills",".skill-lock.json"):(0,f.join)(a,".agents",".skill-lock.json")}(),projectLockPath:l=(0,f.join)(b,"skills-lock.json")}){let m=g(k),n=g(l),o=(0,f.join)(c,"skills"),p=(0,f.join)(b,".pi","skills");return a.map(a=>{if(!(0,d.existsSync)(a.filePath))return a;let b=h(a.filePath,o)?i(m,a.name,"global"):h(a.filePath,p)?i(n,a.name,"project"):void 0;return b?{...a,install:b}:a})}},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:()=>{}};var b=require("../../../../webpack-runtime.js");b.C(a);var c=b.X(0,[4741,1813,426,402],()=>b(b.s=5384));module.exports=c})();
1
+ (()=>{var a={};a.id=2053,a.ids=[2053],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")},19038:(a,b,c)=>{"use strict";c.d(b,{CU:()=>l,S7:()=>u});var d=c(79646),e=c(79748),f=c(21820),g=c(33873),h=c(28354);let i=process.env.SKILLS_API_URL||"https://skills.sh",j=(0,h.promisify)(d.execFile);class k extends Error{constructor(a){super(`HTTP ${a}`),this.status=a}}function l(a){let b=n(a.skillPath??""),c=b?`${a.source}/${b}`:a.source,d=a.ref?`#${encodeURIComponent(a.ref)}`:"",e=["skills","add",`${c}${d}`,"--skill",m(a.package),"-y","--agent","pi"];return"global"===a.scope&&e.push("-g"),e}function m(a){let b=a.lastIndexOf("@");return b>=0?a.slice(b+1):a}function n(a){let b=a.replace(/\\/g,"/");return b.toLowerCase().endsWith("/skill.md")?b=b.slice(0,-9):b.toLowerCase().endsWith("skill.md")&&(b=b.slice(0,-8)),b.replace(/\/$/,"")}function o(a,b,c,d){return{package:a.package,scope:a.scope,state:b,currentVersion:a.versionHash,latestVersion:c,message:d}}async function p(a,b,c){let d=await b(a,{cache:"no-store",headers:c,signal:AbortSignal.timeout(15e3)});if(!d.ok)throw new k(d.status);return d.json()}async function q(a){let b=`https://github.com/${a.source}.git`,c=a.ref||"HEAD",d=n(a.skillPath),h=await (0,e.mkdtemp)((0,g.join)((0,f.tmpdir)(),"pi-web-skill-check-"));try{await j("git",["init","--bare",h],{timeout:3e4}),await j("git",[`--git-dir=${h}`,"fetch","--depth=1","--filter=blob:none","--no-tags",b,c],{timeout:3e4});let a=d?`FETCH_HEAD:${d}`:"FETCH_HEAD^{tree}",{stdout:e}=await j("git",[`--git-dir=${h}`,"rev-parse",a],{timeout:3e4}),f=e.trim();if(!/^[0-9a-f]{40}$/i.test(f))throw Error("Invalid Git tree hash");return f}finally{await (0,e.rm)(h,{recursive:!0,force:!0})}}async function r(a,b){let c,d=a.ref||"HEAD",e=`https://api.github.com/repos/${a.source}/git/trees/${encodeURIComponent(d)}?recursive=1`,f={Accept:"application/vnd.github.v3+json","User-Agent":"pi-web"};b.githubToken&&(f.Authorization=`Bearer ${b.githubToken}`);let g=n(a.skillPath);try{let a=await p(e,b.fetcher,f);if(c="string"!=typeof a.sha||g?void 0:a.sha,g&&Array.isArray(a.tree)){let b=a.tree.find(a=>"tree"===a.type&&a.path===g);b&&"string"==typeof b.sha&&(c=b.sha)}}catch(d){if(!(d instanceof k)||![401,403,429].includes(d.status))throw d;c=await b.resolveGitTreeHash(a)}return c?o(a,c===a.versionHash?"up-to-date":"update-available",c):o(a,"error",void 0,"Remote skill path was not found.")}async function s(a,b){let[c,d]=a.source.split("/"),e=m(a.package).toLowerCase().replace(/[\s_]+/g,"-").replace(/[^a-z0-9-]/g,"").replace(/-+/g,"-").replace(/^-|-$/g,""),f=`${b.skillsApiBase}/api/download/${encodeURIComponent(c)}/${encodeURIComponent(d)}/${encodeURIComponent(e)}`,g=await p(f,b.fetcher),h="string"==typeof g.hash?g.hash:void 0;return h?o(a,h===a.versionHash?"up-to-date":"update-available",h):o(a,"error",void 0,"skills.sh did not return a version hash.")}async function t(a,b={}){if(!a.canCheckForUpdates||!a.versionHash||!a.skillPath)return o(a,"unsupported",void 0,"This lock entry cannot be checked automatically.");let c={...b,fetcher:b.fetcher??fetch,skillsApiBase:b.skillsApiBase??i,resolveGitTreeHash:b.resolveGitTreeHash??q};try{return"global"===a.scope?await r(a,c):await s(a,c)}catch(b){return o(a,"error",void 0,b instanceof Error?b.message:String(b))}}async function u(a,b={}){let c=b.fetcher??fetch,d=new Map,e=async(a,b)=>{let e=d.get(a);return e||(e=c(a,b),d.set(a,e)),(await e).clone()};return Promise.all(a.map(a=>t(a,{...b,fetcher:e})))}},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},21278:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{y:()=>j});var e=c(75430),f=c(75805),g=c(49401),h=c(72498),i=a([e,h]);async function j(a){let b=(0,e.getAgentDir)(),c=new e.DefaultResourceLoader({cwd:a,agentDir:b});await c.reload((0,h.Fk)(a,b));let{skills:d,diagnostics:i}=c.getSkills();return{skills:(0,f._)(d,{cwd:a,agentDir:b}).map(c=>({...c,removable:null!==(0,g.T)(c.filePath,a,b)})),diagnostics:i,projectResourcesLoaded:(0,h.Y1)(a,b).trusted}}[e,h]=i.then?(await i)():i,d()}catch(a){d(a)}})},21820:a=>{"use strict";a.exports=require("os")},21972:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.r(b),c.d(b,{POST:()=>j,dynamic:()=>k});var e=c(23211),f=c(19038),g=c(21278),h=c(80547),i=a([g,h]);[g,h]=i.then?(await i)():i;let k="force-dynamic";async function j(a){try{let b=await a.json(),c="string"==typeof b.cwd?b.cwd:"";if(!c)return e.NextResponse.json({error:"cwd required"},{status:400});let d=await (0,h.mc)();if(!(0,h.B7)(c,d))return e.NextResponse.json({error:"Access denied"},{status:403});let i="string"==typeof b.package?b.package:void 0,j="global"===b.scope||"project"===b.scope?b.scope:void 0;if(i&&!j||!i&&j)return e.NextResponse.json({error:"package and scope must be provided together"},{status:400});let{skills:k}=await (0,g.y)(c),l=k.map(a=>a.install).filter(a=>!!a).filter(a=>!i||a.package===i&&a.scope===j);if(i&&0===l.length)return e.NextResponse.json({error:"Installed skill not found"},{status:404});let m=await (0,f.S7)(l,{githubToken:process.env.GITHUB_TOKEN||process.env.GH_TOKEN});return e.NextResponse.json({updates:m})}catch(a){return e.NextResponse.json({error:a instanceof Error?a.message:String(a)},{status:500})}}d()}catch(a){d(a)}})},22725:(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/skills/check/route",pathname:"/api/skills/check",filename:"route",bundlePath:"app/api/skills/check/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/home/zhujunshen/pi-web/app/api/skills/check/route.ts",nextConfigOutput:"",userland:()=>c(21972),...{}}),{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/skills/check/route";"/index"===d&&(d="/");let f=await u.prepare(a,b,{srcPage:d,multiZoneDraftMode:!1});if(!f)return b.statusCode=400,b.end("Bad Request"),null==c.waitUntil||c.waitUntil.call(c,Promise.resolve()),null;let{buildId:v,deploymentId:w,params:x,nextConfig:y,parsedUrl:z,isDraftMode:A,prerenderManifest:B,routerServerContext:C,isOnDemandRevalidate:D,revalidateOnlyGenerated:E,resolvedPathname:F,clientReferenceManifest:G,serverActionsManifest:H}=f,I=(0,j.normalizeAppPath)(d),J=!!(B.dynamicRoutes[I]||B.routes[F]),K=async()=>((null==C?void 0:C.render404)?await C.render404(a,b,z,!1):b.end("This page could not be found"),null);if(J&&!A){let a=!!B.routes[F],b=B.dynamicRoutes[I];if(b&&!1===b.fallback&&!a){if(y.adapterPath)return await K();throw new s.NoFallbackError}}let L=null;!J||u.isDev||A||(L="/index"===(L=F)?"/":L);let M=!0===u.isDev||!J,N=J&&!M;H&&G&&(0,i.setManifestsSingleton)({page:d,clientReferenceManifest:G,serverActionsManifest:H});let O=a.method||"GET",P=(0,h.getTracer)(),Q=P.getActiveScopeSpan(),R=!!(null==C?void 0:C.isWrappedByNextServer),S=!!(0,g.getRequestMeta)(a,"minimalMode"),T=(0,g.getRequestMeta)(a,"incrementalCache")||await u.getIncrementalCache(a,y,B,S);null==T||T.resetRequestCache(),globalThis.__incrementalCache=T;let U={params:x,previewProps:B.preview,renderOpts:{experimental:{authInterrupts:!!y.experimental.authInterrupts,useCacheTimeout:y.experimental.useCacheTimeout},cacheComponents:!!y.cacheComponents,validationLevel:y.experimental.instantInsights.validationLevel,supportsDynamicResponse:M,incrementalCache:T,hmrRefreshHash:(0,g.getRequestMeta)(a,"hmrRefreshHash"),cacheLifeProfiles:y.cacheLife,staticPageGenerationTimeout:y.staticPageGenerationTimeout,waitUntil:c.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:void 0,onInstrumentationRequestError:(b,c,d,e)=>u.onRequestError(a,b,d,e,C)},sharedContext:{buildId:v,deploymentId:w}},V=new k.NodeNextRequest(a),W=new k.NodeNextResponse(b),X=l.NextRequestAdapter.fromNodeNextRequest(V,(0,l.signalFromNodeResponse)(b)),Y=async({previousCacheEntry:e})=>{try{if(!S&&D&&E&&!e)return b.statusCode=404,b.setHeader("x-nextjs-cache","REVALIDATED"),b.end("This page could not be found"),null;let d=await u.handle(X,U);a.fetchMetrics=U.renderOpts.fetchMetrics;let f=U.renderOpts.pendingWaitUntil;f&&c.waitUntil&&(c.waitUntil(f),f=void 0);let g=U.renderOpts.collectedTags;if(!J)return await (0,o.I)(V,W,d,f),null;{let a=await d.blob(),b=(0,p.toNodeOutgoingHttpHeaders)(d.headers);g&&(b[r.NEXT_CACHE_TAGS_HEADER]=g),!b["content-type"]&&a.type&&(b["content-type"]=a.type);let c=void 0!==U.renderOpts.collectedRevalidate&&!(U.renderOpts.collectedRevalidate>=r.INFINITE_CACHE)&&U.renderOpts.collectedRevalidate,e=void 0===U.renderOpts.collectedExpire||U.renderOpts.collectedExpire>=r.INFINITE_CACHE?!1!==c&&c>0?y.expireTime:void 0:U.renderOpts.collectedExpire;return{value:{kind:t.CachedRouteKind.APP_ROUTE,status:d.status,body:Buffer.from(await a.arrayBuffer()),headers:b},cacheControl:{revalidate:c,expire:e}}}}catch(b){throw(null==e?void 0:e.isStale)&&await u.onRequestError(a,b,{routerKind:"App Router",routePath:d,routeType:"route",revalidateReason:(0,n.getRevalidateReason)({isStaticGeneration:N,isOnDemandRevalidate:D})},!1,C),b}},Z=async(d,f)=>{try{var g,i;let d=await u.handleResponse({req:a,nextConfig:y,cacheKey:L,routeKind:e.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:B,isRoutePPREnabled:!1,isOnDemandRevalidate:D,revalidateOnlyGenerated:E,responseGenerator:Y,waitUntil:c.waitUntil,isMinimalMode:S});if(!J)return;if((null==d||null==(g=d.value)?void 0:g.kind)!==t.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==d||null==(i=d.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});S||b.setHeader("x-nextjs-cache",D?"REVALIDATED":d.isMiss?"MISS":d.isStale?"STALE":"HIT"),A&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let f=(0,p.fromNodeOutgoingHttpHeaders)(d.value.headers);S&&J||f.delete(r.NEXT_CACHE_TAGS_HEADER),!d.cacheControl||b.getHeader("Cache-Control")||f.get("Cache-Control")||f.set("Cache-Control",(0,q.getCacheControlHeader)(d.cacheControl)),await (0,o.I)(V,W,new Response(d.value.body,{headers:f,status:d.value.status||200}));return}catch(b){if(b instanceof s.NoFallbackError||await u.onRequestError(a,b,{routerKind:"App Router",routePath:I,routeType:"route",revalidateReason:(0,n.getRevalidateReason)({isStaticGeneration:N,isOnDemandRevalidate:D})},!1,C),J)throw b;await (0,o.I)(V,W,new Response(null,{status:500}));return}finally{(()=>{if(!d)return;let a=b.statusCode;d.setAttributes({"http.status_code":a,"next.rsc":!1}),a&&a>=500&&(d.setStatus({code:h.SpanStatusCode.ERROR}),d.setAttribute("error.type",a.toString()));let c=P.getRootSpanAttributes();if(!c)return;if(c.get("next.span_type")!==m.BaseServerSpan.handleRequest)return console.warn(`Unexpected root span type '${c.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let e=c.get("next.route")||I,g=`${O} ${e}`;d.setAttributes({"next.route":e,"http.route":e,"next.span_name":g}),d.updateName(g),f&&f!==d&&(f.setAttribute("http.route",e),f.updateName(g))})()}};if(R&&Q)await Z(Q,void 0);else{let b=P.getActiveScopeSpan();await P.withPropagatedContext(a.headers,()=>P.trace(m.BaseServerSpan.handleRequest,{spanName:`${O} ${d}`,kind:h.SpanKind.SERVER,attributes:{"http.method":O,"http.target":a.url}},a=>Z(a,b)),void 0,!R)}}},28354:a=>{"use strict";a.exports=require("util")},29021:a=>{"use strict";a.exports=require("fs")},29294:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},33873:a=>{"use strict";a.exports=require("path")},44870:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},49401:(a,b,c)=>{"use strict";c.d(b,{T:()=>h,k:()=>i});var d=c(29021),e=c(21820),f=c(33873),g=c(58864);function h(a,b,c){let d="SKILL.md"===(0,f.basename)(a)?(0,f.dirname)(a):a,h=(0,f.dirname)(d);return(0,g.Eb)(h,(0,f.join)(c,"skills"))||(0,g.Eb)(h,(0,f.join)(b,".pi","skills"))||(0,g.Eb)(h,(0,f.join)((0,e.homedir)(),".agents","skills"))||"skills"===(0,f.basename)(h)&&".agents"===(0,f.basename)((0,f.dirname)(h))?d:null}function i(a){(0,d.lstatSync)(a).isSymbolicLink()?(0,d.unlinkSync)(a):(0,d.rmSync)(a,{recursive:!0})}},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")},72498:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{Fk:()=>i,Y1:()=>g,er:()=>h});var e=c(75430),f=a([e]);function g(a,b){if(!(a&&(0,e.hasTrustRequiringProjectResources)(a)))return{requiresTrust:!1,trusted:!0};let c=new e.ProjectTrustStore(b);return{requiresTrust:!0,trusted:!0===c.get(a)}}function h(a,b){let c=g(a,b);return c.requiresTrust?(new e.ProjectTrustStore(b).set(a,!0),{requiresTrust:!0,trusted:!0}):c}function i(a,b){if(!g(a,b).requiresTrust)return;let c=new e.ProjectTrustStore(b);return{resolveProjectTrust:async()=>!0===c.get(a)}}e=(f.then?(await f)():f)[0],d()}catch(a){d(a)}})},73024:a=>{"use strict";a.exports=require("node:fs")},75430:a=>{"use strict";a.exports=import("@earendil-works/pi-coding-agent")},75805:(a,b,c)=>{"use strict";c.d(b,{_:()=>j});var d=c(29021),e=c(21820),f=c(33873);function g(a){try{let b=JSON.parse((0,d.readFileSync)(a,"utf8"));return b.skills&&"object"==typeof b.skills?b.skills:{}}catch{return{}}}function h(a,b){let c=(0,f.relative)((0,f.resolve)(b),(0,f.resolve)(a));return""!==c&&".."!==c&&!c.startsWith(`..${f.sep}`)&&!(0,f.isAbsolute)(c)}function i(a,b,c){var d;let e=function(a,b){if(a[b])return a[b];let c=b.toLowerCase(),d=Object.keys(a).find(a=>a.toLowerCase()===c);return d?a[d]:void 0}(a,b);if(!e||"string"!=typeof e.source||!e.source.trim())return;let f="string"==typeof e.sourceType?e.sourceType:void 0,g=(d=e.source.trim(),"github"!==f?d.replace(/\/$/,""):d.replace(/^git\+/,"").replace(/^https?:\/\/github\.com\//,"").replace(/^git@github\.com:/,"").replace(/\.git$/,"").replace(/\/$/,""));if(!g)return;let h="string"==typeof e.skillPath?e.skillPath:void 0,i="string"==typeof e.ref?e.ref:void 0,j="global"===c?e.skillFolderHash:e.computedHash,k="string"==typeof j&&j?j:void 0,l="github"===f&&/^[\w.-]+\/[\w.-]+$/.test(g);return{package:`${g}@${b}`,scope:c,source:g,sourceType:f,skillsShUrl:"local"===f?void 0:function(a,b){if(!a||a.includes("://")||a.startsWith("git@"))return;let c=a.split("/").filter(Boolean).map(encodeURIComponent).join("/");if(c)return`https://skills.sh/${c}/${encodeURIComponent(b)}`}(g,b),...h&&{skillPath:h},...i&&{ref:i},...k&&{versionHash:k},canCheckForUpdates:!!(l&&h&&k&&("global"===c||!i))}}function j(a,{cwd:b,agentDir:c,globalLockPath:k=function({homeDir:a=(0,e.homedir)(),xdgStateHome:b=process.env.XDG_STATE_HOME}={}){return b?(0,f.join)(b,"skills",".skill-lock.json"):(0,f.join)(a,".agents",".skill-lock.json")}(),projectLockPath:l=(0,f.join)(b,"skills-lock.json")}){let m=g(k),n=g(l),o=(0,f.join)(c,"skills"),p=(0,f.join)(b,".pi","skills");return a.map(a=>{if(!(0,d.existsSync)(a.filePath))return a;let b=h(a.filePath,o)?i(m,a.name,"global"):h(a.filePath,p)?i(n,a.name,"project"):void 0;return b?{...a,install:b}:a})}},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:()=>{}};var b=require("../../../../webpack-runtime.js");b.C(a);var c=b.X(0,[4741,1813,426,402],()=>b(b.s=22725));module.exports=c})();
@@ -1 +1 @@
1
- (()=>{var a={};a.id=7812,a.ids=[7812],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},8128:a=>{"use strict";a.exports=require("next/dist/server/runtime-reacts.external.js")},10846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},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")},33873:a=>{"use strict";a.exports=require("path")},43987:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.r(b),c.d(b,{POST:()=>l,dynamic:()=>m});var e=c(23211),f=c(75430),g=c(84107),h=c(80547),i=c(66544),j=c(72498),k=a([f,h,j]);[f,h,j]=k.then?(await k)():k;let m="force-dynamic",n=/\x1B\[[0-9;]*m/g;async function l(a){if(!(0,i.EN)(a))return e.NextResponse.json({error:"Untrusted API request"},{status:403});if(!(0,i.E2)(a))return e.NextResponse.json({error:"Content-Type must be application/json"},{status:415});try{let{package:b,scope:c,cwd:d}=await a.json();if(!b?.trim())return e.NextResponse.json({error:"package required"},{status:400});let i="project"!==c;if(!i){if(!d)return e.NextResponse.json({error:"cwd required for project install"},{status:400});let a=await (0,h.mc)();if(!(0,h.B7)(d,a))return e.NextResponse.json({error:"Access denied"},{status:403});if(!(0,j.Y1)(d,(0,f.getAgentDir)()).trusted)return e.NextResponse.json({error:"Project resources must be trusted before installing project skills"},{status:403})}let k=["skills","add",b.trim(),"-y","--agent","pi"];i&&k.push("-g"),console.log(`[skills/install] running: npx ${k.join(" ")}`);let{stdout:l,stderr:m}=await (0,g.a)(k,{timeout:6e4,cwd:!i&&d?d:void 0,env:{...process.env,FORCE_COLOR:"0"}}),o=(l+m).replace(n,"");if(!/Installation complete|Installed \d+ skill/.test(o))return e.NextResponse.json({error:o.slice(-300)||"Install failed"},{status:500});return e.NextResponse.json({success:!0,output:o})}catch(b){let a=((b.stdout??"")+(b.stderr??"")).replace(n,"");return e.NextResponse.json({error:a||(b.message??String(b))},{status:500})}}d()}catch(a){d(a)}})},44870:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},51455:a=>{"use strict";a.exports=require("node:fs/promises")},53642:(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/skills/install/route",pathname:"/api/skills/install",filename:"route",bundlePath:"app/api/skills/install/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/home/zhujunshen/pi-web/app/api/skills/install/route.ts",nextConfigOutput:"",userland:()=>c(43987),...{}}),{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/skills/install/route";"/index"===d&&(d="/");let f=await u.prepare(a,b,{srcPage:d,multiZoneDraftMode:!1});if(!f)return b.statusCode=400,b.end("Bad Request"),null==c.waitUntil||c.waitUntil.call(c,Promise.resolve()),null;let{buildId:v,deploymentId:w,params:x,nextConfig:y,parsedUrl:z,isDraftMode:A,prerenderManifest:B,routerServerContext:C,isOnDemandRevalidate:D,revalidateOnlyGenerated:E,resolvedPathname:F,clientReferenceManifest:G,serverActionsManifest:H}=f,I=(0,j.normalizeAppPath)(d),J=!!(B.dynamicRoutes[I]||B.routes[F]),K=async()=>((null==C?void 0:C.render404)?await C.render404(a,b,z,!1):b.end("This page could not be found"),null);if(J&&!A){let a=!!B.routes[F],b=B.dynamicRoutes[I];if(b&&!1===b.fallback&&!a){if(y.adapterPath)return await K();throw new s.NoFallbackError}}let L=null;!J||u.isDev||A||(L="/index"===(L=F)?"/":L);let M=!0===u.isDev||!J,N=J&&!M;H&&G&&(0,i.setManifestsSingleton)({page:d,clientReferenceManifest:G,serverActionsManifest:H});let O=a.method||"GET",P=(0,h.getTracer)(),Q=P.getActiveScopeSpan(),R=!!(null==C?void 0:C.isWrappedByNextServer),S=!!(0,g.getRequestMeta)(a,"minimalMode"),T=(0,g.getRequestMeta)(a,"incrementalCache")||await u.getIncrementalCache(a,y,B,S);null==T||T.resetRequestCache(),globalThis.__incrementalCache=T;let U={params:x,previewProps:B.preview,renderOpts:{experimental:{authInterrupts:!!y.experimental.authInterrupts,useCacheTimeout:y.experimental.useCacheTimeout},cacheComponents:!!y.cacheComponents,validationLevel:y.experimental.instantInsights.validationLevel,supportsDynamicResponse:M,incrementalCache:T,hmrRefreshHash:(0,g.getRequestMeta)(a,"hmrRefreshHash"),cacheLifeProfiles:y.cacheLife,staticPageGenerationTimeout:y.staticPageGenerationTimeout,waitUntil:c.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:void 0,onInstrumentationRequestError:(b,c,d,e)=>u.onRequestError(a,b,d,e,C)},sharedContext:{buildId:v,deploymentId:w}},V=new k.NodeNextRequest(a),W=new k.NodeNextResponse(b),X=l.NextRequestAdapter.fromNodeNextRequest(V,(0,l.signalFromNodeResponse)(b)),Y=async({previousCacheEntry:e})=>{try{if(!S&&D&&E&&!e)return b.statusCode=404,b.setHeader("x-nextjs-cache","REVALIDATED"),b.end("This page could not be found"),null;let d=await u.handle(X,U);a.fetchMetrics=U.renderOpts.fetchMetrics;let f=U.renderOpts.pendingWaitUntil;f&&c.waitUntil&&(c.waitUntil(f),f=void 0);let g=U.renderOpts.collectedTags;if(!J)return await (0,o.I)(V,W,d,f),null;{let a=await d.blob(),b=(0,p.toNodeOutgoingHttpHeaders)(d.headers);g&&(b[r.NEXT_CACHE_TAGS_HEADER]=g),!b["content-type"]&&a.type&&(b["content-type"]=a.type);let c=void 0!==U.renderOpts.collectedRevalidate&&!(U.renderOpts.collectedRevalidate>=r.INFINITE_CACHE)&&U.renderOpts.collectedRevalidate,e=void 0===U.renderOpts.collectedExpire||U.renderOpts.collectedExpire>=r.INFINITE_CACHE?!1!==c&&c>0?y.expireTime:void 0:U.renderOpts.collectedExpire;return{value:{kind:t.CachedRouteKind.APP_ROUTE,status:d.status,body:Buffer.from(await a.arrayBuffer()),headers:b},cacheControl:{revalidate:c,expire:e}}}}catch(b){throw(null==e?void 0:e.isStale)&&await u.onRequestError(a,b,{routerKind:"App Router",routePath:d,routeType:"route",revalidateReason:(0,n.getRevalidateReason)({isStaticGeneration:N,isOnDemandRevalidate:D})},!1,C),b}},Z=async(d,f)=>{try{var g,i;let d=await u.handleResponse({req:a,nextConfig:y,cacheKey:L,routeKind:e.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:B,isRoutePPREnabled:!1,isOnDemandRevalidate:D,revalidateOnlyGenerated:E,responseGenerator:Y,waitUntil:c.waitUntil,isMinimalMode:S});if(!J)return;if((null==d||null==(g=d.value)?void 0:g.kind)!==t.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==d||null==(i=d.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});S||b.setHeader("x-nextjs-cache",D?"REVALIDATED":d.isMiss?"MISS":d.isStale?"STALE":"HIT"),A&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let f=(0,p.fromNodeOutgoingHttpHeaders)(d.value.headers);S&&J||f.delete(r.NEXT_CACHE_TAGS_HEADER),!d.cacheControl||b.getHeader("Cache-Control")||f.get("Cache-Control")||f.set("Cache-Control",(0,q.getCacheControlHeader)(d.cacheControl)),await (0,o.I)(V,W,new Response(d.value.body,{headers:f,status:d.value.status||200}));return}catch(b){if(b instanceof s.NoFallbackError||await u.onRequestError(a,b,{routerKind:"App Router",routePath:I,routeType:"route",revalidateReason:(0,n.getRevalidateReason)({isStaticGeneration:N,isOnDemandRevalidate:D})},!1,C),J)throw b;await (0,o.I)(V,W,new Response(null,{status:500}));return}finally{(()=>{if(!d)return;let a=b.statusCode;d.setAttributes({"http.status_code":a,"next.rsc":!1}),a&&a>=500&&(d.setStatus({code:h.SpanStatusCode.ERROR}),d.setAttribute("error.type",a.toString()));let c=P.getRootSpanAttributes();if(!c)return;if(c.get("next.span_type")!==m.BaseServerSpan.handleRequest)return console.warn(`Unexpected root span type '${c.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let e=c.get("next.route")||I,g=`${O} ${e}`;d.setAttributes({"next.route":e,"http.route":e,"next.span_name":g}),d.updateName(g),f&&f!==d&&(f.setAttribute("http.route",e),f.updateName(g))})()}};if(R&&Q)await Z(Q,void 0);else{let b=P.getActiveScopeSpan();await P.withPropagatedContext(a.headers,()=>P.trace(m.BaseServerSpan.handleRequest,{spanName:`${O} ${d}`,kind:h.SpanKind.SERVER,attributes:{"http.method":O,"http.target":a.url}},a=>Z(a,b)),void 0,!R)}}},55511:a=>{"use strict";a.exports=require("crypto")},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"))}},72498:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{Fk:()=>i,Y1:()=>g,er:()=>h});var e=c(75430),f=a([e]);function g(a,b){if(!(a&&(0,e.hasTrustRequiringProjectResources)(a)))return{requiresTrust:!1,trusted:!0};let c=new e.ProjectTrustStore(b);return{requiresTrust:!0,trusted:!0===c.get(a)}}function h(a,b){let c=g(a,b);return c.requiresTrust?(new e.ProjectTrustStore(b).set(a,!0),{requiresTrust:!0,trusted:!0}):c}function i(a,b){if(!g(a,b).requiresTrust)return;let c=new e.ProjectTrustStore(b);return{resolveProjectTrust:async()=>!0===c.get(a)}}e=(f.then?(await f)():f)[0],d()}catch(a){d(a)}})},73024:a=>{"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:()=>{},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)}})},84107:(a,b,c)=>{"use strict";c.d(b,{a:()=>j});var d=c(79646),e=c(28354),f=c(29021),g=c(33873);let h=require("process"),i=(0,e.promisify)(d.execFile);async function j(a,b={}){let c=function(){let a=(0,g.dirname)(h.execPath);for(let b of[(0,g.join)(a,"node_modules","npm","bin","npx-cli.js"),(0,g.join)(a,"..","lib","node_modules","npm","bin","npx-cli.js")])try{if((0,f.existsSync)(b))return b}catch{}return null}(),{command:d,commandArgs:e}=c?{command:h.execPath,commandArgs:[c,...a]}:{command:"npx",commandArgs:a};return i(d,e,{timeout:b.timeout,cwd:b.cwd,env:b.env})}},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,426,402],()=>b(b.s=53642));module.exports=c})();
1
+ (()=>{var a={};a.id=7812,a.ids=[7812],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},8128:a=>{"use strict";a.exports=require("next/dist/server/runtime-reacts.external.js")},10846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},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")},33873:a=>{"use strict";a.exports=require("path")},43987:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.r(b),c.d(b,{POST:()=>l,dynamic:()=>m});var e=c(23211),f=c(75430),g=c(84107),h=c(80547),i=c(66544),j=c(72498),k=a([f,h,j]);[f,h,j]=k.then?(await k)():k;let m="force-dynamic",n=/\x1B\[[0-9;]*m/g;async function l(a){if(!(0,i.EN)(a))return e.NextResponse.json({error:"Untrusted API request"},{status:403});if(!(0,i.E2)(a))return e.NextResponse.json({error:"Content-Type must be application/json"},{status:415});try{let{package:b,scope:c,cwd:d}=await a.json();if(!b?.trim())return e.NextResponse.json({error:"package required"},{status:400});let i="project"!==c;if(!i){if(!d)return e.NextResponse.json({error:"cwd required for project install"},{status:400});let a=await (0,h.mc)();if(!(0,h.B7)(d,a))return e.NextResponse.json({error:"Access denied"},{status:403});if(!(0,j.Y1)(d,(0,f.getAgentDir)()).trusted)return e.NextResponse.json({error:"Project resources must be trusted before installing project skills"},{status:403})}let k=["skills","add",b.trim(),"-y","--agent","pi"];i&&k.push("-g"),console.log(`[skills/install] running: npx ${k.join(" ")}`);let{stdout:l,stderr:m}=await (0,g.a)(k,{timeout:6e4,cwd:!i&&d?d:void 0,env:{...process.env,FORCE_COLOR:"0"}}),o=(l+m).replace(n,"");if(!/Installation complete|Installed \d+ skill/.test(o))return e.NextResponse.json({error:o.slice(-300)||"Install failed"},{status:500});return e.NextResponse.json({success:!0,output:o})}catch(b){let a=((b.stdout??"")+(b.stderr??"")).replace(n,"");return e.NextResponse.json({error:a||(b.message??String(b))},{status:500})}}d()}catch(a){d(a)}})},44870:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},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")},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"))}},70043:(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/skills/install/route",pathname:"/api/skills/install",filename:"route",bundlePath:"app/api/skills/install/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/home/zhujunshen/pi-web/app/api/skills/install/route.ts",nextConfigOutput:"",userland:()=>c(43987),...{}}),{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/skills/install/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)}}},72498:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{Fk:()=>i,Y1:()=>g,er:()=>h});var e=c(75430),f=a([e]);function g(a,b){if(!(a&&(0,e.hasTrustRequiringProjectResources)(a)))return{requiresTrust:!1,trusted:!0};let c=new e.ProjectTrustStore(b);return{requiresTrust:!0,trusted:!0===c.get(a)}}function h(a,b){let c=g(a,b);return c.requiresTrust?(new e.ProjectTrustStore(b).set(a,!0),{requiresTrust:!0,trusted:!0}):c}function i(a,b){if(!g(a,b).requiresTrust)return;let c=new e.ProjectTrustStore(b);return{resolveProjectTrust:async()=>!0===c.get(a)}}e=(f.then?(await f)():f)[0],d()}catch(a){d(a)}})},73024:a=>{"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:()=>{},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)}})},84107:(a,b,c)=>{"use strict";c.d(b,{a:()=>j});var d=c(79646),e=c(28354),f=c(29021),g=c(33873);let h=require("process"),i=(0,e.promisify)(d.execFile);async function j(a,b={}){let c=function(){let a=(0,g.dirname)(h.execPath);for(let b of[(0,g.join)(a,"node_modules","npm","bin","npx-cli.js"),(0,g.join)(a,"..","lib","node_modules","npm","bin","npx-cli.js")])try{if((0,f.existsSync)(b))return b}catch{}return null}(),{command:d,commandArgs:e}=c?{command:h.execPath,commandArgs:[c,...a]}:{command:"npx",commandArgs:a};return i(d,e,{timeout:b.timeout,cwd:b.cwd,env:b.env})}},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,426,402],()=>b(b.s=70043));module.exports=c})();