@code-yeongyu/senpi 2026.9.24-3 → 2026.9.25

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 (256) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/bundle/chunks/{app-server-command-OTRHYRIB.js → app-server-command-RB6QUPRI.js} +1 -1
  3. package/dist/bundle/chunks/{chunk-UM43CBL4.js → chunk-JJ3NJZBD.js} +118 -111
  4. package/dist/bundle/chunks/chunk-SGYEOIOJ.js +8 -0
  5. package/dist/bundle/chunks/chunk-YS5YEX4S.js +2 -0
  6. package/dist/bundle/chunks/{cli-main-TX6I4X4F.js → cli-main-KO53KYDN.js} +1 -1
  7. package/dist/bundle/chunks/{interactive-mode-UI5Q6FGY.js → interactive-mode-ABDNLJSI.js} +1 -1
  8. package/dist/bundle/chunks/{multi-session-host-D6HMI3RQ.js → multi-session-host-JV3MNWXZ.js} +1 -1
  9. package/dist/bundle/chunks/{package-manager-cli-3UWH3ZZS.js → package-manager-cli-ZYYAVCXU.js} +1 -1
  10. package/dist/bundle/chunks/{rpc-mode-LXIZHJSJ.js → rpc-mode-Q2OUJURB.js} +1 -1
  11. package/dist/bundle/chunks/runtime-session-XBT646O5.js +2 -0
  12. package/dist/bundle/chunks/session-worker.js +184 -177
  13. package/dist/bundle/cli.js +1 -1
  14. package/dist/bundle/index.js +1 -1
  15. package/dist/bundle/rpc-entry.js +1 -1
  16. package/dist/core/agent-session.d.ts.map +1 -1
  17. package/dist/core/agent-session.js +1 -1
  18. package/dist/core/agent-session.js.map +1 -1
  19. package/dist/core/extensions/builtin/cursor-cli-oauth/stream.d.ts +7 -0
  20. package/dist/core/extensions/builtin/cursor-cli-oauth/stream.d.ts.map +1 -1
  21. package/dist/core/extensions/builtin/cursor-cli-oauth/stream.js +23 -4
  22. package/dist/core/extensions/builtin/cursor-cli-oauth/stream.js.map +1 -1
  23. package/dist/core/extensions/builtin/terminal/durable-command.d.ts +11 -16
  24. package/dist/core/extensions/builtin/terminal/durable-command.d.ts.map +1 -1
  25. package/dist/core/extensions/builtin/terminal/durable-command.js +97 -43
  26. package/dist/core/extensions/builtin/terminal/durable-command.js.map +1 -1
  27. package/dist/core/extensions/builtin/terminal/durable-file.d.ts.map +1 -1
  28. package/dist/core/extensions/builtin/terminal/durable-file.js +11 -4
  29. package/dist/core/extensions/builtin/terminal/durable-file.js.map +1 -1
  30. package/dist/core/extensions/builtin/terminal/extension-state.d.ts +26 -0
  31. package/dist/core/extensions/builtin/terminal/extension-state.d.ts.map +1 -0
  32. package/dist/core/extensions/builtin/terminal/extension-state.js +151 -0
  33. package/dist/core/extensions/builtin/terminal/extension-state.js.map +1 -0
  34. package/dist/core/extensions/builtin/terminal/extension.d.ts.map +1 -1
  35. package/dist/core/extensions/builtin/terminal/extension.js +32 -308
  36. package/dist/core/extensions/builtin/terminal/extension.js.map +1 -1
  37. package/dist/core/extensions/builtin/terminal/lease-file.d.ts +52 -0
  38. package/dist/core/extensions/builtin/terminal/lease-file.d.ts.map +1 -0
  39. package/dist/core/extensions/builtin/terminal/lease-file.js +205 -0
  40. package/dist/core/extensions/builtin/terminal/lease-file.js.map +1 -0
  41. package/dist/core/extensions/builtin/terminal/lease-keeper.d.ts +33 -0
  42. package/dist/core/extensions/builtin/terminal/lease-keeper.d.ts.map +1 -0
  43. package/dist/core/extensions/builtin/terminal/lease-keeper.js +110 -0
  44. package/dist/core/extensions/builtin/terminal/lease-keeper.js.map +1 -0
  45. package/dist/core/extensions/builtin/terminal/manager.d.ts +1 -0
  46. package/dist/core/extensions/builtin/terminal/manager.d.ts.map +1 -1
  47. package/dist/core/extensions/builtin/terminal/manager.js +6 -0
  48. package/dist/core/extensions/builtin/terminal/manager.js.map +1 -1
  49. package/dist/core/extensions/builtin/terminal/manifest-lease.d.ts +48 -4
  50. package/dist/core/extensions/builtin/terminal/manifest-lease.d.ts.map +1 -1
  51. package/dist/core/extensions/builtin/terminal/manifest-lease.js +141 -59
  52. package/dist/core/extensions/builtin/terminal/manifest-lease.js.map +1 -1
  53. package/dist/core/extensions/builtin/terminal/monitor-registry.d.ts +2 -0
  54. package/dist/core/extensions/builtin/terminal/monitor-registry.d.ts.map +1 -1
  55. package/dist/core/extensions/builtin/terminal/monitor-registry.js +15 -10
  56. package/dist/core/extensions/builtin/terminal/monitor-registry.js.map +1 -1
  57. package/dist/core/extensions/builtin/terminal/monitor-state-dir.d.ts +11 -0
  58. package/dist/core/extensions/builtin/terminal/monitor-state-dir.d.ts.map +1 -0
  59. package/dist/core/extensions/builtin/terminal/monitor-state-dir.js +28 -0
  60. package/dist/core/extensions/builtin/terminal/monitor-state-dir.js.map +1 -0
  61. package/dist/core/extensions/builtin/terminal/orphan-reaper.d.ts +41 -0
  62. package/dist/core/extensions/builtin/terminal/orphan-reaper.d.ts.map +1 -0
  63. package/dist/core/extensions/builtin/terminal/orphan-reaper.js +131 -0
  64. package/dist/core/extensions/builtin/terminal/orphan-reaper.js.map +1 -0
  65. package/dist/core/extensions/builtin/terminal/process-identity.d.ts +21 -0
  66. package/dist/core/extensions/builtin/terminal/process-identity.d.ts.map +1 -0
  67. package/dist/core/extensions/builtin/terminal/process-identity.js +34 -0
  68. package/dist/core/extensions/builtin/terminal/process-identity.js.map +1 -0
  69. package/dist/core/extensions/builtin/terminal/process-start-probe.d.ts +6 -0
  70. package/dist/core/extensions/builtin/terminal/process-start-probe.d.ts.map +1 -0
  71. package/dist/core/extensions/builtin/terminal/process-start-probe.js +60 -0
  72. package/dist/core/extensions/builtin/terminal/process-start-probe.js.map +1 -0
  73. package/dist/core/extensions/builtin/terminal/prompt.d.ts.map +1 -1
  74. package/dist/core/extensions/builtin/terminal/prompt.js +8 -4
  75. package/dist/core/extensions/builtin/terminal/prompt.js.map +1 -1
  76. package/dist/core/extensions/builtin/terminal/restore-digest.d.ts +54 -0
  77. package/dist/core/extensions/builtin/terminal/restore-digest.d.ts.map +1 -0
  78. package/dist/core/extensions/builtin/terminal/restore-digest.js +133 -0
  79. package/dist/core/extensions/builtin/terminal/restore-digest.js.map +1 -0
  80. package/dist/core/extensions/builtin/terminal/restore-session.d.ts +56 -0
  81. package/dist/core/extensions/builtin/terminal/restore-session.d.ts.map +1 -0
  82. package/dist/core/extensions/builtin/terminal/restore-session.js +238 -0
  83. package/dist/core/extensions/builtin/terminal/restore-session.js.map +1 -0
  84. package/dist/core/extensions/builtin/terminal/restore.d.ts +52 -19
  85. package/dist/core/extensions/builtin/terminal/restore.d.ts.map +1 -1
  86. package/dist/core/extensions/builtin/terminal/restore.js +63 -138
  87. package/dist/core/extensions/builtin/terminal/restore.js.map +1 -1
  88. package/dist/core/extensions/builtin/terminal/runtime-session.d.ts +5 -0
  89. package/dist/core/extensions/builtin/terminal/runtime-session.d.ts.map +1 -1
  90. package/dist/core/extensions/builtin/terminal/runtime-session.js +17 -0
  91. package/dist/core/extensions/builtin/terminal/runtime-session.js.map +1 -1
  92. package/dist/core/extensions/builtin/terminal/session-activity.d.ts +8 -0
  93. package/dist/core/extensions/builtin/terminal/session-activity.d.ts.map +1 -0
  94. package/dist/core/extensions/builtin/terminal/session-activity.js +41 -0
  95. package/dist/core/extensions/builtin/terminal/session-activity.js.map +1 -0
  96. package/dist/core/extensions/builtin/terminal/shared.d.ts +14 -0
  97. package/dist/core/extensions/builtin/terminal/shared.d.ts.map +1 -1
  98. package/dist/core/extensions/builtin/terminal/shared.js +14 -0
  99. package/dist/core/extensions/builtin/terminal/shared.js.map +1 -1
  100. package/dist/core/extensions/builtin/terminal/terminal-manifest-model.d.ts +8 -0
  101. package/dist/core/extensions/builtin/terminal/terminal-manifest-model.d.ts.map +1 -1
  102. package/dist/core/extensions/builtin/terminal/terminal-manifest-model.js.map +1 -1
  103. package/dist/core/extensions/builtin/terminal/terminal-manifest-parse.d.ts +15 -0
  104. package/dist/core/extensions/builtin/terminal/terminal-manifest-parse.d.ts.map +1 -0
  105. package/dist/core/extensions/builtin/terminal/terminal-manifest-parse.js +148 -0
  106. package/dist/core/extensions/builtin/terminal/terminal-manifest-parse.js.map +1 -0
  107. package/dist/core/extensions/builtin/terminal/terminal-manifest.d.ts +15 -2
  108. package/dist/core/extensions/builtin/terminal/terminal-manifest.d.ts.map +1 -1
  109. package/dist/core/extensions/builtin/terminal/terminal-manifest.js +62 -11
  110. package/dist/core/extensions/builtin/terminal/terminal-manifest.js.map +1 -1
  111. package/dist/core/extensions/builtin/terminal/terminal-state-gc.d.ts +17 -0
  112. package/dist/core/extensions/builtin/terminal/terminal-state-gc.d.ts.map +1 -0
  113. package/dist/core/extensions/builtin/terminal/terminal-state-gc.js +81 -0
  114. package/dist/core/extensions/builtin/terminal/terminal-state-gc.js.map +1 -0
  115. package/dist/core/extensions/builtin/terminal/tools/context.d.ts +5 -0
  116. package/dist/core/extensions/builtin/terminal/tools/context.d.ts.map +1 -1
  117. package/dist/core/extensions/builtin/terminal/tools/context.js.map +1 -1
  118. package/dist/core/extensions/builtin/terminal/tools/kill-bash.d.ts.map +1 -1
  119. package/dist/core/extensions/builtin/terminal/tools/kill-bash.js +16 -1
  120. package/dist/core/extensions/builtin/terminal/tools/kill-bash.js.map +1 -1
  121. package/dist/core/extensions/builtin/terminal/tools/monitor-manifest-binding.d.ts +27 -0
  122. package/dist/core/extensions/builtin/terminal/tools/monitor-manifest-binding.d.ts.map +1 -0
  123. package/dist/core/extensions/builtin/terminal/tools/monitor-manifest-binding.js +75 -0
  124. package/dist/core/extensions/builtin/terminal/tools/monitor-manifest-binding.js.map +1 -0
  125. package/dist/core/extensions/builtin/terminal/tools/monitor-schema.d.ts +35 -0
  126. package/dist/core/extensions/builtin/terminal/tools/monitor-schema.d.ts.map +1 -0
  127. package/dist/core/extensions/builtin/terminal/tools/monitor-schema.js +67 -0
  128. package/dist/core/extensions/builtin/terminal/tools/monitor-schema.js.map +1 -0
  129. package/dist/core/extensions/builtin/terminal/tools/monitor.d.ts +14 -35
  130. package/dist/core/extensions/builtin/terminal/tools/monitor.d.ts.map +1 -1
  131. package/dist/core/extensions/builtin/terminal/tools/monitor.js +30 -110
  132. package/dist/core/extensions/builtin/terminal/tools/monitor.js.map +1 -1
  133. package/dist/core/extensions/builtin/todotools/first-turn.d.ts +7 -6
  134. package/dist/core/extensions/builtin/todotools/first-turn.d.ts.map +1 -1
  135. package/dist/core/extensions/builtin/todotools/first-turn.js +8 -8
  136. package/dist/core/extensions/builtin/todotools/first-turn.js.map +1 -1
  137. package/dist/core/extensions/builtin/todotools/index.js +1 -1
  138. package/dist/core/extensions/builtin/todotools/index.js.map +1 -1
  139. package/dist/core/extensions/builtin/todotools/todo-format.js +1 -1
  140. package/dist/core/extensions/builtin/todotools/todo-format.js.map +1 -1
  141. package/dist/core/extensions/builtin/ttsr/detectors/repetitive-turns.d.ts.map +1 -1
  142. package/dist/core/extensions/builtin/ttsr/detectors/repetitive-turns.js +4 -0
  143. package/dist/core/extensions/builtin/ttsr/detectors/repetitive-turns.js.map +1 -1
  144. package/dist/core/extensions/builtin/ttsr/prompts.js +1 -1
  145. package/dist/core/extensions/builtin/ttsr/prompts.js.map +1 -1
  146. package/dist/core/extensions/runner.d.ts +1 -0
  147. package/dist/core/extensions/runner.d.ts.map +1 -1
  148. package/dist/core/extensions/runner.js +1 -0
  149. package/dist/core/extensions/runner.js.map +1 -1
  150. package/dist/core/extensions/types.d.ts +6 -0
  151. package/dist/core/extensions/types.d.ts.map +1 -1
  152. package/dist/core/extensions/types.js.map +1 -1
  153. package/docs/extensions.md +2 -0
  154. package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +12 -0
  155. package/node_modules/@code-yeongyu/senpi-codemode/package.json +4 -4
  156. package/node_modules/@code-yeongyu/senpi-desktop-engine/README.md +31 -0
  157. package/node_modules/@code-yeongyu/senpi-desktop-engine/dist/handshake.d.ts +38 -0
  158. package/node_modules/@code-yeongyu/senpi-desktop-engine/dist/handshake.d.ts.map +1 -0
  159. package/node_modules/@code-yeongyu/senpi-desktop-engine/dist/handshake.js +117 -0
  160. package/node_modules/@code-yeongyu/senpi-desktop-engine/dist/handshake.js.map +1 -0
  161. package/node_modules/@code-yeongyu/senpi-desktop-engine/dist/index.d.ts +3 -0
  162. package/node_modules/@code-yeongyu/senpi-desktop-engine/dist/index.d.ts.map +1 -0
  163. package/node_modules/@code-yeongyu/senpi-desktop-engine/dist/index.js +3 -0
  164. package/node_modules/@code-yeongyu/senpi-desktop-engine/dist/index.js.map +1 -0
  165. package/node_modules/@code-yeongyu/senpi-desktop-engine/dist/locator.d.ts +42 -0
  166. package/node_modules/@code-yeongyu/senpi-desktop-engine/dist/locator.d.ts.map +1 -0
  167. package/node_modules/@code-yeongyu/senpi-desktop-engine/dist/locator.js +79 -0
  168. package/node_modules/@code-yeongyu/senpi-desktop-engine/dist/locator.js.map +1 -0
  169. package/node_modules/@code-yeongyu/senpi-desktop-engine/native/check-prebuild-fresh.mjs +160 -0
  170. package/node_modules/@code-yeongyu/senpi-desktop-engine/native/index.d.ts +20 -0
  171. package/node_modules/@code-yeongyu/senpi-desktop-engine/native/index.js +23 -0
  172. package/node_modules/@code-yeongyu/senpi-desktop-engine/native/prebuilds/darwin-arm64/senpi-desktop-engine +0 -0
  173. package/node_modules/@code-yeongyu/senpi-desktop-engine/package.json +53 -0
  174. package/node_modules/@code-yeongyu/senpi-desktop-prelude/README.md +20 -0
  175. package/node_modules/@code-yeongyu/senpi-desktop-prelude/dist/index.d.ts +2 -0
  176. package/node_modules/@code-yeongyu/senpi-desktop-prelude/dist/index.d.ts.map +1 -0
  177. package/node_modules/@code-yeongyu/senpi-desktop-prelude/dist/index.js +2 -0
  178. package/node_modules/@code-yeongyu/senpi-desktop-prelude/dist/index.js.map +1 -0
  179. package/node_modules/@code-yeongyu/senpi-desktop-prelude/package.json +44 -0
  180. package/node_modules/@code-yeongyu/senpi-desktop-protocol/README.md +20 -0
  181. package/node_modules/@code-yeongyu/senpi-desktop-protocol/dist/audit.d.ts +38 -0
  182. package/node_modules/@code-yeongyu/senpi-desktop-protocol/dist/audit.d.ts.map +1 -0
  183. package/node_modules/@code-yeongyu/senpi-desktop-protocol/dist/audit.js +2 -0
  184. package/node_modules/@code-yeongyu/senpi-desktop-protocol/dist/audit.js.map +1 -0
  185. package/node_modules/@code-yeongyu/senpi-desktop-protocol/dist/call.d.ts +28 -0
  186. package/node_modules/@code-yeongyu/senpi-desktop-protocol/dist/call.d.ts.map +1 -0
  187. package/node_modules/@code-yeongyu/senpi-desktop-protocol/dist/call.js +102 -0
  188. package/node_modules/@code-yeongyu/senpi-desktop-protocol/dist/call.js.map +1 -0
  189. package/node_modules/@code-yeongyu/senpi-desktop-protocol/dist/engine-schema.generated.d.ts +14 -0
  190. package/node_modules/@code-yeongyu/senpi-desktop-protocol/dist/engine-schema.generated.d.ts.map +1 -0
  191. package/node_modules/@code-yeongyu/senpi-desktop-protocol/dist/engine-schema.generated.js +71 -0
  192. package/node_modules/@code-yeongyu/senpi-desktop-protocol/dist/engine-schema.generated.js.map +1 -0
  193. package/node_modules/@code-yeongyu/senpi-desktop-protocol/dist/index.d.ts +7 -0
  194. package/node_modules/@code-yeongyu/senpi-desktop-protocol/dist/index.d.ts.map +1 -0
  195. package/node_modules/@code-yeongyu/senpi-desktop-protocol/dist/index.js +4 -0
  196. package/node_modules/@code-yeongyu/senpi-desktop-protocol/dist/index.js.map +1 -0
  197. package/node_modules/@code-yeongyu/senpi-desktop-protocol/dist/json-rpc.d.ts +66 -0
  198. package/node_modules/@code-yeongyu/senpi-desktop-protocol/dist/json-rpc.d.ts.map +1 -0
  199. package/node_modules/@code-yeongyu/senpi-desktop-protocol/dist/json-rpc.js +8 -0
  200. package/node_modules/@code-yeongyu/senpi-desktop-protocol/dist/json-rpc.js.map +1 -0
  201. package/node_modules/@code-yeongyu/senpi-desktop-protocol/dist/session.d.ts +44 -0
  202. package/node_modules/@code-yeongyu/senpi-desktop-protocol/dist/session.d.ts.map +1 -0
  203. package/node_modules/@code-yeongyu/senpi-desktop-protocol/dist/session.js +2 -0
  204. package/node_modules/@code-yeongyu/senpi-desktop-protocol/dist/session.js.map +1 -0
  205. package/node_modules/@code-yeongyu/senpi-desktop-protocol/dist/wire.d.ts +59 -0
  206. package/node_modules/@code-yeongyu/senpi-desktop-protocol/dist/wire.d.ts.map +1 -0
  207. package/node_modules/@code-yeongyu/senpi-desktop-protocol/dist/wire.js +2 -0
  208. package/node_modules/@code-yeongyu/senpi-desktop-protocol/dist/wire.js.map +1 -0
  209. package/node_modules/@code-yeongyu/senpi-desktop-protocol/package.json +45 -0
  210. package/node_modules/@code-yeongyu/senpi-desktop-service/README.md +27 -0
  211. package/node_modules/@code-yeongyu/senpi-desktop-service/dist/index.d.ts +2 -0
  212. package/node_modules/@code-yeongyu/senpi-desktop-service/dist/index.d.ts.map +1 -0
  213. package/node_modules/@code-yeongyu/senpi-desktop-service/dist/index.js +2 -0
  214. package/node_modules/@code-yeongyu/senpi-desktop-service/dist/index.js.map +1 -0
  215. package/node_modules/@code-yeongyu/senpi-desktop-service/package.json +44 -0
  216. package/node_modules/@code-yeongyu/senpi-desktop-tool/README.md +20 -0
  217. package/node_modules/@code-yeongyu/senpi-desktop-tool/dist/index.d.ts +2 -0
  218. package/node_modules/@code-yeongyu/senpi-desktop-tool/dist/index.d.ts.map +1 -0
  219. package/node_modules/@code-yeongyu/senpi-desktop-tool/dist/index.js +2 -0
  220. package/node_modules/@code-yeongyu/senpi-desktop-tool/dist/index.js.map +1 -0
  221. package/node_modules/@code-yeongyu/senpi-desktop-tool/package.json +44 -0
  222. package/node_modules/@earendil-works/pi-agent-core/package.json +3 -3
  223. package/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
  224. package/node_modules/@earendil-works/pi-ai/dist/providers/data/cerebras.json +1 -1
  225. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
  226. package/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
  227. package/node_modules/@earendil-works/pi-ai/package.json +2 -2
  228. package/node_modules/@earendil-works/pi-pty/dist/pipe-fallback.d.ts +2 -0
  229. package/node_modules/@earendil-works/pi-pty/dist/pipe-fallback.d.ts.map +1 -1
  230. package/node_modules/@earendil-works/pi-pty/dist/pipe-fallback.js +6 -0
  231. package/node_modules/@earendil-works/pi-pty/dist/pipe-fallback.js.map +1 -1
  232. package/node_modules/@earendil-works/pi-pty/dist/session-bun.d.ts +1 -0
  233. package/node_modules/@earendil-works/pi-pty/dist/session-bun.d.ts.map +1 -1
  234. package/node_modules/@earendil-works/pi-pty/dist/session-bun.js +1 -0
  235. package/node_modules/@earendil-works/pi-pty/dist/session-bun.js.map +1 -1
  236. package/node_modules/@earendil-works/pi-pty/dist/session-native.js +5 -0
  237. package/node_modules/@earendil-works/pi-pty/dist/session-native.js.map +1 -1
  238. package/node_modules/@earendil-works/pi-pty/dist/session-raw-tail.d.ts +11 -0
  239. package/node_modules/@earendil-works/pi-pty/dist/session-raw-tail.d.ts.map +1 -0
  240. package/node_modules/@earendil-works/pi-pty/dist/session-raw-tail.js +24 -0
  241. package/node_modules/@earendil-works/pi-pty/dist/session-raw-tail.js.map +1 -0
  242. package/node_modules/@earendil-works/pi-pty/dist/session-types.d.ts +2 -0
  243. package/node_modules/@earendil-works/pi-pty/dist/session-types.d.ts.map +1 -1
  244. package/node_modules/@earendil-works/pi-pty/dist/session-types.js.map +1 -1
  245. package/node_modules/@earendil-works/pi-pty/dist/session.d.ts +4 -5
  246. package/node_modules/@earendil-works/pi-pty/dist/session.d.ts.map +1 -1
  247. package/node_modules/@earendil-works/pi-pty/dist/session.js +11 -16
  248. package/node_modules/@earendil-works/pi-pty/dist/session.js.map +1 -1
  249. package/node_modules/@earendil-works/pi-pty/native/prebuilds/darwin-arm64/senpi_pty.darwin-arm64.node +0 -0
  250. package/node_modules/@earendil-works/pi-pty/package.json +1 -1
  251. package/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
  252. package/node_modules/@earendil-works/pi-tui/package.json +1 -1
  253. package/package.json +22 -7
  254. package/dist/bundle/chunks/chunk-GFUZPFHN.js +0 -2
  255. package/dist/bundle/chunks/chunk-JBOV6VNK.js +0 -8
  256. package/dist/bundle/chunks/runtime-session-F3EXC44D.js +0 -2
@@ -1 +1 @@
1
- {"version":3,"file":"monitor-registry.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/terminal/monitor-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAkB,KAAK,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,MAAM,EAAmB,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAC3F,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAKjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,EAAE,mCAAmC,EAAE,6BAA6B,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAExH,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAyBhD,MAAM,mBAAmB,GAAG,kCAAkC,CAAC;AAE/D,gGAAgG;AAChG,MAAM,UAAU,iBAAiB;IAChC,IAAI,EAAE,GAAG,MAAM,CAAC;IAChB,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,KAAK,MAAM,IAAI,IAAI,WAAW,CAAC,EAAE,CAAC,EAAE,CAAC;QACpC,MAAM,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC;QAC9B,IAAI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andle, lstat, open, stat } from \"node:fs/promises\";\nimport { basename, dirname, join, resolve } from \"node:path\";\nimport { canonicalWatchPath, probeDirectoryOpenable } from \"../../../../utils/fs-watch.ts\";\nimport { realpathWithoutOpen } from \"../../../../utils/paths.ts\";\nimport type {\n\tTerminalMonitorEndedEvent as MonitorEndedEvent,\n\tTerminalMonitorEndedReason as MonitorEndedReason,\n} from \"../monitor-state-event.ts\";\nimport { digestFileHandle } from \"./monitor-file-digest.ts\";\nimport { FileWatchLoop } from \"./monitor-file-watch.ts\";\nimport { MonitorLineBuffer } from \"./monitor-line-buffer.ts\";\nimport type { TerminalRuntimeSession } from \"./runtime-session.ts\";\nimport { DEFAULT_DURABLE_MONITOR_FIRE_BUDGET, FIRE_BUDGET_AUTO_MUTE_SUMMARY, FIRE_BUDGET_WINDOW_MS } from \"./shared.ts\";\nimport type { MonitorDurabilityClass } from \"./terminal-manifest.ts\";\nimport { describeExit } from \"./tools/spawn.ts\";\n\nexport interface MonitorLineEvent {\n\treadonly type: \"line\";\n\treadonly id: string;\n\treadonly description: string;\n\treadonly line: string;\n}\n\nexport interface MonitorSummaryEvent {\n\treadonly type: \"summary\";\n\treadonly id: string;\n\treadonly description: string;\n\treadonly summary: string;\n}\n\nexport type MonitorEvent = MonitorLineEvent | MonitorSummaryEvent;\n\nexport type MonitorRearmResult = \"rearmed\" | \"not_paused\" | \"not_found\";\n\nexport interface MonitorResumeResult {\n\treadonly id: string;\n\treadonly mutedDropped: number;\n}\n\nconst MONITOR_ID_ALPHABET = \"0123456789ABCDEFGHJKMNPQRSTVWXYZ\";\n\n/** Allocate a stable monitor identity: \"mon_\" + 16 Crockford base-32 chars (80 random bits). */\nexport function allocateMonitorId(): string {\n\tlet id = \"mon_\";\n\tlet buffer = 0;\n\tlet bits = 0;\n\tfor (const byte of randomBytes(10)) {\n\t\tbuffer = (buffer << 8) | byte;\n\t\tbits += 8;\n\t\twhile (bits >= 5) {\n\t\t\tbits -= 5;\n\t\t\tid += MONITOR_ID_ALPHABET[(buffer >> bits) & 31];\n\t\t}\n\t}\n\treturn id;\n}\n\nexport type MonitorFireWindow = { startMs: number; count: number };\nexport interface MonitorSnapshotEntry {\n\treadonly id: string;\n\t/** Stable \"mon_\" identity carried alongside the runtime id; always set on live snapshots. */\n\treadonly monitorId?: string;\n\treadonly description: string;\n\treadonly paused: boolean;\n\t/** Epoch milliseconds when the watch registered; feeds the footer's live elapsed label. */\n\treadonly startedAtMs: number;\n\treadonly command?: string | null;\n\treadonly filter?: string | null;\n\treadonly persistent?: boolean;\n\treadonly deadlineMs?: number | null;\n\treadonly fireCount?: number;\n\treadonly lastFiredAtMs?: number | null;\n\t/** Durability deadline of a restart-surviving watch; undefined for every ephemeral one. */\n\treadonly expiresAt?: number;\n\treadonly fireWindow?: MonitorFireWindow;\n}\n\nexport type { MonitorEndedEvent, MonitorEndedReason };\n\nexport interface MonitorRegistryOptions {\n\t/** Observes every registry transition (register/pause/rearm/settle/dispose) with the live snapshot. */\n\treadonly onChange?: (snapshot: readonly MonitorSnapshotEntry[]) => void;\n\t/** Fire-stat refreshes are separate from lifecycle transitions (which persist the manifest). */\n\treadonly onFire?: (snapshot: readonly MonitorSnapshotEntry[]) => void;\n\t/** Observes each monitor exactly once when it leaves the registry. */\n\treadonly onEnded?: (event: MonitorEndedEvent) => void;\n\t/** Reserves one shared terminal capacity slot for a native watch. */\n\treadonly reserve?: () => (() => void) | null;\n}\n\nexport interface RegisterFileMonitorOptions {\n\treadonly description: string;\n\treadonly path: string;\n\treadonly persistent?: boolean;\n\treadonly deadlineMs?: number | null;\n\t/** Caller-supplied stable identity so a restore can re-bind the same \"mon_\" id. */\n\treadonly monitorId?: string;\n\treadonly event: \"create\" | \"modify\";\n\treadonly timeoutMs: number;\n\treadonly cwd: string;\n\treadonly approvedParent?: string;\n\t/** Durability deadline of a `checkpointed-file` watch; omitted for a one-shot ephemeral one. */\n\treadonly expiresAt?: number;\n}\n\nexport interface RegisterMonitorOptions {\n\treadonly id: string;\n\treadonly command?: string | null;\n\treadonly persistent?: boolean;\n\treadonly deadlineMs?: number | null;\n\t/** Caller-supplied stable identity so a restore can re-bind the same \"mon_\" id. */\n\treadonly monitorId?: string;\n\treadonly description: string;\n\treadonly runtime: TerminalRuntimeSession;\n\treadonly filter?: RegExp;\n\t/** Durability class from the manifest spec; non-ephemeral records carry the fire budget. */\n\treadonly durabilityClass?: MonitorDurabilityClass;\n\t/** Persisted fire window re-bound by a restore, so a restart cannot reset the budget. */\n\treadonly fireWindow?: MonitorFireWindow;\n\t/** Durability deadline of a durable watch; omitted for an ephemeral one. */\n\treadonly expiresAt?: number;\n}\n\ninterface PendingFileRegistration {\n\trelease: (() => void) | undefined;\n\treadonly abort: AbortController;\n\treadonly deadline: ReturnType<typeof setTimeout>;\n\tsettled: boolean;\n}\n\ninterface FileMonitorRecord {\n\treadonly id: string;\n\treadonly monitorId: string;\n\treadonly sessionId: string;\n\treadonly description: string;\n\treadonly startedAtMs: number;\n\treadonly command: null;\n\treadonly filter: null;\n\treadonly persistent: boolean;\n\treadonly deadlineMs: number | null;\n\tfireCount: number;\n\tlastFiredAtMs: number | null;\n\treadonly expiresAt: number | undefined;\n\treadonly path: string;\n\treadonly canonicalPath: string;\n\treadonly canonicalParent: string;\n\treadonly event: \"create\" | \"modify\";\n\treadonly watcher: FSWatcher;\n\treadonly release: () => void;\n\treadonly watch: FileWatchLoop;\n\tpaused: boolean;\n\tsettled: boolean;\n\tpresent: boolean;\n\tmtimeMs: number;\n\tsize: number;\n\tdigest: string;\n\tdevice: number;\n\tinode: number;\n\tpendingChange: boolean;\n\tdirty: boolean;\n\tdirtyPasses: number;\n\tdirtyWindowStartedAt: number;\n\tchecking: Promise<void> | undefined;\n\treadonly deadline: ReturnType<typeof setTimeout>;\n}\n\ninterface MonitorRecord {\n\treadonly id: string;\n\treadonly monitorId: string;\n\treadonly sessionId: string;\n\treadonly description: string;\n\treadonly startedAtMs: number;\n\treadonly command: string | null;\n\treadonly persistent: boolean;\n\treadonly deadlineMs: number | null;\n\tfireCount: number;\n\tlastFiredAtMs: number | null;\n\treadonly expiresAt: number | undefined;\n\treadonly runtime: TerminalRuntimeSession;\n\treadonly filter: RegExp | undefined;\n\tlineBuffer: MonitorLineBuffer;\n\tmutedDropped: number;\n\tpaused: boolean;\n\tsettled: boolean;\n\tfireWindow: MonitorFireWindow | undefined;\n\tunsubscribeOutput: (() => void) | undefined;\n\tunsubscribeExit: (() => void) | undefined;\n}\n\n/**\n * Tracks active monitor sessions alongside the terminal manager's existing bash-id registry.\n * Output is deliberately retained only by TerminalRuntimeSession's bounded history; this\n * registry holds at most one unfinished line for each live monitor.\n */\nexport class MonitorRegistry {\n\treadonly #records = new Map<string, MonitorRecord>();\n\treadonly #emit: (event: MonitorEvent) => void;\n\treadonly #onChange: ((snapshot: readonly MonitorSnapshotEntry[]) => void) | undefined;\n\treadonly #onEnded: ((event: MonitorEndedEvent) => void) | undefined;\n\treadonly #onFire: ((snapshot: readonly MonitorSnapshotEntry[]) => void) | undefined;\n\treadonly #reserve: (() => (() => void) | null) | undefined;\n\treadonly #files = new Map<string, FileMonitorRecord>();\n\t#nextFileId = 1;\n\t#disposed = false;\n\t#parked = false;\n\t#pendingRegistrations = 0;\n\treadonly #pending = new Set<PendingFileRegistration>();\n\t#lifecycle = 0;\n\n\tconstructor(emit: (event: MonitorEvent) => void, options?: MonitorRegistryOptions) {\n\t\tthis.#emit = emit;\n\t\tthis.#onChange = options?.onChange;\n\t\tthis.#onEnded = options?.onEnded;\n\t\tthis.#onFire = options?.onFire;\n\t\tthis.#reserve = options?.reserve;\n\t}\n\n\t/** Attachment parking is independent of persisted monitor mute and wake budgets. */\n\tsetParked(parked: boolean): void {\n\t\tif (this.#parked === parked) return;\n\t\tthis.#parked = parked;\n\t\tfor (const record of this.#files.values()) {\n\t\t\tif (parked) record.watch.pause();\n\t\t\telse if (!record.paused) record.watch.resume();\n\t\t}\n\t}\n\n\tsnapshot(): readonly MonitorSnapshotEntry[] {\n\t\treturn [...this.#records.values(), ...this.#files.values()].map((record) => ({\n\t\t\tid: record.id,\n\t\t\tmonitorId: record.monitorId,\n\t\t\tdescription: record.description,\n\t\t\tpaused: record.paused,\n\t\t\tstartedAtMs: record.startedAtMs,\n\t\t\tcommand: record.command,\n\t\t\tfilter: record.filter?.source ?? null,\n\t\t\tpersistent: record.persistent,\n\t\t\tdeadlineMs: record.deadlineMs,\n\t\t\tfireCount: record.fireCount,\n\t\t\tlastFiredAtMs: record.lastFiredAtMs,\n\t\t\texpiresAt: record.expiresAt,\n\t\t\tfireWindow: \"fireWindow\" in record ? record.fireWindow : undefined,\n\t\t}));\n\t}\n\n\tasync registerFile(options: RegisterFileMonitorOptions): Promise<{ id: string; monitorId: string }> {\n\t\tif (this.#disposed) throw new Error(\"Cannot create file monitor: monitor registry is disposed.\");\n\t\tthis.#pendingRegistrations += 1;\n\t\tconst lifecycle = this.#lifecycle;\n\t\tconst release = this.#reserve?.();\n\t\tif (this.#reserve && !release) {\n\t\t\tthis.#pendingRegistrations -= 1;\n\t\t\tthrow new Error(\"Cannot create file monitor: terminal capacity is already in use.\");\n\t\t}\n\t\tconst pending: PendingFileRegistration = {\n\t\t\trelease: release ?? undefined,\n\t\t\tabort: new AbortController(),\n\t\t\tdeadline: setTimeout(() => pending.abort.abort(), options.timeoutMs),\n\t\t\tsettled: false,\n\t\t};\n\t\tthis.#pending.add(pending);\n\t\tconst path = resolve(options.cwd, options.path);\n\t\tconst parent = dirname(path);\n\t\tlet approvedParent: string;\n\t\ttry {\n\t\t\tawait this.#registrationAwait(pending, access(parent));\n\t\t\t// Identity is derived without open(2), with the same walker the permission parser used, so the\n\t\t\t// two sides agree byte-for-byte and neither can block on a wedged mount.\n\t\t\tapprovedParent = realpathWithoutOpen(parent);\n\t\t\tconst approvedParentAtPermission = options.approvedParent;\n\t\t\tif (approvedParentAtPermission !== undefined && approvedParent !== approvedParentAtPermission) {\n\t\t\t\tthrow new Error(`Cannot watch file: parent directory changed during permission approval: ${parent}`);\n\t\t\t}\n\t\t\tif (this.#disposed) throw new Error(\"Cannot create file monitor: monitor registry is disposed.\");\n\t\t} catch (error) {\n\t\t\tthis.#finishPending(pending);\n\t\t\tthis.#pendingRegistrations -= 1;\n\t\t\tif (error instanceof Error && error.message.includes(\"disposed\")) throw error;\n\t\t\tif ((error as NodeJS.ErrnoException)?.code !== \"ENOENT\") {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Cannot access parent directory ${parent}: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new Error(`Cannot watch file: parent directory does not exist: ${parent}`);\n\t\t}\n\t\tlet initial: Awaited<ReturnType<typeof stat>> | null = null;\n\t\tlet initialHandle: FileHandle | undefined;\n\t\ttry {\n\t\t\tconst target = await this.#registrationAwait(pending, lstat(path));\n\t\t\tif (target.isSymbolicLink()) throw new Error(`Cannot watch file: target is a symbolic link: ${path}`);\n\t\t\tinitialHandle = await this.#registrationAwait(pending, open(path, \"r\"), async (handle) => {\n\t\t\t\tawait handle.close();\n\t\t\t});\n\t\t\tinitial = await this.#registrationAwait(pending, initialHandle.stat());\n\t\t\tif (!initial.isFile()) throw new Error(`Cannot watch file: target is not a regular file: ${path}`);\n\t\t\tconst resolvedTarget = realpathWithoutOpen(path);\n\t\t\tif (resolvedTarget !== join(approvedParent, basename(path)))\n\t\t\t\tthrow new Error(`Cannot watch file: target identity changed: ${path}`);\n\t\t\tconst rebound = await this.#registrationAwait(pending, lstat(path));\n\t\t\tif (rebound.isSymbolicLink()) throw new Error(`Cannot watch file: target identity changed: ${path}`);\n\t\t\tconst reboundStat = await this.#registrationAwait(pending, stat(path));\n\t\t\tif (!reboundStat.isFile() || reboundStat.dev !== initial.dev || reboundStat.ino !== initial.ino)\n\t\t\t\tthrow new Error(`Cannot watch file: target identity changed: ${path}`);\n\t\t} catch (error) {\n\t\t\tawait initialHandle?.close();\n\t\t\tinitialHandle = undefined;\n\t\t\tif ((error as NodeJS.ErrnoException)?.code !== \"ENOENT\") {\n\t\t\t\tthis.#finishPending(pending);\n\t\t\t\tthis.#pendingRegistrations -= 1;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\tif (this.#disposed || lifecycle !== this.#lifecycle || this.#pendingRegistrations < 1) {\n\t\t\tthis.#finishPending(pending);\n\t\t\tthis.#pendingRegistrations -= 1;\n\t\t\tthrow new Error(\"Cannot create file monitor: monitor registry is disposed.\");\n\t\t}\n\t\tconst id = `watch_${this.#nextFileId++}`;\n\t\tlet watcher: FSWatcher;\n\t\ttry {\n\t\t\tconst activationParent = realpathWithoutOpen(parent);\n\t\t\tif (activationParent !== approvedParent) {\n\t\t\t\tthrow new Error(`Cannot watch file: parent directory changed during registration: ${parent}`);\n\t\t\t}\n\t\t\t// watch() opens the directory synchronously on this thread; prove the open completes on the\n\t\t\t// async pool first so a wedged mount fails at the registration deadline instead of freezing.\n\t\t\tawait this.#registrationAwait(pending, probeDirectoryOpenable(activationParent));\n\t\t\twatcher = watch(canonicalWatchPath(activationParent), (_kind, name) => {\n\t\t\t\tif (!name || basename(String(name)) === basename(path)) void this.#checkFile(id);\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tthis.#finishPending(pending);\n\t\t\tthis.#pendingRegistrations -= 1;\n\t\t\tthrow new Error(`Cannot watch file ${path}: ${error instanceof Error ? error.message : String(error)}`);\n\t\t}\n\t\tlet registrationError: string | undefined;\n\t\twatcher.on(\"error\", (error) => {\n\t\t\tregistrationError = `watcher error: ${error instanceof Error ? error.message : String(error)}`;\n\t\t\tconst record = this.#files.get(id);\n\t\t\tif (record) this.#settleFile(record, registrationError);\n\t\t});\n\t\tlet registrationCleaned = false;\n\t\tconst finishRegistration = () => {\n\t\t\tif (registrationCleaned) return;\n\t\t\tregistrationCleaned = true;\n\t\t\tthis.#pendingRegistrations -= 1;\n\t\t};\n\t\tconst cleanupRegistration = () => {\n\t\t\tif (registrationCleaned) return;\n\t\t\twatcher.close();\n\t\t\tfinishRegistration();\n\t\t\tthis.#finishPending(pending);\n\t\t};\n\t\tif (this.#disposed || lifecycle !== this.#lifecycle) {\n\t\t\tcleanupRegistration();\n\t\t\tthrow new Error(\"Cannot create file monitor: monitor registry is disposed.\");\n\t\t}\n\t\tconst canonicalPath = join(approvedParent, basename(path));\n\t\tlet digest: string;\n\t\ttry {\n\t\t\tdigest =\n\t\t\t\tinitial && initialHandle\n\t\t\t\t\t? await this.#registrationAwait(pending, this.#digestHandle(initialHandle, pending.abort.signal))\n\t\t\t\t\t: \"\";\n\t\t} catch (error) {\n\t\t\tcleanupRegistration();\n\t\t\tawait initialHandle?.close();\n\t\t\tinitialHandle = undefined;\n\t\t\tif (registrationError) {\n\t\t\t\tthis.#emit({ type: \"summary\", id, description: options.description, summary: registrationError });\n\t\t\t\tthrow new Error(registrationError);\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t\tawait initialHandle?.close();\n\t\tinitialHandle = undefined;\n\t\tif (registrationError) {\n\t\t\tcleanupRegistration();\n\t\t\tthis.#emit({ type: \"summary\", id, description: options.description, summary: registrationError });\n\t\t\tthrow new Error(registrationError);\n\t\t}\n\t\tif (this.#disposed || lifecycle !== this.#lifecycle) {\n\t\t\tcleanupRegistration();\n\t\t\tthrow new Error(\"Cannot create file monitor: monitor registry is disposed.\");\n\t\t}\n\t\tconst record: FileMonitorRecord = {\n\t\t\tid,\n\t\t\tmonitorId: options.monitorId ?? allocateMonitorId(),\n\t\t\tsessionId: id,\n\t\t\tdescription: options.description,\n\t\t\tstartedAtMs: Date.now(),\n\t\t\tcommand: null,\n\t\t\tfilter: null,\n\t\t\tpersistent: options.persistent ?? options.expiresAt !== undefined,\n\t\t\tdeadlineMs:\n\t\t\t\t(options.persistent ?? options.expiresAt !== undefined)\n\t\t\t\t\t? null\n\t\t\t\t\t: (options.deadlineMs ?? Date.now() + options.timeoutMs),\n\t\t\tfireCount: 0,\n\t\t\tlastFiredAtMs: null,\n\t\t\texpiresAt: options.expiresAt,\n\t\t\tpath,\n\t\t\tcanonicalPath,\n\t\t\tcanonicalParent: approvedParent,\n\t\t\tevent: options.event,\n\t\t\twatcher,\n\t\t\trelease: release ?? (() => {}),\n\t\t\twatch: new FileWatchLoop(() => void this.#checkFile(id)),\n\t\t\tpaused: false,\n\t\t\tsettled: false,\n\t\t\tpresent: initial !== null,\n\t\t\tmtimeMs: initial?.mtimeMs ?? 0,\n\t\t\tsize: initial?.size ?? 0,\n\t\t\tdigest,\n\t\t\tdevice: initial?.dev ?? 0,\n\t\t\tinode: initial?.ino ?? 0,\n\t\t\tpendingChange: false,\n\t\t\tdirty: false,\n\t\t\tdirtyPasses: 0,\n\t\t\tdirtyWindowStartedAt: 0,\n\t\t\tchecking: undefined,\n\t\t\tdeadline: setTimeout(() => {\n\t\t\t\tconst current = this.#files.get(id);\n\t\t\t\tif (current) this.#settleFile(current, \"watcher timed_out\");\n\t\t\t}, options.timeoutMs),\n\t\t};\n\t\tthis.#files.set(id, record);\n\t\tif (this.#parked) record.watch.pause();\n\t\tfinishRegistration();\n\t\tthis.#finishPending(pending, true);\n\t\tif (registrationError || this.#disposed || lifecycle !== this.#lifecycle) {\n\t\t\tthis.#settleFile(record, registrationError ?? \"watcher killed\");\n\t\t\tthrow new Error(registrationError ?? \"Cannot create file monitor: monitor registry is disposed.\");\n\t\t}\n\t\tthis.#notifyChange();\n\t\treturn { id, monitorId: record.monitorId };\n\t}\n\n\t/** Live identity tuple of one file watch; undefined when the id is not a live file watch. */\n\tfileCheckpoint(id: string) {\n\t\tconst r = this.#files.get(id);\n\t\treturn (\n\t\t\tr && { dev: r.device, ino: r.inode, size: r.size, mtimeMs: r.mtimeMs, digest: r.digest, present: r.present }\n\t\t);\n\t}\n\n\t/** Emit one restored-watch line through the SAME sink a live watch uses (coalescing, wake budget). */\n\temitFileLine(id: string, line: string): boolean {\n\t\tconst record = this.#files.get(id);\n\t\tif (!record || record.settled) return false;\n\t\tthis.#emitForRecord(record, { type: \"line\", id: record.id, description: record.description, line });\n\t\treturn true;\n\t}\n\n\tasync stopFile(id: string): Promise<boolean> {\n\t\tconst record = this.#files.get(id);\n\t\tif (!record) return false;\n\t\tthis.#settleFile(record, \"watcher killed\");\n\t\treturn true;\n\t}\n\n\tasync stopAllFiles(): Promise<number> {\n\t\tthis.#lifecycle += 1;\n\t\tconst records = [...this.#files.values()];\n\t\tfor (const record of records) this.#settleFile(record, \"watcher killed\");\n\t\tfor (const pending of [...this.#pending]) this.#finishPending(pending);\n\t\treturn records.length;\n\t}\n\n\t#settleFile(record: FileMonitorRecord, summary: string): void {\n\t\tif (record.settled) return;\n\t\trecord.settled = true;\n\t\trecord.watch.stop();\n\t\tclearTimeout(record.deadline);\n\t\trecord.watcher.close();\n\t\trecord.release();\n\t\tthis.#files.delete(record.id);\n\t\tthis.#notifyChange();\n\t\tthis.#emitForRecord(record, { type: \"summary\", id: record.id, description: record.description, summary });\n\t\tconst reason =\n\t\t\tsummary === \"watcher timed_out\"\n\t\t\t\t? \"timeout\"\n\t\t\t\t: summary === \"watcher killed\"\n\t\t\t\t\t? \"killed\"\n\t\t\t\t\t: summary === \"watcher disposed\"\n\t\t\t\t\t\t? \"disposed\"\n\t\t\t\t\t\t: \"exit\";\n\t\tthis.#emitEnded(record, reason, null);\n\t}\n\n\tasync #checkFile(id: string): Promise<void> {\n\t\tconst record = this.#files.get(id);\n\t\tif (!record || record.settled || record.paused || this.#parked) return;\n\t\tif (record.checking) {\n\t\t\trecord.dirty = true;\n\t\t\treturn;\n\t\t}\n\t\trecord.checking = this.#checkFileImpl(record)\n\t\t\t.catch((error) => {\n\t\t\t\tif (!record.settled)\n\t\t\t\t\tthis.#settleFile(record, `watcher error: ${error instanceof Error ? error.message : String(error)}`);\n\t\t\t})\n\t\t\t.finally(() => {\n\t\t\t\trecord.checking = undefined;\n\t\t\t\tconst now = Date.now();\n\t\t\t\tif (now - record.dirtyWindowStartedAt >= 1_000) {\n\t\t\t\t\trecord.dirtyWindowStartedAt = now;\n\t\t\t\t\trecord.dirtyPasses = 0;\n\t\t\t\t}\n\t\t\t\tif (record.dirty && !record.settled && record.dirtyPasses < 1) {\n\t\t\t\t\trecord.dirty = false;\n\t\t\t\t\trecord.dirtyPasses += 1;\n\t\t\t\t\tvoid this.#checkFile(id);\n\t\t\t\t} else {\n\t\t\t\t\trecord.dirty = false;\n\t\t\t\t}\n\t\t\t});\n\t\treturn record.checking;\n\t}\n\n\tasync #checkFileImpl(record: FileMonitorRecord): Promise<void> {\n\t\tif (record.settled) return;\n\t\tlet current: Awaited<ReturnType<typeof stat>> | null = null;\n\t\tlet handle: FileHandle | undefined;\n\t\ttry {\n\t\t\tconst currentParent = realpathWithoutOpen(dirname(record.path));\n\t\t\tif (currentParent !== record.canonicalParent) {\n\t\t\t\tthis.#settleFile(record, `watcher error: monitored parent changed: ${dirname(record.path)}`);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst target = await lstat(record.canonicalPath);\n\t\t\tif (target.isSymbolicLink()) throw new Error(`Cannot watch file: target identity changed: ${record.path}`);\n\t\t\tconst resolvedTarget = realpathWithoutOpen(record.canonicalPath);\n\t\t\tif (resolvedTarget !== record.canonicalPath)\n\t\t\t\tthrow new Error(`Cannot watch file: target identity changed: ${record.path}`);\n\t\t\thandle = await open(record.canonicalPath, \"r\");\n\t\t\tconst opened = await handle.stat();\n\t\t\tif (!opened.isFile()) throw new Error(`Cannot watch file: target is not a regular file: ${record.path}`);\n\t\t\tif ((opened.dev !== record.device || opened.ino !== record.inode) && opened.nlink > 1)\n\t\t\t\tthrow new Error(`Cannot watch file: target identity changed: ${record.path}`);\n\t\t\tcurrent = opened;\n\t\t\tconst rebound = await lstat(record.canonicalPath);\n\t\t\tif (rebound.isSymbolicLink()) throw new Error(`Cannot watch file: target identity changed: ${record.path}`);\n\t\t\tconst reboundPath = await stat(record.canonicalPath);\n\t\t\tif (!reboundPath.isFile() || reboundPath.dev !== opened.dev || reboundPath.ino !== opened.ino)\n\t\t\t\tthrow new Error(`Cannot watch file: target identity changed: ${record.path}`);\n\t\t} catch (error) {\n\t\t\tawait handle?.close();\n\t\t\tif ((error as NodeJS.ErrnoException)?.code !== \"ENOENT\") {\n\t\t\t\tthis.#settleFile(record, `watcher error: ${error instanceof Error ? error.message : String(error)}`);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tconst present = current !== null;\n\t\tlet digest = \"\";\n\t\ttry {\n\t\t\tdigest = present && handle ? await this.#digestHandle(handle) : \"\";\n\t\t\tif (present && handle) {\n\t\t\t\tconst afterDigest = await stat(record.canonicalPath);\n\t\t\t\tconst opened = await handle.stat();\n\t\t\t\tif (afterDigest.dev !== opened.dev || afterDigest.ino !== opened.ino)\n\t\t\t\t\tthrow new Error(`Cannot watch file: target identity changed: ${record.path}`);\n\t\t\t}\n\t\t} finally {\n\t\t\tawait handle?.close();\n\t\t}\n\t\tconst changed =\n\t\t\trecord.event === \"create\"\n\t\t\t\t? !record.present && present\n\t\t\t\t: record.present &&\n\t\t\t\t\tpresent &&\n\t\t\t\t\t(current!.mtimeMs !== record.mtimeMs || current!.size !== record.size || digest !== record.digest);\n\t\trecord.pendingChange ||= changed;\n\t\tif (!record.present && current) {\n\t\t\trecord.device = current.dev;\n\t\t\trecord.inode = current.ino;\n\t\t}\n\t\trecord.present = present;\n\t\trecord.mtimeMs = current?.mtimeMs ?? 0;\n\t\trecord.size = current?.size ?? 0;\n\t\trecord.digest = digest;\n\t\tif (!record.pendingChange || record.paused || record.settled) return;\n\t\trecord.pendingChange = false;\n\t\tif (record.settled) return;\n\t\tthis.#emitForRecord(record, {\n\t\t\ttype: \"line\",\n\t\t\tid: record.id,\n\t\t\tdescription: record.description,\n\t\t\tline: `${record.event} ${record.path}`,\n\t\t});\n\t\tthis.#settleFile(record, \"watcher completed\");\n\t}\n\n\tregister(options: RegisterMonitorOptions): string {\n\t\tconst durable = options.durabilityClass !== undefined && options.durabilityClass !== \"ephemeral\";\n\t\tconst record: MonitorRecord = {\n\t\t\tid: options.id,\n\t\t\tmonitorId: options.monitorId ?? allocateMonitorId(),\n\t\t\tsessionId: options.id,\n\t\t\tdescription: options.description,\n\t\t\tstartedAtMs: Date.now(),\n\t\t\tcommand: options.command ?? null,\n\t\t\tpersistent: options.persistent ?? durable,\n\t\t\tdeadlineMs: (options.persistent ?? durable) ? null : (options.deadlineMs ?? null),\n\t\t\tfireCount: 0,\n\t\t\tlastFiredAtMs: null,\n\t\t\texpiresAt: options.expiresAt,\n\t\t\truntime: options.runtime,\n\t\t\tfilter: options.filter,\n\t\t\tlineBuffer: new MonitorLineBuffer(),\n\t\t\tmutedDropped: 0,\n\t\t\tpaused: false,\n\t\t\tsettled: false,\n\t\t\tfireWindow: durable ? { ...(options.fireWindow ?? { startMs: Date.now(), count: 0 }) } : undefined,\n\t\t\tunsubscribeOutput: undefined,\n\t\t\tunsubscribeExit: undefined,\n\t\t};\n\t\tthis.#records.set(record.id, record);\n\t\tthis.#notifyChange();\n\n\t\t// Runtime output is already bounded. Read what was produced before monitor registration,\n\t\t// then subscribe synchronously so a fast watcher cannot lose its first line.\n\t\tthis.#consume(record, record.runtime.fullOutput());\n\t\trecord.unsubscribeOutput = record.runtime.onOutput((chunk) => this.#consume(record, chunk));\n\t\trecord.unsubscribeExit = record.runtime.session.onExit(() => this.#settle(record));\n\t\tif (record.runtime.exited) this.#settle(record);\n\t\treturn record.monitorId;\n\t}\n\n\tpause(ids: readonly string[]): string[] {\n\t\tconst paused: string[] = [];\n\t\tfor (const id of ids) {\n\t\t\tconst record = this.#records.get(id) ?? this.#files.get(id);\n\t\t\tif (!record || record.paused) continue;\n\t\t\trecord.paused = true;\n\t\t\tif (\"watch\" in record) record.watch.pause();\n\t\t\tpaused.push(record.id);\n\t\t}\n\t\tif (paused.length > 0) this.#notifyChange();\n\t\treturn paused;\n\t}\n\n\tpauseAll(): string[] {\n\t\treturn this.pause([...this.#records.keys(), ...this.#files.keys()]);\n\t}\n\n\tresume(ids?: readonly string[]): MonitorResumeResult[] {\n\t\tconst candidates = ids ?? [...this.#records.keys(), ...this.#files.keys()];\n\t\tconst resumed: MonitorResumeResult[] = [];\n\t\tfor (const id of candidates) {\n\t\t\tconst record = this.#records.get(id) ?? this.#files.get(id);\n\t\t\tif (!record?.paused) continue;\n\t\t\trecord.paused = false;\n\t\t\tconst mutedDropped = \"mutedDropped\" in record ? record.mutedDropped : 0;\n\t\t\tif (\"mutedDropped\" in record) record.mutedDropped = 0;\n\t\t\t// A rearm (or any resume) restarts the rolling fire budget while keeping its window start.\n\t\t\tif (\"fireWindow\" in record && record.fireWindow !== undefined) record.fireWindow.count = 0;\n\t\t\tresumed.push({ id: record.id, mutedDropped });\n\t\t\tif (\"watch\" in record && !this.#parked) record.watch.resume();\n\t\t}\n\t\tif (resumed.length > 0) this.#notifyChange();\n\t\treturn resumed;\n\t}\n\n\tmutedDropped(id: string): number {\n\t\treturn this.#records.get(id)?.mutedDropped ?? 0;\n\t}\n\n\trearm(id: string): MonitorRearmResult {\n\t\tconst record = this.#records.get(id) ?? this.#files.get(id);\n\t\tif (!record) return \"not_found\";\n\t\tif (!record.paused) return \"not_paused\";\n\t\tthis.resume([id]);\n\t\treturn \"rearmed\";\n\t}\n\n\t/** Re-bind a persisted fire window onto the record for a durable monitor id (a restore re-arms the budget). */\n\tadoptFireWindow(monitorId: string, fireWindow: MonitorFireWindow): boolean {\n\t\tfor (const record of this.#records.values()) {\n\t\t\tif (record.monitorId !== monitorId) continue;\n\t\t\trecord.fireWindow = { ...fireWindow };\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tdispose(): void {\n\t\tthis.#disposed = true;\n\t\tthis.#lifecycle += 1;\n\t\tfor (const record of [...this.#records.values()]) this.#disposeRecord(record);\n\t\tfor (const record of this.#files.values()) this.#settleFile(record, \"watcher disposed\");\n\t\tfor (const pending of this.#pending) this.#finishPending(pending);\n\t\tthis.#records.clear();\n\t\tthis.#notifyChange();\n\t}\n\n\t#finishPending(pending: PendingFileRegistration, transfer = false): void {\n\t\tif (pending.settled) return;\n\t\tpending.settled = true;\n\t\tclearTimeout(pending.deadline);\n\t\tthis.#pending.delete(pending);\n\t\tif (transfer) pending.release = undefined;\n\t\telse {\n\t\t\tpending.abort.abort();\n\t\t\tpending.release?.();\n\t\t}\n\t}\n\n\tasync #registrationAwait<T>(\n\t\tpending: PendingFileRegistration,\n\t\toperation: Promise<T>,\n\t\tlateCleanup?: (value: T) => Promise<void>,\n\t): Promise<T> {\n\t\tif (pending.abort.signal.aborted) {\n\t\t\tvoid operation.then(\n\t\t\t\t(value) => lateCleanup?.(value),\n\t\t\t\t() => undefined,\n\t\t\t);\n\t\t\tthrow new Error(\"Cannot create file monitor: registration timed out or was disposed.\");\n\t\t}\n\t\tlet aborted = false;\n\t\tconst abort = new Promise<never>((_, reject) =>\n\t\t\tpending.abort.signal.addEventListener(\n\t\t\t\t\"abort\",\n\t\t\t\t() => {\n\t\t\t\t\taborted = true;\n\t\t\t\t\treject(new Error(\"Cannot create file monitor: registration timed out or was disposed.\"));\n\t\t\t\t},\n\t\t\t\t{ once: true },\n\t\t\t),\n\t\t);\n\t\tconst guarded = operation.then(\n\t\t\t(value) => {\n\t\t\t\tif (aborted) void lateCleanup?.(value);\n\t\t\t\treturn value;\n\t\t\t},\n\t\t\t(error) => {\n\t\t\t\tif (aborted) return undefined as T;\n\t\t\t\tthrow error;\n\t\t\t},\n\t\t);\n\t\treturn Promise.race([guarded, abort]);\n\t}\n\n\tasync #digestHandle(handle: FileHandle, signal?: AbortSignal): Promise<string> {\n\t\treturn digestFileHandle(handle, signal);\n\t}\n\n\t#notifyChange(): void {\n\t\tthis.#onChange?.(this.snapshot());\n\t}\n\n\t#consume(record: MonitorRecord, chunk: string): void {\n\t\tif (record.settled || chunk.length === 0) return;\n\t\tfor (const line of record.lineBuffer.append(chunk)) {\n\t\t\tconst matchesFilter = !record.filter || record.filter.test(line);\n\t\t\tif (!matchesFilter) continue;\n\t\t\tif (record.paused) {\n\t\t\t\trecord.mutedDropped += 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tthis.#emitForRecord(record, { type: \"line\", id: record.id, description: record.description, line });\n\t\t\tif (record.fireWindow !== undefined) {\n\t\t\t\tconst now = Date.now();\n\t\t\t\tif (now - record.fireWindow.startMs >= FIRE_BUDGET_WINDOW_MS)\n\t\t\t\t\trecord.fireWindow = { startMs: now, count: 0 };\n\t\t\t\trecord.fireWindow.count += 1;\n\t\t\t\tif (record.fireWindow.count >= DEFAULT_DURABLE_MONITOR_FIRE_BUDGET) {\n\t\t\t\t\trecord.paused = true;\n\t\t\t\t\tthis.#emitForRecord(record, {\n\t\t\t\t\t\ttype: \"summary\",\n\t\t\t\t\t\tid: record.id,\n\t\t\t\t\t\tdescription: record.description,\n\t\t\t\t\t\tsummary: FIRE_BUDGET_AUTO_MUTE_SUMMARY,\n\t\t\t\t\t});\n\t\t\t\t\tthis.#notifyChange();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t#settle(record: MonitorRecord): void {\n\t\tif (record.settled) return;\n\t\trecord.settled = true;\n\t\trecord.unsubscribeOutput?.();\n\t\trecord.unsubscribeExit?.();\n\t\tthis.#records.delete(record.id);\n\t\tthis.#notifyChange();\n\t\tconst status = describeExit(record.runtime) ?? \"exited\";\n\t\tconst code = record.runtime.exitResult?.exitCode;\n\t\tconst codeText = code === null || code === undefined ? \"\" : ` (exit code ${code})`;\n\t\tthis.#emitForRecord(record, {\n\t\t\ttype: \"summary\",\n\t\t\tid: record.id,\n\t\t\tdescription: record.description,\n\t\t\tsummary: `watcher ${status}${codeText}`,\n\t\t});\n\t\tconst exit = record.runtime.exitResult;\n\t\tthis.#emitEnded(record, exit?.timedOut ? \"timeout\" : exit?.cancelled ? \"killed\" : \"exit\", code ?? null);\n\t}\n\n\t#disposeRecord(record: MonitorRecord): void {\n\t\tif (record.settled) return;\n\t\trecord.settled = true;\n\t\trecord.unsubscribeOutput?.();\n\t\trecord.unsubscribeExit?.();\n\t\tthis.#records.delete(record.id);\n\t\tthis.#emitEnded(record, \"disposed\", null);\n\t}\n\n\t#emitForRecord(record: MonitorRecord | FileMonitorRecord, event: MonitorEvent): void {\n\t\trecord.fireCount += 1;\n\t\trecord.lastFiredAtMs = Date.now();\n\t\tthis.#emit(event);\n\t\tif (!record.settled) this.#onFire?.(this.snapshot());\n\t}\n\n\t#emitEnded(record: MonitorRecord | FileMonitorRecord, reason: MonitorEndedReason, exitCode: number | null): void {\n\t\tthis.#onEnded?.({\n\t\t\tid: record.id,\n\t\t\tdescription: record.description,\n\t\t\tstartedAtMs: record.startedAtMs,\n\t\t\tendedAtMs: Date.now(),\n\t\t\treason,\n\t\t\texitCode,\n\t\t\tfireCount: record.fireCount,\n\t\t});\n\t}\n}\n"]}
1
+ {"version":3,"file":"monitor-registry.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/terminal/monitor-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAkB,KAAK,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,MAAM,EAAmB,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAC3F,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAKjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,EAAE,mCAAmC,EAAE,6BAA6B,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAExH,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAyBhD,MAAM,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C,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAClB,IAAI,CAAC,MAAM,CAAC,OAAO;YAAE,IAAI,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;IACtD,CAAC;IAED,UAAU,CAAC,MAAyC,EAAE,MAA0B,EAAE,QAAuB;QACxG,IAAI,CAAC,QAAQ,EAAE,CAAC;YACf,EAAE,EAAE,MAAM,CAAC,EAAE;YACb,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;YACrB,MAAM;YACN,QAAQ;YACR,SAAS,EAAE,MAAM,CAAC,SAAS;SAC3B,CAAC,CAAC;IACJ,CAAC;CACD","sourcesContent":["import { randomBytes } from \"node:crypto\";\nimport { type FSWatcher, watch } from \"node:fs\";\nimport { access, type FileHandle, lstat, open, stat } from \"node:fs/promises\";\nimport { basename, dirname, join, resolve } from \"node:path\";\nimport { canonicalWatchPath, probeDirectoryOpenable } from \"../../../../utils/fs-watch.ts\";\nimport { realpathWithoutOpen } from \"../../../../utils/paths.ts\";\nimport type {\n\tTerminalMonitorEndedEvent as MonitorEndedEvent,\n\tTerminalMonitorEndedReason as MonitorEndedReason,\n} from \"../monitor-state-event.ts\";\nimport { digestFileHandle } from \"./monitor-file-digest.ts\";\nimport { FileWatchLoop } from \"./monitor-file-watch.ts\";\nimport { MonitorLineBuffer } from \"./monitor-line-buffer.ts\";\nimport type { TerminalRuntimeSession } from \"./runtime-session.ts\";\nimport { DEFAULT_DURABLE_MONITOR_FIRE_BUDGET, FIRE_BUDGET_AUTO_MUTE_SUMMARY, FIRE_BUDGET_WINDOW_MS } from \"./shared.ts\";\nimport type { MonitorDurabilityClass } from \"./terminal-manifest.ts\";\nimport { describeExit } from \"./tools/spawn.ts\";\n\nexport interface MonitorLineEvent {\n\treadonly type: \"line\";\n\treadonly id: string;\n\treadonly description: string;\n\treadonly line: string;\n}\n\nexport interface MonitorSummaryEvent {\n\treadonly type: \"summary\";\n\treadonly id: string;\n\treadonly description: string;\n\treadonly summary: string;\n}\n\nexport type MonitorEvent = MonitorLineEvent | MonitorSummaryEvent;\n\nexport type MonitorRearmResult = \"rearmed\" | \"not_paused\" | \"not_found\";\n\nexport interface MonitorResumeResult {\n\treadonly id: string;\n\treadonly mutedDropped: number;\n}\n\nconst MONITOR_ID_ALPHABET = \"0123456789ABCDEFGHJKMNPQRSTVWXYZ\";\n\n/** Allocate a stable monitor identity: \"mon_\" + 16 Crockford base-32 chars (80 random bits). */\nexport function allocateMonitorId(): string {\n\tlet id = \"mon_\";\n\tlet buffer = 0;\n\tlet bits = 0;\n\tfor (const byte of randomBytes(10)) {\n\t\tbuffer = (buffer << 8) | byte;\n\t\tbits += 8;\n\t\twhile (bits >= 5) {\n\t\t\tbits -= 5;\n\t\t\tid += MONITOR_ID_ALPHABET[(buffer >> bits) & 31];\n\t\t}\n\t}\n\treturn id;\n}\n\nexport type MonitorFireWindow = { startMs: number; count: number };\nexport interface MonitorSnapshotEntry {\n\treadonly id: string;\n\t/** Stable \"mon_\" identity carried alongside the runtime id; always set on live snapshots. */\n\treadonly monitorId?: string;\n\treadonly description: string;\n\treadonly paused: boolean;\n\t/** Epoch milliseconds when the watch registered; feeds the footer's live elapsed label. */\n\treadonly startedAtMs: number;\n\treadonly command?: string | null;\n\treadonly filter?: string | null;\n\treadonly persistent?: boolean;\n\treadonly deadlineMs?: number | null;\n\treadonly fireCount?: number;\n\treadonly lastFiredAtMs?: number | null;\n\t/** Durability deadline of a restart-surviving watch; undefined for every ephemeral one. */\n\treadonly expiresAt?: number;\n\treadonly fireWindow?: MonitorFireWindow;\n}\n\nexport type { MonitorEndedEvent, MonitorEndedReason };\n\nexport interface MonitorRegistryOptions {\n\t/** Observes every registry transition (register/pause/rearm/settle/dispose) with the live snapshot. */\n\treadonly onChange?: (snapshot: readonly MonitorSnapshotEntry[]) => void;\n\t/** Fire-stat refreshes are separate from lifecycle transitions (which persist the manifest). */\n\treadonly onFire?: (snapshot: readonly MonitorSnapshotEntry[]) => void;\n\t/** Observes each monitor exactly once when it leaves the registry. */\n\treadonly onEnded?: (event: MonitorEndedEvent) => void;\n\t/** Reserves one shared terminal capacity slot for a native watch. */\n\treadonly reserve?: () => (() => void) | null;\n}\n\nexport interface RegisterFileMonitorOptions {\n\treadonly description: string;\n\treadonly path: string;\n\treadonly persistent?: boolean;\n\treadonly deadlineMs?: number | null;\n\t/** Caller-supplied stable identity so a restore can re-bind the same \"mon_\" id. */\n\treadonly monitorId?: string;\n\treadonly event: \"create\" | \"modify\";\n\treadonly timeoutMs: number;\n\treadonly cwd: string;\n\treadonly approvedParent?: string;\n\t/** Durability deadline of a `checkpointed-file` watch; omitted for a one-shot ephemeral one. */\n\treadonly expiresAt?: number;\n}\n\nexport interface RegisterMonitorOptions {\n\treadonly id: string;\n\treadonly command?: string | null;\n\treadonly persistent?: boolean;\n\treadonly deadlineMs?: number | null;\n\t/** Caller-supplied stable identity so a restore can re-bind the same \"mon_\" id. */\n\treadonly monitorId?: string;\n\treadonly description: string;\n\treadonly runtime: TerminalRuntimeSession;\n\treadonly filter?: RegExp;\n\t/** Durability class from the manifest spec; non-ephemeral records carry the fire budget. */\n\treadonly durabilityClass?: MonitorDurabilityClass;\n\t/** Persisted fire window re-bound by a restore, so a restart cannot reset the budget. */\n\treadonly fireWindow?: MonitorFireWindow;\n\t/** Durability deadline of a durable watch; omitted for an ephemeral one. */\n\treadonly expiresAt?: number;\n}\n\ninterface PendingFileRegistration {\n\trelease: (() => void) | undefined;\n\treadonly abort: AbortController;\n\treadonly deadline: ReturnType<typeof setTimeout>;\n\tsettled: boolean;\n}\n\ninterface FileMonitorRecord {\n\treadonly id: string;\n\treadonly monitorId: string;\n\treadonly sessionId: string;\n\treadonly description: string;\n\treadonly startedAtMs: number;\n\treadonly command: null;\n\treadonly filter: null;\n\treadonly persistent: boolean;\n\treadonly deadlineMs: number | null;\n\tfireCount: number;\n\tlastFiredAtMs: number | null;\n\treadonly expiresAt: number | undefined;\n\treadonly path: string;\n\treadonly canonicalPath: string;\n\treadonly canonicalParent: string;\n\treadonly event: \"create\" | \"modify\";\n\treadonly watcher: FSWatcher;\n\treadonly release: () => void;\n\treadonly watch: FileWatchLoop;\n\tpaused: boolean;\n\tsettled: boolean;\n\tpresent: boolean;\n\tmtimeMs: number;\n\tsize: number;\n\tdigest: string;\n\tdevice: number;\n\tinode: number;\n\tpendingChange: boolean;\n\tdirty: boolean;\n\tdirtyPasses: number;\n\tdirtyWindowStartedAt: number;\n\tchecking: Promise<void> | undefined;\n\t/** Unset for a persistent watch: it has no live deadline, only its durability expiry. */\n\treadonly deadline: ReturnType<typeof setTimeout> | undefined;\n}\n\ninterface MonitorRecord {\n\treadonly id: string;\n\treadonly monitorId: string;\n\treadonly sessionId: string;\n\treadonly description: string;\n\treadonly startedAtMs: number;\n\treadonly command: string | null;\n\treadonly persistent: boolean;\n\treadonly deadlineMs: number | null;\n\tfireCount: number;\n\tlastFiredAtMs: number | null;\n\treadonly expiresAt: number | undefined;\n\treadonly runtime: TerminalRuntimeSession;\n\treadonly filter: RegExp | undefined;\n\tlineBuffer: MonitorLineBuffer;\n\tmutedDropped: number;\n\tpaused: boolean;\n\tsettled: boolean;\n\tfireWindow: MonitorFireWindow | undefined;\n\tunsubscribeOutput: (() => void) | undefined;\n\tunsubscribeExit: (() => void) | undefined;\n}\n\n/**\n * Tracks active monitor sessions alongside the terminal manager's existing bash-id registry.\n * Output is deliberately retained only by TerminalRuntimeSession's bounded history; this\n * registry holds at most one unfinished line for each live monitor.\n */\nexport class MonitorRegistry {\n\treadonly #records = new Map<string, MonitorRecord>();\n\treadonly #emit: (event: MonitorEvent) => void;\n\treadonly #onChange: ((snapshot: readonly MonitorSnapshotEntry[]) => void) | undefined;\n\treadonly #onEnded: ((event: MonitorEndedEvent) => void) | undefined;\n\treadonly #onFire: ((snapshot: readonly MonitorSnapshotEntry[]) => void) | undefined;\n\treadonly #reserve: (() => (() => void) | null) | undefined;\n\treadonly #files = new Map<string, FileMonitorRecord>();\n\t#nextFileId = 1;\n\t#disposed = false;\n\t#parked = false;\n\t#pendingRegistrations = 0;\n\treadonly #pending = new Set<PendingFileRegistration>();\n\t#lifecycle = 0;\n\n\tconstructor(emit: (event: MonitorEvent) => void, options?: MonitorRegistryOptions) {\n\t\tthis.#emit = emit;\n\t\tthis.#onChange = options?.onChange;\n\t\tthis.#onEnded = options?.onEnded;\n\t\tthis.#onFire = options?.onFire;\n\t\tthis.#reserve = options?.reserve;\n\t}\n\n\t/** Attachment parking is independent of persisted monitor mute and wake budgets. */\n\tsetParked(parked: boolean): void {\n\t\tif (this.#parked === parked) return;\n\t\tthis.#parked = parked;\n\t\tfor (const record of this.#files.values()) {\n\t\t\tif (parked) record.watch.pause();\n\t\t\telse if (!record.paused) record.watch.resume();\n\t\t}\n\t}\n\n\tsnapshot(): readonly MonitorSnapshotEntry[] {\n\t\treturn [...this.#records.values(), ...this.#files.values()].map((record) => ({\n\t\t\tid: record.id,\n\t\t\tmonitorId: record.monitorId,\n\t\t\tdescription: record.description,\n\t\t\tpaused: record.paused,\n\t\t\tstartedAtMs: record.startedAtMs,\n\t\t\tcommand: record.command,\n\t\t\tfilter: record.filter?.source ?? null,\n\t\t\tpersistent: record.persistent,\n\t\t\tdeadlineMs: record.deadlineMs,\n\t\t\tfireCount: record.fireCount,\n\t\t\tlastFiredAtMs: record.lastFiredAtMs,\n\t\t\texpiresAt: record.expiresAt,\n\t\t\tfireWindow: \"fireWindow\" in record ? record.fireWindow : undefined,\n\t\t}));\n\t}\n\n\tasync registerFile(options: RegisterFileMonitorOptions): Promise<{ id: string; monitorId: string }> {\n\t\tif (this.#disposed) throw new Error(\"Cannot create file monitor: monitor registry is disposed.\");\n\t\tthis.#pendingRegistrations += 1;\n\t\tconst lifecycle = this.#lifecycle;\n\t\tconst release = this.#reserve?.();\n\t\tif (this.#reserve && !release) {\n\t\t\tthis.#pendingRegistrations -= 1;\n\t\t\tthrow new Error(\"Cannot create file monitor: terminal capacity is already in use.\");\n\t\t}\n\t\tconst pending: PendingFileRegistration = {\n\t\t\trelease: release ?? undefined,\n\t\t\tabort: new AbortController(),\n\t\t\tdeadline: setTimeout(() => pending.abort.abort(), options.timeoutMs),\n\t\t\tsettled: false,\n\t\t};\n\t\tthis.#pending.add(pending);\n\t\tconst path = resolve(options.cwd, options.path);\n\t\tconst parent = dirname(path);\n\t\tlet approvedParent: string;\n\t\ttry {\n\t\t\tawait this.#registrationAwait(pending, access(parent));\n\t\t\t// Identity is derived without open(2), with the same walker the permission parser used, so the\n\t\t\t// two sides agree byte-for-byte and neither can block on a wedged mount.\n\t\t\tapprovedParent = realpathWithoutOpen(parent);\n\t\t\tconst approvedParentAtPermission = options.approvedParent;\n\t\t\tif (approvedParentAtPermission !== undefined && approvedParent !== approvedParentAtPermission) {\n\t\t\t\tthrow new Error(`Cannot watch file: parent directory changed during permission approval: ${parent}`);\n\t\t\t}\n\t\t\tif (this.#disposed) throw new Error(\"Cannot create file monitor: monitor registry is disposed.\");\n\t\t} catch (error) {\n\t\t\tthis.#finishPending(pending);\n\t\t\tthis.#pendingRegistrations -= 1;\n\t\t\tif (error instanceof Error && error.message.includes(\"disposed\")) throw error;\n\t\t\tif ((error as NodeJS.ErrnoException)?.code !== \"ENOENT\") {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Cannot access parent directory ${parent}: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new Error(`Cannot watch file: parent directory does not exist: ${parent}`);\n\t\t}\n\t\tlet initial: Awaited<ReturnType<typeof stat>> | null = null;\n\t\tlet initialHandle: FileHandle | undefined;\n\t\ttry {\n\t\t\tconst target = await this.#registrationAwait(pending, lstat(path));\n\t\t\tif (target.isSymbolicLink()) throw new Error(`Cannot watch file: target is a symbolic link: ${path}`);\n\t\t\tinitialHandle = await this.#registrationAwait(pending, open(path, \"r\"), async (handle) => {\n\t\t\t\tawait handle.close();\n\t\t\t});\n\t\t\tinitial = await this.#registrationAwait(pending, initialHandle.stat());\n\t\t\tif (!initial.isFile()) throw new Error(`Cannot watch file: target is not a regular file: ${path}`);\n\t\t\tconst resolvedTarget = realpathWithoutOpen(path);\n\t\t\tif (resolvedTarget !== join(approvedParent, basename(path)))\n\t\t\t\tthrow new Error(`Cannot watch file: target identity changed: ${path}`);\n\t\t\tconst rebound = await this.#registrationAwait(pending, lstat(path));\n\t\t\tif (rebound.isSymbolicLink()) throw new Error(`Cannot watch file: target identity changed: ${path}`);\n\t\t\tconst reboundStat = await this.#registrationAwait(pending, stat(path));\n\t\t\tif (!reboundStat.isFile() || reboundStat.dev !== initial.dev || reboundStat.ino !== initial.ino)\n\t\t\t\tthrow new Error(`Cannot watch file: target identity changed: ${path}`);\n\t\t} catch (error) {\n\t\t\tawait initialHandle?.close();\n\t\t\tinitialHandle = undefined;\n\t\t\tif ((error as NodeJS.ErrnoException)?.code !== \"ENOENT\") {\n\t\t\t\tthis.#finishPending(pending);\n\t\t\t\tthis.#pendingRegistrations -= 1;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\tif (this.#disposed || lifecycle !== this.#lifecycle || this.#pendingRegistrations < 1) {\n\t\t\tthis.#finishPending(pending);\n\t\t\tthis.#pendingRegistrations -= 1;\n\t\t\tthrow new Error(\"Cannot create file monitor: monitor registry is disposed.\");\n\t\t}\n\t\tconst id = `watch_${this.#nextFileId++}`;\n\t\tlet watcher: FSWatcher;\n\t\ttry {\n\t\t\tconst activationParent = realpathWithoutOpen(parent);\n\t\t\tif (activationParent !== approvedParent) {\n\t\t\t\tthrow new Error(`Cannot watch file: parent directory changed during registration: ${parent}`);\n\t\t\t}\n\t\t\t// watch() opens the directory synchronously on this thread; prove the open completes on the\n\t\t\t// async pool first so a wedged mount fails at the registration deadline instead of freezing.\n\t\t\tawait this.#registrationAwait(pending, probeDirectoryOpenable(activationParent));\n\t\t\twatcher = watch(canonicalWatchPath(activationParent), (_kind, name) => {\n\t\t\t\tif (!name || basename(String(name)) === basename(path)) void this.#checkFile(id);\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tthis.#finishPending(pending);\n\t\t\tthis.#pendingRegistrations -= 1;\n\t\t\tthrow new Error(`Cannot watch file ${path}: ${error instanceof Error ? error.message : String(error)}`);\n\t\t}\n\t\tlet registrationError: string | undefined;\n\t\twatcher.on(\"error\", (error) => {\n\t\t\tregistrationError = `watcher error: ${error instanceof Error ? error.message : String(error)}`;\n\t\t\tconst record = this.#files.get(id);\n\t\t\tif (record) this.#settleFile(record, registrationError);\n\t\t});\n\t\tlet registrationCleaned = false;\n\t\tconst finishRegistration = () => {\n\t\t\tif (registrationCleaned) return;\n\t\t\tregistrationCleaned = true;\n\t\t\tthis.#pendingRegistrations -= 1;\n\t\t};\n\t\tconst cleanupRegistration = () => {\n\t\t\tif (registrationCleaned) return;\n\t\t\twatcher.close();\n\t\t\tfinishRegistration();\n\t\t\tthis.#finishPending(pending);\n\t\t};\n\t\tif (this.#disposed || lifecycle !== this.#lifecycle) {\n\t\t\tcleanupRegistration();\n\t\t\tthrow new Error(\"Cannot create file monitor: monitor registry is disposed.\");\n\t\t}\n\t\tconst canonicalPath = join(approvedParent, basename(path));\n\t\tlet digest: string;\n\t\ttry {\n\t\t\tdigest =\n\t\t\t\tinitial && initialHandle\n\t\t\t\t\t? await this.#registrationAwait(pending, this.#digestHandle(initialHandle, pending.abort.signal))\n\t\t\t\t\t: \"\";\n\t\t} catch (error) {\n\t\t\tcleanupRegistration();\n\t\t\tawait initialHandle?.close();\n\t\t\tinitialHandle = undefined;\n\t\t\tif (registrationError) {\n\t\t\t\tthis.#emit({ type: \"summary\", id, description: options.description, summary: registrationError });\n\t\t\t\tthrow new Error(registrationError);\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t\tawait initialHandle?.close();\n\t\tinitialHandle = undefined;\n\t\tif (registrationError) {\n\t\t\tcleanupRegistration();\n\t\t\tthis.#emit({ type: \"summary\", id, description: options.description, summary: registrationError });\n\t\t\tthrow new Error(registrationError);\n\t\t}\n\t\tif (this.#disposed || lifecycle !== this.#lifecycle) {\n\t\t\tcleanupRegistration();\n\t\t\tthrow new Error(\"Cannot create file monitor: monitor registry is disposed.\");\n\t\t}\n\t\tconst persistent = options.persistent ?? options.expiresAt !== undefined;\n\t\tconst record: FileMonitorRecord = {\n\t\t\tid,\n\t\t\tmonitorId: options.monitorId ?? allocateMonitorId(),\n\t\t\tsessionId: id,\n\t\t\tdescription: options.description,\n\t\t\tstartedAtMs: Date.now(),\n\t\t\tcommand: null,\n\t\t\tfilter: null,\n\t\t\tpersistent,\n\t\t\tdeadlineMs: persistent ? null : (options.deadlineMs ?? Date.now() + options.timeoutMs),\n\t\t\tfireCount: 0,\n\t\t\tlastFiredAtMs: null,\n\t\t\texpiresAt: options.expiresAt,\n\t\t\tpath,\n\t\t\tcanonicalPath,\n\t\t\tcanonicalParent: approvedParent,\n\t\t\tevent: options.event,\n\t\t\twatcher,\n\t\t\trelease: release ?? (() => {}),\n\t\t\twatch: new FileWatchLoop(() => void this.#checkFile(id)),\n\t\t\tpaused: false,\n\t\t\tsettled: false,\n\t\t\tpresent: initial !== null,\n\t\t\tmtimeMs: initial?.mtimeMs ?? 0,\n\t\t\tsize: initial?.size ?? 0,\n\t\t\tdigest,\n\t\t\tdevice: initial?.dev ?? 0,\n\t\t\tinode: initial?.ino ?? 0,\n\t\t\tpendingChange: false,\n\t\t\tdirty: false,\n\t\t\tdirtyPasses: 0,\n\t\t\tdirtyWindowStartedAt: 0,\n\t\t\tchecking: undefined,\n\t\t\tdeadline: persistent\n\t\t\t\t? undefined\n\t\t\t\t: setTimeout(() => {\n\t\t\t\t\t\tconst current = this.#files.get(id);\n\t\t\t\t\t\tif (current) this.#settleFile(current, \"watcher timed_out\");\n\t\t\t\t\t}, options.timeoutMs),\n\t\t};\n\t\tthis.#files.set(id, record);\n\t\tif (this.#parked) record.watch.pause();\n\t\tfinishRegistration();\n\t\tthis.#finishPending(pending, true);\n\t\tif (registrationError || this.#disposed || lifecycle !== this.#lifecycle) {\n\t\t\tthis.#settleFile(record, registrationError ?? \"watcher killed\");\n\t\t\tthrow new Error(registrationError ?? \"Cannot create file monitor: monitor registry is disposed.\");\n\t\t}\n\t\tthis.#notifyChange();\n\t\treturn { id, monitorId: record.monitorId };\n\t}\n\n\t/** Live identity tuple of one file watch; undefined when the id is not a live file watch. */\n\tfileCheckpoint(id: string) {\n\t\tconst r = this.#files.get(id);\n\t\treturn (\n\t\t\tr && { dev: r.device, ino: r.inode, size: r.size, mtimeMs: r.mtimeMs, digest: r.digest, present: r.present }\n\t\t);\n\t}\n\n\t/** Emit one restored-watch line through the SAME sink a live watch uses (coalescing, wake budget). */\n\temitFileLine(id: string, line: string): boolean {\n\t\treturn this.#files.has(id) && this.emitLine(id, line);\n\t}\n\n\t/** Inject one line into a live command or file watch's event stream (e.g. a restore notice). */\n\temitLine(id: string, line: string): boolean {\n\t\tconst record = this.#records.get(id) ?? this.#files.get(id);\n\t\tif (!record || record.settled) return false;\n\t\tthis.#emitForRecord(record, { type: \"line\", id: record.id, description: record.description, line });\n\t\treturn true;\n\t}\n\n\tasync stopFile(id: string): Promise<boolean> {\n\t\tconst record = this.#files.get(id);\n\t\tif (!record) return false;\n\t\tthis.#settleFile(record, \"watcher killed\");\n\t\treturn true;\n\t}\n\n\tasync stopAllFiles(): Promise<number> {\n\t\tthis.#lifecycle += 1;\n\t\tconst records = [...this.#files.values()];\n\t\tfor (const record of records) this.#settleFile(record, \"watcher killed\");\n\t\tfor (const pending of [...this.#pending]) this.#finishPending(pending);\n\t\treturn records.length;\n\t}\n\n\t#settleFile(record: FileMonitorRecord, summary: string): void {\n\t\tif (record.settled) return;\n\t\trecord.settled = true;\n\t\trecord.watch.stop();\n\t\tclearTimeout(record.deadline);\n\t\trecord.watcher.close();\n\t\trecord.release();\n\t\tthis.#files.delete(record.id);\n\t\tthis.#notifyChange();\n\t\tthis.#emitForRecord(record, { type: \"summary\", id: record.id, description: record.description, summary });\n\t\tconst reason =\n\t\t\tsummary === \"watcher timed_out\"\n\t\t\t\t? \"timeout\"\n\t\t\t\t: summary === \"watcher killed\"\n\t\t\t\t\t? \"killed\"\n\t\t\t\t\t: summary === \"watcher disposed\"\n\t\t\t\t\t\t? \"disposed\"\n\t\t\t\t\t\t: \"exit\";\n\t\tthis.#emitEnded(record, reason, null);\n\t}\n\n\tasync #checkFile(id: string): Promise<void> {\n\t\tconst record = this.#files.get(id);\n\t\tif (!record || record.settled || record.paused || this.#parked) return;\n\t\tif (record.checking) {\n\t\t\trecord.dirty = true;\n\t\t\treturn;\n\t\t}\n\t\trecord.checking = this.#checkFileImpl(record)\n\t\t\t.catch((error) => {\n\t\t\t\tif (!record.settled)\n\t\t\t\t\tthis.#settleFile(record, `watcher error: ${error instanceof Error ? error.message : String(error)}`);\n\t\t\t})\n\t\t\t.finally(() => {\n\t\t\t\trecord.checking = undefined;\n\t\t\t\tconst now = Date.now();\n\t\t\t\tif (now - record.dirtyWindowStartedAt >= 1_000) {\n\t\t\t\t\trecord.dirtyWindowStartedAt = now;\n\t\t\t\t\trecord.dirtyPasses = 0;\n\t\t\t\t}\n\t\t\t\tif (record.dirty && !record.settled && record.dirtyPasses < 1) {\n\t\t\t\t\trecord.dirty = false;\n\t\t\t\t\trecord.dirtyPasses += 1;\n\t\t\t\t\tvoid this.#checkFile(id);\n\t\t\t\t} else {\n\t\t\t\t\trecord.dirty = false;\n\t\t\t\t}\n\t\t\t});\n\t\treturn record.checking;\n\t}\n\n\tasync #checkFileImpl(record: FileMonitorRecord): Promise<void> {\n\t\tif (record.settled) return;\n\t\tlet current: Awaited<ReturnType<typeof stat>> | null = null;\n\t\tlet handle: FileHandle | undefined;\n\t\ttry {\n\t\t\tconst currentParent = realpathWithoutOpen(dirname(record.path));\n\t\t\tif (currentParent !== record.canonicalParent) {\n\t\t\t\tthis.#settleFile(record, `watcher error: monitored parent changed: ${dirname(record.path)}`);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst target = await lstat(record.canonicalPath);\n\t\t\tif (target.isSymbolicLink()) throw new Error(`Cannot watch file: target identity changed: ${record.path}`);\n\t\t\tconst resolvedTarget = realpathWithoutOpen(record.canonicalPath);\n\t\t\tif (resolvedTarget !== record.canonicalPath)\n\t\t\t\tthrow new Error(`Cannot watch file: target identity changed: ${record.path}`);\n\t\t\thandle = await open(record.canonicalPath, \"r\");\n\t\t\tconst opened = await handle.stat();\n\t\t\tif (!opened.isFile()) throw new Error(`Cannot watch file: target is not a regular file: ${record.path}`);\n\t\t\tif ((opened.dev !== record.device || opened.ino !== record.inode) && opened.nlink > 1)\n\t\t\t\tthrow new Error(`Cannot watch file: target identity changed: ${record.path}`);\n\t\t\tcurrent = opened;\n\t\t\tconst rebound = await lstat(record.canonicalPath);\n\t\t\tif (rebound.isSymbolicLink()) throw new Error(`Cannot watch file: target identity changed: ${record.path}`);\n\t\t\tconst reboundPath = await stat(record.canonicalPath);\n\t\t\tif (!reboundPath.isFile() || reboundPath.dev !== opened.dev || reboundPath.ino !== opened.ino)\n\t\t\t\tthrow new Error(`Cannot watch file: target identity changed: ${record.path}`);\n\t\t} catch (error) {\n\t\t\tawait handle?.close();\n\t\t\tif ((error as NodeJS.ErrnoException)?.code !== \"ENOENT\") {\n\t\t\t\tthis.#settleFile(record, `watcher error: ${error instanceof Error ? error.message : String(error)}`);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tconst present = current !== null;\n\t\tlet digest = \"\";\n\t\ttry {\n\t\t\tdigest = present && handle ? await this.#digestHandle(handle) : \"\";\n\t\t\tif (present && handle) {\n\t\t\t\tconst afterDigest = await stat(record.canonicalPath);\n\t\t\t\tconst opened = await handle.stat();\n\t\t\t\tif (afterDigest.dev !== opened.dev || afterDigest.ino !== opened.ino)\n\t\t\t\t\tthrow new Error(`Cannot watch file: target identity changed: ${record.path}`);\n\t\t\t}\n\t\t} finally {\n\t\t\tawait handle?.close();\n\t\t}\n\t\tconst changed =\n\t\t\trecord.event === \"create\"\n\t\t\t\t? !record.present && present\n\t\t\t\t: record.present &&\n\t\t\t\t\tpresent &&\n\t\t\t\t\t(current!.mtimeMs !== record.mtimeMs || current!.size !== record.size || digest !== record.digest);\n\t\trecord.pendingChange ||= changed;\n\t\tif (!record.present && current) {\n\t\t\trecord.device = current.dev;\n\t\t\trecord.inode = current.ino;\n\t\t}\n\t\trecord.present = present;\n\t\trecord.mtimeMs = current?.mtimeMs ?? 0;\n\t\trecord.size = current?.size ?? 0;\n\t\trecord.digest = digest;\n\t\tif (!record.pendingChange || record.paused || record.settled) return;\n\t\trecord.pendingChange = false;\n\t\tif (record.settled) return;\n\t\tthis.#emitForRecord(record, {\n\t\t\ttype: \"line\",\n\t\t\tid: record.id,\n\t\t\tdescription: record.description,\n\t\t\tline: `${record.event} ${record.path}`,\n\t\t});\n\t\tthis.#settleFile(record, \"watcher completed\");\n\t}\n\n\tregister(options: RegisterMonitorOptions): string {\n\t\tconst durable = options.durabilityClass !== undefined && options.durabilityClass !== \"ephemeral\";\n\t\tconst record: MonitorRecord = {\n\t\t\tid: options.id,\n\t\t\tmonitorId: options.monitorId ?? allocateMonitorId(),\n\t\t\tsessionId: options.id,\n\t\t\tdescription: options.description,\n\t\t\tstartedAtMs: Date.now(),\n\t\t\tcommand: options.command ?? null,\n\t\t\tpersistent: options.persistent ?? durable,\n\t\t\tdeadlineMs: (options.persistent ?? durable) ? null : (options.deadlineMs ?? null),\n\t\t\tfireCount: 0,\n\t\t\tlastFiredAtMs: null,\n\t\t\texpiresAt: options.expiresAt,\n\t\t\truntime: options.runtime,\n\t\t\tfilter: options.filter,\n\t\t\tlineBuffer: new MonitorLineBuffer(),\n\t\t\tmutedDropped: 0,\n\t\t\tpaused: false,\n\t\t\tsettled: false,\n\t\t\tfireWindow: durable ? { ...(options.fireWindow ?? { startMs: Date.now(), count: 0 }) } : undefined,\n\t\t\tunsubscribeOutput: undefined,\n\t\t\tunsubscribeExit: undefined,\n\t\t};\n\t\tthis.#records.set(record.id, record);\n\t\tthis.#notifyChange();\n\n\t\t// Runtime output is already bounded. Read what was produced before monitor registration,\n\t\t// then subscribe synchronously so a fast watcher cannot lose its first line.\n\t\tthis.#consume(record, record.runtime.fullOutput());\n\t\trecord.unsubscribeOutput = record.runtime.onOutput((chunk) => this.#consume(record, chunk));\n\t\trecord.unsubscribeExit = record.runtime.session.onExit(() => this.#settle(record));\n\t\tif (record.runtime.exited) this.#settle(record);\n\t\treturn record.monitorId;\n\t}\n\n\tpause(ids: readonly string[]): string[] {\n\t\tconst paused: string[] = [];\n\t\tfor (const id of ids) {\n\t\t\tconst record = this.#records.get(id) ?? this.#files.get(id);\n\t\t\tif (!record || record.paused) continue;\n\t\t\trecord.paused = true;\n\t\t\tif (\"watch\" in record) record.watch.pause();\n\t\t\tpaused.push(record.id);\n\t\t}\n\t\tif (paused.length > 0) this.#notifyChange();\n\t\treturn paused;\n\t}\n\n\tpauseAll(): string[] {\n\t\treturn this.pause([...this.#records.keys(), ...this.#files.keys()]);\n\t}\n\n\tresume(ids?: readonly string[]): MonitorResumeResult[] {\n\t\tconst candidates = ids ?? [...this.#records.keys(), ...this.#files.keys()];\n\t\tconst resumed: MonitorResumeResult[] = [];\n\t\tfor (const id of candidates) {\n\t\t\tconst record = this.#records.get(id) ?? this.#files.get(id);\n\t\t\tif (!record?.paused) continue;\n\t\t\trecord.paused = false;\n\t\t\tconst mutedDropped = \"mutedDropped\" in record ? record.mutedDropped : 0;\n\t\t\tif (\"mutedDropped\" in record) record.mutedDropped = 0;\n\t\t\t// A rearm (or any resume) restarts the rolling fire budget while keeping its window start.\n\t\t\tif (\"fireWindow\" in record && record.fireWindow !== undefined) record.fireWindow.count = 0;\n\t\t\tresumed.push({ id: record.id, mutedDropped });\n\t\t\tif (\"watch\" in record && !this.#parked) record.watch.resume();\n\t\t}\n\t\tif (resumed.length > 0) this.#notifyChange();\n\t\treturn resumed;\n\t}\n\n\tmutedDropped(id: string): number {\n\t\treturn this.#records.get(id)?.mutedDropped ?? 0;\n\t}\n\n\trearm(id: string): MonitorRearmResult {\n\t\tconst record = this.#records.get(id) ?? this.#files.get(id);\n\t\tif (!record) return \"not_found\";\n\t\tif (!record.paused) return \"not_paused\";\n\t\tthis.resume([id]);\n\t\treturn \"rearmed\";\n\t}\n\n\t/** Re-bind a persisted fire window onto the record for a durable monitor id (a restore re-arms the budget). */\n\tadoptFireWindow(monitorId: string, fireWindow: MonitorFireWindow): boolean {\n\t\tfor (const record of this.#records.values()) {\n\t\t\tif (record.monitorId !== monitorId) continue;\n\t\t\trecord.fireWindow = { ...fireWindow };\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tdispose(): void {\n\t\tthis.#disposed = true;\n\t\tthis.#lifecycle += 1;\n\t\tfor (const record of [...this.#records.values()]) this.#disposeRecord(record);\n\t\tfor (const record of this.#files.values()) this.#settleFile(record, \"watcher disposed\");\n\t\tfor (const pending of this.#pending) this.#finishPending(pending);\n\t\tthis.#records.clear();\n\t\tthis.#notifyChange();\n\t}\n\n\t#finishPending(pending: PendingFileRegistration, transfer = false): void {\n\t\tif (pending.settled) return;\n\t\tpending.settled = true;\n\t\tclearTimeout(pending.deadline);\n\t\tthis.#pending.delete(pending);\n\t\tif (transfer) pending.release = undefined;\n\t\telse {\n\t\t\tpending.abort.abort();\n\t\t\tpending.release?.();\n\t\t}\n\t}\n\n\tasync #registrationAwait<T>(\n\t\tpending: PendingFileRegistration,\n\t\toperation: Promise<T>,\n\t\tlateCleanup?: (value: T) => Promise<void>,\n\t): Promise<T> {\n\t\tif (pending.abort.signal.aborted) {\n\t\t\tvoid operation.then(\n\t\t\t\t(value) => lateCleanup?.(value),\n\t\t\t\t() => undefined,\n\t\t\t);\n\t\t\tthrow new Error(\"Cannot create file monitor: registration timed out or was disposed.\");\n\t\t}\n\t\tlet aborted = false;\n\t\tconst abort = new Promise<never>((_, reject) =>\n\t\t\tpending.abort.signal.addEventListener(\n\t\t\t\t\"abort\",\n\t\t\t\t() => {\n\t\t\t\t\taborted = true;\n\t\t\t\t\treject(new Error(\"Cannot create file monitor: registration timed out or was disposed.\"));\n\t\t\t\t},\n\t\t\t\t{ once: true },\n\t\t\t),\n\t\t);\n\t\tconst guarded = operation.then(\n\t\t\t(value) => {\n\t\t\t\tif (aborted) void lateCleanup?.(value);\n\t\t\t\treturn value;\n\t\t\t},\n\t\t\t(error) => {\n\t\t\t\tif (aborted) return undefined as T;\n\t\t\t\tthrow error;\n\t\t\t},\n\t\t);\n\t\treturn Promise.race([guarded, abort]);\n\t}\n\n\tasync #digestHandle(handle: FileHandle, signal?: AbortSignal): Promise<string> {\n\t\treturn digestFileHandle(handle, signal);\n\t}\n\n\t#notifyChange(): void {\n\t\tthis.#onChange?.(this.snapshot());\n\t}\n\n\t#consume(record: MonitorRecord, chunk: string): void {\n\t\tif (record.settled || chunk.length === 0) return;\n\t\tfor (const line of record.lineBuffer.append(chunk)) {\n\t\t\tconst matchesFilter = !record.filter || record.filter.test(line);\n\t\t\tif (!matchesFilter) continue;\n\t\t\tif (record.paused) {\n\t\t\t\trecord.mutedDropped += 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tthis.#emitForRecord(record, { type: \"line\", id: record.id, description: record.description, line });\n\t\t\tif (record.fireWindow !== undefined) {\n\t\t\t\tconst now = Date.now();\n\t\t\t\tif (now - record.fireWindow.startMs >= FIRE_BUDGET_WINDOW_MS)\n\t\t\t\t\trecord.fireWindow = { startMs: now, count: 0 };\n\t\t\t\trecord.fireWindow.count += 1;\n\t\t\t\tif (record.fireWindow.count >= DEFAULT_DURABLE_MONITOR_FIRE_BUDGET) {\n\t\t\t\t\trecord.paused = true;\n\t\t\t\t\tthis.#emitForRecord(record, {\n\t\t\t\t\t\ttype: \"summary\",\n\t\t\t\t\t\tid: record.id,\n\t\t\t\t\t\tdescription: record.description,\n\t\t\t\t\t\tsummary: FIRE_BUDGET_AUTO_MUTE_SUMMARY,\n\t\t\t\t\t});\n\t\t\t\t\tthis.#notifyChange();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t#settle(record: MonitorRecord): void {\n\t\tif (record.settled) return;\n\t\trecord.settled = true;\n\t\trecord.unsubscribeOutput?.();\n\t\trecord.unsubscribeExit?.();\n\t\tthis.#records.delete(record.id);\n\t\tthis.#notifyChange();\n\t\tconst status = describeExit(record.runtime) ?? \"exited\";\n\t\tconst code = record.runtime.exitResult?.exitCode;\n\t\tconst codeText = code === null || code === undefined ? \"\" : ` (exit code ${code})`;\n\t\tthis.#emitForRecord(record, {\n\t\t\ttype: \"summary\",\n\t\t\tid: record.id,\n\t\t\tdescription: record.description,\n\t\t\tsummary: `watcher ${status}${codeText}`,\n\t\t});\n\t\tconst exit = record.runtime.exitResult;\n\t\tthis.#emitEnded(record, exit?.timedOut ? \"timeout\" : exit?.cancelled ? \"killed\" : \"exit\", code ?? null);\n\t}\n\n\t#disposeRecord(record: MonitorRecord): void {\n\t\tif (record.settled) return;\n\t\trecord.settled = true;\n\t\trecord.unsubscribeOutput?.();\n\t\trecord.unsubscribeExit?.();\n\t\tthis.#records.delete(record.id);\n\t\tthis.#emitEnded(record, \"disposed\", null);\n\t}\n\n\t#emitForRecord(record: MonitorRecord | FileMonitorRecord, event: MonitorEvent): void {\n\t\trecord.fireCount += 1;\n\t\trecord.lastFiredAtMs = Date.now();\n\t\tthis.#emit(event);\n\t\tif (!record.settled) this.#onFire?.(this.snapshot());\n\t}\n\n\t#emitEnded(record: MonitorRecord | FileMonitorRecord, reason: MonitorEndedReason, exitCode: number | null): void {\n\t\tthis.#onEnded?.({\n\t\t\tid: record.id,\n\t\t\tdescription: record.description,\n\t\t\tstartedAtMs: record.startedAtMs,\n\t\t\tendedAtMs: Date.now(),\n\t\t\treason,\n\t\t\texitCode,\n\t\t\tfireCount: record.fireCount,\n\t\t});\n\t}\n}\n"]}
@@ -0,0 +1,11 @@
1
+ import type { ExtensionContext } from "../../types.ts";
2
+ /**
3
+ * Per-session persistence dir for the terminal lease, manifest and monitor state dirs; undefined
4
+ * when the context carries no durable session dir (SDK/in-memory sessions) or runs a one-shot
5
+ * `print`/`json` turn, which has no later generation to restore into.
6
+ */
7
+ export declare function terminalStateDir(ctx: ExtensionContext | undefined): string | undefined;
8
+ export declare function monitorStateDir(terminalDir: string, monitorId: string): string;
9
+ export declare function ensureMonitorStateDir(terminalDir: string, monitorId: string): Promise<string>;
10
+ export declare function removeMonitorStateDir(terminalDir: string, monitorId: string): Promise<void>;
11
+ //# sourceMappingURL=monitor-state-dir.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"monitor-state-dir.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/terminal/monitor-state-dir.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGvD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,gBAAgB,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAKtF;AAED,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAE9E;AAED,wBAAsB,qBAAqB,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAInG;AAED,wBAAsB,qBAAqB,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEjG"}
@@ -0,0 +1,28 @@
1
+ import { mkdir, rm } from "node:fs/promises";
2
+ import { isAbsolute, join } from "node:path";
3
+ import { NON_INTERACTIVE_MODES } from "./notify.js";
4
+ /**
5
+ * Per-session persistence dir for the terminal lease, manifest and monitor state dirs; undefined
6
+ * when the context carries no durable session dir (SDK/in-memory sessions) or runs a one-shot
7
+ * `print`/`json` turn, which has no later generation to restore into.
8
+ */
9
+ export function terminalStateDir(ctx) {
10
+ if (ctx !== undefined && NON_INTERACTIVE_MODES.has(ctx.mode))
11
+ return undefined;
12
+ const sessionDir = ctx?.sessionManager?.getSessionDir?.();
13
+ if (sessionDir === undefined || sessionDir.length === 0 || !isAbsolute(sessionDir))
14
+ return undefined;
15
+ return join(sessionDir, "extensions", "terminal");
16
+ }
17
+ export function monitorStateDir(terminalDir, monitorId) {
18
+ return join(terminalDir, "state", monitorId);
19
+ }
20
+ export async function ensureMonitorStateDir(terminalDir, monitorId) {
21
+ const dir = monitorStateDir(terminalDir, monitorId);
22
+ await mkdir(dir, { recursive: true, mode: 0o700 });
23
+ return dir;
24
+ }
25
+ export async function removeMonitorStateDir(terminalDir, monitorId) {
26
+ await rm(monitorStateDir(terminalDir, monitorId), { recursive: true, force: true });
27
+ }
28
+ //# sourceMappingURL=monitor-state-dir.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"monitor-state-dir.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/terminal/monitor-state-dir.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEpD;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,GAAiC;IACjE,IAAI,GAAG,KAAK,SAAS,IAAI,qBAAqB,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC;QAAE,OAAO,SAAS,CAAC;IAC/E,MAAM,UAAU,GAAG,GAAG,EAAE,cAAc,EAAE,aAAa,EAAE,EAAE,CAAC;IAC1D,IAAI,UAAU,KAAK,SAAS,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC;QAAE,OAAO,SAAS,CAAC;IACrG,OAAO,IAAI,CAAC,UAAU,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,WAAmB,EAAE,SAAiB;IACrE,OAAO,IAAI,CAAC,WAAW,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;AAC9C,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,WAAmB,EAAE,SAAiB;IACjF,MAAM,GAAG,GAAG,eAAe,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;IACpD,MAAM,KAAK,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IACnD,OAAO,GAAG,CAAC;AACZ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,WAAmB,EAAE,SAAiB;IACjF,MAAM,EAAE,CAAC,eAAe,CAAC,WAAW,EAAE,SAAS,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AACrF,CAAC","sourcesContent":["import { mkdir, rm } from \"node:fs/promises\";\nimport { isAbsolute, join } from \"node:path\";\nimport type { ExtensionContext } from \"../../types.ts\";\nimport { NON_INTERACTIVE_MODES } from \"./notify.ts\";\n\n/**\n * Per-session persistence dir for the terminal lease, manifest and monitor state dirs; undefined\n * when the context carries no durable session dir (SDK/in-memory sessions) or runs a one-shot\n * `print`/`json` turn, which has no later generation to restore into.\n */\nexport function terminalStateDir(ctx: ExtensionContext | undefined): string | undefined {\n\tif (ctx !== undefined && NON_INTERACTIVE_MODES.has(ctx.mode)) return undefined;\n\tconst sessionDir = ctx?.sessionManager?.getSessionDir?.();\n\tif (sessionDir === undefined || sessionDir.length === 0 || !isAbsolute(sessionDir)) return undefined;\n\treturn join(sessionDir, \"extensions\", \"terminal\");\n}\n\nexport function monitorStateDir(terminalDir: string, monitorId: string): string {\n\treturn join(terminalDir, \"state\", monitorId);\n}\n\nexport async function ensureMonitorStateDir(terminalDir: string, monitorId: string): Promise<string> {\n\tconst dir = monitorStateDir(terminalDir, monitorId);\n\tawait mkdir(dir, { recursive: true, mode: 0o700 });\n\treturn dir;\n}\n\nexport async function removeMonitorStateDir(terminalDir: string, monitorId: string): Promise<void> {\n\tawait rm(monitorStateDir(terminalDir, monitorId), { recursive: true, force: true });\n}\n"]}
@@ -0,0 +1,41 @@
1
+ import { type ChildProcessIdentity } from "./process-identity.ts";
2
+ export type OwnerVerdict = "confirmed" | "dead" | "unverifiable";
3
+ export interface ProcessEvidence {
4
+ readonly startedAtMs?: number;
5
+ /** The command line the OS reports for the pid, space-joined. */
6
+ readonly argv?: string;
7
+ /** Linux only: raw NUL-separated `/proc/<pid>/environ`. */
8
+ readonly environ?: string;
9
+ }
10
+ export interface OwnerProbes {
11
+ readonly platform?: NodeJS.Platform;
12
+ readonly isProcessAlive?: (pid: number) => boolean;
13
+ readonly readProcessEvidence?: (pid: number) => Promise<ProcessEvidence | undefined>;
14
+ readonly bootAtMs?: () => number;
15
+ }
16
+ export interface KillTreeOptions {
17
+ readonly graceMs?: number;
18
+ readonly isProcessAlive?: (pid: number) => boolean;
19
+ readonly kill?: (pid: number, signal: NodeJS.Signals) => void;
20
+ readonly wait?: (ms: number) => Promise<void>;
21
+ }
22
+ export interface ReapResult {
23
+ readonly action: "killed" | "already-dead" | "none";
24
+ readonly reason?: string;
25
+ }
26
+ /** Start instants further apart than this are different processes, even on the same pid. */
27
+ export declare const OWNER_START_TOLERANCE_MS = 2000;
28
+ export declare const DEFAULT_KILL_GRACE_MS = 1000;
29
+ export declare function isProcessAlive(pid: number): boolean;
30
+ /**
31
+ * A pid alone is never trusted: after a crash or reboot the OS recycles it, so killing on a bare
32
+ * pid match can take down an unrelated process. Ownership needs the pid alive on the same boot,
33
+ * the same start instant, and a per-platform content marker (env on Linux, argv elsewhere). A
34
+ * background session carries no monitor id in its environment, so it is matched by argv everywhere.
35
+ */
36
+ export declare function confirmOwner(runtime: ChildProcessIdentity, monitorId: string | undefined, probes?: OwnerProbes): Promise<OwnerVerdict>;
37
+ export declare function killTree(runtime: ChildProcessIdentity, options?: KillTreeOptions): Promise<{
38
+ action: "killed" | "already-dead";
39
+ }>;
40
+ export declare function reapBeforeRespawn(runtime: ChildProcessIdentity, monitorId: string, probes?: OwnerProbes & KillTreeOptions): Promise<ReapResult>;
41
+ //# sourceMappingURL=orphan-reaper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orphan-reaper.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/terminal/orphan-reaper.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,oBAAoB,EAA6B,MAAM,uBAAuB,CAAC;AAG7F,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,MAAM,GAAG,cAAc,CAAC;AAEjE,MAAM,WAAW,eAAe;IAC/B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,iEAAiE;IACjE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,2DAA2D;IAC3D,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,WAAW;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC;IACpC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;IACnD,QAAQ,CAAC,mBAAmB,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC,CAAC;IACrF,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,MAAM,CAAC;CACjC;AAED,MAAM,WAAW,eAAe;IAC/B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;IACnD,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,OAAO,KAAK,IAAI,CAAC;IAC9D,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9C;AAED,MAAM,WAAW,UAAU;IAC1B,QAAQ,CAAC,MAAM,EAAE,QAAQ,GAAG,cAAc,GAAG,MAAM,CAAC;IACpD,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,4FAA4F;AAC5F,eAAO,MAAM,wBAAwB,OAAQ,CAAC;AAC9C,eAAO,MAAM,qBAAqB,OAAQ,CAAC;AAQ3C,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAQnD;AAgDD;;;;;GAKG;AACH,wBAAsB,YAAY,CACjC,OAAO,EAAE,oBAAoB,EAC7B,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,MAAM,GAAE,WAAgB,GACtB,OAAO,CAAC,YAAY,CAAC,CAgBvB;AAED,wBAAsB,QAAQ,CAC7B,OAAO,EAAE,oBAAoB,EAC7B,OAAO,GAAE,eAAoB,GAC3B,OAAO,CAAC;IAAE,MAAM,EAAE,QAAQ,GAAG,cAAc,CAAA;CAAE,CAAC,CAmBhD;AAED,wBAAsB,iBAAiB,CACtC,OAAO,EAAE,oBAAoB,EAC7B,SAAS,EAAE,MAAM,EACjB,MAAM,GAAE,WAAW,GAAG,eAAoB,GACxC,OAAO,CAAC,UAAU,CAAC,CAMrB"}
@@ -0,0 +1,131 @@
1
+ import { execFile } from "node:child_process";
2
+ import { readFile } from "node:fs/promises";
3
+ import { processBootAtMs, sameBoot } from "./process-identity.js";
4
+ import { readProcessStartMs } from "./process-start-probe.js";
5
+ /** Start instants further apart than this are different processes, even on the same pid. */
6
+ export const OWNER_START_TOLERANCE_MS = 2_000;
7
+ export const DEFAULT_KILL_GRACE_MS = 1_000;
8
+ /** `ps -o lstart=` is always `Www Mmm dd hh:mm:ss yyyy`; the command follows. */
9
+ const LSTART_LENGTH = 24;
10
+ function errorCode(error) {
11
+ return typeof error === "object" && error !== null && "code" in error ? error.code : undefined;
12
+ }
13
+ export function isProcessAlive(pid) {
14
+ try {
15
+ process.kill(pid, 0);
16
+ return true;
17
+ }
18
+ catch (error) {
19
+ // EPERM: the pid exists but belongs to someone else - alive, and certainly not ours to kill.
20
+ return errorCode(error) !== "ESRCH";
21
+ }
22
+ }
23
+ function execText(command, args) {
24
+ return new Promise((resolve, reject) => {
25
+ const env = { ...process.env, LC_ALL: "C" };
26
+ execFile(command, [...args], { encoding: "utf8", timeout: 5_000, windowsHide: true, env }, (error, stdout) => {
27
+ if (error)
28
+ reject(error);
29
+ else
30
+ resolve(stdout);
31
+ });
32
+ });
33
+ }
34
+ async function readLinuxEvidence(pid) {
35
+ const [startedAtMs, environ, cmdline] = await Promise.all([
36
+ readProcessStartMs(pid),
37
+ readFile(`/proc/${pid}/environ`, "utf8"),
38
+ readFile(`/proc/${pid}/cmdline`, "utf8"),
39
+ ]);
40
+ return { startedAtMs, environ, argv: cmdline.split("\0").filter(Boolean).join(" ") };
41
+ }
42
+ async function readDarwinEvidence(pid) {
43
+ const text = (await execText("ps", ["-o", "lstart=,command=", "-p", String(pid)])).trim();
44
+ if (text.length <= LSTART_LENGTH)
45
+ return undefined;
46
+ return { startedAtMs: new Date(text.slice(0, LSTART_LENGTH)).getTime(), argv: text.slice(LSTART_LENGTH).trim() };
47
+ }
48
+ async function readWindowsEvidence(pid) {
49
+ const script = `Get-CimInstance Win32_Process -Filter "ProcessId=${pid}" | ForEach-Object { $_.CreationDate.ToUniversalTime().ToString('o') + '|' + $_.CommandLine }`;
50
+ const text = (await execText("powershell", ["-NoProfile", "-NonInteractive", "-Command", script])).trim();
51
+ const separator = text.indexOf("|");
52
+ if (separator < 0)
53
+ return undefined;
54
+ return { startedAtMs: new Date(text.slice(0, separator)).getTime(), argv: text.slice(separator + 1).trim() };
55
+ }
56
+ function defaultEvidenceReader(platform) {
57
+ if (platform === "linux")
58
+ return readLinuxEvidence;
59
+ if (platform === "darwin")
60
+ return readDarwinEvidence;
61
+ if (platform === "win32")
62
+ return readWindowsEvidence;
63
+ return async () => undefined;
64
+ }
65
+ function argvMatches(observed, argv) {
66
+ if (observed === undefined || argv.length === 0)
67
+ return false;
68
+ const command = argv[argv.length - 1] ?? "";
69
+ return observed.trim() === argv.join(" ") || (command.length > 0 && observed.includes(command));
70
+ }
71
+ /**
72
+ * A pid alone is never trusted: after a crash or reboot the OS recycles it, so killing on a bare
73
+ * pid match can take down an unrelated process. Ownership needs the pid alive on the same boot,
74
+ * the same start instant, and a per-platform content marker (env on Linux, argv elsewhere). A
75
+ * background session carries no monitor id in its environment, so it is matched by argv everywhere.
76
+ */
77
+ export async function confirmOwner(runtime, monitorId, probes = {}) {
78
+ const platform = probes.platform ?? process.platform;
79
+ try {
80
+ if (!sameBoot(runtime.bootAtMs, (probes.bootAtMs ?? processBootAtMs)()))
81
+ return "dead";
82
+ if (!(probes.isProcessAlive ?? isProcessAlive)(runtime.pid))
83
+ return "dead";
84
+ const evidence = await (probes.readProcessEvidence ?? defaultEvidenceReader(platform))(runtime.pid);
85
+ if (evidence?.startedAtMs === undefined || !Number.isFinite(evidence.startedAtMs))
86
+ return "unverifiable";
87
+ if (Math.abs(evidence.startedAtMs - runtime.startedAtMs) > OWNER_START_TOLERANCE_MS)
88
+ return "unverifiable";
89
+ const marked = platform === "linux" && monitorId !== undefined
90
+ ? (evidence.environ ?? "").split("\0").includes(`SENPI_MONITOR_ID=${monitorId}`)
91
+ : argvMatches(evidence.argv, runtime.argv);
92
+ return marked ? "confirmed" : "unverifiable";
93
+ }
94
+ catch {
95
+ return "unverifiable";
96
+ }
97
+ }
98
+ export async function killTree(runtime, options = {}) {
99
+ const kill = options.kill ?? ((pid, signal) => process.kill(pid, signal));
100
+ const wait = options.wait ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
101
+ const target = runtime.processGroupId !== undefined ? -runtime.processGroupId : runtime.pid;
102
+ try {
103
+ kill(target, "SIGTERM");
104
+ }
105
+ catch (error) {
106
+ if (errorCode(error) === "ESRCH")
107
+ return { action: "already-dead" };
108
+ throw error;
109
+ }
110
+ await wait(options.graceMs ?? DEFAULT_KILL_GRACE_MS);
111
+ if ((options.isProcessAlive ?? isProcessAlive)(runtime.pid)) {
112
+ try {
113
+ kill(target, "SIGKILL");
114
+ }
115
+ catch (error) {
116
+ if (errorCode(error) !== "ESRCH")
117
+ throw error;
118
+ }
119
+ }
120
+ return { action: "killed" };
121
+ }
122
+ export async function reapBeforeRespawn(runtime, monitorId, probes = {}) {
123
+ const verdict = await confirmOwner(runtime, monitorId, probes);
124
+ if (verdict === "dead")
125
+ return { action: "none" };
126
+ // win32 has no process groups to signal and no race-free way to act on a confirmation, so it only reports.
127
+ if (verdict === "confirmed" && (probes.platform ?? process.platform) !== "win32")
128
+ return killTree(runtime, probes);
129
+ return { action: "none", reason: `previous watcher pid ${runtime.pid} unverifiable` };
130
+ }
131
+ //# sourceMappingURL=orphan-reaper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orphan-reaper.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/terminal/orphan-reaper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAA6B,eAAe,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAC7F,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AA+B9D,4FAA4F;AAC5F,MAAM,CAAC,MAAM,wBAAwB,GAAG,KAAK,CAAC;AAC9C,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,CAAC;AAC3C,iFAAiF;AACjF,MAAM,aAAa,GAAG,EAAE,CAAC;AAEzB,SAAS,SAAS,CAAC,KAAc;IAChC,OAAO,OAA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AAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,wBAAwB,OAAO,CAAC,GAAG,eAAe,EAAE,CAAC;AACvF,CAAC","sourcesContent":["import { execFile } from \"node:child_process\";\nimport { readFile } from \"node:fs/promises\";\nimport { type ChildProcessIdentity, processBootAtMs, sameBoot } from \"./process-identity.ts\";\nimport { readProcessStartMs } from \"./process-start-probe.ts\";\n\nexport type OwnerVerdict = \"confirmed\" | \"dead\" | \"unverifiable\";\n\nexport interface ProcessEvidence {\n\treadonly startedAtMs?: number;\n\t/** The command line the OS reports for the pid, space-joined. */\n\treadonly argv?: string;\n\t/** Linux only: raw NUL-separated `/proc/<pid>/environ`. */\n\treadonly environ?: string;\n}\n\nexport interface OwnerProbes {\n\treadonly platform?: NodeJS.Platform;\n\treadonly isProcessAlive?: (pid: number) => boolean;\n\treadonly readProcessEvidence?: (pid: number) => Promise<ProcessEvidence | undefined>;\n\treadonly bootAtMs?: () => number;\n}\n\nexport interface KillTreeOptions {\n\treadonly graceMs?: number;\n\treadonly isProcessAlive?: (pid: number) => boolean;\n\treadonly kill?: (pid: number, signal: NodeJS.Signals) => void;\n\treadonly wait?: (ms: number) => Promise<void>;\n}\n\nexport interface ReapResult {\n\treadonly action: \"killed\" | \"already-dead\" | \"none\";\n\treadonly reason?: string;\n}\n\n/** Start instants further apart than this are different processes, even on the same pid. */\nexport const OWNER_START_TOLERANCE_MS = 2_000;\nexport const DEFAULT_KILL_GRACE_MS = 1_000;\n/** `ps -o lstart=` is always `Www Mmm dd hh:mm:ss yyyy`; the command follows. */\nconst LSTART_LENGTH = 24;\n\nfunction errorCode(error: unknown): unknown {\n\treturn typeof error === \"object\" && error !== null && \"code\" in error ? error.code : undefined;\n}\n\nexport function isProcessAlive(pid: number): boolean {\n\ttry {\n\t\tprocess.kill(pid, 0);\n\t\treturn true;\n\t} catch (error) {\n\t\t// EPERM: the pid exists but belongs to someone else - alive, and certainly not ours to kill.\n\t\treturn errorCode(error) !== \"ESRCH\";\n\t}\n}\n\nfunction execText(command: string, args: readonly string[]): Promise<string> {\n\treturn new Promise((resolve, reject) => {\n\t\tconst env = { ...process.env, LC_ALL: \"C\" };\n\t\texecFile(command, [...args], { encoding: \"utf8\", timeout: 5_000, windowsHide: true, env }, (error, stdout) => {\n\t\t\tif (error) reject(error);\n\t\t\telse resolve(stdout);\n\t\t});\n\t});\n}\n\nasync function readLinuxEvidence(pid: number): Promise<ProcessEvidence> {\n\tconst [startedAtMs, environ, cmdline] = await Promise.all([\n\t\treadProcessStartMs(pid),\n\t\treadFile(`/proc/${pid}/environ`, \"utf8\"),\n\t\treadFile(`/proc/${pid}/cmdline`, \"utf8\"),\n\t]);\n\treturn { startedAtMs, environ, argv: cmdline.split(\"\\0\").filter(Boolean).join(\" \") };\n}\n\nasync function readDarwinEvidence(pid: number): Promise<ProcessEvidence | undefined> {\n\tconst text = (await execText(\"ps\", [\"-o\", \"lstart=,command=\", \"-p\", String(pid)])).trim();\n\tif (text.length <= LSTART_LENGTH) return undefined;\n\treturn { startedAtMs: new Date(text.slice(0, LSTART_LENGTH)).getTime(), argv: text.slice(LSTART_LENGTH).trim() };\n}\n\nasync function readWindowsEvidence(pid: number): Promise<ProcessEvidence | undefined> {\n\tconst script = `Get-CimInstance Win32_Process -Filter \"ProcessId=${pid}\" | ForEach-Object { $_.CreationDate.ToUniversalTime().ToString('o') + '|' + $_.CommandLine }`;\n\tconst text = (await execText(\"powershell\", [\"-NoProfile\", \"-NonInteractive\", \"-Command\", script])).trim();\n\tconst separator = text.indexOf(\"|\");\n\tif (separator < 0) return undefined;\n\treturn { startedAtMs: new Date(text.slice(0, separator)).getTime(), argv: text.slice(separator + 1).trim() };\n}\n\nfunction defaultEvidenceReader(platform: NodeJS.Platform): (pid: number) => Promise<ProcessEvidence | undefined> {\n\tif (platform === \"linux\") return readLinuxEvidence;\n\tif (platform === \"darwin\") return readDarwinEvidence;\n\tif (platform === \"win32\") return readWindowsEvidence;\n\treturn async () => undefined;\n}\n\nfunction argvMatches(observed: string | undefined, argv: readonly string[]): boolean {\n\tif (observed === undefined || argv.length === 0) return false;\n\tconst command = argv[argv.length - 1] ?? \"\";\n\treturn observed.trim() === argv.join(\" \") || (command.length > 0 && observed.includes(command));\n}\n\n/**\n * A pid alone is never trusted: after a crash or reboot the OS recycles it, so killing on a bare\n * pid match can take down an unrelated process. Ownership needs the pid alive on the same boot,\n * the same start instant, and a per-platform content marker (env on Linux, argv elsewhere). A\n * background session carries no monitor id in its environment, so it is matched by argv everywhere.\n */\nexport async function confirmOwner(\n\truntime: ChildProcessIdentity,\n\tmonitorId: string | undefined,\n\tprobes: OwnerProbes = {},\n): Promise<OwnerVerdict> {\n\tconst platform = probes.platform ?? process.platform;\n\ttry {\n\t\tif (!sameBoot(runtime.bootAtMs, (probes.bootAtMs ?? processBootAtMs)())) return \"dead\";\n\t\tif (!(probes.isProcessAlive ?? isProcessAlive)(runtime.pid)) return \"dead\";\n\t\tconst evidence = await (probes.readProcessEvidence ?? defaultEvidenceReader(platform))(runtime.pid);\n\t\tif (evidence?.startedAtMs === undefined || !Number.isFinite(evidence.startedAtMs)) return \"unverifiable\";\n\t\tif (Math.abs(evidence.startedAtMs - runtime.startedAtMs) > OWNER_START_TOLERANCE_MS) return \"unverifiable\";\n\t\tconst marked =\n\t\t\tplatform === \"linux\" && monitorId !== undefined\n\t\t\t\t? (evidence.environ ?? \"\").split(\"\\0\").includes(`SENPI_MONITOR_ID=${monitorId}`)\n\t\t\t\t: argvMatches(evidence.argv, runtime.argv);\n\t\treturn marked ? \"confirmed\" : \"unverifiable\";\n\t} catch {\n\t\treturn \"unverifiable\";\n\t}\n}\n\nexport async function killTree(\n\truntime: ChildProcessIdentity,\n\toptions: KillTreeOptions = {},\n): Promise<{ action: \"killed\" | \"already-dead\" }> {\n\tconst kill = options.kill ?? ((pid: number, signal: NodeJS.Signals) => process.kill(pid, signal));\n\tconst wait = options.wait ?? ((ms: number) => new Promise<void>((resolve) => setTimeout(resolve, ms)));\n\tconst target = runtime.processGroupId !== undefined ? -runtime.processGroupId : runtime.pid;\n\ttry {\n\t\tkill(target, \"SIGTERM\");\n\t} catch (error) {\n\t\tif (errorCode(error) === \"ESRCH\") return { action: \"already-dead\" };\n\t\tthrow error;\n\t}\n\tawait wait(options.graceMs ?? DEFAULT_KILL_GRACE_MS);\n\tif ((options.isProcessAlive ?? isProcessAlive)(runtime.pid)) {\n\t\ttry {\n\t\t\tkill(target, \"SIGKILL\");\n\t\t} catch (error) {\n\t\t\tif (errorCode(error) !== \"ESRCH\") throw error;\n\t\t}\n\t}\n\treturn { action: \"killed\" };\n}\n\nexport async function reapBeforeRespawn(\n\truntime: ChildProcessIdentity,\n\tmonitorId: string,\n\tprobes: OwnerProbes & KillTreeOptions = {},\n): Promise<ReapResult> {\n\tconst verdict = await confirmOwner(runtime, monitorId, probes);\n\tif (verdict === \"dead\") return { action: \"none\" };\n\t// win32 has no process groups to signal and no race-free way to act on a confirmation, so it only reports.\n\tif (verdict === \"confirmed\" && (probes.platform ?? process.platform) !== \"win32\") return killTree(runtime, probes);\n\treturn { action: \"none\", reason: `previous watcher pid ${runtime.pid} unverifiable` };\n}\n"]}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Two boot instants further apart than this belong to different boots. `os.uptime()` is
3
+ * integral seconds on every platform, and a laptop's sleep is accounted in uptime, so the
4
+ * only drift left is sub-second rounding on either side.
5
+ */
6
+ export declare const BOOT_INSTANT_TOLERANCE_MS = 120000;
7
+ /** Two process start instants further apart than this are different processes (ps/lstart is second-precise). */
8
+ export declare const PROCESS_START_TOLERANCE_MS = 3000;
9
+ export declare function processBootAtMs(now?: () => number): number;
10
+ /** Floored like `ps -o lstart`, which truncates to the second: rounding up could land after now. */
11
+ export declare function ownProcessStartedAtMs(now?: () => number): number;
12
+ export declare function sameBoot(bootAtMs: number, otherBootAtMs: number | undefined): boolean;
13
+ export declare function sameProcessStart(startedAtMs: number, otherStartedAtMs: number | undefined): boolean;
14
+ export interface ChildProcessIdentity {
15
+ readonly pid: number;
16
+ readonly processGroupId?: number;
17
+ readonly startedAtMs: number;
18
+ readonly bootAtMs: number;
19
+ readonly argv: readonly string[];
20
+ }
21
+ //# sourceMappingURL=process-identity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"process-identity.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/terminal/process-identity.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,SAAU,CAAC;AAEjD,gHAAgH;AAChH,eAAO,MAAM,0BAA0B,OAAQ,CAAC;AAIhD,wBAAgB,eAAe,CAAC,GAAG,GAAE,MAAM,MAAiB,GAAG,MAAM,CAEpE;AAUD,oGAAoG;AACpG,wBAAgB,qBAAqB,CAAC,GAAG,CAAC,EAAE,MAAM,MAAM,GAAG,MAAM,CAEhE;AAED,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAGrF;AAED,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAGnG;AAED,MAAM,WAAW,oBAAoB;IACpC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;CACjC"}
@@ -0,0 +1,34 @@
1
+ import { uptime as osUptimeSeconds } from "node:os";
2
+ /**
3
+ * Two boot instants further apart than this belong to different boots. `os.uptime()` is
4
+ * integral seconds on every platform, and a laptop's sleep is accounted in uptime, so the
5
+ * only drift left is sub-second rounding on either side.
6
+ */
7
+ export const BOOT_INSTANT_TOLERANCE_MS = 120_000;
8
+ /** Two process start instants further apart than this are different processes (ps/lstart is second-precise). */
9
+ export const PROCESS_START_TOLERANCE_MS = 3_000;
10
+ const wholeSeconds = (ms) => Math.round(ms / 1000) * 1000;
11
+ export function processBootAtMs(now = Date.now) {
12
+ return wholeSeconds(now() - osUptimeSeconds() * 1000);
13
+ }
14
+ const floorToSecond = (ms) => Math.floor(ms / 1000) * 1000;
15
+ /**
16
+ * Captured once at load: `process.uptime()` runs on a monotonic clock that stops during a Linux
17
+ * suspend, so recomputing later would drift by every suspend and read our own live lease as reused.
18
+ */
19
+ const OWN_START_AT_LOAD = floorToSecond(Date.now() - process.uptime() * 1000);
20
+ /** Floored like `ps -o lstart`, which truncates to the second: rounding up could land after now. */
21
+ export function ownProcessStartedAtMs(now) {
22
+ return now === undefined ? OWN_START_AT_LOAD : floorToSecond(now() - process.uptime() * 1000);
23
+ }
24
+ export function sameBoot(bootAtMs, otherBootAtMs) {
25
+ if (otherBootAtMs === undefined || !Number.isFinite(otherBootAtMs))
26
+ return false;
27
+ return Math.abs(bootAtMs - otherBootAtMs) <= BOOT_INSTANT_TOLERANCE_MS;
28
+ }
29
+ export function sameProcessStart(startedAtMs, otherStartedAtMs) {
30
+ if (otherStartedAtMs === undefined || !Number.isFinite(otherStartedAtMs))
31
+ return false;
32
+ return Math.abs(startedAtMs - otherStartedAtMs) <= PROCESS_START_TOLERANCE_MS;
33
+ }
34
+ //# sourceMappingURL=process-identity.js.map