@code-yeongyu/senpi 2026.9.7 → 2026.9.9-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 (470) hide show
  1. package/CHANGELOG.md +122 -3
  2. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  3. package/dist/core/agent-session-runtime.js +2 -0
  4. package/dist/core/agent-session-runtime.js.map +1 -1
  5. package/dist/core/agent-session.d.ts +48 -4
  6. package/dist/core/agent-session.d.ts.map +1 -1
  7. package/dist/core/agent-session.js +192 -40
  8. package/dist/core/agent-session.js.map +1 -1
  9. package/dist/core/compaction/compaction-execution.d.ts.map +1 -1
  10. package/dist/core/compaction/compaction-execution.js +5 -5
  11. package/dist/core/compaction/compaction-execution.js.map +1 -1
  12. package/dist/core/compaction/compaction-settings.d.ts +2 -0
  13. package/dist/core/compaction/compaction-settings.d.ts.map +1 -1
  14. package/dist/core/compaction/compaction-settings.js.map +1 -1
  15. package/dist/core/compaction/compaction.d.ts +3 -3
  16. package/dist/core/compaction/compaction.d.ts.map +1 -1
  17. package/dist/core/compaction/compaction.js +14 -8
  18. package/dist/core/compaction/compaction.js.map +1 -1
  19. package/dist/core/compaction/stream-watchdog.d.ts +29 -0
  20. package/dist/core/compaction/stream-watchdog.d.ts.map +1 -1
  21. package/dist/core/compaction/stream-watchdog.js +35 -0
  22. package/dist/core/compaction/stream-watchdog.js.map +1 -1
  23. package/dist/core/compaction-settings-access.d.ts +6 -0
  24. package/dist/core/compaction-settings-access.d.ts.map +1 -1
  25. package/dist/core/compaction-settings-access.js.map +1 -1
  26. package/dist/core/compaction-settings-resolver.d.ts +2 -0
  27. package/dist/core/compaction-settings-resolver.d.ts.map +1 -1
  28. package/dist/core/compaction-settings-resolver.js +5 -0
  29. package/dist/core/compaction-settings-resolver.js.map +1 -1
  30. package/dist/core/dynamic-prompt/working-task.js +1 -1
  31. package/dist/core/dynamic-prompt/working-task.js.map +1 -1
  32. package/dist/core/extensions/builtin/cache-keepalive/index.d.ts.map +1 -1
  33. package/dist/core/extensions/builtin/cache-keepalive/index.js +4 -21
  34. package/dist/core/extensions/builtin/cache-keepalive/index.js.map +1 -1
  35. package/dist/core/extensions/builtin/claude-sdk-oauth/account-command.d.ts +2 -0
  36. package/dist/core/extensions/builtin/claude-sdk-oauth/account-command.d.ts.map +1 -1
  37. package/dist/core/extensions/builtin/claude-sdk-oauth/account-command.js +10 -25
  38. package/dist/core/extensions/builtin/claude-sdk-oauth/account-command.js.map +1 -1
  39. package/dist/core/extensions/builtin/claude-sdk-oauth/session-binding.d.ts.map +1 -1
  40. package/dist/core/extensions/builtin/claude-sdk-oauth/session-binding.js +36 -19
  41. package/dist/core/extensions/builtin/claude-sdk-oauth/session-binding.js.map +1 -1
  42. package/dist/core/extensions/builtin/claude-sdk-oauth/session-commit-boundary.d.ts.map +1 -1
  43. package/dist/core/extensions/builtin/claude-sdk-oauth/session-commit-boundary.js +21 -10
  44. package/dist/core/extensions/builtin/claude-sdk-oauth/session-commit-boundary.js.map +1 -1
  45. package/dist/core/extensions/builtin/claude-sdk-oauth/session-continuity.d.ts +4 -17
  46. package/dist/core/extensions/builtin/claude-sdk-oauth/session-continuity.d.ts.map +1 -1
  47. package/dist/core/extensions/builtin/claude-sdk-oauth/session-continuity.js +23 -33
  48. package/dist/core/extensions/builtin/claude-sdk-oauth/session-continuity.js.map +1 -1
  49. package/dist/core/extensions/builtin/claude-sdk-oauth/session-stream.d.ts.map +1 -1
  50. package/dist/core/extensions/builtin/claude-sdk-oauth/session-stream.js +5 -1
  51. package/dist/core/extensions/builtin/claude-sdk-oauth/session-stream.js.map +1 -1
  52. package/dist/core/extensions/builtin/claude-sdk-oauth/session-sync.d.ts.map +1 -1
  53. package/dist/core/extensions/builtin/claude-sdk-oauth/session-sync.js +5 -3
  54. package/dist/core/extensions/builtin/claude-sdk-oauth/session-sync.js.map +1 -1
  55. package/dist/core/extensions/builtin/claude-sdk-oauth/session-turn-attempt.d.ts.map +1 -1
  56. package/dist/core/extensions/builtin/claude-sdk-oauth/session-turn-attempt.js +8 -3
  57. package/dist/core/extensions/builtin/claude-sdk-oauth/session-turn-attempt.js.map +1 -1
  58. package/dist/core/extensions/builtin/claude-sdk-oauth/tools.d.ts +6 -5
  59. package/dist/core/extensions/builtin/claude-sdk-oauth/tools.d.ts.map +1 -1
  60. package/dist/core/extensions/builtin/claude-sdk-oauth/tools.js +6 -5
  61. package/dist/core/extensions/builtin/claude-sdk-oauth/tools.js.map +1 -1
  62. package/dist/core/extensions/builtin/compaction/circuit-breaker.d.ts +8 -0
  63. package/dist/core/extensions/builtin/compaction/circuit-breaker.d.ts.map +1 -1
  64. package/dist/core/extensions/builtin/compaction/circuit-breaker.js +8 -0
  65. package/dist/core/extensions/builtin/compaction/circuit-breaker.js.map +1 -1
  66. package/dist/core/extensions/builtin/compaction/deterministic-fallback.d.ts +8 -0
  67. package/dist/core/extensions/builtin/compaction/deterministic-fallback.d.ts.map +1 -1
  68. package/dist/core/extensions/builtin/compaction/deterministic-fallback.js +125 -20
  69. package/dist/core/extensions/builtin/compaction/deterministic-fallback.js.map +1 -1
  70. package/dist/core/extensions/builtin/compaction/fallback-failed-turn-normalization.d.ts +18 -0
  71. package/dist/core/extensions/builtin/compaction/fallback-failed-turn-normalization.d.ts.map +1 -0
  72. package/dist/core/extensions/builtin/compaction/fallback-failed-turn-normalization.js +20 -0
  73. package/dist/core/extensions/builtin/compaction/fallback-failed-turn-normalization.js.map +1 -0
  74. package/dist/core/extensions/builtin/compaction/index.d.ts.map +1 -1
  75. package/dist/core/extensions/builtin/compaction/index.js +54 -11
  76. package/dist/core/extensions/builtin/compaction/index.js.map +1 -1
  77. package/dist/core/extensions/builtin/compaction/lane-policy.d.ts +3 -0
  78. package/dist/core/extensions/builtin/compaction/lane-policy.d.ts.map +1 -1
  79. package/dist/core/extensions/builtin/compaction/lane-policy.js +47 -23
  80. package/dist/core/extensions/builtin/compaction/lane-policy.js.map +1 -1
  81. package/dist/core/extensions/builtin/compaction/model-usability-budget.d.ts +1 -1
  82. package/dist/core/extensions/builtin/compaction/model-usability-budget.d.ts.map +1 -1
  83. package/dist/core/extensions/builtin/compaction/model-usability-budget.js +23 -3
  84. package/dist/core/extensions/builtin/compaction/model-usability-budget.js.map +1 -1
  85. package/dist/core/extensions/builtin/compaction/resume-admission.d.ts +7 -0
  86. package/dist/core/extensions/builtin/compaction/resume-admission.d.ts.map +1 -0
  87. package/dist/core/extensions/builtin/compaction/resume-admission.js +7 -0
  88. package/dist/core/extensions/builtin/compaction/resume-admission.js.map +1 -0
  89. package/dist/core/extensions/builtin/compaction/speculative-summary.d.ts +2 -0
  90. package/dist/core/extensions/builtin/compaction/speculative-summary.d.ts.map +1 -1
  91. package/dist/core/extensions/builtin/compaction/speculative-summary.js +5 -2
  92. package/dist/core/extensions/builtin/compaction/speculative-summary.js.map +1 -1
  93. package/dist/core/extensions/builtin/compaction/speculative.d.ts.map +1 -1
  94. package/dist/core/extensions/builtin/compaction/speculative.js +9 -3
  95. package/dist/core/extensions/builtin/compaction/speculative.js.map +1 -1
  96. package/dist/core/extensions/builtin/compaction/summarization-retry.d.ts +10 -4
  97. package/dist/core/extensions/builtin/compaction/summarization-retry.d.ts.map +1 -1
  98. package/dist/core/extensions/builtin/compaction/summarization-retry.js +14 -5
  99. package/dist/core/extensions/builtin/compaction/summarization-retry.js.map +1 -1
  100. package/dist/core/extensions/builtin/goal/agent-end-continuation.d.ts.map +1 -1
  101. package/dist/core/extensions/builtin/goal/agent-end-continuation.js +11 -0
  102. package/dist/core/extensions/builtin/goal/agent-end-continuation.js.map +1 -1
  103. package/dist/core/extensions/builtin/goal/cache-warm-renderer.js +6 -4
  104. package/dist/core/extensions/builtin/goal/cache-warm-renderer.js.map +1 -1
  105. package/dist/core/extensions/builtin/goal/cache-warm.d.ts +25 -1
  106. package/dist/core/extensions/builtin/goal/cache-warm.d.ts.map +1 -1
  107. package/dist/core/extensions/builtin/goal/cache-warm.js +29 -10
  108. package/dist/core/extensions/builtin/goal/cache-warm.js.map +1 -1
  109. package/dist/core/extensions/builtin/goal/continuation.d.ts +3 -1
  110. package/dist/core/extensions/builtin/goal/continuation.d.ts.map +1 -1
  111. package/dist/core/extensions/builtin/goal/continuation.js +17 -2
  112. package/dist/core/extensions/builtin/goal/continuation.js.map +1 -1
  113. package/dist/core/extensions/builtin/goal/lifecycle-helpers.d.ts.map +1 -1
  114. package/dist/core/extensions/builtin/goal/lifecycle-helpers.js +1 -0
  115. package/dist/core/extensions/builtin/goal/lifecycle-helpers.js.map +1 -1
  116. package/dist/core/extensions/builtin/goal/monitor-continuation.d.ts +1 -1
  117. package/dist/core/extensions/builtin/goal/monitor-continuation.d.ts.map +1 -1
  118. package/dist/core/extensions/builtin/goal/monitor-continuation.js +8 -3
  119. package/dist/core/extensions/builtin/goal/monitor-continuation.js.map +1 -1
  120. package/dist/core/extensions/builtin/gpt-account.d.ts +5 -1
  121. package/dist/core/extensions/builtin/gpt-account.d.ts.map +1 -1
  122. package/dist/core/extensions/builtin/gpt-account.js +9 -26
  123. package/dist/core/extensions/builtin/gpt-account.js.map +1 -1
  124. package/dist/core/extensions/builtin/hooks/plugin-manifest.js +2 -2
  125. package/dist/core/extensions/builtin/hooks/plugin-manifest.js.map +1 -1
  126. package/dist/core/extensions/builtin/hooks/safety.js +2 -2
  127. package/dist/core/extensions/builtin/hooks/safety.js.map +1 -1
  128. package/dist/core/extensions/builtin/imagegen/params.d.ts +36 -0
  129. package/dist/core/extensions/builtin/imagegen/params.d.ts.map +1 -0
  130. package/dist/core/extensions/builtin/imagegen/params.js +55 -0
  131. package/dist/core/extensions/builtin/imagegen/params.js.map +1 -0
  132. package/dist/core/extensions/builtin/imagegen/reference-images.d.ts +11 -0
  133. package/dist/core/extensions/builtin/imagegen/reference-images.d.ts.map +1 -0
  134. package/dist/core/extensions/builtin/imagegen/reference-images.js +55 -0
  135. package/dist/core/extensions/builtin/imagegen/reference-images.js.map +1 -0
  136. package/dist/core/extensions/builtin/imagegen/skill/SKILL.md +47 -4
  137. package/dist/core/extensions/builtin/imagegen/tool.d.ts +10 -19
  138. package/dist/core/extensions/builtin/imagegen/tool.d.ts.map +1 -1
  139. package/dist/core/extensions/builtin/imagegen/tool.js +21 -45
  140. package/dist/core/extensions/builtin/imagegen/tool.js.map +1 -1
  141. package/dist/core/extensions/builtin/monitor-state-event.d.ts +18 -0
  142. package/dist/core/extensions/builtin/monitor-state-event.d.ts.map +1 -1
  143. package/dist/core/extensions/builtin/monitor-state-event.js +23 -0
  144. package/dist/core/extensions/builtin/monitor-state-event.js.map +1 -1
  145. package/dist/core/extensions/builtin/oauth-login-interaction.d.ts +24 -0
  146. package/dist/core/extensions/builtin/oauth-login-interaction.d.ts.map +1 -0
  147. package/dist/core/extensions/builtin/oauth-login-interaction.js +77 -0
  148. package/dist/core/extensions/builtin/oauth-login-interaction.js.map +1 -0
  149. package/dist/core/extensions/builtin/permission-system/external-dir.d.ts.map +1 -1
  150. package/dist/core/extensions/builtin/permission-system/external-dir.js +5 -51
  151. package/dist/core/extensions/builtin/permission-system/external-dir.js.map +1 -1
  152. package/dist/core/extensions/builtin/permission-system/parsers.d.ts.map +1 -1
  153. package/dist/core/extensions/builtin/permission-system/parsers.js +5 -7
  154. package/dist/core/extensions/builtin/permission-system/parsers.js.map +1 -1
  155. package/dist/core/extensions/builtin/prompt-preset/claude-fable-5-1.js +1 -1
  156. package/dist/core/extensions/builtin/prompt-preset/claude-fable-5-1.js.map +1 -1
  157. package/dist/core/extensions/builtin/prompt-preset/claude-fable-5.js +1 -1
  158. package/dist/core/extensions/builtin/prompt-preset/claude-fable-5.js.map +1 -1
  159. package/dist/core/extensions/builtin/prompt-preset/execution-tooling.d.ts +14 -7
  160. package/dist/core/extensions/builtin/prompt-preset/execution-tooling.d.ts.map +1 -1
  161. package/dist/core/extensions/builtin/prompt-preset/execution-tooling.js +34 -13
  162. package/dist/core/extensions/builtin/prompt-preset/execution-tooling.js.map +1 -1
  163. package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.d.ts +6 -10
  164. package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.d.ts.map +1 -1
  165. package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js +14 -9
  166. package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js.map +1 -1
  167. package/dist/core/extensions/builtin/prompt-preset/gpt-6-astra.d.ts +15 -15
  168. package/dist/core/extensions/builtin/prompt-preset/gpt-6-astra.d.ts.map +1 -1
  169. package/dist/core/extensions/builtin/prompt-preset/gpt-6-astra.js +49 -21
  170. package/dist/core/extensions/builtin/prompt-preset/gpt-6-astra.js.map +1 -1
  171. package/dist/core/extensions/builtin/prompt-preset/kimi-k3.js +1 -1
  172. package/dist/core/extensions/builtin/prompt-preset/kimi-k3.js.map +1 -1
  173. package/dist/core/extensions/builtin/service-tier.d.ts +2 -0
  174. package/dist/core/extensions/builtin/service-tier.d.ts.map +1 -1
  175. package/dist/core/extensions/builtin/service-tier.js +17 -1
  176. package/dist/core/extensions/builtin/service-tier.js.map +1 -1
  177. package/dist/core/extensions/builtin/terminal/durable-command.d.ts.map +1 -1
  178. package/dist/core/extensions/builtin/terminal/durable-command.js +3 -0
  179. package/dist/core/extensions/builtin/terminal/durable-command.js.map +1 -1
  180. package/dist/core/extensions/builtin/terminal/durable-file.d.ts.map +1 -1
  181. package/dist/core/extensions/builtin/terminal/durable-file.js +2 -0
  182. package/dist/core/extensions/builtin/terminal/durable-file.js.map +1 -1
  183. package/dist/core/extensions/builtin/terminal/extension.d.ts.map +1 -1
  184. package/dist/core/extensions/builtin/terminal/extension.js +14 -2
  185. package/dist/core/extensions/builtin/terminal/extension.js.map +1 -1
  186. package/dist/core/extensions/builtin/terminal/monitor-notify.d.ts.map +1 -1
  187. package/dist/core/extensions/builtin/terminal/monitor-notify.js +27 -5
  188. package/dist/core/extensions/builtin/terminal/monitor-notify.js.map +1 -1
  189. package/dist/core/extensions/builtin/terminal/monitor-registry.d.ts +17 -0
  190. package/dist/core/extensions/builtin/terminal/monitor-registry.d.ts.map +1 -1
  191. package/dist/core/extensions/builtin/terminal/monitor-registry.js +76 -14
  192. package/dist/core/extensions/builtin/terminal/monitor-registry.js.map +1 -1
  193. package/dist/core/extensions/builtin/terminal/notify.d.ts +2 -0
  194. package/dist/core/extensions/builtin/terminal/notify.d.ts.map +1 -1
  195. package/dist/core/extensions/builtin/terminal/notify.js +6 -1
  196. package/dist/core/extensions/builtin/terminal/notify.js.map +1 -1
  197. package/dist/core/extensions/builtin/terminal/session-bundle.d.ts +3 -1
  198. package/dist/core/extensions/builtin/terminal/session-bundle.d.ts.map +1 -1
  199. package/dist/core/extensions/builtin/terminal/session-bundle.js +13 -0
  200. package/dist/core/extensions/builtin/terminal/session-bundle.js.map +1 -1
  201. package/dist/core/extensions/builtin/terminal/shared.d.ts +13 -2
  202. package/dist/core/extensions/builtin/terminal/shared.d.ts.map +1 -1
  203. package/dist/core/extensions/builtin/terminal/shared.js +15 -2
  204. package/dist/core/extensions/builtin/terminal/shared.js.map +1 -1
  205. package/dist/core/extensions/builtin/terminal/tools/monitor.d.ts.map +1 -1
  206. package/dist/core/extensions/builtin/terminal/tools/monitor.js +8 -1
  207. package/dist/core/extensions/builtin/terminal/tools/monitor.js.map +1 -1
  208. package/dist/core/extensions/builtin/tool-search/index.d.ts.map +1 -1
  209. package/dist/core/extensions/builtin/tool-search/index.js +1 -0
  210. package/dist/core/extensions/builtin/tool-search/index.js.map +1 -1
  211. package/dist/core/extensions/builtin/tool-search/service.d.ts +4 -0
  212. package/dist/core/extensions/builtin/tool-search/service.d.ts.map +1 -1
  213. package/dist/core/extensions/builtin/tool-search/service.js +11 -0
  214. package/dist/core/extensions/builtin/tool-search/service.js.map +1 -1
  215. package/dist/core/extensions/loader.d.ts +2 -1
  216. package/dist/core/extensions/loader.d.ts.map +1 -1
  217. package/dist/core/extensions/loader.js +17 -8
  218. package/dist/core/extensions/loader.js.map +1 -1
  219. package/dist/core/extensions/runner.d.ts +1 -0
  220. package/dist/core/extensions/runner.d.ts.map +1 -1
  221. package/dist/core/extensions/runner.js +8 -1
  222. package/dist/core/extensions/runner.js.map +1 -1
  223. package/dist/core/extensions/types.d.ts +14 -0
  224. package/dist/core/extensions/types.d.ts.map +1 -1
  225. package/dist/core/extensions/types.js.map +1 -1
  226. package/dist/core/high-reasoning-warning.d.ts.map +1 -1
  227. package/dist/core/high-reasoning-warning.js +4 -6
  228. package/dist/core/high-reasoning-warning.js.map +1 -1
  229. package/dist/core/resource-loader.d.ts +2 -0
  230. package/dist/core/resource-loader.d.ts.map +1 -1
  231. package/dist/core/resource-loader.js +11 -7
  232. package/dist/core/resource-loader.js.map +1 -1
  233. package/dist/core/sdk.d.ts +1 -1
  234. package/dist/core/sdk.d.ts.map +1 -1
  235. package/dist/core/sdk.js +38 -7
  236. package/dist/core/sdk.js.map +1 -1
  237. package/dist/core/session-manager.d.ts.map +1 -1
  238. package/dist/core/session-manager.js +11 -1
  239. package/dist/core/session-manager.js.map +1 -1
  240. package/dist/core/session-write-reservation.d.ts +4 -0
  241. package/dist/core/session-write-reservation.d.ts.map +1 -0
  242. package/dist/core/session-write-reservation.js +12 -0
  243. package/dist/core/session-write-reservation.js.map +1 -0
  244. package/dist/core/settings-manager.js +1 -1
  245. package/dist/core/settings-manager.js.map +1 -1
  246. package/dist/core/settings-shapes.js.map +1 -1
  247. package/dist/core/tools/bounded-realpath.d.ts +28 -0
  248. package/dist/core/tools/bounded-realpath.d.ts.map +1 -0
  249. package/dist/core/tools/bounded-realpath.js +53 -0
  250. package/dist/core/tools/bounded-realpath.js.map +1 -0
  251. package/dist/core/tools/file-mutation-queue.d.ts.map +1 -1
  252. package/dist/core/tools/file-mutation-queue.js +15 -13
  253. package/dist/core/tools/file-mutation-queue.js.map +1 -1
  254. package/dist/core/tools/filesystem-policy.d.ts +7 -0
  255. package/dist/core/tools/filesystem-policy.d.ts.map +1 -1
  256. package/dist/core/tools/filesystem-policy.js +25 -15
  257. package/dist/core/tools/filesystem-policy.js.map +1 -1
  258. package/dist/core/tools/read-classifiers.d.ts +17 -0
  259. package/dist/core/tools/read-classifiers.d.ts.map +1 -0
  260. package/dist/core/tools/read-classifiers.js +26 -0
  261. package/dist/core/tools/read-classifiers.js.map +1 -0
  262. package/dist/core/tools/read.d.ts +5 -1
  263. package/dist/core/tools/read.d.ts.map +1 -1
  264. package/dist/core/tools/read.js +21 -1
  265. package/dist/core/tools/read.js.map +1 -1
  266. package/dist/core/trust-manager.d.ts.map +1 -1
  267. package/dist/core/trust-manager.js +13 -2
  268. package/dist/core/trust-manager.js.map +1 -1
  269. package/dist/index.d.ts +1 -0
  270. package/dist/index.d.ts.map +1 -1
  271. package/dist/index.js +1 -0
  272. package/dist/index.js.map +1 -1
  273. package/dist/main.d.ts +14 -0
  274. package/dist/main.d.ts.map +1 -1
  275. package/dist/main.js +166 -147
  276. package/dist/main.js.map +1 -1
  277. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  278. package/dist/modes/interactive/interactive-mode.js +4 -0
  279. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  280. package/dist/modes/interactive/tips/catalog/memory-tips.d.ts.map +1 -1
  281. package/dist/modes/interactive/tips/catalog/memory-tips.js +6 -0
  282. package/dist/modes/interactive/tips/catalog/memory-tips.js.map +1 -1
  283. package/dist/modes/interactive/tips/catalog/subagent-tips.d.ts.map +1 -1
  284. package/dist/modes/interactive/tips/catalog/subagent-tips.js +6 -0
  285. package/dist/modes/interactive/tips/catalog/subagent-tips.js.map +1 -1
  286. package/dist/modes/rpc/connection-handler.d.ts +2 -0
  287. package/dist/modes/rpc/connection-handler.d.ts.map +1 -1
  288. package/dist/modes/rpc/connection-handler.js +1 -1
  289. package/dist/modes/rpc/connection-handler.js.map +1 -1
  290. package/dist/modes/rpc/host-lifecycle.d.ts.map +1 -1
  291. package/dist/modes/rpc/host-lifecycle.js +31 -5
  292. package/dist/modes/rpc/host-lifecycle.js.map +1 -1
  293. package/dist/modes/rpc/host-watchdog.d.ts +11 -0
  294. package/dist/modes/rpc/host-watchdog.d.ts.map +1 -1
  295. package/dist/modes/rpc/host-watchdog.js +16 -2
  296. package/dist/modes/rpc/host-watchdog.js.map +1 -1
  297. package/dist/modes/rpc/multi-session-host.d.ts +2 -0
  298. package/dist/modes/rpc/multi-session-host.d.ts.map +1 -1
  299. package/dist/modes/rpc/multi-session-host.js +72 -24
  300. package/dist/modes/rpc/multi-session-host.js.map +1 -1
  301. package/dist/modes/rpc/session-binding.d.ts.map +1 -1
  302. package/dist/modes/rpc/session-binding.js +3 -0
  303. package/dist/modes/rpc/session-binding.js.map +1 -1
  304. package/dist/modes/rpc/session-command-router.d.ts +1 -1
  305. package/dist/modes/rpc/session-command-router.d.ts.map +1 -1
  306. package/dist/modes/rpc/session-command-router.js +57 -25
  307. package/dist/modes/rpc/session-command-router.js.map +1 -1
  308. package/dist/modes/rpc/session-event-writer.d.ts +23 -1
  309. package/dist/modes/rpc/session-event-writer.d.ts.map +1 -1
  310. package/dist/modes/rpc/session-event-writer.js +108 -1
  311. package/dist/modes/rpc/session-event-writer.js.map +1 -1
  312. package/dist/modes/rpc/session-registry.d.ts +4 -2
  313. package/dist/modes/rpc/session-registry.d.ts.map +1 -1
  314. package/dist/modes/rpc/session-registry.js +1 -1
  315. package/dist/modes/rpc/session-registry.js.map +1 -1
  316. package/dist/modes/rpc/session-worker-client.d.ts +47 -0
  317. package/dist/modes/rpc/session-worker-client.d.ts.map +1 -0
  318. package/dist/modes/rpc/session-worker-client.js +226 -0
  319. package/dist/modes/rpc/session-worker-client.js.map +1 -0
  320. package/dist/modes/rpc/session-worker-protocol.d.ts +103 -0
  321. package/dist/modes/rpc/session-worker-protocol.d.ts.map +1 -0
  322. package/dist/modes/rpc/session-worker-protocol.js +12 -0
  323. package/dist/modes/rpc/session-worker-protocol.js.map +1 -0
  324. package/dist/modes/rpc/session-worker-requests.d.ts +24 -0
  325. package/dist/modes/rpc/session-worker-requests.d.ts.map +1 -0
  326. package/dist/modes/rpc/session-worker-requests.js +71 -0
  327. package/dist/modes/rpc/session-worker-requests.js.map +1 -0
  328. package/dist/modes/rpc/session-worker.d.ts +2 -0
  329. package/dist/modes/rpc/session-worker.d.ts.map +1 -0
  330. package/dist/modes/rpc/session-worker.js +229 -0
  331. package/dist/modes/rpc/session-worker.js.map +1 -0
  332. package/dist/modes/rpc/socket-ownership.d.ts +46 -0
  333. package/dist/modes/rpc/socket-ownership.d.ts.map +1 -0
  334. package/dist/modes/rpc/socket-ownership.js +178 -0
  335. package/dist/modes/rpc/socket-ownership.js.map +1 -0
  336. package/dist/modes/rpc/worker-session-registry.d.ts +37 -0
  337. package/dist/modes/rpc/worker-session-registry.d.ts.map +1 -0
  338. package/dist/modes/rpc/worker-session-registry.js +207 -0
  339. package/dist/modes/rpc/worker-session-registry.js.map +1 -0
  340. package/dist/utils/fs-watch.d.ts +17 -0
  341. package/dist/utils/fs-watch.d.ts.map +1 -1
  342. package/dist/utils/fs-watch.js +38 -10
  343. package/dist/utils/fs-watch.js.map +1 -1
  344. package/dist/utils/paths.d.ts +33 -0
  345. package/dist/utils/paths.d.ts.map +1 -1
  346. package/dist/utils/paths.js +109 -3
  347. package/dist/utils/paths.js.map +1 -1
  348. package/docs/development.md +3 -2
  349. package/docs/providers.md +5 -1
  350. package/docs/rpc.md +70 -9
  351. package/docs/settings.md +2 -0
  352. package/docs/skills.md +1 -1
  353. package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +55 -0
  354. package/node_modules/@code-yeongyu/senpi-codemode/README.md +14 -1
  355. package/node_modules/@code-yeongyu/senpi-codemode/package.json +4 -4
  356. package/node_modules/@code-yeongyu/senpi-codemode/src/bridge/protocol.ts +1 -0
  357. package/node_modules/@code-yeongyu/senpi-codemode/src/extension/runtime-factory.ts +3 -0
  358. package/node_modules/@code-yeongyu/senpi-codemode/src/extension/session-manager.ts +7 -0
  359. package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/AGENTS.md +7 -0
  360. package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/jl/kernel.ts +4 -0
  361. package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/kernel-contract.ts +3 -0
  362. package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/worker-core.js +29 -0
  363. package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/worker-indirect-eval.js +10 -6
  364. package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/worker-shell-capture.d.ts +16 -0
  365. package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/worker-shell-capture.js +44 -8
  366. package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/worker-startup.ts +1 -0
  367. package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/py/kernel-contract.ts +3 -0
  368. package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/py/transport.ts +9 -1
  369. package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/rb/kernel.ts +4 -0
  370. package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/session-env.ts +56 -0
  371. package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/shared/subprocess-contract.ts +3 -0
  372. package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/shared/subprocess-kernel.ts +9 -1
  373. package/node_modules/@code-yeongyu/senpi-codemode/src/output/output-meta.ts +26 -2
  374. package/node_modules/@code-yeongyu/senpi-codemode/src/prompt/eval-prompt.ts +17 -24
  375. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/image.ts +12 -3
  376. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.d.ts.map +1 -1
  377. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js +2 -2
  378. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js.map +1 -1
  379. package/node_modules/@earendil-works/pi-agent-core/dist/assistant-terminal-state.d.ts +7 -0
  380. package/node_modules/@earendil-works/pi-agent-core/dist/assistant-terminal-state.d.ts.map +1 -1
  381. package/node_modules/@earendil-works/pi-agent-core/dist/assistant-terminal-state.js +19 -0
  382. package/node_modules/@earendil-works/pi-agent-core/dist/assistant-terminal-state.js.map +1 -1
  383. package/node_modules/@earendil-works/pi-agent-core/dist/empty-assistant-recovery.d.ts.map +1 -1
  384. package/node_modules/@earendil-works/pi-agent-core/dist/empty-assistant-recovery.js +24 -16
  385. package/node_modules/@earendil-works/pi-agent-core/dist/empty-assistant-recovery.js.map +1 -1
  386. package/node_modules/@earendil-works/pi-agent-core/dist/index.d.ts +1 -1
  387. package/node_modules/@earendil-works/pi-agent-core/dist/index.d.ts.map +1 -1
  388. package/node_modules/@earendil-works/pi-agent-core/dist/index.js +1 -1
  389. package/node_modules/@earendil-works/pi-agent-core/dist/index.js.map +1 -1
  390. package/node_modules/@earendil-works/pi-agent-core/package.json +3 -3
  391. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.d.ts.map +1 -1
  392. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +70 -183
  393. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js.map +1 -1
  394. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-tool-references.d.ts +3 -0
  395. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-tool-references.d.ts.map +1 -0
  396. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-tool-references.js +260 -0
  397. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-tool-references.js.map +1 -0
  398. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.d.ts.map +1 -1
  399. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js +1 -0
  400. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js.map +1 -1
  401. package/node_modules/@earendil-works/pi-ai/dist/api/openai-images-edit.d.ts +4 -0
  402. package/node_modules/@earendil-works/pi-ai/dist/api/openai-images-edit.d.ts.map +1 -0
  403. package/node_modules/@earendil-works/pi-ai/dist/api/openai-images-edit.js +11 -0
  404. package/node_modules/@earendil-works/pi-ai/dist/api/openai-images-edit.js.map +1 -0
  405. package/node_modules/@earendil-works/pi-ai/dist/api/openai-images-params.d.ts +25 -0
  406. package/node_modules/@earendil-works/pi-ai/dist/api/openai-images-params.d.ts.map +1 -0
  407. package/node_modules/@earendil-works/pi-ai/dist/api/openai-images-params.js +58 -0
  408. package/node_modules/@earendil-works/pi-ai/dist/api/openai-images-params.js.map +1 -0
  409. package/node_modules/@earendil-works/pi-ai/dist/api/openai-images.d.ts +3 -6
  410. package/node_modules/@earendil-works/pi-ai/dist/api/openai-images.d.ts.map +1 -1
  411. package/node_modules/@earendil-works/pi-ai/dist/api/openai-images.js +15 -33
  412. package/node_modules/@earendil-works/pi-ai/dist/api/openai-images.js.map +1 -1
  413. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.d.ts.map +1 -1
  414. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js +1 -0
  415. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js.map +1 -1
  416. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/anthropic-callback-listener.d.ts +40 -0
  417. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/anthropic-callback-listener.d.ts.map +1 -0
  418. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/anthropic-callback-listener.js +138 -0
  419. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/anthropic-callback-listener.js.map +1 -0
  420. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/anthropic.d.ts +2 -3
  421. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/anthropic.d.ts.map +1 -1
  422. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/anthropic.js +42 -139
  423. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/anthropic.js.map +1 -1
  424. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/authorization-input.d.ts +6 -0
  425. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/authorization-input.d.ts.map +1 -0
  426. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/authorization-input.js +29 -0
  427. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/authorization-input.js.map +1 -0
  428. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/error-details.d.ts +3 -0
  429. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/error-details.d.ts.map +1 -0
  430. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/error-details.js +20 -0
  431. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/error-details.js.map +1 -0
  432. package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.d.ts +61 -1
  433. package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.d.ts.map +1 -1
  434. package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js +61 -1
  435. package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js.map +1 -1
  436. package/node_modules/@earendil-works/pi-ai/dist/images.d.ts +1 -0
  437. package/node_modules/@earendil-works/pi-ai/dist/images.d.ts.map +1 -1
  438. package/node_modules/@earendil-works/pi-ai/dist/images.js +1 -0
  439. package/node_modules/@earendil-works/pi-ai/dist/images.js.map +1 -1
  440. package/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
  441. package/node_modules/@earendil-works/pi-ai/dist/providers/data/amazon-bedrock.json +1 -1
  442. package/node_modules/@earendil-works/pi-ai/dist/providers/data/azure-openai-responses.json +1 -1
  443. package/node_modules/@earendil-works/pi-ai/dist/providers/data/fireworks.json +1 -1
  444. package/node_modules/@earendil-works/pi-ai/dist/providers/data/github-copilot.json +1 -1
  445. package/node_modules/@earendil-works/pi-ai/dist/providers/data/nvidia.json +1 -1
  446. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openai-codex.json +1 -1
  447. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openai.json +1 -1
  448. package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
  449. package/node_modules/@earendil-works/pi-ai/dist/providers/data/opengateway.json +1 -1
  450. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
  451. package/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
  452. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/recovery-stream-terminal.d.ts.map +1 -1
  453. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/recovery-stream-terminal.js +16 -1
  454. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/recovery-stream-terminal.js.map +1 -1
  455. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts +7 -0
  456. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts.map +1 -1
  457. package/node_modules/@earendil-works/pi-ai/dist/types.js.map +1 -1
  458. package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.d.ts +1 -1
  459. package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.d.ts.map +1 -1
  460. package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.js +14 -3
  461. package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.js.map +1 -1
  462. package/node_modules/@earendil-works/pi-ai/dist/utils/server-fallback-receipt.d.ts +2 -1
  463. package/node_modules/@earendil-works/pi-ai/dist/utils/server-fallback-receipt.d.ts.map +1 -1
  464. package/node_modules/@earendil-works/pi-ai/dist/utils/server-fallback-receipt.js +16 -0
  465. package/node_modules/@earendil-works/pi-ai/dist/utils/server-fallback-receipt.js.map +1 -1
  466. package/node_modules/@earendil-works/pi-ai/package.json +2 -2
  467. package/node_modules/@earendil-works/pi-pty/package.json +1 -1
  468. package/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
  469. package/node_modules/@earendil-works/pi-tui/package.json +1 -1
  470. package/package.json +7 -7
@@ -1,6 +1,6 @@
1
- import { realpathSync, statSync } from "node:fs";
1
+ import { lstatSync, readlinkSync, realpathSync, statSync } from "node:fs";
2
2
  import { homedir } from "node:os";
3
- import { isAbsolute, join, resolve as nodeResolvePath, relative, sep } from "node:path";
3
+ import { isAbsolute, join, resolve as nodeResolvePath, parse, relative, sep } from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import { spawnProcessSync } from "./child-process.js";
6
6
  const UNICODE_SPACES = /[\u00A0\u2000-\u200A\u202F\u205F\u3000]/g;
@@ -12,12 +12,118 @@ const UNICODE_SPACES = /[\u00A0\u2000-\u200A\u202F\u205F\u3000]/g;
12
12
  */
13
13
  export function canonicalizePath(path) {
14
14
  try {
15
- return realpathSync(path);
15
+ return realpathSync.native(path);
16
16
  }
17
17
  catch {
18
18
  return path;
19
19
  }
20
20
  }
21
+ /**
22
+ * {@link canonicalizePath} that refuses to guess.
23
+ *
24
+ * The convenience form hands back its input when resolution fails, which is what most callers
25
+ * want: they compare two canonical spellings and an unresolvable path simply compares unequal.
26
+ * A security decision cannot use that, because the raw input is indistinguishable from a
27
+ * canonical answer - so a path that could not be resolved would be keyed, compared, or trusted
28
+ * under a spelling the filesystem never confirmed. This form throws instead, leaving the caller
29
+ * to decide what an unresolvable path means.
30
+ */
31
+ export function canonicalizePathStrict(path) {
32
+ return realpathSync.native(path);
33
+ }
34
+ /** Symlink hops allowed while resolving one path; realpath(3) reports ELOOP past this. */
35
+ const MAX_SYMLINK_HOPS = 40;
36
+ /** Error codes that mean "this component does not exist", which resolution tolerates. */
37
+ const MISSING_PATH_CODES = new Set(["ENOENT", "ENOTDIR"]);
38
+ function splitParts(pathSegment) {
39
+ return pathSegment.split(sep).filter((part) => part.length > 0);
40
+ }
41
+ /**
42
+ * realpath(3) semantics with one lstat/readlink per component and no open(2) anywhere.
43
+ *
44
+ * `..` is applied to the already-resolved prefix rather than collapsed lexically, because the two
45
+ * differ whenever a link target reaches back through a symlink: for `entry -> jump/../secret` with
46
+ * `jump -> /elsewhere/dir`, POSIX resolves `jump` first and lands in `/elsewhere/secret`, while a
47
+ * lexical collapse would answer `secret` next to `entry`. Handing a lexical answer to a
48
+ * containment decision would approve one directory while the I/O reached another, so neither the
49
+ * input nor a link target is normalized before traversal.
50
+ */
51
+ function resolveWithoutOpen(inputPath) {
52
+ const absolutePath = isAbsolute(inputPath) ? inputPath : nodeResolvePath(inputPath);
53
+ const { root } = parse(absolutePath);
54
+ const pending = splitParts(absolutePath.slice(root.length));
55
+ const resolved = [];
56
+ let hops = 0;
57
+ while (pending.length > 0) {
58
+ const part = pending.shift();
59
+ if (part === undefined)
60
+ break;
61
+ if (part === ".")
62
+ continue;
63
+ if (part === "..") {
64
+ // At the root `..` is the root itself, which an empty stack already represents.
65
+ resolved.pop();
66
+ continue;
67
+ }
68
+ const candidate = join(root, ...resolved, part);
69
+ let link;
70
+ try {
71
+ if (!lstatSync(candidate).isSymbolicLink()) {
72
+ resolved.push(part);
73
+ continue;
74
+ }
75
+ hops += 1;
76
+ if (hops > MAX_SYMLINK_HOPS)
77
+ return { path: join(candidate, ...pending), errorCode: "ELOOP" };
78
+ link = readlinkSync(candidate);
79
+ }
80
+ catch (error) {
81
+ const code = error?.code ?? "UNKNOWN";
82
+ return { path: join(candidate, ...pending), errorCode: code };
83
+ }
84
+ if (isAbsolute(link)) {
85
+ resolved.length = 0;
86
+ pending.unshift(...splitParts(link.slice(parse(link).root.length)));
87
+ }
88
+ else {
89
+ pending.unshift(...splitParts(link));
90
+ }
91
+ }
92
+ return { path: join(root, ...resolved) };
93
+ }
94
+ /**
95
+ * Resolve symlinks without ever open(2)-ing a component, tolerating every error.
96
+ *
97
+ * Bun's `fs.realpath*` opens every directory it resolves, so an autofs trigger such as macOS
98
+ * `/home` blocks the calling thread (on the host main thread that freezes the TUI) and an
99
+ * execute-only directory fails with EACCES; lstat needs only search permission and never mounts
100
+ * anything. Components from the first unresolvable one onward are kept verbatim, so a file that
101
+ * does not exist yet still lands where its symlinked parent points.
102
+ *
103
+ * Never throws, so the resolved path may be incomplete. Use it where an approximate answer is
104
+ * better than a blocked thread — the external-path classifier and the monitor parent identity —
105
+ * and use {@link realpathWithoutOpenStrict} where an incomplete answer must not be trusted.
106
+ */
107
+ export function realpathWithoutOpen(inputPath) {
108
+ return resolveWithoutOpen(inputPath).path;
109
+ }
110
+ /**
111
+ * {@link realpathWithoutOpen} that refuses to answer with a guess: a missing component is still
112
+ * tolerated (its name is appended verbatim, which is what a not-yet-created target needs), but
113
+ * EACCES, EIO, ELOOP and hop exhaustion throw instead of returning an unresolved path. Callers
114
+ * that feed a canonical path into a containment or identity decision need this contract, because
115
+ * an unresolved path can name a different file than the one the I/O will reach.
116
+ */
117
+ export function realpathWithoutOpenStrict(inputPath) {
118
+ const resolution = resolveWithoutOpen(inputPath);
119
+ if (resolution.errorCode !== undefined && !MISSING_PATH_CODES.has(resolution.errorCode)) {
120
+ throw Object.assign(new Error(`${resolution.errorCode}: cannot resolve path '${inputPath}' without opening it`), {
121
+ code: resolution.errorCode,
122
+ path: inputPath,
123
+ });
124
+ }
125
+ return resolution.path;
126
+ }
21
127
  export function getFileRevision(path) {
22
128
  try {
23
129
  const stats = statSync(path, { bigint: true });
@@ -1 +1 @@
1
- {"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/utils/paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,IAAI,eAAe,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACxF,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,MAAM,cAAc,GAAG,0CAA0C,CAAC;AAelE;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC5C,IAAI,CAAC;QACJ,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,IAAI,CAAC;IACb,CAAC;AACF,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,IAAY;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AAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IACvB,MAAM,IAAI,GAAG,OAAO,EAAE,CAAC;IACvB,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;IAChE,OAAO,IAAI,CAAC;AACb,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,IAAY;IACtD,MAAM,KAAK,GACV,OAAO,CAAC,QAAQ,KAAK,QAAQ;QAC5B,CAAC,CAAC,CAAC,qBAAqB,EAAE,iCAAiC,CAAC;QAC5D,CAAC,CAAC,OAAO,CAAC,QAAQ,KAAK,OAAO;YAC7B,CAAC,CAAC,CAAC,0BAA0B,CAAC;YAC9B,CAAC,CAAC,EAAE,CAAC;IAER,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QAC1B,IAAI,OAAO,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;YACnC,gBAAgB,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC5F,CAAC;aAAM,CAAC;YACP,gBAAgB,CAAC,UAAU,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QACrG,CAAC;IACF,CAAC;AACF,CAAC","sourcesContent":["import { realpathSync, statSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { isAbsolute, join, resolve as nodeResolvePath, relative, sep } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { spawnProcessSync } from \"./child-process.ts\";\n\nconst UNICODE_SPACES = /[\\u00A0\\u2000-\\u200A\\u202F\\u205F\\u3000]/g;\n\nexport interface PathInputOptions {\n\t/** Trim leading/trailing whitespace before normalization. */\n\ttrim?: boolean;\n\t/** Expand leading `~` to a home directory. Defaults to true. */\n\texpandTilde?: boolean;\n\t/** Home directory used for `~` expansion. Defaults to `os.homedir()`. */\n\thomeDir?: string;\n\t/** Strip a leading `@`, used for CLI @file paths. */\n\tstripAtPrefix?: boolean;\n\t/** Normalize unicode space variants to regular spaces. */\n\tnormalizeUnicodeSpaces?: boolean;\n}\n\n/**\n * Resolve a path to its canonical (real) form, following symlinks.\n * Falls back to the raw path if resolution fails (e.g. the target does\n * not exist yet), so that callers never crash on missing filesystem\n * entries.\n */\nexport function canonicalizePath(path: string): string {\n\ttry {\n\t\treturn realpathSync(path);\n\t} catch {\n\t\treturn path;\n\t}\n}\n\nexport function getFileRevision(path: string): string | undefined {\n\ttry {\n\t\tconst stats = statSync(path, { bigint: true });\n\t\treturn `${stats.dev}:${stats.ino}:${stats.size}:${stats.mtimeNs}:${stats.ctimeNs}`;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/**\n * Returns true if the value is NOT a package source (npm:, git:, etc.)\n * or a remote URL protocol. Bare names, relative paths, and file: URLs\n * are considered local.\n */\nexport function isLocalPath(value: string): boolean {\n\tconst trimmed = value.trim();\n\t// Known non-local prefixes. file: URLs are local paths and are intentionally resolved by resolvePath().\n\tif (\n\t\ttrimmed.startsWith(\"npm:\") ||\n\t\ttrimmed.startsWith(\"git:\") ||\n\t\ttrimmed.startsWith(\"github:\") ||\n\t\ttrimmed.startsWith(\"http:\") ||\n\t\ttrimmed.startsWith(\"https:\") ||\n\t\ttrimmed.startsWith(\"ssh:\")\n\t) {\n\t\treturn false;\n\t}\n\treturn true;\n}\n\n/** Convert Git Bash, MSYS, Cygwin, and WSL drive paths to a form native Windows APIs accept. */\nexport function normalizeWindowsShellPath(filePath: string): string {\n\tif (!filePath.startsWith(\"/\") || filePath.startsWith(\"//\") || filePath.includes(\"\\\\\")) return filePath;\n\tconst match = filePath.match(/^\\/(?:mnt\\/|cygdrive\\/)?([a-z])(?:\\/(.*))?$/i);\n\tif (!match) return filePath;\n\tconst suffix = match[2]?.replaceAll(\"/\", \"\\\\\");\n\treturn `${match[1].toUpperCase()}:\\\\${suffix ?? \"\"}`;\n}\n\nexport function normalizePath(input: string, options: PathInputOptions = {}): string {\n\tlet normalized = options.trim ? input.trim() : input;\n\tif (options.normalizeUnicodeSpaces) {\n\t\tnormalized = normalized.replace(UNICODE_SPACES, \" \");\n\t}\n\tif (options.stripAtPrefix && normalized.startsWith(\"@\")) {\n\t\tnormalized = normalized.slice(1);\n\t}\n\tif (process.platform === \"win32\") {\n\t\tnormalized = normalizeWindowsShellPath(normalized);\n\t}\n\n\tif (options.expandTilde ?? true) {\n\t\tconst home = options.homeDir ?? homedir();\n\t\tif (normalized === \"~\") return home;\n\t\tif (normalized.startsWith(\"~/\") || (process.platform === \"win32\" && normalized.startsWith(\"~\\\\\"))) {\n\t\t\treturn join(home, normalized.slice(2));\n\t\t}\n\t}\n\n\tif (/^file:\\/\\//.test(normalized)) {\n\t\treturn fileURLToPath(normalized);\n\t}\n\n\treturn normalized;\n}\n\nexport function resolvePath(input: string, baseDir: string = process.cwd(), options: PathInputOptions = {}): string {\n\tconst normalized = normalizePath(input, options);\n\tconst normalizedBaseDir = normalizePath(baseDir);\n\treturn isAbsolute(normalized) ? nodeResolvePath(normalized) : nodeResolvePath(normalizedBaseDir, normalized);\n}\n\nexport function getCwdRelativePath(filePath: string, cwd: string): string | undefined {\n\tconst resolvedCwd = resolvePath(cwd);\n\tconst resolvedPath = resolvePath(filePath, resolvedCwd);\n\tconst relativePath = relative(resolvedCwd, resolvedPath);\n\tconst isInsideCwd =\n\t\trelativePath === \"\" ||\n\t\t(relativePath !== \"..\" && !relativePath.startsWith(`..${sep}`) && !isAbsolute(relativePath));\n\n\treturn isInsideCwd ? relativePath || \".\" : undefined;\n}\n\nexport function formatPathRelativeToCwdOrAbsolute(filePath: string, cwd: string): string {\n\tconst absolutePath = resolvePath(filePath, cwd);\n\treturn (getCwdRelativePath(absolutePath, cwd) ?? absolutePath).split(sep).join(\"/\");\n}\n\nexport function shortenPath(path: string): string {\n\tif (!path) return path;\n\tconst home = homedir();\n\tif (path.startsWith(home)) return `~${path.slice(home.length)}`;\n\treturn path;\n}\n\nexport function markPathIgnoredByCloudSync(path: string): void {\n\tconst attrs =\n\t\tprocess.platform === \"darwin\"\n\t\t\t? [\"com.dropbox.ignored\", \"com.apple.fileprovider.ignore#P\"]\n\t\t\t: process.platform === \"linux\"\n\t\t\t\t? [\"user.com.dropbox.ignored\"]\n\t\t\t\t: [];\n\n\tfor (const attr of attrs) {\n\t\tif (process.platform === \"darwin\") {\n\t\t\tspawnProcessSync(\"xattr\", [\"-w\", attr, \"1\", path], { encoding: \"utf-8\", stdio: \"ignore\" });\n\t\t} else {\n\t\t\tspawnProcessSync(\"setfattr\", [\"-n\", attr, \"-v\", \"1\", path], { encoding: \"utf-8\", stdio: \"ignore\" });\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/utils/paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,IAAI,eAAe,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAC/F,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,MAAM,cAAc,GAAG,0CAA0C,CAAC;AAelE;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC5C,IAAI,CAAC;QACJ,OAAO,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;I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,gBAAgB,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC5F,CAAC;aAAM,CAAC;YACP,gBAAgB,CAAC,UAAU,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QACrG,CAAC;IACF,CAAC;AACF,CAAC","sourcesContent":["import { lstatSync, readlinkSync, realpathSync, statSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { isAbsolute, join, resolve as nodeResolvePath, parse, relative, sep } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { spawnProcessSync } from \"./child-process.ts\";\n\nconst UNICODE_SPACES = /[\\u00A0\\u2000-\\u200A\\u202F\\u205F\\u3000]/g;\n\nexport interface PathInputOptions {\n\t/** Trim leading/trailing whitespace before normalization. */\n\ttrim?: boolean;\n\t/** Expand leading `~` to a home directory. Defaults to true. */\n\texpandTilde?: boolean;\n\t/** Home directory used for `~` expansion. Defaults to `os.homedir()`. */\n\thomeDir?: string;\n\t/** Strip a leading `@`, used for CLI @file paths. */\n\tstripAtPrefix?: boolean;\n\t/** Normalize unicode space variants to regular spaces. */\n\tnormalizeUnicodeSpaces?: boolean;\n}\n\n/**\n * Resolve a path to its canonical (real) form, following symlinks.\n * Falls back to the raw path if resolution fails (e.g. the target does\n * not exist yet), so that callers never crash on missing filesystem\n * entries.\n */\nexport function canonicalizePath(path: string): string {\n\ttry {\n\t\treturn realpathSync.native(path);\n\t} catch {\n\t\treturn path;\n\t}\n}\n\n/**\n * {@link canonicalizePath} that refuses to guess.\n *\n * The convenience form hands back its input when resolution fails, which is what most callers\n * want: they compare two canonical spellings and an unresolvable path simply compares unequal.\n * A security decision cannot use that, because the raw input is indistinguishable from a\n * canonical answer - so a path that could not be resolved would be keyed, compared, or trusted\n * under a spelling the filesystem never confirmed. This form throws instead, leaving the caller\n * to decide what an unresolvable path means.\n */\nexport function canonicalizePathStrict(path: string): string {\n\treturn realpathSync.native(path);\n}\n\n/** Symlink hops allowed while resolving one path; realpath(3) reports ELOOP past this. */\nconst MAX_SYMLINK_HOPS = 40;\n\n/** Error codes that mean \"this component does not exist\", which resolution tolerates. */\nconst MISSING_PATH_CODES = new Set([\"ENOENT\", \"ENOTDIR\"]);\n\nfunction splitParts(pathSegment: string): string[] {\n\treturn pathSegment.split(sep).filter((part) => part.length > 0);\n}\n\ninterface OpenFreeResolution {\n\t/** The resolved path; components from an unresolvable one onward are kept verbatim. */\n\treadonly path: string;\n\t/** Set when resolution stopped early: the fs error code, or ELOOP for hop exhaustion. */\n\treadonly errorCode?: string;\n}\n\n/**\n * realpath(3) semantics with one lstat/readlink per component and no open(2) anywhere.\n *\n * `..` is applied to the already-resolved prefix rather than collapsed lexically, because the two\n * differ whenever a link target reaches back through a symlink: for `entry -> jump/../secret` with\n * `jump -> /elsewhere/dir`, POSIX resolves `jump` first and lands in `/elsewhere/secret`, while a\n * lexical collapse would answer `secret` next to `entry`. Handing a lexical answer to a\n * containment decision would approve one directory while the I/O reached another, so neither the\n * input nor a link target is normalized before traversal.\n */\nfunction resolveWithoutOpen(inputPath: string): OpenFreeResolution {\n\tconst absolutePath = isAbsolute(inputPath) ? inputPath : nodeResolvePath(inputPath);\n\tconst { root } = parse(absolutePath);\n\tconst pending = splitParts(absolutePath.slice(root.length));\n\tconst resolved: string[] = [];\n\tlet hops = 0;\n\twhile (pending.length > 0) {\n\t\tconst part = pending.shift();\n\t\tif (part === undefined) break;\n\t\tif (part === \".\") continue;\n\t\tif (part === \"..\") {\n\t\t\t// At the root `..` is the root itself, which an empty stack already represents.\n\t\t\tresolved.pop();\n\t\t\tcontinue;\n\t\t}\n\t\tconst candidate = join(root, ...resolved, part);\n\t\tlet link: string;\n\t\ttry {\n\t\t\tif (!lstatSync(candidate).isSymbolicLink()) {\n\t\t\t\tresolved.push(part);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\thops += 1;\n\t\t\tif (hops > MAX_SYMLINK_HOPS) return { path: join(candidate, ...pending), errorCode: \"ELOOP\" };\n\t\t\tlink = readlinkSync(candidate);\n\t\t} catch (error) {\n\t\t\tconst code = (error as NodeJS.ErrnoException)?.code ?? \"UNKNOWN\";\n\t\t\treturn { path: join(candidate, ...pending), errorCode: code };\n\t\t}\n\t\tif (isAbsolute(link)) {\n\t\t\tresolved.length = 0;\n\t\t\tpending.unshift(...splitParts(link.slice(parse(link).root.length)));\n\t\t} else {\n\t\t\tpending.unshift(...splitParts(link));\n\t\t}\n\t}\n\treturn { path: join(root, ...resolved) };\n}\n\n/**\n * Resolve symlinks without ever open(2)-ing a component, tolerating every error.\n *\n * Bun's `fs.realpath*` opens every directory it resolves, so an autofs trigger such as macOS\n * `/home` blocks the calling thread (on the host main thread that freezes the TUI) and an\n * execute-only directory fails with EACCES; lstat needs only search permission and never mounts\n * anything. Components from the first unresolvable one onward are kept verbatim, so a file that\n * does not exist yet still lands where its symlinked parent points.\n *\n * Never throws, so the resolved path may be incomplete. Use it where an approximate answer is\n * better than a blocked thread — the external-path classifier and the monitor parent identity —\n * and use {@link realpathWithoutOpenStrict} where an incomplete answer must not be trusted.\n */\nexport function realpathWithoutOpen(inputPath: string): string {\n\treturn resolveWithoutOpen(inputPath).path;\n}\n\n/**\n * {@link realpathWithoutOpen} that refuses to answer with a guess: a missing component is still\n * tolerated (its name is appended verbatim, which is what a not-yet-created target needs), but\n * EACCES, EIO, ELOOP and hop exhaustion throw instead of returning an unresolved path. Callers\n * that feed a canonical path into a containment or identity decision need this contract, because\n * an unresolved path can name a different file than the one the I/O will reach.\n */\nexport function realpathWithoutOpenStrict(inputPath: string): string {\n\tconst resolution = resolveWithoutOpen(inputPath);\n\tif (resolution.errorCode !== undefined && !MISSING_PATH_CODES.has(resolution.errorCode)) {\n\t\tthrow Object.assign(new Error(`${resolution.errorCode}: cannot resolve path '${inputPath}' without opening it`), {\n\t\t\tcode: resolution.errorCode,\n\t\t\tpath: inputPath,\n\t\t});\n\t}\n\treturn resolution.path;\n}\n\nexport function getFileRevision(path: string): string | undefined {\n\ttry {\n\t\tconst stats = statSync(path, { bigint: true });\n\t\treturn `${stats.dev}:${stats.ino}:${stats.size}:${stats.mtimeNs}:${stats.ctimeNs}`;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/**\n * Returns true if the value is NOT a package source (npm:, git:, etc.)\n * or a remote URL protocol. Bare names, relative paths, and file: URLs\n * are considered local.\n */\nexport function isLocalPath(value: string): boolean {\n\tconst trimmed = value.trim();\n\t// Known non-local prefixes. file: URLs are local paths and are intentionally resolved by resolvePath().\n\tif (\n\t\ttrimmed.startsWith(\"npm:\") ||\n\t\ttrimmed.startsWith(\"git:\") ||\n\t\ttrimmed.startsWith(\"github:\") ||\n\t\ttrimmed.startsWith(\"http:\") ||\n\t\ttrimmed.startsWith(\"https:\") ||\n\t\ttrimmed.startsWith(\"ssh:\")\n\t) {\n\t\treturn false;\n\t}\n\treturn true;\n}\n\n/** Convert Git Bash, MSYS, Cygwin, and WSL drive paths to a form native Windows APIs accept. */\nexport function normalizeWindowsShellPath(filePath: string): string {\n\tif (!filePath.startsWith(\"/\") || filePath.startsWith(\"//\") || filePath.includes(\"\\\\\")) return filePath;\n\tconst match = filePath.match(/^\\/(?:mnt\\/|cygdrive\\/)?([a-z])(?:\\/(.*))?$/i);\n\tif (!match) return filePath;\n\tconst suffix = match[2]?.replaceAll(\"/\", \"\\\\\");\n\treturn `${match[1].toUpperCase()}:\\\\${suffix ?? \"\"}`;\n}\n\nexport function normalizePath(input: string, options: PathInputOptions = {}): string {\n\tlet normalized = options.trim ? input.trim() : input;\n\tif (options.normalizeUnicodeSpaces) {\n\t\tnormalized = normalized.replace(UNICODE_SPACES, \" \");\n\t}\n\tif (options.stripAtPrefix && normalized.startsWith(\"@\")) {\n\t\tnormalized = normalized.slice(1);\n\t}\n\tif (process.platform === \"win32\") {\n\t\tnormalized = normalizeWindowsShellPath(normalized);\n\t}\n\n\tif (options.expandTilde ?? true) {\n\t\tconst home = options.homeDir ?? homedir();\n\t\tif (normalized === \"~\") return home;\n\t\tif (normalized.startsWith(\"~/\") || (process.platform === \"win32\" && normalized.startsWith(\"~\\\\\"))) {\n\t\t\treturn join(home, normalized.slice(2));\n\t\t}\n\t}\n\n\tif (/^file:\\/\\//.test(normalized)) {\n\t\treturn fileURLToPath(normalized);\n\t}\n\n\treturn normalized;\n}\n\nexport function resolvePath(input: string, baseDir: string = process.cwd(), options: PathInputOptions = {}): string {\n\tconst normalized = normalizePath(input, options);\n\tconst normalizedBaseDir = normalizePath(baseDir);\n\treturn isAbsolute(normalized) ? nodeResolvePath(normalized) : nodeResolvePath(normalizedBaseDir, normalized);\n}\n\nexport function getCwdRelativePath(filePath: string, cwd: string): string | undefined {\n\tconst resolvedCwd = resolvePath(cwd);\n\tconst resolvedPath = resolvePath(filePath, resolvedCwd);\n\tconst relativePath = relative(resolvedCwd, resolvedPath);\n\tconst isInsideCwd =\n\t\trelativePath === \"\" ||\n\t\t(relativePath !== \"..\" && !relativePath.startsWith(`..${sep}`) && !isAbsolute(relativePath));\n\n\treturn isInsideCwd ? relativePath || \".\" : undefined;\n}\n\nexport function formatPathRelativeToCwdOrAbsolute(filePath: string, cwd: string): string {\n\tconst absolutePath = resolvePath(filePath, cwd);\n\treturn (getCwdRelativePath(absolutePath, cwd) ?? absolutePath).split(sep).join(\"/\");\n}\n\nexport function shortenPath(path: string): string {\n\tif (!path) return path;\n\tconst home = homedir();\n\tif (path.startsWith(home)) return `~${path.slice(home.length)}`;\n\treturn path;\n}\n\nexport function markPathIgnoredByCloudSync(path: string): void {\n\tconst attrs =\n\t\tprocess.platform === \"darwin\"\n\t\t\t? [\"com.dropbox.ignored\", \"com.apple.fileprovider.ignore#P\"]\n\t\t\t: process.platform === \"linux\"\n\t\t\t\t? [\"user.com.dropbox.ignored\"]\n\t\t\t\t: [];\n\n\tfor (const attr of attrs) {\n\t\tif (process.platform === \"darwin\") {\n\t\t\tspawnProcessSync(\"xattr\", [\"-w\", attr, \"1\", path], { encoding: \"utf-8\", stdio: \"ignore\" });\n\t\t} else {\n\t\t\tspawnProcessSync(\"setfattr\", [\"-n\", attr, \"-v\", \"1\", path], { encoding: \"utf-8\", stdio: \"ignore\" });\n\t\t}\n\t}\n}\n"]}
@@ -62,10 +62,11 @@ bun run check # Biome + tsc + browser-smoke check (pre-commit equivalent)
62
62
 
63
63
  Live-API tests are env-gated vitest tests. Set `PI_ENABLE_LIVE_API_TESTS=1` (or a per-provider flag from `packages/ai/test/live-api-gates.ts`) plus the provider API keys, then run `bun run test`.
64
64
 
65
- Run a specific test:
65
+ Run a specific test from the package, or from the repository root through the workspace runner (the root form runs the `scripts/` tests first):
66
66
 
67
67
  ```bash
68
- bun run test --workspace @code-yeongyu/senpi -- test/specific.test.ts
68
+ bun run --cwd packages/coding-agent test -- test/specific.test.ts
69
+ bun run test --workspace packages/coding-agent -- test/specific.test.ts
69
70
  ```
70
71
 
71
72
  ## Project Structure
package/docs/providers.md CHANGED
@@ -36,6 +36,10 @@ Use `/logout` to clear credentials. Tokens are stored in `~/.senpi/agent/auth.js
36
36
 
37
37
  Anthropic subscription auth is active for Claude Pro/Max accounts. Third-party harness usage draws from [extra usage](https://claude.ai/settings/usage) and is billed per token, not against Claude plan limits.
38
38
 
39
+ - Run `/login anthropic` to open the browser flow. The login listens on loopback port 53692 when it is free and on an ephemeral port otherwise, so a second session on the same machine (another TUI, an RPC host, an abandoned login) can log in at the same time; the auth URL always names the port that is actually listening.
40
+ - If the browser lands on a page saying the login belongs to a different session or an earlier attempt, that page's address was sent to another login's listener: paste the full address from the address bar into the session whose prompt is still waiting, or run the login again from that session.
41
+ - A login that receives neither the browser callback nor a pasted redirect URL for 10 minutes fails with a timeout and releases its port; run `/login anthropic` again.
42
+
39
43
  ### Claude SDK OAuth
40
44
 
41
45
  The `claude-sdk-oauth` provider routes LLM calls through the official [Claude Agent SDK](https://www.npmjs.com/package/@anthropic-ai/claude-agent-sdk) - it spawns the real Claude Code engine - while senpi executes every tool itself. Subscription usage flows through Anthropic's official Claude Code surface.
@@ -101,7 +105,7 @@ If your Claude Pro/Max subscription usage through `claude-sdk-oauth` feels unexp
101
105
  | Anthropic-compatible providers (kimi-coding, fireworks, gateways) | 5 minutes | The 1h TTL is gated on the native `api.anthropic.com` base URL, so these lanes stay short. | `cacheRetention` |
102
106
 
103
107
  Override precedence: `cacheRetention` in `models.json` / the model catalog wins over everything. `PI_CACHE_RETENTION=long` selects long; any other set value forces short; unset falls back to the lane default above.
104
- 5. **Goal-monitor timing.** The goal monitor's continuation backstop is derived from the model's cache-safe wait (TTL minus `promptCache.safetyBufferSeconds`, default 30), capped by `promptCache.goalBackstopMaxSeconds` (default 3570), instead of a fixed 4 minutes. The default 5m lanes wake every ~4m30s; a supported lane explicitly configured for 1h retention can wait up to 59m30s. Cache-warm notices show which warm iteration you are on.
108
+ 5. **Goal-monitor timing.** While at least one wake source is live, the goal monitor arms one periodic backstop of `promptCache.goalBackstopMaxSeconds` (default 270, so 4m30s: the 5-minute Anthropic prompt-cache TTL minus the 30s safety buffer; hard-capped at 1h). The normal resumption is event-driven: a monitor event or a finished background job starts a turn, and when the last wake source drains, exactly one continuation is queued about a second later. The backstop is the floor underneath that: a wake source can be misconfigured (a filter that never matches, a stream that never ends), so the goal re-checks at least once per backstop interval instead of waiting an hour on a source that will never deliver. Each backstop firing is a full main-model turn that re-sends the accumulated context; at the default it lands inside the prompt-cache TTL, so the cache stays warm. Raise `goalBackstopMaxSeconds` (up to 3600) to trade that re-check frequency for cost on a wait you trust, and use `promptCache.keepAlive` (opt-in, off by default) to keep the cache warm across such a long backstop. Cache-warm notices show which warm iteration you are on.
105
109
  6. **Wake sources that hold the goal backstop.** Anything that can wake a parked session publishes a `wake_source_state` event (`{source, activeCount}`): terminal monitors (`terminal-monitors`), background bash sessions including auto-detached and killed ones (`terminal-background-sessions`), detached `eval` cells (`senpi-codemode`), and omo-senpi background task children plus owned team members (`senpi-task`). The goal extension sums every source, so a goal waits inside the prompt-cache TTL while ANY of them is on duty instead of continuing immediately. The legacy `terminal_monitor_state` event is still emitted for external consumers and is folded onto the same `terminal-monitors` count.
106
110
  7. **Directive-block deduplication.** As of v2026.8.4, the flatten serialization collapses repeated `<ultrawork-mode>` directive blocks to a single copy, preventing the issue-#494 scenario where duplicated ~17KB directive blocks consumed up to 73% of the re-sent prompt. The continuity observation reports how many were collapsed and the payload size.
107
111
 
package/docs/rpc.md CHANGED
@@ -177,8 +177,8 @@ hosts) sees neither variable and is unaffected. A host whose supervisor is alive
177
177
 
178
178
  ### Shared host occupancy (idle eviction, session cap, empty-host exit)
179
179
 
180
- Every open session owns a complete runtime (a lone idle session measures 340-510 MB RSS), so the host enforces three
181
- occupancy bounds itself, independent of the supervisor and of client cooperation:
180
+ Every CLI shared-host session owns a worker isolate and a complete runtime. Memory depends on its extensions and
181
+ session contents; isolates do not provide process-fatal OOM containment. The host enforces these occupancy bounds:
182
182
 
183
183
  - **Idle eviction**: a session with no routed command and no session-owned work for
184
184
  `SENPI_RPC_SESSION_IDLE_EVICTION_MS` (default 30 minutes) is closed through the exact `close_session` sequence
@@ -188,9 +188,13 @@ occupancy bounds itself, independent of the supervisor and of client cooperation
188
188
  background terminal jobs and any other published wake source (terminal monitors, loop-guard holds), compaction,
189
189
  and barrier-held session work all defer eviction, and the idle clock restarts when that work settles. An evicted
190
190
  session resumes like any other: the next `open_session` with the same `sessionPath` reopens it.
191
- - **Logical sessions**: `open_session` has no session-count admission limit. Every logical session remains isolated
192
- by its routing handle and provider scope inside this one shared daemon; idle eviction and empty-host shutdown
193
- reclaim resident resources without rejecting a new session.
191
+ - **Worker capacity**: at most 20 workers may be preparing, open, closing, or quarantined together. Admission beyond
192
+ this bound fails explicitly with `open_failed: too_many_sessions`; it never evicts another session or starts an OS
193
+ process as a fallback. This is a new externally visible bound for CLI shared mode, which previously admitted
194
+ unlimited logical sessions. It applies to new worker allocation, not attachments: a known canonical path or
195
+ original opening spelling joins its already-bound owner without allocating a worker, even at capacity. An
196
+ unknown path/alias still needs a preparation worker slot. In-process SDK registries using an injected runtime
197
+ factory retain their existing behavior.
194
198
  - **Empty-host exit**: when the registry holds zero sessions AND no client is connected, continuously for
195
199
  `SENPI_RPC_HOST_EMPTY_EXIT_MS` (default 15 minutes), the host exits through its clean shutdown path (flush, socket
196
200
  removal), for stdio and `--listen` hosts alike. A connected client counts as occupancy even with no session open,
@@ -200,14 +204,71 @@ occupancy bounds itself, independent of the supervisor and of client cooperation
200
204
  Values are positive integers; invalid values fall through to the defaults. These lifecycle windows run inside the host process,
201
205
  so they hold even for embedders and hand-started hosts that have no supervisor.
202
206
 
207
+ ### Worker ownership and flow control
208
+
209
+ The main host owns transport, attachments and canonical reservations. Workers canonicalize caller-supplied paths;
210
+ main does not synchronously traverse those paths. An open prepares a path, obtains the main host's exclusive grant,
211
+ and only then constructs its session writer and runtime. A conflicting alias attaches to an open owner or fails
212
+ explicitly before opening another writer.
213
+
214
+ SessionManager writes, switches, forks, new sessions and imports obtain the same grant before writer creation or
215
+ append-side normalization. Acquired paths are conservatively retained for that worker's entire lifetime, including
216
+ superseded paths after a switch. Each worker may reserve at most 64 paths; an exhausted reservation budget fails
217
+ explicitly. Close or an opening deadline requests worker termination, but does not release reservations or worker
218
+ capacity until the actual exit event. A syscall that cannot yet be interrupted can therefore keep an entry
219
+ internally quarantined after the routing handle has closed. `list_sessions` continues to publish `closing`, not a
220
+ new status: existing clients must not mistake a quarantined worker for a live reattach target. Retry the path only
221
+ after that entry disappears.
222
+
223
+ Each worker accepts at most 64 ordinary pending requests totaling 16 MiB, plus four reserved interrupt/UI-response
224
+ slots totaling 1 MiB. Prepare, commit and bind share one 30-second opening budget starting with worker allocation;
225
+ they do not each reset that budget. Interrupt requests have a five-second deadline. Ordinary commands remain bounded
226
+ by count and bytes without imposing a new timeout on long-running commands. The desktop's 60-second open/readmission
227
+ window is a separate client-side wait: the host normally reports its earlier 30-second failure within that window,
228
+ but a slow transport can delay delivery. Neither timeout proves worker exit or permits concurrent reopening.
229
+ Display updates coalesce to one pending update and one latest value; UI cancellation and close have separate control
230
+ messages. IPC output and snapshots are limited to 16 MiB per record, with one acknowledged record at a time. Credit
231
+ returns after the session's destinations consume their output, not merely on IPC receipt. A five-second credit
232
+ failure closes that session visibly (`session_error` followed by `session_closed`), rather than retaining an
233
+ unbounded queue. Socket queues retain their existing independent overflow/disconnect behavior. The default stdio
234
+ queue is bounded at 64 MiB or 4096 records, with reserved terminal-failure records and one control-overflow notice.
235
+ Close admission counts both queued output and pending close replies (including their serialized bytes) before
236
+ releasing an attachment or waiting for teardown. An admitted first closer reserves its lifecycle and terminal reply;
237
+ admitted joiners follow those records in FIFO order. Excess closes are not admitted and do not release ownership.
238
+ One bounded `overflow` record with `command: "close_session"` and
239
+ `error: "rpc_close_output_overflow, resync required"` reports the saturation episode instead of retaining a reply
240
+ or promise for each rejected request. Over sockets, this notice goes only to the requester whose close was rejected;
241
+ each connection may have at most one outstanding notice, released when its sink consumes it. After socket-only drain,
242
+ a subsequent saturation episode on the same connection can report a new notice without reconnecting. A healthy peer is not
243
+ told to resynchronize, and a newly affected or reconnected peer receives its own notice. Stdio retains one notice per
244
+ episode. Clients receiving a notice must stop issuing closes, drain output, and resynchronize unacknowledged requests; the notice is not a successful close acknowledgment. Admission resumes as capacity becomes available.
245
+ Canonical reservations and worker capacity remain held until native exit, including after close-output overflow.
246
+
247
+ The classic handler, extension UI bridge, renderer callbacks and provider scope run inside the owning worker; only
248
+ plain data crosses IPC. Inline `main()` extension factories cannot be cloned and are rejected in shared mode: use
249
+ file-backed extensions. Classic single-session RPC remains in-process. Standalone Bun builds must embed
250
+ `src/modes/rpc/session-worker.ts` as an explicit entrypoint; Node bundles must ship `session-worker.js` beside the
251
+ chunk containing its worker client. Third-party/rebranded Bun wrappers must pass the published
252
+ `dist/modes/rpc/session-worker.js` as an additional compile entry, set an explicit `--root`, and set
253
+ `--define=SENPI_RPC_SESSION_WORKER_ENTRY='"./<worker-path-relative-to-root>"'`. The define is a build-time
254
+ contract, not an environment variable. Its path must match Bun's embedded entry name, not the source machine's
255
+ absolute path or the runtime working directory. The client resolves it against its compiled `import.meta.url`
256
+ before constructing the Worker: Bun 1.4.0 resolves a bare relative Worker string against the real cwd instead
257
+ of the embedded filesystem. Verify the relocated wrapper on the wrapper's supported Bun version and platform
258
+ by opening two shared sessions;
259
+ a standalone Senpi smoke does not verify a wrapper's different compile graph.
260
+
261
+ Workers isolate JavaScript event loops, not OS processes: they do not promise syscall cancellation, process-fatal OOM
262
+ containment, or containment of arbitrary native code. They are not an extension sandbox.
263
+
203
264
  ### D1 normative table (multi-session mode)
204
265
 
205
266
  | Command | Params | Success data | Notes |
206
267
  | --- | --- | --- | --- |
207
268
  | `get_protocol_info` | - | `{ protocolVersion: 1, serverVersion: string, capabilities: string[], mode: "classic"\|"multi" }` | Answered in BOTH modes; side-effect-free; the capability probe. Multi-session hosts include `multi_session` plus the negotiated launch capabilities. |
208
269
  | `open_session` | `sessionPath?`, `cwd?`, `provider?`, `modelId?`, `thinkingLevel?`, `permissionPreset?` (all optional; paths MUST be absolute) | `{ sessionId, state: RpcSessionState, attached?: true }` | `sessionPath` = today's `--session` semantics (open-if-exists else create persisting there, `session-manager.ts:926-940`); `provider`/`modelId` applied only on create (resume restores the session's model — mirrors `SenpiSessionRuntime.ts:198-200`); params form the immutable launch profile (D8). When the path is already held by a fully-open session, the open ATTACHES to it: same routing handle, `attached: true`, one more attachment counted; the runtime is torn down only when the last attachment closes. Idle sessions past the eviction window are closed by the host itself. |
209
- | `close_session` | `sessionId` | `{}` | Aborts active work, awaits agent idle + settled persistence for up to the host grace window (default 10s), then force-releases the session; its response is the LAST record tagged with that handle for the first closer — no events after (test-pinned). A concurrent close joins the same teardown and receives its own successful response. |
210
- | `list_sessions` | - | `{ sessions: [{ sessionId, durableSessionId, sessionPath, cwd, name, status }] }` | Includes `opening`/`closing` entries with their status. |
270
+ | `close_session` | `sessionId` | `{}` | Aborts active work, awaits agent idle + settled persistence for up to the host grace window (default 10s), then quarantines any worker that has not exited without releasing its path reservation; its response is the LAST record tagged with that handle for the first closer — no events after (test-pinned). An admitted concurrent close joins the same teardown and receives its own successful response; output saturation rejects admission with the bounded close-overflow/resync notice described above. |
271
+ | `list_sessions` | - | `{ sessions: [{ sessionId, durableSessionId, sessionPath, cwd, name, status }] }` | Includes `opening`/`closing` entries. Internally quarantined workers remain externally `closing` until exit. |
211
272
  | every existing command | + `sessionId` (REQUIRED in multi mode) | unchanged | Routed to that session. |
212
273
 
213
274
  ### Identities (D6)
@@ -220,7 +281,7 @@ In the response `error` field, machine-matchable:
220
281
 
221
282
  - `unknown_session`
222
283
  - `session_closing`
223
- - `session_path_in_use` (path held by a session still `opening` or already `closing`; a fully-open session is attached instead)
284
+ - `session_path_in_use` (path held by an opening, closing, quarantined, or superseded owner; a fully-open current owner is attached instead)
224
285
  - `missing_session_id` (session-scoped command without `sessionId` in multi mode)
225
286
  - `multi_session_disabled` (`open_session` in classic mode)
226
287
  - `invalid_path` (relative `sessionPath`/`cwd`)
@@ -237,7 +298,7 @@ Strict FIFO per session; one total stdout order; cross-session order unspecified
237
298
 
238
299
  ### Duplicate/idempotency
239
300
 
240
- Duplicate `open_session` while a path reservation is held by a fully-open session → ATTACH (`attached: true`, same handle); while held by an `opening`/`closing` entry → `session_path_in_use`. `close_session` releases one attachment; the runtime is disposed only when the last attachment closes. A close for an entry already `closing` joins its in-flight teardown. `close_session` on unknown/already-closed → `unknown_session` error. The grace window is configurable by the host through `SENPI_RPC_CLOSE_GRACE_MS`. Request `id`s are client-owned; the server echoes them without dedup.
301
+ Duplicate `open_session` while a path reservation is held by a fully-open session → ATTACH (`attached: true`, same handle); while held by an `opening`/`closing` entry (including internal quarantine) → `session_path_in_use`. `close_session` releases one attachment; the runtime is disposed only when the last attachment closes. A close for an entry already `closing` joins its in-flight teardown. `close_session` on unknown/already-closed → `unknown_session` error. The grace window is configurable by the host through `SENPI_RPC_CLOSE_GRACE_MS`. Request `id`s are client-owned; the server echoes them without dedup.
241
302
 
242
303
  ## Protocol Overview
243
304
 
package/docs/settings.md CHANGED
@@ -191,6 +191,7 @@ Set `PI_SKIP_VERSION_CHECK=1` to disable the senpi version update check. Use `--
191
191
  | `compaction.enabled` | boolean | `true` | Enable auto-compaction |
192
192
  | `compaction.reserveTokens` | number | `16384` | Tokens reserved for LLM response |
193
193
  | `compaction.keepRecentTokens` | number | `20000` | Recent tokens to keep (not summarized) |
194
+ | `compaction.summarizationMaxDurationMs` | number | adaptive | Wall-clock budget for one summarization attempt: larger of 120s and 2ms per estimated input token, capped at 30min. Set a positive value to override |
194
195
 
195
196
  ```json
196
197
  {
@@ -364,6 +365,7 @@ unknown (e.g. Google models) or caching is off, no budget applies and timeout be
364
365
  |---------|------|---------|-------------|
365
366
  | `promptCache.cacheAwareTimeouts` | boolean | `true` | Cap foreground tool waits at the model's prompt-cache TTL minus the safety buffer; `false` restores the fixed legacy ceilings |
366
367
  | `promptCache.safetyBufferSeconds` | number | `30` | Headroom subtracted from the cache TTL (a 5m TTL yields a 270s ceiling). If it consumes the whole TTL, no budget applies |
368
+ | `promptCache.goalBackstopMaxSeconds` | number | `270` | Longest a goal parked on live wake sources (terminal monitors, background sessions, detached `eval` cells, task children) waits before it re-checks with a full turn, clamped to 1..3600. The default lands inside the 5m cache TTL; raise it toward `3570` to trade re-check frequency for cost on a wait you trust |
367
369
 
368
370
  A foreground `bash` command still running at the budget is handed to a live background session
369
371
  instead of being killed; its explicit `timeout` remains the kill deadline. See
package/docs/skills.md CHANGED
@@ -270,7 +270,7 @@ cd /path/to/brave-search && bun install
270
270
 
271
271
  Senpi contributes built-in skills conditionally based on available credentials and capabilities.
272
272
 
273
- **gpt-image-gen** is contributed by the `imagegen` builtin extension when image-generation credentials exist (a stored OpenAI key, `OPENAI_API_KEY`, or a configured OpenAI-compatible gateway). It provides a prompt-crafting guide for `gpt-image-2`, covering detail-maxxing techniques, verbatim quoted render text, revised-prompt feedback loops, and routing guidance for the native server tool vs. the client `generate_image` tool. The skill is absent from `<available_skills>` when no credentials are configured.
273
+ **gpt-image-gen** is contributed by the `imagegen` builtin extension when image-generation credentials exist (a stored OpenAI key, `OPENAI_API_KEY`, or a configured OpenAI-compatible gateway). It provides a prompt-crafting guide for GPT Image 2.5, covering detail-maxxing techniques, verbatim quoted render text, revised-prompt feedback loops, and routing guidance for the native server tool vs. the client `generate_image` tool. For `generate_image`, `model` selects `gpt-image-2.5-sunburst` (default, precise edits), `gpt-image-2.5-flare` (speed), or legacy `gpt-image-2`; `quality` accepts `auto`, `low`, `medium`, `high`, `xhigh`, or `max` (the last two require 2.5); `size` accepts `auto`, presets, or validated custom dimensions. `reference_image_paths` supplies 1-5 local PNG/JPEG/WEBP files for editing or references. The skill is absent from `<available_skills>` when no credentials are configured.
274
274
 
275
275
  Skill visibility refreshes at startup and on `/reload`. Mid-session credential changes (login, environment variable updates) take effect on the tool and injector immediately but are reflected in the skill list only after the next reload.
276
276
 
@@ -12,6 +12,61 @@
12
12
 
13
13
  ### Removed
14
14
 
15
+ ## [2026.9.9-2] - 2026-09-09
16
+
17
+ ### Breaking Changes
18
+
19
+ ### Added
20
+
21
+ ### Changed
22
+
23
+ ### Fixed
24
+
25
+ ### Removed
26
+
27
+ ## [2026.9.9] - 2026-09-09
28
+
29
+ ### Breaking Changes
30
+
31
+ ### Added
32
+
33
+ ### Changed
34
+
35
+ ### Fixed
36
+
37
+ ### Removed
38
+
39
+ ## [2026.9.8] - 2026-09-08
40
+
41
+ ### Breaking Changes
42
+
43
+ ### Added
44
+
45
+ ### Changed
46
+
47
+ - The eval tool description teaches cell mechanics only (batch independent calls, real code, failures kept verbatim, truncated output re-read) and drops the "default execution surface / never a chain / distilled facts only" wording; routing lives in the model's prompt preset.
48
+
49
+ ### Fixed
50
+
51
+ ### Removed
52
+
53
+ ## [2026.9.7-2] - 2026-09-07
54
+
55
+ ### Breaking Changes
56
+
57
+ ### Added
58
+
59
+ ### Changed
60
+
61
+ ### Fixed
62
+
63
+ - The JS kernel's shell capture now pins the worker's environment view for `Bun.spawnSync` as well as `Bun.spawn`, so a cell calling it without an explicit `env` sees the session's `PI_*` values instead of the inherited OS environ.
64
+ - Eval kernels and every child they spawn now see the active session's `PI_*` environment (`PI_SESSION_ID`, `PI_SESSION_FILE`, `PI_PROVIDER`, `PI_MODEL`, `PI_REASONING_LEVEL`) exactly as bash-tool children do: inherited `PI_*` values are dropped before the session values are applied, so subprocesses such as `omo-agent-toolkit ulw-loop` resolve the same session as the `bash` tool instead of a cwd-global one.
65
+ - JavaScript eval cells no longer lose their completion value when a nested function, callback, or try/catch helper contains `return`: the cell wrapper now skips last-expression capture only for a genuine top-level `return`, and a property named `return` no longer primes the statement scanner as the keyword (#1439).
66
+ - Eval output truncation notices now name the real cause: a width-clamped line reports `N line(s) clamped to M columns (… dropped)`, a byte-capped tail reports the actual cap, and a notice never presents the output's own size as a limit.
67
+
68
+ ### Removed
69
+
15
70
  ## [2026.9.7] - 2026-09-07
16
71
 
17
72
  ### Breaking Changes
@@ -54,6 +54,19 @@ task-tool names are known.
54
54
  A missing optional interpreter removes that language from the session's `eval`
55
55
  schema; it is not an installation failure.
56
56
 
57
+ ### Session environment
58
+
59
+ Every kernel starts with the active session's `PI_*` environment — `PI_SESSION_ID`,
60
+ `PI_SESSION_FILE` (when the session is persistent), `PI_PROVIDER`, `PI_MODEL`, and
61
+ `PI_REASONING_LEVEL` (when set) — resolved at session start, mirroring the bash tool's
62
+ session environment contract. The values are visible to `env()`/`process.env`/`os.environ`
63
+ inside cells and are inherited by every child process a cell spawns
64
+ (`Bun.$`, `Bun.spawn`, `child_process`, `subprocess`, ...). Inherited `PI_*` values from
65
+ the launching environment are dropped first, so a child spawned from a cell sees exactly
66
+ what a child spawned from the bash tool sees. The values snapshot at kernel start, so a
67
+ mid-session model switch updates the bash tool's next command but not already-running
68
+ kernels; a new session starts fresh kernels with fresh values.
69
+
57
70
  ## Settings
58
71
 
59
72
  Configuration is loaded in this order:
@@ -116,7 +129,7 @@ options object and asynchronous helpers are `await`-able.
116
129
  | `print(value, ...)` | Emits text output. |
117
130
  | `read(path, offset?, limit?)` | Reads text with 1-indexed line slicing. `local://` paths resolve under the session artifact root. |
118
131
  | `write(path, content)` | Creates parent directories and writes text. `local://` paths persist in the session artifact root. |
119
- | `env(key?, value?)` | Reads all kernel environment values, one value, or sets one value. |
132
+ | `env(key?, value?)` | Reads all kernel environment values, one value, or sets one value. Includes the session's `PI_*` values (see [Session environment](#session-environment)). |
120
133
  | `tool.<name>(args)` | Invokes an active Senpi tool through the normal `pi.executeTool` pipeline and returns `{ text, images?, details?, hasError? }` in every kernel; image blocks arrive as `images[i] = { mimeType, dataBase64 }`. |
121
134
  | `tool_schema(name?)` | Returns a tool's parameter schema without calling it; omit `name` to list tool names. |
122
135
  | `completion(prompt, model?, system?, schema?)` | Requests a one-shot host completion; `schema` asks the host to parse structured output. |
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code-yeongyu/senpi-codemode",
3
- "version": "2026.9.7",
3
+ "version": "2026.9.9-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.9.7",
34
+ "@earendil-works/pi-ai": "npm:@code-yeongyu/senpi-ai@2026.9.9-2",
35
35
  "typebox": "1.3.18"
36
36
  },
37
37
  "peerDependencies": {
38
- "@code-yeongyu/senpi": "2026.9.7"
38
+ "@code-yeongyu/senpi": "2026.9.9-2"
39
39
  },
40
40
  "devDependencies": {
41
- "@code-yeongyu/senpi": "2026.9.7"
41
+ "@code-yeongyu/senpi": "2026.9.9-2"
42
42
  },
43
43
  "keywords": [
44
44
  "senpi",
@@ -26,6 +26,7 @@ const hostToKernelMessageSchema = Type.Union([
26
26
  type: Type.Literal("init"),
27
27
  sessionId: Type.String({ minLength: 1 }),
28
28
  connection: connectionConfigSchema,
29
+ sessionEnv: Type.Optional(Type.Record(Type.String(), Type.String())),
29
30
  }),
30
31
  Type.Object({
31
32
  type: Type.Literal("run"),
@@ -13,6 +13,7 @@ import {
13
13
  getInterpreterAvailability,
14
14
  type InterpreterAvailability,
15
15
  } from "../interpreters/detect.ts";
16
+ import { sessionEnvironmentFrom } from "../kernels/session-env.ts";
16
17
  import { resolveSessionArtifactsDir } from "../output/streaming-output.ts";
17
18
  import type { EnabledEvalLanguages, EvalLanguage, EvalRuntimes } from "../tool/types.ts";
18
19
  import { jsRuntimeInfo, runtimesFromAvailability } from "./runtime-info.ts";
@@ -66,11 +67,13 @@ export async function createRuntime(
66
67
  const executeTool = createExecuteTool(pi, activeTools);
67
68
  const create = options.createSessionManager ?? createCodemodeSessionManager;
68
69
  const sessionId = sessionIdFrom(event);
70
+ const sessionEnv = sessionEnvironmentFrom(ctx);
69
71
  const configuredPoolWidth = settings.parallelPoolWidth;
70
72
  const parallelPoolWidth = Number.isFinite(configuredPoolWidth) ? Math.max(1, Math.trunc(configuredPoolWidth)) : 1;
71
73
  const manager = await create({
72
74
  sessionId,
73
75
  cwd: ctx.cwd,
76
+ sessionEnv,
74
77
  settings,
75
78
  availability,
76
79
  artifactsDir: artifacts.dir,
@@ -11,6 +11,7 @@ import { JuliaKernel } from "../kernels/jl/kernel.ts";
11
11
  import { JavaScriptKernel } from "../kernels/js/context-manager.ts";
12
12
  import { PythonKernel } from "../kernels/py/kernel.ts";
13
13
  import { RubyKernel } from "../kernels/rb/kernel.ts";
14
+ import type { SessionEnvironment } from "../kernels/session-env.ts";
14
15
  import { marshalToolResult } from "../tool/image.ts";
15
16
  import type { EvalKernel, EvalKernelManager, EvalLanguage, ExecuteTool } from "../tool/types.ts";
16
17
 
@@ -40,6 +41,8 @@ export interface CreateCodemodeSessionManagerOptions {
40
41
  readonly localRoots?: Readonly<Record<string, string>>;
41
42
  /** Session-adjacent directory used for persisted eval artifacts. */
42
43
  readonly artifactsDir?: string;
44
+ /** Per-session PI_* values exposed to every kernel and the children it spawns. */
45
+ readonly sessionEnv?: SessionEnvironment;
43
46
  readonly executeTool: ExecuteTool;
44
47
  readonly listTools?: () => readonly EvalSchemaToolInfo[];
45
48
  readonly complete: (request: CompletionRequest, ctx: ExtensionContext) => Promise<CompletionResult>;
@@ -212,6 +215,7 @@ class DefaultCodemodeSessionManager implements CodemodeSessionManager {
212
215
  cwd: this.#options.cwd,
213
216
  parallelPoolWidth,
214
217
  onMessage,
218
+ ...(this.#options.sessionEnv ? { sessionEnv: this.#options.sessionEnv } : {}),
215
219
  ...(localRoots ? { localRoots: { ...localRoots } } : {}),
216
220
  ...(this.#options.artifactsDir ? { artifactsDir: this.#options.artifactsDir } : {}),
217
221
  });
@@ -230,6 +234,7 @@ class DefaultCodemodeSessionManager implements CodemodeSessionManager {
230
234
  interpreterPath: detected.path,
231
235
  sessionId: this.#options.sessionId,
232
236
  cwd: this.#options.cwd,
237
+ ...(this.#options.sessionEnv ? { sessionEnv: this.#options.sessionEnv } : {}),
233
238
  connection,
234
239
  onMessage,
235
240
  });
@@ -239,6 +244,7 @@ class DefaultCodemodeSessionManager implements CodemodeSessionManager {
239
244
  command: detected.path,
240
245
  sessionId: this.#options.sessionId,
241
246
  cwd: this.#options.cwd,
247
+ ...(this.#options.sessionEnv ? { sessionEnv: this.#options.sessionEnv } : {}),
242
248
  connection,
243
249
  onMessage,
244
250
  });
@@ -247,6 +253,7 @@ class DefaultCodemodeSessionManager implements CodemodeSessionManager {
247
253
  command: detected.path,
248
254
  sessionId: this.#options.sessionId,
249
255
  cwd: this.#options.cwd,
256
+ ...(this.#options.sessionEnv ? { sessionEnv: this.#options.sessionEnv } : {}),
250
257
  connection,
251
258
  onMessage,
252
259
  });
@@ -15,6 +15,7 @@ runner/prelude assets).
15
15
  | Ruby kernel | `rb/kernel.ts` + `rb/prelude.rb`, `rb/runner.rb` |
16
16
  | Julia kernel | `jl/kernel.ts` + `jl/prelude.jl`, `jl/runner.jl` |
17
17
  | Shared subprocess layer | `shared/subprocess-kernel.ts`, `subprocess-{contract,process,queue,run}.ts`, `runtime-asset.ts` |
18
+ | Session environment | `session-env.ts` (PI_* contract shared by all kernels; mirrors the core bash tool) |
18
19
 
19
20
  ## CONVENTIONS
20
21
 
@@ -29,6 +30,12 @@ runner/prelude assets).
29
30
  framed subprocesses through `shared/`.
30
31
  - Subprocess retirement/restart, worker recovery, timeout, and interrupt
31
32
  semantics live here, never in the tool layer.
33
+ - Every kernel exposes the active session's `PI_*` environment (`session-env.ts`):
34
+ inherited values are deleted before the session's values are applied, so any
35
+ child spawned from a cell sees the same session environment a bash-tool child
36
+ sees. The JS worker applies it at init (`worker-core.js`; shell capture pins
37
+ the env view under Bun because `delete process.env.X` does not unsetenv),
38
+ and py/rb/jl spawn with it merged into the interpreter environment.
32
39
 
33
40
  ## ANTI-PATTERNS
34
41