@henlii/pidance 0.2.28 → 0.2.30

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 (264) 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 +2 -2
  4. package/.next/prerender-manifest.json +3 -3
  5. package/.next/required-server-files.json +1 -1
  6. package/.next/routes-manifest.json +8 -0
  7. package/.next/server/app/_global-error/page.js +3 -3
  8. package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  9. package/.next/server/app/_global-error.html +1 -1
  10. package/.next/server/app/_global-error.rsc +1 -1
  11. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  12. package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  13. package/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  14. package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  15. package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  16. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  17. package/.next/server/app/_not-found/page.js +2 -2
  18. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  19. package/.next/server/app/_not-found.html +1 -1
  20. package/.next/server/app/_not-found.rsc +3 -3
  21. package/.next/server/app/_not-found.segments/_full.segment.rsc +3 -3
  22. package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  23. package/.next/server/app/_not-found.segments/_index.segment.rsc +3 -3
  24. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  25. package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  26. package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  27. package/.next/server/app/api/about/route.js +1 -1
  28. package/.next/server/app/api/agent/[id]/bash-output/route.js +1 -1
  29. package/.next/server/app/api/agent/[id]/events/route.js +2 -2
  30. package/.next/server/app/api/agent/[id]/route.js +1 -1
  31. package/.next/server/app/api/agent/new/route.js +1 -1
  32. package/.next/server/app/api/agent/running/events/route.js +1 -1
  33. package/.next/server/app/api/agent/running/route.js +1 -1
  34. package/.next/server/app/api/agent/submissions/[submissionId]/route.js +1 -0
  35. package/.next/server/app/api/agent/submissions/[submissionId]/route_client-reference-manifest.js +1 -0
  36. package/.next/server/app/api/agent-settings/route.js +2 -2
  37. package/.next/server/app/api/attachments/route.js +1 -1
  38. package/.next/server/app/api/auth/all-providers/route.js +1 -1
  39. package/.next/server/app/api/auth/api-key/[provider]/route.js +1 -1
  40. package/.next/server/app/api/auth/login/[provider]/route.js +2 -2
  41. package/.next/server/app/api/auth/logout/[provider]/route.js +1 -1
  42. package/.next/server/app/api/auth/providers/route.js +1 -1
  43. package/.next/server/app/api/auth/ui-session/route.js +1 -1
  44. package/.next/server/app/api/auth/ui-sessions/[id]/route.js +1 -1
  45. package/.next/server/app/api/auth/ui-sessions/route.js +1 -1
  46. package/.next/server/app/api/cwd/browse/route.js +1 -1
  47. package/.next/server/app/api/cwd/validate/route.js +1 -1
  48. package/.next/server/app/api/default-cwd/route.js +1 -1
  49. package/.next/server/app/api/file-index/route.js +1 -1
  50. package/.next/server/app/api/files/[...path]/route.js +1 -1
  51. package/.next/server/app/api/git/diff/route.js +1 -1
  52. package/.next/server/app/api/git/status/route.js +1 -1
  53. package/.next/server/app/api/home/route.js +1 -1
  54. package/.next/server/app/api/message-media/route.js +1 -1
  55. package/.next/server/app/api/models/route.js +1 -1
  56. package/.next/server/app/api/models-config/raw/route.js +1 -1
  57. package/.next/server/app/api/models-config/route.js +1 -1
  58. package/.next/server/app/api/models-config/test/route.js +1 -1
  59. package/.next/server/app/api/plugins/route.js +1 -1
  60. package/.next/server/app/api/plugins/search/route.js +1 -1
  61. package/.next/server/app/api/plugins/updates/route.js +1 -1
  62. package/.next/server/app/api/preferences/route.js +1 -1
  63. package/.next/server/app/api/project-assets/route.js +2 -2
  64. package/.next/server/app/api/prompts/route.js +1 -1
  65. package/.next/server/app/api/pty/route.js +2 -2
  66. package/.next/server/app/api/sessions/[id]/archive/route.js +1 -1
  67. package/.next/server/app/api/sessions/[id]/auto-name/route.js +1 -1
  68. package/.next/server/app/api/sessions/[id]/command-entry/route.js +1 -1
  69. package/.next/server/app/api/sessions/[id]/context/route.js +1 -1
  70. package/.next/server/app/api/sessions/[id]/entries/[entryId]/thinking/route.js +1 -1
  71. package/.next/server/app/api/sessions/[id]/export/route.js +1 -1
  72. package/.next/server/app/api/sessions/[id]/info/route.js +1 -1
  73. package/.next/server/app/api/sessions/[id]/outline/route.js +1 -1
  74. package/.next/server/app/api/sessions/[id]/route.js +1 -1
  75. package/.next/server/app/api/sessions/[id]/state/route.js +1 -1
  76. package/.next/server/app/api/sessions/[id]/tool-results/[toolCallId]/route.js +1 -1
  77. package/.next/server/app/api/sessions/route.js +1 -1
  78. package/.next/server/app/api/sessions/search/route.js +1 -1
  79. package/.next/server/app/api/settings/raw/route.js +2 -2
  80. package/.next/server/app/api/settings/remote/route.js +1 -1
  81. package/.next/server/app/api/skills/check/route.js +1 -1
  82. package/.next/server/app/api/skills/install/route.js +1 -1
  83. package/.next/server/app/api/skills/route.js +1 -1
  84. package/.next/server/app/api/skills/search/route.js +1 -1
  85. package/.next/server/app/api/skills/update/route.js +1 -1
  86. package/.next/server/app/api/subagent-runs/route.js +1 -1
  87. package/.next/server/app/api/update/apply/route.js +2 -2
  88. package/.next/server/app/api/update/check/route.js +1 -1
  89. package/.next/server/app/api/worktrees/route.js +1 -1
  90. package/.next/server/app/icon.png/route.js +1 -1
  91. package/.next/server/app/index.html +1 -1
  92. package/.next/server/app/index.rsc +5 -5
  93. package/.next/server/app/index.segments/__PAGE__.segment.rsc +3 -3
  94. package/.next/server/app/index.segments/_full.segment.rsc +5 -5
  95. package/.next/server/app/index.segments/_head.segment.rsc +1 -1
  96. package/.next/server/app/index.segments/_index.segment.rsc +3 -3
  97. package/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  98. package/.next/server/app/page.js +15 -15
  99. package/.next/server/app/page_client-reference-manifest.js +1 -1
  100. package/.next/server/app-paths-manifest.json +11 -10
  101. package/.next/server/chunks/188.js +1 -1
  102. package/.next/server/chunks/2356.js +2 -0
  103. package/.next/server/chunks/3379.js +1 -1
  104. package/.next/server/chunks/3557.js +1 -0
  105. package/.next/server/chunks/5274.js +1 -1
  106. package/.next/server/chunks/5304.js +2 -2
  107. package/.next/server/chunks/5582.js +1 -1
  108. package/.next/server/chunks/6192.js +1 -1
  109. package/.next/server/chunks/7594.js +5 -5
  110. package/.next/server/chunks/9935.js +1 -0
  111. package/.next/server/instrumentation.js +1 -1
  112. package/.next/server/middleware-build-manifest.js +1 -1
  113. package/.next/server/pages/404.html +1 -1
  114. package/.next/server/pages/500.html +1 -1
  115. package/.next/server/server-reference-manifest.json +1 -1
  116. package/.next/static/{Ni2HugOTDE44QzNWaiTkR → 7Pv6SoXSxrYy0FZPYHHKJ}/_buildManifest.js +1 -1
  117. package/.next/static/chunks/9780-e89266f79eb581fe.js +1 -0
  118. package/.next/static/chunks/app/_global-error/page-3154b10ff0f29211.js +1 -0
  119. package/.next/static/chunks/app/api/about/route-3154b10ff0f29211.js +1 -0
  120. package/.next/static/chunks/app/api/agent/[id]/bash-output/route-3154b10ff0f29211.js +1 -0
  121. package/.next/static/chunks/app/api/agent/[id]/events/route-3154b10ff0f29211.js +1 -0
  122. package/.next/static/chunks/app/api/agent/[id]/route-3154b10ff0f29211.js +1 -0
  123. package/.next/static/chunks/app/api/agent/new/route-3154b10ff0f29211.js +1 -0
  124. package/.next/static/chunks/app/api/agent/running/events/route-3154b10ff0f29211.js +1 -0
  125. package/.next/static/chunks/app/api/agent/running/route-3154b10ff0f29211.js +1 -0
  126. package/.next/static/chunks/app/api/agent/submissions/[submissionId]/route-3154b10ff0f29211.js +1 -0
  127. package/.next/static/chunks/app/api/agent-settings/route-3154b10ff0f29211.js +1 -0
  128. package/.next/static/chunks/app/api/attachments/route-3154b10ff0f29211.js +1 -0
  129. package/.next/static/chunks/app/api/auth/all-providers/route-3154b10ff0f29211.js +1 -0
  130. package/.next/static/chunks/app/api/auth/api-key/[provider]/route-3154b10ff0f29211.js +1 -0
  131. package/.next/static/chunks/app/api/auth/login/[provider]/route-3154b10ff0f29211.js +1 -0
  132. package/.next/static/chunks/app/api/auth/logout/[provider]/route-3154b10ff0f29211.js +1 -0
  133. package/.next/static/chunks/app/api/auth/providers/route-3154b10ff0f29211.js +1 -0
  134. package/.next/static/chunks/app/api/auth/ui-session/route-3154b10ff0f29211.js +1 -0
  135. package/.next/static/chunks/app/api/auth/ui-sessions/[id]/route-3154b10ff0f29211.js +1 -0
  136. package/.next/static/chunks/app/api/auth/ui-sessions/route-3154b10ff0f29211.js +1 -0
  137. package/.next/static/chunks/app/api/cwd/browse/route-3154b10ff0f29211.js +1 -0
  138. package/.next/static/chunks/app/api/cwd/validate/route-3154b10ff0f29211.js +1 -0
  139. package/.next/static/chunks/app/api/default-cwd/route-3154b10ff0f29211.js +1 -0
  140. package/.next/static/chunks/app/api/file-index/route-3154b10ff0f29211.js +1 -0
  141. package/.next/static/chunks/app/api/files/[...path]/route-3154b10ff0f29211.js +1 -0
  142. package/.next/static/chunks/app/api/git/diff/route-3154b10ff0f29211.js +1 -0
  143. package/.next/static/chunks/app/api/git/status/route-3154b10ff0f29211.js +1 -0
  144. package/.next/static/chunks/app/api/home/route-3154b10ff0f29211.js +1 -0
  145. package/.next/static/chunks/app/api/message-media/route-3154b10ff0f29211.js +1 -0
  146. package/.next/static/chunks/app/api/models/route-3154b10ff0f29211.js +1 -0
  147. package/.next/static/chunks/app/api/models-config/raw/route-3154b10ff0f29211.js +1 -0
  148. package/.next/static/chunks/app/api/models-config/route-3154b10ff0f29211.js +1 -0
  149. package/.next/static/chunks/app/api/models-config/test/route-3154b10ff0f29211.js +1 -0
  150. package/.next/static/chunks/app/api/plugins/route-3154b10ff0f29211.js +1 -0
  151. package/.next/static/chunks/app/api/plugins/search/route-3154b10ff0f29211.js +1 -0
  152. package/.next/static/chunks/app/api/plugins/updates/route-3154b10ff0f29211.js +1 -0
  153. package/.next/static/chunks/app/api/preferences/route-3154b10ff0f29211.js +1 -0
  154. package/.next/static/chunks/app/api/project-assets/route-3154b10ff0f29211.js +1 -0
  155. package/.next/static/chunks/app/api/prompts/route-3154b10ff0f29211.js +1 -0
  156. package/.next/static/chunks/app/api/pty/route-3154b10ff0f29211.js +1 -0
  157. package/.next/static/chunks/app/api/sessions/[id]/archive/route-3154b10ff0f29211.js +1 -0
  158. package/.next/static/chunks/app/api/sessions/[id]/auto-name/route-3154b10ff0f29211.js +1 -0
  159. package/.next/static/chunks/app/api/sessions/[id]/command-entry/route-3154b10ff0f29211.js +1 -0
  160. package/.next/static/chunks/app/api/sessions/[id]/context/route-3154b10ff0f29211.js +1 -0
  161. package/.next/static/chunks/app/api/sessions/[id]/entries/[entryId]/thinking/route-3154b10ff0f29211.js +1 -0
  162. package/.next/static/chunks/app/api/sessions/[id]/export/route-3154b10ff0f29211.js +1 -0
  163. package/.next/static/chunks/app/api/sessions/[id]/info/route-3154b10ff0f29211.js +1 -0
  164. package/.next/static/chunks/app/api/sessions/[id]/outline/route-3154b10ff0f29211.js +1 -0
  165. package/.next/static/chunks/app/api/sessions/[id]/route-3154b10ff0f29211.js +1 -0
  166. package/.next/static/chunks/app/api/sessions/[id]/state/route-3154b10ff0f29211.js +1 -0
  167. package/.next/static/chunks/app/api/sessions/[id]/tool-results/[toolCallId]/route-3154b10ff0f29211.js +1 -0
  168. package/.next/static/chunks/app/api/sessions/route-3154b10ff0f29211.js +1 -0
  169. package/.next/static/chunks/app/api/sessions/search/route-3154b10ff0f29211.js +1 -0
  170. package/.next/static/chunks/app/api/settings/raw/route-3154b10ff0f29211.js +1 -0
  171. package/.next/static/chunks/app/api/settings/remote/route-3154b10ff0f29211.js +1 -0
  172. package/.next/static/chunks/app/api/skills/check/route-3154b10ff0f29211.js +1 -0
  173. package/.next/static/chunks/app/api/skills/install/route-3154b10ff0f29211.js +1 -0
  174. package/.next/static/chunks/app/api/skills/route-3154b10ff0f29211.js +1 -0
  175. package/.next/static/chunks/app/api/skills/search/route-3154b10ff0f29211.js +1 -0
  176. package/.next/static/chunks/app/api/skills/update/route-3154b10ff0f29211.js +1 -0
  177. package/.next/static/chunks/app/api/subagent-runs/route-3154b10ff0f29211.js +1 -0
  178. package/.next/static/chunks/app/api/update/apply/route-3154b10ff0f29211.js +1 -0
  179. package/.next/static/chunks/app/api/update/check/route-3154b10ff0f29211.js +1 -0
  180. package/.next/static/chunks/app/api/worktrees/route-3154b10ff0f29211.js +1 -0
  181. package/.next/static/chunks/app/page-05c85e412b0302f9.js +25 -0
  182. package/.next/static/chunks/next/dist/client/components/builtin/app-error-3154b10ff0f29211.js +1 -0
  183. package/.next/static/chunks/next/dist/client/components/builtin/forbidden-3154b10ff0f29211.js +1 -0
  184. package/.next/static/chunks/next/dist/client/components/builtin/not-found-3154b10ff0f29211.js +1 -0
  185. package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-3154b10ff0f29211.js +1 -0
  186. package/.next/static/css/2655240c351314b2.css +1 -0
  187. package/README.en.md +19 -15
  188. package/README.md +17 -13
  189. package/README.zh-CN.md +11 -204
  190. package/bin/pidance-http-server.js +10 -0
  191. package/bin/pty-manager.cjs +3 -12
  192. package/bin/pty-shell.cjs +27 -0
  193. package/bin/pty-worker.js +17 -8
  194. package/package.json +2 -2
  195. package/.next/static/chunks/9780-4b76db8fbfb345c2.js +0 -1
  196. package/.next/static/chunks/app/_global-error/page-005f7c16c8d63642.js +0 -1
  197. package/.next/static/chunks/app/api/about/route-005f7c16c8d63642.js +0 -1
  198. package/.next/static/chunks/app/api/agent/[id]/bash-output/route-005f7c16c8d63642.js +0 -1
  199. package/.next/static/chunks/app/api/agent/[id]/events/route-005f7c16c8d63642.js +0 -1
  200. package/.next/static/chunks/app/api/agent/[id]/route-005f7c16c8d63642.js +0 -1
  201. package/.next/static/chunks/app/api/agent/new/route-005f7c16c8d63642.js +0 -1
  202. package/.next/static/chunks/app/api/agent/running/events/route-005f7c16c8d63642.js +0 -1
  203. package/.next/static/chunks/app/api/agent/running/route-005f7c16c8d63642.js +0 -1
  204. package/.next/static/chunks/app/api/agent-settings/route-005f7c16c8d63642.js +0 -1
  205. package/.next/static/chunks/app/api/attachments/route-005f7c16c8d63642.js +0 -1
  206. package/.next/static/chunks/app/api/auth/all-providers/route-005f7c16c8d63642.js +0 -1
  207. package/.next/static/chunks/app/api/auth/api-key/[provider]/route-005f7c16c8d63642.js +0 -1
  208. package/.next/static/chunks/app/api/auth/login/[provider]/route-005f7c16c8d63642.js +0 -1
  209. package/.next/static/chunks/app/api/auth/logout/[provider]/route-005f7c16c8d63642.js +0 -1
  210. package/.next/static/chunks/app/api/auth/providers/route-005f7c16c8d63642.js +0 -1
  211. package/.next/static/chunks/app/api/auth/ui-session/route-005f7c16c8d63642.js +0 -1
  212. package/.next/static/chunks/app/api/auth/ui-sessions/[id]/route-005f7c16c8d63642.js +0 -1
  213. package/.next/static/chunks/app/api/auth/ui-sessions/route-005f7c16c8d63642.js +0 -1
  214. package/.next/static/chunks/app/api/cwd/browse/route-005f7c16c8d63642.js +0 -1
  215. package/.next/static/chunks/app/api/cwd/validate/route-005f7c16c8d63642.js +0 -1
  216. package/.next/static/chunks/app/api/default-cwd/route-005f7c16c8d63642.js +0 -1
  217. package/.next/static/chunks/app/api/file-index/route-005f7c16c8d63642.js +0 -1
  218. package/.next/static/chunks/app/api/files/[...path]/route-005f7c16c8d63642.js +0 -1
  219. package/.next/static/chunks/app/api/git/diff/route-005f7c16c8d63642.js +0 -1
  220. package/.next/static/chunks/app/api/git/status/route-005f7c16c8d63642.js +0 -1
  221. package/.next/static/chunks/app/api/home/route-005f7c16c8d63642.js +0 -1
  222. package/.next/static/chunks/app/api/message-media/route-005f7c16c8d63642.js +0 -1
  223. package/.next/static/chunks/app/api/models/route-005f7c16c8d63642.js +0 -1
  224. package/.next/static/chunks/app/api/models-config/raw/route-005f7c16c8d63642.js +0 -1
  225. package/.next/static/chunks/app/api/models-config/route-005f7c16c8d63642.js +0 -1
  226. package/.next/static/chunks/app/api/models-config/test/route-005f7c16c8d63642.js +0 -1
  227. package/.next/static/chunks/app/api/plugins/route-005f7c16c8d63642.js +0 -1
  228. package/.next/static/chunks/app/api/plugins/search/route-005f7c16c8d63642.js +0 -1
  229. package/.next/static/chunks/app/api/plugins/updates/route-005f7c16c8d63642.js +0 -1
  230. package/.next/static/chunks/app/api/preferences/route-005f7c16c8d63642.js +0 -1
  231. package/.next/static/chunks/app/api/project-assets/route-005f7c16c8d63642.js +0 -1
  232. package/.next/static/chunks/app/api/prompts/route-005f7c16c8d63642.js +0 -1
  233. package/.next/static/chunks/app/api/pty/route-005f7c16c8d63642.js +0 -1
  234. package/.next/static/chunks/app/api/sessions/[id]/archive/route-005f7c16c8d63642.js +0 -1
  235. package/.next/static/chunks/app/api/sessions/[id]/auto-name/route-005f7c16c8d63642.js +0 -1
  236. package/.next/static/chunks/app/api/sessions/[id]/command-entry/route-005f7c16c8d63642.js +0 -1
  237. package/.next/static/chunks/app/api/sessions/[id]/context/route-005f7c16c8d63642.js +0 -1
  238. package/.next/static/chunks/app/api/sessions/[id]/entries/[entryId]/thinking/route-005f7c16c8d63642.js +0 -1
  239. package/.next/static/chunks/app/api/sessions/[id]/export/route-005f7c16c8d63642.js +0 -1
  240. package/.next/static/chunks/app/api/sessions/[id]/info/route-005f7c16c8d63642.js +0 -1
  241. package/.next/static/chunks/app/api/sessions/[id]/outline/route-005f7c16c8d63642.js +0 -1
  242. package/.next/static/chunks/app/api/sessions/[id]/route-005f7c16c8d63642.js +0 -1
  243. package/.next/static/chunks/app/api/sessions/[id]/state/route-005f7c16c8d63642.js +0 -1
  244. package/.next/static/chunks/app/api/sessions/[id]/tool-results/[toolCallId]/route-005f7c16c8d63642.js +0 -1
  245. package/.next/static/chunks/app/api/sessions/route-005f7c16c8d63642.js +0 -1
  246. package/.next/static/chunks/app/api/sessions/search/route-005f7c16c8d63642.js +0 -1
  247. package/.next/static/chunks/app/api/settings/raw/route-005f7c16c8d63642.js +0 -1
  248. package/.next/static/chunks/app/api/settings/remote/route-005f7c16c8d63642.js +0 -1
  249. package/.next/static/chunks/app/api/skills/check/route-005f7c16c8d63642.js +0 -1
  250. package/.next/static/chunks/app/api/skills/install/route-005f7c16c8d63642.js +0 -1
  251. package/.next/static/chunks/app/api/skills/route-005f7c16c8d63642.js +0 -1
  252. package/.next/static/chunks/app/api/skills/search/route-005f7c16c8d63642.js +0 -1
  253. package/.next/static/chunks/app/api/skills/update/route-005f7c16c8d63642.js +0 -1
  254. package/.next/static/chunks/app/api/subagent-runs/route-005f7c16c8d63642.js +0 -1
  255. package/.next/static/chunks/app/api/update/apply/route-005f7c16c8d63642.js +0 -1
  256. package/.next/static/chunks/app/api/update/check/route-005f7c16c8d63642.js +0 -1
  257. package/.next/static/chunks/app/api/worktrees/route-005f7c16c8d63642.js +0 -1
  258. package/.next/static/chunks/app/page-354e6fd7f7df840b.js +0 -25
  259. package/.next/static/chunks/next/dist/client/components/builtin/app-error-005f7c16c8d63642.js +0 -1
  260. package/.next/static/chunks/next/dist/client/components/builtin/forbidden-005f7c16c8d63642.js +0 -1
  261. package/.next/static/chunks/next/dist/client/components/builtin/not-found-005f7c16c8d63642.js +0 -1
  262. package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-005f7c16c8d63642.js +0 -1
  263. package/.next/static/css/1c6fd1229e5153db.css +0 -1
  264. /package/.next/static/{Ni2HugOTDE44QzNWaiTkR → 7Pv6SoXSxrYy0FZPYHHKJ}/_ssgManifest.js +0 -0
@@ -1 +1 @@
1
- exports.id=5582,exports.ids=[5582],exports.modules={12039:(a,b,c)=>{"use strict";c.d(b,{B:()=>f});var d=c(31514);function e(a){return"object"==typeof a&&null!==a&&!Array.isArray(a)}function f(a){if("assistant"!==a.role)return a;let b=a.content;if(!Array.isArray(b))return a;let c=b.map(a=>{let b=function(a){if(!e(a)||"toolCall"!==a.type)return null;let b={type:"toolCall",toolCallId:"string"==typeof a.toolCallId?a.toolCallId:"string"==typeof a.id?a.id:"",toolName:"string"==typeof a.toolName?a.toolName:"string"==typeof a.name?a.name:"",input:"object"!=typeof a.input||null===a.input||Array.isArray(a.input)?"object"!=typeof a.arguments||null===a.arguments||Array.isArray(a.arguments)?{}:a.arguments:a.input};return Array.isArray(a.renderedCallLines)&&a.renderedCallLines.every(a=>"string"==typeof a)&&(b.renderedCallLines=[...a.renderedCallLines]),b}(a);return b||(e(a)&&(0,d.mv)(a.type)?(0,d.Xb)(a):a)});return{...a,content:c}}},13737:(a,b,c)=>{"use strict";c.d(b,{FH:()=>j,Ln:()=>g,PB:()=>k,QT:()=>i,uG:()=>d});let d="pidance.binary",e=/^[a-z0-9][a-z0-9!#$&^_.+-]*\/[a-z0-9][a-z0-9!#$&^_.+-]*$/i;function f(a){let b=a.toLowerCase();return b.startsWith("image/")?"image":b.startsWith("audio/")?"audio":b.startsWith("video/")?"video":"file"}function g(a){if("string"!=typeof a)return null;let b=a.trim().toLowerCase();return e.test(b)?b:null}function h(a){if("string"!=typeof a)return null;let b=a.replace(/[\\/\0]/g,"_").trim();return!b||b.length>180?null:b}function i(a){if(!a||"object"!=typeof a||Array.isArray(a)||"binary"!==a.type||1!==a.version||"string"!=typeof a.path)return null;let b=a.path.trim();if(!b||b.length>4096)return null;let c=h(a.name),d=g(a.mimeType);if(!c||!d||"number"!=typeof a.size||!Number.isSafeInteger(a.size)||a.size<0)return null;let e=a.kind;if("image"!==e&&"audio"!==e&&"video"!==e&&"file"!==e||e!==f(d))return null;let i=void 0===a.previewPath?void 0:"string"==typeof a.previewPath&&a.previewPath.trim().length<=4096?a.previewPath.trim()||void 0:null;if(null===i)return null;let j=void 0===a.messageEntryId?void 0:"string"==typeof a.messageEntryId&&a.messageEntryId.trim()?a.messageEntryId.trim():null;return null===j?null:{type:"binary",version:1,kind:e,path:b,name:c,mimeType:d,size:a.size,...i?{previewPath:i}:{},...j?{messageEntryId:j}:{}}}function j(a,b){let c={role:"custom",customType:d,content:a.name,display:!0,details:a};return void 0!==b&&(c.timestamp=b),c}function k(a,b){let c=g(a.mimeType)??"application/octet-stream",d=h(a.name)??"file",e=a.path.trim(),i=Number.isSafeInteger(a.size)&&a.size>=0?a.size:0,j=a.previewPath?.trim()||void 0;return{type:"binary",version:1,kind:f(c),path:e,name:d,mimeType:c,size:i,...j?{previewPath:j}:{},...b?{messageEntryId:b}:{}}}},13995:(a,b,c)=>{"use strict";let d;c.d(b,{If:()=>o,Jz:()=>l,O:()=>q,iw:()=>m});var e=c(4984),f=c(29021),g=c(79748),h=c(33873),i=c(60396);function j(){return(0,h.join)((0,i.$M)(),"pidance-session-cache.json")}async function k(a){try{let b=await (0,g.stat)(a);return{path:a,mtimeMs:b.mtimeMs,size:b.size}}catch{return null}}async function l(a=(0,h.join)((0,i.$M)(),"sessions")){let b=[];try{b=(await (0,g.readdir)(a,{withFileTypes:!0})).filter(a=>a.isDirectory()).map(b=>(0,h.join)(a,b.name))}catch{return[]}let c=[],d=[];for(let a of b)d.push((async()=>{try{for(let b of(await (0,g.readdir)(a)))b.endsWith(".jsonl")&&c.push((0,h.join)(a,b))}catch{}})());return await Promise.all(d),(await Promise.all(c.map(a=>k(a)))).filter(a=>null!==a)}function m(a=j()){try{let b=(0,f.readFileSync)(a,"utf8"),c=JSON.parse(b);if(!c||2!==c.version||!c.sessions||"object"!=typeof c.sessions)return null;return{version:2,sessions:c.sessions,discovery:c.discovery&&"object"==typeof c.discovery?c.discovery:{}}}catch{return null}}let n=!1;function o(a,b,c=j()){n=!0,d||(d=setTimeout(()=>{if(d=void 0,!n)return;n=!1;let e={version:2,sessions:Object.fromEntries(a),discovery:Object.fromEntries(b)},g=`${c}.tmp`;try{(0,f.writeFileSync)(g,JSON.stringify(e),"utf8"),(0,f.renameSync)(g,c)}catch{try{(0,f.existsSync)(g)&&(0,f.renameSync)(g,c)}catch{}}},1500))}function p(a){return"object"==typeof a&&null!==a&&"string"==typeof a.role&&"content"in a}async function q(a,b){try{let c,d,g=(0,e.createInterface)({input:(0,f.createReadStream)(a,{encoding:"utf8"}),crlfDelay:1/0}),h=null,i=0,j="";for await(let a of g){let b;if(!a.trim())continue;try{b=JSON.parse(a)}catch{continue}if(!h){if("session"!==b.type)return null;h=b;continue}if("session_info"===b.type){let a=b.name;"string"==typeof a&&a.trim()&&(c=a.trim());continue}if("message"!==b.type)continue;i++;let e=function(a){let b=a.message;if(!p(b)||"user"!==b.role)return;let c=b.timestamp;if("number"==typeof c)return c;let d=new Date(a.timestamp??"").getTime();return Number.isNaN(d)?void 0:d}(b);"number"==typeof e&&(d=Math.max(d??0,e));let f=b.message;if(!p(f)||"user"!==f.role&&"assistant"!==f.role)continue;let g=function(a){let b=a.content;return"string"==typeof b?b:Array.isArray(b)?b.filter(a=>!!(a&&"text"===a.type&&"string"==typeof a.text)).map(a=>a.text).join(" "):""}(f);g&&(j||"user"!==f.role||(j=g))}if(!h)return null;let k="string"==typeof h.timestamp?new Date(h.timestamp).getTime():NaN,l=new Date("number"==typeof d&&d>0?d:Number.isNaN(k)?b.mtimeMs:k);return{id:"string"==typeof h.id?h.id:"",cwd:"string"==typeof h.cwd?h.cwd:"",name:c,created:h.timestamp,modified:l.toISOString(),messageCount:i,firstMessage:j||"(no messages)",parentSessionPath:"string"==typeof h.parentSession?h.parentSession:void 0}}catch{return null}}},15461:(a,b,c)=>{"use strict";c.d(b,{OE:()=>d,fc:()=>e,yz:()=>f});let d="pidance.command";function e(a){return{command:"string"==typeof a.command?a.command.trim():"",ok:!1!==a.ok,result:"string"==typeof a.result&&""!==a.result.trim()?a.result.trim():void 0,version:1}}function f(a){return a&&"object"==typeof a?1!==a.version||"string"!=typeof a.command||""===a.command.trim()?null:{command:a.command,ok:!1!==a.ok,result:"string"==typeof a.result?a.result:void 0,version:1}:null}},24923:(a,b,c)=>{"use strict";c.d(b,{IL:()=>p,KI:()=>l,P9:()=>n,l:()=>o});var d=c(79646),e=c(29021),f=c(33873),g=c(28354),h=c(25252);let i=(0,g.promisify)(d.execFile);function j(){globalThis.__piProjectCache?.clear()}async function k(a,b){let{stdout:c}=await i("git",["-C",a,...b],{timeout:1e4,maxBuffer:1048576,env:{...process.env,LC_ALL:"C"}});return c.trim()}async function l(a){let b,c=(globalThis.__piProjectCache||(globalThis.__piProjectCache=new Map),globalThis.__piProjectCache),d=c.get(a);if(d&&d.expiresAt>Date.now())return d.info;try{if(!(0,e.existsSync)(a))return b=function(a){let b=(0,f.dirname)(a);if(!b.endsWith("-worktrees"))return null;let c=b.slice(0,-10);return c&&(0,e.existsSync)((0,f.join)(c,".git"))?{projectRoot:c,branch:(0,f.basename)(a),isWorktree:!0,isTopLevel:!0}:null}(a)??{projectRoot:a,branch:null,isWorktree:!1,isTopLevel:!1},c.set(a,{info:b,expiresAt:Date.now()+6e4}),b;let[d,g,h,i]=(await k(a,["rev-parse","--path-format=absolute","--git-common-dir","--git-dir","--show-toplevel","--abbrev-ref","HEAD"])).split("\n").map(a=>a.trim()),j=a;try{j=(0,e.realpathSync)(a)}catch{}let l=h===j,m=g!==d&&l;b={projectRoot:m?(0,f.dirname)(d):a,branch:i&&"HEAD"!==i?i:null,isWorktree:m,isTopLevel:l}}catch{b={projectRoot:a,branch:null,isWorktree:!1,isTopLevel:!1}}return c.set(a,{info:b,expiresAt:Date.now()+6e4}),b}async function m(a){let b=await k(a,["rev-parse","--path-format=absolute","--git-common-dir"]);return(0,f.dirname)(b)}async function n(a){let b=await k(a,["worktree","list","--porcelain"]),c=[],d=null,f=()=>{d?.path&&!d.prunable&&(0,e.existsSync)(d.path)&&c.push({path:d.path,branch:d.branch??null,isMain:0===c.length}),d=null};for(let a of b.split("\n"))a.startsWith("worktree ")?(f(),d={path:a.slice(9).trim()}):a.startsWith("branch ")&&d?d.branch=a.slice(7).trim().replace(/^refs\/heads\//,""):a.startsWith("prunable")&&d?d.prunable=!0:""===a.trim()&&f();return f(),c}async function o(a,b){let c=b.trim();if(!c)throw Error("Branch name is required");let d=c.replace(/[\/\\:*?"<>|\s]+/g,"-").replace(/^-+|-+$/g,"");if(!d)throw Error(`Invalid branch name: ${b}`);let g=await m(a),i=`${(0,f.resolve)(g)}-worktrees`,l=(0,f.join)(i,d);if((0,e.existsSync)(l))throw Error(`Directory already exists: ${l}`);(0,e.mkdirSync)(i,{recursive:!0});let n=!1;try{await k(g,["rev-parse","--verify","--quiet",`refs/heads/${c}`]),n=!0}catch{n=!1}try{n?await k(g,["worktree","add","--",l,c]):await k(g,["worktree","add","-b",c,"--",l])}catch(a){throw Error(q(a))}return(0,h.wz)(l),j(),{path:l,branch:c}}async function p(a,b,c=!1){let d=(await n(a)).find(a=>a.path===b);if(!d)throw Error(`Not a worktree of this repository: ${b}`);if(d.isMain)throw Error("Cannot remove the main worktree");try{await k(a,["worktree","remove",...c?["--force"]:[],b])}catch(a){throw Error(q(a))}j()}function q(a){let b=a.stderr;return"string"==typeof b&&b.trim()?b.trim():a instanceof Error?a.message:String(a)}},25252:(a,b,c)=>{"use strict";c.d(b,{HM:()=>e,wz:()=>f});var d=c(50593);function e(){return globalThis.__piAdditionalAllowedRoots||(globalThis.__piAdditionalAllowedRoots=new Set),globalThis.__piAdditionalAllowedRoots}function f(a){if(!a)return;let b=(0,d.Nw)(a);e().add(b),globalThis.__piAllowedRootsCache?.roots.add(b)}},31514:(a,b,c)=>{"use strict";function d(a){for(let b of[a.thinking,a.text,a.reasoning])if("string"==typeof b&&b.length>0)return b;return""}function e(a){return"thinking"===a||"reasoning"===a||"redacted_thinking"===a}function f(a){let b={...a,type:"thinking",thinking:d(a)};return!0===a.deferred&&(b.deferred=!0),b}c.d(b,{Ux:()=>d,Xb:()=>f,mv:()=>e})},40402:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{BR:()=>y,CM:()=>D,DK:()=>A,O8:()=>x,Uv:()=>F,Zx:()=>B,dQ:()=>r,eP:()=>z,jK:()=>C,mD:()=>s,os:()=>v,tY:()=>E,u1:()=>w});var e=c(29021),f=c(33873),g=c(15461),h=c(13995),i=c(12039),j=c(85664),k=c(13737),l=c(24923),m=c(50955);c(60396);var n=c(95237),o=c(31514),p=a([n]);async function q(){let a=await (0,h.Jz)(),b=(0,h.iw)(),c=new Map;if(b)for(let[a,d]of Object.entries(b.sessions))c.set(a,d);let d=a.filter(a=>{let b=c.get(a.path);return!b||b.m!==a.mtimeMs||b.s!==a.size}),g=d.length>0,i=new Map;for(let a of(await Promise.all(d.map(async a=>{let b=await (0,h.O)(a.path,a);b&&i.set(a.path,b)})),d)){let b=i.get(a.path);if(!b){c.delete(a.path);continue}c.set(a.path,{m:a.mtimeMs,s:a.size,i:b})}let j=new Set(a.map(a=>a.path)),k=0;for(let a of[...c.keys()])!j.has(a)&&(c.delete(a),k++);k>0&&(g=!0);let n=[...c.entries()].map(([a,b])=>({path:a,...b.i})).filter(a=>!!(a&&a.id)),o=new Map,p=new Map;for(let a of n){let b=(0,f.normalize)(a.path);o.has(b)||p.has(a.id)||(o.set(b,a.id),p.set(a.id,b))}let q=[...new Set(n.map(a=>a.cwd).filter(Boolean))],r=new Map;await Promise.all(q.map(async a=>{r.set(a,await (0,l.KI)(a))}));let s=new Set,t=new Set,u=n.sort((a,b)=>a.modified<b.modified?1:a.modified>b.modified?-1:0).flatMap(a=>{let b=(0,f.normalize)(a.path);if(s.has(b)||t.has(a.id))return[];s.add(b),t.add(a.id),x(a.id,a.path);let c=a.cwd?r.get(a.cwd):void 0;return[{path:a.path,id:a.id,cwd:a.cwd,name:a.name,created:a.created,modified:a.modified,messageCount:a.messageCount,firstMessage:a.firstMessage||"(no messages)",parentSessionId:a.parentSessionPath?o.get((0,f.normalize)(a.parentSessionPath)):void 0,projectRoot:c?.projectRoot??a.cwd,...c?.isWorktree&&c.branch?{worktreeBranch:c.branch}:{}}]}),v=new Map(u.map(a=>[(0,f.normalize)(a.path),a])),w=new Map(u.map(a=>[a.id,a])),y=new Set,z=new Set,A=[],B=new Map;if(b)for(let[a,c]of Object.entries(b.discovery))B.set(a,c);let C=u.map(a=>({parent:a,depth:0}));for(;C.length&&z.size<256;){let a=C.shift();if(!(a.depth>=16))for(let b of function(a,b,c,d){try{let f=(0,e.statSync)(a),g=c.get(a);if(g&&g.m===f.mtimeMs&&g.s===f.size)return g.c;let h=d(a,b);return c.set(a,{m:f.mtimeMs,s:f.size,c:h}),h}catch{return c.delete(a),[]}}(a.parent.path,a.parent.id,B,(a,b)=>(g=!0,(0,m.ob)(a,b).map(a=>({path:a.path,id:a.header.id,cwd:a.header.cwd,timestamp:a.header.timestamp,parentSessionId:a.parentSessionId,runId:a.runId,runIndex:a.runIndex,...a.agent?{agent:a.agent}:{}}))))){let c=(0,f.normalize)(b.path);if(y.has(c)||z.has(b.id))continue;y.add(c),z.add(b.id);let d=v.get(c),e=w.get(b.id);if(d&&d.id!==b.id||e&&(0,f.normalize)(e.path)!==c)continue;let g=d??e;if(g){g.subagent={parentSessionId:b.parentSessionId,runId:b.runId,runIndex:b.runIndex,...b.agent?{agent:b.agent}:{}},g.readOnly=!0,C.push({parent:g,depth:a.depth+1});continue}s.has(c)||t.has(b.id)||(s.add(c),t.add(b.id),o.set(c,b.id),A.push({child:b}),C.push({parent:{path:b.path,id:b.id,cwd:b.cwd,created:b.timestamp,modified:b.timestamp,messageCount:0,firstMessage:"(no messages)",projectRoot:b.cwd},depth:a.depth+1}))}}let D=await Promise.all(A.map(async({child:a})=>{let b=await (0,l.KI)(a.cwd),c=a.timestamp;try{c=(0,e.statSync)(a.path).mtime.toISOString()}catch{}return x(a.id,a.path),{path:a.path,id:a.id,cwd:a.cwd,created:a.timestamp,modified:c,messageCount:0,firstMessage:"(no messages)",projectRoot:b?.projectRoot??a.cwd,...b?.isWorktree&&b.branch?{worktreeBranch:b.branch}:{},subagent:{parentSessionId:a.parentSessionId,runId:a.runId,runIndex:a.runIndex,...a.agent?{agent:a.agent}:{}},readOnly:!0}}));return g&&(0,h.If)(c,B),[...u,...D]}async function r(){let a=globalThis.__piSessionListGeneration??0;if(globalThis.__piSessionListCache&&Date.now()-globalThis.__piSessionListCache.ts<J)return globalThis.__piSessionListCache.data;if(globalThis.__piSessionListPromise&&globalThis.__piSessionListPromiseGeneration===a)return globalThis.__piSessionListPromise;let b=q().then(b=>((globalThis.__piSessionListGeneration??0)===a&&(globalThis.__piSessionListCache={data:b,ts:Date.now()}),b)).finally(()=>{globalThis.__piSessionListPromise===b&&(globalThis.__piSessionListPromise=void 0,globalThis.__piSessionListPromiseGeneration=void 0)});return globalThis.__piSessionListPromise=b,globalThis.__piSessionListPromiseGeneration=a,b}n=(p.then?(await p)():p)[0];let J=3e4;function s(){globalThis.__piSessionListGeneration=(globalThis.__piSessionListGeneration??0)+1,globalThis.__piSessionListCache=void 0}function t(){return globalThis.__piSessionPathCache||(globalThis.__piSessionPathCache=new Map),globalThis.__piSessionPathCache}function u(){return globalThis.__piPathToSessionIdCache||(globalThis.__piPathToSessionIdCache=new Map),globalThis.__piPathToSessionIdCache}async function v(a){let b=t().get(a);if(b){if((0,e.existsSync)(b))return b;y(a)}await r();let c=t().get(a)??null;return c&&!(0,e.existsSync)(c)?(y(a),null):c}async function w(a){let b=(0,f.normalize)(a),c=u().get(b);return c||(await r(),u().get(b))}function x(a,b){let c=(0,f.normalize)(b),d=t(),e=u(),g=d.get(a),h=e.get(c);g&&g!==c&&e.get(g)===a&&e.delete(g),h&&h!==a&&d.get(h)===c&&d.delete(h),d.set(a,c),e.set(c,a)}function y(a){let b=t(),c=u(),d=b.get(a);b.delete(a),d&&c.get(d)===a&&c.delete(d)}function z(a){let b=(0,e.openSync)(a,"r");try{let a=[],c=0,d=!1;for(;c<65536&&!d;){let f=Buffer.allocUnsafe(Math.min(4096,65536-c)),g=(0,e.readSync)(b,f,0,f.length,c);if(0===g)break;let h=f.subarray(0,g),i=h.indexOf(10);a.push(-1===i?h:h.subarray(0,i)),c+=g,d=-1!==i}if(!d&&c>=65536)return null;let f=Buffer.concat(a).toString("utf8").trimEnd();if(!f)return null;try{let a=JSON.parse(f);return"session"===a.type?a:null}catch{return null}}finally{(0,e.closeSync)(b)}}function A(a){return(0,n.kW)(a).getEntries()}function B(a){let b=a.liveSession;return b?.isAlive()&&b.inner?.sessionManager?b.inner.sessionManager:(a.openFromDisk??(a=>{let b=(0,n.kW)(a);return{getEntries:()=>b.getEntries(),getLeafId:()=>b.getLeafId(),getTree:()=>b.getTree(),getHeader:()=>b.getHeader(),getSessionName:()=>b.getSessionName()}}))(a.filePath)}function C(a,b={}){let c=a.getEntries(),d=D(c,a.getLeafId()),e=function(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||"string"==typeof a.label&&a.label.length>0)&&b.add(a),a.children))e.push(f)}let f=(a,b)=>({...a,children:[],...b?.length?{compressedEntryIds:b}:{}}),g=a.map(a=>f(a)),h=a.map((a,b)=>({source:a,projected:g[b],depth:1})),i=(a,c)=>{let d=[{node:a,compressedEntryIds:[]}],e=new Set;for(;d.length>0;){let{node:a,compressedEntryIds:g}=d.pop();if(!e.has(a)){e.add(a),b.has(a)&&c.children.push(f(a,g));for(let c=a.children.length-1;c>=0;c--)d.push({node:a.children[c],compressedEntryIds:b.has(a)?[]:[...g,a.entry.id]})}}};for(;h.length>0;){let{source:a,projected:c,depth:d}=h.pop();for(let e of a.children){let a=e;if(d>=200){i(a,c);continue}let g=[];for(;!b.has(a)&&1===a.children.length;)g.push(a.entry.id),a=a.children[0];if(!b.has(a))continue;let j=f(a,g);c.children.push(j),h.push({source:a,projected:j,depth:d+1})}}return g}(function(a){let b=[],c=[];for(let d=a.length-1;d>=0;d--)c.push({node:a[d],out:b});for(;c.length>0;){let{node:a,out:b}=c.pop();if("label"===a.entry.type){for(let d=a.children.length-1;d>=0;d--)c.push({node:a.children[d],out:b});continue}let d=[];for(let b=a.children.length-1;b>=0;b--)c.push({node:a.children[b],out:d});b.push({...a,children:d})}return b}(a.getTree())),f=F(c,d,b);return{entries:c,leafId:d,tree:e,context:f,header:a.getHeader(),sessionName:a.getSessionName()}}function D(a,b){if(null==b)return null;let c=new Map(a.map(a=>[a.id,a])),d=c.get(b);if(!d)return b;for(;d?.type==="label";){if(!d.parentId)return null;d=c.get(d.parentId)}return d?.id??null}function E(a,b){if(null===b)return[];let c=new Map,d=null;for(let b of a)b?.id&&(c.set(b.id,b),d=b.id);let e=void 0!==b?b:d,f=[],g=new Set;for(;e&&!g.has(e);){g.add(e);let a=c.get(e);if(!a)break;f.unshift(a),e=a.parentId??null}return f}function F(a,b,c={}){let d=E(a,b),e=function(a){let b,c,d;for(let e of a)if("thinking_level_change"===e.type&&"string"==typeof e.thinkingLevel&&(b=e.thinkingLevel),"model_change"===e.type&&e.provider&&e.modelId&&(c={provider:e.provider,modelId:e.modelId,id:e.modelId}),"message"===e.type){let a=e.message;a?.role==="assistant"&&"string"==typeof a.provider&&a.provider&&"string"==typeof a.model&&a.model&&(d={provider:a.provider,modelId:a.model,id:a.model})}return{thinkingLevel:b,model:c??d}}(d),f=E(a,b),h=[],l=[],m=new Map,n="off";for(let a of d)"thinking_level_change"===a.type&&"string"==typeof a.thinkingLevel&&(n=a.thinkingLevel),m.set(a.id,n);for(let a of f){let b=function(a,b){switch(a.type){case"message":{let c=(0,i.B)(a.message);if(b.deferToolResultImages&&(c=function(a){if("toolResult"!==a.role)return a;let b=0,c=0,d=new Set,e=a.content.filter(a=>{let e=function(a){let b,c;if(!H(a)||"image"!==a.type||("string"==typeof a.data?(b=a.data,c="string"==typeof a.mimeType?a.mimeType:void 0):H(a.source)&&"base64"===a.source.type&&"string"==typeof a.source.data&&(b=a.source.data,c="string"==typeof a.source.media_type?a.source.media_type:void 0),!b))return null;let d=b.endsWith("==")?2:+!!b.endsWith("=");return{bytes:Math.max(0,Math.floor(3*b.length/4)-d),mime:c}}(a);return!e||(b+=1,c+=e.bytes,e.mime&&d.add(e.mime),!1)});if(0===b)return a;let f=d.size>0?`: ${[...d].join(", ")}`:"";return e.push({type:"text",text:`[${b} tool result image${1===b?"":"s"} omitted from initial history payload${f}, ~${c} bytes]`}),{...a,content:e}}(c),c=function(a){if("toolResult"!==a.role||!H(a.details))return a;let b=!1,c={};for(let[d,e]of Object.entries(a.details))if(d!==L){if(K.has(d)){b=!0;continue}c[d]=e}return b?{...a,details:{...c,[L]:!0}}:a}(c)),!b.deferThinking||"assistant"!==c.role)return c;return{...c,content:c.content.map(a=>(0,o.mv)(a.type)&&""!==(0,o.Ux)(a).trim()?{...a,thinking:"",deferred:!0}:a)}}case"compaction":return{role:"custom",customType:"compaction",content:a.summary,display:!0,details:{tokensBefore:a.tokensBefore,firstKeptEntryId:a.firstKeptEntryId},timestamp:G(a.timestamp)};case"branch_summary":if(!a.summary)return null;let c=a.usage;return{role:"custom",customType:"branch_summary",content:a.summary,display:!0,details:{fromId:a.fromId,details:a.details,usage:c,fromHook:a.fromHook},timestamp:G(a.timestamp)};case"custom_message":return{role:"custom",customType:a.customType,content:a.content,display:a.display,details:a.details,timestamp:G(a.timestamp)};case"custom":{if(a.customType===k.uG){let b=(0,k.QT)(a.data);if(!b)return null;return(0,k.FH)(b,G(a.timestamp))}if(a.customType===g.OE){let b=(0,g.yz)(a.data);if(!b)return null;return{role:"custom",customType:g.OE,content:b.command,display:!0,details:{ok:b.ok,result:b.result},timestamp:G(a.timestamp)}}if(a.customType!==j.cP)return null;let b=(0,j.p_)(a.data);if(!b)return null;return(0,j.iv)(b,G(a.timestamp))}default:return null}}(a,c);if(b?.role==="custom"&&b.customType===k.uG){let a=(0,k.QT)(b.details),c=a?.messageEntryId?l.indexOf(a.messageEntryId):-1,d=c>=0?h[c]:void 0;if(a&&d?.role==="user"){h[c]={...d,binaryBlocks:[...d.binaryBlocks??[],a]};continue}}b&&(h.push("assistant"===b.role?{...b,thinkingLevel:m.get(a.id)??n}:b),l.push(a.id))}return{messages:c.deferToolResultImages?h.map(I):h,entryIds:l,thinkingLevel:e.thinkingLevel??"off",model:e.model??null}}function G(a){let b=Date.parse(a);return Number.isNaN(b)?void 0:b}function H(a){return"object"==typeof a&&null!==a&&!Array.isArray(a)}function I(a){return"user"===a.role&&Array.isArray(a.content)&&a.binaryBlocks?.some(a=>"image"===a.kind)?{...a,content:a.content.filter(a=>"image"!==a.type)}:a}let K=new Set(["diff","patch","diffData","readSeekValue"]),L="deferredHeavy";d()}catch(a){d(a)}})},50593:(a,b,c)=>{"use strict";function d(a){try{return decodeURIComponent(a)}catch{return a}}function e(a){return a.replace(/\\/g,"/")}c.d(b,{Nw:()=>e,ex:()=>d})},50955:(a,b,c)=>{"use strict";c.d(b,{ku:()=>o,ob:()=>n,uq:()=>l});var d=c(29021),e=c(33873);let f=/^[0-9a-f]{8}$/i,g=/^run-(\d+)$/,h=/^async-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function i(a){return"object"==typeof a&&null!==a&&!Array.isArray(a)}function j(a,b){try{let c=(0,d.lstatSync)(a);if(!c.isFile()||c.isSymbolicLink()||!a.endsWith(".jsonl"))return null;let f=(0,d.realpathSync)(a),g=(0,d.realpathSync)(b),h=(0,e.relative)(g,f);if(!h||h.startsWith("..")||h.includes("/../")||h.includes("\\..\\"))return null;let i=g;for(let a of h.split(/[\\/]/))if(i=(0,e.join)(i,a),(0,d.lstatSync)(i).isSymbolicLink())return null;return f}catch{return null}}function k(a){let b=-1;try{b=(0,d.openSync)(a,"r");let c=[],e=0,f=!1;for(;e<65536&&!f;){let a=Buffer.allocUnsafe(Math.min(4096,65536-e)),g=(0,d.readSync)(b,a,0,a.length,e);if(!g)break;let h=a.subarray(0,g),i=h.indexOf(10);c.push(i>=0?h.subarray(0,i):h),e+=g,f=i>=0}if(!f&&e>=65536)return null;let g=Buffer.concat(c).toString("utf8").replace(/\r$/,""),h=JSON.parse(g);if(!i(h)||"session"!==h.type||"string"!=typeof h.id||!h.id||"string"!=typeof h.cwd||"string"!=typeof h.timestamp)return null;return h}catch{return null}finally{b>=0&&(0,d.closeSync)(b)}}function l(a,b,c){let f=0;for(let g of[...a].sort((a,b)=>b.path.length-a.path.length))try{if(!function(a,b,c){try{return j(a,b)===(0,d.realpathSync)(a)&&k(a)?.id===c}catch{return!1}}(g.path,b,g.header.id)){f++;continue}let a=(0,d.realpathSync)(g.path),h=(0,d.realpathSync)(b),i=(0,e.relative)(h,a);if(!i||i.startsWith("..")||i.includes("/../")||i.includes("\\..\\")){f++;continue}(0,d.unlinkSync)(g.path),c(g.header.id);let l=(0,e.dirname)(g.path);for(let a=0;a<4;a++){try{let a=(0,d.lstatSync)(l);if(!a.isDirectory()||a.isSymbolicLink())break;(0,d.rmdirSync)(l)}catch{break}l=(0,e.dirname)(l)}}catch{f++}return f}function m(a,b){let c;try{c=JSON.parse(a)}catch{return}if(!i(c)||"message"!==c.type||!i(c.message)||"toolResult"!==c.message.role||"subagent"!==c.message.toolName||!i(c.message.details)||!Array.isArray(c.message.details.results))return;let d=c.message.details;for(let a of d.results)i(a)&&"string"==typeof a.sessionFile&&b.push({path:a.sessionFile,runId:"string"==typeof d.runId?d.runId:void 0,agent:"string"==typeof a.agent?a.agent:"string"==typeof d.agent?d.agent:void 0})}function n(a,b){let c=a.endsWith(".jsonl")?a.slice(0,-6):"";if(!c)return[];let i=new Set,l=new Set,n=[];for(let o of[...function(a){let b=[],c=-1;try{c=(0,d.openSync)(a,"r");let e="",f=0;for(;f<2097152&&b.length<512;){let a=Buffer.allocUnsafe(Math.min(65536,2097152-f)),g=(0,d.readSync)(c,a,0,a.length,f);if(!g)break;f+=g;let h=(e+=a.subarray(0,g).toString("utf8")).split(/\r?\n/);for(let a of(e=h.pop()??"",h))if(!(a.length>131072)&&(m(a,b),b.length>=512))break}e.length<=131072&&b.length<512&&m(e,b)}catch{}finally{c>=0&&(0,d.closeSync)(c)}return b}(a),...(function(a){let b=a.endsWith(".jsonl")?a.slice(0,-6):"",c=[];if(!b)return c;try{for(let a of(0,d.readdirSync)(b,{withFileTypes:!0})){if(!a.isDirectory()||a.isSymbolicLink()||!f.test(a.name))continue;let h=(0,e.join)(b,a.name);for(let a of(0,d.readdirSync)(h,{withFileTypes:!0}))if(!(!a.isDirectory()||a.isSymbolicLink())&&g.test(a.name)&&(c.push((0,e.join)(h,a.name,"session.jsonl")),c.length>=2048))return c}for(let a of(0,d.readdirSync)(b,{withFileTypes:!0})){if(!a.isDirectory()||a.isSymbolicLink()||!h.test(a.name))continue;let f=(0,e.join)(b,a.name);for(let a of(0,d.readdirSync)(f,{withFileTypes:!0}).filter(a=>a.isFile()&&!a.isSymbolicLink()&&a.name.endsWith(".jsonl")).map(a=>a.name).sort())if(c.push((0,e.join)(f,a)),c.length>=2048)return c}}catch{}return c})(a).map(a=>({path:a}))]){if(n.length>=256)break;let a=j((0,e.resolve)(o.path),c);if(!a||!function(a,b){let c=(0,e.relative)((0,e.resolve)(b),(0,e.resolve)(a)).split(/[\\/]/);return!!(3===c.length&&f.test(c[0])&&g.test(c[1]))&&"session.jsonl"===c[2]||2===c.length&&h.test(c[0])&&c[1].endsWith(".jsonl")}(a,c)||i.has(a))continue;let d=(0,e.relative)((0,e.resolve)(c),(0,e.resolve)(a)).split(/[\\/]/),m=2===d.length&&h.test(d[0]),p=m?0:function(a){let b=g.exec((0,e.basename)((0,e.dirname)(a)));return b?Number(b[1]):null}(a);if(null===p||p<0)continue;let q=k(a);if(!q||l.has(q.id)||q.id===b)continue;let r=m?d[0].slice(6):o.runId??(0,e.basename)((0,e.dirname)((0,e.dirname)(a)));i.add(a),l.add(q.id),n.push({path:a,header:q,runIndex:p,parentSessionId:b,runId:r,agent:o.agent})}return n}function o(a,b){let c=[],d=new Set([(0,e.resolve)(a)]),f=new Set([b]),g=[{file:a,id:b,depth:0}];for(;g.length&&c.length<256;){let a=g.shift();if(!(a.depth>=16))for(let b of n(a.file,a.id))d.has(b.path)||f.has(b.header.id)||(d.add(b.path),f.add(b.header.id),c.push(b),g.push({file:b.path,id:b.header.id,depth:a.depth+1}))}return c}},60396:(a,b,c)=>{"use strict";c.d(b,{$M:()=>f,CZ:()=>h,Mc:()=>g,pA:()=>i});var d=c(62228),e=c(86697);function f(a=process.env){let b=a.PI_CODING_AGENT_DIR?.trim();if(b)return"~"===b?(0,d.homedir)():b.startsWith("~/")||b.startsWith("~\\")?(0,e.join)((0,d.homedir)(),b.slice(2)):b;return(0,e.join)((0,d.homedir)(),".pi","agent")}function g(a=process.env){return(0,e.join)(f(a),"models.json")}function h(a=process.env){return(0,e.join)(f(a),"auth.json")}function i(a=process.env){return(0,e.join)(f(a),"settings.json")}},65107:(a,b,c)=>{"use strict";c.d(b,{$9:()=>j,R3:()=>i,ek:()=>h});var d=c(89477),e=c(86697),f=c(716);function g(a){return`${a}.leaf.json`}function h(a){let b=g(a);if(!(0,d.existsSync)(b))return null;try{let a=JSON.parse((0,d.readFileSync)(b,"utf8"));if(!a||"object"!=typeof a)return null;let c=a.leafId;return"string"==typeof c&&c?c:null}catch{return null}}function i(a,b){let c=g(a),h=(0,e.dirname)(c);(0,d.existsSync)(h)||(0,d.mkdirSync)(h,{recursive:!0});let i=JSON.stringify({version:1,leafId:b},null,2),j=(0,e.join)(h,`.leaf-${process.pid}-${(0,f.randomUUID)()}.tmp`);try{(0,d.writeFileSync)(j,i,{encoding:"utf8",flag:"wx"}),(0,d.renameSync)(j,c)}catch(a){try{(0,d.existsSync)(j)&&(0,d.unlinkSync)(j)}catch{}throw a}}function j(a){try{let b=g(a);(0,d.existsSync)(b)&&(0,d.unlinkSync)(b)}catch{}}},78335:()=>{},85664:(a,b,c)=>{"use strict";c.d(b,{cP:()=>d,iv:()=>l,l$:()=>j,o7:()=>m,p_:()=>k,qF:()=>n});let d="pidance.activity",e=["result","warning","error","output"];class f extends Error{constructor(a){super(a),this.name="SessionActivityError"}}function g(a){return"object"==typeof a&&null!==a&&!Array.isArray(a)}function h(a){return Buffer.byteLength(a,"utf8")}function i(a,b,c){if(void 0===a)return;if("string"!=typeof a)throw new f(`${b} must be a string`);let d=a.trim();if(""!==d){if(d.length>c)throw new f(`${b} exceeds maximum length ${c}`);return d}}function j(a){var b;let c,d;if(!g(a))throw new f("activity must be a plain object");let j=void 0===a.version?1:a.version;if(1!==j)throw new f(`unsupported activity version: ${String(j)}`);if(!("string"==typeof(b=a.kind)&&e.includes(b)))throw new f(`kind must be one of: ${e.join(", ")}`);if("string"!=typeof a.title)throw new f("title must be a string");let k=a.title.trim();if(""===k)throw new f("title is required");if(k.length>200)throw new f("title exceeds maximum length 200");if("string"!=typeof a.content)throw new f("content must be a string");let l=a.content.trim();if(l.length>32768)throw new f("content exceeds maximum length 32768");let m=i(a.source,"source",200),n=i(a.requestId,"requestId",200);if(void 0!==a.metadata){if(!g(a.metadata))throw new f("metadata must be a plain object");let b=function a(b,c,d){if(null===b)return null;if("string"==typeof b){if(h(b)>1024)throw new f("metadata string exceeds 1024 bytes");return b}if("number"==typeof b){if(!Number.isFinite(b))throw new f("metadata number must be finite");return b}if("boolean"==typeof b)return b;if("bigint"==typeof b||"function"==typeof b||"symbol"==typeof b||void 0===b||"object"!=typeof b)throw new f("metadata contains non-JSON value");if(d.has(b))throw new f("metadata contains circular reference");if(c>3)throw new f("metadata exceeds max depth 3");if(Array.isArray(b)){if(b.length>32)throw new f("metadata array exceeds 32 items");d.add(b);try{return b.map(b=>a(b,c+1,d))}finally{d.delete(b)}}let e=Object.getPrototypeOf(b);if(e!==Object.prototype&&null!==e)throw new f("metadata must be a plain JSON object or array");let g=Object.keys(b);if(g.length>20)throw new f("metadata exceeds 20 keys");d.add(b);try{let e=Object.create(null);for(let i of g){if("__proto__"===i||"constructor"===i||"prototype"===i)throw new f("metadata key is not allowed");if(h(i)>64)throw new f("metadata key exceeds 64 bytes");e[i]=a(b[i],c+1,d)}return e}finally{d.delete(b)}}(a.metadata,0,new WeakSet);if(!g(b)||Array.isArray(b))throw new f("metadata must be a plain object");0===Object.keys(c=b).length&&(c=void 0)}let o={version:1,kind:a.kind,title:k,content:l};void 0!==m&&(o.source=m),void 0!==n&&(o.requestId=n),void 0!==c&&(o.metadata=c);try{d=JSON.stringify(o)}catch{throw new f("activity is not JSON-serializable")}if(h(d)>48e3)throw new f("activity exceeds maximum serialized size 48000 bytes");return o}function k(a){try{return j(a)}catch{return null}}function l(a,b){let c={role:"custom",customType:d,content:a.title,display:!0,details:a};return void 0!==b&&(c.timestamp=b),c}function m(a){return"custom"===a.type&&a.customType===d&&null!==k(a.data)}function n(a){if("customType"in a&&void 0!==a.customType)throw new f("customType is not allowed on append_activity");let b=a.activity;if(void 0!==b){if(!g(b))throw new f("activity must be a plain object");if("customType"in b&&void 0!==b.customType)throw new f("customType is not allowed on append_activity");return j(b)}let c={...a};return delete c.type,j(c)}},95237:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{G1:()=>j,Qu:()=>k,i5:()=>m,iR:()=>e.CURRENT_SESSION_VERSION,kW:()=>l,kb:()=>i});var e=c(75430),f=c(89477),g=c(65107),h=a([e]);function i(a){let b=a.getSessionFile();!b||((0,f.existsSync)(b)||a._rewriteFile?.(),(0,f.existsSync)(b)&&(a.flushed=!0))}function j(a,b){let c=e.SessionManager.open(a,b),d=(0,g.ek)(a);if(d&&c.getEntry(d)){if(c.getLeafId()!==d)try{c.branch(d)}catch{(0,g.$9)(a)}}else d&&(0,g.$9)(a);return c}function k(a,b){return e.SessionManager.create(a,b)}function l(a,b){var c;return c=j(a,b),{getEntries:()=>c.getEntries(),getLeafId:()=>c.getLeafId(),getTree:()=>c.getTree(),getHeader:()=>c.getHeader(),getSessionName:()=>c.getSessionName(),getSessionId:()=>c.getSessionId(),getSessionFile:()=>c.getSessionFile(),getCwd:()=>c.getCwd(),getEntry:a=>c.getEntry(a),getBranch:a=>void 0===a?c.getBranch():c.getBranch(a),buildSessionContext:()=>c.buildSessionContext(),appendSessionInfo:a=>c.appendSessionInfo(a),appendCustomEntry:(a,b)=>c.appendCustomEntry(a,b),appendModelChange:(a,b)=>c.appendModelChange(a,b),branch:a=>c.branch(a),createBranchedSession:a=>c.createBranchedSession(a),getSessionDir:()=>c.getSessionDir(),getLastEntryId:()=>(function(a){let b=a.getEntries();for(let a=b.length-1;a>=0;a--){let c=b[a];if(c&&"object"==typeof c&&"id"in c&&"string"==typeof c.id)return c.id}return null})(c)}}function m(a,b){let c=j(a),d=c.getHeader();d&&"session"===d.type&&(b?d.parentSession=b:delete d.parentSession,c._rewriteFile?.(),(0,f.existsSync)(a)&&(c.flushed=!0))}e=(h.then?(await h)():h)[0],d()}catch(a){d(a)}})},96487:()=>{}};
1
+ exports.id=5582,exports.ids=[5582],exports.modules={12039:(a,b,c)=>{"use strict";c.d(b,{B:()=>f});var d=c(31514);function e(a){return"object"==typeof a&&null!==a&&!Array.isArray(a)}function f(a){if("assistant"!==a.role)return a;let b=a.content;if(!Array.isArray(b))return a;let c=b.map(a=>{let b=function(a){if(!e(a)||"toolCall"!==a.type)return null;let b={type:"toolCall",toolCallId:"string"==typeof a.toolCallId?a.toolCallId:"string"==typeof a.id?a.id:"",toolName:"string"==typeof a.toolName?a.toolName:"string"==typeof a.name?a.name:"",input:"object"!=typeof a.input||null===a.input||Array.isArray(a.input)?"object"!=typeof a.arguments||null===a.arguments||Array.isArray(a.arguments)?{}:a.arguments:a.input};return Array.isArray(a.renderedCallLines)&&a.renderedCallLines.every(a=>"string"==typeof a)&&(b.renderedCallLines=[...a.renderedCallLines]),b}(a);return b||(e(a)&&(0,d.mv)(a.type)?(0,d.Xb)(a):a)});return{...a,content:c}}},13737:(a,b,c)=>{"use strict";c.d(b,{FH:()=>j,Ln:()=>g,PB:()=>k,QT:()=>i,uG:()=>d});let d="pidance.binary",e=/^[a-z0-9][a-z0-9!#$&^_.+-]*\/[a-z0-9][a-z0-9!#$&^_.+-]*$/i;function f(a){let b=a.toLowerCase();return b.startsWith("image/")?"image":b.startsWith("audio/")?"audio":b.startsWith("video/")?"video":"file"}function g(a){if("string"!=typeof a)return null;let b=a.trim().toLowerCase();return e.test(b)?b:null}function h(a){if("string"!=typeof a)return null;let b=a.replace(/[\\/\0]/g,"_").trim();return!b||b.length>180?null:b}function i(a){if(!a||"object"!=typeof a||Array.isArray(a)||"binary"!==a.type||1!==a.version||"string"!=typeof a.path)return null;let b=a.path.trim();if(!b||b.length>4096)return null;let c=h(a.name),d=g(a.mimeType);if(!c||!d||"number"!=typeof a.size||!Number.isSafeInteger(a.size)||a.size<0)return null;let e=a.kind;if("image"!==e&&"audio"!==e&&"video"!==e&&"file"!==e||e!==f(d))return null;let i=void 0===a.previewPath?void 0:"string"==typeof a.previewPath&&a.previewPath.trim().length<=4096?a.previewPath.trim()||void 0:null;if(null===i)return null;let j=void 0===a.messageEntryId?void 0:"string"==typeof a.messageEntryId&&a.messageEntryId.trim()?a.messageEntryId.trim():null;return null===j?null:{type:"binary",version:1,kind:e,path:b,name:c,mimeType:d,size:a.size,...i?{previewPath:i}:{},...j?{messageEntryId:j}:{}}}function j(a,b){let c={role:"custom",customType:d,content:a.name,display:!0,details:a};return void 0!==b&&(c.timestamp=b),c}function k(a,b){let c=g(a.mimeType)??"application/octet-stream",d=h(a.name)??"file",e=a.path.trim(),i=Number.isSafeInteger(a.size)&&a.size>=0?a.size:0,j=a.previewPath?.trim()||void 0;return{type:"binary",version:1,kind:f(c),path:e,name:d,mimeType:c,size:i,...j?{previewPath:j}:{},...b?{messageEntryId:b}:{}}}},13995:(a,b,c)=>{"use strict";let d;c.d(b,{If:()=>o,Jz:()=>l,O:()=>q,iw:()=>m});var e=c(4984),f=c(29021),g=c(79748),h=c(33873),i=c(60396);function j(){return(0,h.join)((0,i.$M)(),"pidance-session-cache.json")}async function k(a){try{let b=await (0,g.stat)(a);return{path:a,mtimeMs:b.mtimeMs,size:b.size}}catch{return null}}async function l(a=(0,h.join)((0,i.$M)(),"sessions")){let b=[];try{b=(await (0,g.readdir)(a,{withFileTypes:!0})).filter(a=>a.isDirectory()).map(b=>(0,h.join)(a,b.name))}catch{return[]}let c=[],d=[];for(let a of b)d.push((async()=>{try{for(let b of(await (0,g.readdir)(a)))b.endsWith(".jsonl")&&c.push((0,h.join)(a,b))}catch{}})());return await Promise.all(d),(await Promise.all(c.map(a=>k(a)))).filter(a=>null!==a)}function m(a=j()){try{let b=(0,f.readFileSync)(a,"utf8"),c=JSON.parse(b);if(!c||2!==c.version||!c.sessions||"object"!=typeof c.sessions)return null;return{version:2,sessions:c.sessions,discovery:c.discovery&&"object"==typeof c.discovery?c.discovery:{}}}catch{return null}}let n=!1;function o(a,b,c=j()){n=!0,d||(d=setTimeout(()=>{if(d=void 0,!n)return;n=!1;let e={version:2,sessions:Object.fromEntries(a),discovery:Object.fromEntries(b)},g=`${c}.tmp`;try{(0,f.writeFileSync)(g,JSON.stringify(e),"utf8"),(0,f.renameSync)(g,c)}catch{try{(0,f.existsSync)(g)&&(0,f.renameSync)(g,c)}catch{}}},1500))}function p(a){return"object"==typeof a&&null!==a&&"string"==typeof a.role&&"content"in a}async function q(a,b){try{let c,d,g=(0,e.createInterface)({input:(0,f.createReadStream)(a,{encoding:"utf8"}),crlfDelay:1/0}),h=null,i=0,j="";for await(let a of g){let b;if(!a.trim())continue;try{b=JSON.parse(a)}catch{continue}if(!h){if("session"!==b.type)return null;h=b;continue}if("session_info"===b.type){let a=b.name;"string"==typeof a&&a.trim()&&(c=a.trim());continue}if("message"!==b.type)continue;i++;let e=function(a){let b=a.message;if(!p(b)||"user"!==b.role)return;let c=b.timestamp;if("number"==typeof c)return c;let d=new Date(a.timestamp??"").getTime();return Number.isNaN(d)?void 0:d}(b);"number"==typeof e&&(d=Math.max(d??0,e));let f=b.message;if(!p(f)||"user"!==f.role&&"assistant"!==f.role)continue;let g=function(a){let b=a.content;return"string"==typeof b?b:Array.isArray(b)?b.filter(a=>!!(a&&"text"===a.type&&"string"==typeof a.text)).map(a=>a.text).join(" "):""}(f);g&&(j||"user"!==f.role||(j=g))}if(!h)return null;let k="string"==typeof h.timestamp?new Date(h.timestamp).getTime():NaN,l=new Date("number"==typeof d&&d>0?d:Number.isNaN(k)?b.mtimeMs:k);return{id:"string"==typeof h.id?h.id:"",cwd:"string"==typeof h.cwd?h.cwd:"",name:c,created:h.timestamp,modified:l.toISOString(),messageCount:i,firstMessage:j||"(no messages)",parentSessionPath:"string"==typeof h.parentSession?h.parentSession:void 0}}catch{return null}}},15461:(a,b,c)=>{"use strict";c.d(b,{OE:()=>d,fc:()=>e,yz:()=>f});let d="pidance.command";function e(a){return{command:"string"==typeof a.command?a.command.trim():"",ok:!1!==a.ok,result:"string"==typeof a.result&&""!==a.result.trim()?a.result.trim():void 0,version:1}}function f(a){return a&&"object"==typeof a?1!==a.version||"string"!=typeof a.command||""===a.command.trim()?null:{command:a.command,ok:!1!==a.ok,result:"string"==typeof a.result?a.result:void 0,version:1}:null}},24923:(a,b,c)=>{"use strict";c.d(b,{IL:()=>p,KI:()=>l,P9:()=>n,l:()=>o});var d=c(79646),e=c(29021),f=c(33873),g=c(28354),h=c(25252);let i=(0,g.promisify)(d.execFile);function j(){globalThis.__piProjectCache?.clear()}async function k(a,b){let{stdout:c}=await i("git",["-C",a,...b],{timeout:1e4,maxBuffer:1048576,env:{...process.env,LC_ALL:"C"}});return c.trim()}async function l(a){let b,c=(globalThis.__piProjectCache||(globalThis.__piProjectCache=new Map),globalThis.__piProjectCache),d=c.get(a);if(d&&d.expiresAt>Date.now())return d.info;try{if(!(0,e.existsSync)(a))return b=function(a){let b=(0,f.dirname)(a);if(!b.endsWith("-worktrees"))return null;let c=b.slice(0,-10);return c&&(0,e.existsSync)((0,f.join)(c,".git"))?{projectRoot:c,branch:(0,f.basename)(a),isWorktree:!0,isTopLevel:!0}:null}(a)??{projectRoot:a,branch:null,isWorktree:!1,isTopLevel:!1},c.set(a,{info:b,expiresAt:Date.now()+6e4}),b;let[d,g,h,i]=(await k(a,["rev-parse","--path-format=absolute","--git-common-dir","--git-dir","--show-toplevel","--abbrev-ref","HEAD"])).split("\n").map(a=>a.trim()),j=a;try{j=(0,e.realpathSync)(a)}catch{}let l=h===j,m=g!==d&&l;b={projectRoot:m?(0,f.dirname)(d):a,branch:i&&"HEAD"!==i?i:null,isWorktree:m,isTopLevel:l}}catch{b={projectRoot:a,branch:null,isWorktree:!1,isTopLevel:!1}}return c.set(a,{info:b,expiresAt:Date.now()+6e4}),b}async function m(a){let b=await k(a,["rev-parse","--path-format=absolute","--git-common-dir"]);return(0,f.dirname)(b)}async function n(a){let b=await k(a,["worktree","list","--porcelain"]),c=[],d=null,f=()=>{d?.path&&!d.prunable&&(0,e.existsSync)(d.path)&&c.push({path:d.path,branch:d.branch??null,isMain:0===c.length}),d=null};for(let a of b.split("\n"))a.startsWith("worktree ")?(f(),d={path:a.slice(9).trim()}):a.startsWith("branch ")&&d?d.branch=a.slice(7).trim().replace(/^refs\/heads\//,""):a.startsWith("prunable")&&d?d.prunable=!0:""===a.trim()&&f();return f(),c}async function o(a,b){let c=b.trim();if(!c)throw Error("Branch name is required");let d=c.replace(/[\/\\:*?"<>|\s]+/g,"-").replace(/^-+|-+$/g,"");if(!d)throw Error(`Invalid branch name: ${b}`);let g=await m(a),i=`${(0,f.resolve)(g)}-worktrees`,l=(0,f.join)(i,d);if((0,e.existsSync)(l))throw Error(`Directory already exists: ${l}`);(0,e.mkdirSync)(i,{recursive:!0});let n=!1;try{await k(g,["rev-parse","--verify","--quiet",`refs/heads/${c}`]),n=!0}catch{n=!1}try{n?await k(g,["worktree","add","--",l,c]):await k(g,["worktree","add","-b",c,"--",l])}catch(a){throw Error(q(a))}return(0,h.wz)(l),j(),{path:l,branch:c}}async function p(a,b,c=!1){let d=(await n(a)).find(a=>a.path===b);if(!d)throw Error(`Not a worktree of this repository: ${b}`);if(d.isMain)throw Error("Cannot remove the main worktree");try{await k(a,["worktree","remove",...c?["--force"]:[],b])}catch(a){throw Error(q(a))}j()}function q(a){let b=a.stderr;return"string"==typeof b&&b.trim()?b.trim():a instanceof Error?a.message:String(a)}},25252:(a,b,c)=>{"use strict";c.d(b,{HM:()=>e,wz:()=>f});var d=c(50593);function e(){return globalThis.__piAdditionalAllowedRoots||(globalThis.__piAdditionalAllowedRoots=new Set),globalThis.__piAdditionalAllowedRoots}function f(a){if(!a)return;let b=(0,d.Nw)(a);e().add(b),globalThis.__piAllowedRootsCache?.roots.add(b)}},31514:(a,b,c)=>{"use strict";function d(a){for(let b of[a.thinking,a.text,a.reasoning])if("string"==typeof b&&b.length>0)return b;return""}function e(a){return"thinking"===a||"reasoning"===a||"redacted_thinking"===a}function f(a){let b={...a,type:"thinking",thinking:d(a)};return!0===a.deferred&&(b.deferred=!0),b}c.d(b,{Ux:()=>d,Xb:()=>f,mv:()=>e})},40402:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{BR:()=>y,CM:()=>D,DK:()=>A,O8:()=>x,Uv:()=>F,Zx:()=>B,dQ:()=>r,eP:()=>z,jK:()=>C,mD:()=>s,os:()=>v,tY:()=>E,u1:()=>w});var e=c(29021),f=c(33873),g=c(15461),h=c(13995),i=c(12039),j=c(85664),k=c(13737),l=c(24923),m=c(50955);c(60396);var n=c(95237),o=c(31514),p=a([n]);async function q(){let a=await (0,h.Jz)(),b=(0,h.iw)(),c=new Map;if(b)for(let[a,d]of Object.entries(b.sessions))c.set(a,d);let d=a.filter(a=>{let b=c.get(a.path);return!b||b.m!==a.mtimeMs||b.s!==a.size}),g=d.length>0,i=new Map;for(let a of(await Promise.all(d.map(async a=>{let b=await (0,h.O)(a.path,a);b&&i.set(a.path,b)})),d)){let b=i.get(a.path);if(!b){c.delete(a.path);continue}c.set(a.path,{m:a.mtimeMs,s:a.size,i:b})}let j=new Set(a.map(a=>a.path)),k=0;for(let a of[...c.keys()])!j.has(a)&&(c.delete(a),k++);k>0&&(g=!0);let n=[...c.entries()].map(([a,b])=>({path:a,...b.i})).filter(a=>!!(a&&a.id)),o=new Map,p=new Map;for(let a of n){let b=(0,f.normalize)(a.path);o.has(b)||p.has(a.id)||(o.set(b,a.id),p.set(a.id,b))}let q=[...new Set(n.map(a=>a.cwd).filter(Boolean))],r=new Map;await Promise.all(q.map(async a=>{r.set(a,await (0,l.KI)(a))}));let s=new Set,t=new Set,u=n.sort((a,b)=>a.modified<b.modified?1:a.modified>b.modified?-1:0).flatMap(a=>{let b=(0,f.normalize)(a.path);if(s.has(b)||t.has(a.id))return[];s.add(b),t.add(a.id),x(a.id,a.path);let c=a.cwd?r.get(a.cwd):void 0;return[{path:a.path,id:a.id,cwd:a.cwd,name:a.name,created:a.created,modified:a.modified,messageCount:a.messageCount,firstMessage:a.firstMessage||"(no messages)",parentSessionId:a.parentSessionPath?o.get((0,f.normalize)(a.parentSessionPath)):void 0,projectRoot:c?.projectRoot??a.cwd,...c?.isWorktree&&c.branch?{worktreeBranch:c.branch}:{}}]}),v=new Map(u.map(a=>[(0,f.normalize)(a.path),a])),w=new Map(u.map(a=>[a.id,a])),y=new Set,z=new Set,A=[],B=new Map;if(b)for(let[a,c]of Object.entries(b.discovery))B.set(a,c);let C=u.map(a=>({parent:a,depth:0}));for(;C.length&&z.size<256;){let a=C.shift();if(!(a.depth>=16))for(let b of function(a,b,c,d){try{let f=(0,e.statSync)(a),g=c.get(a);if(g&&g.m===f.mtimeMs&&g.s===f.size)return g.c;let h=d(a,b);return c.set(a,{m:f.mtimeMs,s:f.size,c:h}),h}catch{return c.delete(a),[]}}(a.parent.path,a.parent.id,B,(a,b)=>(g=!0,(0,m.ob)(a,b).map(a=>({path:a.path,id:a.header.id,cwd:a.header.cwd,timestamp:a.header.timestamp,parentSessionId:a.parentSessionId,runId:a.runId,runIndex:a.runIndex,...a.agent?{agent:a.agent}:{}}))))){let c=(0,f.normalize)(b.path);if(y.has(c)||z.has(b.id))continue;y.add(c),z.add(b.id);let d=v.get(c),e=w.get(b.id);if(d&&d.id!==b.id||e&&(0,f.normalize)(e.path)!==c)continue;let g=d??e;if(g){g.subagent={parentSessionId:b.parentSessionId,runId:b.runId,runIndex:b.runIndex,...b.agent?{agent:b.agent}:{}},g.readOnly=!0,C.push({parent:g,depth:a.depth+1});continue}s.has(c)||t.has(b.id)||(s.add(c),t.add(b.id),o.set(c,b.id),A.push({child:b}),C.push({parent:{path:b.path,id:b.id,cwd:b.cwd,created:b.timestamp,modified:b.timestamp,messageCount:0,firstMessage:"(no messages)",projectRoot:b.cwd},depth:a.depth+1}))}}let D=await Promise.all(A.map(async({child:a})=>{let b=await (0,l.KI)(a.cwd),c=a.timestamp;try{c=(0,e.statSync)(a.path).mtime.toISOString()}catch{}return x(a.id,a.path),{path:a.path,id:a.id,cwd:a.cwd,created:a.timestamp,modified:c,messageCount:0,firstMessage:"(no messages)",projectRoot:b?.projectRoot??a.cwd,...b?.isWorktree&&b.branch?{worktreeBranch:b.branch}:{},subagent:{parentSessionId:a.parentSessionId,runId:a.runId,runIndex:a.runIndex,...a.agent?{agent:a.agent}:{}},readOnly:!0}}));return g&&(0,h.If)(c,B),[...u,...D]}async function r(){let a=globalThis.__piSessionListGeneration??0;if(globalThis.__piSessionListCache&&Date.now()-globalThis.__piSessionListCache.ts<J)return globalThis.__piSessionListCache.data;if(globalThis.__piSessionListPromise&&globalThis.__piSessionListPromiseGeneration===a)return globalThis.__piSessionListPromise;let b=q().then(b=>((globalThis.__piSessionListGeneration??0)===a&&(globalThis.__piSessionListCache={data:b,ts:Date.now()}),b)).finally(()=>{globalThis.__piSessionListPromise===b&&(globalThis.__piSessionListPromise=void 0,globalThis.__piSessionListPromiseGeneration=void 0)});return globalThis.__piSessionListPromise=b,globalThis.__piSessionListPromiseGeneration=a,b}n=(p.then?(await p)():p)[0];let J=3e4;function s(){globalThis.__piSessionListGeneration=(globalThis.__piSessionListGeneration??0)+1,globalThis.__piSessionListCache=void 0}function t(){return globalThis.__piSessionPathCache||(globalThis.__piSessionPathCache=new Map),globalThis.__piSessionPathCache}function u(){return globalThis.__piPathToSessionIdCache||(globalThis.__piPathToSessionIdCache=new Map),globalThis.__piPathToSessionIdCache}async function v(a){let b=t().get(a);if(b){if((0,e.existsSync)(b))return b;y(a)}await r();let c=t().get(a)??null;return c&&!(0,e.existsSync)(c)?(y(a),null):c}async function w(a){let b=(0,f.normalize)(a),c=u().get(b);return c||(await r(),u().get(b))}function x(a,b){let c=(0,f.normalize)(b),d=t(),e=u(),g=d.get(a),h=e.get(c);g&&g!==c&&e.get(g)===a&&e.delete(g),h&&h!==a&&d.get(h)===c&&d.delete(h),d.set(a,c),e.set(c,a)}function y(a){let b=t(),c=u(),d=b.get(a);b.delete(a),d&&c.get(d)===a&&c.delete(d)}function z(a){let b=(0,e.openSync)(a,"r");try{let a=[],c=0,d=!1;for(;c<65536&&!d;){let f=Buffer.allocUnsafe(Math.min(4096,65536-c)),g=(0,e.readSync)(b,f,0,f.length,c);if(0===g)break;let h=f.subarray(0,g),i=h.indexOf(10);a.push(-1===i?h:h.subarray(0,i)),c+=g,d=-1!==i}if(!d&&c>=65536)return null;let f=Buffer.concat(a).toString("utf8").trimEnd();if(!f)return null;try{let a=JSON.parse(f);return"session"===a.type?a:null}catch{return null}}finally{(0,e.closeSync)(b)}}function A(a){return(0,n.kW)(a).getEntries()}function B(a){let b=a.liveSession;return b?.isAlive()&&b.inner?.sessionManager?b.inner.sessionManager:(a.openFromDisk??(a=>{let b=(0,n.kW)(a);return{getEntries:()=>b.getEntries(),getLeafId:()=>b.getLeafId(),getTree:()=>b.getTree(),getHeader:()=>b.getHeader(),getSessionName:()=>b.getSessionName()}}))(a.filePath)}function C(a,b={}){let c=a.getEntries(),d=D(c,a.getLeafId()),e=function(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||"string"==typeof a.label&&a.label.length>0)&&b.add(a),a.children))e.push(f)}let f=(a,b)=>({...a,children:[],...b?.length?{compressedEntryIds:b}:{}}),g=a.map(a=>f(a)),h=a.map((a,b)=>({source:a,projected:g[b],depth:1})),i=(a,c)=>{let d=[{node:a,compressedEntryIds:[]}],e=new Set;for(;d.length>0;){let{node:a,compressedEntryIds:g}=d.pop();if(!e.has(a)){e.add(a),b.has(a)&&c.children.push(f(a,g));for(let c=a.children.length-1;c>=0;c--)d.push({node:a.children[c],compressedEntryIds:b.has(a)?[]:[...g,a.entry.id]})}}};for(;h.length>0;){let{source:a,projected:c,depth:d}=h.pop();for(let e of a.children){let a=e;if(d>=200){i(a,c);continue}let g=[];for(;!b.has(a)&&1===a.children.length;)g.push(a.entry.id),a=a.children[0];if(!b.has(a))continue;let j=f(a,g);c.children.push(j),h.push({source:a,projected:j,depth:d+1})}}return g}(function(a){let b=[],c=[];for(let d=a.length-1;d>=0;d--)c.push({node:a[d],out:b});for(;c.length>0;){let{node:a,out:b}=c.pop();if("label"===a.entry.type){for(let d=a.children.length-1;d>=0;d--)c.push({node:a.children[d],out:b});continue}let d=[];for(let b=a.children.length-1;b>=0;b--)c.push({node:a.children[b],out:d});b.push({...a,children:d})}return b}(a.getTree())),f=F(c,d,b);return{entries:c,leafId:d,tree:e,context:f,header:a.getHeader(),sessionName:a.getSessionName()}}function D(a,b){if(null==b)return null;let c=new Map(a.map(a=>[a.id,a])),d=c.get(b);if(!d)return b;for(;d?.type==="label";){if(!d.parentId)return null;d=c.get(d.parentId)}return d?.id??null}function E(a,b){if(null===b)return[];let c=new Map,d=null;for(let b of a)b?.id&&(c.set(b.id,b),d=b.id);let e=void 0!==b?b:d,f=[],g=new Set;for(;e&&!g.has(e);){g.add(e);let a=c.get(e);if(!a)break;f.unshift(a),e=a.parentId??null}return f}function F(a,b,c={}){let d=E(a,b),e=function(a){let b,c,d;for(let e of a)if("thinking_level_change"===e.type&&"string"==typeof e.thinkingLevel&&(b=e.thinkingLevel),"model_change"===e.type&&e.provider&&e.modelId&&(c={provider:e.provider,modelId:e.modelId,id:e.modelId}),"message"===e.type){let a=e.message;a?.role==="assistant"&&"string"==typeof a.provider&&a.provider&&"string"==typeof a.model&&a.model&&(d={provider:a.provider,modelId:a.model,id:a.model})}return{thinkingLevel:b,model:c??d}}(d),f=E(a,b),h=[],l=[],m=new Map,n="off";for(let a of d)"thinking_level_change"===a.type&&"string"==typeof a.thinkingLevel&&(n=a.thinkingLevel),m.set(a.id,n);for(let a of f){let b=function(a,b){switch(a.type){case"message":{let c=(0,i.B)(a.message);if(b.deferToolResultImages&&(c=function(a){if("toolResult"!==a.role)return a;let b=0,c=0,d=new Set,e=a.content.filter(a=>{let e=function(a){let b,c;if(!H(a)||"image"!==a.type||("string"==typeof a.data?(b=a.data,c="string"==typeof a.mimeType?a.mimeType:void 0):H(a.source)&&"base64"===a.source.type&&"string"==typeof a.source.data&&(b=a.source.data,c="string"==typeof a.source.media_type?a.source.media_type:void 0),!b))return null;let d=b.endsWith("==")?2:+!!b.endsWith("=");return{bytes:Math.max(0,Math.floor(3*b.length/4)-d),mime:c}}(a);return!e||(b+=1,c+=e.bytes,e.mime&&d.add(e.mime),!1)});if(0===b)return a;let f=d.size>0?`: ${[...d].join(", ")}`:"";return e.push({type:"text",text:`[${b} tool result image${1===b?"":"s"} omitted from initial history payload${f}, ~${c} bytes]`}),{...a,content:e}}(c),c=function(a){if("toolResult"!==a.role||!H(a.details))return a;let b=!1,c={};for(let[d,e]of Object.entries(a.details))if(d!==L){if(K.has(d)){b=!0;continue}c[d]=e}return b?{...a,details:{...c,[L]:!0}}:a}(c)),!b.deferThinking||"assistant"!==c.role)return c;return{...c,content:c.content.map(a=>(0,o.mv)(a.type)&&""!==(0,o.Ux)(a).trim()?{...a,thinking:"",deferred:!0}:a)}}case"compaction":return{role:"custom",customType:"compaction",content:a.summary,display:!0,details:{tokensBefore:a.tokensBefore,firstKeptEntryId:a.firstKeptEntryId},timestamp:G(a.timestamp)};case"branch_summary":if(!a.summary)return null;let c=a.usage;return{role:"custom",customType:"branch_summary",content:a.summary,display:!0,details:{fromId:a.fromId,details:a.details,usage:c,fromHook:a.fromHook},timestamp:G(a.timestamp)};case"custom_message":return{role:"custom",customType:a.customType,content:a.content,display:a.display,details:a.details,timestamp:G(a.timestamp)};case"custom":{if(a.customType===k.uG){let b=(0,k.QT)(a.data);if(!b)return null;return(0,k.FH)(b,G(a.timestamp))}if(a.customType===g.OE){let b=(0,g.yz)(a.data);if(!b)return null;return{role:"custom",customType:g.OE,content:b.command,display:!0,details:{ok:b.ok,result:b.result},timestamp:G(a.timestamp)}}if(a.customType!==j.cP)return null;let b=(0,j.p_)(a.data);if(!b)return null;return(0,j.iv)(b,G(a.timestamp))}default:return null}}(a,c);if(b?.role==="custom"&&b.customType===k.uG){let a=(0,k.QT)(b.details),c=a?.messageEntryId?l.indexOf(a.messageEntryId):-1,d=c>=0?h[c]:void 0;if(a&&d?.role==="user"){h[c]={...d,binaryBlocks:[...d.binaryBlocks??[],a]};continue}}b&&(h.push("assistant"===b.role?{...b,thinkingLevel:m.get(a.id)??n}:b),l.push(a.id))}return{messages:c.deferToolResultImages?h.map(I):h,entryIds:l,thinkingLevel:e.thinkingLevel??"off",model:e.model??null}}function G(a){let b=Date.parse(a);return Number.isNaN(b)?void 0:b}function H(a){return"object"==typeof a&&null!==a&&!Array.isArray(a)}function I(a){return"user"===a.role&&Array.isArray(a.content)&&a.binaryBlocks?.some(a=>"image"===a.kind)?{...a,content:a.content.filter(a=>"image"!==a.type)}:a}let K=new Set(["diff","patch","diffData","readSeekValue"]),L="deferredHeavy";d()}catch(a){d(a)}})},50593:(a,b,c)=>{"use strict";function d(a){try{return decodeURIComponent(a)}catch{return a}}function e(a){return a.replace(/\\/g,"/")}c.d(b,{Nw:()=>e,ex:()=>d})},50955:(a,b,c)=>{"use strict";c.d(b,{ku:()=>o,ob:()=>n,uq:()=>l});var d=c(29021),e=c(33873);let f=/^[0-9a-f]{8}$/i,g=/^run-(\d+)$/,h=/^async-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function i(a){return"object"==typeof a&&null!==a&&!Array.isArray(a)}function j(a,b){try{let c=(0,d.lstatSync)(a);if(!c.isFile()||c.isSymbolicLink()||!a.endsWith(".jsonl"))return null;let f=(0,d.realpathSync)(a),g=(0,d.realpathSync)(b),h=(0,e.relative)(g,f);if(!h||h.startsWith("..")||h.includes("/../")||h.includes("\\..\\"))return null;let i=g;for(let a of h.split(/[\\/]/))if(i=(0,e.join)(i,a),(0,d.lstatSync)(i).isSymbolicLink())return null;return f}catch{return null}}function k(a){let b=-1;try{b=(0,d.openSync)(a,"r");let c=[],e=0,f=!1;for(;e<65536&&!f;){let a=Buffer.allocUnsafe(Math.min(4096,65536-e)),g=(0,d.readSync)(b,a,0,a.length,e);if(!g)break;let h=a.subarray(0,g),i=h.indexOf(10);c.push(i>=0?h.subarray(0,i):h),e+=g,f=i>=0}if(!f&&e>=65536)return null;let g=Buffer.concat(c).toString("utf8").replace(/\r$/,""),h=JSON.parse(g);if(!i(h)||"session"!==h.type||"string"!=typeof h.id||!h.id||"string"!=typeof h.cwd||"string"!=typeof h.timestamp)return null;return h}catch{return null}finally{b>=0&&(0,d.closeSync)(b)}}function l(a,b,c){let f=0;for(let g of[...a].sort((a,b)=>b.path.length-a.path.length))try{if(!function(a,b,c){try{return j(a,b)===(0,d.realpathSync)(a)&&k(a)?.id===c}catch{return!1}}(g.path,b,g.header.id)){f++;continue}let a=(0,d.realpathSync)(g.path),h=(0,d.realpathSync)(b),i=(0,e.relative)(h,a);if(!i||i.startsWith("..")||i.includes("/../")||i.includes("\\..\\")){f++;continue}(0,d.unlinkSync)(g.path),c(g.header.id);let l=(0,e.dirname)(g.path);for(let a=0;a<4;a++){try{let a=(0,d.lstatSync)(l);if(!a.isDirectory()||a.isSymbolicLink())break;(0,d.rmdirSync)(l)}catch{break}l=(0,e.dirname)(l)}}catch{f++}return f}function m(a,b){let c;try{c=JSON.parse(a)}catch{return}if(!i(c)||"message"!==c.type||!i(c.message)||"toolResult"!==c.message.role||"subagent"!==c.message.toolName||!i(c.message.details)||!Array.isArray(c.message.details.results))return;let d=c.message.details;for(let a of d.results)i(a)&&"string"==typeof a.sessionFile&&b.push({path:a.sessionFile,runId:"string"==typeof d.runId?d.runId:void 0,agent:"string"==typeof a.agent?a.agent:"string"==typeof d.agent?d.agent:void 0})}function n(a,b){let c=a.endsWith(".jsonl")?a.slice(0,-6):"";if(!c)return[];let i=new Set,l=new Set,n=[];for(let o of[...function(a){let b=[],c=-1;try{c=(0,d.openSync)(a,"r");let e="",f=0;for(;f<2097152&&b.length<512;){let a=Buffer.allocUnsafe(Math.min(65536,2097152-f)),g=(0,d.readSync)(c,a,0,a.length,f);if(!g)break;f+=g;let h=(e+=a.subarray(0,g).toString("utf8")).split(/\r?\n/);for(let a of(e=h.pop()??"",h))if(!(a.length>131072)&&(m(a,b),b.length>=512))break}e.length<=131072&&b.length<512&&m(e,b)}catch{}finally{c>=0&&(0,d.closeSync)(c)}return b}(a),...(function(a){let b=a.endsWith(".jsonl")?a.slice(0,-6):"",c=[];if(!b)return c;try{for(let a of(0,d.readdirSync)(b,{withFileTypes:!0})){if(!a.isDirectory()||a.isSymbolicLink()||!f.test(a.name))continue;let h=(0,e.join)(b,a.name);for(let a of(0,d.readdirSync)(h,{withFileTypes:!0}))if(!(!a.isDirectory()||a.isSymbolicLink())&&g.test(a.name)&&(c.push((0,e.join)(h,a.name,"session.jsonl")),c.length>=2048))return c}for(let a of(0,d.readdirSync)(b,{withFileTypes:!0})){if(!a.isDirectory()||a.isSymbolicLink()||!h.test(a.name))continue;let f=(0,e.join)(b,a.name);for(let a of(0,d.readdirSync)(f,{withFileTypes:!0}).filter(a=>a.isFile()&&!a.isSymbolicLink()&&a.name.endsWith(".jsonl")).map(a=>a.name).sort())if(c.push((0,e.join)(f,a)),c.length>=2048)return c}}catch{}return c})(a).map(a=>({path:a}))]){if(n.length>=256)break;let a=j((0,e.resolve)(o.path),c);if(!a||!function(a,b){let c=(0,e.relative)((0,e.resolve)(b),(0,e.resolve)(a)).split(/[\\/]/);return!!(3===c.length&&f.test(c[0])&&g.test(c[1]))&&"session.jsonl"===c[2]||2===c.length&&h.test(c[0])&&c[1].endsWith(".jsonl")}(a,c)||i.has(a))continue;let d=(0,e.relative)((0,e.resolve)(c),(0,e.resolve)(a)).split(/[\\/]/),m=2===d.length&&h.test(d[0]),p=m?0:function(a){let b=g.exec((0,e.basename)((0,e.dirname)(a)));return b?Number(b[1]):null}(a);if(null===p||p<0)continue;let q=k(a);if(!q||l.has(q.id)||q.id===b)continue;let r=m?d[0].slice(6):o.runId??(0,e.basename)((0,e.dirname)((0,e.dirname)(a)));i.add(a),l.add(q.id),n.push({path:a,header:q,runIndex:p,parentSessionId:b,runId:r,agent:o.agent})}return n}function o(a,b){let c=[],d=new Set([(0,e.resolve)(a)]),f=new Set([b]),g=[{file:a,id:b,depth:0}];for(;g.length&&c.length<256;){let a=g.shift();if(!(a.depth>=16))for(let b of n(a.file,a.id))d.has(b.path)||f.has(b.header.id)||(d.add(b.path),f.add(b.header.id),c.push(b),g.push({file:b.path,id:b.header.id,depth:a.depth+1}))}return c}},60396:(a,b,c)=>{"use strict";c.d(b,{$M:()=>f,CZ:()=>h,Mc:()=>g,pA:()=>i});var d=c(62228),e=c(86697);function f(a=process.env){let b=a.PI_CODING_AGENT_DIR?.trim();if(b)return"~"===b?(0,d.homedir)():b.startsWith("~/")||b.startsWith("~\\")?(0,e.join)((0,d.homedir)(),b.slice(2)):b;return(0,e.join)((0,d.homedir)(),".pi","agent")}function g(a=process.env){return(0,e.join)(f(a),"models.json")}function h(a=process.env){return(0,e.join)(f(a),"auth.json")}function i(a=process.env){return(0,e.join)(f(a),"settings.json")}},65107:(a,b,c)=>{"use strict";c.d(b,{$9:()=>j,R3:()=>i,ek:()=>h});var d=c(89477),e=c(86697),f=c(716);function g(a){return`${a}.leaf.json`}function h(a){let b=g(a);if(!(0,d.existsSync)(b))return null;try{let a=JSON.parse((0,d.readFileSync)(b,"utf8"));if(!a||"object"!=typeof a)return null;let c=a.leafId;return"string"==typeof c&&c?c:null}catch{return null}}function i(a,b){let c=g(a),h=(0,e.dirname)(c);(0,d.existsSync)(h)||(0,d.mkdirSync)(h,{recursive:!0});let i=JSON.stringify({version:1,leafId:b},null,2),j=(0,e.join)(h,`.leaf-${process.pid}-${(0,f.randomUUID)()}.tmp`);try{(0,d.writeFileSync)(j,i,{encoding:"utf8",flag:"wx"}),(0,d.renameSync)(j,c)}catch(a){try{(0,d.existsSync)(j)&&(0,d.unlinkSync)(j)}catch{}throw a}}function j(a){try{let b=g(a);(0,d.existsSync)(b)&&(0,d.unlinkSync)(b)}catch{}}},78335:()=>{},85664:(a,b,c)=>{"use strict";c.d(b,{cP:()=>d,iv:()=>l,l$:()=>j,o7:()=>m,p_:()=>k,qF:()=>n});let d="pidance.activity",e=["result","warning","error","output"];class f extends Error{constructor(a){super(a),this.name="SessionActivityError"}}function g(a){return"object"==typeof a&&null!==a&&!Array.isArray(a)}function h(a){return Buffer.byteLength(a,"utf8")}function i(a,b,c){if(void 0===a)return;if("string"!=typeof a)throw new f(`${b} must be a string`);let d=a.trim();if(""!==d){if(d.length>c)throw new f(`${b} exceeds maximum length ${c}`);return d}}function j(a){var b;let c,d;if(!g(a))throw new f("activity must be a plain object");let j=void 0===a.version?1:a.version;if(1!==j)throw new f(`unsupported activity version: ${String(j)}`);if(!("string"==typeof(b=a.kind)&&e.includes(b)))throw new f(`kind must be one of: ${e.join(", ")}`);if("string"!=typeof a.title)throw new f("title must be a string");let k=a.title.trim();if(""===k)throw new f("title is required");if(k.length>200)throw new f("title exceeds maximum length 200");if("string"!=typeof a.content)throw new f("content must be a string");let l=a.content.trim();if(l.length>32768)throw new f("content exceeds maximum length 32768");let m=i(a.source,"source",200),n=i(a.requestId,"requestId",200);if(void 0!==a.metadata){if(!g(a.metadata))throw new f("metadata must be a plain object");let b=function a(b,c,d){if(null===b)return null;if("string"==typeof b){if(h(b)>1024)throw new f("metadata string exceeds 1024 bytes");return b}if("number"==typeof b){if(!Number.isFinite(b))throw new f("metadata number must be finite");return b}if("boolean"==typeof b)return b;if("bigint"==typeof b||"function"==typeof b||"symbol"==typeof b||void 0===b||"object"!=typeof b)throw new f("metadata contains non-JSON value");if(d.has(b))throw new f("metadata contains circular reference");if(c>3)throw new f("metadata exceeds max depth 3");if(Array.isArray(b)){if(b.length>32)throw new f("metadata array exceeds 32 items");d.add(b);try{return b.map(b=>a(b,c+1,d))}finally{d.delete(b)}}let e=Object.getPrototypeOf(b);if(e!==Object.prototype&&null!==e)throw new f("metadata must be a plain JSON object or array");let g=Object.keys(b);if(g.length>20)throw new f("metadata exceeds 20 keys");d.add(b);try{let e=Object.create(null);for(let i of g){if("__proto__"===i||"constructor"===i||"prototype"===i)throw new f("metadata key is not allowed");if(h(i)>64)throw new f("metadata key exceeds 64 bytes");e[i]=a(b[i],c+1,d)}return e}finally{d.delete(b)}}(a.metadata,0,new WeakSet);if(!g(b)||Array.isArray(b))throw new f("metadata must be a plain object");0===Object.keys(c=b).length&&(c=void 0)}let o={version:1,kind:a.kind,title:k,content:l};void 0!==m&&(o.source=m),void 0!==n&&(o.requestId=n),void 0!==c&&(o.metadata=c);try{d=JSON.stringify(o)}catch{throw new f("activity is not JSON-serializable")}if(h(d)>48e3)throw new f("activity exceeds maximum serialized size 48000 bytes");return o}function k(a){try{return j(a)}catch{return null}}function l(a,b){let c={role:"custom",customType:d,content:a.title,display:!0,details:a};return void 0!==b&&(c.timestamp=b),c}function m(a){return"custom"===a.type&&a.customType===d&&null!==k(a.data)}function n(a){if("customType"in a&&void 0!==a.customType)throw new f("customType is not allowed on append_activity");let b=a.activity;if(void 0!==b){if(!g(b))throw new f("activity must be a plain object");if("customType"in b&&void 0!==b.customType)throw new f("customType is not allowed on append_activity");return j(b)}let c={...a};return delete c.type,j(c)}},95237:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{G1:()=>k,Qu:()=>l,i5:()=>n,iR:()=>e.CURRENT_SESSION_VERSION,kW:()=>m,kb:()=>j});var e=c(75430),f=c(89477),g=c(65107),h=a([e]);function i(a){let b="function"!=typeof a._rewriteFile?null:{rewriteFile:()=>a._rewriteFile.call(a),markFlushed:()=>{a.flushed=!0}};if(!b)throw Error("Pi SDK 未提供会话文件写入入口(_rewriteFile / flushed)。请检查 @earendil-works/pi-coding-agent 版本(当前基线 0.85.1)与 pi-session-io 适配层。");return b}function j(a){let b=a.getSessionFile();if(!b)return;let c=i(a);(0,f.existsSync)(b)||c.rewriteFile(),(0,f.existsSync)(b)&&c.markFlushed()}function k(a,b){let c=e.SessionManager.open(a,b),d=(0,g.ek)(a);if(d&&c.getEntry(d)){if(c.getLeafId()!==d)try{c.branch(d)}catch{(0,g.$9)(a)}}else d&&(0,g.$9)(a);return c}function l(a,b){return e.SessionManager.create(a,b)}function m(a,b){var c;return c=k(a,b),{getEntries:()=>c.getEntries(),getLeafId:()=>c.getLeafId(),getTree:()=>c.getTree(),getHeader:()=>c.getHeader(),getSessionName:()=>c.getSessionName(),getSessionId:()=>c.getSessionId(),getSessionFile:()=>c.getSessionFile(),getCwd:()=>c.getCwd(),getEntry:a=>c.getEntry(a),getBranch:a=>void 0===a?c.getBranch():c.getBranch(a),buildSessionContext:()=>c.buildSessionContext(),appendSessionInfo:a=>c.appendSessionInfo(a),appendCustomEntry:(a,b)=>c.appendCustomEntry(a,b),appendModelChange:(a,b)=>c.appendModelChange(a,b),branch:a=>c.branch(a),createBranchedSession:a=>c.createBranchedSession(a),getSessionDir:()=>c.getSessionDir(),getLastEntryId:()=>(function(a){let b=a.getEntries();for(let a=b.length-1;a>=0;a--){let c=b[a];if(c&&"object"==typeof c&&"id"in c&&"string"==typeof c.id)return c.id}return null})(c)}}function n(a,b){let c=k(a),d=c.getHeader();if(!d||"session"!==d.type)return;b?d.parentSession=b:delete d.parentSession;let e=i(c);e.rewriteFile(),(0,f.existsSync)(a)&&e.markFlushed()}e=(h.then?(await h)():h)[0],d()}catch(a){d(a)}})},96487:()=>{}};
@@ -3,4 +3,4 @@ new file mode 100644
3
3
  --- /dev/null
4
4
  +++ b/${a}
5
5
  @@ -0,0 +1,${d.length} @@
6
- ${e}${f}`}async function z(a,b,c){try{return await r(a,["diff","--no-color","--no-ext-diff","--unified=3","HEAD","--",...c&&c!==b?[c,b]:[b]],4*j._4)}catch{return null}}async function A(a,b,c={}){let d,e,g=await t(a);if(!g||!u(g.repositoryRoot,b))return{supported:!1};let{repositoryRoot:i,head:k}=g,n=h().resolve(b);try{d=f().lstatSync(n)}catch{return q(a,b),{supported:!1}}if(!d.isFile()||d.size>j._4)return{supported:!1};let p=m(a,b),r=o.get(p);if(!c.force&&r&&r.mtimeMs===d.mtimeMs&&r.size===d.size&&r.head===k)return r.response;let s=h().relative(i,n).split(h().sep).join("/"),w=(await v(i)).find(a=>a.path===s);if(!w)return q(a,b),{supported:!1};let{status:x}=l(w);if("deleted"===x)return q(a,b),{supported:!1};let B=f().readFileSync(n);if(B.includes(0))return{supported:!1};let C=B.toString("utf8");if("untracked"===x)e=y(s,C);else{let a=await z(i,s,w.originalPath);if(null===a){if("added"!==x)return{supported:!1};e=y(s,C)}else e=a}let D=e.includes("\n@@ ")?{supported:!0,status:x,patch:e}:{supported:!1};return o.set(p,{mtimeMs:d.mtimeMs,size:d.size,head:k,response:D}),D}},69835:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.d(b,{Gt:()=>u,Lj:()=>t,Md:()=>s,eq:()=>n,ki:()=>r,qo:()=>m,uF:()=>o,xd:()=>q});var e=c(29021),f=c(33873),g=c(55511),h=c(27910),i=c(77725),j=c(60396),k=c(80547),l=a([k]);k=(l.then?(await l)():l)[0];let s=0x1900000,t=0x6400000,u=0x20000000;function m(a=(0,j.$M)()){return(0,k.Nw)((0,f.join)(a,"pidance-attachments"))}function n(a=(0,j.$M)()){let b=m(a);return(0,e.existsSync)(b)||(0,e.mkdirSync)(b,{recursive:!0,mode:448}),(0,k.wz)(b),b}function o(a){let b=(a.replace(/\\/g,"/").split("/").pop()??"file").replace(/\0/g,"").replace(/^\.+/,"").trim()||"file";if(b.length<=180)return b;let c=b.lastIndexOf(".");if(c>0&&b.length-c<=20){let a=b.slice(c);return b.slice(0,180-a.length)+a}return b.slice(0,180)}function p(a,b=Date.now()){let c=o(a),d=new Date(b).toISOString().replace(/[:.]/g,"-"),e=(0,g.randomUUID)().slice(0,8);return`${d}_${e}_${c}`}async function q(a,b,c=(0,j.$M)(),d=u){let l=n(c),m=p(a),r=(0,f.join)(l,m),s=(0,f.join)(l,`.${m}.${(0,g.randomUUID)()}.tmp`),t=0,v=new h.Transform({transform(a,b,c){let e=Buffer.isBuffer(a)?a:Buffer.from(a);(t+=e.length)>d?c(Error(`message media exceeds ${d} bytes`)):c(null,e)}});try{await (0,i.pipeline)(h.Readable.fromWeb(b),v,(0,e.createWriteStream)(s,{flags:"wx",mode:384})),(0,e.renameSync)(s,r)}catch(a){try{(0,e.unlinkSync)(s)}catch{}throw a}return{path:(0,k.Nw)(r),name:o(a),storedName:m,size:t}}function r(a,b,c=(0,j.$M)()){let d=n(c),g=p(a),h=(0,f.join)(d,g);return(0,e.writeFileSync)(h,b,{flag:"wx",mode:384}),{path:(0,k.Nw)(h),name:o(a),storedName:g,size:b.length}}d()}catch(a){d(a)}})},80547:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.d(b,{A$:()=>r,Nw:()=>j.Nw,bk:()=>q,mc:()=>p,uK:()=>o,wz:()=>k.wz});var e=c(29021),f=c(21820),g=c(33873),h=c.n(g),i=c(60396),j=c(50593),k=c(25252),l=c(69835),m=c(40402),n=a([l,m]);[l,m]=n.then?(await n)():n;let s=/^[a-zA-Z]:[\\/]/;function o(a){return s.test(a)||a.startsWith("\\\\")||a.startsWith("//")}async function p(){let a=Date.now(),b=globalThis.__piAllowedRootsCache;if(b&&b.expiresAt>a)return b.roots;let c=await (0,m.dQ)(),d=function(a){let b=new Set;for(let c of a)!0!==c.readOnly&&c.cwd&&b.add((0,j.Nw)(c.cwd)),!0!==c.readOnly&&c.projectRoot&&b.add((0,j.Nw)(c.projectRoot));return b}(c);try{for(let a of(0,e.readdirSync)((0,f.homedir)()))/^pi-cwd-\d{8}$/.test(a)&&d.add((0,j.Nw)(h().join((0,f.homedir)(),a)))}catch{}for(let a of(0,k.HM)())d.add(a);try{d.add((0,l.qo)((0,i.$M)()))}catch{}return globalThis.__piAllowedRootsCache={roots:d,expiresAt:a+5e3},d}function q(){return!0}function r(a,b){return!0}d()}catch(a){d(a)}})}};
6
+ ${e}${f}`}async function z(a,b,c){try{return await r(a,["diff","--no-color","--no-ext-diff","--unified=3","HEAD","--",...c&&c!==b?[c,b]:[b]],4*j._4)}catch{return null}}async function A(a,b,c={}){let d,e,g=await t(a);if(!g||!u(g.repositoryRoot,b))return{supported:!1};let{repositoryRoot:i,head:k}=g,n=h().resolve(b);try{d=f().lstatSync(n)}catch{return q(a,b),{supported:!1}}if(!d.isFile()||d.size>j._4)return{supported:!1};let p=m(a,b),r=o.get(p);if(!c.force&&r&&r.mtimeMs===d.mtimeMs&&r.size===d.size&&r.head===k)return r.response;let s=h().relative(i,n).split(h().sep).join("/"),w=(await v(i)).find(a=>a.path===s);if(!w)return q(a,b),{supported:!1};let{status:x}=l(w);if("deleted"===x)return q(a,b),{supported:!1};let B=f().readFileSync(n);if(B.includes(0))return{supported:!1};let C=B.toString("utf8");if("untracked"===x)e=y(s,C);else{let a=await z(i,s,w.originalPath);if(null===a){if("added"!==x)return{supported:!1};e=y(s,C)}else e=a}let D=e.includes("\n@@ ")?{supported:!0,status:x,patch:e}:{supported:!1};return o.set(p,{mtimeMs:d.mtimeMs,size:d.size,head:k,response:D}),D}},69835:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.d(b,{$t:()=>w,Gt:()=>z,Lj:()=>y,Md:()=>x,eq:()=>n,fb:()=>u,fm:()=>v,ki:()=>r,qo:()=>m,uF:()=>o,vy:()=>t,xd:()=>q});var e=c(29021),f=c(33873),g=c(55511),h=c(27910),i=c(77725),j=c(60396),k=c(80547),l=a([k]);k=(l.then?(await l)():l)[0];let x=0x1900000,y=0x6400000,z=0x20000000;function m(a=(0,j.$M)()){return(0,k.Nw)((0,f.join)(a,"pidance-attachments"))}function n(a=(0,j.$M)()){let b=m(a);return(0,e.existsSync)(b)||(0,e.mkdirSync)(b,{recursive:!0,mode:448}),(0,k.wz)(b),b}function o(a){let b=(a.replace(/\\/g,"/").split("/").pop()??"file").replace(/\0/g,"").replace(/^\.+/,"").trim()||"file";if(b.length<=180)return b;let c=b.lastIndexOf(".");if(c>0&&b.length-c<=20){let a=b.slice(c);return b.slice(0,180-a.length)+a}return b.slice(0,180)}function p(a,b=Date.now()){let c=o(a),d=new Date(b).toISOString().replace(/[:.]/g,"-"),e=(0,g.randomUUID)().slice(0,8);return`${d}_${e}_${c}`}async function q(a,b,c=(0,j.$M)(),d=z){let l=n(c),m=p(a),r=(0,f.join)(l,m),s=(0,f.join)(l,`.${m}.${(0,g.randomUUID)()}.tmp`),t=0,u=new h.Transform({transform(a,b,c){let e=Buffer.isBuffer(a)?a:Buffer.from(a);(t+=e.length)>d?c(Error(`message media exceeds ${d} bytes`)):c(null,e)}});try{await (0,i.pipeline)(h.Readable.fromWeb(b),u,(0,e.createWriteStream)(s,{flags:"wx",mode:384})),(0,e.renameSync)(s,r)}catch(a){try{(0,e.unlinkSync)(s)}catch{}throw a}return{path:(0,k.Nw)(r),name:o(a),storedName:m,size:t}}function r(a,b,c=(0,j.$M)()){let d=n(c),g=p(a),h=(0,f.join)(d,g);return(0,e.writeFileSync)(h,b,{flag:"wx",mode:384}),{path:(0,k.Nw)(h),name:o(a),storedName:g,size:b.length}}function s(a,b,c){let d=a.trim();if(!d)return null;try{let a=(0,k.Nw)((0,e.realpathSync)(n(b))),f=(0,k.Nw)((0,e.realpathSync)(d));if(f!==a&&!f.startsWith(`${a}/`)||!(0,e.statSync)(f).isFile())return null;return c(f)}catch{return null}}function t(a,b=(0,j.$M)()){return s(a,b,a=>(0,e.statSync)(a).size)}function u(a,b=(0,j.$M)(),c=0x1900000){return s(a,b,a=>(0,e.statSync)(a).size>c?null:(0,e.readFileSync)(a).toString("base64"))}function v(a,b=(0,j.$M)()){return s(a,b,a=>{try{return(0,e.unlinkSync)(a),!0}catch{return!1}})??!1}function w(a=(0,j.$M)()){let b=[];return function a(b,c){for(let d of(()=>{try{return(0,e.readdirSync)(b,{withFileTypes:!0})}catch{return[]}})()){let g=(0,f.join)(b,d.name);if(d.isDirectory()){a(g,c);continue}if(d.isFile())try{let a=(0,e.statSync)(g);c.push({path:(0,k.Nw)(g),size:a.size,mtimeMs:a.mtimeMs})}catch{}}}(m(a),b),b}d()}catch(a){d(a)}})},80547:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.d(b,{A$:()=>r,Nw:()=>j.Nw,bk:()=>q,mc:()=>p,uK:()=>o,wz:()=>k.wz});var e=c(29021),f=c(21820),g=c(33873),h=c.n(g),i=c(60396),j=c(50593),k=c(25252),l=c(69835),m=c(40402),n=a([l,m]);[l,m]=n.then?(await n)():n;let s=/^[a-zA-Z]:[\\/]/;function o(a){return s.test(a)||a.startsWith("\\\\")||a.startsWith("//")}async function p(){let a=Date.now(),b=globalThis.__piAllowedRootsCache;if(b&&b.expiresAt>a)return b.roots;let c=await (0,m.dQ)(),d=function(a){let b=new Set;for(let c of a)!0!==c.readOnly&&c.cwd&&b.add((0,j.Nw)(c.cwd)),!0!==c.readOnly&&c.projectRoot&&b.add((0,j.Nw)(c.projectRoot));return b}(c);try{for(let a of(0,e.readdirSync)((0,f.homedir)()))/^pi-cwd-\d{8}$/.test(a)&&d.add((0,j.Nw)(h().join((0,f.homedir)(),a)))}catch{}for(let a of(0,k.HM)())d.add(a);try{d.add((0,l.qo)((0,i.$M)()))}catch{}return globalThis.__piAllowedRootsCache={roots:d,expiresAt:a+5e3},d}function q(){return!0}function r(a,b){return!0}d()}catch(a){d(a)}})}};