@code-yeongyu/senpi 2026.8.29 → 2026.8.30-2

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 (311) hide show
  1. package/CHANGELOG.md +122 -0
  2. package/dist/core/agent-session.d.ts +45 -1
  3. package/dist/core/agent-session.d.ts.map +1 -1
  4. package/dist/core/agent-session.js +329 -29
  5. package/dist/core/agent-session.js.map +1 -1
  6. package/dist/core/bash-executor.d.ts.map +1 -1
  7. package/dist/core/bash-executor.js +155 -37
  8. package/dist/core/bash-executor.js.map +1 -1
  9. package/dist/core/compaction/compaction-execution.d.ts +14 -0
  10. package/dist/core/compaction/compaction-execution.d.ts.map +1 -0
  11. package/dist/core/compaction/compaction-execution.js +121 -0
  12. package/dist/core/compaction/compaction-execution.js.map +1 -0
  13. package/dist/core/compaction/compaction-settings.d.ts +17 -0
  14. package/dist/core/compaction/compaction-settings.d.ts.map +1 -0
  15. package/dist/core/compaction/compaction-settings.js +17 -0
  16. package/dist/core/compaction/compaction-settings.js.map +1 -0
  17. package/dist/core/compaction/compaction.d.ts +13 -26
  18. package/dist/core/compaction/compaction.d.ts.map +1 -1
  19. package/dist/core/compaction/compaction.js +7 -136
  20. package/dist/core/compaction/compaction.js.map +1 -1
  21. package/dist/core/compaction/ideal-compaction-settings.d.ts +9 -0
  22. package/dist/core/compaction/ideal-compaction-settings.d.ts.map +1 -0
  23. package/dist/core/compaction/ideal-compaction-settings.js +7 -0
  24. package/dist/core/compaction/ideal-compaction-settings.js.map +1 -0
  25. package/dist/core/compaction-settings-access.d.ts +19 -0
  26. package/dist/core/compaction-settings-access.d.ts.map +1 -0
  27. package/dist/core/compaction-settings-access.js +10 -0
  28. package/dist/core/compaction-settings-access.js.map +1 -0
  29. package/dist/core/compaction-settings-resolver.d.ts +22 -0
  30. package/dist/core/compaction-settings-resolver.d.ts.map +1 -0
  31. package/dist/core/compaction-settings-resolver.js +46 -0
  32. package/dist/core/compaction-settings-resolver.js.map +1 -0
  33. package/dist/core/credential-accounts.d.ts.map +1 -1
  34. package/dist/core/credential-accounts.js +23 -9
  35. package/dist/core/credential-accounts.js.map +1 -1
  36. package/dist/core/credential-pool/env-slots.d.ts.map +1 -1
  37. package/dist/core/credential-pool/env-slots.js +2 -0
  38. package/dist/core/credential-pool/env-slots.js.map +1 -1
  39. package/dist/core/extensions/builtin/compaction/context-pipeline.d.ts +17 -0
  40. package/dist/core/extensions/builtin/compaction/context-pipeline.d.ts.map +1 -0
  41. package/dist/core/extensions/builtin/compaction/context-pipeline.js +28 -0
  42. package/dist/core/extensions/builtin/compaction/context-pipeline.js.map +1 -0
  43. package/dist/core/extensions/builtin/compaction/deterministic-fallback.d.ts +8 -2
  44. package/dist/core/extensions/builtin/compaction/deterministic-fallback.d.ts.map +1 -1
  45. package/dist/core/extensions/builtin/compaction/deterministic-fallback.js +163 -48
  46. package/dist/core/extensions/builtin/compaction/deterministic-fallback.js.map +1 -1
  47. package/dist/core/extensions/builtin/compaction/emergency-prune.d.ts +17 -0
  48. package/dist/core/extensions/builtin/compaction/emergency-prune.d.ts.map +1 -0
  49. package/dist/core/extensions/builtin/compaction/emergency-prune.js +64 -0
  50. package/dist/core/extensions/builtin/compaction/emergency-prune.js.map +1 -0
  51. package/dist/core/extensions/builtin/compaction/extension-wiring.d.ts +27 -0
  52. package/dist/core/extensions/builtin/compaction/extension-wiring.d.ts.map +1 -0
  53. package/dist/core/extensions/builtin/compaction/extension-wiring.js +84 -0
  54. package/dist/core/extensions/builtin/compaction/extension-wiring.js.map +1 -0
  55. package/dist/core/extensions/builtin/compaction/idle.d.ts +1 -0
  56. package/dist/core/extensions/builtin/compaction/idle.d.ts.map +1 -1
  57. package/dist/core/extensions/builtin/compaction/idle.js +13 -2
  58. package/dist/core/extensions/builtin/compaction/idle.js.map +1 -1
  59. package/dist/core/extensions/builtin/compaction/index.d.ts +1 -1
  60. package/dist/core/extensions/builtin/compaction/index.d.ts.map +1 -1
  61. package/dist/core/extensions/builtin/compaction/index.js +121 -147
  62. package/dist/core/extensions/builtin/compaction/index.js.map +1 -1
  63. package/dist/core/extensions/builtin/compaction/log.d.ts +1 -1
  64. package/dist/core/extensions/builtin/compaction/log.d.ts.map +1 -1
  65. package/dist/core/extensions/builtin/compaction/log.js +2 -0
  66. package/dist/core/extensions/builtin/compaction/log.js.map +1 -1
  67. package/dist/core/extensions/builtin/compaction/model-selection.d.ts +14 -0
  68. package/dist/core/extensions/builtin/compaction/model-selection.d.ts.map +1 -0
  69. package/dist/core/extensions/builtin/compaction/model-selection.js +37 -0
  70. package/dist/core/extensions/builtin/compaction/model-selection.js.map +1 -0
  71. package/dist/core/extensions/builtin/compaction/openai-remote-dependencies.d.ts +9 -0
  72. package/dist/core/extensions/builtin/compaction/openai-remote-dependencies.d.ts.map +1 -0
  73. package/dist/core/extensions/builtin/compaction/openai-remote-dependencies.js +2 -0
  74. package/dist/core/extensions/builtin/compaction/openai-remote-dependencies.js.map +1 -0
  75. package/dist/core/extensions/builtin/compaction/openai-remote.d.ts +3 -6
  76. package/dist/core/extensions/builtin/compaction/openai-remote.d.ts.map +1 -1
  77. package/dist/core/extensions/builtin/compaction/openai-remote.js.map +1 -1
  78. package/dist/core/extensions/builtin/compaction/orchestration.d.ts +56 -0
  79. package/dist/core/extensions/builtin/compaction/orchestration.d.ts.map +1 -0
  80. package/dist/core/extensions/builtin/compaction/orchestration.js +136 -0
  81. package/dist/core/extensions/builtin/compaction/orchestration.js.map +1 -0
  82. package/dist/core/extensions/builtin/compaction/policy.d.ts +5 -2
  83. package/dist/core/extensions/builtin/compaction/policy.d.ts.map +1 -1
  84. package/dist/core/extensions/builtin/compaction/policy.js +43 -26
  85. package/dist/core/extensions/builtin/compaction/policy.js.map +1 -1
  86. package/dist/core/extensions/builtin/compaction/retained-message-safety.d.ts.map +1 -1
  87. package/dist/core/extensions/builtin/compaction/retained-message-safety.js +31 -8
  88. package/dist/core/extensions/builtin/compaction/retained-message-safety.js.map +1 -1
  89. package/dist/core/extensions/builtin/compaction/speculation-lead.d.ts +8 -0
  90. package/dist/core/extensions/builtin/compaction/speculation-lead.d.ts.map +1 -0
  91. package/dist/core/extensions/builtin/compaction/speculation-lead.js +17 -0
  92. package/dist/core/extensions/builtin/compaction/speculation-lead.js.map +1 -0
  93. package/dist/core/extensions/builtin/compaction/speculative-job.d.ts +22 -0
  94. package/dist/core/extensions/builtin/compaction/speculative-job.d.ts.map +1 -0
  95. package/dist/core/extensions/builtin/compaction/speculative-job.js +16 -0
  96. package/dist/core/extensions/builtin/compaction/speculative-job.js.map +1 -0
  97. package/dist/core/extensions/builtin/compaction/speculative-summary.d.ts +22 -0
  98. package/dist/core/extensions/builtin/compaction/speculative-summary.d.ts.map +1 -0
  99. package/dist/core/extensions/builtin/compaction/speculative-summary.js +131 -0
  100. package/dist/core/extensions/builtin/compaction/speculative-summary.js.map +1 -0
  101. package/dist/core/extensions/builtin/compaction/speculative.d.ts +8 -13
  102. package/dist/core/extensions/builtin/compaction/speculative.d.ts.map +1 -1
  103. package/dist/core/extensions/builtin/compaction/speculative.js +7 -196
  104. package/dist/core/extensions/builtin/compaction/speculative.js.map +1 -1
  105. package/dist/core/extensions/builtin/compaction/token-budget-reminder.d.ts +18 -0
  106. package/dist/core/extensions/builtin/compaction/token-budget-reminder.d.ts.map +1 -0
  107. package/dist/core/extensions/builtin/compaction/token-budget-reminder.js +18 -0
  108. package/dist/core/extensions/builtin/compaction/token-budget-reminder.js.map +1 -0
  109. package/dist/core/extensions/builtin/compaction/tool-admission.d.ts +36 -0
  110. package/dist/core/extensions/builtin/compaction/tool-admission.d.ts.map +1 -0
  111. package/dist/core/extensions/builtin/compaction/tool-admission.js +92 -0
  112. package/dist/core/extensions/builtin/compaction/tool-admission.js.map +1 -0
  113. package/dist/core/extensions/builtin/cursor-cli-oauth/stream.d.ts.map +1 -1
  114. package/dist/core/extensions/builtin/cursor-cli-oauth/stream.js +8 -28
  115. package/dist/core/extensions/builtin/cursor-cli-oauth/stream.js.map +1 -1
  116. package/dist/core/extensions/builtin/permission-system/external-dir.d.ts.map +1 -1
  117. package/dist/core/extensions/builtin/permission-system/external-dir.js +15 -5
  118. package/dist/core/extensions/builtin/permission-system/external-dir.js.map +1 -1
  119. package/dist/core/extensions/builtin/permission-system/parsers.d.ts.map +1 -1
  120. package/dist/core/extensions/builtin/permission-system/parsers.js +16 -1
  121. package/dist/core/extensions/builtin/permission-system/parsers.js.map +1 -1
  122. package/dist/core/extensions/builtin/terminal/manager.d.ts +5 -0
  123. package/dist/core/extensions/builtin/terminal/manager.d.ts.map +1 -1
  124. package/dist/core/extensions/builtin/terminal/manager.js +31 -3
  125. package/dist/core/extensions/builtin/terminal/manager.js.map +1 -1
  126. package/dist/core/extensions/builtin/terminal/monitor-permission.d.ts +8 -0
  127. package/dist/core/extensions/builtin/terminal/monitor-permission.d.ts.map +1 -0
  128. package/dist/core/extensions/builtin/terminal/monitor-permission.js +16 -0
  129. package/dist/core/extensions/builtin/terminal/monitor-permission.js.map +1 -0
  130. package/dist/core/extensions/builtin/terminal/monitor-registry.d.ts +13 -0
  131. package/dist/core/extensions/builtin/terminal/monitor-registry.d.ts.map +1 -1
  132. package/dist/core/extensions/builtin/terminal/monitor-registry.js +403 -3
  133. package/dist/core/extensions/builtin/terminal/monitor-registry.js.map +1 -1
  134. package/dist/core/extensions/builtin/terminal/session-bundle.d.ts.map +1 -1
  135. package/dist/core/extensions/builtin/terminal/session-bundle.js +1 -0
  136. package/dist/core/extensions/builtin/terminal/session-bundle.js.map +1 -1
  137. package/dist/core/extensions/builtin/terminal/tools/kill-bash.d.ts.map +1 -1
  138. package/dist/core/extensions/builtin/terminal/tools/kill-bash.js +5 -2
  139. package/dist/core/extensions/builtin/terminal/tools/kill-bash.js.map +1 -1
  140. package/dist/core/extensions/builtin/terminal/tools/monitor.d.ts +4 -0
  141. package/dist/core/extensions/builtin/terminal/tools/monitor.d.ts.map +1 -1
  142. package/dist/core/extensions/builtin/terminal/tools/monitor.js +40 -2
  143. package/dist/core/extensions/builtin/terminal/tools/monitor.js.map +1 -1
  144. package/dist/core/model-resolver.js +2 -2
  145. package/dist/core/model-resolver.js.map +1 -1
  146. package/dist/core/session-manager.d.ts.map +1 -1
  147. package/dist/core/session-manager.js +10 -1
  148. package/dist/core/session-manager.js.map +1 -1
  149. package/dist/core/settings-manager.d.ts +15 -85
  150. package/dist/core/settings-manager.d.ts.map +1 -1
  151. package/dist/core/settings-manager.js +15 -17
  152. package/dist/core/settings-manager.js.map +1 -1
  153. package/dist/core/settings-public-types.d.ts +11 -0
  154. package/dist/core/settings-public-types.d.ts.map +1 -0
  155. package/dist/core/settings-public-types.js +2 -0
  156. package/dist/core/settings-public-types.js.map +1 -0
  157. package/dist/core/settings-shapes.d.ts +36 -0
  158. package/dist/core/settings-shapes.d.ts.map +1 -0
  159. package/dist/core/settings-shapes.js +2 -0
  160. package/dist/core/settings-shapes.js.map +1 -0
  161. package/dist/core/shared-host-policy.d.ts +6 -0
  162. package/dist/core/shared-host-policy.d.ts.map +1 -0
  163. package/dist/core/shared-host-policy.js +7 -0
  164. package/dist/core/shared-host-policy.js.map +1 -0
  165. package/dist/core/terminal-settings.d.ts +22 -0
  166. package/dist/core/terminal-settings.d.ts.map +1 -0
  167. package/dist/core/terminal-settings.js +2 -0
  168. package/dist/core/terminal-settings.js.map +1 -0
  169. package/dist/core/tools/bash.d.ts.map +1 -1
  170. package/dist/core/tools/bash.js +97 -15
  171. package/dist/core/tools/bash.js.map +1 -1
  172. package/dist/core/tools/index.d.ts +1 -0
  173. package/dist/core/tools/index.d.ts.map +1 -1
  174. package/dist/core/tools/index.js +8 -0
  175. package/dist/core/tools/index.js.map +1 -1
  176. package/dist/core/tools/output-accumulator.d.ts +1 -1
  177. package/dist/core/tools/output-accumulator.d.ts.map +1 -1
  178. package/dist/core/tools/output-accumulator.js +76 -34
  179. package/dist/core/tools/output-accumulator.js.map +1 -1
  180. package/dist/main.d.ts.map +1 -1
  181. package/dist/main.js +17 -5
  182. package/dist/main.js.map +1 -1
  183. package/dist/modes/interactive/components/footer.d.ts +7 -0
  184. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  185. package/dist/modes/interactive/components/footer.js +34 -8
  186. package/dist/modes/interactive/components/footer.js.map +1 -1
  187. package/dist/modes/interactive/grok/chrome.d.ts +2 -0
  188. package/dist/modes/interactive/grok/chrome.d.ts.map +1 -1
  189. package/dist/modes/interactive/grok/chrome.js.map +1 -1
  190. package/dist/modes/interactive/interactive-host-runtime.d.ts +121 -1
  191. package/dist/modes/interactive/interactive-host-runtime.d.ts.map +1 -1
  192. package/dist/modes/interactive/interactive-host-runtime.js +336 -65
  193. package/dist/modes/interactive/interactive-host-runtime.js.map +1 -1
  194. package/dist/modes/interactive/interactive-mode.d.ts +7 -0
  195. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  196. package/dist/modes/interactive/interactive-mode.js +114 -2
  197. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  198. package/dist/modes/rpc/connection-handler.d.ts +8 -1
  199. package/dist/modes/rpc/connection-handler.d.ts.map +1 -1
  200. package/dist/modes/rpc/connection-handler.js +145 -49
  201. package/dist/modes/rpc/connection-handler.js.map +1 -1
  202. package/dist/modes/rpc/host-ensure.d.ts +19 -0
  203. package/dist/modes/rpc/host-ensure.d.ts.map +1 -1
  204. package/dist/modes/rpc/host-ensure.js +79 -15
  205. package/dist/modes/rpc/host-ensure.js.map +1 -1
  206. package/dist/modes/rpc/host-lifecycle.d.ts +29 -0
  207. package/dist/modes/rpc/host-lifecycle.d.ts.map +1 -1
  208. package/dist/modes/rpc/host-lifecycle.js +96 -25
  209. package/dist/modes/rpc/host-lifecycle.js.map +1 -1
  210. package/dist/modes/rpc/host-watchdog.d.ts +2 -0
  211. package/dist/modes/rpc/host-watchdog.d.ts.map +1 -1
  212. package/dist/modes/rpc/host-watchdog.js +23 -12
  213. package/dist/modes/rpc/host-watchdog.js.map +1 -1
  214. package/dist/modes/rpc/multi-session-host.js +6 -4
  215. package/dist/modes/rpc/multi-session-host.js.map +1 -1
  216. package/dist/modes/rpc/rpc-client.d.ts +10 -4
  217. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  218. package/dist/modes/rpc/rpc-client.js +47 -10
  219. package/dist/modes/rpc/rpc-client.js.map +1 -1
  220. package/dist/modes/rpc/rpc-input-validation.d.ts +1 -0
  221. package/dist/modes/rpc/rpc-input-validation.d.ts.map +1 -1
  222. package/dist/modes/rpc/rpc-input-validation.js +66 -0
  223. package/dist/modes/rpc/rpc-input-validation.js.map +1 -1
  224. package/dist/modes/rpc/rpc-types.d.ts +86 -1
  225. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  226. package/dist/modes/rpc/rpc-types.js.map +1 -1
  227. package/dist/modes/rpc/session-binding.d.ts +1 -0
  228. package/dist/modes/rpc/session-binding.d.ts.map +1 -1
  229. package/dist/modes/rpc/session-binding.js +21 -1
  230. package/dist/modes/rpc/session-binding.js.map +1 -1
  231. package/dist/modes/rpc/session-command-router.d.ts.map +1 -1
  232. package/dist/modes/rpc/session-command-router.js +1 -0
  233. package/dist/modes/rpc/session-command-router.js.map +1 -1
  234. package/dist/modes/rpc/session-event-writer.d.ts +2 -0
  235. package/dist/modes/rpc/session-event-writer.d.ts.map +1 -1
  236. package/dist/modes/rpc/session-event-writer.js +54 -7
  237. package/dist/modes/rpc/session-event-writer.js.map +1 -1
  238. package/dist/modes/rpc/session-extension-ui-requests.d.ts +1 -0
  239. package/dist/modes/rpc/session-extension-ui-requests.d.ts.map +1 -1
  240. package/dist/modes/rpc/session-extension-ui-requests.js +5 -0
  241. package/dist/modes/rpc/session-extension-ui-requests.js.map +1 -1
  242. package/dist/modes/rpc/session-registry.d.ts +10 -2
  243. package/dist/modes/rpc/session-registry.d.ts.map +1 -1
  244. package/dist/modes/rpc/session-registry.js +58 -4
  245. package/dist/modes/rpc/session-registry.js.map +1 -1
  246. package/dist/modes/rpc/socket-event-fanout.d.ts +22 -0
  247. package/dist/modes/rpc/socket-event-fanout.d.ts.map +1 -0
  248. package/dist/modes/rpc/socket-event-fanout.js +84 -0
  249. package/dist/modes/rpc/socket-event-fanout.js.map +1 -0
  250. package/docs/rpc.md +18 -2
  251. package/docs/settings.md +34 -0
  252. package/docs/windows.md +2 -0
  253. package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +50 -0
  254. package/node_modules/@code-yeongyu/senpi-codemode/package.json +4 -4
  255. package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/worker-indirect-eval.js +139 -90
  256. package/node_modules/@code-yeongyu/senpi-codemode/src/prompt/eval-prompt.ts +4 -4
  257. package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.d.ts.map +1 -1
  258. package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.js +40 -20
  259. package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.js.map +1 -1
  260. package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.d.ts +3 -3
  261. package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.d.ts.map +1 -1
  262. package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.js.map +1 -1
  263. package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/shell-output.d.ts +1 -1
  264. package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/shell-output.d.ts.map +1 -1
  265. package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/shell-output.js +28 -9
  266. package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/shell-output.js.map +1 -1
  267. package/node_modules/@earendil-works/pi-agent-core/package.json +3 -3
  268. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.d.ts.map +1 -1
  269. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +67 -38
  270. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js.map +1 -1
  271. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent/measure.d.ts +20 -0
  272. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent/measure.d.ts.map +1 -0
  273. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent/measure.js +443 -0
  274. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent/measure.js.map +1 -0
  275. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent.d.ts +2 -0
  276. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent.d.ts.map +1 -1
  277. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent.js +2 -0
  278. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent.js.map +1 -1
  279. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +1 -1
  280. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js.map +1 -1
  281. package/node_modules/@earendil-works/pi-ai/dist/index.d.ts +1 -0
  282. package/node_modules/@earendil-works/pi-ai/dist/index.d.ts.map +1 -1
  283. package/node_modules/@earendil-works/pi-ai/dist/index.js +1 -0
  284. package/node_modules/@earendil-works/pi-ai/dist/index.js.map +1 -1
  285. package/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
  286. package/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-ai-gateway.json +1 -1
  287. package/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-workers-ai.json +1 -1
  288. package/node_modules/@earendil-works/pi-ai/dist/providers/data/fireworks.json +1 -1
  289. package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode-go.json +1 -1
  290. package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
  291. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
  292. package/node_modules/@earendil-works/pi-ai/dist/providers/data/together.json +1 -1
  293. package/node_modules/@earendil-works/pi-ai/dist/providers/data/zai-coding-cn.json +1 -1
  294. package/node_modules/@earendil-works/pi-ai/dist/providers/data/zai.json +1 -1
  295. package/node_modules/@earendil-works/pi-ai/package.json +2 -2
  296. package/node_modules/@earendil-works/pi-pty/package.json +1 -1
  297. package/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
  298. package/node_modules/@earendil-works/pi-tui/dist/components/editor.d.ts +7 -0
  299. package/node_modules/@earendil-works/pi-tui/dist/components/editor.d.ts.map +1 -1
  300. package/node_modules/@earendil-works/pi-tui/dist/components/editor.js +5 -0
  301. package/node_modules/@earendil-works/pi-tui/dist/components/editor.js.map +1 -1
  302. package/node_modules/@earendil-works/pi-tui/dist/mux.d.ts +1 -1
  303. package/node_modules/@earendil-works/pi-tui/dist/mux.d.ts.map +1 -1
  304. package/node_modules/@earendil-works/pi-tui/dist/mux.js +2 -2
  305. package/node_modules/@earendil-works/pi-tui/dist/mux.js.map +1 -1
  306. package/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts +1 -0
  307. package/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts.map +1 -1
  308. package/node_modules/@earendil-works/pi-tui/dist/terminal.js +19 -0
  309. package/node_modules/@earendil-works/pi-tui/dist/terminal.js.map +1 -1
  310. package/node_modules/@earendil-works/pi-tui/package.json +1 -1
  311. package/package.json +7 -7
@@ -1,7 +1,7 @@
1
1
  import { existsSync, realpathSync } from "node:fs";
2
2
  import { basename, dirname, isAbsolute, resolve } from "node:path";
3
3
  import { ProviderScope, runWithProviderScope } from "@earendil-works/pi-ai/node/provider-scope";
4
- import { createAgentSessionRuntime, } from "../../core/agent-session-runtime.js";
4
+ import { AgentSessionRuntime, createAgentSessionRuntime, } from "../../core/agent-session-runtime.js";
5
5
  import { SessionManager } from "../../core/session-manager.js";
6
6
  export class RpcSessionRegistryError extends Error {
7
7
  constructor(code, reason) {
@@ -32,6 +32,7 @@ export class RpcSessionRegistry {
32
32
  }
33
33
  async openSession(profile) {
34
34
  this.validateProfile(profile);
35
+ this.syncRuntimeMetadata();
35
36
  const sessionPath = profile.sessionPath ? canonicalPath(profile.sessionPath) : undefined;
36
37
  if (sessionPath && this.reservations.has(sessionPath)) {
37
38
  // Attach-on-open: a live session outlives individual client attachments, so a
@@ -70,9 +71,34 @@ export class RpcSessionRegistry {
70
71
  profile: storedProfile,
71
72
  sessionPath,
72
73
  reservationKey: sessionPath,
74
+ cwd: storedProfile.cwd,
73
75
  attachments: 1,
74
76
  lifecycleMutex: Promise.resolve(),
75
77
  };
78
+ entry.switchSession = (sessionPath, options) => {
79
+ const operation = entry.lifecycleMutex.then(async () => {
80
+ if (entry.state !== "open" || !entry.runtime) {
81
+ throw new RpcSessionRegistryError("unknown_session");
82
+ }
83
+ const runtime = entry.runtime;
84
+ const cwdOverride = options?.cwdOverride;
85
+ const cwdChanged = cwdOverride !== undefined && runtime.session.sessionManager.getCwd() !== cwdOverride;
86
+ const result = await runtime.switchSession(sessionPath, options);
87
+ if (result.cancelled || !cwdChanged)
88
+ return result;
89
+ // A multi-session binding outlives an individual replacement. Keep the
90
+ // entry's runtime object aligned with the replacement so every attached
91
+ // client resolves getters and future commands against the new cwd-bound
92
+ // runtime, not the object created during open_session.
93
+ const replacement = new AgentSessionRuntime(runtime.session, runtime.services, this.options.createRuntime, [...runtime.diagnostics], runtime.modelFallbackMessage, runtime.launchProfile);
94
+ replacement.setRebindSession(entry.rebindSession);
95
+ entry.runtime = replacement;
96
+ this.syncRuntimeMetadata();
97
+ return result;
98
+ });
99
+ entry.lifecycleMutex = operation.then(() => undefined, () => undefined);
100
+ return operation;
101
+ };
76
102
  this.entries.set(handle, entry);
77
103
  try {
78
104
  const manager = sessionPath
@@ -161,10 +187,13 @@ export class RpcSessionRegistry {
161
187
  }
162
188
  /** Completes a close previously made visible by beginClose(). */
163
189
  async closeMarked(handle) {
190
+ this.syncRuntimeMetadata();
164
191
  const entry = this.entries.get(handle);
165
192
  if (entry?.state !== "closing")
166
193
  throw new RpcSessionRegistryError("unknown_session");
194
+ const previousLifecycle = entry.lifecycleMutex;
167
195
  entry.lifecycleMutex = (async () => {
196
+ await previousLifecycle;
168
197
  try {
169
198
  await entry.runtime?.session.abort();
170
199
  await entry.runtime?.session.waitForIdle();
@@ -174,22 +203,47 @@ export class RpcSessionRegistry {
174
203
  finally {
175
204
  entry.state = "closed";
176
205
  this.entries.delete(handle);
177
- if (entry.sessionPath)
178
- this.reservations.delete(entry.sessionPath);
206
+ if (entry.reservationKey)
207
+ this.reservations.delete(entry.reservationKey);
179
208
  }
180
209
  })();
181
210
  return entry.lifecycleMutex;
182
211
  }
183
212
  list() {
213
+ this.syncRuntimeMetadata();
184
214
  return [...this.entries].map(([sessionId, entry]) => ({
185
215
  sessionId,
186
216
  durableSessionId: entry.durableSessionId,
187
217
  sessionPath: entry.sessionPath,
188
- cwd: entry.profile.cwd,
218
+ cwd: entry.cwd,
189
219
  name: entry.runtime?.session.sessionManager.getSessionName(),
190
220
  status: entry.state,
191
221
  }));
192
222
  }
223
+ /** Reconcile path and durable identity after runtime replacement. */
224
+ syncRuntimeMetadata() {
225
+ for (const entry of this.entries.values()) {
226
+ const manager = entry.runtime?.session.sessionManager;
227
+ if (!manager)
228
+ continue;
229
+ const currentPath = manager.getSessionFile();
230
+ // Preserve the originally canonicalized key while the runtime still points at
231
+ // the same path. SessionManager may expose a symlink-resolved spelling after
232
+ // opening a file that did not exist yet; treating that as replacement would
233
+ // break ordinary attach-on-open aliases.
234
+ if (currentPath !== entry.sessionPath) {
235
+ const currentKey = currentPath ? canonicalPath(currentPath) : undefined;
236
+ if (entry.reservationKey)
237
+ this.reservations.delete(entry.reservationKey);
238
+ if (currentKey)
239
+ this.reservations.add(currentKey);
240
+ entry.reservationKey = currentKey;
241
+ entry.sessionPath = currentPath;
242
+ }
243
+ entry.durableSessionId = manager.getSessionId();
244
+ entry.cwd = manager.getCwd();
245
+ }
246
+ }
193
247
  validateProfile(profile) {
194
248
  if (!isAbsolute(profile.cwd) || (profile.sessionPath !== undefined && !isAbsolute(profile.sessionPath))) {
195
249
  throw new RpcSessionRegistryError("invalid_path");
@@ -1 +1 @@
1
- {"version":3,"file":"session-registry.js","sourceRoot":"","sources":["../../../src/modes/rpc/session-registry.ts"],"names":[],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AE,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,cAAc,CAAC,cAAc,EAAE;YAC5D,MAAM,EAAE,KAAK,CAAC,KAAK;SACnB,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,eAAe,CAAC,OAAgC;QACvD,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,KAAK,SAAS,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC;YACzG,MAAM,IAAI,uBAAuB,CAAC,cAAc,CAAC,CAAC;QACnD,CAAC;IACF,CAAC;CACD","sourcesContent":["import { existsSync, realpathSync } from \"node:fs\";\nimport { basename, dirname, isAbsolute, resolve } from \"node:path\";\nimport { ProviderScope, runWithProviderScope } from \"@earendil-works/pi-ai/node/provider-scope\";\nimport {\n\ttype AgentSessionLaunchProfile,\n\ttype AgentSessionRuntime,\n\ttype CreateAgentSessionRuntimeFactory,\n\tcreateAgentSessionRuntime,\n} from \"../../core/agent-session-runtime.ts\";\nimport { SessionManager } from \"../../core/session-manager.ts\";\n\n/** The immutable flags selected when a routing session is opened. */\nexport interface RpcSessionLaunchProfile extends AgentSessionLaunchProfile {\n\tsessionPath?: string;\n}\n\nexport type SessionRuntime = Pick<AgentSessionRuntime, \"session\" | \"dispose\">;\nexport type RpcSessionState = \"opening\" | \"open\" | \"closing\" | \"closed\";\n\nexport interface RpcSessionEntry {\n\tstate: RpcSessionState;\n\truntime?: SessionRuntime;\n\tscope: ProviderScope;\n\tprofile: Readonly<RpcSessionLaunchProfile>;\n\tdurableSessionId?: string;\n\tsessionPath?: string;\n\t/** Canonical reservation key for path-opened sessions; matches the reservations set. */\n\treservationKey?: string;\n\t/** Live attachments (open + later attaches). The runtime is disposed only when the last one closes. */\n\tattachments: number;\n\tlifecycleMutex: Promise<void>;\n}\n\nexport class RpcSessionRegistryError extends Error {\n\treadonly code: \"unknown_session\" | \"session_closing\" | \"session_path_in_use\" | \"invalid_path\" | \"open_failed\";\n\n\tconstructor(code: RpcSessionRegistryError[\"code\"], reason?: string) {\n\t\tsuper(code === \"open_failed\" && reason ? `${code}: ${reason}` : code);\n\t\tthis.code = code;\n\t\tthis.name = \"RpcSessionRegistryError\";\n\t}\n}\n\nexport interface RpcSessionRegistryOptions {\n\tagentDir: string;\n\tcreateRuntime: CreateAgentSessionRuntimeFactory;\n}\n\nexport interface OpenRpcSession {\n\tsessionId: string;\n\tdurableSessionId: string;\n\tsessionPath?: string;\n\t/** True when this open attached to an already-open session instead of creating one. */\n\tattached?: boolean;\n}\n\nfunction canonicalPath(path: string): string {\n\tconst absolutePath = resolve(path);\n\tif (existsSync(absolutePath)) return realpathSync(absolutePath);\n\treturn `${realpathSync(dirname(absolutePath))}/${basename(absolutePath)}`;\n}\n\nfunction frozenProfile(profile: RpcSessionLaunchProfile): Readonly<RpcSessionLaunchProfile> {\n\treturn Object.freeze({\n\t\t...profile,\n\t\t...(profile.creationModel ? { creationModel: Object.freeze({ ...profile.creationModel }) } : {}),\n\t});\n}\n\n/** Process-local lifecycle owner for multi-session RPC runtimes. */\nexport class RpcSessionRegistry {\n\tprivate readonly entries = new Map<string, RpcSessionEntry>();\n\tprivate readonly reservations = new Set<string>();\n\tprivate nextHandle = 0;\n\tprivate readonly options: RpcSessionRegistryOptions;\n\n\tconstructor(options: RpcSessionRegistryOptions) {\n\t\tthis.options = options;\n\t}\n\n\tasync openSession(profile: RpcSessionLaunchProfile): Promise<OpenRpcSession> {\n\t\tthis.validateProfile(profile);\n\t\tconst sessionPath = profile.sessionPath ? canonicalPath(profile.sessionPath) : undefined;\n\t\tif (sessionPath && this.reservations.has(sessionPath)) {\n\t\t\t// Attach-on-open: a live session outlives individual client attachments, so a\n\t\t\t// resume (or a second surface) for an already-hosted path joins the existing\n\t\t\t// runtime instead of failing. Entries still opening or closing keep the\n\t\t\t// exclusive reservation and reject as before.\n\t\t\tconst existing = [...this.entries].find(\n\t\t\t\t([, entry]) => entry.reservationKey === sessionPath && entry.state === \"open\",\n\t\t\t);\n\t\t\tif (!existing) throw new RpcSessionRegistryError(\"session_path_in_use\");\n\t\t\tconst [handle, entry] = existing;\n\t\t\tentry.attachments += 1;\n\t\t\tif (!entry.durableSessionId) throw new RpcSessionRegistryError(\"session_path_in_use\");\n\t\t\treturn {\n\t\t\t\tsessionId: handle,\n\t\t\t\tdurableSessionId: entry.durableSessionId,\n\t\t\t\tsessionPath: entry.sessionPath,\n\t\t\t\tattached: true,\n\t\t\t};\n\t\t}\n\t\tif (sessionPath) this.reservations.add(sessionPath);\n\n\t\t// Resume vs create parity (D1 + omo SenpiSessionRuntime.ts:198-200):\n\t\t// Create-only launch semantics mirror classic startup flags. A resumed\n\t\t// session restores its persisted model and thinking level instead of being\n\t\t// overridden by the new open_session request.\n\t\tconst isResume = sessionPath !== undefined && existsSync(sessionPath);\n\t\tconst storedProfile = frozenProfile({ ...profile, ...(sessionPath ? { sessionPath } : {}) });\n\t\tconst runtimeProfile = isResume\n\t\t\t? frozenProfile({ ...storedProfile, creationModel: undefined, initialThinkingLevel: undefined })\n\t\t\t: storedProfile;\n\n\t\tconst handle = `rpc-${++this.nextHandle}`;\n\t\tconst entry: RpcSessionEntry = {\n\t\t\tstate: \"opening\",\n\t\t\tscope: new ProviderScope(),\n\t\t\tprofile: storedProfile,\n\t\t\tsessionPath,\n\t\t\treservationKey: sessionPath,\n\t\t\tattachments: 1,\n\t\t\tlifecycleMutex: Promise.resolve(),\n\t\t};\n\t\tthis.entries.set(handle, entry);\n\t\ttry {\n\t\t\tconst manager = sessionPath\n\t\t\t\t? SessionManager.open(sessionPath, undefined, storedProfile.cwd)\n\t\t\t\t: SessionManager.create(storedProfile.cwd);\n\t\t\tentry.runtime = await runWithProviderScope(entry.scope, () =>\n\t\t\t\tcreateAgentSessionRuntime(this.options.createRuntime, {\n\t\t\t\t\tcwd: manager.getCwd(),\n\t\t\t\t\tagentDir: this.options.agentDir,\n\t\t\t\t\tsessionManager: manager,\n\t\t\t\t\tlaunchProfile: runtimeProfile,\n\t\t\t\t}),\n\t\t\t);\n\t\t\tentry.durableSessionId = manager.getSessionId();\n\t\t\tentry.sessionPath ??= manager.getSessionFile();\n\t\t\tentry.state = \"open\";\n\t\t\treturn { sessionId: handle, durableSessionId: entry.durableSessionId, sessionPath: entry.sessionPath };\n\t\t} catch (error) {\n\t\t\t// Runtime construction may have started extensions, watchers, and provider\n\t\t\t// registrations before it rejects. Keep the reservation and entry private\n\t\t\t// until all of those resources have been torn down, then release them as\n\t\t\t// one rollback so the path can immediately be opened again.\n\t\t\ttry {\n\t\t\t\tawait entry.runtime?.dispose();\n\t\t\t} catch {\n\t\t\t\t// The original construction error remains the externally visible cause.\n\t\t\t} finally {\n\t\t\t\ttry {\n\t\t\t\t\tawait entry.scope.close?.();\n\t\t\t\t} finally {\n\t\t\t\t\tthis.entries.delete(handle);\n\t\t\t\t\tif (sessionPath) this.reservations.delete(sessionPath);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (error instanceof RpcSessionRegistryError) throw error;\n\t\t\tthrow new RpcSessionRegistryError(\"open_failed\", error instanceof Error ? error.message : undefined);\n\t\t}\n\t}\n\n\t/**\n\t * Read-only lookup with no state transitions or attachment accounting.\n\t * Exists so lifecycle decisions (e.g. deferring a dropped connection's\n\t * release while a turn is still streaming) can inspect the live entry\n\t * without claiming it.\n\t */\n\tpeek(handle: string): RpcSessionEntry | undefined {\n\t\treturn this.entries.get(handle);\n\t}\n\n\tgetForCommand(handle: string, command: string): RpcSessionEntry {\n\t\tconst entry = this.entries.get(handle);\n\t\tif (!entry) throw new RpcSessionRegistryError(\"unknown_session\");\n\t\tif (entry.state === \"closing\" && ![\"abort\", \"abort_bash\", \"extension_ui_response\"].includes(command)) {\n\t\t\tthrow new RpcSessionRegistryError(\"session_closing\");\n\t\t}\n\t\tif (entry.state !== \"open\" && entry.state !== \"closing\") throw new RpcSessionRegistryError(\"unknown_session\");\n\t\treturn entry;\n\t}\n\n\t/**\n\t * Starts a close synchronously. Call this before disposing any session-owned\n\t * binding so a concurrent command cannot reach a half-disposed handler.\n\t * Each call releases one attachment; the entry transitions to \"closing\" only\n\t * when the last attachment closes, so callers must check the returned state\n\t * and skip finalization while other attachments remain.\n\t */\n\tbeginClose(handle: string): RpcSessionEntry {\n\t\tconst entry = this.entries.get(handle);\n\t\tif (entry?.state !== \"open\") throw new RpcSessionRegistryError(\"unknown_session\");\n\t\tentry.attachments -= 1;\n\t\tif (entry.attachments > 0) return entry;\n\t\tentry.state = \"closing\";\n\t\treturn entry;\n\t}\n\n\tasync close(handle: string): Promise<void> {\n\t\tconst entry = this.beginClose(handle);\n\t\t// Other attachments may still own the live session; only the last close finalizes.\n\t\tif (entry.state !== \"closing\") return;\n\t\treturn this.closeMarked(handle);\n\t}\n\n\t/** Completes a close previously made visible by beginClose(). */\n\tasync closeMarked(handle: string): Promise<void> {\n\t\tconst entry = this.entries.get(handle);\n\t\tif (entry?.state !== \"closing\") throw new RpcSessionRegistryError(\"unknown_session\");\n\t\tentry.lifecycleMutex = (async () => {\n\t\t\ttry {\n\t\t\t\tawait entry.runtime?.session.abort();\n\t\t\t\tawait entry.runtime?.session.waitForIdle();\n\t\t\t\tawait entry.runtime?.dispose();\n\t\t\t\tawait entry.scope.close?.();\n\t\t\t} finally {\n\t\t\t\tentry.state = \"closed\";\n\t\t\t\tthis.entries.delete(handle);\n\t\t\t\tif (entry.sessionPath) this.reservations.delete(entry.sessionPath);\n\t\t\t}\n\t\t})();\n\t\treturn entry.lifecycleMutex;\n\t}\n\n\tlist(): Array<{\n\t\tsessionId: string;\n\t\tdurableSessionId?: string;\n\t\tsessionPath?: string;\n\t\tcwd: string;\n\t\tname?: string;\n\t\tstatus: RpcSessionState;\n\t}> {\n\t\treturn [...this.entries].map(([sessionId, entry]) => ({\n\t\t\tsessionId,\n\t\t\tdurableSessionId: entry.durableSessionId,\n\t\t\tsessionPath: entry.sessionPath,\n\t\t\tcwd: entry.profile.cwd,\n\t\t\tname: entry.runtime?.session.sessionManager.getSessionName(),\n\t\t\tstatus: entry.state,\n\t\t}));\n\t}\n\n\tprivate validateProfile(profile: RpcSessionLaunchProfile): void {\n\t\tif (!isAbsolute(profile.cwd) || (profile.sessionPath !== undefined && !isAbsolute(profile.sessionPath))) {\n\t\t\tthrow new RpcSessionRegistryError(\"invalid_path\");\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"session-registry.js","sourceRoot":"","sources":["../../../src/modes/rpc/session-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAChG,OAAO,EAEN,mBAAmB,EAEnB,yBAAyB,GACzB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AA8B/D,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAGjD,YAAY,IAAqC,EAAE,MAAe;QACjE,KAAK,CAAC,IAAI,KAAK,aAAa,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,KAAK,MAAM,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACtE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;IACvC,CAAC;CACD;AAeD,SAAS,aAAa,CAAC,IAAY;IAClC,MAAM,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,IAAI,UAAU,CAAC,YAAY,CAAC;QAAE,OAAO,YAAY,CAAC,YAAY,CAAC,CAAC;IAChE,OAAO,GAAG,YAAY,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,IAAI,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;AAC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W,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;gBACxE,IAAI,KAAK,CAAC,cAAc;oBAAE,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;gBACzE,IAAI,UAAU;oBAAE,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;gBAClD,KAAK,CAAC,cAAc,GAAG,UAAU,CAAC;gBAClC,KAAK,CAAC,WAAW,GAAG,WAAW,CAAC;YACjC,CAAC;YACD,KAAK,CAAC,gBAAgB,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;YAChD,KAAK,CAAC,GAAG,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;QAC9B,CAAC;IACF,CAAC;IAEO,eAAe,CAAC,OAAgC;QACvD,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,KAAK,SAAS,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC;YACzG,MAAM,IAAI,uBAAuB,CAAC,cAAc,CAAC,CAAC;QACnD,CAAC;IACF,CAAC;CACD","sourcesContent":["import { existsSync, realpathSync } from \"node:fs\";\nimport { basename, dirname, isAbsolute, resolve } from \"node:path\";\nimport { ProviderScope, runWithProviderScope } from \"@earendil-works/pi-ai/node/provider-scope\";\nimport {\n\ttype AgentSessionLaunchProfile,\n\tAgentSessionRuntime,\n\ttype CreateAgentSessionRuntimeFactory,\n\tcreateAgentSessionRuntime,\n} from \"../../core/agent-session-runtime.ts\";\nimport { SessionManager } from \"../../core/session-manager.ts\";\n\n/** The immutable flags selected when a routing session is opened. */\nexport interface RpcSessionLaunchProfile extends AgentSessionLaunchProfile {\n\tsessionPath?: string;\n}\n\nexport type SessionRuntime = AgentSessionRuntime;\nexport type RpcSessionState = \"opening\" | \"open\" | \"closing\" | \"closed\";\n\nexport interface RpcSessionEntry {\n\tstate: RpcSessionState;\n\truntime?: SessionRuntime;\n\t/** Resolves replacement against the runtime currently owned by this entry. */\n\tswitchSession?: SessionRuntime[\"switchSession\"];\n\t/** Rebind callback installed by the shared RPC connection handler. */\n\trebindSession?: Parameters<SessionRuntime[\"setRebindSession\"]>[0];\n\tscope: ProviderScope;\n\tprofile: Readonly<RpcSessionLaunchProfile>;\n\tdurableSessionId?: string;\n\tsessionPath?: string;\n\t/** Canonical reservation key for path-opened sessions; matches the reservations set. */\n\treservationKey?: string;\n\t/** Current runtime cwd, which can change when a session is replaced. */\n\tcwd: string;\n\t/** Live attachments (open + later attaches). The runtime is disposed only when the last one closes. */\n\tattachments: number;\n\tlifecycleMutex: Promise<void>;\n}\n\nexport class RpcSessionRegistryError extends Error {\n\treadonly code: \"unknown_session\" | \"session_closing\" | \"session_path_in_use\" | \"invalid_path\" | \"open_failed\";\n\n\tconstructor(code: RpcSessionRegistryError[\"code\"], reason?: string) {\n\t\tsuper(code === \"open_failed\" && reason ? `${code}: ${reason}` : code);\n\t\tthis.code = code;\n\t\tthis.name = \"RpcSessionRegistryError\";\n\t}\n}\n\nexport interface RpcSessionRegistryOptions {\n\tagentDir: string;\n\tcreateRuntime: CreateAgentSessionRuntimeFactory;\n}\n\nexport interface OpenRpcSession {\n\tsessionId: string;\n\tdurableSessionId: string;\n\tsessionPath?: string;\n\t/** True when this open attached to an already-open session instead of creating one. */\n\tattached?: boolean;\n}\n\nfunction canonicalPath(path: string): string {\n\tconst absolutePath = resolve(path);\n\tif (existsSync(absolutePath)) return realpathSync(absolutePath);\n\treturn `${realpathSync(dirname(absolutePath))}/${basename(absolutePath)}`;\n}\n\nfunction frozenProfile(profile: RpcSessionLaunchProfile): Readonly<RpcSessionLaunchProfile> {\n\treturn Object.freeze({\n\t\t...profile,\n\t\t...(profile.creationModel ? { creationModel: Object.freeze({ ...profile.creationModel }) } : {}),\n\t});\n}\n\n/** Process-local lifecycle owner for multi-session RPC runtimes. */\nexport class RpcSessionRegistry {\n\tprivate readonly entries = new Map<string, RpcSessionEntry>();\n\tprivate readonly reservations = new Set<string>();\n\tprivate nextHandle = 0;\n\tprivate readonly options: RpcSessionRegistryOptions;\n\n\tconstructor(options: RpcSessionRegistryOptions) {\n\t\tthis.options = options;\n\t}\n\n\tasync openSession(profile: RpcSessionLaunchProfile): Promise<OpenRpcSession> {\n\t\tthis.validateProfile(profile);\n\t\tthis.syncRuntimeMetadata();\n\t\tconst sessionPath = profile.sessionPath ? canonicalPath(profile.sessionPath) : undefined;\n\t\tif (sessionPath && this.reservations.has(sessionPath)) {\n\t\t\t// Attach-on-open: a live session outlives individual client attachments, so a\n\t\t\t// resume (or a second surface) for an already-hosted path joins the existing\n\t\t\t// runtime instead of failing. Entries still opening or closing keep the\n\t\t\t// exclusive reservation and reject as before.\n\t\t\tconst existing = [...this.entries].find(\n\t\t\t\t([, entry]) => entry.reservationKey === sessionPath && entry.state === \"open\",\n\t\t\t);\n\t\t\tif (!existing) throw new RpcSessionRegistryError(\"session_path_in_use\");\n\t\t\tconst [handle, entry] = existing;\n\t\t\tentry.attachments += 1;\n\t\t\tif (!entry.durableSessionId) throw new RpcSessionRegistryError(\"session_path_in_use\");\n\t\t\treturn {\n\t\t\t\tsessionId: handle,\n\t\t\t\tdurableSessionId: entry.durableSessionId,\n\t\t\t\tsessionPath: entry.sessionPath,\n\t\t\t\tattached: true,\n\t\t\t};\n\t\t}\n\t\tif (sessionPath) this.reservations.add(sessionPath);\n\n\t\t// Resume vs create parity (D1 + omo SenpiSessionRuntime.ts:198-200):\n\t\t// Create-only launch semantics mirror classic startup flags. A resumed\n\t\t// session restores its persisted model and thinking level instead of being\n\t\t// overridden by the new open_session request.\n\t\tconst isResume = sessionPath !== undefined && existsSync(sessionPath);\n\t\tconst storedProfile = frozenProfile({ ...profile, ...(sessionPath ? { sessionPath } : {}) });\n\t\tconst runtimeProfile = isResume\n\t\t\t? frozenProfile({ ...storedProfile, creationModel: undefined, initialThinkingLevel: undefined })\n\t\t\t: storedProfile;\n\n\t\tconst handle = `rpc-${++this.nextHandle}`;\n\t\tconst entry: RpcSessionEntry = {\n\t\t\tstate: \"opening\",\n\t\t\tscope: new ProviderScope(),\n\t\t\tprofile: storedProfile,\n\t\t\tsessionPath,\n\t\t\treservationKey: sessionPath,\n\t\t\tcwd: storedProfile.cwd,\n\t\t\tattachments: 1,\n\t\t\tlifecycleMutex: Promise.resolve(),\n\t\t};\n\t\tentry.switchSession = (sessionPath, options) => {\n\t\t\tconst operation = entry.lifecycleMutex.then(async () => {\n\t\t\t\tif (entry.state !== \"open\" || !entry.runtime) {\n\t\t\t\t\tthrow new RpcSessionRegistryError(\"unknown_session\");\n\t\t\t\t}\n\t\t\t\tconst runtime = entry.runtime;\n\t\t\t\tconst cwdOverride = options?.cwdOverride;\n\t\t\t\tconst cwdChanged = cwdOverride !== undefined && runtime.session.sessionManager.getCwd() !== cwdOverride;\n\t\t\t\tconst result = await runtime.switchSession(sessionPath, options);\n\t\t\t\tif (result.cancelled || !cwdChanged) return result;\n\n\t\t\t\t// A multi-session binding outlives an individual replacement. Keep the\n\t\t\t\t// entry's runtime object aligned with the replacement so every attached\n\t\t\t\t// client resolves getters and future commands against the new cwd-bound\n\t\t\t\t// runtime, not the object created during open_session.\n\t\t\t\tconst replacement = new AgentSessionRuntime(\n\t\t\t\t\truntime.session,\n\t\t\t\t\truntime.services,\n\t\t\t\t\tthis.options.createRuntime,\n\t\t\t\t\t[...runtime.diagnostics],\n\t\t\t\t\truntime.modelFallbackMessage,\n\t\t\t\t\truntime.launchProfile,\n\t\t\t\t);\n\t\t\t\treplacement.setRebindSession(entry.rebindSession);\n\t\t\t\tentry.runtime = replacement;\n\t\t\t\tthis.syncRuntimeMetadata();\n\t\t\t\treturn result;\n\t\t\t});\n\t\t\tentry.lifecycleMutex = operation.then(\n\t\t\t\t() => undefined,\n\t\t\t\t() => undefined,\n\t\t\t);\n\t\t\treturn operation;\n\t\t};\n\t\tthis.entries.set(handle, entry);\n\t\ttry {\n\t\t\tconst manager = sessionPath\n\t\t\t\t? SessionManager.open(sessionPath, undefined, storedProfile.cwd)\n\t\t\t\t: SessionManager.create(storedProfile.cwd);\n\t\t\tentry.runtime = await runWithProviderScope(entry.scope, () =>\n\t\t\t\tcreateAgentSessionRuntime(this.options.createRuntime, {\n\t\t\t\t\tcwd: manager.getCwd(),\n\t\t\t\t\tagentDir: this.options.agentDir,\n\t\t\t\t\tsessionManager: manager,\n\t\t\t\t\tlaunchProfile: runtimeProfile,\n\t\t\t\t}),\n\t\t\t);\n\t\t\tentry.durableSessionId = manager.getSessionId();\n\t\t\tentry.sessionPath ??= manager.getSessionFile();\n\t\t\tentry.state = \"open\";\n\t\t\treturn { sessionId: handle, durableSessionId: entry.durableSessionId, sessionPath: entry.sessionPath };\n\t\t} catch (error) {\n\t\t\t// Runtime construction may have started extensions, watchers, and provider\n\t\t\t// registrations before it rejects. Keep the reservation and entry private\n\t\t\t// until all of those resources have been torn down, then release them as\n\t\t\t// one rollback so the path can immediately be opened again.\n\t\t\ttry {\n\t\t\t\tawait entry.runtime?.dispose();\n\t\t\t} catch {\n\t\t\t\t// The original construction error remains the externally visible cause.\n\t\t\t} finally {\n\t\t\t\ttry {\n\t\t\t\t\tawait entry.scope.close?.();\n\t\t\t\t} finally {\n\t\t\t\t\tthis.entries.delete(handle);\n\t\t\t\t\tif (sessionPath) this.reservations.delete(sessionPath);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (error instanceof RpcSessionRegistryError) throw error;\n\t\t\tthrow new RpcSessionRegistryError(\"open_failed\", error instanceof Error ? error.message : undefined);\n\t\t}\n\t}\n\n\t/**\n\t * Read-only lookup with no state transitions or attachment accounting.\n\t * Exists so lifecycle decisions (e.g. deferring a dropped connection's\n\t * release while a turn is still streaming) can inspect the live entry\n\t * without claiming it.\n\t */\n\tpeek(handle: string): RpcSessionEntry | undefined {\n\t\treturn this.entries.get(handle);\n\t}\n\n\tgetForCommand(handle: string, command: string): RpcSessionEntry {\n\t\tconst entry = this.entries.get(handle);\n\t\tif (!entry) throw new RpcSessionRegistryError(\"unknown_session\");\n\t\tif (entry.state === \"closing\" && ![\"abort\", \"abort_bash\", \"extension_ui_response\"].includes(command)) {\n\t\t\tthrow new RpcSessionRegistryError(\"session_closing\");\n\t\t}\n\t\tif (entry.state !== \"open\" && entry.state !== \"closing\") throw new RpcSessionRegistryError(\"unknown_session\");\n\t\treturn entry;\n\t}\n\n\t/**\n\t * Starts a close synchronously. Call this before disposing any session-owned\n\t * binding so a concurrent command cannot reach a half-disposed handler.\n\t * Each call releases one attachment; the entry transitions to \"closing\" only\n\t * when the last attachment closes, so callers must check the returned state\n\t * and skip finalization while other attachments remain.\n\t */\n\tbeginClose(handle: string): RpcSessionEntry {\n\t\tconst entry = this.entries.get(handle);\n\t\tif (entry?.state !== \"open\") throw new RpcSessionRegistryError(\"unknown_session\");\n\t\tentry.attachments -= 1;\n\t\tif (entry.attachments > 0) return entry;\n\t\tentry.state = \"closing\";\n\t\treturn entry;\n\t}\n\n\tasync close(handle: string): Promise<void> {\n\t\tconst entry = this.beginClose(handle);\n\t\t// Other attachments may still own the live session; only the last close finalizes.\n\t\tif (entry.state !== \"closing\") return;\n\t\treturn this.closeMarked(handle);\n\t}\n\n\t/** Completes a close previously made visible by beginClose(). */\n\tasync closeMarked(handle: string): Promise<void> {\n\t\tthis.syncRuntimeMetadata();\n\t\tconst entry = this.entries.get(handle);\n\t\tif (entry?.state !== \"closing\") throw new RpcSessionRegistryError(\"unknown_session\");\n\t\tconst previousLifecycle = entry.lifecycleMutex;\n\t\tentry.lifecycleMutex = (async () => {\n\t\t\tawait previousLifecycle;\n\t\t\ttry {\n\t\t\t\tawait entry.runtime?.session.abort();\n\t\t\t\tawait entry.runtime?.session.waitForIdle();\n\t\t\t\tawait entry.runtime?.dispose();\n\t\t\t\tawait entry.scope.close?.();\n\t\t\t} finally {\n\t\t\t\tentry.state = \"closed\";\n\t\t\t\tthis.entries.delete(handle);\n\t\t\t\tif (entry.reservationKey) this.reservations.delete(entry.reservationKey);\n\t\t\t}\n\t\t})();\n\t\treturn entry.lifecycleMutex;\n\t}\n\n\tlist(): Array<{\n\t\tsessionId: string;\n\t\tdurableSessionId?: string;\n\t\tsessionPath?: string;\n\t\tcwd: string;\n\t\tname?: string;\n\t\tstatus: RpcSessionState;\n\t}> {\n\t\tthis.syncRuntimeMetadata();\n\t\treturn [...this.entries].map(([sessionId, entry]) => ({\n\t\t\tsessionId,\n\t\t\tdurableSessionId: entry.durableSessionId,\n\t\t\tsessionPath: entry.sessionPath,\n\t\t\tcwd: entry.cwd,\n\t\t\tname: entry.runtime?.session.sessionManager.getSessionName(),\n\t\t\tstatus: entry.state,\n\t\t}));\n\t}\n\n\t/** Reconcile path and durable identity after runtime replacement. */\n\tprivate syncRuntimeMetadata(): void {\n\t\tfor (const entry of this.entries.values()) {\n\t\t\tconst manager = entry.runtime?.session.sessionManager;\n\t\t\tif (!manager) continue;\n\t\t\tconst currentPath = manager.getSessionFile();\n\t\t\t// Preserve the originally canonicalized key while the runtime still points at\n\t\t\t// the same path. SessionManager may expose a symlink-resolved spelling after\n\t\t\t// opening a file that did not exist yet; treating that as replacement would\n\t\t\t// break ordinary attach-on-open aliases.\n\t\t\tif (currentPath !== entry.sessionPath) {\n\t\t\t\tconst currentKey = currentPath ? canonicalPath(currentPath) : undefined;\n\t\t\t\tif (entry.reservationKey) this.reservations.delete(entry.reservationKey);\n\t\t\t\tif (currentKey) this.reservations.add(currentKey);\n\t\t\t\tentry.reservationKey = currentKey;\n\t\t\t\tentry.sessionPath = currentPath;\n\t\t\t}\n\t\t\tentry.durableSessionId = manager.getSessionId();\n\t\t\tentry.cwd = manager.getCwd();\n\t\t}\n\t}\n\n\tprivate validateProfile(profile: RpcSessionLaunchProfile): void {\n\t\tif (!isAbsolute(profile.cwd) || (profile.sessionPath !== undefined && !isAbsolute(profile.sessionPath))) {\n\t\t\tthrow new RpcSessionRegistryError(\"invalid_path\");\n\t\t}\n\t}\n}\n"]}
@@ -0,0 +1,22 @@
1
+ type SocketSink = {
2
+ writeRaw(chunk: string): void;
3
+ waitForBackpressure(): Promise<void>;
4
+ };
5
+ /** Independent FIFO actor for one socket. It never shares a drain promise with another sink. */
6
+ export declare class SocketEventSinkActor {
7
+ private readonly queue;
8
+ private queuedBytes;
9
+ private draining?;
10
+ private closed;
11
+ private failure?;
12
+ private readonly sink;
13
+ private readonly onFailure;
14
+ private readonly maxQueueBytes;
15
+ constructor(sink: SocketSink, onFailure: (cause: unknown) => void, maxQueueBytes?: number);
16
+ enqueue(line: string, key?: string, onWritten?: () => void): void;
17
+ flush(): Promise<void>;
18
+ close(): void;
19
+ private drain;
20
+ }
21
+ export {};
22
+ //# sourceMappingURL=socket-event-fanout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"socket-event-fanout.d.ts","sourceRoot":"","sources":["../../../src/modes/rpc/socket-event-fanout.ts"],"names":[],"mappings":"AAAA,KAAK,UAAU,GAAG;IACjB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACrC,CAAC;AAMF,gGAAgG;AAChG,qBAAa,oBAAoB;IAChC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAoB;IAC1C,OAAO,CAAC,WAAW,CAAK;IACxB,OAAO,CAAC,QAAQ,CAAC,CAAgB;IACjC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAAC,CAAU;IAE1B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAa;IAClC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA2B;IACrD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;gBAE3B,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,EAAE,aAAa,SAAsB;IAMtG,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,IAAI,GAAG,IAAI;IA6B3D,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAK5B,KAAK,IAAI,IAAI;IAMb,OAAO,CAAC,KAAK;CA0Bb"}
@@ -0,0 +1,84 @@
1
+ const DEFAULT_QUEUE_BYTES = 4 * 1024 * 1024;
2
+ /** Independent FIFO actor for one socket. It never shares a drain promise with another sink. */
3
+ export class SocketEventSinkActor {
4
+ constructor(sink, onFailure, maxQueueBytes = DEFAULT_QUEUE_BYTES) {
5
+ this.queue = [];
6
+ this.queuedBytes = 0;
7
+ this.closed = false;
8
+ this.sink = sink;
9
+ this.onFailure = onFailure;
10
+ this.maxQueueBytes = maxQueueBytes;
11
+ }
12
+ enqueue(line, key, onWritten) {
13
+ if (this.closed)
14
+ return;
15
+ const bytes = Buffer.byteLength(line);
16
+ if (key !== undefined) {
17
+ const existing = this.queue.find((entry) => entry.key === key);
18
+ if (existing) {
19
+ this.queuedBytes += bytes - existing.bytes;
20
+ existing.line = line;
21
+ existing.bytes = bytes;
22
+ if (this.queuedBytes <= this.maxQueueBytes)
23
+ return;
24
+ }
25
+ }
26
+ if (this.queuedBytes + bytes > this.maxQueueBytes) {
27
+ this.closed = true;
28
+ this.queue.length = 0;
29
+ this.queuedBytes = 0;
30
+ try {
31
+ this.sink.writeRaw(`${JSON.stringify({ type: "overflow", error: "overflow, resync required" })}\n`);
32
+ }
33
+ catch (cause) {
34
+ this.onFailure(cause);
35
+ }
36
+ this.onFailure(new Error("socket event queue overflow"));
37
+ return;
38
+ }
39
+ this.queue.push({ line, bytes, key, onWritten });
40
+ this.queuedBytes += bytes;
41
+ void this.drain();
42
+ }
43
+ async flush() {
44
+ while (this.draining)
45
+ await this.draining;
46
+ if (this.failure !== undefined)
47
+ throw this.failure;
48
+ }
49
+ close() {
50
+ this.closed = true;
51
+ this.queue.length = 0;
52
+ this.queuedBytes = 0;
53
+ }
54
+ drain() {
55
+ if (this.draining)
56
+ return this.draining;
57
+ this.draining = (async () => {
58
+ try {
59
+ while (!this.closed && this.queue.length > 0) {
60
+ const entry = this.queue.shift();
61
+ this.queuedBytes -= entry.bytes;
62
+ this.sink.writeRaw(entry.line);
63
+ await this.sink.waitForBackpressure();
64
+ entry.onWritten?.();
65
+ }
66
+ }
67
+ catch (cause) {
68
+ this.failure = cause;
69
+ this.closed = true;
70
+ this.queue.length = 0;
71
+ this.queuedBytes = 0;
72
+ this.onFailure(cause);
73
+ }
74
+ })().finally(() => {
75
+ this.draining = undefined;
76
+ // An enqueue that lands between the loop's exit and this reaction sees the
77
+ // stale settled promise and starts nothing; reschedule for it here.
78
+ if (!this.closed && this.queue.length > 0)
79
+ void this.drain();
80
+ });
81
+ return this.draining;
82
+ }
83
+ }
84
+ //# sourceMappingURL=socket-event-fanout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"socket-event-fanout.js","sourceRoot":"","sources":["../../../src/modes/rpc/socket-event-fanout.ts"],"names":[],"mappings":"AAOA,MAAM,mBAAmB,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AAE5C,gGAAgG;AAChG,MAAM,OAAO,oBAAoB;IAWhC,YAAY,IAAgB,EAAE,SAAmC,EAAE,aAAa,GAAG,mBAAmB;QAVrF,UAAK,GAAiB,EAAE,CAAC;QAClC,gBAAW,GAAG,CAAC,CAAC;QAEhB,WAAM,GAAG,KAAK,CAAC;QAQtB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACpC,CAAC;IAED,OAAO,CAAC,IAAY,EAAE,GAAY,EAAE,SAAsB;QACzD,IAAI,IAAI,CAAC,MAAM;YAAE,OAAO;QACxB,MAAM,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACtC,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACvB,MAAM,QAAQ,GAAG,IAAI,CAAC,K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AC1B,2EAA2E;YAC3E,oEAAoE;YACpE,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC;gBAAE,KAAK,IAAI,CAAC,KAAK,EAAE,CAAC;QAC9D,CAAC,CAAC,CAAC;QACH,OAAO,IAAI,CAAC,QAAQ,CAAC;IACtB,CAAC;CACD","sourcesContent":["type SocketSink = {\n\twriteRaw(chunk: string): void;\n\twaitForBackpressure(): Promise<void>;\n};\n\ntype QueueEntry = { line: string; bytes: number; key?: string; onWritten?: () => void };\n\nconst DEFAULT_QUEUE_BYTES = 4 * 1024 * 1024;\n\n/** Independent FIFO actor for one socket. It never shares a drain promise with another sink. */\nexport class SocketEventSinkActor {\n\tprivate readonly queue: QueueEntry[] = [];\n\tprivate queuedBytes = 0;\n\tprivate draining?: Promise<void>;\n\tprivate closed = false;\n\tprivate failure?: unknown;\n\n\tprivate readonly sink: SocketSink;\n\tprivate readonly onFailure: (cause: unknown) => void;\n\tprivate readonly maxQueueBytes: number;\n\n\tconstructor(sink: SocketSink, onFailure: (cause: unknown) => void, maxQueueBytes = DEFAULT_QUEUE_BYTES) {\n\t\tthis.sink = sink;\n\t\tthis.onFailure = onFailure;\n\t\tthis.maxQueueBytes = maxQueueBytes;\n\t}\n\n\tenqueue(line: string, key?: string, onWritten?: () => void): void {\n\t\tif (this.closed) return;\n\t\tconst bytes = Buffer.byteLength(line);\n\t\tif (key !== undefined) {\n\t\t\tconst existing = this.queue.find((entry) => entry.key === key);\n\t\t\tif (existing) {\n\t\t\t\tthis.queuedBytes += bytes - existing.bytes;\n\t\t\t\texisting.line = line;\n\t\t\t\texisting.bytes = bytes;\n\t\t\t\tif (this.queuedBytes <= this.maxQueueBytes) return;\n\t\t\t}\n\t\t}\n\t\tif (this.queuedBytes + bytes > this.maxQueueBytes) {\n\t\t\tthis.closed = true;\n\t\t\tthis.queue.length = 0;\n\t\t\tthis.queuedBytes = 0;\n\t\t\ttry {\n\t\t\t\tthis.sink.writeRaw(`${JSON.stringify({ type: \"overflow\", error: \"overflow, resync required\" })}\\n`);\n\t\t\t} catch (cause) {\n\t\t\t\tthis.onFailure(cause);\n\t\t\t}\n\t\t\tthis.onFailure(new Error(\"socket event queue overflow\"));\n\t\t\treturn;\n\t\t}\n\t\tthis.queue.push({ line, bytes, key, onWritten });\n\t\tthis.queuedBytes += bytes;\n\t\tvoid this.drain();\n\t}\n\n\tasync flush(): Promise<void> {\n\t\twhile (this.draining) await this.draining;\n\t\tif (this.failure !== undefined) throw this.failure;\n\t}\n\n\tclose(): void {\n\t\tthis.closed = true;\n\t\tthis.queue.length = 0;\n\t\tthis.queuedBytes = 0;\n\t}\n\n\tprivate drain(): Promise<void> {\n\t\tif (this.draining) return this.draining;\n\t\tthis.draining = (async () => {\n\t\t\ttry {\n\t\t\t\twhile (!this.closed && this.queue.length > 0) {\n\t\t\t\t\tconst entry = this.queue.shift()!;\n\t\t\t\t\tthis.queuedBytes -= entry.bytes;\n\t\t\t\t\tthis.sink.writeRaw(entry.line);\n\t\t\t\t\tawait this.sink.waitForBackpressure();\n\t\t\t\t\tentry.onWritten?.();\n\t\t\t\t}\n\t\t\t} catch (cause) {\n\t\t\t\tthis.failure = cause;\n\t\t\t\tthis.closed = true;\n\t\t\t\tthis.queue.length = 0;\n\t\t\t\tthis.queuedBytes = 0;\n\t\t\t\tthis.onFailure(cause);\n\t\t\t}\n\t\t})().finally(() => {\n\t\t\tthis.draining = undefined;\n\t\t\t// An enqueue that lands between the loop's exit and this reaction sees the\n\t\t\t// stale settled promise and starts nothing; reschedule for it here.\n\t\t\tif (!this.closed && this.queue.length > 0) void this.drain();\n\t\t});\n\t\treturn this.draining;\n\t}\n}\n"]}
package/docs/rpc.md CHANGED
@@ -76,9 +76,23 @@ Startup: `senpi --mode rpc --multi-session` → NO default session is constructe
76
76
 
77
77
  Interactive launches use the shared RPC host by default when a persisted session is available. A cold start takes approximately 1.3 seconds on the first launch; warm attachment to an existing compatible host is fast. To use the local runtime directly for a launch, set `SENPI_DISABLE_SHARED_HOST=1`. This uses the same local fallback runtime and does not change RPC socket behavior for other clients.
78
78
 
79
+ ### Session replacement
80
+
81
+ A replacement (`new_session`, `switch_session`, `fork`) responds as soon as the swap is committed; the derived-surface refresh that rebinds extensions continues afterwards. That refresh does not disturb work the client starts against the committed session: tool activation performed while extensions are still binding no longer cancels an in-flight compaction or invalidates its context. `loaded_surfaces_changed` is emitted only when the surface digest actually changes, so it is NOT a settle barrier clients can wait on.
82
+
83
+ #### Replacement identity event
84
+
85
+ When `new_session`, `switch_session`, or `fork` swaps the live session - including replacements an extension drives, which a client never issued - every attached connection receives:
86
+
87
+ ```json
88
+ { "type": "session_replaced", "durableSessionId": "…", "sessionFile": "…", "cwd": "…", "sessionName": "…" }
89
+ ```
90
+
91
+ The command response reports only `{ cancelled }`, so this event is the only push channel carrying the new identity. The identity is `durableSessionId`, never `sessionId`: top-level `sessionId` is reserved for the per-connection routing handle that multi-session hosts tag every record with, and that tag is applied last, so reusing the key would overwrite the identity the event exists to deliver. Classic mode emits the event untagged.
92
+
79
93
  ### Shared host lifecycle (cold start + idle exit)
80
94
 
81
- The lifecycle supervisor is also available to bundled/rebranded runtimes through the hidden internal launch route `--internal-rpc-host-supervisor`. This route is wire-invisible and intended only for desktop launchers: it receives the public socket, ownership directory, and the runtime command/arguments to wrap, then runs the same `host-lifecycle.ts` implementation used by `ensureHost()`. Normal CLI modes do not use or advertise this route.
95
+ The lifecycle supervisor is also available to bundled/rebranded runtimes through the hidden internal launch route `--internal-rpc-host-supervisor`. This route is wire-invisible and intended only for desktop launchers: it receives the public socket, ownership directory, and the runtime command/arguments to wrap, then runs the same `host-lifecycle.ts` implementation used by `ensureHost()`. Normal CLI modes do not use or advertise this route. Compiled standalone binaries also re-enter themselves through this route automatically: a bun executable always boots its embedded entrypoint, so the script-path re-entry used under a JS runtime would be parsed as CLI arguments (`Unknown option: --socket`) and the host could never start.
82
96
 
83
97
  Hosts started through `ensureHost()` are wrapped by a lifecycle supervisor that owns the public socket and spawns the
84
98
  real RPC host on a private internal hop. The policy lives in `<agentDir>/rpc-host-daemon/settings.json`:
@@ -844,9 +858,11 @@ Response:
844
858
  Load a different session file. Can be cancelled by a `session_before_switch` extension event handler.
845
859
 
846
860
  ```json
847
- {"type": "switch_session", "sessionPath": "/path/to/session.jsonl"}
861
+ {"type": "switch_session", "sessionPath": "/path/to/session.jsonl", "cwdOverride": "/path/to/project"}
848
862
  ```
849
863
 
864
+ `cwdOverride` is optional. When supplied, the replacement session and its cwd-bound settings and runtime state are rebuilt for that directory instead of using the session file's stored cwd. The host also resolves `projectTrusted` from its saved project trust store for the replacement cwd; an absent or false decision keeps project-scoped settings and resources disabled.
865
+
850
866
  Response:
851
867
  ```json
852
868
  {"type": "response", "command": "switch_session", "success": true, "data": {"cancelled": false}}
package/docs/settings.md CHANGED
@@ -399,6 +399,8 @@ Windows paths in JSON must use forward slashes or escaped backslashes:
399
399
  | Setting | Type | Default | Description |
400
400
  |---------|------|---------|-------------|
401
401
  | `defaultTools` | string[] | - | Built-in tools enabled initially. When omitted, Pi uses its standard defaults |
402
+ | `experimental.bashEvalOnly` | boolean | `false` | Route `bash` and `powershell` through eval cells only; the tools leave the model's direct tool list |
403
+ | `experimental.workflowEvalOnly` | boolean | `false` | Route the workflow (dag) tool through eval cells only; the tool leaves the model direct tool list |
402
404
 
403
405
  `defaultTools` selects the built-in tools enabled at startup. Extension and SDK custom tools remain enabled. Available built-ins are `read`, `bash`, `powershell`, `edit`, `write`, `grep`, `find`, and `ls`:
404
406
 
@@ -418,6 +420,38 @@ On Windows, select `powershell` instead of `bash`, or include both:
418
420
 
419
421
  An empty array starts with no built-in tools while preserving extension and SDK custom tools. `--tools` replaces this behavior with a strict allowlist for all tools, `--no-tools` disables all tools, and `--no-builtin-tools` disables the built-in defaults. `--exclude-tools` filters the resulting list. A project `defaultTools` array replaces the global array.
420
422
 
423
+ With `experimental.bashEvalOnly` enabled, the `bash` and `powershell` tools disappear from the model's direct tool list and run only inside eval cells:
424
+
425
+ ```json
426
+ {
427
+ "experimental": {
428
+ "bashEvalOnly": true
429
+ }
430
+ }
431
+ ```
432
+
433
+ ```js
434
+ const { output } = await tool.bash({ command: "ls -la" });
435
+ ```
436
+
437
+ Hooks and permission checks apply unchanged to shell commands run this way. If the model hallucinates a direct `bash` or `powershell` call anyway, the call returns a hint redirecting it to an eval cell. When the `eval` tool is unavailable (codemode not loaded), the policy auto-disables and both tools stay on the direct tool list, so shell access is never lost.
438
+
439
+ With `experimental.workflowEvalOnly` enabled, the `workflow` (dag) tool disappears from the model's direct tool list and runs only inside eval cells:
440
+
441
+ ```json
442
+ {
443
+ "experimental": {
444
+ "workflowEvalOnly": true
445
+ }
446
+ }
447
+ ```
448
+
449
+ ```js
450
+ const snapshot = await tool.workflow({ action: "snapshot", run_id });
451
+ ```
452
+
453
+ Hooks and permission checks apply unchanged to workflow operations run this way. When the `eval` tool is unavailable (codemode not loaded), the policy auto-disables and the workflow tool stays on the direct tool list, so workflow access is never lost.
454
+
421
455
  ### Sessions
422
456
 
423
457
  | Setting | Type | Default | Description |
package/docs/windows.md CHANGED
@@ -30,6 +30,8 @@ Or enable both while comparing behavior:
30
30
 
31
31
  The `!` and `!!` editor commands still use Bash.
32
32
 
33
+ With `experimental.bashEvalOnly` enabled, both `bash` and `powershell` run only inside eval cells; see [Settings](settings.md#tools).
34
+
33
35
  ## Custom Bash Path
34
36
 
35
37
  ```json
@@ -12,6 +12,56 @@
12
12
 
13
13
  ### Removed
14
14
 
15
+ ## [2026.8.30-2] - 2026-08-30
16
+
17
+ ### Breaking Changes
18
+
19
+ ### Added
20
+
21
+ ### Changed
22
+
23
+ ### Fixed
24
+
25
+ ### Removed
26
+
27
+ ## [2026.8.30] - 2026-08-30
28
+
29
+ ### Breaking Changes
30
+
31
+ ### Added
32
+
33
+ ### Changed
34
+
35
+ - The eval prompt's dependency-graph section is now `<workflow>` and states its contract directly:
36
+ define the workflow spec in code, one node per logically distinct step, rather than hand-authoring
37
+ the graph as a single opaque call.
38
+
39
+ ### Fixed
40
+
41
+ - The JavaScript kernel persistence transform no longer truncates declarations whose multi-line
42
+ initializers contain interior `//` comments (previously emitted unparseable code such as
43
+ `globalThis["jobs"] = {;`, failing cells with `Unexpected token ';'. Expected a property name.`),
44
+ and no longer re-evaluates comment-bearing initializers when persisting bindings — such
45
+ declarations are kept verbatim and their bindings persisted by reference.
46
+ - Last-expression capture no longer inserts `return` before continuation lines (`else`/`catch`/`finally`
47
+ clauses and leading-`.`/operator method-chain lines), and now scans template literals (including
48
+ nested templates in interpolations), regexes, and comments with the same literal-aware scanner as
49
+ the persistence transform — fixing `return else …`, `return .replace(…)`, and mid-argument
50
+ `return )` corruption of valid cells.
51
+ - Last-expression capture now follows real ASI statement semantics: a parenthesized/bracketed/template
52
+ line after a closed block starts a new statement (echo restored), expressions split after a trailing
53
+ operator or `await` stay one statement, tagged templates split across lines invoke the tag, regexes
54
+ directly after a control-structure condition no longer desync the scanner, and labeled final
55
+ statements are left uncaptured instead of emitting invalid `return label: …`.
56
+ - Destructuring patterns carrying interior line comments now persist their bindings, and declarations
57
+ with a dangling trailing comma are left untransformed so the original syntax error surfaces instead
58
+ of being silently "repaired".
59
+ - Rewritten destructuring assignments are emitted with a leading defensive semicolon so they can no
60
+ longer ASI-merge into a preceding unterminated expression statement as a bogus call
61
+ (`foo()\n({…} = …)` previously became `foo()({…} = …)`).
62
+
63
+ ### Removed
64
+
15
65
  ## [2026.8.29] - 2026-08-29
16
66
 
17
67
  ### Breaking Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code-yeongyu/senpi-codemode",
3
- "version": "2026.8.29",
3
+ "version": "2026.8.30-2",
4
4
  "private": true,
5
5
  "description": "Source-only senpi extension package for codemode evaluation tools",
6
6
  "type": "module",
@@ -31,14 +31,14 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@babel/parser": "8.0.4",
34
- "@earendil-works/pi-ai": "npm:@code-yeongyu/senpi-ai@2026.8.29",
34
+ "@earendil-works/pi-ai": "npm:@code-yeongyu/senpi-ai@2026.8.30-2",
35
35
  "typebox": "1.3.18"
36
36
  },
37
37
  "peerDependencies": {
38
- "@code-yeongyu/senpi": "2026.8.29"
38
+ "@code-yeongyu/senpi": "2026.8.30-2"
39
39
  },
40
40
  "devDependencies": {
41
- "@code-yeongyu/senpi": "2026.8.29"
41
+ "@code-yeongyu/senpi": "2026.8.30-2"
42
42
  },
43
43
  "keywords": [
44
44
  "senpi",