@bastani/atomic 0.10.1 → 0.10.2-alpha.1

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 (295) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/builtin/intercom/CHANGELOG.md +6 -0
  3. package/dist/builtin/intercom/broker/watchdog.ts +4 -0
  4. package/dist/builtin/intercom/package.json +1 -1
  5. package/dist/builtin/mcp/package.json +1 -1
  6. package/dist/builtin/subagents/CHANGELOG.md +16 -0
  7. package/dist/builtin/subagents/README.md +2 -0
  8. package/dist/builtin/subagents/package.json +1 -1
  9. package/dist/builtin/subagents/skills/subagent/SKILL.md +3 -3
  10. package/dist/builtin/subagents/src/extension/index.bundle.mjs +269 -144
  11. package/dist/builtin/web-access/CHANGELOG.md +7 -0
  12. package/dist/builtin/web-access/index.bundle.mjs +9 -5
  13. package/dist/builtin/web-access/package.json +1 -1
  14. package/dist/cli/list-models.d.ts.map +1 -1
  15. package/dist/cli/list-models.js +1 -14
  16. package/dist/cli/list-models.js.map +1 -1
  17. package/dist/core/agent-session-export.d.ts.map +1 -1
  18. package/dist/core/agent-session-export.js +13 -9
  19. package/dist/core/agent-session-export.js.map +1 -1
  20. package/dist/core/agent-session-message-queue.d.ts.map +1 -1
  21. package/dist/core/agent-session-message-queue.js +6 -3
  22. package/dist/core/agent-session-message-queue.js.map +1 -1
  23. package/dist/core/agent-session-methods.d.ts +3 -0
  24. package/dist/core/agent-session-methods.d.ts.map +1 -1
  25. package/dist/core/agent-session-methods.js.map +1 -1
  26. package/dist/core/agent-session-nested-tools.d.ts.map +1 -1
  27. package/dist/core/agent-session-nested-tools.js +2 -1
  28. package/dist/core/agent-session-nested-tools.js.map +1 -1
  29. package/dist/core/agent-session-prompt.d.ts.map +1 -1
  30. package/dist/core/agent-session-prompt.js +12 -0
  31. package/dist/core/agent-session-prompt.js.map +1 -1
  32. package/dist/core/agent-session-state.d.ts +6 -0
  33. package/dist/core/agent-session-state.d.ts.map +1 -1
  34. package/dist/core/agent-session-state.js +71 -4
  35. package/dist/core/agent-session-state.js.map +1 -1
  36. package/dist/core/agent-session-tool-hooks.d.ts.map +1 -1
  37. package/dist/core/agent-session-tool-hooks.js +9 -1
  38. package/dist/core/agent-session-tool-hooks.js.map +1 -1
  39. package/dist/core/agent-session-types.d.ts +2 -0
  40. package/dist/core/agent-session-types.d.ts.map +1 -1
  41. package/dist/core/agent-session-types.js.map +1 -1
  42. package/dist/core/agent-session.d.ts +3 -0
  43. package/dist/core/agent-session.d.ts.map +1 -1
  44. package/dist/core/agent-session.js +7 -0
  45. package/dist/core/agent-session.js.map +1 -1
  46. package/dist/core/cache-stats.d.ts +15 -0
  47. package/dist/core/cache-stats.d.ts.map +1 -1
  48. package/dist/core/cache-stats.js +40 -2
  49. package/dist/core/cache-stats.js.map +1 -1
  50. package/dist/core/diagnostic-writer.d.ts.map +1 -1
  51. package/dist/core/diagnostic-writer.js +2 -1
  52. package/dist/core/diagnostic-writer.js.map +1 -1
  53. package/dist/core/export-html/template.js +14 -4
  54. package/dist/core/extensions/context-types.d.ts +6 -0
  55. package/dist/core/extensions/context-types.d.ts.map +1 -1
  56. package/dist/core/extensions/context-types.js.map +1 -1
  57. package/dist/core/extensions/loader-api.d.ts.map +1 -1
  58. package/dist/core/extensions/loader-api.js +5 -2
  59. package/dist/core/extensions/loader-api.js.map +1 -1
  60. package/dist/core/queued-message-delivery.d.ts +100 -7
  61. package/dist/core/queued-message-delivery.d.ts.map +1 -1
  62. package/dist/core/queued-message-delivery.js +194 -4
  63. package/dist/core/queued-message-delivery.js.map +1 -1
  64. package/dist/core/resume-cache-checkpoint.d.ts +32 -0
  65. package/dist/core/resume-cache-checkpoint.d.ts.map +1 -0
  66. package/dist/core/resume-cache-checkpoint.js +67 -0
  67. package/dist/core/resume-cache-checkpoint.js.map +1 -0
  68. package/dist/core/sdk-types.d.ts +37 -0
  69. package/dist/core/sdk-types.d.ts.map +1 -1
  70. package/dist/core/sdk-types.js.map +1 -1
  71. package/dist/core/sdk.d.ts.map +1 -1
  72. package/dist/core/sdk.js +57 -28
  73. package/dist/core/sdk.js.map +1 -1
  74. package/dist/core/session-manager-core.d.ts.map +1 -1
  75. package/dist/core/session-manager-core.js +12 -3
  76. package/dist/core/session-manager-core.js.map +1 -1
  77. package/dist/core/session-manager-entries.d.ts +13 -0
  78. package/dist/core/session-manager-entries.d.ts.map +1 -1
  79. package/dist/core/session-manager-entries.js +38 -6
  80. package/dist/core/session-manager-entries.js.map +1 -1
  81. package/dist/core/settings-lock-directory.d.ts.map +1 -1
  82. package/dist/core/settings-lock-directory.js +2 -1
  83. package/dist/core/settings-lock-directory.js.map +1 -1
  84. package/dist/core/storage/node-sqlite-file-gate.d.ts +173 -0
  85. package/dist/core/storage/node-sqlite-file-gate.d.ts.map +1 -0
  86. package/dist/core/storage/node-sqlite-file-gate.js +1033 -0
  87. package/dist/core/storage/node-sqlite-file-gate.js.map +1 -0
  88. package/dist/core/storage/node-sqlite-thread.d.ts +33 -6
  89. package/dist/core/storage/node-sqlite-thread.d.ts.map +1 -1
  90. package/dist/core/storage/node-sqlite-thread.js +72 -2
  91. package/dist/core/storage/node-sqlite-thread.js.map +1 -1
  92. package/dist/core/storage/node-sqlite.d.ts.map +1 -1
  93. package/dist/core/storage/node-sqlite.js +216 -15
  94. package/dist/core/storage/node-sqlite.js.map +1 -1
  95. package/dist/core/storage/session/entry-structure.d.ts.map +1 -1
  96. package/dist/core/storage/session/entry-structure.js +39 -2
  97. package/dist/core/storage/session/entry-structure.js.map +1 -1
  98. package/dist/core/storage/session/session-resume.d.ts.map +1 -1
  99. package/dist/core/storage/session/session-resume.js +1 -0
  100. package/dist/core/storage/session/session-resume.js.map +1 -1
  101. package/dist/core/storage/session/session-search-index.d.ts.map +1 -1
  102. package/dist/core/storage/session/session-search-index.js +56 -9
  103. package/dist/core/storage/session/session-search-index.js.map +1 -1
  104. package/dist/core/storage/statement-sequence.d.ts +36 -0
  105. package/dist/core/storage/statement-sequence.d.ts.map +1 -0
  106. package/dist/core/storage/statement-sequence.js +22 -0
  107. package/dist/core/storage/statement-sequence.js.map +1 -0
  108. package/dist/core/system-prompt.d.ts.map +1 -1
  109. package/dist/core/system-prompt.js +13 -4
  110. package/dist/core/system-prompt.js.map +1 -1
  111. package/dist/core/tasks/heartbeat-notice.d.ts.map +1 -1
  112. package/dist/core/tasks/heartbeat-notice.js +2 -1
  113. package/dist/core/tasks/heartbeat-notice.js.map +1 -1
  114. package/dist/core/tool-loadout.d.ts +4 -2
  115. package/dist/core/tool-loadout.d.ts.map +1 -1
  116. package/dist/core/tool-loadout.js +27 -5
  117. package/dist/core/tool-loadout.js.map +1 -1
  118. package/dist/core/tools/history-regex-worker.d.ts.map +1 -1
  119. package/dist/core/tools/history-regex-worker.js +2 -1
  120. package/dist/core/tools/history-regex-worker.js.map +1 -1
  121. package/dist/core/tools/powershell.d.ts +22 -22
  122. package/dist/core/tools/sqlite-selector-connection.d.ts.map +1 -1
  123. package/dist/core/tools/sqlite-selector-connection.js +7 -0
  124. package/dist/core/tools/sqlite-selector-connection.js.map +1 -1
  125. package/dist/core/transformed-system-prompt.d.ts +92 -0
  126. package/dist/core/transformed-system-prompt.d.ts.map +1 -0
  127. package/dist/core/transformed-system-prompt.js +240 -0
  128. package/dist/core/transformed-system-prompt.js.map +1 -0
  129. package/dist/extensions/codemode/execute.js +1 -1
  130. package/dist/extensions/codemode/execute.js.map +1 -1
  131. package/dist/extensions/codemode/tool.d.ts.map +1 -1
  132. package/dist/extensions/codemode/tool.js +16 -3
  133. package/dist/extensions/codemode/tool.js.map +1 -1
  134. package/dist/extensions/llama/ui.d.ts.map +1 -1
  135. package/dist/extensions/llama/ui.js +13 -8
  136. package/dist/extensions/llama/ui.js.map +1 -1
  137. package/dist/extensions/mcp/config.d.ts +2 -0
  138. package/dist/extensions/mcp/config.d.ts.map +1 -1
  139. package/dist/extensions/mcp/config.js +5 -0
  140. package/dist/extensions/mcp/config.js.map +1 -1
  141. package/dist/extensions/mcp/index.d.ts +4 -0
  142. package/dist/extensions/mcp/index.d.ts.map +1 -1
  143. package/dist/extensions/mcp/index.js +289 -64
  144. package/dist/extensions/mcp/index.js.map +1 -1
  145. package/dist/extensions/mcp/runtime.d.ts +1 -1
  146. package/dist/extensions/mcp/runtime.d.ts.map +1 -1
  147. package/dist/extensions/mcp/runtime.js +2 -2
  148. package/dist/extensions/mcp/runtime.js.map +1 -1
  149. package/dist/extensions/mcp/tool-records.d.ts +58 -0
  150. package/dist/extensions/mcp/tool-records.d.ts.map +1 -0
  151. package/dist/extensions/mcp/tool-records.js +129 -0
  152. package/dist/extensions/mcp/tool-records.js.map +1 -0
  153. package/dist/index.d.ts +1 -0
  154. package/dist/index.d.ts.map +1 -1
  155. package/dist/index.js +1 -0
  156. package/dist/index.js.map +1 -1
  157. package/dist/modes/interactive/components/agent-panel.d.ts +2 -4
  158. package/dist/modes/interactive/components/agent-panel.d.ts.map +1 -1
  159. package/dist/modes/interactive/components/agent-panel.js +65 -80
  160. package/dist/modes/interactive/components/agent-panel.js.map +1 -1
  161. package/dist/modes/interactive/components/compaction-boundary-message.d.ts.map +1 -1
  162. package/dist/modes/interactive/components/compaction-boundary-message.js +3 -3
  163. package/dist/modes/interactive/components/compaction-boundary-message.js.map +1 -1
  164. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  165. package/dist/modes/interactive/components/footer.js +35 -28
  166. package/dist/modes/interactive/components/footer.js.map +1 -1
  167. package/dist/modes/interactive/components/notice-line.d.ts +16 -0
  168. package/dist/modes/interactive/components/notice-line.d.ts.map +1 -1
  169. package/dist/modes/interactive/components/notice-line.js +7 -0
  170. package/dist/modes/interactive/components/notice-line.js.map +1 -1
  171. package/dist/modes/interactive/components/prompt-slot.d.ts +1 -0
  172. package/dist/modes/interactive/components/prompt-slot.d.ts.map +1 -1
  173. package/dist/modes/interactive/components/prompt-slot.js +8 -4
  174. package/dist/modes/interactive/components/prompt-slot.js.map +1 -1
  175. package/dist/modes/interactive/components/task-board.d.ts +0 -1
  176. package/dist/modes/interactive/components/task-board.d.ts.map +1 -1
  177. package/dist/modes/interactive/components/task-board.js +6 -14
  178. package/dist/modes/interactive/components/task-board.js.map +1 -1
  179. package/dist/modes/interactive/components/task-row.d.ts.map +1 -1
  180. package/dist/modes/interactive/components/task-row.js +7 -6
  181. package/dist/modes/interactive/components/task-row.js.map +1 -1
  182. package/dist/modes/interactive/components/token-segment.d.ts +2 -1
  183. package/dist/modes/interactive/components/token-segment.d.ts.map +1 -1
  184. package/dist/modes/interactive/components/token-segment.js +2 -4
  185. package/dist/modes/interactive/components/token-segment.js.map +1 -1
  186. package/dist/modes/interactive/components/tree-selector-content.d.ts.map +1 -1
  187. package/dist/modes/interactive/components/tree-selector-content.js +2 -2
  188. package/dist/modes/interactive/components/tree-selector-content.js.map +1 -1
  189. package/dist/modes/interactive/components/working-run-meter.d.ts +0 -1
  190. package/dist/modes/interactive/components/working-run-meter.d.ts.map +1 -1
  191. package/dist/modes/interactive/components/working-run-meter.js +0 -9
  192. package/dist/modes/interactive/components/working-run-meter.js.map +1 -1
  193. package/dist/modes/interactive/extension-command-hold.d.ts +25 -0
  194. package/dist/modes/interactive/extension-command-hold.d.ts.map +1 -0
  195. package/dist/modes/interactive/extension-command-hold.js +45 -0
  196. package/dist/modes/interactive/extension-command-hold.js.map +1 -0
  197. package/dist/modes/interactive/interactive-agent-events.js +2 -1
  198. package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
  199. package/dist/modes/interactive/interactive-extension-context.js +18 -10
  200. package/dist/modes/interactive/interactive-extension-context.js.map +1 -1
  201. package/dist/modes/interactive/interactive-extension-custom-ui.js +3 -0
  202. package/dist/modes/interactive/interactive-extension-custom-ui.js.map +1 -1
  203. package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
  204. package/dist/modes/interactive/interactive-input-handling.js +54 -13
  205. package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
  206. package/dist/modes/interactive/interactive-model-routing.d.ts +6 -0
  207. package/dist/modes/interactive/interactive-model-routing.d.ts.map +1 -1
  208. package/dist/modes/interactive/interactive-model-routing.js +15 -9
  209. package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
  210. package/dist/modes/interactive/interactive-prompt-turn.js +4 -0
  211. package/dist/modes/interactive/interactive-prompt-turn.js.map +1 -1
  212. package/dist/modes/interactive/interactive-queueing.d.ts +7 -0
  213. package/dist/modes/interactive/interactive-queueing.d.ts.map +1 -1
  214. package/dist/modes/interactive/interactive-queueing.js +47 -1
  215. package/dist/modes/interactive/interactive-queueing.js.map +1 -1
  216. package/dist/modes/interactive/interactive-session-routing.js +6 -0
  217. package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
  218. package/dist/modes/interactive/interactive-slash-commands.js +165 -65
  219. package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
  220. package/dist/modes/interactive/screen-hold.d.ts +3 -0
  221. package/dist/modes/interactive/screen-hold.d.ts.map +1 -1
  222. package/dist/modes/interactive/screen-hold.js +9 -1
  223. package/dist/modes/interactive/screen-hold.js.map +1 -1
  224. package/dist/modes/interactive-engine/engine-health.d.ts +11 -3
  225. package/dist/modes/interactive-engine/engine-health.d.ts.map +1 -1
  226. package/dist/modes/interactive-engine/engine-health.js +5 -4
  227. package/dist/modes/interactive-engine/engine-health.js.map +1 -1
  228. package/dist/modes/interactive-engine/engine-quit-intent.d.ts +7 -0
  229. package/dist/modes/interactive-engine/engine-quit-intent.d.ts.map +1 -1
  230. package/dist/modes/interactive-engine/engine-quit-intent.js +19 -0
  231. package/dist/modes/interactive-engine/engine-quit-intent.js.map +1 -1
  232. package/dist/modes/interactive-engine/isolated-runtime.d.ts +18 -0
  233. package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
  234. package/dist/modes/interactive-engine/isolated-runtime.js +56 -4
  235. package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
  236. package/dist/modes/interactive-engine/protocol.d.ts +7 -0
  237. package/dist/modes/interactive-engine/protocol.d.ts.map +1 -1
  238. package/dist/modes/interactive-engine/protocol.js +1 -0
  239. package/dist/modes/interactive-engine/protocol.js.map +1 -1
  240. package/dist/modes/rpc/agent-panel-bridge.d.ts.map +1 -1
  241. package/dist/modes/rpc/agent-panel-bridge.js +0 -13
  242. package/dist/modes/rpc/agent-panel-bridge.js.map +1 -1
  243. package/dist/modes/rpc/rpc-client-process.d.ts +14 -1
  244. package/dist/modes/rpc/rpc-client-process.d.ts.map +1 -1
  245. package/dist/modes/rpc/rpc-client-process.js +74 -10
  246. package/dist/modes/rpc/rpc-client-process.js.map +1 -1
  247. package/dist/modes/rpc/rpc-client.d.ts +27 -1
  248. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  249. package/dist/modes/rpc/rpc-client.js +81 -5
  250. package/dist/modes/rpc/rpc-client.js.map +1 -1
  251. package/dist/modes/rpc/rpc-event-buffer.d.ts +2 -0
  252. package/dist/modes/rpc/rpc-event-buffer.d.ts.map +1 -1
  253. package/dist/modes/rpc/rpc-event-buffer.js +9 -0
  254. package/dist/modes/rpc/rpc-event-buffer.js.map +1 -1
  255. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  256. package/dist/modes/rpc/rpc-mode.js +16 -3
  257. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  258. package/dist/modes/rpc/rpc-session-binding.d.ts +7 -1
  259. package/dist/modes/rpc/rpc-session-binding.d.ts.map +1 -1
  260. package/dist/modes/rpc/rpc-session-binding.js +10 -2
  261. package/dist/modes/rpc/rpc-session-binding.js.map +1 -1
  262. package/dist/utils/image-resize.d.ts.map +1 -1
  263. package/dist/utils/image-resize.js +2 -1
  264. package/dist/utils/image-resize.js.map +1 -1
  265. package/dist/utils/interactive-engine-bootstrap.d.ts +2 -0
  266. package/dist/utils/interactive-engine-bootstrap.d.ts.map +1 -1
  267. package/dist/utils/interactive-engine-bootstrap.js +1 -0
  268. package/dist/utils/interactive-engine-bootstrap.js.map +1 -1
  269. package/dist/utils/interactive-engine-env.d.ts +2 -0
  270. package/dist/utils/interactive-engine-env.d.ts.map +1 -1
  271. package/dist/utils/interactive-engine-env.js +1 -0
  272. package/dist/utils/interactive-engine-env.js.map +1 -1
  273. package/dist/utils/shell.d.ts.map +1 -1
  274. package/dist/utils/shell.js +2 -0
  275. package/dist/utils/shell.js.map +1 -1
  276. package/dist/utils/token-count.d.ts +8 -0
  277. package/dist/utils/token-count.d.ts.map +1 -0
  278. package/dist/utils/token-count.js +25 -0
  279. package/dist/utils/token-count.js.map +1 -0
  280. package/dist/utils/worker-threads.d.ts +18 -0
  281. package/dist/utils/worker-threads.d.ts.map +1 -0
  282. package/dist/utils/worker-threads.js +28 -0
  283. package/dist/utils/worker-threads.js.map +1 -0
  284. package/docs/background-tasks.md +13 -12
  285. package/docs/compaction.md +2 -2
  286. package/docs/development.md +1 -1
  287. package/docs/extensions/api-reference.md +5 -3
  288. package/docs/extensions/events.md +2 -0
  289. package/docs/mcp-servers.md +1 -1
  290. package/docs/settings.md +2 -0
  291. package/docs/storage.md +3 -1
  292. package/docs/subagents.md +6 -2
  293. package/docs/usage.md +1 -1
  294. package/npm-shrinkwrap.json +49 -49
  295. package/package.json +6 -6
@@ -1 +1 @@
1
- {"version":3,"file":"shell.js","sourceRoot":"","sources":["../../src/utils/shell.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACrE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAqB,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,6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AAI,OAAO,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;YACnC,oFAAoF;YACpF,kFAAkF;YAClF,qFAAqF;YACrF,mFAAmF;YACnF,mFAAmF;YACnF,sFAAsF;YACtF,IAAI,CAAC;gBACJ,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;YAC/B,CAAC;YAAC,MAAM,CAAC;gBACR,kFAAkF;YACnF,CAAC;QACF,CAAC;QACD,gCAAgC;QAChC,IAAI,CAAC;YACJ,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;QAC/B,CAAC;QAAC,MAAM,CAAC;YACR,iEAAiE;YACjE,IAAI,CAAC;gBACJ,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;YAC9B,CAAC;YAAC,MAAM,CAAC;gBACR,uBAAuB;YACxB,CAAC;QACF,CAAC;IACF,CAAC;AACF,CAAC","sourcesContent":["import { accessSync, constants, lstatSync, statSync } from \"node:fs\";\nimport { lstat, stat } from \"node:fs/promises\";\nimport { delimiter, join, win32 } from \"node:path\";\nimport { Worker } from \"node:worker_threads\";\nimport { type ChildProcess, execFile, spawn, spawnSync } from \"child_process\";\nimport { getBinDir } from \"../config.js\";\nimport { createChildProcessEnvironment } from \"./child-process.ts\";\nimport { pathExists as shellPathExistsAsync } from \"./path-exists.ts\";\nimport { getGitShellEnvironment, getGitShellEnvironmentAsync } from \"./tools-manager.ts\";\n\nexport interface ShellConfig {\n\tshell: string;\n\targs: string[];\n\tcommandTransport?: \"argv\" | \"stdin\";\n}\n\nfunction isLegacyWslBashPath(path: string): boolean {\n\tconst normalized = win32.normalize(path).toLowerCase();\n\tconst systemRoot = process.env.SystemRoot;\n\tif (systemRoot) {\n\t\tif (!/^[a-z]:[\\\\/]/i.test(systemRoot)) return false;\n\t\treturn [\"System32\", \"Sysnative\"].some(\n\t\t\t(directory) => normalized === win32.join(systemRoot, directory, \"bash.exe\").toLowerCase(),\n\t\t);\n\t}\n\t// Fall back to conventional launcher paths only when the Windows directory is unknown.\n\treturn /^[a-z]:\\\\windows\\\\(?:system32|sysnative)\\\\bash\\.exe$/.test(normalized);\n}\n\nfunction getBashShellConfig(shell: string): ShellConfig {\n\treturn isLegacyWslBashPath(shell) ? { shell, args: [\"-s\"], commandTransport: \"stdin\" } : { shell, args: [\"-c\"] };\n}\n\n// On Unix this is identical to existsSync() (both are access(F_OK)), just\n// spelled with try/catch. On Windows we explicitly avoid existsSync(): its\n// extra stat check rejects runnable Store aliases (nodejs/node#36790).\nfunction shellPathExists(path: string): boolean {\n\ttry {\n\t\taccessSync(path, constants.F_OK);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nfunction isDirectoryEntry(path: string): boolean {\n\ttry {\n\t\tconst entry = lstatSync(path, { throwIfNoEntry: false });\n\t\tif (entry === undefined || entry.isFile()) return false;\n\t\tif (entry.isDirectory()) return true;\n\t\treturn entry.isSymbolicLink() && statSync(path, { throwIfNoEntry: false })?.isDirectory() === true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nfunction executableCandidateExists(path: string): boolean {\n\treturn shellPathExists(path) && !isDirectoryEntry(path);\n}\n\nasync function isDirectoryEntryAsync(path: string): Promise<boolean> {\n\ttry {\n\t\tconst entry = await lstat(path);\n\t\tif (entry.isFile()) return false;\n\t\tif (entry.isDirectory()) return true;\n\t\treturn entry.isSymbolicLink() && (await stat(path)).isDirectory();\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nasync function executableCandidateExistsAsync(path: string): Promise<boolean> {\n\treturn (await shellPathExistsAsync(path)) && !(await isDirectoryEntryAsync(path));\n}\n\nconst MISSING_EXECUTABLE_RECHECK_MS = 30_000;\n\ninterface ExecutableLookup {\n\tpath: string | null;\n\tcheckedAt: number;\n}\n\nconst executablePathLookups = new Map<string, ExecutableLookup>();\n\nfunction isReusableLookup(lookup: ExecutableLookup): boolean {\n\treturn lookup.path === null\n\t\t? Date.now() - lookup.checkedAt < MISSING_EXECUTABLE_RECHECK_MS\n\t\t: executableCandidateExists(lookup.path);\n}\n\nasync function isReusableLookupAsync(lookup: ExecutableLookup): Promise<boolean> {\n\treturn lookup.path === null\n\t\t? Date.now() - lookup.checkedAt < MISSING_EXECUTABLE_RECHECK_MS\n\t\t: executableCandidateExistsAsync(lookup.path);\n}\n\n/**\n * Find an executable on PATH (cross-platform), memoized per PATH value.\n * A missing executable is looked up again once its result is 30 seconds old.\n */\nfunction findExecutableOnPath(executable: string): string | null {\n\tconst key = `${executable}\\0${process.env.PATH ?? \"\"}\\0${process.cwd()}`;\n\tconst cached = executablePathLookups.get(key);\n\tif (cached && isReusableLookup(cached)) return cached.path;\n\tconst path = lookupExecutableOnPath(executable);\n\texecutablePathLookups.set(key, { path, checkedAt: Date.now() });\n\treturn path;\n}\n\nasync function findExecutableOnPathAsync(executable: string): Promise<string | null> {\n\tconst key = `${executable}\\0${process.env.PATH ?? \"\"}\\0${process.cwd()}`;\n\tconst cached = executablePathLookups.get(key);\n\tif (cached && (await isReusableLookupAsync(cached))) return cached.path;\n\tconst path = await lookupExecutableOnPathAsync(executable);\n\texecutablePathLookups.set(key, { path, checkedAt: Date.now() });\n\treturn path;\n}\n\nfunction scanWindowsPath(executable: string): string | null {\n\tconst extensions = win32.extname(executable)\n\t\t? [\"\"]\n\t\t: (process.env.PATHEXT ?? \".COM;.EXE;.BAT;.CMD\").split(\";\").filter(Boolean);\n\tfor (const entry of [process.cwd(), ...(process.env.PATH ?? \"\").split(win32.delimiter)]) {\n\t\tconst directory = entry.trim().replace(/^\"(.*)\"$/, \"$1\");\n\t\tif (!directory) continue;\n\t\tfor (const extension of extensions) {\n\t\t\tconst candidate = win32.resolve(process.cwd(), directory, `${executable}${extension}`);\n\t\t\tif (executableCandidateExists(candidate)) return candidate;\n\t\t}\n\t}\n\treturn null;\n}\n\nasync function scanWindowsPathAsync(executable: string): Promise<string | null> {\n\tconst extensions = win32.extname(executable)\n\t\t? [\"\"]\n\t\t: (process.env.PATHEXT ?? \".COM;.EXE;.BAT;.CMD\").split(\";\").filter(Boolean);\n\tfor (const entry of [process.cwd(), ...(process.env.PATH ?? \"\").split(win32.delimiter)]) {\n\t\tconst directory = entry.trim().replace(/^\"(.*)\"$/, \"$1\");\n\t\tif (!directory) continue;\n\t\tfor (const extension of extensions) {\n\t\t\tconst candidate = win32.resolve(process.cwd(), directory, `${executable}${extension}`);\n\t\t\tif (await executableCandidateExistsAsync(candidate)) return candidate;\n\t\t}\n\t}\n\treturn null;\n}\n\nfunction lookupExecutableOnPath(executable: string): string | null {\n\tif (process.platform === \"win32\") return scanWindowsPath(executable);\n\n\t// Unix: Use 'which' and trust its output (handles Termux and special filesystems)\n\ttry {\n\t\tconst result = spawnSync(\"which\", [executable], {\n\t\t\tencoding: \"utf-8\",\n\t\t\ttimeout: 5000,\n\t\t\tenv: createChildProcessEnvironment(),\n\t\t});\n\t\tif (result.status === 0 && result.stdout) {\n\t\t\tconst firstMatch = result.stdout.trim().split(/\\r?\\n/)[0];\n\t\t\tif (firstMatch) {\n\t\t\t\treturn firstMatch;\n\t\t\t}\n\t\t}\n\t} catch {\n\t\t// Ignore errors\n\t}\n\treturn null;\n}\n\nasync function lookupExecutableOnPathAsync(executable: string): Promise<string | null> {\n\tif (process.platform === \"win32\") return scanWindowsPathAsync(executable);\n\n\treturn new Promise((resolve) => {\n\t\ttry {\n\t\t\texecFile(\n\t\t\t\t\"which\",\n\t\t\t\t[executable],\n\t\t\t\t{\n\t\t\t\t\tencoding: \"utf-8\",\n\t\t\t\t\ttimeout: 5000,\n\t\t\t\t\tenv: createChildProcessEnvironment(),\n\t\t\t\t},\n\t\t\t\t(error, stdout) => {\n\t\t\t\t\tif (error !== null || !stdout) {\n\t\t\t\t\t\tresolve(null);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tconst firstMatch = String(stdout).trim().split(/\\r?\\n/)[0];\n\t\t\t\t\tresolve(firstMatch || null);\n\t\t\t\t},\n\t\t\t);\n\t\t} catch {\n\t\t\tresolve(null);\n\t\t}\n\t});\n}\n\n/**\n * Resolve shell configuration based on platform and an optional explicit shell path.\n * Resolution order:\n * 1. User-specified shellPath\n * 2. On Windows: Git Bash in known locations, then bash on PATH\n * 3. On Unix: /bin/bash, then bash on PATH, then fallback to sh\n */\nexport function getShellConfig(customShellPath?: string): ShellConfig {\n\t// 1. Check user-specified shell path\n\tif (customShellPath) {\n\t\tif (executableCandidateExists(customShellPath)) {\n\t\t\treturn getBashShellConfig(customShellPath);\n\t\t}\n\t\tthrow new Error(`Custom shell path not found: ${customShellPath}`);\n\t}\n\n\tif (process.platform === \"win32\") {\n\t\t// 2. Try Git Bash in known locations\n\t\tconst paths: string[] = [];\n\t\tconst programFiles = process.env.ProgramFiles;\n\t\tif (programFiles) {\n\t\t\tpaths.push(`${programFiles}\\\\Git\\\\bin\\\\bash.exe`);\n\t\t}\n\t\tconst programFilesX86 = process.env[\"ProgramFiles(x86)\"];\n\t\tif (programFilesX86) {\n\t\t\tpaths.push(`${programFilesX86}\\\\Git\\\\bin\\\\bash.exe`);\n\t\t}\n\n\t\tfor (const path of paths) {\n\t\t\tif (executableCandidateExists(path)) {\n\t\t\t\treturn getBashShellConfig(path);\n\t\t\t}\n\t\t}\n\n\t\t// 3. Fallback: search bash.exe on PATH (Cygwin, MSYS2, WSL, etc.)\n\t\tconst bashOnPath = findExecutableOnPath(\"bash.exe\");\n\t\tif (bashOnPath) {\n\t\t\treturn getBashShellConfig(bashOnPath);\n\t\t}\n\n\t\tthrow new Error(\n\t\t\t`No bash shell found. Options:\\n` +\n\t\t\t\t` 1. Install Git for Windows: https://git-scm.com/download/win\\n` +\n\t\t\t\t` 2. Add your bash to PATH (Cygwin, MSYS2, etc.)\\n` +\n\t\t\t\t\" 3. Set shellPath in settings.json\\n\\n\" +\n\t\t\t\t`Searched Git Bash in:\\n${paths.map((p) => ` ${p}`).join(\"\\n\")}`,\n\t\t);\n\t}\n\n\t// Unix: try /bin/bash, then bash on PATH, then fallback to sh\n\tif (executableCandidateExists(\"/bin/bash\")) {\n\t\treturn getBashShellConfig(\"/bin/bash\");\n\t}\n\n\tconst bashOnPath = findExecutableOnPath(\"bash\");\n\tif (bashOnPath) {\n\t\treturn getBashShellConfig(bashOnPath);\n\t}\n\n\treturn { shell: \"sh\", args: [\"-c\"] };\n}\n\nexport async function getShellConfigAsync(customShellPath?: string): Promise<ShellConfig> {\n\tif (customShellPath) {\n\t\tif (await executableCandidateExistsAsync(customShellPath)) {\n\t\t\treturn getBashShellConfig(customShellPath);\n\t\t}\n\t\tthrow new Error(`Custom shell path not found: ${customShellPath}`);\n\t}\n\n\tif (process.platform === \"win32\") {\n\t\tconst paths: string[] = [];\n\t\tconst programFiles = process.env.ProgramFiles;\n\t\tif (programFiles) {\n\t\t\tpaths.push(`${programFiles}\\\\Git\\\\bin\\\\bash.exe`);\n\t\t}\n\t\tconst programFilesX86 = process.env[\"ProgramFiles(x86)\"];\n\t\tif (programFilesX86) {\n\t\t\tpaths.push(`${programFilesX86}\\\\Git\\\\bin\\\\bash.exe`);\n\t\t}\n\n\t\tfor (const path of paths) {\n\t\t\tif (await executableCandidateExistsAsync(path)) {\n\t\t\t\treturn getBashShellConfig(path);\n\t\t\t}\n\t\t}\n\n\t\tconst bashOnPath = await findExecutableOnPathAsync(\"bash.exe\");\n\t\tif (bashOnPath) {\n\t\t\treturn getBashShellConfig(bashOnPath);\n\t\t}\n\n\t\tthrow new Error(\n\t\t\t`No bash shell found. Options:\\n` +\n\t\t\t\t` 1. Install Git for Windows: https://git-scm.com/download/win\\n` +\n\t\t\t\t` 2. Add your bash to PATH (Cygwin, MSYS2, etc.)\\n` +\n\t\t\t\t\" 3. Set shellPath in settings.json\\n\\n\" +\n\t\t\t\t`Searched Git Bash in:\\n${paths.map((p) => ` ${p}`).join(\"\\n\")}`,\n\t\t);\n\t}\n\n\tif (await executableCandidateExistsAsync(\"/bin/bash\")) {\n\t\treturn getBashShellConfig(\"/bin/bash\");\n\t}\n\n\tconst bashOnPath = await findExecutableOnPathAsync(\"bash\");\n\tif (bashOnPath) {\n\t\treturn getBashShellConfig(bashOnPath);\n\t}\n\n\treturn { shell: \"sh\", args: [\"-c\"] };\n}\n\nexport const POWERSHELL_ARGS = [\"-NoProfile\", \"-NonInteractive\", \"-ExecutionPolicy\", \"Bypass\", \"-Command\"] as const;\n\nexport function getPowerShellConfig(): ShellConfig {\n\tif (process.platform !== \"win32\") throw new Error(\"The powershell tool is only available on Windows.\");\n\tlet shell = findExecutableOnPath(\"pwsh.exe\");\n\t// Installation directories may be on any drive and need not be on PATH.\n\tconst programFiles = process.env.ProgramFiles;\n\tif (!shell && programFiles) {\n\t\tconst pwsh7 = win32.join(programFiles, \"PowerShell\", \"7\", \"pwsh.exe\");\n\t\tif (executableCandidateExists(pwsh7)) shell = pwsh7;\n\t}\n\n\tshell ??= findExecutableOnPath(\"powershell.exe\");\n\tconst systemRoot = process.env.SystemRoot;\n\tif (!shell && systemRoot) {\n\t\tconst windowsPowerShell = win32.join(systemRoot, \"System32\", \"WindowsPowerShell\", \"v1.0\", \"powershell.exe\");\n\t\tif (executableCandidateExists(windowsPowerShell)) shell = windowsPowerShell;\n\t}\n\n\tif (!shell) throw new Error(\"No PowerShell executable found. Install PowerShell or add it to PATH.\");\n\treturn { shell, args: [...POWERSHELL_ARGS] };\n}\n\nexport async function getPowerShellConfigAsync(): Promise<ShellConfig> {\n\tif (process.platform !== \"win32\") throw new Error(\"The powershell tool is only available on Windows.\");\n\tlet shell = await findExecutableOnPathAsync(\"pwsh.exe\");\n\tconst programFiles = process.env.ProgramFiles;\n\tif (!shell && programFiles) {\n\t\tconst pwsh7 = win32.join(programFiles, \"PowerShell\", \"7\", \"pwsh.exe\");\n\t\tif (await executableCandidateExistsAsync(pwsh7)) shell = pwsh7;\n\t}\n\n\tshell ??= await findExecutableOnPathAsync(\"powershell.exe\");\n\tconst systemRoot = process.env.SystemRoot;\n\tif (!shell && systemRoot) {\n\t\tconst windowsPowerShell = win32.join(systemRoot, \"System32\", \"WindowsPowerShell\", \"v1.0\", \"powershell.exe\");\n\t\tif (await executableCandidateExistsAsync(windowsPowerShell)) shell = windowsPowerShell;\n\t}\n\n\tif (!shell) throw new Error(\"No PowerShell executable found. Install PowerShell or add it to PATH.\");\n\treturn { shell, args: [...POWERSHELL_ARGS] };\n}\n\nexport function isPowerShellAvailable(): boolean {\n\ttry {\n\t\tgetPowerShellConfig();\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nexport async function isPowerShellAvailableAsync(): Promise<boolean> {\n\ttry {\n\t\tawait getPowerShellConfigAsync();\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nfunction buildShellEnv(\n\tgit: { readonly pathEntry: string; readonly env: Record<string, string> } | undefined,\n): NodeJS.ProcessEnv {\n\tconst binDir = getBinDir();\n\tconst pathKey = Object.keys(process.env).find((key) => key.toLowerCase() === \"path\") ?? \"PATH\";\n\tconst currentPath = process.env[pathKey] ?? \"\";\n\tconst pathEntries = currentPath.split(delimiter).filter(Boolean);\n\tconst additions = [...(git === undefined ? [] : [git.pathEntry]), binDir].filter(\n\t\t(entry) => !pathEntries.includes(entry),\n\t);\n\tconst updatedPath = [...additions, currentPath].filter(Boolean).join(delimiter);\n\n\treturn {\n\t\t...process.env,\n\t\t...git?.env,\n\t\t[pathKey]: updatedPath,\n\t};\n}\n\nexport function getShellEnv(): NodeJS.ProcessEnv {\n\treturn buildShellEnv(getGitShellEnvironment(process.env));\n}\n\nexport async function getShellEnvAsync(): Promise<NodeJS.ProcessEnv> {\n\treturn buildShellEnv(await getGitShellEnvironmentAsync(process.env));\n}\n\ninterface DetachedChildGuardian {\n\tpostMessage(message: { action: \"track\" | \"exited\" | \"untrack\"; pid: number }): void;\n\tterminate(): Promise<number>;\n\tunref(): void;\n}\n\nlet detachedChildGuardian: DetachedChildGuardian | undefined;\n\nconst PARENT_GUARDIAN_SOURCE = `\nconst { parentPort, workerData } = require(\"node:worker_threads\");\nconst { spawn } = require(\"node:child_process\");\nconst { existsSync } = require(\"node:fs\");\nconst { join } = require(\"node:path\");\nconst tracked = new Map();\nparentPort.on(\"message\", ({ action, pid }) => {\n if (action === \"track\") tracked.set(pid, false);\n else if (action === \"exited\") { if (tracked.has(pid)) tracked.set(pid, true); }\n else tracked.delete(pid);\n});\nfunction killTree(pid, exited) {\n if (process.platform === \"win32\") {\n if (exited) return;\n // Same System32 hardening as killProcessTree: PATH is not trusted here, and an\n // unconsumed async \"error\" from a failed spawn would take the guardian thread\n // down and leak every detached child it exists to reap.\n try {\n const child = spawn(join(process.env.SystemRoot || \"C:\\\\\\\\Windows\", \"System32\", \"taskkill.exe\"), [\"/F\", \"/T\", \"/PID\", String(pid)], { stdio: \"ignore\", detached: true, windowsHide: true, env: { ...process.env, AI_AGENT: workerData.aiAgent } });\n child.once(\"error\", () => {});\n } catch {}\n return;\n }\n try { process.kill(-pid, \"SIGKILL\"); }\n catch { if (!exited) { try { process.kill(pid, \"SIGKILL\"); } catch {} } }\n}\nconst timer = setInterval(() => {\n let parentAlive = true;\n try { process.kill(workerData.parentPid, 0); } catch { parentAlive = false; }\n if (parentAlive && (!workerData.stopFile || !existsSync(workerData.stopFile))) return;\n for (const [pid, exited] of tracked) killTree(pid, exited);\n killTree(process.pid, false);\n}, 50);\ntimer.unref?.();\n`;\n\nexport function startParentProcessGuardian(parentPid: number, stopFile?: string): () => Promise<void> {\n\tif (detachedChildGuardian) return async () => {};\n\tconst guardian = new Worker(PARENT_GUARDIAN_SOURCE, {\n\t\teval: true,\n\t\tworkerData: { parentPid, stopFile, aiAgent: createChildProcessEnvironment().AI_AGENT },\n\t});\n\tdetachedChildGuardian = guardian;\n\tfor (const [pid, exited] of trackedDetachedChildPids) {\n\t\tguardian.postMessage({ action: \"track\", pid });\n\t\tif (exited) guardian.postMessage({ action: \"exited\", pid });\n\t}\n\tguardian.unref();\n\treturn async () => {\n\t\tif (detachedChildGuardian !== guardian) return;\n\t\tdetachedChildGuardian = undefined;\n\t\tawait guardian.terminate();\n\t};\n}\n\n/**\n * Detached child processes must be tracked so they can be killed on parent\n * shutdown signals (SIGHUP/SIGTERM).\n */\nconst trackedDetachedChildPids = new Map<number, boolean>();\n\nexport function trackDetachedChildPid(pid: number): void {\n\ttrackedDetachedChildPids.set(pid, false);\n\tdetachedChildGuardian?.postMessage({ action: \"track\", pid });\n}\n\nexport function markDetachedChildExited(pid: number): void {\n\tif (!trackedDetachedChildPids.has(pid)) return;\n\ttrackedDetachedChildPids.set(pid, true);\n\tdetachedChildGuardian?.postMessage({ action: \"exited\", pid });\n}\n\nexport function untrackDetachedChildPid(pid: number): void {\n\ttrackedDetachedChildPids.delete(pid);\n\tdetachedChildGuardian?.postMessage({ action: \"untrack\", pid });\n}\n\nexport function killTrackedDetachedChildren(): void {\n\tfor (const [pid, exited] of trackedDetachedChildPids) {\n\t\tif (!exited) killProcessTree(pid);\n\t\telse if (process.platform !== \"win32\") {\n\t\t\ttry {\n\t\t\t\tprocess.kill(-pid, \"SIGKILL\");\n\t\t\t} catch {}\n\t\t}\n\t\tdetachedChildGuardian?.postMessage({ action: \"untrack\", pid });\n\t}\n\ttrackedDetachedChildPids.clear();\n}\n\n/**\n * Stops `child` and its descendants when no Job object contains them; `exited` says whether its exit was reported.\n * Once it was, the root's pid may already name another process: on POSIX only its process group, which lives on only\n * while its descendants do, is signalled, and on Windows nothing is killed by pid. While the root runs, its tree is\n * killed and then the root itself through its handle, which on Windows also ends a root that taskkill could not.\n * A child that never started (no pid) has nothing to kill: Node reports its failure as an `error` event, and on\n * Windows its `kill()` throws.\n */\nexport function killChildProcessTree(child: ChildProcess, exited: boolean): void {\n\tconst pid = child.pid;\n\tif (pid === undefined) return;\n\tif (pid === process.pid) {\n\t\tif (process.platform !== \"win32\") child.kill(\"SIGKILL\");\n\t\treturn;\n\t}\n\tif (process.platform === \"win32\") {\n\t\tif (exited) return;\n\t\ttaskkillTree(pid, () => {\n\t\t\tif (child.exitCode === null && child.signalCode === null) child.kill(\"SIGKILL\");\n\t\t});\n\t\treturn;\n\t}\n\tif (exited) {\n\t\ttry {\n\t\t\tprocess.kill(-pid, \"SIGKILL\");\n\t\t} catch {\n\t\t\t// No process is left in its group.\n\t\t}\n\t\treturn;\n\t}\n\tkillProcessTree(pid);\n\tchild.kill(\"SIGKILL\");\n}\n\nfunction taskkillTree(pid: number, settled?: () => void): void {\n\t// Use the trusted System32 executable so cleanup does not depend on PATH.\n\ttry {\n\t\tconst child = spawn(\n\t\t\tjoin(process.env.SystemRoot || \"C:\\\\Windows\", \"System32\", \"taskkill.exe\"),\n\t\t\t[\"/F\", \"/T\", \"/PID\", String(pid)],\n\t\t\t{\n\t\t\t\tstdio: \"ignore\",\n\t\t\t\tdetached: true,\n\t\t\t\t// `detached` gives the child its own console on Windows unless this is\n\t\t\t\t// set, so omitting it both flashes a window and pays for a console\n\t\t\t\t// allocation on every tree kill. Every other spawn in the fork sets it.\n\t\t\t\twindowsHide: true,\n\t\t\t\tenv: createChildProcessEnvironment(),\n\t\t\t},\n\t\t);\n\t\t// A failed spawn emits \"error\" asynchronously; consume it to avoid crashing Node.\n\t\tlet done = false;\n\t\tconst finish = () => {\n\t\t\tif (done) return;\n\t\t\tdone = true;\n\t\t\tsettled?.();\n\t\t};\n\t\tchild.once(\"error\", finish);\n\t\tchild.once(\"exit\", finish);\n\t} catch {\n\t\tsettled?.();\n\t}\n}\n\n/**\n * Kill a process and all its children (cross-platform)\n */\nexport function killProcessTree(pid: number): void {\n\tif (process.platform === \"win32\") {\n\t\ttaskkillTree(pid);\n\t} else {\n\t\tif (process.platform === \"darwin\") {\n\t\t\t// macOS signals group members individually after releasing the group lock. A killed\n\t\t\t// child can wake its waiting shell before that shell is signalled, letting `a; b`\n\t\t\t// start b during cancellation (pi #11252). Stop the group first to reduce this race;\n\t\t\t// this is best-effort, not an atomic freeze. SIGKILL also kills stopped processes.\n\t\t\t// Linux holds tasklist_lock across group signalling; child exit notification needs\n\t\t\t// its write lock, so the shell is signalled before observing the killed child's exit.\n\t\t\ttry {\n\t\t\t\tprocess.kill(-pid, \"SIGSTOP\");\n\t\t\t} catch {\n\t\t\t\t// A failed stop must not prevent the kill attempt or its single-process fallback.\n\t\t\t}\n\t\t}\n\t\t// Use SIGKILL on Unix/Linux/Mac\n\t\ttry {\n\t\t\tprocess.kill(-pid, \"SIGKILL\");\n\t\t} catch {\n\t\t\t// Fallback to killing just the child if process group kill fails\n\t\t\ttry {\n\t\t\t\tprocess.kill(pid, \"SIGKILL\");\n\t\t\t} catch {\n\t\t\t\t// Process already dead\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"shell.js","sourceRoot":"","sources":["../../src/utils/shell.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACrE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAqB,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAAE,UAAU,IAAI,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,sBAAsB,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAQzD,SAAS,mBAAmB,CAAC,IAAY;IACxC,MAAM,UAAU,GAAG,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;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AC;gBACR,kFAAkF;YACnF,CAAC;QACF,CAAC;QACD,gCAAgC;QAChC,IAAI,CAAC;YACJ,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;QAC/B,CAAC;QAAC,MAAM,CAAC;YACR,iEAAiE;YACjE,IAAI,CAAC;gBACJ,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;YAC9B,CAAC;YAAC,MAAM,CAAC;gBACR,uBAAuB;YACxB,CAAC;QACF,CAAC;IACF,CAAC;AACF,CAAC","sourcesContent":["import { accessSync, constants, lstatSync, statSync } from \"node:fs\";\nimport { lstat, stat } from \"node:fs/promises\";\nimport { delimiter, join, win32 } from \"node:path\";\nimport { Worker } from \"node:worker_threads\";\nimport { type ChildProcess, execFile, spawn, spawnSync } from \"child_process\";\nimport { getBinDir } from \"../config.js\";\nimport { createChildProcessEnvironment } from \"./child-process.ts\";\nimport { pathExists as shellPathExistsAsync } from \"./path-exists.ts\";\nimport { getGitShellEnvironment, getGitShellEnvironmentAsync } from \"./tools-manager.ts\";\nimport { evalWorkerExecArgv } from \"./worker-threads.js\";\n\nexport interface ShellConfig {\n\tshell: string;\n\targs: string[];\n\tcommandTransport?: \"argv\" | \"stdin\";\n}\n\nfunction isLegacyWslBashPath(path: string): boolean {\n\tconst normalized = win32.normalize(path).toLowerCase();\n\tconst systemRoot = process.env.SystemRoot;\n\tif (systemRoot) {\n\t\tif (!/^[a-z]:[\\\\/]/i.test(systemRoot)) return false;\n\t\treturn [\"System32\", \"Sysnative\"].some(\n\t\t\t(directory) => normalized === win32.join(systemRoot, directory, \"bash.exe\").toLowerCase(),\n\t\t);\n\t}\n\t// Fall back to conventional launcher paths only when the Windows directory is unknown.\n\treturn /^[a-z]:\\\\windows\\\\(?:system32|sysnative)\\\\bash\\.exe$/.test(normalized);\n}\n\nfunction getBashShellConfig(shell: string): ShellConfig {\n\treturn isLegacyWslBashPath(shell) ? { shell, args: [\"-s\"], commandTransport: \"stdin\" } : { shell, args: [\"-c\"] };\n}\n\n// On Unix this is identical to existsSync() (both are access(F_OK)), just\n// spelled with try/catch. On Windows we explicitly avoid existsSync(): its\n// extra stat check rejects runnable Store aliases (nodejs/node#36790).\nfunction shellPathExists(path: string): boolean {\n\ttry {\n\t\taccessSync(path, constants.F_OK);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nfunction isDirectoryEntry(path: string): boolean {\n\ttry {\n\t\tconst entry = lstatSync(path, { throwIfNoEntry: false });\n\t\tif (entry === undefined || entry.isFile()) return false;\n\t\tif (entry.isDirectory()) return true;\n\t\treturn entry.isSymbolicLink() && statSync(path, { throwIfNoEntry: false })?.isDirectory() === true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nfunction executableCandidateExists(path: string): boolean {\n\treturn shellPathExists(path) && !isDirectoryEntry(path);\n}\n\nasync function isDirectoryEntryAsync(path: string): Promise<boolean> {\n\ttry {\n\t\tconst entry = await lstat(path);\n\t\tif (entry.isFile()) return false;\n\t\tif (entry.isDirectory()) return true;\n\t\treturn entry.isSymbolicLink() && (await stat(path)).isDirectory();\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nasync function executableCandidateExistsAsync(path: string): Promise<boolean> {\n\treturn (await shellPathExistsAsync(path)) && !(await isDirectoryEntryAsync(path));\n}\n\nconst MISSING_EXECUTABLE_RECHECK_MS = 30_000;\n\ninterface ExecutableLookup {\n\tpath: string | null;\n\tcheckedAt: number;\n}\n\nconst executablePathLookups = new Map<string, ExecutableLookup>();\n\nfunction isReusableLookup(lookup: ExecutableLookup): boolean {\n\treturn lookup.path === null\n\t\t? Date.now() - lookup.checkedAt < MISSING_EXECUTABLE_RECHECK_MS\n\t\t: executableCandidateExists(lookup.path);\n}\n\nasync function isReusableLookupAsync(lookup: ExecutableLookup): Promise<boolean> {\n\treturn lookup.path === null\n\t\t? Date.now() - lookup.checkedAt < MISSING_EXECUTABLE_RECHECK_MS\n\t\t: executableCandidateExistsAsync(lookup.path);\n}\n\n/**\n * Find an executable on PATH (cross-platform), memoized per PATH value.\n * A missing executable is looked up again once its result is 30 seconds old.\n */\nfunction findExecutableOnPath(executable: string): string | null {\n\tconst key = `${executable}\\0${process.env.PATH ?? \"\"}\\0${process.cwd()}`;\n\tconst cached = executablePathLookups.get(key);\n\tif (cached && isReusableLookup(cached)) return cached.path;\n\tconst path = lookupExecutableOnPath(executable);\n\texecutablePathLookups.set(key, { path, checkedAt: Date.now() });\n\treturn path;\n}\n\nasync function findExecutableOnPathAsync(executable: string): Promise<string | null> {\n\tconst key = `${executable}\\0${process.env.PATH ?? \"\"}\\0${process.cwd()}`;\n\tconst cached = executablePathLookups.get(key);\n\tif (cached && (await isReusableLookupAsync(cached))) return cached.path;\n\tconst path = await lookupExecutableOnPathAsync(executable);\n\texecutablePathLookups.set(key, { path, checkedAt: Date.now() });\n\treturn path;\n}\n\nfunction scanWindowsPath(executable: string): string | null {\n\tconst extensions = win32.extname(executable)\n\t\t? [\"\"]\n\t\t: (process.env.PATHEXT ?? \".COM;.EXE;.BAT;.CMD\").split(\";\").filter(Boolean);\n\tfor (const entry of [process.cwd(), ...(process.env.PATH ?? \"\").split(win32.delimiter)]) {\n\t\tconst directory = entry.trim().replace(/^\"(.*)\"$/, \"$1\");\n\t\tif (!directory) continue;\n\t\tfor (const extension of extensions) {\n\t\t\tconst candidate = win32.resolve(process.cwd(), directory, `${executable}${extension}`);\n\t\t\tif (executableCandidateExists(candidate)) return candidate;\n\t\t}\n\t}\n\treturn null;\n}\n\nasync function scanWindowsPathAsync(executable: string): Promise<string | null> {\n\tconst extensions = win32.extname(executable)\n\t\t? [\"\"]\n\t\t: (process.env.PATHEXT ?? \".COM;.EXE;.BAT;.CMD\").split(\";\").filter(Boolean);\n\tfor (const entry of [process.cwd(), ...(process.env.PATH ?? \"\").split(win32.delimiter)]) {\n\t\tconst directory = entry.trim().replace(/^\"(.*)\"$/, \"$1\");\n\t\tif (!directory) continue;\n\t\tfor (const extension of extensions) {\n\t\t\tconst candidate = win32.resolve(process.cwd(), directory, `${executable}${extension}`);\n\t\t\tif (await executableCandidateExistsAsync(candidate)) return candidate;\n\t\t}\n\t}\n\treturn null;\n}\n\nfunction lookupExecutableOnPath(executable: string): string | null {\n\tif (process.platform === \"win32\") return scanWindowsPath(executable);\n\n\t// Unix: Use 'which' and trust its output (handles Termux and special filesystems)\n\ttry {\n\t\tconst result = spawnSync(\"which\", [executable], {\n\t\t\tencoding: \"utf-8\",\n\t\t\ttimeout: 5000,\n\t\t\tenv: createChildProcessEnvironment(),\n\t\t});\n\t\tif (result.status === 0 && result.stdout) {\n\t\t\tconst firstMatch = result.stdout.trim().split(/\\r?\\n/)[0];\n\t\t\tif (firstMatch) {\n\t\t\t\treturn firstMatch;\n\t\t\t}\n\t\t}\n\t} catch {\n\t\t// Ignore errors\n\t}\n\treturn null;\n}\n\nasync function lookupExecutableOnPathAsync(executable: string): Promise<string | null> {\n\tif (process.platform === \"win32\") return scanWindowsPathAsync(executable);\n\n\treturn new Promise((resolve) => {\n\t\ttry {\n\t\t\texecFile(\n\t\t\t\t\"which\",\n\t\t\t\t[executable],\n\t\t\t\t{\n\t\t\t\t\tencoding: \"utf-8\",\n\t\t\t\t\ttimeout: 5000,\n\t\t\t\t\tenv: createChildProcessEnvironment(),\n\t\t\t\t},\n\t\t\t\t(error, stdout) => {\n\t\t\t\t\tif (error !== null || !stdout) {\n\t\t\t\t\t\tresolve(null);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tconst firstMatch = String(stdout).trim().split(/\\r?\\n/)[0];\n\t\t\t\t\tresolve(firstMatch || null);\n\t\t\t\t},\n\t\t\t);\n\t\t} catch {\n\t\t\tresolve(null);\n\t\t}\n\t});\n}\n\n/**\n * Resolve shell configuration based on platform and an optional explicit shell path.\n * Resolution order:\n * 1. User-specified shellPath\n * 2. On Windows: Git Bash in known locations, then bash on PATH\n * 3. On Unix: /bin/bash, then bash on PATH, then fallback to sh\n */\nexport function getShellConfig(customShellPath?: string): ShellConfig {\n\t// 1. Check user-specified shell path\n\tif (customShellPath) {\n\t\tif (executableCandidateExists(customShellPath)) {\n\t\t\treturn getBashShellConfig(customShellPath);\n\t\t}\n\t\tthrow new Error(`Custom shell path not found: ${customShellPath}`);\n\t}\n\n\tif (process.platform === \"win32\") {\n\t\t// 2. Try Git Bash in known locations\n\t\tconst paths: string[] = [];\n\t\tconst programFiles = process.env.ProgramFiles;\n\t\tif (programFiles) {\n\t\t\tpaths.push(`${programFiles}\\\\Git\\\\bin\\\\bash.exe`);\n\t\t}\n\t\tconst programFilesX86 = process.env[\"ProgramFiles(x86)\"];\n\t\tif (programFilesX86) {\n\t\t\tpaths.push(`${programFilesX86}\\\\Git\\\\bin\\\\bash.exe`);\n\t\t}\n\n\t\tfor (const path of paths) {\n\t\t\tif (executableCandidateExists(path)) {\n\t\t\t\treturn getBashShellConfig(path);\n\t\t\t}\n\t\t}\n\n\t\t// 3. Fallback: search bash.exe on PATH (Cygwin, MSYS2, WSL, etc.)\n\t\tconst bashOnPath = findExecutableOnPath(\"bash.exe\");\n\t\tif (bashOnPath) {\n\t\t\treturn getBashShellConfig(bashOnPath);\n\t\t}\n\n\t\tthrow new Error(\n\t\t\t`No bash shell found. Options:\\n` +\n\t\t\t\t` 1. Install Git for Windows: https://git-scm.com/download/win\\n` +\n\t\t\t\t` 2. Add your bash to PATH (Cygwin, MSYS2, etc.)\\n` +\n\t\t\t\t\" 3. Set shellPath in settings.json\\n\\n\" +\n\t\t\t\t`Searched Git Bash in:\\n${paths.map((p) => ` ${p}`).join(\"\\n\")}`,\n\t\t);\n\t}\n\n\t// Unix: try /bin/bash, then bash on PATH, then fallback to sh\n\tif (executableCandidateExists(\"/bin/bash\")) {\n\t\treturn getBashShellConfig(\"/bin/bash\");\n\t}\n\n\tconst bashOnPath = findExecutableOnPath(\"bash\");\n\tif (bashOnPath) {\n\t\treturn getBashShellConfig(bashOnPath);\n\t}\n\n\treturn { shell: \"sh\", args: [\"-c\"] };\n}\n\nexport async function getShellConfigAsync(customShellPath?: string): Promise<ShellConfig> {\n\tif (customShellPath) {\n\t\tif (await executableCandidateExistsAsync(customShellPath)) {\n\t\t\treturn getBashShellConfig(customShellPath);\n\t\t}\n\t\tthrow new Error(`Custom shell path not found: ${customShellPath}`);\n\t}\n\n\tif (process.platform === \"win32\") {\n\t\tconst paths: string[] = [];\n\t\tconst programFiles = process.env.ProgramFiles;\n\t\tif (programFiles) {\n\t\t\tpaths.push(`${programFiles}\\\\Git\\\\bin\\\\bash.exe`);\n\t\t}\n\t\tconst programFilesX86 = process.env[\"ProgramFiles(x86)\"];\n\t\tif (programFilesX86) {\n\t\t\tpaths.push(`${programFilesX86}\\\\Git\\\\bin\\\\bash.exe`);\n\t\t}\n\n\t\tfor (const path of paths) {\n\t\t\tif (await executableCandidateExistsAsync(path)) {\n\t\t\t\treturn getBashShellConfig(path);\n\t\t\t}\n\t\t}\n\n\t\tconst bashOnPath = await findExecutableOnPathAsync(\"bash.exe\");\n\t\tif (bashOnPath) {\n\t\t\treturn getBashShellConfig(bashOnPath);\n\t\t}\n\n\t\tthrow new Error(\n\t\t\t`No bash shell found. Options:\\n` +\n\t\t\t\t` 1. Install Git for Windows: https://git-scm.com/download/win\\n` +\n\t\t\t\t` 2. Add your bash to PATH (Cygwin, MSYS2, etc.)\\n` +\n\t\t\t\t\" 3. Set shellPath in settings.json\\n\\n\" +\n\t\t\t\t`Searched Git Bash in:\\n${paths.map((p) => ` ${p}`).join(\"\\n\")}`,\n\t\t);\n\t}\n\n\tif (await executableCandidateExistsAsync(\"/bin/bash\")) {\n\t\treturn getBashShellConfig(\"/bin/bash\");\n\t}\n\n\tconst bashOnPath = await findExecutableOnPathAsync(\"bash\");\n\tif (bashOnPath) {\n\t\treturn getBashShellConfig(bashOnPath);\n\t}\n\n\treturn { shell: \"sh\", args: [\"-c\"] };\n}\n\nexport const POWERSHELL_ARGS = [\"-NoProfile\", \"-NonInteractive\", \"-ExecutionPolicy\", \"Bypass\", \"-Command\"] as const;\n\nexport function getPowerShellConfig(): ShellConfig {\n\tif (process.platform !== \"win32\") throw new Error(\"The powershell tool is only available on Windows.\");\n\tlet shell = findExecutableOnPath(\"pwsh.exe\");\n\t// Installation directories may be on any drive and need not be on PATH.\n\tconst programFiles = process.env.ProgramFiles;\n\tif (!shell && programFiles) {\n\t\tconst pwsh7 = win32.join(programFiles, \"PowerShell\", \"7\", \"pwsh.exe\");\n\t\tif (executableCandidateExists(pwsh7)) shell = pwsh7;\n\t}\n\n\tshell ??= findExecutableOnPath(\"powershell.exe\");\n\tconst systemRoot = process.env.SystemRoot;\n\tif (!shell && systemRoot) {\n\t\tconst windowsPowerShell = win32.join(systemRoot, \"System32\", \"WindowsPowerShell\", \"v1.0\", \"powershell.exe\");\n\t\tif (executableCandidateExists(windowsPowerShell)) shell = windowsPowerShell;\n\t}\n\n\tif (!shell) throw new Error(\"No PowerShell executable found. Install PowerShell or add it to PATH.\");\n\treturn { shell, args: [...POWERSHELL_ARGS] };\n}\n\nexport async function getPowerShellConfigAsync(): Promise<ShellConfig> {\n\tif (process.platform !== \"win32\") throw new Error(\"The powershell tool is only available on Windows.\");\n\tlet shell = await findExecutableOnPathAsync(\"pwsh.exe\");\n\tconst programFiles = process.env.ProgramFiles;\n\tif (!shell && programFiles) {\n\t\tconst pwsh7 = win32.join(programFiles, \"PowerShell\", \"7\", \"pwsh.exe\");\n\t\tif (await executableCandidateExistsAsync(pwsh7)) shell = pwsh7;\n\t}\n\n\tshell ??= await findExecutableOnPathAsync(\"powershell.exe\");\n\tconst systemRoot = process.env.SystemRoot;\n\tif (!shell && systemRoot) {\n\t\tconst windowsPowerShell = win32.join(systemRoot, \"System32\", \"WindowsPowerShell\", \"v1.0\", \"powershell.exe\");\n\t\tif (await executableCandidateExistsAsync(windowsPowerShell)) shell = windowsPowerShell;\n\t}\n\n\tif (!shell) throw new Error(\"No PowerShell executable found. Install PowerShell or add it to PATH.\");\n\treturn { shell, args: [...POWERSHELL_ARGS] };\n}\n\nexport function isPowerShellAvailable(): boolean {\n\ttry {\n\t\tgetPowerShellConfig();\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nexport async function isPowerShellAvailableAsync(): Promise<boolean> {\n\ttry {\n\t\tawait getPowerShellConfigAsync();\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nfunction buildShellEnv(\n\tgit: { readonly pathEntry: string; readonly env: Record<string, string> } | undefined,\n): NodeJS.ProcessEnv {\n\tconst binDir = getBinDir();\n\tconst pathKey = Object.keys(process.env).find((key) => key.toLowerCase() === \"path\") ?? \"PATH\";\n\tconst currentPath = process.env[pathKey] ?? \"\";\n\tconst pathEntries = currentPath.split(delimiter).filter(Boolean);\n\tconst additions = [...(git === undefined ? [] : [git.pathEntry]), binDir].filter(\n\t\t(entry) => !pathEntries.includes(entry),\n\t);\n\tconst updatedPath = [...additions, currentPath].filter(Boolean).join(delimiter);\n\n\treturn {\n\t\t...process.env,\n\t\t...git?.env,\n\t\t[pathKey]: updatedPath,\n\t};\n}\n\nexport function getShellEnv(): NodeJS.ProcessEnv {\n\treturn buildShellEnv(getGitShellEnvironment(process.env));\n}\n\nexport async function getShellEnvAsync(): Promise<NodeJS.ProcessEnv> {\n\treturn buildShellEnv(await getGitShellEnvironmentAsync(process.env));\n}\n\ninterface DetachedChildGuardian {\n\tpostMessage(message: { action: \"track\" | \"exited\" | \"untrack\"; pid: number }): void;\n\tterminate(): Promise<number>;\n\tunref(): void;\n}\n\nlet detachedChildGuardian: DetachedChildGuardian | undefined;\n\nconst PARENT_GUARDIAN_SOURCE = `\nconst { parentPort, workerData } = require(\"node:worker_threads\");\nconst { spawn } = require(\"node:child_process\");\nconst { existsSync } = require(\"node:fs\");\nconst { join } = require(\"node:path\");\nconst tracked = new Map();\nparentPort.on(\"message\", ({ action, pid }) => {\n if (action === \"track\") tracked.set(pid, false);\n else if (action === \"exited\") { if (tracked.has(pid)) tracked.set(pid, true); }\n else tracked.delete(pid);\n});\nfunction killTree(pid, exited) {\n if (process.platform === \"win32\") {\n if (exited) return;\n // Same System32 hardening as killProcessTree: PATH is not trusted here, and an\n // unconsumed async \"error\" from a failed spawn would take the guardian thread\n // down and leak every detached child it exists to reap.\n try {\n const child = spawn(join(process.env.SystemRoot || \"C:\\\\\\\\Windows\", \"System32\", \"taskkill.exe\"), [\"/F\", \"/T\", \"/PID\", String(pid)], { stdio: \"ignore\", detached: true, windowsHide: true, env: { ...process.env, AI_AGENT: workerData.aiAgent } });\n child.once(\"error\", () => {});\n } catch {}\n return;\n }\n try { process.kill(-pid, \"SIGKILL\"); }\n catch { if (!exited) { try { process.kill(pid, \"SIGKILL\"); } catch {} } }\n}\nconst timer = setInterval(() => {\n let parentAlive = true;\n try { process.kill(workerData.parentPid, 0); } catch { parentAlive = false; }\n if (parentAlive && (!workerData.stopFile || !existsSync(workerData.stopFile))) return;\n for (const [pid, exited] of tracked) killTree(pid, exited);\n killTree(process.pid, false);\n}, 50);\ntimer.unref?.();\n`;\n\nexport function startParentProcessGuardian(parentPid: number, stopFile?: string): () => Promise<void> {\n\tif (detachedChildGuardian) return async () => {};\n\tconst guardian = new Worker(PARENT_GUARDIAN_SOURCE, {\n\t\teval: true,\n\t\texecArgv: evalWorkerExecArgv(),\n\t\tworkerData: { parentPid, stopFile, aiAgent: createChildProcessEnvironment().AI_AGENT },\n\t});\n\tdetachedChildGuardian = guardian;\n\tfor (const [pid, exited] of trackedDetachedChildPids) {\n\t\tguardian.postMessage({ action: \"track\", pid });\n\t\tif (exited) guardian.postMessage({ action: \"exited\", pid });\n\t}\n\tguardian.unref();\n\treturn async () => {\n\t\tif (detachedChildGuardian !== guardian) return;\n\t\tdetachedChildGuardian = undefined;\n\t\tawait guardian.terminate();\n\t};\n}\n\n/**\n * Detached child processes must be tracked so they can be killed on parent\n * shutdown signals (SIGHUP/SIGTERM).\n */\nconst trackedDetachedChildPids = new Map<number, boolean>();\n\nexport function trackDetachedChildPid(pid: number): void {\n\ttrackedDetachedChildPids.set(pid, false);\n\tdetachedChildGuardian?.postMessage({ action: \"track\", pid });\n}\n\nexport function markDetachedChildExited(pid: number): void {\n\tif (!trackedDetachedChildPids.has(pid)) return;\n\ttrackedDetachedChildPids.set(pid, true);\n\tdetachedChildGuardian?.postMessage({ action: \"exited\", pid });\n}\n\nexport function untrackDetachedChildPid(pid: number): void {\n\ttrackedDetachedChildPids.delete(pid);\n\tdetachedChildGuardian?.postMessage({ action: \"untrack\", pid });\n}\n\nexport function killTrackedDetachedChildren(): void {\n\tfor (const [pid, exited] of trackedDetachedChildPids) {\n\t\tif (!exited) killProcessTree(pid);\n\t\telse if (process.platform !== \"win32\") {\n\t\t\ttry {\n\t\t\t\tprocess.kill(-pid, \"SIGKILL\");\n\t\t\t} catch {}\n\t\t}\n\t\tdetachedChildGuardian?.postMessage({ action: \"untrack\", pid });\n\t}\n\ttrackedDetachedChildPids.clear();\n}\n\n/**\n * Stops `child` and its descendants when no Job object contains them; `exited` says whether its exit was reported.\n * Once it was, the root's pid may already name another process: on POSIX only its process group, which lives on only\n * while its descendants do, is signalled, and on Windows nothing is killed by pid. While the root runs, its tree is\n * killed and then the root itself through its handle, which on Windows also ends a root that taskkill could not.\n * A child that never started (no pid) has nothing to kill: Node reports its failure as an `error` event, and on\n * Windows its `kill()` throws.\n */\nexport function killChildProcessTree(child: ChildProcess, exited: boolean): void {\n\tconst pid = child.pid;\n\tif (pid === undefined) return;\n\tif (pid === process.pid) {\n\t\tif (process.platform !== \"win32\") child.kill(\"SIGKILL\");\n\t\treturn;\n\t}\n\tif (process.platform === \"win32\") {\n\t\tif (exited) return;\n\t\ttaskkillTree(pid, () => {\n\t\t\tif (child.exitCode === null && child.signalCode === null) child.kill(\"SIGKILL\");\n\t\t});\n\t\treturn;\n\t}\n\tif (exited) {\n\t\ttry {\n\t\t\tprocess.kill(-pid, \"SIGKILL\");\n\t\t} catch {\n\t\t\t// No process is left in its group.\n\t\t}\n\t\treturn;\n\t}\n\tkillProcessTree(pid);\n\tchild.kill(\"SIGKILL\");\n}\n\nfunction taskkillTree(pid: number, settled?: () => void): void {\n\t// Use the trusted System32 executable so cleanup does not depend on PATH.\n\ttry {\n\t\tconst child = spawn(\n\t\t\tjoin(process.env.SystemRoot || \"C:\\\\Windows\", \"System32\", \"taskkill.exe\"),\n\t\t\t[\"/F\", \"/T\", \"/PID\", String(pid)],\n\t\t\t{\n\t\t\t\tstdio: \"ignore\",\n\t\t\t\tdetached: true,\n\t\t\t\t// `detached` gives the child its own console on Windows unless this is\n\t\t\t\t// set, so omitting it both flashes a window and pays for a console\n\t\t\t\t// allocation on every tree kill. Every other spawn in the fork sets it.\n\t\t\t\twindowsHide: true,\n\t\t\t\tenv: createChildProcessEnvironment(),\n\t\t\t},\n\t\t);\n\t\t// A failed spawn emits \"error\" asynchronously; consume it to avoid crashing Node.\n\t\tlet done = false;\n\t\tconst finish = () => {\n\t\t\tif (done) return;\n\t\t\tdone = true;\n\t\t\tsettled?.();\n\t\t};\n\t\tchild.once(\"error\", finish);\n\t\tchild.once(\"exit\", finish);\n\t} catch {\n\t\tsettled?.();\n\t}\n}\n\n/**\n * Kill a process and all its children (cross-platform)\n */\nexport function killProcessTree(pid: number): void {\n\tif (process.platform === \"win32\") {\n\t\ttaskkillTree(pid);\n\t} else {\n\t\tif (process.platform === \"darwin\") {\n\t\t\t// macOS signals group members individually after releasing the group lock. A killed\n\t\t\t// child can wake its waiting shell before that shell is signalled, letting `a; b`\n\t\t\t// start b during cancellation (pi #11252). Stop the group first to reduce this race;\n\t\t\t// this is best-effort, not an atomic freeze. SIGKILL also kills stopped processes.\n\t\t\t// Linux holds tasklist_lock across group signalling; child exit notification needs\n\t\t\t// its write lock, so the shell is signalled before observing the killed child's exit.\n\t\t\ttry {\n\t\t\t\tprocess.kill(-pid, \"SIGSTOP\");\n\t\t\t} catch {\n\t\t\t\t// A failed stop must not prevent the kill attempt or its single-process fallback.\n\t\t\t}\n\t\t}\n\t\t// Use SIGKILL on Unix/Linux/Mac\n\t\ttry {\n\t\t\tprocess.kill(-pid, \"SIGKILL\");\n\t\t} catch {\n\t\t\t// Fallback to killing just the child if process group kill fails\n\t\t\ttry {\n\t\t\t\tprocess.kill(pid, \"SIGKILL\");\n\t\t\t} catch {\n\t\t\t\t// Process already dead\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * A token count as every view shows it: the whole count below 1,000, then one decimal and a unit, as in "1.0k",
3
+ * "248.6k", "1.2M", "1.0B" and "1.0T". Thousands use a lowercase "k" and larger units an uppercase letter, so a count
4
+ * never ends in an "m" that reads as minutes beside an elapsed time. A count that rounds to 1000.0 of a unit shows as
5
+ * 1.0 of the next one: 999,950 is "1.0M". Fractional counts round to whole tokens; a negative or non-finite count is "0".
6
+ */
7
+ export declare function formatTokenCount(count: number): string;
8
+ //# sourceMappingURL=token-count.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token-count.d.ts","sourceRoot":"","sources":["../../src/utils/token-count.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAetD"}
@@ -0,0 +1,25 @@
1
+ const TOKEN_COUNT_UNITS = ["k", "M", "B", "T", "Q"];
2
+ /**
3
+ * A token count as every view shows it: the whole count below 1,000, then one decimal and a unit, as in "1.0k",
4
+ * "248.6k", "1.2M", "1.0B" and "1.0T". Thousands use a lowercase "k" and larger units an uppercase letter, so a count
5
+ * never ends in an "m" that reads as minutes beside an elapsed time. A count that rounds to 1000.0 of a unit shows as
6
+ * 1.0 of the next one: 999,950 is "1.0M". Fractional counts round to whole tokens; a negative or non-finite count is "0".
7
+ */
8
+ export function formatTokenCount(count) {
9
+ // A JavaScript caller can pass a numeric string such as "1500"; any other non-number is malformed.
10
+ const input = count;
11
+ const value = typeof input === "number" || typeof input === "string" ? Number(input) : Number.NaN;
12
+ const tokens = Number.isFinite(value) ? Math.max(0, Math.round(value)) : 0;
13
+ if (tokens < 1000)
14
+ return String(tokens);
15
+ let unit = 0;
16
+ let tenthStep = 100;
17
+ let tenths = Math.round(tokens / tenthStep);
18
+ while (tenths >= 10_000 && unit < TOKEN_COUNT_UNITS.length - 1) {
19
+ unit++;
20
+ tenthStep *= 1000;
21
+ tenths = Math.round(tokens / tenthStep);
22
+ }
23
+ return `${Math.floor(tenths / 10)}.${tenths % 10}${TOKEN_COUNT_UNITS[unit]}`;
24
+ }
25
+ //# sourceMappingURL=token-count.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token-count.js","sourceRoot":"","sources":["../../src/utils/token-count.ts"],"names":[],"mappings":"AAAA,MAAM,iBAAiB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAU,CAAC;AAE7D;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC7C,mGAAmG;IACnG,MAAM,KAAK,GAAG,KAAwB,CAAC;IACvC,MAAM,KAAK,GAAG,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;IAClG,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3E,IAAI,MAAM,GAAG,IAAI;QAAE,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC;IACzC,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,IAAI,SAAS,GAAG,GAAG,CAAC;IACpB,IAAI,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAC5C,OAAO,MAAM,IAAI,MAAM,IAAI,IAAI,GAAG,iBAAiB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAChE,IAAI,EAAE,CAAC;QACP,SAAS,IAAI,IAAI,CAAC;QAClB,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,EAAE,CAAC,IAAI,MAAM,GAAG,EAAE,GAAG,iBAAiB,CAAC,IAAI,CAAC,EAAE,CAAC;AAC9E,CAAC","sourcesContent":["const TOKEN_COUNT_UNITS = [\"k\", \"M\", \"B\", \"T\", \"Q\"] as const;\n\n/**\n * A token count as every view shows it: the whole count below 1,000, then one decimal and a unit, as in \"1.0k\",\n * \"248.6k\", \"1.2M\", \"1.0B\" and \"1.0T\". Thousands use a lowercase \"k\" and larger units an uppercase letter, so a count\n * never ends in an \"m\" that reads as minutes beside an elapsed time. A count that rounds to 1000.0 of a unit shows as\n * 1.0 of the next one: 999,950 is \"1.0M\". Fractional counts round to whole tokens; a negative or non-finite count is \"0\".\n */\nexport function formatTokenCount(count: number): string {\n\t// A JavaScript caller can pass a numeric string such as \"1500\"; any other non-number is malformed.\n\tconst input = count as number | string;\n\tconst value = typeof input === \"number\" || typeof input === \"string\" ? Number(input) : Number.NaN;\n\tconst tokens = Number.isFinite(value) ? Math.max(0, Math.round(value)) : 0;\n\tif (tokens < 1000) return String(tokens);\n\tlet unit = 0;\n\tlet tenthStep = 100;\n\tlet tenths = Math.round(tokens / tenthStep);\n\twhile (tenths >= 10_000 && unit < TOKEN_COUNT_UNITS.length - 1) {\n\t\tunit++;\n\t\ttenthStep *= 1000;\n\t\ttenths = Math.round(tokens / tenthStep);\n\t}\n\treturn `${Math.floor(tenths / 10)}.${tenths % 10}${TOKEN_COUNT_UNITS[unit]}`;\n}\n"]}
@@ -0,0 +1,18 @@
1
+ import { Worker, type WorkerOptions } from "node:worker_threads";
2
+ /**
3
+ * The `execArgv` for a worker thread that evaluates Atomic's own CommonJS source (`new Worker(source, { eval: true })`).
4
+ *
5
+ * None of the process's command-line flags: a host started with `--input-type=module` would make that source a module,
6
+ * which fails at its first `require`, and the host's `--import`/`--require` preloads would run again in every worker
7
+ * (#6079). Under Node's permission model a worker is restricted only by the flags it starts with, so there it keeps the
8
+ * process's flags (`undefined` inherits them) and stays as restricted as the process.
9
+ */
10
+ export declare function evalWorkerExecArgv(): string[] | undefined;
11
+ /**
12
+ * Starts a worker thread that runs Atomic's own ES module at `url` with the process's flags, which can include the
13
+ * loaders the module needs. Node refuses `--input-type` for an ES module given as a worker's entry, and a worker
14
+ * inherits it from a process started with it (`node --input-type=module --eval ...`), so there the worker imports the
15
+ * module from evaluated source instead (#6079).
16
+ */
17
+ export declare function startModuleWorker(url: URL, options?: WorkerOptions): Worker;
18
+ //# sourceMappingURL=worker-threads.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker-threads.d.ts","sourceRoot":"","sources":["../../src/utils/worker-threads.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEjE;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,EAAE,GAAG,SAAS,CAEzD;AASD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,GAAE,aAAkB,GAAG,MAAM,CAG/E"}
@@ -0,0 +1,28 @@
1
+ import { Worker } from "node:worker_threads";
2
+ /**
3
+ * The `execArgv` for a worker thread that evaluates Atomic's own CommonJS source (`new Worker(source, { eval: true })`).
4
+ *
5
+ * None of the process's command-line flags: a host started with `--input-type=module` would make that source a module,
6
+ * which fails at its first `require`, and the host's `--import`/`--require` preloads would run again in every worker
7
+ * (#6079). Under Node's permission model a worker is restricted only by the flags it starts with, so there it keeps the
8
+ * process's flags (`undefined` inherits them) and stays as restricted as the process.
9
+ */
10
+ export function evalWorkerExecArgv() {
11
+ return process.permission === undefined ? [] : undefined;
12
+ }
13
+ /** Whether the process was started with `--input-type`, on its command line or in `NODE_OPTIONS`. */
14
+ function startedWithInputType() {
15
+ return [...process.execArgv, ...(process.env.NODE_OPTIONS ?? "").split(/\s+/)].some((flag) => flag === "--input-type" || flag.startsWith("--input-type="));
16
+ }
17
+ /**
18
+ * Starts a worker thread that runs Atomic's own ES module at `url` with the process's flags, which can include the
19
+ * loaders the module needs. Node refuses `--input-type` for an ES module given as a worker's entry, and a worker
20
+ * inherits it from a process started with it (`node --input-type=module --eval ...`), so there the worker imports the
21
+ * module from evaluated source instead (#6079).
22
+ */
23
+ export function startModuleWorker(url, options = {}) {
24
+ if (!startedWithInputType())
25
+ return new Worker(url, options);
26
+ return new Worker(`import(${JSON.stringify(url.href)});`, { ...options, eval: true });
27
+ }
28
+ //# sourceMappingURL=worker-threads.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker-threads.js","sourceRoot":"","sources":["../../src/utils/worker-threads.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAsB,MAAM,qBAAqB,CAAC;AAEjE;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB;IACjC,OAAO,OAAO,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAC1D,CAAC;AAED,qGAAqG;AACrG,SAAS,oBAAoB;IAC5B,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAClF,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,cAAc,IAAI,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,CACrE,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAQ,EAAE,OAAO,GAAkB,EAAE;IACtE,IAAI,CAAC,oBAAoB,EAAE;QAAE,OAAO,IAAI,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC7D,OAAO,IAAI,MAAM,CAAC,UAAU,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,GAAG,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;AACvF,CAAC","sourcesContent":["import { Worker, type WorkerOptions } from \"node:worker_threads\";\n\n/**\n * The `execArgv` for a worker thread that evaluates Atomic's own CommonJS source (`new Worker(source, { eval: true })`).\n *\n * None of the process's command-line flags: a host started with `--input-type=module` would make that source a module,\n * which fails at its first `require`, and the host's `--import`/`--require` preloads would run again in every worker\n * (#6079). Under Node's permission model a worker is restricted only by the flags it starts with, so there it keeps the\n * process's flags (`undefined` inherits them) and stays as restricted as the process.\n */\nexport function evalWorkerExecArgv(): string[] | undefined {\n\treturn process.permission === undefined ? [] : undefined;\n}\n\n/** Whether the process was started with `--input-type`, on its command line or in `NODE_OPTIONS`. */\nfunction startedWithInputType(): boolean {\n\treturn [...process.execArgv, ...(process.env.NODE_OPTIONS ?? \"\").split(/\\s+/)].some(\n\t\t(flag) => flag === \"--input-type\" || flag.startsWith(\"--input-type=\"),\n\t);\n}\n\n/**\n * Starts a worker thread that runs Atomic's own ES module at `url` with the process's flags, which can include the\n * loaders the module needs. Node refuses `--input-type` for an ES module given as a worker's entry, and a worker\n * inherits it from a process started with it (`node --input-type=module --eval ...`), so there the worker imports the\n * module from evaluated source instead (#6079).\n */\nexport function startModuleWorker(url: URL, options: WorkerOptions = {}): Worker {\n\tif (!startedWithInputType()) return new Worker(url, options);\n\treturn new Worker(`import(${JSON.stringify(url.href)});`, { ...options, eval: true });\n}\n"]}
@@ -9,29 +9,30 @@ Background subagents keep working after the launch call returns. You can continu
9
9
 
10
10
  ### The agent panel
11
11
 
12
- Below the prompt, the **agent panel** lists the session's active background subagents, one row each. A `main` row comes first and stands for the main chat. Whichever agent the screen shows is marked with `●`:
12
+ Below the prompt, the **agent panel** lists the session's active background subagents, one row each. A `main` row comes first and stands for the main chat. Whichever agent the screen shows has a filled `●` and reads in bold:
13
13
 
14
14
  ```text
15
15
  ● main
16
- ∀ worker openai/gpt-5.5 high fix shipping batches 41m · ↓ 96.1k tokens
17
- ∀ debugger github-copilot/claude-opus-5.5 medium #5220 spawn lock 18m · ↓ 87.4k tokens
18
- ⧗ shell npm test 12s
19
- ◼ worker anthropic/claude-sonnet-4-5 high picker clamp stopped · 6m
16
+ ◯ worker openai/gpt-5.5 high fix shipping batches 41m · ↓ 96.1k tokens
17
+ ◯ debugger github-copilot/claude-opus-5.5 medium #5220 spawn lock 18m · ↓ 87.4k tokens
18
+ ⧗ shell npm test 12s
19
+ ◯ worker anthropic/claude-sonnet-4-5 high picker clamp stopped · 6m
20
20
  ```
21
21
 
22
22
  - **Each row shows** the status, the agent's name, the model it runs on and its reasoning level, what it works on, how long it has run, and the tokens it has used. A waiting row shows its question.
23
- - **Viewed marker (`●`):** While viewing the main chat, `● main` is active. While viewing a subagent, an accent `●` appears before its row (`❯` takes that column while the selection cursor is on it, with its name still highlighted) and `main` is muted. A resumed subagent stays one row, and `●` follows its latest attempt.
23
+ - **Viewed marker (`●`):** While viewing the main chat, `● main` is bold. While viewing a subagent, its row is bold and its open circle is filled (`●`), and `main` shows a muted `◯`. A resumed subagent stays one row, and `●` follows its latest attempt.
24
24
  - **The model column** names the model the subagent runs on now, as `provider/model-id`, then its reasoning level, as the footer shows the main chat's. A model without reasoning levels shows no level. The column follows the subagent: it changes as soon as the subagent falls back to another model, is resumed on a different one, or changes its reasoning level. A stopped or paused row shows the model its last turn ran on. A row whose model is not known yet leaves the column blank. When a subagent's model becomes known while you look at its row, the row shows it together with its reasoning level, or the model alone if no level arrives within a second, so the row's task moves only once. While the panel or `/tasks` stays open, the column keeps its width as long as it fits, even when the longest model leaves; it is measured again when the terminal is resized or the list is opened again.
25
25
  - The task title in the panel and on the prompt's top rule stops at a whole character. A shortened title ends in `…`.
26
26
  - **Status glyphs:**
27
- - `∀` running
27
+ - `◯` running, in grey (`●` while you view it)
28
28
  - `◆` needs input, with its question when it waits on one
29
29
  - `‖` paused
30
30
  - `○` queued
31
31
  - `◌` waiting on a detached call or shell (released)
32
- - `✓` done
32
+ - `●` done, in green
33
33
  - `✗` failed, showing the reason
34
- - `◼` stopped
34
+ - `◼` stopping
35
+ - `◯` stopped, in red (`●` while you view it)
35
36
  - `⧗` running shell (nested under the subagent that started it)
36
37
  - **Finished subagents** leave the panel as soon as they finish, except the subagent you are currently viewing: it stays listed until you switch to another agent or dismiss it (`x`), which switches back to `main`. `/tasks` still lists finished subagents. A stopped, paused, or interrupted subagent stays while another subagent or background shell is still running, and leaves once nothing is running. Switching sessions or starting unrelated work does not bring it back. If it resumes and stops again while other work is running, it reappears as one row, even if the panel was closed during the resume. A stopped row reads dim after 30 seconds. As the terminal narrows, each task is shortened first; below 100 columns, or when a row would be left no room for its task or its time, the model column is dropped, and below 70 columns the token count.
37
38
  - **Up to four rows** show while the prompt has focus, then `+N more`; the focused panel shows eight at a time. The `main` row does not count toward either. The viewed subagent and its running shells are always kept visible in the four rows (taking the last slots when they rank lower), and `+N more` counts every omitted row, nested shells included.
@@ -42,7 +43,7 @@ The main chat's background shells are not panel rows; the footer counts the runn
42
43
 
43
44
  Press **↓** on an empty prompt to focus the panel, whether you are viewing `main` or a subagent (while a viewed subagent's question form has focus, ↓ moves its selection instead):
44
45
 
45
- - **↑↓** select rows, including `main` and nested shell rows.
46
+ - **↑↓** select rows, including `main` and nested shell rows. The selected row is marked with `∀` before its mark and reads in the default text colour.
46
47
  - **Enter** or **→** on a subagent row switches the chat screen to that subagent and returns focus to the prompt.
47
48
  - **Enter** or **→** on `main` switches back to the main chat and returns focus to the prompt.
48
49
  - **Enter** or **→** on a nested shell row opens that shell's output in `/tasks` without changing which agent the chat screen shows (`←` returns to the focused panel).
@@ -88,7 +89,7 @@ Typing `/` offers completion for every built-in (`/model` and `/thinking` includ
88
89
  Run `/tasks` to inspect work without stopping it:
89
90
 
90
91
  - The list opens in the editor slot, with the conversation visible above it. It lists the subagents and shells of the session, running and finished.
91
- - Its header counts them, for example `Tasks 1 needs input · 3 working · 2 done`, and the rows are grouped **Needs input**, **Working** and **Done**. Each row is one line: its status mark (`⧗` for a running shell), its name, a subagent's model and reasoning level in the agent panel's model column, its task (or the question, while it waits for an answer), and on the right how long it has waited, run or took, in the agent panel's format (`3m`, `1h 6m`), with its tokens. A finished subagent's row shows the model its last turn ran on; the model column follows the panel's width rules.
92
+ - Its header counts them, for example `Tasks 1 needs input · 3 working · 2 done`, and the rows are grouped **Needs input**, **Working** and **Done**. Each row is one line: its status mark (the agent panel's: a grey `◯` running, a green `●` done, a red `◯` stopped, `⧗` for a running shell), its name, a subagent's model and reasoning level in the agent panel's model column, its task (or the question, while it waits for an answer), and on the right how long it has waited, run or took, in the agent panel's format (`3m`, `1h 6m`), with its tokens. A finished subagent's row shows the model its last turn ran on; the model column follows the panel's width rules.
92
93
  - The hint line lists the keys that work on the selected row: `↑↓ select · space peek · enter/→ open · x stop · / filter · esc/← close · ? keys`. On a finished row `x` reads `dismiss`.
93
94
  - Space opens a peek card under the selected row, and the rest of the list stays in place:
94
95
  - A subagent or shell shows its model, current tool call and usage.
@@ -208,7 +209,7 @@ Supervisor progress messages are labelled **Historical supervisor update** with
208
209
 
209
210
  Stopping a subagent through `/tasks` (`x`, then `x` again within 3 seconds) stops it resumably, as `subagent({ action: "quit", id })` does. It delivers a **paused** notice line and quit context to the parent model. The notice arrives only after termination is confirmed, not while the task is **Stopping**. It requires no final response from the child. Cancelling queued work sends the notice without starting it. Send it a message while viewing it, or use `subagent({ action: "resume", id })`, to resume it. Ctrl+X Ctrl+K stops subagents the same way.
210
211
 
211
- A subagent stopped with `subagent({ action: "pause" | "quit", id })` is not ended. Its notice line reads **paused · awaiting resume** or **quit · awaiting resume**. The model context gives `Stop reason: pause` or `quit` and names the call that continues it, `subagent({ action: "resume", id: "<child-id>" })`, instead of telling the model the execution has ended. Its `/tasks` row shows **Stopped** (`◼`); viewing it shows `Stopped · send to resume` in the prompt and accepts a message to continue it.
212
+ A subagent stopped with `subagent({ action: "pause" | "quit", id })` is not ended. Its notice line reads **paused · awaiting resume** or **quit · awaiting resume**. The model context gives `Stop reason: pause` or `quit` and names the call that continues it, `subagent({ action: "resume", id: "<child-id>" })`, instead of telling the model the execution has ended. Its `/tasks` row shows it as stopped (a red `◯`); viewing it shows `Stopped · send to resume` in the prompt and accepts a message to continue it.
212
213
 
213
214
  A subagent that completed or failed keeps its own session. Its notice tells the model the execution has ended and not to restart it merely to retrieve its result, and names the call that continues it with a follow-up, for example `Resume it with subagent({ action: "resume", id: "a760c0ec:0", message: "…" }) to continue it with a follow-up.` When the notice knows the child's Intercom name, it adds that the child takes Intercom messages under that name again once resumed. The id is the child id. A notice restored after a restart without its task record names the task id, which `resume` also accepts. Expanding the notice line (Ctrl+O) of a completed, failed, paused or quit subagent shows the same id as `resume id <child-id>` under the line; the collapsed line is unchanged. In `/tasks`, the expanded row and the detail page of such a subagent name it too, as `resume id <child-id>` and `Resume id <child-id>`, on its latest attempt only: once you resume it, the earlier attempt no longer shows the id. A subagent cancelled for good, one released while it waits, and background shells name no resume id.
214
215
 
@@ -125,8 +125,8 @@ The tags change nothing automatically: no text is protected or kept in context.
125
125
  The main chat and subagent views in `/tasks` show one line for each boundary:
126
126
 
127
127
  ```text
128
- ⚛ Context cleared · 182k tokens
129
- ⚛ Context compacted · morph/morph-compactor · 182k → 21.4k tokens
128
+ ⚛ Context cleared · 182.0k tokens
129
+ ⚛ Context compacted · morph/morph-compactor · 182.0k → 21.4k tokens
130
130
  ```
131
131
 
132
132
  A boundary written from an extension's replacement text names `extension` as its source. When a configured compactor was not used, the `Compaction model not used (<reason>); context cleared instead` notice follows the line. Press Ctrl+O (`app.tools.expand`) or click the boundary to show the whole boundary message: the recovery instructions and any compacted text.
@@ -54,7 +54,7 @@ The process that draws the UI (`host`) and the engine that runs the agent and ex
54
54
  | `block` | After each stall of at least the threshold | `at` (when the UI was due to respond), `durationMs`, the number of stack `samples`, `hotFrames` (the functions most samples were in, most specific first) and the most common full `stacks` |
55
55
  | `delay` | Once the process is ready for input (the `host` as it draws its first frame, the `engine` once it has loaded its session and extensions), once it starts to quit, and as it exits | `phase` (`startup`, `session` or `shutdown`), and how late the process responded: `p50Ms`, `p99Ms`, `maxMs` over `ticks` checks. A stall counts in the phase it started in |
56
56
 
57
- On Windows, the host ends the engine as soon as you quit. The engine then writes no `shutdown` record, and the record of a stall that ended just before you quit can be missing. If you close the terminal instead of quitting, the engine's last records are not written either.
57
+ Quit to get the engine's `shutdown` record. If you close the terminal instead, the engine is ended at once on every platform, so its last records are not written.
58
58
 
59
59
  Records hold function names and file paths, never prompts or message text. Atomic never trims the file, so delete it before reproducing a problem.
60
60
 
@@ -652,6 +652,8 @@ pi.sendMessage({
652
652
  });
653
653
  ```
654
654
 
655
+ `display: true` shows the message in the chat; `false`, or leaving `display` out, keeps it out of the chat. `customType` must be a string and `content` a string or an array of content blocks: otherwise the call throws a `TypeError` and nothing is saved.
656
+
655
657
  **Options:**
656
658
  - `deliverAs` - Delivery mode:
657
659
  - `"steer"` (default) - Queues the message while streaming. Delivered after the current assistant turn finishes executing its tool calls, before the next LLM call.
@@ -673,7 +675,7 @@ pi.sendMessages([
673
675
  ], { triggerTurn: true });
674
676
  ```
675
677
 
676
- The batch supports `triggerTurn`, `excludeFromContext`, and `deliverAs: "steer" | "followUp" | "nextTurn"`. Interrupt delivery remains a single-message operation.
678
+ The batch supports `triggerTurn`, `excludeFromContext`, and `deliverAs: "steer" | "followUp" | "nextTurn"`. Interrupt delivery remains a single-message operation. Each message follows the `pi.sendMessage()` rules; if one breaks them, the call throws a `TypeError` and none is sent.
677
679
 
678
680
  ### pi.sendUserMessage(content, options?)
679
681
 
@@ -710,7 +712,7 @@ See [send-user-message.ts](https://github.com/bastani-inc/atomic/blob/main/packa
710
712
 
711
713
  ### pi.appendEntry(customType, data?)
712
714
 
713
- Persist extension state (does NOT participate in LLM context).
715
+ Persist extension state (does NOT participate in LLM context). `customType` must be a string; otherwise the returned promise rejects with a `TypeError` and nothing is saved.
714
716
 
715
717
  ```typescript
716
718
  await pi.appendEntry("my-state", { count: 42 });
@@ -765,7 +767,7 @@ if (name) {
765
767
 
766
768
  ### pi.setLabel(entryId, label)
767
769
 
768
- Set or clear a label on an entry. Labels are user-defined markers for bookmarking and navigation (shown in `/tree` selector).
770
+ Set or clear a label on an entry. Labels are user-defined markers for bookmarking and navigation (shown in `/tree` selector). A label is a string, or `undefined` to clear it; any other value rejects with a `TypeError`.
769
771
 
770
772
  ```typescript
771
773
  // Set a label
@@ -298,6 +298,8 @@ pi.on("session_shutdown", async (event, ctx) => {
298
298
 
299
299
  `fromSignal` is set only on `reason: "quit"`. Ctrl+D and `/quit` leave it unset. Use it to tell a deliberate exit from the host stopping the process, for example to keep externally registered state that a restart can resume from.
300
300
 
301
+ When you quit the interactive app, `session_shutdown` handlers have about five seconds to finish; a handler still running then is stopped with the rest of the session.
302
+
301
303
  ### Agent Events
302
304
 
303
305
  #### before_agent_start
@@ -91,7 +91,7 @@ Installed [packages](/packages/authoring#mcp-servers) and extensions can contrib
91
91
 
92
92
  Command completion suggests actions and eligible server names. When a server name is omitted, Atomic selects an eligible server when the choice is unambiguous; otherwise it asks you to choose. Session login requires an interactive UI. Shell login opens the browser without starting a session; authenticate before unattended work.
93
93
 
94
- Enabled servers connect in the background when a session starts. The first prompt waits up to 10 seconds for servers with `direct` tools. Codemode, tool search, and resource calls wait for the servers they need. A dropped connection reconnects on the next call. Changes announced by a server update the available tools; withdrawn tools become unreachable.
94
+ Enabled servers connect in the background when a session starts. The first prompt waits up to 10 seconds for servers with `direct` tools. Codemode, tool search, and resource calls wait for the servers they need. A dropped connection reconnects on the next call. Changes announced by a server update the available tools; withdrawn tools become unreachable. When you resume a session, the MCP tools it was using stay available while their servers reconnect: a call to one waits for its server and runs only if the server still offers the same tool. Tools of a server that does not reconnect, needs a sign-in, or changed them are removed or updated with the next request.
95
95
 
96
96
  ### Shell commands
97
97
 
package/docs/settings.md CHANGED
@@ -83,6 +83,8 @@ See [Structured decisions](/sdk/structured-decisions) and [TypeSafe Jev](/provid
83
83
  }
84
84
  ```
85
85
 
86
+ A changed budget applies to new sessions. A resumed session keeps the budget it last used on the same model and thinking level, because a different budget would make the provider bill the cached conversation again; choosing another model or thinking level applies the setting.
87
+
86
88
  #### fallbackModels
87
89
 
88
90
  Ordered fallback chain for main-chat turns after same-model retries exhaust on a retryable failure:
package/docs/storage.md CHANGED
@@ -46,7 +46,7 @@ try {
46
46
 
47
47
  **Local Node SQLite (`openNodeSqliteDatabase` / `wrapNodeSqliteDatabase`):**
48
48
  - Creates parent directories and enables WAL, `FULL` sync, foreign keys, and `busyTimeoutMs: 5000` (override via options). Pass `:memory:` for ephemeral DBs or `{ readOnly: true }` to inspect without creating files or changing journal mode.
49
- - **Threads:** `openNodeSqliteDatabase` runs each connection to a file on a worker thread of its own, so your event loop keeps running while a statement waits for another connection's lock or a commit syncs to disk. Opening a file starts its thread (about 10 ms on Bun, 20 ms on Node), and each statement makes one round trip to it. `:memory:` databases and connections passed to `wrapNodeSqliteDatabase` run on the calling thread, as before. In one process, a `DatabaseSync` of your own or a `wrapNodeSqliteDatabase` handle that writes a file while an `openNodeSqliteDatabase` transaction on it is open can wait for its busy timeout on your thread, which the transaction needs to commit, and fail with `SQLITE_BUSY`. Open every handle that writes a shared file with `openNodeSqliteDatabase`.
49
+ - **Threads:** `openNodeSqliteDatabase` runs each connection to a file on a worker thread of its own, so your event loop keeps running while a statement waits for another connection's lock or a commit syncs to disk. Opening a file starts its thread (about 10 ms on Bun, 20 ms on Node), and each statement makes one round trip to it. `:memory:` databases and connections passed to `wrapNodeSqliteDatabase` run on the calling thread, as before. While an `openNodeSqliteDatabase` transaction started on the same JavaScript thread takes or holds a file's write lock, a `wrapNodeSqliteDatabase` handle on that file that was open when the transaction started runs a statement that writes the file at once if it can; if the lock is taken, the statement waits off your thread, runs once the lock is free (calls waiting meanwhile run oldest first, one per turn of the event loop), and fails with `SQLITE_BUSY` without effect if its busy timeout passes first. A script of several statements waits until no such transaction holds the lock, then runs whole. Reads, writes of temporary tables, and calls made inside that transaction's callback run at once; a call made in the callback can run before an earlier call of the same connection that waits. These statements run as before, so they can still wait for the lock on your thread for their busy timeout: ones that call a function you registered, a collating sequence or virtual table of an extension, `load_extension`, `changes()`, `total_changes()` or `last_insert_rowid()`; ones that write another attached file, `VACUUM` and `ATTACH`; every `PRAGMA` except `user_version`, `application_id`, `schema_version` and `incremental_vacuum` on the main database; and every statement while the connection is inside a transaction you began on it or the file is not in WAL mode. A call on the same connection, through this or another wrapped handle of it, waits behind one that waits. To decide this meanwhile, the handle prepares `EXPLAIN` of a statement once, reads `PRAGMA busy_timeout`, `PRAGMA main.journal_mode` and, for an `INSERT`, `UPDATE` or `DELETE` or a statement that calls a function, `PRAGMA function_list`, and sets `PRAGMA busy_timeout` to 0 and back around each try, which an authorizer you set with `setAuthorizer` sees; if your authorizer denies or ignores reading or setting `PRAGMA busy_timeout`, the handle's statements run as before. Have your authorizer treat `PRAGMA busy_timeout` the same way every time: one that allows setting it to 0 and then denies or ignores setting it back leaves the connection's busy timeout at 0. A `DatabaseSync` you use directly gets no such wait, nor does a write during a transaction of another worker thread: it waits for the lock on your thread for its busy timeout and can fail with `SQLITE_BUSY`. Keep raw and wrapped use of one connection apart: raw statements on a connection that is also wrapped can change how its wrapped writes behave. While a wrapped call waits, raw code on the same `DatabaseSync` can read `changes()` as 0 until the call runs again, and a raw statement iterator left open (`prepare().iterate()`) keeps a read of the file open that the handle cannot see, so a wrapped write can then fail at once with `SQLITE_BUSY` or succeed where it would have failed before. A trigger or view that reads `changes()`, `total_changes()` or `last_insert_rowid()`, itself or through a function of yours that only it calls, can read a `changes()` of 0 when a wrapped `INSERT`, `UPDATE` or `DELETE` runs it during such a transaction. Open every handle that writes a shared file with `openNodeSqliteDatabase` or `wrapNodeSqliteDatabase`.
50
50
  - **Open locks:** File-backed connections hold a shared lock on `<file>-open.lock` (read-only `openNodeSqliteDatabase` takes it only if lock/holder files already exist and skips it in read-only dirs; `wrapNodeSqliteDatabase` attempts it for all file-backed connections and tolerates unwritable dirs) so checkpoint cleanup never deletes live journals. Do not open crashed hosts' checkpoint journals with external tools while a new host starts.
51
51
  - **Same-process & cross-process queueing:** Separate `openNodeSqliteDatabase` handles to the same file (including symlinks) share an async queue; `wrapNodeSqliteDatabase(conn)` shares a queue per wrapped connection and leaves your connection open on `close()`. Across processes, writers queue FIFO in `<file>-writers`, wake the next writer via `<file>-wakes`, and track holders in `<file>-holders`.
52
52
  - **Group commit & lock wait:** `groupCommitHoldMs` (default `100` ms / `DEFAULT_GROUP_COMMIT_HOLD_MS`, `0` commits individually; invalid throws `StorageConfigError`) batches queued transactions on one connection per lock acquisition. Waiting writers refresh every 500 ms and bypass dead processes after 2 s (live processes are bypassed only after 2 s of active wall time so laptop/VM suspend preserves FIFO order). Exceeding `lockWaitMs` (default `30000` ms, or per-transaction `{ lockWaitMs }`) with no commits rejects with `StorageWriteLockTimeoutError`.
@@ -273,6 +273,8 @@ A cloud identity is a role like any other: make it the runtime role with the gra
273
273
  - **The server refused a token**: `28P01` ("password authentication failed") is a token for the wrong user or one that expired. Azure answers `28000` ("The access token has invalid format") for a malformed one, such as a token for another resource or an empty or truncated token file: get it for `https://ossrdbms-aad.database.windows.net` (`az account get-access-token --resource-type oss-rdbms`), or use `--auth azure`.
274
274
  - **`StorageUnavailableError`** when the store opens: the server refused the password (`28P01`, or `28000` for an Azure token, as above), the database does not exist (`3D000`), or the server is older than PostgreSQL 14. Atomic's tables need PostgreSQL 16: on 14 and 15 the adapter connects, but sessions fail to open.
275
275
  - **A certificate error** (`self-signed certificate in certificate chain`, `unable to get local issuer certificate`): the server's CA is not one Node.js trusts. Add `sslrootcert`, as in [TLS](#tls).
276
+ - **`INVALID_PURPOSE`**: a certificate in the server's chain may not be used for it. Usually the certificate `sslrootcert` names is not marked as a CA (`basicConstraints=CA:TRUE`), or it is limited to client authentication. Point `sslrootcert` at the CA certificate that signed the server's certificate, or reissue that CA with `CA:TRUE` and without the client-authentication limit. Atomic does not retry it.
277
+ - **`PATH_LENGTH_EXCEEDED`**: the server's chain has more intermediate CAs than its root allows. Reissue the root without that path-length limit, or have the root sign the server's certificate directly. Atomic does not retry it.
276
278
  - **"the proxy … refused the tunnel to …"**: the proxy's allow-list does not name the database's `host:port`, or (`407`) it wants credentials it was not given: put them in the proxy URL. "could not be reached" means nothing answers at the proxy's address; check `HTTPS_PROXY`. To connect without the proxy, add the host to `NO_PROXY` or set the `proxy` option to `"none"`. See [Through an HTTP proxy](#through-an-http-proxy).
277
279
  - **`unsupported-proxy`**: the proxy variable or option is not an `http://` or `https://` URL, for example a `socks5://` proxy in `HTTPS_PROXY`. Set an HTTP proxy, add the database host to `NO_PROXY`, or set the `proxy` option to `"none"`.
278
280
  - **`StorageTransientError` with code `read-only-server`** (`25006`): the server accepts reads only. Either the URL names a read replica, a standby or a read-only endpoint, such as an Azure HorizonDB pool's: use the primary server, or the cluster's read/write endpoint. Or the server is read-only for now, during a failover or while Azure keeps a server whose storage is nearly full read-only: Atomic retries, and a call still refused after its retries fails with this code.
package/docs/subagents.md CHANGED
@@ -262,7 +262,7 @@ Use `/tasks` (or `/tasks <id>`) to inspect background subagents and shells (excl
262
262
  | --- | --- |
263
263
  | `Space` | Toggle inline peek card (model, reasoning, activity, usage, plus quick reply box for working subagents) |
264
264
  | `Enter` / `→` | View the selected subagent on the chat screen, or open a shell's output tail |
265
- | `x` twice (within 3 s) | Stop a running task (quits subagents resumably → **Stopped** `◼`) |
265
+ | `x` twice (within 3 s) | Stop a running task (quits subagents resumably → **Stopped**, a red `◯`) |
266
266
  | `x` once | Dismiss a finished row |
267
267
  | `Esc` / `←` | Go back one view without stopping work |
268
268
 
@@ -284,9 +284,13 @@ Use `/tasks` (or `/tasks <id>`) to inspect background subagents and shells (excl
284
284
 
285
285
  ### Fresh vs. forked context
286
286
 
287
- - `context: "fresh"` — starts an isolated in-process child session with only the task and agent prompt (preferred for adversarial reviews and independent research).
287
+ - `context: "fresh"` — starts an isolated in-process child session with only the task and agent prompt (preferred for adversarial reviews and independent research). Its context is small: the agent's prompt and the task.
288
288
  - `context: "fork"` — branches from the parent's settled entry (fails fast if the parent cannot be forked; never downgrades to fresh). Inherits model, thinking, tool changes, `pi.appendEntry` data since the last clear, and referenced saved tool outputs, without taking ownership of the parent's subagents or replaying parent Intercom cards.
289
289
 
290
+ Use `fork` when the child needs the parent's conversation. A forked child sends the parent's conversation exactly as the parent last sent it: the same system prompt, including the project context and skills the parent was sent, the same tools and the same messages, including the parent's earlier subagent calls. Its own role, a short note and its task come after it. When the child runs on the parent's model and thinking level, its first request is read from the parent's prompt cache, so it pays for the new part only. On another model or provider it reads nothing from it; on another thinking level it may read only part of it, depending on the model. The cache statistics name the cause. Every later request carries that conversation too, mostly read from the cache. Use `fresh` for independent work that needs none of it. The default stays `fresh` unless an agent sets `defaultContext: fork`.
291
+
292
+ In a fork, the agent's `inheritProjectContext` and `inheritSkills` settings do not hide what the parent already sent; they apply to fresh children. To keep the project context and skills out of a child, launch it with `context: "fresh"`. The child's tool policy does apply: it can call only its own tools, and a call to another tool the parent declared fails with an error naming the tools it may call. Where the provider takes tool changes mid-conversation, the removed tools are also declared after the conversation. A tool only the child has is declared after the conversation where the provider can add one; otherwise it is reached through the parent's `codemode`, and is added to the tool list only when the parent has no `codemode`, which the cache statistics show as a tool change. When the parent has `codemode` and the agent does not, the fork can call it, but only as a way to reach its own tools: its scripts cannot call `models` or any tool outside the child's tools, so the fork can do nothing a fresh child of the same agent could not. A forked child started by this version keeps sending the same start when it is reopened; one reopened under different inheritance or fan-out settings sends its own prompt instead. A forked child started by an earlier version is reopened as the child it was, under its own prompt and tools.
293
+
290
294
  Fresh children inherit the parent's SDK config, discovery inputs, model/auth runtime, and host callbacks. Child tool lists can narrow permissions but cannot re-enable excluded tools or disabled packages. See [SDK child configuration](/sdk).
291
295
 
292
296
  ### Temporary worktrees (`worktree: true`)
package/docs/usage.md CHANGED
@@ -32,7 +32,7 @@ Startup lists loaded context files, skills, prompts, and extensions by name. Cus
32
32
 
33
33
  While the agent works, `∀` pulses beside a working message, followed by the current run's elapsed time and output tokens. A new run starts a fresh meter; steering keeps the current run's meter. Retry, fallback, compaction, cancellation, and error messages take precedence; approval prompts hide ordinary activity. Set `ATOMIC_REDUCED_MOTION=1` for a static indicator or `NO_COLOR` for activity without foreground colors. Elapsed time still updates once per second with reduced motion. Extensions can [customize the indicator](/tui#pattern-4b-working-indicator-customization).
34
34
 
35
- Compaction uses a still `∀` mark with elapsed time and the cancel key. Opening a chat during compaction shows the time since that compaction began. Afterwards, one line marks the boundary: `⚛ Context cleared · 182k tokens`, or `⚛ Context compacted · morph/morph-compactor · 182k → 21.4k tokens` when a compactor model ran. Use the expand key, normally Ctrl+O, to read the whole boundary message: where the earlier conversation is in session history, what the agent recovers first, and any compacted text.
35
+ Compaction uses a still `∀` mark with elapsed time and the cancel key. Opening a chat during compaction shows the time since that compaction began. Afterwards, one line marks the boundary: `⚛ Context cleared · 182.0k tokens`, or `⚛ Context compacted · morph/morph-compactor · 182.0k → 21.4k tokens` when a compactor model ran. Use the expand key, normally Ctrl+O, to read the whole boundary message: where the earlier conversation is in session history, what the agent recovers first, and any compacted text.
36
36
 
37
37
  ### Editor Features
38
38