@code-yeongyu/senpi 2026.9.27-2 → 2026.9.27-3

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 (293) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/bundle/chunks/anthropic-messages-3FGAXYJS.js +8 -0
  3. package/dist/bundle/chunks/{app-server-command-ATWHNOOO.js → app-server-command-ZVB35UIJ.js} +1 -1
  4. package/dist/bundle/chunks/azure-openai-responses-4SUOOZZ4.js +2 -0
  5. package/dist/bundle/chunks/{chunk-KMJXSXRX.js → chunk-357I4IUU.js} +2 -2
  6. package/dist/bundle/chunks/chunk-3SIQIY57.js +8 -0
  7. package/dist/bundle/chunks/chunk-45SZOLCU.js +2 -0
  8. package/dist/bundle/chunks/{chunk-77ACEMYL.js → chunk-6J6RDMBY.js} +1 -1
  9. package/dist/bundle/chunks/{chunk-FD34HSJJ.js → chunk-C6LQNMRB.js} +1 -1
  10. package/dist/bundle/chunks/chunk-ELM77A26.js +2 -0
  11. package/dist/bundle/chunks/chunk-GZVCRV7I.js +3 -0
  12. package/dist/bundle/chunks/{chunk-TTY5BHCG.js → chunk-H2SGCPMD.js} +1 -1
  13. package/dist/bundle/chunks/chunk-KLBKUBDV.js +2 -0
  14. package/dist/bundle/chunks/chunk-L6QV7NZI.js +2 -0
  15. package/dist/bundle/chunks/{chunk-ZKZAATFM.js → chunk-LDB5UMH2.js} +2 -2
  16. package/dist/bundle/chunks/{chunk-HZAKOVHN.js → chunk-LGKKU4VM.js} +1 -1
  17. package/dist/bundle/chunks/{chunk-6Q6DGME2.js → chunk-NMDALHXH.js} +1 -1
  18. package/dist/bundle/chunks/chunk-NNILBBOH.js +18 -0
  19. package/dist/bundle/chunks/{chunk-SUQDU5KM.js → chunk-OQRUK2DK.js} +1 -1
  20. package/dist/bundle/chunks/{chunk-67BC7VZV.js → chunk-OZN2KUPR.js} +6 -6
  21. package/dist/bundle/chunks/{chunk-X3T45623.js → chunk-QK4QKRTF.js} +1 -1
  22. package/dist/bundle/chunks/{chunk-WM5FVFAP.js → chunk-QPZVJQC5.js} +1 -1
  23. package/dist/bundle/chunks/{chunk-HPY47AVX.js → chunk-QYAO24GB.js} +1 -1
  24. package/dist/bundle/chunks/{chunk-6W2DB2GC.js → chunk-RULGEHQM.js} +1 -1
  25. package/dist/bundle/chunks/{chunk-6SLQ5HFO.js → chunk-RYI6XR6Z.js} +55 -53
  26. package/dist/bundle/chunks/chunk-U3VOXCGP.js +2 -0
  27. package/dist/bundle/chunks/{chunk-LPFZGWG2.js → chunk-Y7EIVDHZ.js} +1 -1
  28. package/dist/bundle/chunks/chunk-ZIVYE5YK.js +2 -0
  29. package/dist/bundle/chunks/cli-main-RONHLFWZ.js +3 -0
  30. package/dist/bundle/chunks/google-generative-ai-ZTGKZTGU.js +2 -0
  31. package/dist/bundle/chunks/google-vertex-CCZ376YK.js +2 -0
  32. package/dist/bundle/chunks/help-fast-path-5LRG6FCG.js +2 -0
  33. package/dist/bundle/chunks/host-command-JVPGQR74.js +2 -0
  34. package/dist/bundle/chunks/host-lifecycle-R4HLXLBM.js +3 -0
  35. package/dist/bundle/chunks/host-lifecycle.js +4 -4
  36. package/dist/bundle/chunks/interactive-host-runtime-FES2G62G.js +4 -0
  37. package/dist/bundle/chunks/interactive-mode-45EP2FVL.js +2 -0
  38. package/dist/bundle/chunks/{list-tips-EBRNBPBM.js → list-tips-XXMRDHN6.js} +1 -1
  39. package/dist/bundle/chunks/{multi-session-host-CE3W6COI.js → multi-session-host-EFCMD5OT.js} +6 -6
  40. package/dist/bundle/chunks/{openai-completions-4CLXDDHJ.js → openai-completions-OP6VFNUR.js} +1 -1
  41. package/dist/bundle/chunks/openai-images-6U5FCN5S.js +2 -0
  42. package/dist/bundle/chunks/openai-responses-7PWMBGYX.js +2 -0
  43. package/dist/bundle/chunks/openrouter-images-QIKWQZUD.js +2 -0
  44. package/dist/bundle/chunks/{package-manager-cli-2PHRL2SX.js → package-manager-cli-5XJS3TYM.js} +1 -1
  45. package/dist/bundle/chunks/rotation-stream-KW7PTEC4.js +2 -0
  46. package/dist/bundle/chunks/rpc-mode-ZHYECU24.js +2 -0
  47. package/dist/bundle/chunks/session-picker-QHIYVQP4.js +2 -0
  48. package/dist/bundle/chunks/session-worker.js +245 -238
  49. package/dist/bundle/chunks/{state-store-Q5EWEAFG.js → state-store-D4GGGT3J.js} +1 -1
  50. package/dist/bundle/cli.js +1 -1
  51. package/dist/bundle/index.js +1 -1
  52. package/dist/bundle/rpc-entry.js +1 -1
  53. package/dist/cli/continue-moved.d.ts +15 -0
  54. package/dist/cli/continue-moved.d.ts.map +1 -0
  55. package/dist/cli/continue-moved.js +26 -0
  56. package/dist/cli/continue-moved.js.map +1 -0
  57. package/dist/core/agent-session-runtime.d.ts +3 -0
  58. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  59. package/dist/core/agent-session-runtime.js +43 -10
  60. package/dist/core/agent-session-runtime.js.map +1 -1
  61. package/dist/core/extensions/builtin/anthropic-subscription/session-registry-pump.d.ts.map +1 -1
  62. package/dist/core/extensions/builtin/anthropic-subscription/session-registry-pump.js +5 -1
  63. package/dist/core/extensions/builtin/anthropic-subscription/session-registry-pump.js.map +1 -1
  64. package/dist/core/extensions/builtin/anthropic-subscription/session-turn-claim.d.ts +13 -1
  65. package/dist/core/extensions/builtin/anthropic-subscription/session-turn-claim.d.ts.map +1 -1
  66. package/dist/core/extensions/builtin/anthropic-subscription/session-turn-claim.js +25 -2
  67. package/dist/core/extensions/builtin/anthropic-subscription/session-turn-claim.js.map +1 -1
  68. package/dist/core/extensions/builtin/anthropic-subscription/session-turn-types.d.ts +1 -0
  69. package/dist/core/extensions/builtin/anthropic-subscription/session-turn-types.d.ts.map +1 -1
  70. package/dist/core/extensions/builtin/anthropic-subscription/session-turn-types.js.map +1 -1
  71. package/dist/core/extensions/builtin/mcp/catalog.d.ts +3 -0
  72. package/dist/core/extensions/builtin/mcp/catalog.d.ts.map +1 -1
  73. package/dist/core/extensions/builtin/mcp/catalog.js +9 -0
  74. package/dist/core/extensions/builtin/mcp/catalog.js.map +1 -1
  75. package/dist/core/extensions/builtin/mcp/connection-types.d.ts +2 -0
  76. package/dist/core/extensions/builtin/mcp/connection-types.d.ts.map +1 -1
  77. package/dist/core/extensions/builtin/mcp/connection-types.js.map +1 -1
  78. package/dist/core/extensions/builtin/mcp/connection.d.ts +1 -1
  79. package/dist/core/extensions/builtin/mcp/connection.d.ts.map +1 -1
  80. package/dist/core/extensions/builtin/mcp/connection.js +3 -2
  81. package/dist/core/extensions/builtin/mcp/connection.js.map +1 -1
  82. package/dist/core/extensions/builtin/mcp/expose/session.d.ts +3 -0
  83. package/dist/core/extensions/builtin/mcp/expose/session.d.ts.map +1 -1
  84. package/dist/core/extensions/builtin/mcp/expose/session.js +9 -2
  85. package/dist/core/extensions/builtin/mcp/expose/session.js.map +1 -1
  86. package/dist/core/extensions/builtin/mcp/service-register.d.ts.map +1 -1
  87. package/dist/core/extensions/builtin/mcp/service-register.js +7 -1
  88. package/dist/core/extensions/builtin/mcp/service-register.js.map +1 -1
  89. package/dist/core/extensions/builtin/mcp/service-tools-changed.d.ts +18 -0
  90. package/dist/core/extensions/builtin/mcp/service-tools-changed.d.ts.map +1 -0
  91. package/dist/core/extensions/builtin/mcp/service-tools-changed.js +61 -0
  92. package/dist/core/extensions/builtin/mcp/service-tools-changed.js.map +1 -0
  93. package/dist/core/extensions/builtin/mcp/service-types.d.ts +13 -0
  94. package/dist/core/extensions/builtin/mcp/service-types.d.ts.map +1 -1
  95. package/dist/core/extensions/builtin/mcp/service-types.js.map +1 -1
  96. package/dist/core/extensions/builtin/mcp/service.d.ts.map +1 -1
  97. package/dist/core/extensions/builtin/mcp/service.js +4 -37
  98. package/dist/core/extensions/builtin/mcp/service.js.map +1 -1
  99. package/dist/core/extensions/builtin/mcp/shared-lease.js +1 -1
  100. package/dist/core/extensions/builtin/mcp/shared-lease.js.map +1 -1
  101. package/dist/core/extensions/builtin/mcp/startup-race.d.ts.map +1 -1
  102. package/dist/core/extensions/builtin/mcp/startup-race.js +11 -1
  103. package/dist/core/extensions/builtin/mcp/startup-race.js.map +1 -1
  104. package/dist/core/moved-sessions.d.ts +10 -0
  105. package/dist/core/moved-sessions.d.ts.map +1 -0
  106. package/dist/core/moved-sessions.js +84 -0
  107. package/dist/core/moved-sessions.js.map +1 -0
  108. package/dist/core/process-crash-record.d.ts +62 -0
  109. package/dist/core/process-crash-record.d.ts.map +1 -0
  110. package/dist/core/process-crash-record.js +216 -0
  111. package/dist/core/process-crash-record.js.map +1 -0
  112. package/dist/core/resume-target.d.ts +20 -0
  113. package/dist/core/resume-target.d.ts.map +1 -0
  114. package/dist/core/resume-target.js +30 -0
  115. package/dist/core/resume-target.js.map +1 -0
  116. package/dist/core/session-discovery.d.ts.map +1 -1
  117. package/dist/core/session-discovery.js +1 -0
  118. package/dist/core/session-discovery.js.map +1 -1
  119. package/dist/core/session-hold-errors.d.ts +20 -0
  120. package/dist/core/session-hold-errors.d.ts.map +1 -0
  121. package/dist/core/session-hold-errors.js +28 -0
  122. package/dist/core/session-hold-errors.js.map +1 -0
  123. package/dist/core/session-holders.d.ts +22 -0
  124. package/dist/core/session-holders.d.ts.map +1 -0
  125. package/dist/core/session-holders.js +234 -0
  126. package/dist/core/session-holders.js.map +1 -0
  127. package/dist/core/session-manager.d.ts +5 -0
  128. package/dist/core/session-manager.d.ts.map +1 -1
  129. package/dist/core/session-manager.js.map +1 -1
  130. package/dist/core/session-rebind.d.ts +7 -1
  131. package/dist/core/session-rebind.d.ts.map +1 -1
  132. package/dist/core/session-rebind.js +21 -5
  133. package/dist/core/session-rebind.js.map +1 -1
  134. package/dist/core/session-summary-index-file.d.ts.map +1 -1
  135. package/dist/core/session-summary-index-file.js +5 -2
  136. package/dist/core/session-summary-index-file.js.map +1 -1
  137. package/dist/core/session-summary.d.ts +3 -0
  138. package/dist/core/session-summary.d.ts.map +1 -1
  139. package/dist/core/session-summary.js +7 -0
  140. package/dist/core/session-summary.js.map +1 -1
  141. package/dist/legacy-dir-copy.d.ts +9 -0
  142. package/dist/legacy-dir-copy.d.ts.map +1 -0
  143. package/dist/legacy-dir-copy.js +69 -0
  144. package/dist/legacy-dir-copy.js.map +1 -0
  145. package/dist/legacy-senpi-dir-migration.d.ts.map +1 -1
  146. package/dist/legacy-senpi-dir-migration.js +64 -48
  147. package/dist/legacy-senpi-dir-migration.js.map +1 -1
  148. package/dist/main.d.ts.map +1 -1
  149. package/dist/main.js +45 -19
  150. package/dist/main.js.map +1 -1
  151. package/dist/migrations-state.d.ts +1 -1
  152. package/dist/migrations-state.d.ts.map +1 -1
  153. package/dist/migrations-state.js +5 -1
  154. package/dist/migrations-state.js.map +1 -1
  155. package/dist/migrations.d.ts.map +1 -1
  156. package/dist/migrations.js +4 -0
  157. package/dist/migrations.js.map +1 -1
  158. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  159. package/dist/modes/interactive/components/session-selector.js +5 -3
  160. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  161. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  162. package/dist/modes/interactive/interactive-mode.js +8 -4
  163. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  164. package/dist/modes/interactive/resume-rebind.d.ts +12 -0
  165. package/dist/modes/interactive/resume-rebind.d.ts.map +1 -0
  166. package/dist/modes/interactive/resume-rebind.js +37 -0
  167. package/dist/modes/interactive/resume-rebind.js.map +1 -0
  168. package/dist/modes/interactive/tips/catalog/computer-tips.d.ts +7 -0
  169. package/dist/modes/interactive/tips/catalog/computer-tips.d.ts.map +1 -0
  170. package/dist/modes/interactive/tips/catalog/computer-tips.js +36 -0
  171. package/dist/modes/interactive/tips/catalog/computer-tips.js.map +1 -0
  172. package/dist/modes/interactive/tips/registry.d.ts.map +1 -1
  173. package/dist/modes/interactive/tips/registry.js +2 -0
  174. package/dist/modes/interactive/tips/registry.js.map +1 -1
  175. package/dist/modes/rpc/connection-handler.d.ts.map +1 -1
  176. package/dist/modes/rpc/connection-handler.js +3 -0
  177. package/dist/modes/rpc/connection-handler.js.map +1 -1
  178. package/dist/modes/rpc/host-child-exit.d.ts.map +1 -1
  179. package/dist/modes/rpc/host-child-exit.js +4 -0
  180. package/dist/modes/rpc/host-child-exit.js.map +1 -1
  181. package/dist/modes/rpc/host-crash-record.d.ts +8 -0
  182. package/dist/modes/rpc/host-crash-record.d.ts.map +1 -1
  183. package/dist/modes/rpc/host-crash-record.js.map +1 -1
  184. package/dist/modes/rpc/host-crash-record.test.js +11 -0
  185. package/dist/modes/rpc/host-crash-record.test.js.map +1 -1
  186. package/dist/modes/rpc/rpc-client.d.ts +2 -2
  187. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  188. package/dist/modes/rpc/rpc-client.js +14 -6
  189. package/dist/modes/rpc/rpc-client.js.map +1 -1
  190. package/dist/modes/rpc/rpc-request-deadline.d.ts +17 -0
  191. package/dist/modes/rpc/rpc-request-deadline.d.ts.map +1 -0
  192. package/dist/modes/rpc/rpc-request-deadline.js +27 -0
  193. package/dist/modes/rpc/rpc-request-deadline.js.map +1 -0
  194. package/dist/modes/rpc/rpc-types.d.ts +9 -2
  195. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  196. package/dist/modes/rpc/rpc-types.js.map +1 -1
  197. package/dist/modes/rpc/session-command-router.d.ts +3 -6
  198. package/dist/modes/rpc/session-command-router.d.ts.map +1 -1
  199. package/dist/modes/rpc/session-command-router.js +9 -22
  200. package/dist/modes/rpc/session-command-router.js.map +1 -1
  201. package/dist/modes/rpc/session-path-key.d.ts +10 -0
  202. package/dist/modes/rpc/session-path-key.d.ts.map +1 -0
  203. package/dist/modes/rpc/session-path-key.js +33 -0
  204. package/dist/modes/rpc/session-path-key.js.map +1 -0
  205. package/dist/modes/rpc/session-registry.d.ts.map +1 -1
  206. package/dist/modes/rpc/session-registry.js +6 -10
  207. package/dist/modes/rpc/session-registry.js.map +1 -1
  208. package/dist/modes/rpc/session-sweep.d.ts +18 -0
  209. package/dist/modes/rpc/session-sweep.d.ts.map +1 -0
  210. package/dist/modes/rpc/session-sweep.js +32 -0
  211. package/dist/modes/rpc/session-sweep.js.map +1 -0
  212. package/dist/pi-dir-restore.d.ts +4 -0
  213. package/dist/pi-dir-restore.d.ts.map +1 -0
  214. package/dist/pi-dir-restore.js +92 -0
  215. package/dist/pi-dir-restore.js.map +1 -0
  216. package/docs/rpc.md +8 -3
  217. package/docs/sdk.md +29 -0
  218. package/docs/sessions.md +4 -0
  219. package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +12 -0
  220. package/node_modules/@code-yeongyu/senpi-codemode/package.json +4 -4
  221. package/node_modules/@earendil-works/pi-agent-core/dist/agent.d.ts +2 -2
  222. package/node_modules/@earendil-works/pi-agent-core/dist/agent.d.ts.map +1 -1
  223. package/node_modules/@earendil-works/pi-agent-core/dist/agent.js +7 -0
  224. package/node_modules/@earendil-works/pi-agent-core/dist/agent.js.map +1 -1
  225. package/node_modules/@earendil-works/pi-agent-core/dist/assistant-terminal-state.d.ts.map +1 -1
  226. package/node_modules/@earendil-works/pi-agent-core/dist/assistant-terminal-state.js +3 -1
  227. package/node_modules/@earendil-works/pi-agent-core/dist/assistant-terminal-state.js.map +1 -1
  228. package/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts +3 -1
  229. package/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts.map +1 -1
  230. package/node_modules/@earendil-works/pi-agent-core/dist/types.js.map +1 -1
  231. package/node_modules/@earendil-works/pi-agent-core/package.json +3 -3
  232. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.d.ts.map +1 -1
  233. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +10 -7
  234. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js.map +1 -1
  235. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts.map +1 -1
  236. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +9 -1
  237. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js.map +1 -1
  238. package/node_modules/@earendil-works/pi-ai/dist/index.d.ts +1 -0
  239. package/node_modules/@earendil-works/pi-ai/dist/index.d.ts.map +1 -1
  240. package/node_modules/@earendil-works/pi-ai/dist/index.js +1 -0
  241. package/node_modules/@earendil-works/pi-ai/dist/index.js.map +1 -1
  242. package/node_modules/@earendil-works/pi-ai/dist/provider-diagnostic.d.ts +33 -0
  243. package/node_modules/@earendil-works/pi-ai/dist/provider-diagnostic.d.ts.map +1 -0
  244. package/node_modules/@earendil-works/pi-ai/dist/provider-diagnostic.js +56 -0
  245. package/node_modules/@earendil-works/pi-ai/dist/provider-diagnostic.js.map +1 -0
  246. package/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
  247. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
  248. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts +3 -0
  249. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts.map +1 -1
  250. package/node_modules/@earendil-works/pi-ai/dist/types.js.map +1 -1
  251. package/node_modules/@earendil-works/pi-ai/dist/utils/provider-diagnostic-carrier.d.ts +5 -0
  252. package/node_modules/@earendil-works/pi-ai/dist/utils/provider-diagnostic-carrier.d.ts.map +1 -0
  253. package/node_modules/@earendil-works/pi-ai/dist/utils/provider-diagnostic-carrier.js +18 -0
  254. package/node_modules/@earendil-works/pi-ai/dist/utils/provider-diagnostic-carrier.js.map +1 -0
  255. package/node_modules/@earendil-works/pi-ai/dist/utils/provider-diagnostic-sources.d.ts +26 -0
  256. package/node_modules/@earendil-works/pi-ai/dist/utils/provider-diagnostic-sources.d.ts.map +1 -0
  257. package/node_modules/@earendil-works/pi-ai/dist/utils/provider-diagnostic-sources.js +103 -0
  258. package/node_modules/@earendil-works/pi-ai/dist/utils/provider-diagnostic-sources.js.map +1 -0
  259. package/node_modules/@earendil-works/pi-ai/dist/utils/provider-diagnostic-vocabulary.d.ts +36 -0
  260. package/node_modules/@earendil-works/pi-ai/dist/utils/provider-diagnostic-vocabulary.d.ts.map +1 -0
  261. package/node_modules/@earendil-works/pi-ai/dist/utils/provider-diagnostic-vocabulary.js +129 -0
  262. package/node_modules/@earendil-works/pi-ai/dist/utils/provider-diagnostic-vocabulary.js.map +1 -0
  263. package/node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.d.ts.map +1 -1
  264. package/node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.js +5 -4
  265. package/node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.js.map +1 -1
  266. package/node_modules/@earendil-works/pi-ai/package.json +2 -2
  267. package/node_modules/@earendil-works/pi-pty/package.json +1 -1
  268. package/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
  269. package/node_modules/@earendil-works/pi-tui/package.json +1 -1
  270. package/package.json +7 -7
  271. package/dist/bundle/chunks/anthropic-messages-UYDVRFAS.js +0 -8
  272. package/dist/bundle/chunks/azure-openai-responses-DODWR4W6.js +0 -2
  273. package/dist/bundle/chunks/chunk-2L26KPZ6.js +0 -8
  274. package/dist/bundle/chunks/chunk-3CC5ZOBV.js +0 -13
  275. package/dist/bundle/chunks/chunk-L6JO4M6J.js +0 -3
  276. package/dist/bundle/chunks/chunk-SFYHCFRO.js +0 -2
  277. package/dist/bundle/chunks/chunk-TTHMOL5G.js +0 -2
  278. package/dist/bundle/chunks/chunk-UYCGOK6M.js +0 -2
  279. package/dist/bundle/chunks/chunk-ZTVQY5V6.js +0 -2
  280. package/dist/bundle/chunks/cli-main-HOM6UH3H.js +0 -3
  281. package/dist/bundle/chunks/google-generative-ai-VIEFECKJ.js +0 -2
  282. package/dist/bundle/chunks/google-vertex-Q64CKFID.js +0 -2
  283. package/dist/bundle/chunks/help-fast-path-YGYHMV2W.js +0 -2
  284. package/dist/bundle/chunks/host-command-XXSAFWBW.js +0 -2
  285. package/dist/bundle/chunks/host-lifecycle-GOMGJ25O.js +0 -3
  286. package/dist/bundle/chunks/interactive-host-runtime-IYCZWJGX.js +0 -4
  287. package/dist/bundle/chunks/interactive-mode-ZMO7YVYU.js +0 -2
  288. package/dist/bundle/chunks/openai-images-JA5N5DUU.js +0 -2
  289. package/dist/bundle/chunks/openai-responses-IBFGBAJP.js +0 -2
  290. package/dist/bundle/chunks/openrouter-images-MW5TXV7L.js +0 -2
  291. package/dist/bundle/chunks/rotation-stream-NATO6IMN.js +0 -2
  292. package/dist/bundle/chunks/rpc-mode-WCETTMFV.js +0 -2
  293. package/dist/bundle/chunks/session-picker-BP7THCWF.js +0 -2
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url); { const __piWorkerThreads = require("node:worker_threads"); if (typeof __piWorkerThreads.markAsUncloneable !== "function") { __piWorkerThreads.markAsUncloneable = () => {}; } }
2
- import{CREDENTIAL_POOL_STATE_FILENAME,CredentialSlotRepository,acquireHalfOpenLease,credentialPoolStatePath,slotHealth}from"./chunk-X3T45623.js";import"./chunk-7X72IACK.js";import"./chunk-KUPQO7MC.js";import"./chunk-L6JO4M6J.js";import"./chunk-Y65WFI5H.js";import"./chunk-ATQFN5HI.js";import"./chunk-IKOFCODM.js";export{CREDENTIAL_POOL_STATE_FILENAME,CredentialSlotRepository,acquireHalfOpenLease,credentialPoolStatePath,slotHealth};
2
+ import{CREDENTIAL_POOL_STATE_FILENAME,CredentialSlotRepository,acquireHalfOpenLease,credentialPoolStatePath,slotHealth}from"./chunk-QK4QKRTF.js";import"./chunk-7X72IACK.js";import"./chunk-KUPQO7MC.js";import"./chunk-GZVCRV7I.js";import"./chunk-U3VOXCGP.js";import"./chunk-Y65WFI5H.js";import"./chunk-ATQFN5HI.js";import"./chunk-IKOFCODM.js";export{CREDENTIAL_POOL_STATE_FILENAME,CredentialSlotRepository,acquireHalfOpenLease,credentialPoolStatePath,slotHealth};
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url); { const __piWorkerThreads = require("node:worker_threads"); if (typeof __piWorkerThreads.markAsUncloneable !== "function") { __piWorkerThreads.markAsUncloneable = () => {}; } }
3
- import{enableStartupCompileCache}from"./chunks/chunk-F73COJ7R.js";import{getLatestPiRelease,hasInheritedInspectorOption,isNewerPackageVersion,processBunRuntimeOptions,releaseInheritedInspectorForChild,resolveBunReexec}from"./chunks/chunk-W3D3ZYDS.js";import"./chunks/chunk-ZOFZRJSL.js";import"./chunks/chunk-2SOVDETB.js";import{APP_NAME,DISPLAY_VERSION,PACKAGE_NAME,VERSION,brandProfile,getAgentDir,getPackageDir,getSelfUpdateCommand,getSelfUpdateUnavailableInstruction,isBundledNode}from"./chunks/chunk-Y65WFI5H.js";import"./chunks/chunk-ATQFN5HI.js";import"./chunks/chunk-IKOFCODM.js";import{spawn as spawn2,spawnSync}from"node:child_process";import{existsSync,realpathSync}from"node:fs";import{join as join2}from"node:path";import{fileURLToPath}from"node:url";import{spawn}from"node:child_process";import{readFileSync}from"node:fs";import{join}from"node:path";function parseBootstrapSelfUpdateArgs(args2){let[command,...rest]=args2;if(command!=="update")return;let force=!1,selfFlag=!1,extensionsFlag=!1,extensionFlag=!1,source;for(let index=0;index<rest.length;index++){let arg=rest[index];if(arg==="-h"||arg==="--help")return;if(arg==="--force"){force=!0;continue}if(arg==="--self"){selfFlag=!0;continue}if(arg==="--extensions"){extensionsFlag=!0;continue}if(arg==="--extension"){extensionFlag=!0,index++;continue}if(arg.startsWith("-")||source)return;source=arg}if(extensionFlag)return;let sourceIsSelf=source==="self"||source==="pi"||source===APP_NAME;if(!(source&&!sourceIsSelf)&&!(!selfFlag&&!sourceIsSelf&&extensionsFlag))return{force}}function getObjectProperty(value,key){if(!(!value||typeof value!="object"))return Object.getOwnPropertyDescriptor(value,key)?.value}function readConfiguredNpmCommand(){try{let parsed=JSON.parse(readFileSync(join(getAgentDir(),"settings.json"),"utf-8")),npmCommand=getObjectProperty(parsed,"npmCommand");return!Array.isArray(npmCommand)||npmCommand.some(part=>typeof part!="string")?void 0:npmCommand.length>0?npmCommand:void 0}catch{return}}async function runCommand(step){await new Promise((resolve,reject)=>{let child=spawn(step.command,step.args,{stdio:"inherit"});child.on("error",error=>{reject(error)}),child.on("close",(code,signal)=>{code===0?resolve():reject(signal?new Error(`${step.display} terminated by signal ${signal}`):new Error(`${step.display} exited with code ${code??"unknown"}`))})})}async function handleBootstrapSelfUpdate(args2,dependencies={}){let parsed=parseBootstrapSelfUpdateArgs(args2);if(!parsed)return!1;let writeStdout=dependencies.writeStdout??(line=>console.log(line)),writeStderr=dependencies.writeStderr??(line=>console.error(line)),readNpmCommand=dependencies.readNpmCommand??readConfiguredNpmCommand,resolveSelfUpdateCommand=dependencies.getSelfUpdateCommand??getSelfUpdateCommand,resolveUnavailableInstruction=dependencies.getUnavailableInstruction??getSelfUpdateUnavailableInstruction,executeCommand=dependencies.runCommand??runCommand,brandUpdate=brandProfile()?.update;if(brandUpdate)return writeStdout(`${APP_NAME} ships inside ${brandUpdate.packageName}. Update it with: ${brandUpdate.command}`),!0;let loadLatestRelease=dependencies.getLatestRelease??getLatestPiRelease,latestRelease;if(!parsed.force)try{latestRelease=await loadLatestRelease(VERSION)}catch{latestRelease=void 0}let updatePackageName=latestRelease?.packageName??PACKAGE_NAME;if(!(parsed.force||!latestRelease||updatePackageName!==PACKAGE_NAME||isNewerPackageVersion(latestRelease.version,VERSION)))return writeStdout(`${APP_NAME} is already up to date (v${VERSION})`),!0;let npmCommand=readNpmCommand(),selfUpdateCommand=resolveSelfUpdateCommand(PACKAGE_NAME,npmCommand,updatePackageName);if(!selfUpdateCommand)return writeStderr(`error: ${APP_NAME} cannot self-update this installation.`),writeStderr(resolveUnavailableInstruction(PACKAGE_NAME,npmCommand,updatePackageName)),process.argv[1]&&(writeStderr(""),writeStderr(`Location of ${APP_NAME} executable: ${process.argv[1]}`)),process.exitCode=1,!0;latestRelease?.note?.trim()&&(writeStdout(""),writeStdout("Update note"),writeStdout(latestRelease.note.trim()),writeStdout("")),writeStdout(`Updating ${APP_NAME} with ${selfUpdateCommand.display}...`);for(let step of selfUpdateCommand.steps??[selfUpdateCommand])try{await executeCommand(step)}catch(error){let message=error instanceof Error?error.message:"Unknown package command error";return writeStderr(`Error: ${message}`),writeStderr(`If this keeps failing, run this command yourself: ${selfUpdateCommand.display}`),process.exitCode=1,!0}return writeStdout(`Updated ${APP_NAME}`),!0}function reexecUnderBunIfNeeded(){let options=processBunRuntimeOptions(existsSync,realpathSync),scriptRealPath=process.argv[1]??fileURLToPath(import.meta.url);try{scriptRealPath=realpathSync(scriptRealPath)}catch{}let decision=resolveBunReexec({scriptRealPath,versions:process.versions,hasInheritedInspectorOption:hasInheritedInspectorOption(),options});if(decision.action==="stay")return!1;let result=spawnSync(decision.bunPath,[scriptRealPath,...process.argv.slice(2)],{stdio:"inherit",windowsHide:!0});return result.signal?(process.kill(process.pid,result.signal),!0):(process.exitCode=result.status??1,!0)}reexecUnderBunIfNeeded()&&process.exit();enableStartupCompileCache();process.title=APP_NAME;process.env.PI_CODING_AGENT="true";process.env.AI_AGENT=APP_NAME;process.emitWarning=(()=>{});var args=process.argv.slice(2),PACKAGE_COMMANDS=new Set(["install","remove","uninstall","update","list","config"]);function isRootCommand(args2){let firstArg=args2[0];return firstArg===void 0||!PACKAGE_COMMANDS.has(firstArg)}function isPackageManagerInstall(packageDir){return packageDir.replace(/\\/g,"/").includes("/node_modules/@code-yeongyu/senpi")}function isMissingBundledWorkspaceDependencies(packageDir){return isPackageManagerInstall(packageDir)?["pi-agent-core","pi-ai","pi-tui"].some(name=>!existsSync(join2(packageDir,"node_modules","@earendil-works",name,"dist","index.js"))):!1}var ISOLATED_CHILD_ENV="SENPI_CLI_ISOLATED_CHILD";function requiresIsolatedProcess(){return process.env[ISOLATED_CHILD_ENV]==="1"?!1:process.execArgv.length>0||hasInheritedInspectorOption()}async function spawnFullCli(){let extension=import.meta.url.endsWith(".ts")?".ts":".js",fullCliPath=isBundledNode?fileURLToPath(import.meta.url):fileURLToPath(new URL(`./cli-main${extension}`,import.meta.url));releaseInheritedInspectorForChild();let childEnvironment=isBundledNode?{...process.env,[ISOLATED_CHILD_ENV]:"1"}:process.env;return await new Promise((resolve,reject)=>{let child=spawn2(process.execPath,[...process.execArgv,fullCliPath,...args],{env:childEnvironment,stdio:"inherit"});child.on("error",error=>{reject(error)}),child.on("close",(code,signal)=>{if(signal){process.kill(process.pid,signal),resolve(1);return}resolve(code??1)})})}isRootCommand(args)&&(args.includes("--version")||args.includes("-v"))&&(console.log(DISPLAY_VERSION),process.exit());if(isRootCommand(args)&&args.some(arg=>arg==="--help"||arg==="-h")){let{tryPrintHelpWithoutEngine}=await import("./chunks/help-fast-path-YGYHMV2W.js");tryPrintHelpWithoutEngine(args)&&process.exit()}isMissingBundledWorkspaceDependencies(getPackageDir())&&await handleBootstrapSelfUpdate(args)&&process.exit();requiresIsolatedProcess()?process.exitCode=await spawnFullCli():await import("./chunks/cli-main-HOM6UH3H.js");
3
+ import{enableStartupCompileCache}from"./chunks/chunk-F73COJ7R.js";import{getLatestPiRelease,hasInheritedInspectorOption,isNewerPackageVersion,processBunRuntimeOptions,releaseInheritedInspectorForChild,resolveBunReexec}from"./chunks/chunk-W3D3ZYDS.js";import"./chunks/chunk-ZOFZRJSL.js";import"./chunks/chunk-2SOVDETB.js";import{APP_NAME,DISPLAY_VERSION,PACKAGE_NAME,VERSION,brandProfile,getAgentDir,getPackageDir,getSelfUpdateCommand,getSelfUpdateUnavailableInstruction,isBundledNode}from"./chunks/chunk-Y65WFI5H.js";import"./chunks/chunk-ATQFN5HI.js";import"./chunks/chunk-IKOFCODM.js";import{spawn as spawn2,spawnSync}from"node:child_process";import{existsSync,realpathSync}from"node:fs";import{join as join2}from"node:path";import{fileURLToPath}from"node:url";import{spawn}from"node:child_process";import{readFileSync}from"node:fs";import{join}from"node:path";function parseBootstrapSelfUpdateArgs(args2){let[command,...rest]=args2;if(command!=="update")return;let force=!1,selfFlag=!1,extensionsFlag=!1,extensionFlag=!1,source;for(let index=0;index<rest.length;index++){let arg=rest[index];if(arg==="-h"||arg==="--help")return;if(arg==="--force"){force=!0;continue}if(arg==="--self"){selfFlag=!0;continue}if(arg==="--extensions"){extensionsFlag=!0;continue}if(arg==="--extension"){extensionFlag=!0,index++;continue}if(arg.startsWith("-")||source)return;source=arg}if(extensionFlag)return;let sourceIsSelf=source==="self"||source==="pi"||source===APP_NAME;if(!(source&&!sourceIsSelf)&&!(!selfFlag&&!sourceIsSelf&&extensionsFlag))return{force}}function getObjectProperty(value,key){if(!(!value||typeof value!="object"))return Object.getOwnPropertyDescriptor(value,key)?.value}function readConfiguredNpmCommand(){try{let parsed=JSON.parse(readFileSync(join(getAgentDir(),"settings.json"),"utf-8")),npmCommand=getObjectProperty(parsed,"npmCommand");return!Array.isArray(npmCommand)||npmCommand.some(part=>typeof part!="string")?void 0:npmCommand.length>0?npmCommand:void 0}catch{return}}async function runCommand(step){await new Promise((resolve,reject)=>{let child=spawn(step.command,step.args,{stdio:"inherit"});child.on("error",error=>{reject(error)}),child.on("close",(code,signal)=>{code===0?resolve():reject(signal?new Error(`${step.display} terminated by signal ${signal}`):new Error(`${step.display} exited with code ${code??"unknown"}`))})})}async function handleBootstrapSelfUpdate(args2,dependencies={}){let parsed=parseBootstrapSelfUpdateArgs(args2);if(!parsed)return!1;let writeStdout=dependencies.writeStdout??(line=>console.log(line)),writeStderr=dependencies.writeStderr??(line=>console.error(line)),readNpmCommand=dependencies.readNpmCommand??readConfiguredNpmCommand,resolveSelfUpdateCommand=dependencies.getSelfUpdateCommand??getSelfUpdateCommand,resolveUnavailableInstruction=dependencies.getUnavailableInstruction??getSelfUpdateUnavailableInstruction,executeCommand=dependencies.runCommand??runCommand,brandUpdate=brandProfile()?.update;if(brandUpdate)return writeStdout(`${APP_NAME} ships inside ${brandUpdate.packageName}. Update it with: ${brandUpdate.command}`),!0;let loadLatestRelease=dependencies.getLatestRelease??getLatestPiRelease,latestRelease;if(!parsed.force)try{latestRelease=await loadLatestRelease(VERSION)}catch{latestRelease=void 0}let updatePackageName=latestRelease?.packageName??PACKAGE_NAME;if(!(parsed.force||!latestRelease||updatePackageName!==PACKAGE_NAME||isNewerPackageVersion(latestRelease.version,VERSION)))return writeStdout(`${APP_NAME} is already up to date (v${VERSION})`),!0;let npmCommand=readNpmCommand(),selfUpdateCommand=resolveSelfUpdateCommand(PACKAGE_NAME,npmCommand,updatePackageName);if(!selfUpdateCommand)return writeStderr(`error: ${APP_NAME} cannot self-update this installation.`),writeStderr(resolveUnavailableInstruction(PACKAGE_NAME,npmCommand,updatePackageName)),process.argv[1]&&(writeStderr(""),writeStderr(`Location of ${APP_NAME} executable: ${process.argv[1]}`)),process.exitCode=1,!0;latestRelease?.note?.trim()&&(writeStdout(""),writeStdout("Update note"),writeStdout(latestRelease.note.trim()),writeStdout("")),writeStdout(`Updating ${APP_NAME} with ${selfUpdateCommand.display}...`);for(let step of selfUpdateCommand.steps??[selfUpdateCommand])try{await executeCommand(step)}catch(error){let message=error instanceof Error?error.message:"Unknown package command error";return writeStderr(`Error: ${message}`),writeStderr(`If this keeps failing, run this command yourself: ${selfUpdateCommand.display}`),process.exitCode=1,!0}return writeStdout(`Updated ${APP_NAME}`),!0}function reexecUnderBunIfNeeded(){let options=processBunRuntimeOptions(existsSync,realpathSync),scriptRealPath=process.argv[1]??fileURLToPath(import.meta.url);try{scriptRealPath=realpathSync(scriptRealPath)}catch{}let decision=resolveBunReexec({scriptRealPath,versions:process.versions,hasInheritedInspectorOption:hasInheritedInspectorOption(),options});if(decision.action==="stay")return!1;let result=spawnSync(decision.bunPath,[scriptRealPath,...process.argv.slice(2)],{stdio:"inherit",windowsHide:!0});return result.signal?(process.kill(process.pid,result.signal),!0):(process.exitCode=result.status??1,!0)}reexecUnderBunIfNeeded()&&process.exit();enableStartupCompileCache();process.title=APP_NAME;process.env.PI_CODING_AGENT="true";process.env.AI_AGENT=APP_NAME;process.emitWarning=(()=>{});var args=process.argv.slice(2),PACKAGE_COMMANDS=new Set(["install","remove","uninstall","update","list","config"]);function isRootCommand(args2){let firstArg=args2[0];return firstArg===void 0||!PACKAGE_COMMANDS.has(firstArg)}function isPackageManagerInstall(packageDir){return packageDir.replace(/\\/g,"/").includes("/node_modules/@code-yeongyu/senpi")}function isMissingBundledWorkspaceDependencies(packageDir){return isPackageManagerInstall(packageDir)?["pi-agent-core","pi-ai","pi-tui"].some(name=>!existsSync(join2(packageDir,"node_modules","@earendil-works",name,"dist","index.js"))):!1}var ISOLATED_CHILD_ENV="SENPI_CLI_ISOLATED_CHILD";function requiresIsolatedProcess(){return process.env[ISOLATED_CHILD_ENV]==="1"?!1:process.execArgv.length>0||hasInheritedInspectorOption()}async function spawnFullCli(){let extension=import.meta.url.endsWith(".ts")?".ts":".js",fullCliPath=isBundledNode?fileURLToPath(import.meta.url):fileURLToPath(new URL(`./cli-main${extension}`,import.meta.url));releaseInheritedInspectorForChild();let childEnvironment=isBundledNode?{...process.env,[ISOLATED_CHILD_ENV]:"1"}:process.env;return await new Promise((resolve,reject)=>{let child=spawn2(process.execPath,[...process.execArgv,fullCliPath,...args],{env:childEnvironment,stdio:"inherit"});child.on("error",error=>{reject(error)}),child.on("close",(code,signal)=>{if(signal){process.kill(process.pid,signal),resolve(1);return}resolve(code??1)})})}isRootCommand(args)&&(args.includes("--version")||args.includes("-v"))&&(console.log(DISPLAY_VERSION),process.exit());if(isRootCommand(args)&&args.some(arg=>arg==="--help"||arg==="-h")){let{tryPrintHelpWithoutEngine}=await import("./chunks/help-fast-path-5LRG6FCG.js");tryPrintHelpWithoutEngine(args)&&process.exit()}isMissingBundledWorkspaceDependencies(getPackageDir())&&await handleBootstrapSelfUpdate(args)&&process.exit();requiresIsolatedProcess()?process.exitCode=await spawnFullCli():await import("./chunks/cli-main-RONHLFWZ.js");
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url); { const __piWorkerThreads = require("node:worker_threads"); if (typeof __piWorkerThreads.markAsUncloneable !== "function") { __piWorkerThreads.markAsUncloneable = () => {}; } }
2
- import{AgentSession,AgentSessionRuntime,ArminComponent,AssistantMessageComponent,BashExecutionComponent,BorderedLoader,BranchSummaryMessageComponent,CompactionSummaryMessageComponent,CredentialSynchronizationError,CustomEditor,CustomMessageComponent,DEFAULT_COMPACTION_SETTINGS,DefaultResourceLoader,ExtensionEditorComponent,ExtensionRunner,FooterComponent,InteractiveMode,LoginDialogComponent,ModelRegistry,ModelRuntime,ModelSelectorComponent,OAuthSelectorComponent,SettingsSelectorComponent,ShowImagesSelectorComponent,SkillInvocationMessageComponent,ThemeSelectorComponent,ThinkingSelectorComponent,ToolExecutionComponent,TreeSelectorComponent,UserMessageComponent,UserMessageSelectorComponent,buildNoticeBox,calculateContextTokens,classifyRead,collectEntriesForBranchSummary,compact,convertToPng,copyToClipboard,createAgentSession,createAgentSessionFromServices,createAgentSessionRuntime,createAgentSessionServices,createBashTool,createBashToolDefinition,createCodingTools,createEditTool,createEditToolDefinition,createEventBus,createExtensionRuntime,createFindTool,createFindToolDefinition,createGrepTool,createGrepToolDefinition,createLocalBashOperations,createLsTool,createLsToolDefinition,createPowerShellTool,createReadOnlyTools,createReadTool,createReadToolDefinition,createSyntheticSourceInfo,createWriteTool,createWriteToolDefinition,defineTool,detectSupportedImageMimeTypeFromFile,discoverAndLoadExtensions,estimateTokens,findCutPoint,findTurnStartIndex,formatDimensionNote,formatSkillsForPrompt,generateBranchSummary,generateDiffString,generateSummary,generateSummaryWithUsage,generateUnifiedPatch,getLastAssistantUsage,isBashToolResult,isEditToolResult,isFindToolResult,isGrepToolResult,isLsToolResult,isPowerShellToolResult,isReadToolResult,isToolCallEventType,isWriteToolResult,kernelToolsStorage,loadProjectContextFiles,loadSkills,loadSkillsFromDir,main,noticeEntryRenderer,noticeMessageRenderer,parseFrontmatter,parseSkillBlock,prepareBranchEntries,readStoredCredential,registerReadClassifier,renderDiff,resizeImage,resolveCliModel,resolveModelScopeWithDiagnostics,runPrintMode,serializeConversation,shouldCompact,stripFrontmatter,truncateToVisualLines,withFileMutationQueue,wrapRegisteredTool,wrapRegisteredTools}from"./chunks/chunk-6SLQ5HFO.js";import{DefaultPackageManager,DynamicBorder,ExtensionInputComponent,ExtensionSelectorComponent,SessionSelectorComponent,keyHint,keyText,rawKeyHint}from"./chunks/chunk-ZKZAATFM.js";import"./chunks/chunk-UYCGOK6M.js";import"./chunks/chunk-6WBYI25N.js";import{CURRENT_SESSION_VERSION,DEFAULT_MAX_BYTES,DEFAULT_MAX_LINES,RpcClient,RpcClientOpenInFlightError,RpcTransportGoneError,SessionManager,buildContextEntries,buildSessionContext,convertToLlm,formatSize,getLatestCompactionEntry,isTransportGoneError,migrateSessionEntries,parseSessionEntries,sessionEntryToContextMessages,truncateHead,truncateLine,truncateTail}from"./chunks/chunk-67BC7VZV.js";import"./chunks/chunk-YS5YEX4S.js";import{runRpcMode}from"./chunks/chunk-2L26KPZ6.js";import{Theme,getLanguageFromPath,getMarkdownTheme,getSelectListTheme,getSettingsListTheme,highlightCode,initTheme}from"./chunks/chunk-77ACEMYL.js";import{sanitizeTerminalLabel}from"./chunks/chunk-EJKCBRYK.js";import"./chunks/chunk-6Q6DGME2.js";import{SettingsManager}from"./chunks/chunk-WM5FVFAP.js";import"./chunks/chunk-YU2P3CAR.js";import"./chunks/chunk-BMX2U22F.js";import{DEFAULT_HOST_LAUNCH_SPEC,HOST_EXIT_ERROR,HOST_EXIT_FALLBACK,HOST_EXIT_OK,HOST_EXIT_REFUSED,HOST_EXIT_USAGE,HostLaunchSpecError,loadHostLaunchSpec,parseHostLaunchSpec,readHostStatus,runHostCommand,runHostRequest}from"./chunks/chunk-6W2DB2GC.js";import{GENERATION_HANDOFF_CAPABILITY,HOST_PROTOCOL_VERSION,HostEnsureRefusedError,PINNED_HOST_CLIENT_CAPABILITIES,REQUIRED_HOST_CAPABILITIES,decideHostAction,ensureHost,handoffHost,parseHostProtocolInfo,probeHost,stopHost}from"./chunks/chunk-LPFZGWG2.js";import"./chunks/chunk-HH3KJDWA.js";import{createHostDaemonPaths}from"./chunks/chunk-3CC5ZOBV.js";import{compareEngineOrdinal,engineBuildIdentity,engineBuildIdentityFrom}from"./chunks/chunk-XKLR7C5B.js";import"./chunks/chunk-FIJJKSPL.js";import"./chunks/chunk-H4QOEVS5.js";import"./chunks/chunk-HB35RBP4.js";import"./chunks/chunk-HZAKOVHN.js";import"./chunks/chunk-TTY5BHCG.js";import{getPowerShellConfig,getShellConfig}from"./chunks/chunk-FHXKBENX.js";import"./chunks/chunk-X3T45623.js";import"./chunks/chunk-7X72IACK.js";import"./chunks/chunk-KUPQO7MC.js";import"./chunks/chunk-HPY47AVX.js";import{ProjectTrustStore,hasTrustRequiringProjectResources}from"./chunks/chunk-SUQDU5KM.js";import{parseArgs}from"./chunks/chunk-7FXXRPB3.js";import"./chunks/chunk-26UBFF6N.js";import"./chunks/chunk-KMJXSXRX.js";import"./chunks/chunk-L6JO4M6J.js";import"./chunks/chunk-RFB5CBW7.js";import"./chunks/chunk-2VZJTDUX.js";import"./chunks/chunk-ELFCNCBY.js";import"./chunks/chunk-PRC5XIIH.js";import"./chunks/chunk-W3D3ZYDS.js";import"./chunks/chunk-ZOFZRJSL.js";import"./chunks/chunk-2SOVDETB.js";import{CONFIG_DIR_NAME,VERSION,getAgentDir,getDocsPath,getExamplesPath,getPackageDir,getReadmePath}from"./chunks/chunk-Y65WFI5H.js";import"./chunks/chunk-ATQFN5HI.js";import"./chunks/chunk-RBCQOIAD.js";import"./chunks/chunk-WASCMT6Y.js";import"./chunks/chunk-X4Q5YSTE.js";import"./chunks/chunk-IXAUDPOK.js";import"./chunks/chunk-TTHMOL5G.js";import"./chunks/chunk-WVGCQOLJ.js";import"./chunks/chunk-BPX6QWPD.js";import"./chunks/chunk-WL5EQYNL.js";import"./chunks/chunk-WDTJ6JKE.js";import"./chunks/chunk-5ROMKDLK.js";import"./chunks/chunk-3W47LTXQ.js";import"./chunks/chunk-DMI55M2N.js";import"./chunks/chunk-BQVVQ2LQ.js";import"./chunks/chunk-IKOFCODM.js";export{AgentSession,AgentSessionRuntime,ArminComponent,AssistantMessageComponent,BashExecutionComponent,BorderedLoader,BranchSummaryMessageComponent,CONFIG_DIR_NAME,CURRENT_SESSION_VERSION,CompactionSummaryMessageComponent,CredentialSynchronizationError,CustomEditor,CustomMessageComponent,DEFAULT_COMPACTION_SETTINGS,DEFAULT_HOST_LAUNCH_SPEC,DEFAULT_MAX_BYTES,DEFAULT_MAX_LINES,DefaultPackageManager,DefaultResourceLoader,DynamicBorder,ExtensionEditorComponent,ExtensionInputComponent,ExtensionRunner,ExtensionSelectorComponent,FooterComponent,GENERATION_HANDOFF_CAPABILITY,HOST_EXIT_ERROR,HOST_EXIT_FALLBACK,HOST_EXIT_OK,HOST_EXIT_REFUSED,HOST_EXIT_USAGE,HOST_PROTOCOL_VERSION,HostEnsureRefusedError,HostLaunchSpecError,InteractiveMode,LoginDialogComponent,ModelRegistry,ModelRuntime,ModelSelectorComponent,OAuthSelectorComponent,PINNED_HOST_CLIENT_CAPABILITIES,ProjectTrustStore,REQUIRED_HOST_CAPABILITIES,RpcClient,RpcClientOpenInFlightError,RpcTransportGoneError,SessionManager,SessionSelectorComponent,SettingsManager,SettingsSelectorComponent,ShowImagesSelectorComponent,SkillInvocationMessageComponent,Theme,ThemeSelectorComponent,ThinkingSelectorComponent,ToolExecutionComponent,TreeSelectorComponent,UserMessageComponent,UserMessageSelectorComponent,VERSION,buildContextEntries,buildNoticeBox,buildSessionContext,calculateContextTokens,classifyRead,collectEntriesForBranchSummary,compact,compareEngineOrdinal,convertToLlm,convertToPng,copyToClipboard,createAgentSession,createAgentSessionFromServices,createAgentSessionRuntime,createAgentSessionServices,createBashTool,createBashToolDefinition,createCodingTools,createEditTool,createEditToolDefinition,createEventBus,createExtensionRuntime,createFindTool,createFindToolDefinition,createGrepTool,createGrepToolDefinition,createHostDaemonPaths,createLocalBashOperations,createLsTool,createLsToolDefinition,createPowerShellTool,createReadOnlyTools,createReadTool,createReadToolDefinition,createSyntheticSourceInfo,createWriteTool,createWriteToolDefinition,decideHostAction,defineTool,detectSupportedImageMimeTypeFromFile,discoverAndLoadExtensions,engineBuildIdentity,engineBuildIdentityFrom,ensureHost,estimateTokens,findCutPoint,findTurnStartIndex,formatDimensionNote,formatSize,formatSkillsForPrompt,generateBranchSummary,generateDiffString,generateSummary,generateSummaryWithUsage,generateUnifiedPatch,getAgentDir,getDocsPath,getExamplesPath,getLanguageFromPath,getLastAssistantUsage,getLatestCompactionEntry,getMarkdownTheme,getPackageDir,getPowerShellConfig,getReadmePath,getSelectListTheme,getSettingsListTheme,getShellConfig,handoffHost,hasTrustRequiringProjectResources,highlightCode,initTheme,isBashToolResult,isEditToolResult,isFindToolResult,isGrepToolResult,isLsToolResult,isPowerShellToolResult,isReadToolResult,isToolCallEventType,isTransportGoneError,isWriteToolResult,kernelToolsStorage,keyHint,keyText,loadHostLaunchSpec,loadProjectContextFiles,loadSkills,loadSkillsFromDir,main,migrateSessionEntries,noticeEntryRenderer,noticeMessageRenderer,parseArgs,parseFrontmatter,parseHostLaunchSpec,parseHostProtocolInfo,parseSessionEntries,parseSkillBlock,prepareBranchEntries,probeHost,rawKeyHint,readHostStatus,readStoredCredential,registerReadClassifier,renderDiff,resizeImage,resolveCliModel,resolveModelScopeWithDiagnostics,runHostCommand,runHostRequest,runPrintMode,runRpcMode,sanitizeTerminalLabel,serializeConversation,sessionEntryToContextMessages,shouldCompact,stopHost,stripFrontmatter,truncateHead,truncateLine,truncateTail,truncateToVisualLines,withFileMutationQueue,wrapRegisteredTool,wrapRegisteredTools};
2
+ import{AgentSession,AgentSessionRuntime,ArminComponent,AssistantMessageComponent,BashExecutionComponent,BorderedLoader,BranchSummaryMessageComponent,CompactionSummaryMessageComponent,CredentialSynchronizationError,CustomEditor,CustomMessageComponent,DEFAULT_COMPACTION_SETTINGS,DefaultResourceLoader,ExtensionEditorComponent,ExtensionRunner,FooterComponent,InteractiveMode,LoginDialogComponent,ModelRegistry,ModelRuntime,ModelSelectorComponent,OAuthSelectorComponent,SettingsSelectorComponent,ShowImagesSelectorComponent,SkillInvocationMessageComponent,ThemeSelectorComponent,ThinkingSelectorComponent,ToolExecutionComponent,TreeSelectorComponent,UserMessageComponent,UserMessageSelectorComponent,buildNoticeBox,calculateContextTokens,classifyRead,collectEntriesForBranchSummary,compact,convertToPng,copyToClipboard,createAgentSession,createAgentSessionFromServices,createAgentSessionRuntime,createAgentSessionServices,createBashTool,createBashToolDefinition,createCodingTools,createEditTool,createEditToolDefinition,createEventBus,createExtensionRuntime,createFindTool,createFindToolDefinition,createGrepTool,createGrepToolDefinition,createLocalBashOperations,createLsTool,createLsToolDefinition,createPowerShellTool,createReadOnlyTools,createReadTool,createReadToolDefinition,createSyntheticSourceInfo,createWriteTool,createWriteToolDefinition,defineTool,detectSupportedImageMimeTypeFromFile,discoverAndLoadExtensions,estimateTokens,findCutPoint,findTurnStartIndex,formatDimensionNote,formatSkillsForPrompt,generateBranchSummary,generateDiffString,generateSummary,generateSummaryWithUsage,generateUnifiedPatch,getLastAssistantUsage,isBashToolResult,isEditToolResult,isFindToolResult,isGrepToolResult,isLsToolResult,isPowerShellToolResult,isReadToolResult,isToolCallEventType,isWriteToolResult,kernelToolsStorage,loadProjectContextFiles,loadSkills,loadSkillsFromDir,main,noticeEntryRenderer,noticeMessageRenderer,parseFrontmatter,parseSkillBlock,prepareBranchEntries,readStoredCredential,registerReadClassifier,renderDiff,resizeImage,resolveCliModel,resolveModelScopeWithDiagnostics,runPrintMode,serializeConversation,shouldCompact,stripFrontmatter,truncateToVisualLines,withFileMutationQueue,wrapRegisteredTool,wrapRegisteredTools}from"./chunks/chunk-RYI6XR6Z.js";import{DefaultPackageManager,DynamicBorder,ExtensionInputComponent,ExtensionSelectorComponent,SessionSelectorComponent,keyHint,keyText,rawKeyHint}from"./chunks/chunk-LDB5UMH2.js";import"./chunks/chunk-ELM77A26.js";import"./chunks/chunk-6WBYI25N.js";import{CURRENT_SESSION_VERSION,DEFAULT_MAX_BYTES,DEFAULT_MAX_LINES,RpcClient,RpcClientOpenInFlightError,RpcTransportGoneError,SessionManager,buildContextEntries,buildSessionContext,convertToLlm,formatSize,getLatestCompactionEntry,isTransportGoneError,migrateSessionEntries,parseSessionEntries,sessionEntryToContextMessages,truncateHead,truncateLine,truncateTail}from"./chunks/chunk-OZN2KUPR.js";import"./chunks/chunk-YS5YEX4S.js";import{runRpcMode}from"./chunks/chunk-3SIQIY57.js";import{Theme,getLanguageFromPath,getMarkdownTheme,getSelectListTheme,getSettingsListTheme,highlightCode,initTheme}from"./chunks/chunk-6J6RDMBY.js";import{sanitizeTerminalLabel}from"./chunks/chunk-EJKCBRYK.js";import"./chunks/chunk-NMDALHXH.js";import{SettingsManager}from"./chunks/chunk-QPZVJQC5.js";import"./chunks/chunk-YU2P3CAR.js";import"./chunks/chunk-BMX2U22F.js";import{DEFAULT_HOST_LAUNCH_SPEC,HOST_EXIT_ERROR,HOST_EXIT_FALLBACK,HOST_EXIT_OK,HOST_EXIT_REFUSED,HOST_EXIT_USAGE,HostLaunchSpecError,loadHostLaunchSpec,parseHostLaunchSpec,readHostStatus,runHostCommand,runHostRequest}from"./chunks/chunk-RULGEHQM.js";import{GENERATION_HANDOFF_CAPABILITY,HOST_PROTOCOL_VERSION,HostEnsureRefusedError,PINNED_HOST_CLIENT_CAPABILITIES,REQUIRED_HOST_CAPABILITIES,decideHostAction,ensureHost,handoffHost,parseHostProtocolInfo,probeHost,stopHost}from"./chunks/chunk-Y7EIVDHZ.js";import"./chunks/chunk-HH3KJDWA.js";import{createHostDaemonPaths}from"./chunks/chunk-NNILBBOH.js";import{compareEngineOrdinal,engineBuildIdentity,engineBuildIdentityFrom}from"./chunks/chunk-XKLR7C5B.js";import"./chunks/chunk-FIJJKSPL.js";import"./chunks/chunk-H4QOEVS5.js";import"./chunks/chunk-HB35RBP4.js";import"./chunks/chunk-LGKKU4VM.js";import"./chunks/chunk-H2SGCPMD.js";import{getPowerShellConfig,getShellConfig}from"./chunks/chunk-FHXKBENX.js";import"./chunks/chunk-QK4QKRTF.js";import"./chunks/chunk-7X72IACK.js";import"./chunks/chunk-KUPQO7MC.js";import"./chunks/chunk-QYAO24GB.js";import{ProjectTrustStore,hasTrustRequiringProjectResources}from"./chunks/chunk-OQRUK2DK.js";import{parseArgs}from"./chunks/chunk-7FXXRPB3.js";import"./chunks/chunk-26UBFF6N.js";import"./chunks/chunk-357I4IUU.js";import"./chunks/chunk-GZVCRV7I.js";import"./chunks/chunk-U3VOXCGP.js";import"./chunks/chunk-RFB5CBW7.js";import"./chunks/chunk-2VZJTDUX.js";import"./chunks/chunk-ELFCNCBY.js";import"./chunks/chunk-PRC5XIIH.js";import"./chunks/chunk-W3D3ZYDS.js";import"./chunks/chunk-ZOFZRJSL.js";import"./chunks/chunk-2SOVDETB.js";import{CONFIG_DIR_NAME,VERSION,getAgentDir,getDocsPath,getExamplesPath,getPackageDir,getReadmePath}from"./chunks/chunk-Y65WFI5H.js";import"./chunks/chunk-ATQFN5HI.js";import"./chunks/chunk-RBCQOIAD.js";import"./chunks/chunk-WASCMT6Y.js";import"./chunks/chunk-X4Q5YSTE.js";import"./chunks/chunk-IXAUDPOK.js";import"./chunks/chunk-L6QV7NZI.js";import"./chunks/chunk-45SZOLCU.js";import"./chunks/chunk-WVGCQOLJ.js";import"./chunks/chunk-BPX6QWPD.js";import"./chunks/chunk-WL5EQYNL.js";import"./chunks/chunk-WDTJ6JKE.js";import"./chunks/chunk-5ROMKDLK.js";import"./chunks/chunk-3W47LTXQ.js";import"./chunks/chunk-DMI55M2N.js";import"./chunks/chunk-BQVVQ2LQ.js";import"./chunks/chunk-IKOFCODM.js";export{AgentSession,AgentSessionRuntime,ArminComponent,AssistantMessageComponent,BashExecutionComponent,BorderedLoader,BranchSummaryMessageComponent,CONFIG_DIR_NAME,CURRENT_SESSION_VERSION,CompactionSummaryMessageComponent,CredentialSynchronizationError,CustomEditor,CustomMessageComponent,DEFAULT_COMPACTION_SETTINGS,DEFAULT_HOST_LAUNCH_SPEC,DEFAULT_MAX_BYTES,DEFAULT_MAX_LINES,DefaultPackageManager,DefaultResourceLoader,DynamicBorder,ExtensionEditorComponent,ExtensionInputComponent,ExtensionRunner,ExtensionSelectorComponent,FooterComponent,GENERATION_HANDOFF_CAPABILITY,HOST_EXIT_ERROR,HOST_EXIT_FALLBACK,HOST_EXIT_OK,HOST_EXIT_REFUSED,HOST_EXIT_USAGE,HOST_PROTOCOL_VERSION,HostEnsureRefusedError,HostLaunchSpecError,InteractiveMode,LoginDialogComponent,ModelRegistry,ModelRuntime,ModelSelectorComponent,OAuthSelectorComponent,PINNED_HOST_CLIENT_CAPABILITIES,ProjectTrustStore,REQUIRED_HOST_CAPABILITIES,RpcClient,RpcClientOpenInFlightError,RpcTransportGoneError,SessionManager,SessionSelectorComponent,SettingsManager,SettingsSelectorComponent,ShowImagesSelectorComponent,SkillInvocationMessageComponent,Theme,ThemeSelectorComponent,ThinkingSelectorComponent,ToolExecutionComponent,TreeSelectorComponent,UserMessageComponent,UserMessageSelectorComponent,VERSION,buildContextEntries,buildNoticeBox,buildSessionContext,calculateContextTokens,classifyRead,collectEntriesForBranchSummary,compact,compareEngineOrdinal,convertToLlm,convertToPng,copyToClipboard,createAgentSession,createAgentSessionFromServices,createAgentSessionRuntime,createAgentSessionServices,createBashTool,createBashToolDefinition,createCodingTools,createEditTool,createEditToolDefinition,createEventBus,createExtensionRuntime,createFindTool,createFindToolDefinition,createGrepTool,createGrepToolDefinition,createHostDaemonPaths,createLocalBashOperations,createLsTool,createLsToolDefinition,createPowerShellTool,createReadOnlyTools,createReadTool,createReadToolDefinition,createSyntheticSourceInfo,createWriteTool,createWriteToolDefinition,decideHostAction,defineTool,detectSupportedImageMimeTypeFromFile,discoverAndLoadExtensions,engineBuildIdentity,engineBuildIdentityFrom,ensureHost,estimateTokens,findCutPoint,findTurnStartIndex,formatDimensionNote,formatSize,formatSkillsForPrompt,generateBranchSummary,generateDiffString,generateSummary,generateSummaryWithUsage,generateUnifiedPatch,getAgentDir,getDocsPath,getExamplesPath,getLanguageFromPath,getLastAssistantUsage,getLatestCompactionEntry,getMarkdownTheme,getPackageDir,getPowerShellConfig,getReadmePath,getSelectListTheme,getSettingsListTheme,getShellConfig,handoffHost,hasTrustRequiringProjectResources,highlightCode,initTheme,isBashToolResult,isEditToolResult,isFindToolResult,isGrepToolResult,isLsToolResult,isPowerShellToolResult,isReadToolResult,isToolCallEventType,isTransportGoneError,isWriteToolResult,kernelToolsStorage,keyHint,keyText,loadHostLaunchSpec,loadProjectContextFiles,loadSkills,loadSkillsFromDir,main,migrateSessionEntries,noticeEntryRenderer,noticeMessageRenderer,parseArgs,parseFrontmatter,parseHostLaunchSpec,parseHostProtocolInfo,parseSessionEntries,parseSkillBlock,prepareBranchEntries,probeHost,rawKeyHint,readHostStatus,readStoredCredential,registerReadClassifier,renderDiff,resizeImage,resolveCliModel,resolveModelScopeWithDiagnostics,runHostCommand,runHostRequest,runPrintMode,runRpcMode,sanitizeTerminalLabel,serializeConversation,sessionEntryToContextMessages,shouldCompact,stopHost,stripFrontmatter,truncateHead,truncateLine,truncateTail,truncateToVisualLines,withFileMutationQueue,wrapRegisteredTool,wrapRegisteredTools};
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url); { const __piWorkerThreads = require("node:worker_threads"); if (typeof __piWorkerThreads.markAsUncloneable !== "function") { __piWorkerThreads.markAsUncloneable = () => {}; } }
3
- import{main}from"./chunks/chunk-6SLQ5HFO.js";import"./chunks/chunk-ZKZAATFM.js";import"./chunks/chunk-UYCGOK6M.js";import"./chunks/chunk-6WBYI25N.js";import"./chunks/chunk-67BC7VZV.js";import"./chunks/chunk-YS5YEX4S.js";import"./chunks/chunk-2L26KPZ6.js";import"./chunks/chunk-77ACEMYL.js";import"./chunks/chunk-EJKCBRYK.js";import"./chunks/chunk-6Q6DGME2.js";import{configureHttpDispatcher}from"./chunks/chunk-WM5FVFAP.js";import"./chunks/chunk-YU2P3CAR.js";import"./chunks/chunk-BMX2U22F.js";import"./chunks/chunk-6W2DB2GC.js";import"./chunks/chunk-LPFZGWG2.js";import"./chunks/chunk-HH3KJDWA.js";import"./chunks/chunk-3CC5ZOBV.js";import"./chunks/chunk-XKLR7C5B.js";import"./chunks/chunk-FIJJKSPL.js";import"./chunks/chunk-H4QOEVS5.js";import"./chunks/chunk-HB35RBP4.js";import"./chunks/chunk-HZAKOVHN.js";import"./chunks/chunk-TTY5BHCG.js";import"./chunks/chunk-FHXKBENX.js";import"./chunks/chunk-X3T45623.js";import"./chunks/chunk-7X72IACK.js";import"./chunks/chunk-KUPQO7MC.js";import"./chunks/chunk-HPY47AVX.js";import"./chunks/chunk-SUQDU5KM.js";import"./chunks/chunk-7FXXRPB3.js";import"./chunks/chunk-26UBFF6N.js";import"./chunks/chunk-KMJXSXRX.js";import"./chunks/chunk-L6JO4M6J.js";import"./chunks/chunk-RFB5CBW7.js";import"./chunks/chunk-2VZJTDUX.js";import"./chunks/chunk-ELFCNCBY.js";import"./chunks/chunk-PRC5XIIH.js";import"./chunks/chunk-W3D3ZYDS.js";import"./chunks/chunk-ZOFZRJSL.js";import"./chunks/chunk-2SOVDETB.js";import{APP_NAME,scrubBrandFromEnvironment}from"./chunks/chunk-Y65WFI5H.js";import"./chunks/chunk-ATQFN5HI.js";import"./chunks/chunk-RBCQOIAD.js";import"./chunks/chunk-WASCMT6Y.js";import"./chunks/chunk-X4Q5YSTE.js";import"./chunks/chunk-IXAUDPOK.js";import"./chunks/chunk-TTHMOL5G.js";import"./chunks/chunk-WVGCQOLJ.js";import"./chunks/chunk-BPX6QWPD.js";import"./chunks/chunk-WL5EQYNL.js";import"./chunks/chunk-WDTJ6JKE.js";import"./chunks/chunk-5ROMKDLK.js";import"./chunks/chunk-3W47LTXQ.js";import"./chunks/chunk-DMI55M2N.js";import"./chunks/chunk-BQVVQ2LQ.js";import"./chunks/chunk-IKOFCODM.js";process.title=`${APP_NAME}-rpc`;scrubBrandFromEnvironment();process.env.PI_CODING_AGENT="true";process.env.AI_AGENT=APP_NAME;process.emitWarning=(()=>{});configureHttpDispatcher();main(["--mode","rpc",...process.argv.slice(2)]);
3
+ import{main}from"./chunks/chunk-RYI6XR6Z.js";import"./chunks/chunk-LDB5UMH2.js";import"./chunks/chunk-ELM77A26.js";import"./chunks/chunk-6WBYI25N.js";import"./chunks/chunk-OZN2KUPR.js";import"./chunks/chunk-YS5YEX4S.js";import"./chunks/chunk-3SIQIY57.js";import"./chunks/chunk-6J6RDMBY.js";import"./chunks/chunk-EJKCBRYK.js";import"./chunks/chunk-NMDALHXH.js";import{configureHttpDispatcher}from"./chunks/chunk-QPZVJQC5.js";import"./chunks/chunk-YU2P3CAR.js";import"./chunks/chunk-BMX2U22F.js";import"./chunks/chunk-RULGEHQM.js";import"./chunks/chunk-Y7EIVDHZ.js";import"./chunks/chunk-HH3KJDWA.js";import"./chunks/chunk-NNILBBOH.js";import"./chunks/chunk-XKLR7C5B.js";import"./chunks/chunk-FIJJKSPL.js";import"./chunks/chunk-H4QOEVS5.js";import"./chunks/chunk-HB35RBP4.js";import"./chunks/chunk-LGKKU4VM.js";import"./chunks/chunk-H2SGCPMD.js";import"./chunks/chunk-FHXKBENX.js";import"./chunks/chunk-QK4QKRTF.js";import"./chunks/chunk-7X72IACK.js";import"./chunks/chunk-KUPQO7MC.js";import"./chunks/chunk-QYAO24GB.js";import"./chunks/chunk-OQRUK2DK.js";import"./chunks/chunk-7FXXRPB3.js";import"./chunks/chunk-26UBFF6N.js";import"./chunks/chunk-357I4IUU.js";import"./chunks/chunk-GZVCRV7I.js";import"./chunks/chunk-U3VOXCGP.js";import"./chunks/chunk-RFB5CBW7.js";import"./chunks/chunk-2VZJTDUX.js";import"./chunks/chunk-ELFCNCBY.js";import"./chunks/chunk-PRC5XIIH.js";import"./chunks/chunk-W3D3ZYDS.js";import"./chunks/chunk-ZOFZRJSL.js";import"./chunks/chunk-2SOVDETB.js";import{APP_NAME,scrubBrandFromEnvironment}from"./chunks/chunk-Y65WFI5H.js";import"./chunks/chunk-ATQFN5HI.js";import"./chunks/chunk-RBCQOIAD.js";import"./chunks/chunk-WASCMT6Y.js";import"./chunks/chunk-X4Q5YSTE.js";import"./chunks/chunk-IXAUDPOK.js";import"./chunks/chunk-L6QV7NZI.js";import"./chunks/chunk-45SZOLCU.js";import"./chunks/chunk-WVGCQOLJ.js";import"./chunks/chunk-BPX6QWPD.js";import"./chunks/chunk-WL5EQYNL.js";import"./chunks/chunk-WDTJ6JKE.js";import"./chunks/chunk-5ROMKDLK.js";import"./chunks/chunk-3W47LTXQ.js";import"./chunks/chunk-DMI55M2N.js";import"./chunks/chunk-BQVVQ2LQ.js";import"./chunks/chunk-IKOFCODM.js";process.title=`${APP_NAME}-rpc`;scrubBrandFromEnvironment();process.env.PI_CODING_AGENT="true";process.env.AI_AGENT=APP_NAME;process.emitWarning=(()=>{});configureHttpDispatcher();main(["--mode","rpc",...process.argv.slice(2)]);
@@ -0,0 +1,15 @@
1
+ import { type MovedSessionOptions } from "../core/moved-sessions.ts";
2
+ export interface ContinueMovedChoice extends MovedSessionOptions {
3
+ readonly cwd: string;
4
+ readonly interactive: boolean;
5
+ readonly confirm: (message: string) => Promise<boolean>;
6
+ readonly out: (line: string) => void;
7
+ readonly err: (line: string) => void;
8
+ }
9
+ /**
10
+ * `--continue` in a project with no session of its own: the newest session this repository recorded
11
+ * before it moved is offered for the #2182 rebind. Returns its path when the user accepts; without an
12
+ * interactive session nothing is asked and the `--rebind` command is printed instead.
13
+ */
14
+ export declare function movedSessionToContinue(choice: ContinueMovedChoice): Promise<string | undefined>;
15
+ //# sourceMappingURL=continue-moved.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"continue-moved.d.ts","sourceRoot":"","sources":["../../src/cli/continue-moved.ts"],"names":[],"mappings":"AACA,OAAO,EAAqB,KAAK,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAGxF,MAAM,WAAW,mBAAoB,SAAQ,mBAAmB;IAC/D,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACxD,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACrC;AAED;;;;GAIG;AACH,wBAAsB,sBAAsB,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAmBrG"}
@@ -0,0 +1,26 @@
1
+ import chalk from "chalk";
2
+ import { listMovedSessions } from "../core/moved-sessions.js";
3
+ import { confirmSameRepositoryRebind } from "./cross-project-session.js";
4
+ /**
5
+ * `--continue` in a project with no session of its own: the newest session this repository recorded
6
+ * before it moved is offered for the #2182 rebind. Returns its path when the user accepts; without an
7
+ * interactive session nothing is asked and the `--rebind` command is printed instead.
8
+ */
9
+ export async function movedSessionToContinue(choice) {
10
+ const [newest] = await listMovedSessions(choice.cwd, choice);
11
+ if (newest === undefined)
12
+ return undefined;
13
+ if (!choice.interactive) {
14
+ choice.err(chalk.yellow(`A session of this repository was recorded at ${newest.cwd} before it moved. Use --rebind '${newest.id}' to continue it here.`));
15
+ return undefined;
16
+ }
17
+ choice.out(chalk.yellow(`Session found in different project: ${newest.cwd}`));
18
+ const accepted = await confirmSameRepositoryRebind({
19
+ sessionArg: newest.id,
20
+ cwd: choice.cwd,
21
+ confirm: choice.confirm,
22
+ out: choice.out,
23
+ });
24
+ return accepted ? newest.path : undefined;
25
+ }
26
+ //# sourceMappingURL=continue-moved.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"continue-moved.js","sourceRoot":"","sources":["../../src/cli/continue-moved.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAA4B,MAAM,2BAA2B,CAAC;AACxF,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AAUzE;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,MAA2B;IACvE,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,iBAAiB,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAC7D,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC3C,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;QACzB,MAAM,CAAC,GAAG,CACT,KAAK,CAAC,MAAM,CACX,gDAAgD,MAAM,CAAC,GAAG,mCAAmC,MAAM,CAAC,EAAE,wBAAwB,CAC9H,CACD,CAAC;QACF,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,uCAAuC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IAC9E,MAAM,QAAQ,GAAG,MAAM,2BAA2B,CAAC;QAClD,UAAU,EAAE,MAAM,CAAC,EAAE;QACrB,GAAG,EAAE,MAAM,CAAC,GAAG;QACf,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,GAAG,EAAE,MAAM,CAAC,GAAG;KACf,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;AAC3C,CAAC","sourcesContent":["import chalk from \"chalk\";\nimport { listMovedSessions, type MovedSessionOptions } from \"../core/moved-sessions.ts\";\nimport { confirmSameRepositoryRebind } from \"./cross-project-session.ts\";\n\nexport interface ContinueMovedChoice extends MovedSessionOptions {\n\treadonly cwd: string;\n\treadonly interactive: boolean;\n\treadonly confirm: (message: string) => Promise<boolean>;\n\treadonly out: (line: string) => void;\n\treadonly err: (line: string) => void;\n}\n\n/**\n * `--continue` in a project with no session of its own: the newest session this repository recorded\n * before it moved is offered for the #2182 rebind. Returns its path when the user accepts; without an\n * interactive session nothing is asked and the `--rebind` command is printed instead.\n */\nexport async function movedSessionToContinue(choice: ContinueMovedChoice): Promise<string | undefined> {\n\tconst [newest] = await listMovedSessions(choice.cwd, choice);\n\tif (newest === undefined) return undefined;\n\tif (!choice.interactive) {\n\t\tchoice.err(\n\t\t\tchalk.yellow(\n\t\t\t\t`A session of this repository was recorded at ${newest.cwd} before it moved. Use --rebind '${newest.id}' to continue it here.`,\n\t\t\t),\n\t\t);\n\t\treturn undefined;\n\t}\n\tchoice.out(chalk.yellow(`Session found in different project: ${newest.cwd}`));\n\tconst accepted = await confirmSameRepositoryRebind({\n\t\tsessionArg: newest.id,\n\t\tcwd: choice.cwd,\n\t\tconfirm: choice.confirm,\n\t\tout: choice.out,\n\t});\n\treturn accepted ? newest.path : undefined;\n}\n"]}
@@ -76,8 +76,11 @@ export declare class AgentSessionRuntime {
76
76
  private _diagnostics;
77
77
  private _modelFallbackMessage?;
78
78
  private readonly _launchProfile?;
79
+ private _sessionHold?;
79
80
  private _removedOnReplacement?;
80
81
  constructor(_session: AgentSession, _services: AgentSessionServices, createRuntime: CreateAgentSessionRuntimeFactory, _diagnostics?: AgentSessionRuntimeDiagnostic[], _modelFallbackMessage?: string, launchProfile?: Readonly<AgentSessionLaunchProfile>);
82
+ /** Stops advertising the open session to other processes; a runtime that replaces this one holds its own. */
83
+ releaseSessionHold(): void;
81
84
  get services(): AgentSessionServices;
82
85
  get session(): AgentSession;
83
86
  get cwd(): string;
@@ -1 +1 @@
1
- {"version":3,"file":"agent-session-runtime.d.ts","sourceRoot":"","sources":["../../src/core/agent-session-runtime.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;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AC,yBAAyB,CAAC,CAAC;CACpD,GACC,OAAO,CAAC,mBAAmB,CAAC,CAW9B;AAED,OAAO,EACN,KAAK,6BAA6B,EAClC,KAAK,oBAAoB,EACzB,KAAK,qCAAqC,EAC1C,KAAK,iCAAiC,EACtC,8BAA8B,EAC9B,0BAA0B,GAC1B,MAAM,6BAA6B,CAAC"}
@@ -3,6 +3,7 @@ import { basename, join, parse, resolve } from "node:path";
3
3
  import { resolvePath } from "../utils/paths.js";
4
4
  import { emitSessionShutdownEvent } from "./extensions/runner.js";
5
5
  import { assertSessionCwdExists } from "./session-cwd.js";
6
+ import { holdSessionFile } from "./session-holders.js";
6
7
  import { SessionManager } from "./session-manager.js";
7
8
  import { reserveSessionWrite, unregisterSessionWriter } from "./session-write-reservation.js";
8
9
  import { resetTimings, time } from "./timings.js";
@@ -40,6 +41,12 @@ export class AgentSessionRuntime {
40
41
  this._diagnostics = _diagnostics;
41
42
  this._modelFallbackMessage = _modelFallbackMessage;
42
43
  this._launchProfile = launchProfile;
44
+ this._sessionHold = holdActiveSession(_session.sessionManager, wasFlushed(_session.sessionManager));
45
+ }
46
+ /** Stops advertising the open session to other processes; a runtime that replaces this one holds its own. */
47
+ releaseSessionHold() {
48
+ this._sessionHold?.release();
49
+ this._sessionHold = undefined;
43
50
  }
44
51
  get services() {
45
52
  return this._services;
@@ -134,6 +141,7 @@ export class AgentSessionRuntime {
134
141
  // Nothing writes to the replaced manager once its session is disposed, so the
135
142
  // shared host may hand its session file to another worker.
136
143
  unregisterSessionWriter(replaced);
144
+ this.releaseSessionHold();
137
145
  mark("dispose");
138
146
  }
139
147
  async reportRemovedExtensions() {
@@ -150,7 +158,8 @@ export class AgentSessionRuntime {
150
158
  return;
151
159
  await pending.oldRunner.emit({ type: "session_extensions_removed", reason: pending.reason, removed });
152
160
  }
153
- async apply(result) {
161
+ async apply(result, hold) {
162
+ this._sessionHold = hold ?? holdActiveSession(result.session.sessionManager, false);
154
163
  this._session = result.session;
155
164
  this._services = result.services;
156
165
  this._diagnostics = result.diagnostics;
@@ -175,16 +184,25 @@ export class AgentSessionRuntime {
175
184
  const previousSessionFile = this.session.sessionFile;
176
185
  const sessionManager = SessionManager.open(sessionPath, undefined, options?.cwdOverride);
177
186
  assertSessionCwdExists(sessionManager, this.cwd);
187
+ // Held before the current session is torn down: a session being moved fails the switch here.
188
+ const hold = holdActiveSession(sessionManager, wasFlushed(sessionManager));
178
189
  time("open", "switch");
179
- await this.teardownCurrent("resume", sessionManager.getSessionFile());
180
- await this.apply(await this.createRuntime({
181
- cwd: sessionManager.getCwd(),
182
- agentDir: this.services.agentDir,
183
- sessionManager,
184
- sessionStartEvent: { type: "session_start", reason: "resume", previousSessionFile },
185
- projectTrustContext: options?.projectTrustContextFactory?.(sessionManager.getCwd()),
186
- launchProfile: this._launchProfile,
187
- }));
190
+ try {
191
+ await this.teardownCurrent("resume", sessionManager.getSessionFile());
192
+ await this.apply(await this.createRuntime({
193
+ cwd: sessionManager.getCwd(),
194
+ agentDir: this.services.agentDir,
195
+ sessionManager,
196
+ sessionStartEvent: { type: "session_start", reason: "resume", previousSessionFile },
197
+ projectTrustContext: options?.projectTrustContextFactory?.(sessionManager.getCwd()),
198
+ launchProfile: this._launchProfile,
199
+ }), hold);
200
+ }
201
+ catch (error) {
202
+ if (this._sessionHold !== hold)
203
+ hold?.release();
204
+ throw error;
205
+ }
188
206
  time("apply", "switch");
189
207
  await this.finishSessionReplacement(options?.withSession);
190
208
  time("rebind", "switch");
@@ -352,8 +370,23 @@ export class AgentSessionRuntime {
352
370
  });
353
371
  this.beforeSessionInvalidate?.();
354
372
  this.session.dispose();
373
+ this.releaseSessionHold();
355
374
  }
356
375
  }
376
+ // A persisted session is written to disk with its first assistant message, so one that has an
377
+ // assistant message and no file was moved away after it was read.
378
+ function wasFlushed(sessionManager) {
379
+ return sessionManager.getEntries().some((entry) => entry.type === "message" && entry.message.role === "assistant");
380
+ }
381
+ function holdActiveSession(sessionManager, expectExisting) {
382
+ const sessionFile = sessionManager.getSessionFile();
383
+ if (!sessionManager.isPersisted() || sessionFile === undefined)
384
+ return undefined;
385
+ return holdSessionFile(sessionFile, sessionManager.getSessionId(), {
386
+ cwd: sessionManager.getCwd(),
387
+ expectExisting,
388
+ });
389
+ }
357
390
  /**
358
391
  * Create the initial runtime from a runtime factory and initial session target.
359
392
  *
@@ -1 +1 @@
1
- {"version":3,"file":"agent-session-runtime.js","sourceRoot":"","sources":["../../src/core/agent-session-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAYhD,OAAO,EAAwB,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAExF,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAC9F,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAmDlD;;GAEG;AACH,MAAM,OAAO,8BAA+B,SAAQ,KAAK;IAGxD,YAAY,QAAgB;QAC3B,KAAK,CAAC,mBAAmB,QAAQ,EAAE,CAAC,CAAC;QACrC,IAAI,CAAC,IAAI,GAAG,gCAAgC,CAAC;QAC7C,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC1B,CAAC;CACD;AAED,SAAS,sBAAsB,CAAC,OAAwD;IACvF,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QACjC,OAAO,OAAO,CAAC;IAChB,CAAC;IAED,OAAO,OAAO;SACZ,MAAM,CAAC,CAAC,IAAI,EAA0C,EAAE,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AuB,EAAE,EAAE,CAAC;QACjC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;IACxB,CAAC;CACD;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC9C,aAA+C,EAC/C,OAMC;IAED,sBAAsB,CAAC,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;IAC5D,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,OAAO,CAAC,CAAC;IAC5C,OAAO,IAAI,mBAAmB,CAC7B,MAAM,CAAC,OAAO,EACd,MAAM,CAAC,QAAQ,EACf,aAAa,EACb,MAAM,CAAC,WAAW,EAClB,MAAM,CAAC,oBAAoB,EAC3B,OAAO,CAAC,aAAa,CACrB,CAAC;AACH,CAAC;AAED,OAAO,EAKN,8BAA8B,EAC9B,0BAA0B,GAC1B,MAAM,6BAA6B,CAAC","sourcesContent":["import { constants, copyFileSync, existsSync, mkdirSync } from \"node:fs\";\nimport { basename, join, parse, resolve } from \"node:path\";\nimport { resolvePath } from \"../utils/paths.ts\";\nimport type { AgentSession } from \"./agent-session.ts\";\nimport type { AgentSessionRuntimeDiagnostic, AgentSessionServices } from \"./agent-session-services.ts\";\nimport type { HostMcpRegistry } from \"./extensions/builtin/mcp/host-registry.ts\";\nimport type {\n\tProjectTrustContext,\n\tReplacedSessionContext,\n\tSessionContext,\n\tSessionKind,\n\tSessionShutdownEvent,\n\tSessionStartEvent,\n} from \"./extensions/index.ts\";\nimport { type ExtensionRunner, emitSessionShutdownEvent } from \"./extensions/runner.ts\";\nimport type { CreateAgentSessionResult } from \"./sdk.ts\";\nimport { assertSessionCwdExists } from \"./session-cwd.ts\";\nimport { SessionManager } from \"./session-manager.ts\";\nimport { reserveSessionWrite, unregisterSessionWriter } from \"./session-write-reservation.ts\";\nimport { resetTimings, time } from \"./timings.ts\";\n\n/**\n * Result returned by runtime creation.\n *\n * The caller gets the created session, its cwd-bound services, and all\n * diagnostics collected during setup.\n */\nexport interface CreateAgentSessionRuntimeResult extends CreateAgentSessionResult {\n\tservices: AgentSessionServices;\n\tdiagnostics: AgentSessionRuntimeDiagnostic[];\n}\n\n/** Immutable flags selected when a runtime is first launched. */\nexport interface AgentSessionLaunchProfile {\n\tcwd: string;\n\tpermissionPreset?: string;\n\tcreationModel?: { provider: string; modelId: string };\n\tinitialThinkingLevel?: string;\n\t/**\n\t * Visibility class of this session (`open_session.kind`), absent for classic\n\t * launches. It reaches the extensions this session loads and nothing else: it\n\t * never takes part in auth, model or resource resolution.\n\t */\n\tsessionKind?: SessionKind;\n\t/** Opaque labels the opener attached (`open_session.context`), absent when none. */\n\tsessionContext?: SessionContext;\n\t/**\n\t * Per-session auto-titling (`open_session.auto_title`). When set, this session\n\t * ignores the host-wide `--auto-title-sessions` / appMode default.\n\t */\n\tautoTitle?: boolean;\n}\n\n/**\n * Creates a full runtime for a target cwd and session manager.\n *\n * The factory closes over process-global fixed inputs, recreates cwd-bound\n * services for the effective cwd, resolves session options against those\n * services, and finally creates the AgentSession.\n */\nexport type CreateAgentSessionRuntimeFactory = (options: {\n\tcwd: string;\n\tagentDir: string;\n\tmcpRegistry?: HostMcpRegistry;\n\tsessionManager: SessionManager;\n\tsessionStartEvent?: SessionStartEvent;\n\tprojectTrustContext?: ProjectTrustContext;\n\tlaunchProfile?: Readonly<AgentSessionLaunchProfile>;\n}) => Promise<CreateAgentSessionRuntimeResult>;\n\n/**\n * Thrown when /import references a JSONL file path that does not exist.\n */\nexport class SessionImportFileNotFoundError extends Error {\n\treadonly filePath: string;\n\n\tconstructor(filePath: string) {\n\t\tsuper(`File not found: ${filePath}`);\n\t\tthis.name = \"SessionImportFileNotFoundError\";\n\t\tthis.filePath = filePath;\n\t}\n}\n\nfunction extractUserMessageText(content: string | Array<{ type: string; text?: string }>): string {\n\tif (typeof content === \"string\") {\n\t\treturn content;\n\t}\n\n\treturn content\n\t\t.filter((part): part is { type: \"text\"; text: string } => part.type === \"text\" && typeof part.text === \"string\")\n\t\t.map((part) => part.text)\n\t\t.join(\"\");\n}\n\n/**\n * Owns the current AgentSession plus its cwd-bound services.\n *\n * Session replacement methods tear down the current runtime first, then create\n * and apply the next runtime. If creation fails, the error is propagated to the\n * caller. The caller is responsible for user-facing error handling.\n */\nexport class AgentSessionRuntime {\n\tprivate rebindSession?: (session: AgentSession) => Promise<void>;\n\tprivate beforeSessionInvalidate?: () => void;\n\tprivate _session: AgentSession;\n\tprivate _services: AgentSessionServices;\n\tprivate readonly createRuntime: CreateAgentSessionRuntimeFactory;\n\tprivate _diagnostics: AgentSessionRuntimeDiagnostic[];\n\tprivate _modelFallbackMessage?: string;\n\tprivate readonly _launchProfile?: Readonly<AgentSessionLaunchProfile>;\n\tprivate _removedOnReplacement?: {\n\t\toldRunner: ExtensionRunner;\n\t\toldIdentities: Array<{ path: string; resolvedPath: string }>;\n\t\treason: SessionShutdownEvent[\"reason\"];\n\t};\n\n\tconstructor(\n\t\t_session: AgentSession,\n\t\t_services: AgentSessionServices,\n\t\tcreateRuntime: CreateAgentSessionRuntimeFactory,\n\t\t_diagnostics: AgentSessionRuntimeDiagnostic[] = [],\n\t\t_modelFallbackMessage?: string,\n\t\tlaunchProfile?: Readonly<AgentSessionLaunchProfile>,\n\t) {\n\t\tthis._session = _session;\n\t\tthis._services = _services;\n\t\tthis.createRuntime = createRuntime;\n\t\tthis._diagnostics = _diagnostics;\n\t\tthis._modelFallbackMessage = _modelFallbackMessage;\n\t\tthis._launchProfile = launchProfile;\n\t}\n\n\tget services(): AgentSessionServices {\n\t\treturn this._services;\n\t}\n\n\tget session(): AgentSession {\n\t\treturn this._session;\n\t}\n\n\tget cwd(): string {\n\t\treturn this._services.cwd;\n\t}\n\n\tget diagnostics(): readonly AgentSessionRuntimeDiagnostic[] {\n\t\treturn this._diagnostics;\n\t}\n\n\tget modelFallbackMessage(): string | undefined {\n\t\treturn this._modelFallbackMessage;\n\t}\n\n\tget launchProfile(): Readonly<AgentSessionLaunchProfile> | undefined {\n\t\treturn this._launchProfile;\n\t}\n\n\tsetRebindSession(rebindSession?: (session: AgentSession) => Promise<void>): void {\n\t\tthis.rebindSession = rebindSession;\n\t}\n\n\t/**\n\t * Set a synchronous callback that runs after `session_shutdown` handlers finish\n\t * but before the current session is invalidated.\n\t *\n\t * This is for host-owned UI teardown that must not yield to the event loop,\n\t * such as detaching extension-provided TUI components before the old extension\n\t * context becomes stale.\n\t */\n\tsetBeforeSessionInvalidate(beforeSessionInvalidate?: () => void): void {\n\t\tthis.beforeSessionInvalidate = beforeSessionInvalidate;\n\t}\n\n\t/** Attachment transitions are ordered by the RPC entry's lifecycle mutex. */\n\tasync emitAttachmentEvent(type: \"session_parked\" | \"session_resumed\"): Promise<void> {\n\t\tconst runner = this.session.extensionRunner;\n\t\tif (runner.hasHandlers(type)) await runner.emit({ type });\n\t}\n\n\tprivate async emitBeforeSwitch(\n\t\treason: \"new\" | \"resume\",\n\t\ttargetSessionFile?: string,\n\t): Promise<{ cancelled: boolean }> {\n\t\tconst runner = this.session.extensionRunner;\n\t\tif (!runner.hasHandlers(\"session_before_switch\")) {\n\t\t\treturn { cancelled: false };\n\t\t}\n\n\t\tconst result = await runner.emit({\n\t\t\ttype: \"session_before_switch\",\n\t\t\treason,\n\t\t\ttargetSessionFile,\n\t\t});\n\t\treturn { cancelled: result?.cancel === true };\n\t}\n\n\tprivate async emitBeforeFork(\n\t\tentryId: string,\n\t\toptions: { position: \"before\" | \"at\" },\n\t): Promise<{ cancelled: boolean }> {\n\t\tconst runner = this.session.extensionRunner;\n\t\tif (!runner.hasHandlers(\"session_before_fork\")) {\n\t\t\treturn { cancelled: false };\n\t\t}\n\n\t\tconst result = await runner.emit({\n\t\t\ttype: \"session_before_fork\",\n\t\t\tentryId,\n\t\t\t...options,\n\t\t});\n\t\treturn { cancelled: result?.cancel === true };\n\t}\n\n\tprivate async teardownCurrent(reason: SessionShutdownEvent[\"reason\"], targetSessionFile?: string): Promise<void> {\n\t\tconst mark = (label: string): void => {\n\t\t\tif (reason === \"resume\") time(label, \"switch\");\n\t\t};\n\t\t// Settle the active response before replacement so the outgoing turn and\n\t\t// any completed tool results are persisted to the old session.\n\t\tawait this.session.abort();\n\t\tmark(\"abort\");\n\t\tconst oldRunner = this.session.extensionRunner;\n\t\t// Test hosts and partial runner implementations may lack identity introspection;\n\t\t// skip removal reporting there rather than break the replacement itself.\n\t\tif (typeof oldRunner.getExtensionIdentities === \"function\") {\n\t\t\tthis._removedOnReplacement = {\n\t\t\t\toldRunner,\n\t\t\t\toldIdentities: oldRunner.getExtensionIdentities(),\n\t\t\t\treason,\n\t\t\t};\n\t\t}\n\t\tawait emitSessionShutdownEvent(oldRunner, {\n\t\t\ttype: \"session_shutdown\",\n\t\t\treason,\n\t\t\ttargetSessionFile,\n\t\t});\n\t\tmark(\"shutdown\");\n\t\tthis.beforeSessionInvalidate?.();\n\t\tconst replaced = this.session.sessionManager;\n\t\tthis.session.dispose();\n\t\t// Nothing writes to the replaced manager once its session is disposed, so the\n\t\t// shared host may hand its session file to another worker.\n\t\tunregisterSessionWriter(replaced);\n\t\tmark(\"dispose\");\n\t}\n\n\tprivate async reportRemovedExtensions(): Promise<void> {\n\t\tconst pending = this._removedOnReplacement;\n\t\tthis._removedOnReplacement = undefined;\n\t\tif (!pending) return;\n\t\tconst newRunner = this.session.extensionRunner;\n\t\tif (typeof newRunner.getExtensionIdentities !== \"function\") return;\n\t\tconst newResolvedPaths = new Set(newRunner.getExtensionIdentities().map((extension) => extension.resolvedPath));\n\t\tconst removed = pending.oldIdentities.filter((extension) => !newResolvedPaths.has(extension.resolvedPath));\n\t\tif (removed.length === 0) return;\n\t\tawait pending.oldRunner.emit({ type: \"session_extensions_removed\", reason: pending.reason, removed });\n\t}\n\n\tprivate async apply(result: CreateAgentSessionRuntimeResult): Promise<void> {\n\t\tthis._session = result.session;\n\t\tthis._services = result.services;\n\t\tthis._diagnostics = result.diagnostics;\n\t\tthis._modelFallbackMessage = result.modelFallbackMessage;\n\t\tawait this.reportRemovedExtensions();\n\t}\n\n\tprivate async finishSessionReplacement(withSession?: (ctx: ReplacedSessionContext) => Promise<void>): Promise<void> {\n\t\tif (this.rebindSession) {\n\t\t\tawait this.rebindSession(this.session);\n\t\t}\n\t\tif (withSession) {\n\t\t\tawait withSession(this.session.createReplacedSessionContext());\n\t\t}\n\t}\n\n\tasync switchSession(\n\t\tsessionPath: string,\n\t\toptions?: {\n\t\t\tcwdOverride?: string;\n\t\t\twithSession?: (ctx: ReplacedSessionContext) => Promise<void>;\n\t\t\tprojectTrustContextFactory?: (cwd: string) => ProjectTrustContext;\n\t\t},\n\t): Promise<{ cancelled: boolean }> {\n\t\tresetTimings(\"switch\");\n\t\tconst beforeResult = await this.emitBeforeSwitch(\"resume\", sessionPath);\n\t\tif (beforeResult.cancelled) {\n\t\t\treturn beforeResult;\n\t\t}\n\t\ttime(\"beforeSwitch\", \"switch\");\n\n\t\tconst previousSessionFile = this.session.sessionFile;\n\t\tconst sessionManager = SessionManager.open(sessionPath, undefined, options?.cwdOverride);\n\t\tassertSessionCwdExists(sessionManager, this.cwd);\n\t\ttime(\"open\", \"switch\");\n\t\tawait this.teardownCurrent(\"resume\", sessionManager.getSessionFile());\n\t\tawait this.apply(\n\t\t\tawait this.createRuntime({\n\t\t\t\tcwd: sessionManager.getCwd(),\n\t\t\t\tagentDir: this.services.agentDir,\n\t\t\t\tsessionManager,\n\t\t\t\tsessionStartEvent: { type: \"session_start\", reason: \"resume\", previousSessionFile },\n\t\t\t\tprojectTrustContext: options?.projectTrustContextFactory?.(sessionManager.getCwd()),\n\t\t\t\tlaunchProfile: this._launchProfile,\n\t\t\t}),\n\t\t);\n\t\ttime(\"apply\", \"switch\");\n\t\tawait this.finishSessionReplacement(options?.withSession);\n\t\ttime(\"rebind\", \"switch\");\n\t\treturn { cancelled: false };\n\t}\n\n\tasync newSession(options?: {\n\t\tparentSession?: string;\n\t\tsetup?: (sessionManager: SessionManager) => Promise<void>;\n\t\twithSession?: (ctx: ReplacedSessionContext) => Promise<void>;\n\t}): Promise<{ cancelled: boolean }> {\n\t\tconst beforeResult = await this.emitBeforeSwitch(\"new\");\n\t\tif (beforeResult.cancelled) {\n\t\t\treturn beforeResult;\n\t\t}\n\n\t\tconst previousSessionFile = this.session.sessionFile;\n\t\tconst sessionDir = this.session.sessionManager.getSessionDir();\n\t\tconst sessionManager = this.session.sessionManager.isPersisted()\n\t\t\t? SessionManager.create(this.cwd, sessionDir)\n\t\t\t: SessionManager.inMemory(this.cwd);\n\t\tif (options?.parentSession) {\n\t\t\tsessionManager.newSession({ parentSession: options.parentSession });\n\t\t}\n\n\t\tawait this.teardownCurrent(\"new\", sessionManager.getSessionFile());\n\t\tawait this.apply(\n\t\t\tawait this.createRuntime({\n\t\t\t\tcwd: this.cwd,\n\t\t\t\tagentDir: this.services.agentDir,\n\t\t\t\tsessionManager,\n\t\t\t\tsessionStartEvent: { type: \"session_start\", reason: \"new\", previousSessionFile },\n\t\t\t\tlaunchProfile: this._launchProfile,\n\t\t\t}),\n\t\t);\n\t\tif (options?.setup) {\n\t\t\tawait options.setup(this.session.sessionManager);\n\t\t\tthis.session.agent.state.messages = this.session.sessionManager.buildSessionContext().messages;\n\t\t}\n\t\tawait this.finishSessionReplacement(options?.withSession);\n\t\treturn { cancelled: false };\n\t}\n\n\tasync fork(\n\t\tentryId: string,\n\t\toptions?: { position?: \"before\" | \"at\"; withSession?: (ctx: ReplacedSessionContext) => Promise<void> },\n\t): Promise<{ cancelled: boolean; selectedText?: string }> {\n\t\tconst position = options?.position ?? \"before\";\n\t\tconst beforeResult = await this.emitBeforeFork(entryId, { position });\n\t\tif (beforeResult.cancelled) {\n\t\t\treturn { cancelled: true };\n\t\t}\n\t\tlet targetLeafId: string | null;\n\t\tlet selectedText: string | undefined;\n\n\t\tconst selectedEntry = this.session.sessionManager.getEntry(entryId);\n\t\tif (!selectedEntry) {\n\t\t\tthrow new Error(\"Invalid entry ID for forking\");\n\t\t}\n\n\t\tif (position === \"at\") {\n\t\t\ttargetLeafId = selectedEntry.id;\n\t\t} else {\n\t\t\tif (selectedEntry.type !== \"message\" || selectedEntry.message.role !== \"user\") {\n\t\t\t\tthrow new Error(\"Invalid entry ID for forking\");\n\t\t\t}\n\t\t\ttargetLeafId = selectedEntry.parentId;\n\t\t\tselectedText = extractUserMessageText(selectedEntry.message.content);\n\t\t}\n\n\t\tconst previousSessionFile = this.session.sessionFile;\n\t\tif (this.session.sessionManager.isPersisted()) {\n\t\t\tconst currentSessionFile = this.session.sessionFile;\n\t\t\tif (!currentSessionFile) {\n\t\t\t\tthrow new Error(\"Persisted session is missing a session file\");\n\t\t\t}\n\t\t\tconst sessionDir = this.session.sessionManager.getSessionDir();\n\t\t\tif (!targetLeafId) {\n\t\t\t\tconst sessionManager = SessionManager.create(this.cwd, sessionDir);\n\t\t\t\tsessionManager.newSession({ parentSession: currentSessionFile });\n\t\t\t\tawait this.teardownCurrent(\"fork\", sessionManager.getSessionFile());\n\t\t\t\tawait this.apply(\n\t\t\t\t\tawait this.createRuntime({\n\t\t\t\t\t\tcwd: this.cwd,\n\t\t\t\t\t\tagentDir: this.services.agentDir,\n\t\t\t\t\t\tsessionManager,\n\t\t\t\t\t\tsessionStartEvent: { type: \"session_start\", reason: \"fork\", previousSessionFile },\n\t\t\t\t\t\tlaunchProfile: this._launchProfile,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t\tawait this.finishSessionReplacement(options?.withSession);\n\t\t\t\treturn { cancelled: false, selectedText };\n\t\t\t}\n\n\t\t\tif (!existsSync(currentSessionFile)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"This session has not been saved yet. Wait for the first assistant response before cloning or forking it.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst sessionManager = SessionManager.open(currentSessionFile, sessionDir);\n\t\t\tconst forkedSessionPath = sessionManager.createBranchedSession(targetLeafId);\n\t\t\tif (!forkedSessionPath) {\n\t\t\t\tthrow new Error(\"Failed to create forked session\");\n\t\t\t}\n\t\t\tawait this.teardownCurrent(\"fork\", sessionManager.getSessionFile());\n\t\t\tawait this.apply(\n\t\t\t\tawait this.createRuntime({\n\t\t\t\t\tcwd: sessionManager.getCwd(),\n\t\t\t\t\tagentDir: this.services.agentDir,\n\t\t\t\t\tsessionManager,\n\t\t\t\t\tsessionStartEvent: { type: \"session_start\", reason: \"fork\", previousSessionFile },\n\t\t\t\t\tlaunchProfile: this._launchProfile,\n\t\t\t\t}),\n\t\t\t);\n\t\t\tawait this.finishSessionReplacement(options?.withSession);\n\t\t\treturn { cancelled: false, selectedText };\n\t\t}\n\n\t\tconst sessionManager = this.session.sessionManager;\n\t\tawait this.teardownCurrent(\"fork\", sessionManager.getSessionFile());\n\t\tif (!targetLeafId) {\n\t\t\tsessionManager.newSession({ parentSession: previousSessionFile });\n\t\t} else {\n\t\t\tsessionManager.createBranchedSession(targetLeafId);\n\t\t}\n\t\tawait this.apply(\n\t\t\tawait this.createRuntime({\n\t\t\t\tcwd: this.cwd,\n\t\t\t\tagentDir: this.services.agentDir,\n\t\t\t\tsessionManager,\n\t\t\t\tsessionStartEvent: { type: \"session_start\", reason: \"fork\", previousSessionFile },\n\t\t\t\tlaunchProfile: this._launchProfile,\n\t\t\t}),\n\t\t);\n\t\tawait this.finishSessionReplacement(options?.withSession);\n\t\treturn { cancelled: false, selectedText };\n\t}\n\n\t/**\n\t * Import a session JSONL file and switch runtime state to the imported session.\n\t *\n\t * @returns `{ cancelled: true }` when cancelled by `session_before_switch`, otherwise `{ cancelled: false }`.\n\t * @throws {SessionImportFileNotFoundError} When the input path does not exist.\n\t * @throws {MissingSessionCwdError} When the imported session cwd cannot be resolved and no override is provided.\n\t */\n\tasync importFromJsonl(inputPath: string, cwdOverride?: string): Promise<{ cancelled: boolean }> {\n\t\tconst resolvedPath = resolvePath(inputPath);\n\t\tif (!existsSync(resolvedPath)) {\n\t\t\tthrow new SessionImportFileNotFoundError(resolvedPath);\n\t\t}\n\n\t\tconst sessionDir = this.session.sessionManager.getSessionDir();\n\t\tif (!existsSync(sessionDir)) {\n\t\t\tmkdirSync(sessionDir, { recursive: true });\n\t\t}\n\n\t\tlet destinationPath = join(sessionDir, basename(resolvedPath));\n\t\tconst sourceAlreadyStored = resolve(destinationPath) === resolvedPath;\n\t\tif (!sourceAlreadyStored) {\n\t\t\tconst { name, ext } = parse(destinationPath);\n\t\t\tlet suffix = 1;\n\t\t\twhile (existsSync(destinationPath)) {\n\t\t\t\tdestinationPath = join(sessionDir, `${name}-${suffix++}${ext}`);\n\t\t\t}\n\t\t}\n\t\tconst beforeResult = await this.emitBeforeSwitch(\"resume\", destinationPath);\n\t\tif (beforeResult.cancelled) {\n\t\t\treturn beforeResult;\n\t\t}\n\n\t\tconst previousSessionFile = this.session.sessionFile;\n\t\treserveSessionWrite(destinationPath);\n\t\tif (!sourceAlreadyStored) {\n\t\t\tcopyFileSync(resolvedPath, destinationPath, constants.COPYFILE_EXCL);\n\t\t}\n\n\t\tconst sessionManager = SessionManager.open(destinationPath, sessionDir, cwdOverride);\n\t\tassertSessionCwdExists(sessionManager, this.cwd);\n\t\tawait this.teardownCurrent(\"resume\", sessionManager.getSessionFile());\n\t\tawait this.apply(\n\t\t\tawait this.createRuntime({\n\t\t\t\tcwd: sessionManager.getCwd(),\n\t\t\t\tagentDir: this.services.agentDir,\n\t\t\t\tsessionManager,\n\t\t\t\tsessionStartEvent: { type: \"session_start\", reason: \"resume\", previousSessionFile },\n\t\t\t\tlaunchProfile: this._launchProfile,\n\t\t\t}),\n\t\t);\n\t\tawait this.finishSessionReplacement();\n\t\treturn { cancelled: false };\n\t}\n\n\tasync dispose(): Promise<void> {\n\t\tawait emitSessionShutdownEvent(this.session.extensionRunner, {\n\t\t\ttype: \"session_shutdown\",\n\t\t\treason: \"quit\",\n\t\t});\n\t\tthis.beforeSessionInvalidate?.();\n\t\tthis.session.dispose();\n\t}\n}\n\n/**\n * Create the initial runtime from a runtime factory and initial session target.\n *\n * The same factory is stored on the returned AgentSessionRuntime and reused for\n * later /new, /resume, /fork, and import flows.\n */\nexport async function createAgentSessionRuntime(\n\tcreateRuntime: CreateAgentSessionRuntimeFactory,\n\toptions: {\n\t\tcwd: string;\n\t\tagentDir: string;\n\t\tsessionManager: SessionManager;\n\t\tsessionStartEvent?: SessionStartEvent;\n\t\tlaunchProfile?: Readonly<AgentSessionLaunchProfile>;\n\t},\n): Promise<AgentSessionRuntime> {\n\tassertSessionCwdExists(options.sessionManager, options.cwd);\n\tconst result = await createRuntime(options);\n\treturn new AgentSessionRuntime(\n\t\tresult.session,\n\t\tresult.services,\n\t\tcreateRuntime,\n\t\tresult.diagnostics,\n\t\tresult.modelFallbackMessage,\n\t\toptions.launchProfile,\n\t);\n}\n\nexport {\n\ttype AgentSessionRuntimeDiagnostic,\n\ttype AgentSessionServices,\n\ttype CreateAgentSessionFromServicesOptions,\n\ttype CreateAgentSessionServicesOptions,\n\tcreateAgentSessionFromServices,\n\tcreateAgentSessionServices,\n} from \"./agent-session-services.ts\";\n"]}
1
+ {"version":3,"file":"agent-session-runtime.js","sourceRoot":"","sources":["../../src/core/agent-session-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAYhD,OAAO,EAAwB,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAExF,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAoB,MAAM,sBAAsB,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAC9F,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAA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BAAkB,EAAE,CAAC;IAC3B,CAAC;CACD;AAED,8FAA8F;AAC9F,kEAAkE;AAClE,SAAS,UAAU,CAAC,cAA8B;IACjD,OAAO,cAAc,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC,CAAC;AACpH,CAAC;AAED,SAAS,iBAAiB,CAAC,cAA8B,EAAE,cAAuB;IACjF,MAAM,WAAW,GAAG,cAAc,CAAC,cAAc,EAAE,CAAC;IACpD,IAAI,CAAC,cAAc,CAAC,WAAW,EAAE,IAAI,WAAW,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACjF,OAAO,eAAe,CAAC,WAAW,EAAE,cAAc,CAAC,YAAY,EAAE,EAAE;QAClE,GAAG,EAAE,cAAc,CAAC,MAAM,EAAE;QAC5B,cAAc;KACd,CAAC,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC9C,aAA+C,EAC/C,OAMC;IAED,sBAAsB,CAAC,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;IAC5D,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,OAAO,CAAC,CAAC;IAC5C,OAAO,IAAI,mBAAmB,CAC7B,MAAM,CAAC,OAAO,EACd,MAAM,CAAC,QAAQ,EACf,aAAa,EACb,MAAM,CAAC,WAAW,EAClB,MAAM,CAAC,oBAAoB,EAC3B,OAAO,CAAC,aAAa,CACrB,CAAC;AACH,CAAC;AAED,OAAO,EAKN,8BAA8B,EAC9B,0BAA0B,GAC1B,MAAM,6BAA6B,CAAC","sourcesContent":["import { constants, copyFileSync, existsSync, mkdirSync } from \"node:fs\";\nimport { basename, join, parse, resolve } from \"node:path\";\nimport { resolvePath } from \"../utils/paths.ts\";\nimport type { AgentSession } from \"./agent-session.ts\";\nimport type { AgentSessionRuntimeDiagnostic, AgentSessionServices } from \"./agent-session-services.ts\";\nimport type { HostMcpRegistry } from \"./extensions/builtin/mcp/host-registry.ts\";\nimport type {\n\tProjectTrustContext,\n\tReplacedSessionContext,\n\tSessionContext,\n\tSessionKind,\n\tSessionShutdownEvent,\n\tSessionStartEvent,\n} from \"./extensions/index.ts\";\nimport { type ExtensionRunner, emitSessionShutdownEvent } from \"./extensions/runner.ts\";\nimport type { CreateAgentSessionResult } from \"./sdk.ts\";\nimport { assertSessionCwdExists } from \"./session-cwd.ts\";\nimport { holdSessionFile, type SessionHold } from \"./session-holders.ts\";\nimport { SessionManager } from \"./session-manager.ts\";\nimport { reserveSessionWrite, unregisterSessionWriter } from \"./session-write-reservation.ts\";\nimport { resetTimings, time } from \"./timings.ts\";\n\n/**\n * Result returned by runtime creation.\n *\n * The caller gets the created session, its cwd-bound services, and all\n * diagnostics collected during setup.\n */\nexport interface CreateAgentSessionRuntimeResult extends CreateAgentSessionResult {\n\tservices: AgentSessionServices;\n\tdiagnostics: AgentSessionRuntimeDiagnostic[];\n}\n\n/** Immutable flags selected when a runtime is first launched. */\nexport interface AgentSessionLaunchProfile {\n\tcwd: string;\n\tpermissionPreset?: string;\n\tcreationModel?: { provider: string; modelId: string };\n\tinitialThinkingLevel?: string;\n\t/**\n\t * Visibility class of this session (`open_session.kind`), absent for classic\n\t * launches. It reaches the extensions this session loads and nothing else: it\n\t * never takes part in auth, model or resource resolution.\n\t */\n\tsessionKind?: SessionKind;\n\t/** Opaque labels the opener attached (`open_session.context`), absent when none. */\n\tsessionContext?: SessionContext;\n\t/**\n\t * Per-session auto-titling (`open_session.auto_title`). When set, this session\n\t * ignores the host-wide `--auto-title-sessions` / appMode default.\n\t */\n\tautoTitle?: boolean;\n}\n\n/**\n * Creates a full runtime for a target cwd and session manager.\n *\n * The factory closes over process-global fixed inputs, recreates cwd-bound\n * services for the effective cwd, resolves session options against those\n * services, and finally creates the AgentSession.\n */\nexport type CreateAgentSessionRuntimeFactory = (options: {\n\tcwd: string;\n\tagentDir: string;\n\tmcpRegistry?: HostMcpRegistry;\n\tsessionManager: SessionManager;\n\tsessionStartEvent?: SessionStartEvent;\n\tprojectTrustContext?: ProjectTrustContext;\n\tlaunchProfile?: Readonly<AgentSessionLaunchProfile>;\n}) => Promise<CreateAgentSessionRuntimeResult>;\n\n/**\n * Thrown when /import references a JSONL file path that does not exist.\n */\nexport class SessionImportFileNotFoundError extends Error {\n\treadonly filePath: string;\n\n\tconstructor(filePath: string) {\n\t\tsuper(`File not found: ${filePath}`);\n\t\tthis.name = \"SessionImportFileNotFoundError\";\n\t\tthis.filePath = filePath;\n\t}\n}\n\nfunction extractUserMessageText(content: string | Array<{ type: string; text?: string }>): string {\n\tif (typeof content === \"string\") {\n\t\treturn content;\n\t}\n\n\treturn content\n\t\t.filter((part): part is { type: \"text\"; text: string } => part.type === \"text\" && typeof part.text === \"string\")\n\t\t.map((part) => part.text)\n\t\t.join(\"\");\n}\n\n/**\n * Owns the current AgentSession plus its cwd-bound services.\n *\n * Session replacement methods tear down the current runtime first, then create\n * and apply the next runtime. If creation fails, the error is propagated to the\n * caller. The caller is responsible for user-facing error handling.\n */\nexport class AgentSessionRuntime {\n\tprivate rebindSession?: (session: AgentSession) => Promise<void>;\n\tprivate beforeSessionInvalidate?: () => void;\n\tprivate _session: AgentSession;\n\tprivate _services: AgentSessionServices;\n\tprivate readonly createRuntime: CreateAgentSessionRuntimeFactory;\n\tprivate _diagnostics: AgentSessionRuntimeDiagnostic[];\n\tprivate _modelFallbackMessage?: string;\n\tprivate readonly _launchProfile?: Readonly<AgentSessionLaunchProfile>;\n\t// Advertises the open session file to other processes so none moves it out from under this one.\n\tprivate _sessionHold?: SessionHold;\n\tprivate _removedOnReplacement?: {\n\t\toldRunner: ExtensionRunner;\n\t\toldIdentities: Array<{ path: string; resolvedPath: string }>;\n\t\treason: SessionShutdownEvent[\"reason\"];\n\t};\n\n\tconstructor(\n\t\t_session: AgentSession,\n\t\t_services: AgentSessionServices,\n\t\tcreateRuntime: CreateAgentSessionRuntimeFactory,\n\t\t_diagnostics: AgentSessionRuntimeDiagnostic[] = [],\n\t\t_modelFallbackMessage?: string,\n\t\tlaunchProfile?: Readonly<AgentSessionLaunchProfile>,\n\t) {\n\t\tthis._session = _session;\n\t\tthis._services = _services;\n\t\tthis.createRuntime = createRuntime;\n\t\tthis._diagnostics = _diagnostics;\n\t\tthis._modelFallbackMessage = _modelFallbackMessage;\n\t\tthis._launchProfile = launchProfile;\n\t\tthis._sessionHold = holdActiveSession(_session.sessionManager, wasFlushed(_session.sessionManager));\n\t}\n\n\t/** Stops advertising the open session to other processes; a runtime that replaces this one holds its own. */\n\treleaseSessionHold(): void {\n\t\tthis._sessionHold?.release();\n\t\tthis._sessionHold = undefined;\n\t}\n\n\tget services(): AgentSessionServices {\n\t\treturn this._services;\n\t}\n\n\tget session(): AgentSession {\n\t\treturn this._session;\n\t}\n\n\tget cwd(): string {\n\t\treturn this._services.cwd;\n\t}\n\n\tget diagnostics(): readonly AgentSessionRuntimeDiagnostic[] {\n\t\treturn this._diagnostics;\n\t}\n\n\tget modelFallbackMessage(): string | undefined {\n\t\treturn this._modelFallbackMessage;\n\t}\n\n\tget launchProfile(): Readonly<AgentSessionLaunchProfile> | undefined {\n\t\treturn this._launchProfile;\n\t}\n\n\tsetRebindSession(rebindSession?: (session: AgentSession) => Promise<void>): void {\n\t\tthis.rebindSession = rebindSession;\n\t}\n\n\t/**\n\t * Set a synchronous callback that runs after `session_shutdown` handlers finish\n\t * but before the current session is invalidated.\n\t *\n\t * This is for host-owned UI teardown that must not yield to the event loop,\n\t * such as detaching extension-provided TUI components before the old extension\n\t * context becomes stale.\n\t */\n\tsetBeforeSessionInvalidate(beforeSessionInvalidate?: () => void): void {\n\t\tthis.beforeSessionInvalidate = beforeSessionInvalidate;\n\t}\n\n\t/** Attachment transitions are ordered by the RPC entry's lifecycle mutex. */\n\tasync emitAttachmentEvent(type: \"session_parked\" | \"session_resumed\"): Promise<void> {\n\t\tconst runner = this.session.extensionRunner;\n\t\tif (runner.hasHandlers(type)) await runner.emit({ type });\n\t}\n\n\tprivate async emitBeforeSwitch(\n\t\treason: \"new\" | \"resume\",\n\t\ttargetSessionFile?: string,\n\t): Promise<{ cancelled: boolean }> {\n\t\tconst runner = this.session.extensionRunner;\n\t\tif (!runner.hasHandlers(\"session_before_switch\")) {\n\t\t\treturn { cancelled: false };\n\t\t}\n\n\t\tconst result = await runner.emit({\n\t\t\ttype: \"session_before_switch\",\n\t\t\treason,\n\t\t\ttargetSessionFile,\n\t\t});\n\t\treturn { cancelled: result?.cancel === true };\n\t}\n\n\tprivate async emitBeforeFork(\n\t\tentryId: string,\n\t\toptions: { position: \"before\" | \"at\" },\n\t): Promise<{ cancelled: boolean }> {\n\t\tconst runner = this.session.extensionRunner;\n\t\tif (!runner.hasHandlers(\"session_before_fork\")) {\n\t\t\treturn { cancelled: false };\n\t\t}\n\n\t\tconst result = await runner.emit({\n\t\t\ttype: \"session_before_fork\",\n\t\t\tentryId,\n\t\t\t...options,\n\t\t});\n\t\treturn { cancelled: result?.cancel === true };\n\t}\n\n\tprivate async teardownCurrent(reason: SessionShutdownEvent[\"reason\"], targetSessionFile?: string): Promise<void> {\n\t\tconst mark = (label: string): void => {\n\t\t\tif (reason === \"resume\") time(label, \"switch\");\n\t\t};\n\t\t// Settle the active response before replacement so the outgoing turn and\n\t\t// any completed tool results are persisted to the old session.\n\t\tawait this.session.abort();\n\t\tmark(\"abort\");\n\t\tconst oldRunner = this.session.extensionRunner;\n\t\t// Test hosts and partial runner implementations may lack identity introspection;\n\t\t// skip removal reporting there rather than break the replacement itself.\n\t\tif (typeof oldRunner.getExtensionIdentities === \"function\") {\n\t\t\tthis._removedOnReplacement = {\n\t\t\t\toldRunner,\n\t\t\t\toldIdentities: oldRunner.getExtensionIdentities(),\n\t\t\t\treason,\n\t\t\t};\n\t\t}\n\t\tawait emitSessionShutdownEvent(oldRunner, {\n\t\t\ttype: \"session_shutdown\",\n\t\t\treason,\n\t\t\ttargetSessionFile,\n\t\t});\n\t\tmark(\"shutdown\");\n\t\tthis.beforeSessionInvalidate?.();\n\t\tconst replaced = this.session.sessionManager;\n\t\tthis.session.dispose();\n\t\t// Nothing writes to the replaced manager once its session is disposed, so the\n\t\t// shared host may hand its session file to another worker.\n\t\tunregisterSessionWriter(replaced);\n\t\tthis.releaseSessionHold();\n\t\tmark(\"dispose\");\n\t}\n\n\tprivate async reportRemovedExtensions(): Promise<void> {\n\t\tconst pending = this._removedOnReplacement;\n\t\tthis._removedOnReplacement = undefined;\n\t\tif (!pending) return;\n\t\tconst newRunner = this.session.extensionRunner;\n\t\tif (typeof newRunner.getExtensionIdentities !== \"function\") return;\n\t\tconst newResolvedPaths = new Set(newRunner.getExtensionIdentities().map((extension) => extension.resolvedPath));\n\t\tconst removed = pending.oldIdentities.filter((extension) => !newResolvedPaths.has(extension.resolvedPath));\n\t\tif (removed.length === 0) return;\n\t\tawait pending.oldRunner.emit({ type: \"session_extensions_removed\", reason: pending.reason, removed });\n\t}\n\n\tprivate async apply(result: CreateAgentSessionRuntimeResult, hold?: SessionHold): Promise<void> {\n\t\tthis._sessionHold = hold ?? holdActiveSession(result.session.sessionManager, false);\n\t\tthis._session = result.session;\n\t\tthis._services = result.services;\n\t\tthis._diagnostics = result.diagnostics;\n\t\tthis._modelFallbackMessage = result.modelFallbackMessage;\n\t\tawait this.reportRemovedExtensions();\n\t}\n\n\tprivate async finishSessionReplacement(withSession?: (ctx: ReplacedSessionContext) => Promise<void>): Promise<void> {\n\t\tif (this.rebindSession) {\n\t\t\tawait this.rebindSession(this.session);\n\t\t}\n\t\tif (withSession) {\n\t\t\tawait withSession(this.session.createReplacedSessionContext());\n\t\t}\n\t}\n\n\tasync switchSession(\n\t\tsessionPath: string,\n\t\toptions?: {\n\t\t\tcwdOverride?: string;\n\t\t\twithSession?: (ctx: ReplacedSessionContext) => Promise<void>;\n\t\t\tprojectTrustContextFactory?: (cwd: string) => ProjectTrustContext;\n\t\t},\n\t): Promise<{ cancelled: boolean }> {\n\t\tresetTimings(\"switch\");\n\t\tconst beforeResult = await this.emitBeforeSwitch(\"resume\", sessionPath);\n\t\tif (beforeResult.cancelled) {\n\t\t\treturn beforeResult;\n\t\t}\n\t\ttime(\"beforeSwitch\", \"switch\");\n\n\t\tconst previousSessionFile = this.session.sessionFile;\n\t\tconst sessionManager = SessionManager.open(sessionPath, undefined, options?.cwdOverride);\n\t\tassertSessionCwdExists(sessionManager, this.cwd);\n\t\t// Held before the current session is torn down: a session being moved fails the switch here.\n\t\tconst hold = holdActiveSession(sessionManager, wasFlushed(sessionManager));\n\t\ttime(\"open\", \"switch\");\n\t\ttry {\n\t\t\tawait this.teardownCurrent(\"resume\", sessionManager.getSessionFile());\n\t\t\tawait this.apply(\n\t\t\t\tawait this.createRuntime({\n\t\t\t\t\tcwd: sessionManager.getCwd(),\n\t\t\t\t\tagentDir: this.services.agentDir,\n\t\t\t\t\tsessionManager,\n\t\t\t\t\tsessionStartEvent: { type: \"session_start\", reason: \"resume\", previousSessionFile },\n\t\t\t\t\tprojectTrustContext: options?.projectTrustContextFactory?.(sessionManager.getCwd()),\n\t\t\t\t\tlaunchProfile: this._launchProfile,\n\t\t\t\t}),\n\t\t\t\thold,\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tif (this._sessionHold !== hold) hold?.release();\n\t\t\tthrow error;\n\t\t}\n\t\ttime(\"apply\", \"switch\");\n\t\tawait this.finishSessionReplacement(options?.withSession);\n\t\ttime(\"rebind\", \"switch\");\n\t\treturn { cancelled: false };\n\t}\n\n\tasync newSession(options?: {\n\t\tparentSession?: string;\n\t\tsetup?: (sessionManager: SessionManager) => Promise<void>;\n\t\twithSession?: (ctx: ReplacedSessionContext) => Promise<void>;\n\t}): Promise<{ cancelled: boolean }> {\n\t\tconst beforeResult = await this.emitBeforeSwitch(\"new\");\n\t\tif (beforeResult.cancelled) {\n\t\t\treturn beforeResult;\n\t\t}\n\n\t\tconst previousSessionFile = this.session.sessionFile;\n\t\tconst sessionDir = this.session.sessionManager.getSessionDir();\n\t\tconst sessionManager = this.session.sessionManager.isPersisted()\n\t\t\t? SessionManager.create(this.cwd, sessionDir)\n\t\t\t: SessionManager.inMemory(this.cwd);\n\t\tif (options?.parentSession) {\n\t\t\tsessionManager.newSession({ parentSession: options.parentSession });\n\t\t}\n\n\t\tawait this.teardownCurrent(\"new\", sessionManager.getSessionFile());\n\t\tawait this.apply(\n\t\t\tawait this.createRuntime({\n\t\t\t\tcwd: this.cwd,\n\t\t\t\tagentDir: this.services.agentDir,\n\t\t\t\tsessionManager,\n\t\t\t\tsessionStartEvent: { type: \"session_start\", reason: \"new\", previousSessionFile },\n\t\t\t\tlaunchProfile: this._launchProfile,\n\t\t\t}),\n\t\t);\n\t\tif (options?.setup) {\n\t\t\tawait options.setup(this.session.sessionManager);\n\t\t\tthis.session.agent.state.messages = this.session.sessionManager.buildSessionContext().messages;\n\t\t}\n\t\tawait this.finishSessionReplacement(options?.withSession);\n\t\treturn { cancelled: false };\n\t}\n\n\tasync fork(\n\t\tentryId: string,\n\t\toptions?: { position?: \"before\" | \"at\"; withSession?: (ctx: ReplacedSessionContext) => Promise<void> },\n\t): Promise<{ cancelled: boolean; selectedText?: string }> {\n\t\tconst position = options?.position ?? \"before\";\n\t\tconst beforeResult = await this.emitBeforeFork(entryId, { position });\n\t\tif (beforeResult.cancelled) {\n\t\t\treturn { cancelled: true };\n\t\t}\n\t\tlet targetLeafId: string | null;\n\t\tlet selectedText: string | undefined;\n\n\t\tconst selectedEntry = this.session.sessionManager.getEntry(entryId);\n\t\tif (!selectedEntry) {\n\t\t\tthrow new Error(\"Invalid entry ID for forking\");\n\t\t}\n\n\t\tif (position === \"at\") {\n\t\t\ttargetLeafId = selectedEntry.id;\n\t\t} else {\n\t\t\tif (selectedEntry.type !== \"message\" || selectedEntry.message.role !== \"user\") {\n\t\t\t\tthrow new Error(\"Invalid entry ID for forking\");\n\t\t\t}\n\t\t\ttargetLeafId = selectedEntry.parentId;\n\t\t\tselectedText = extractUserMessageText(selectedEntry.message.content);\n\t\t}\n\n\t\tconst previousSessionFile = this.session.sessionFile;\n\t\tif (this.session.sessionManager.isPersisted()) {\n\t\t\tconst currentSessionFile = this.session.sessionFile;\n\t\t\tif (!currentSessionFile) {\n\t\t\t\tthrow new Error(\"Persisted session is missing a session file\");\n\t\t\t}\n\t\t\tconst sessionDir = this.session.sessionManager.getSessionDir();\n\t\t\tif (!targetLeafId) {\n\t\t\t\tconst sessionManager = SessionManager.create(this.cwd, sessionDir);\n\t\t\t\tsessionManager.newSession({ parentSession: currentSessionFile });\n\t\t\t\tawait this.teardownCurrent(\"fork\", sessionManager.getSessionFile());\n\t\t\t\tawait this.apply(\n\t\t\t\t\tawait this.createRuntime({\n\t\t\t\t\t\tcwd: this.cwd,\n\t\t\t\t\t\tagentDir: this.services.agentDir,\n\t\t\t\t\t\tsessionManager,\n\t\t\t\t\t\tsessionStartEvent: { type: \"session_start\", reason: \"fork\", previousSessionFile },\n\t\t\t\t\t\tlaunchProfile: this._launchProfile,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t\tawait this.finishSessionReplacement(options?.withSession);\n\t\t\t\treturn { cancelled: false, selectedText };\n\t\t\t}\n\n\t\t\tif (!existsSync(currentSessionFile)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"This session has not been saved yet. Wait for the first assistant response before cloning or forking it.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst sessionManager = SessionManager.open(currentSessionFile, sessionDir);\n\t\t\tconst forkedSessionPath = sessionManager.createBranchedSession(targetLeafId);\n\t\t\tif (!forkedSessionPath) {\n\t\t\t\tthrow new Error(\"Failed to create forked session\");\n\t\t\t}\n\t\t\tawait this.teardownCurrent(\"fork\", sessionManager.getSessionFile());\n\t\t\tawait this.apply(\n\t\t\t\tawait this.createRuntime({\n\t\t\t\t\tcwd: sessionManager.getCwd(),\n\t\t\t\t\tagentDir: this.services.agentDir,\n\t\t\t\t\tsessionManager,\n\t\t\t\t\tsessionStartEvent: { type: \"session_start\", reason: \"fork\", previousSessionFile },\n\t\t\t\t\tlaunchProfile: this._launchProfile,\n\t\t\t\t}),\n\t\t\t);\n\t\t\tawait this.finishSessionReplacement(options?.withSession);\n\t\t\treturn { cancelled: false, selectedText };\n\t\t}\n\n\t\tconst sessionManager = this.session.sessionManager;\n\t\tawait this.teardownCurrent(\"fork\", sessionManager.getSessionFile());\n\t\tif (!targetLeafId) {\n\t\t\tsessionManager.newSession({ parentSession: previousSessionFile });\n\t\t} else {\n\t\t\tsessionManager.createBranchedSession(targetLeafId);\n\t\t}\n\t\tawait this.apply(\n\t\t\tawait this.createRuntime({\n\t\t\t\tcwd: this.cwd,\n\t\t\t\tagentDir: this.services.agentDir,\n\t\t\t\tsessionManager,\n\t\t\t\tsessionStartEvent: { type: \"session_start\", reason: \"fork\", previousSessionFile },\n\t\t\t\tlaunchProfile: this._launchProfile,\n\t\t\t}),\n\t\t);\n\t\tawait this.finishSessionReplacement(options?.withSession);\n\t\treturn { cancelled: false, selectedText };\n\t}\n\n\t/**\n\t * Import a session JSONL file and switch runtime state to the imported session.\n\t *\n\t * @returns `{ cancelled: true }` when cancelled by `session_before_switch`, otherwise `{ cancelled: false }`.\n\t * @throws {SessionImportFileNotFoundError} When the input path does not exist.\n\t * @throws {MissingSessionCwdError} When the imported session cwd cannot be resolved and no override is provided.\n\t */\n\tasync importFromJsonl(inputPath: string, cwdOverride?: string): Promise<{ cancelled: boolean }> {\n\t\tconst resolvedPath = resolvePath(inputPath);\n\t\tif (!existsSync(resolvedPath)) {\n\t\t\tthrow new SessionImportFileNotFoundError(resolvedPath);\n\t\t}\n\n\t\tconst sessionDir = this.session.sessionManager.getSessionDir();\n\t\tif (!existsSync(sessionDir)) {\n\t\t\tmkdirSync(sessionDir, { recursive: true });\n\t\t}\n\n\t\tlet destinationPath = join(sessionDir, basename(resolvedPath));\n\t\tconst sourceAlreadyStored = resolve(destinationPath) === resolvedPath;\n\t\tif (!sourceAlreadyStored) {\n\t\t\tconst { name, ext } = parse(destinationPath);\n\t\t\tlet suffix = 1;\n\t\t\twhile (existsSync(destinationPath)) {\n\t\t\t\tdestinationPath = join(sessionDir, `${name}-${suffix++}${ext}`);\n\t\t\t}\n\t\t}\n\t\tconst beforeResult = await this.emitBeforeSwitch(\"resume\", destinationPath);\n\t\tif (beforeResult.cancelled) {\n\t\t\treturn beforeResult;\n\t\t}\n\n\t\tconst previousSessionFile = this.session.sessionFile;\n\t\treserveSessionWrite(destinationPath);\n\t\tif (!sourceAlreadyStored) {\n\t\t\tcopyFileSync(resolvedPath, destinationPath, constants.COPYFILE_EXCL);\n\t\t}\n\n\t\tconst sessionManager = SessionManager.open(destinationPath, sessionDir, cwdOverride);\n\t\tassertSessionCwdExists(sessionManager, this.cwd);\n\t\tawait this.teardownCurrent(\"resume\", sessionManager.getSessionFile());\n\t\tawait this.apply(\n\t\t\tawait this.createRuntime({\n\t\t\t\tcwd: sessionManager.getCwd(),\n\t\t\t\tagentDir: this.services.agentDir,\n\t\t\t\tsessionManager,\n\t\t\t\tsessionStartEvent: { type: \"session_start\", reason: \"resume\", previousSessionFile },\n\t\t\t\tlaunchProfile: this._launchProfile,\n\t\t\t}),\n\t\t);\n\t\tawait this.finishSessionReplacement();\n\t\treturn { cancelled: false };\n\t}\n\n\tasync dispose(): Promise<void> {\n\t\tawait emitSessionShutdownEvent(this.session.extensionRunner, {\n\t\t\ttype: \"session_shutdown\",\n\t\t\treason: \"quit\",\n\t\t});\n\t\tthis.beforeSessionInvalidate?.();\n\t\tthis.session.dispose();\n\t\tthis.releaseSessionHold();\n\t}\n}\n\n// A persisted session is written to disk with its first assistant message, so one that has an\n// assistant message and no file was moved away after it was read.\nfunction wasFlushed(sessionManager: SessionManager): boolean {\n\treturn sessionManager.getEntries().some((entry) => entry.type === \"message\" && entry.message.role === \"assistant\");\n}\n\nfunction holdActiveSession(sessionManager: SessionManager, expectExisting: boolean): SessionHold | undefined {\n\tconst sessionFile = sessionManager.getSessionFile();\n\tif (!sessionManager.isPersisted() || sessionFile === undefined) return undefined;\n\treturn holdSessionFile(sessionFile, sessionManager.getSessionId(), {\n\t\tcwd: sessionManager.getCwd(),\n\t\texpectExisting,\n\t});\n}\n\n/**\n * Create the initial runtime from a runtime factory and initial session target.\n *\n * The same factory is stored on the returned AgentSessionRuntime and reused for\n * later /new, /resume, /fork, and import flows.\n */\nexport async function createAgentSessionRuntime(\n\tcreateRuntime: CreateAgentSessionRuntimeFactory,\n\toptions: {\n\t\tcwd: string;\n\t\tagentDir: string;\n\t\tsessionManager: SessionManager;\n\t\tsessionStartEvent?: SessionStartEvent;\n\t\tlaunchProfile?: Readonly<AgentSessionLaunchProfile>;\n\t},\n): Promise<AgentSessionRuntime> {\n\tassertSessionCwdExists(options.sessionManager, options.cwd);\n\tconst result = await createRuntime(options);\n\treturn new AgentSessionRuntime(\n\t\tresult.session,\n\t\tresult.services,\n\t\tcreateRuntime,\n\t\tresult.diagnostics,\n\t\tresult.modelFallbackMessage,\n\t\toptions.launchProfile,\n\t);\n}\n\nexport {\n\ttype AgentSessionRuntimeDiagnostic,\n\ttype AgentSessionServices,\n\ttype CreateAgentSessionFromServicesOptions,\n\ttype CreateAgentSessionServicesOptions,\n\tcreateAgentSessionFromServices,\n\tcreateAgentSessionServices,\n} from \"./agent-session-services.ts\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"session-registry-pump.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/anthropic-subscription/session-registry-pump.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEpE,OAAO,EACN,KAAK,iCAAiC,EACtC,KAAK,oCAAoC,EAEzC,MAAM,uBAAuB,CAAC;AAS/B,OAAO,KAAK,EAAc,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEpG,YAAY,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAIjE,eAAO,MAAM,+BAA+B,KAAK,CAAC;AAClD,eAAO,MAAM,4BAA4B,QAAa,CAAC;AACvD,eAAO,MAAM,2BAA2B,OAAQ,CAAC;AAEjD,MAAM,WAAW,kBAAkB;IAClC,OAAO,EAAE,cAAc,CAAC,SAAS,CAAC,CAAC;IACnC,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,UAAU,KAAK,IAAI,CAAC;IAC1C,aAAa,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,MAAM,IAAI,CAAC;CACtE;AAED,qBAAa,mCAAoC,SAAQ,KAAK;IAC7D,QAAQ,CAAC,IAAI,gDAAgD;IAE7D,YAAY,SAAS,EAAE,MAAM,EAG5B;CACD;AAuJD,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,oCAAoC,EAC9C,KAAK,EAAE,iCAAiC,EACxC,OAAO,EAAE,kBAAkB,EAC3B,MAAM,GAAE,qBAGP,GACC,OAAO,CAAC,iBAAiB,CAAC,CAsD5B"}
1
+ {"version":3,"file":"session-registry-pump.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/anthropic-subscription/session-registry-pump.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEpE,OAAO,EACN,KAAK,iCAAiC,EACtC,KAAK,oCAAoC,EAEzC,MAAM,uBAAuB,CAAC;AAiB/B,OAAO,KAAK,EAAc,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEpG,YAAY,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAIjE,eAAO,MAAM,+BAA+B,KAAK,CAAC;AAClD,eAAO,MAAM,4BAA4B,QAAa,CAAC;AACvD,eAAO,MAAM,2BAA2B,OAAQ,CAAC;AAEjD,MAAM,WAAW,kBAAkB;IAClC,OAAO,EAAE,cAAc,CAAC,SAAS,CAAC,CAAC;IACnC,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,UAAU,KAAK,IAAI,CAAC;IAC1C,aAAa,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,MAAM,IAAI,CAAC;CACtE;AAED,qBAAa,mCAAoC,SAAQ,KAAK;IAC7D,QAAQ,CAAC,IAAI,gDAAgD;IAE7D,YAAY,SAAS,EAAE,MAAM,EAG5B;CACD;AAyJD,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,oCAAoC,EAC9C,KAAK,EAAE,iCAAiC,EACxC,OAAO,EAAE,kBAAkB,EAC3B,MAAM,GAAE,qBAGP,GACC,OAAO,CAAC,iBAAiB,CAAC,CAuD5B"}
@@ -3,7 +3,7 @@ import { refusalError } from "./refusal.js";
3
3
  import { evaluateAbortOutcome } from "./session-reattach.js";
4
4
  import { createSessionUuid, } from "./session-registry.js";
5
5
  import { transitionToIdleSynced, transitionToTurnResultSeen, transitionToTurnSent, transitionToTurnStreaming, transitionToTurnWaiting, } from "./session-registry-state.js";
6
- import { bufferBeforeReplay, claimTurn, deliver, isReplayFor, resultMatchesTurn } from "./session-turn-claim.js";
6
+ import { bufferBeforeReplay, claimTurn, deliver, endForeignTurnBeforeReplay, isForeignResult, isReplayFor, resultMatchesTurn, } from "./session-turn-claim.js";
7
7
  import { SessionTurnAttributionError } from "./session-turn-types.js";
8
8
  export const DEFAULT_PRE_REPLAY_MAX_MESSAGES = 64;
9
9
  export const DEFAULT_PRE_REPLAY_MAX_BYTES = 256 * 1024;
@@ -104,6 +104,9 @@ function handleMessage(registry, entry, message) {
104
104
  finishTurn(registry, entry, turn, message);
105
105
  return false;
106
106
  }
107
+ else if (message.type === "result" && isForeignResult(message, turn)) {
108
+ endForeignTurnBeforeReplay(turn);
109
+ }
107
110
  else if (message.type === "result") {
108
111
  // A result that fails before the SDK ever echoed our user message (a
109
112
  // 400 version floor, a session limit) must surface as that failure so
@@ -183,6 +186,7 @@ export function submitSessionTurn(registry, entry, request, limits = {
183
186
  messages: [],
184
187
  preReplay: [],
185
188
  preReplayBytes: 0,
189
+ preReplayOverflowed: false,
186
190
  claimed: false,
187
191
  aborted: false,
188
192
  onMessage: request.onMessage,