@bastani/atomic 0.9.5-alpha.9 → 0.9.5

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 (377) hide show
  1. package/CHANGELOG.md +106 -0
  2. package/README.md +2 -2
  3. package/dist/builtin/cursor/CHANGELOG.md +12 -0
  4. package/dist/builtin/cursor/package.json +3 -3
  5. package/dist/builtin/cursor/src/model-mapper.ts +6 -3
  6. package/dist/builtin/intercom/CHANGELOG.md +37 -0
  7. package/dist/builtin/intercom/README.md +4 -2
  8. package/dist/builtin/intercom/broker/broker.ts +6 -114
  9. package/dist/builtin/intercom/broker/client.ts +29 -54
  10. package/dist/builtin/intercom/broker/delivered-message-cache.ts +44 -0
  11. package/dist/builtin/intercom/broker/pending-send-registry.ts +142 -0
  12. package/dist/builtin/intercom/broker/send-handler.ts +106 -0
  13. package/dist/builtin/intercom/broker/send-signature.ts +37 -0
  14. package/dist/builtin/intercom/foreground-detach-handoff.ts +136 -0
  15. package/dist/builtin/intercom/index-heavy.ts +49 -53
  16. package/dist/builtin/intercom/index.ts +278 -262
  17. package/dist/builtin/intercom/lazy-heavy-proxy.ts +114 -0
  18. package/dist/builtin/intercom/lazy-subagent-ack.ts +20 -0
  19. package/dist/builtin/intercom/lazy-tool-execution.ts +39 -0
  20. package/dist/builtin/intercom/lifecycle-lease.ts +51 -0
  21. package/dist/builtin/intercom/lifecycle.ts +37 -20
  22. package/dist/builtin/intercom/package.json +3 -6
  23. package/dist/builtin/intercom/reply-routing.ts +17 -0
  24. package/dist/builtin/intercom/subagent-relay.ts +58 -12
  25. package/dist/builtin/intercom/types.ts +3 -3
  26. package/dist/builtin/mcp/CHANGELOG.md +27 -0
  27. package/dist/builtin/mcp/OAUTH.md +1 -0
  28. package/dist/builtin/mcp/README.md +4 -0
  29. package/dist/builtin/mcp/apps-cancellation.ts +32 -0
  30. package/dist/builtin/mcp/call-tool-result.ts +9 -0
  31. package/dist/builtin/mcp/caller-wait.ts +50 -0
  32. package/dist/builtin/mcp/command-registration.ts +82 -0
  33. package/dist/builtin/mcp/direct-tool-executor.ts +279 -0
  34. package/dist/builtin/mcp/direct-tools.ts +6 -239
  35. package/dist/builtin/mcp/host-html-template.ts +4 -2
  36. package/dist/builtin/mcp/index.ts +258 -250
  37. package/dist/builtin/mcp/init.ts +96 -87
  38. package/dist/builtin/mcp/mcp-auth-flow.ts +247 -237
  39. package/dist/builtin/mcp/mcp-callback-server.ts +89 -68
  40. package/dist/builtin/mcp/mcp-oauth-provider.ts +23 -1
  41. package/dist/builtin/mcp/metadata-hydration.ts +21 -6
  42. package/dist/builtin/mcp/package.json +3 -3
  43. package/dist/builtin/mcp/proxy-auth.ts +4 -4
  44. package/dist/builtin/mcp/proxy-call.ts +111 -40
  45. package/dist/builtin/mcp/proxy-connect.ts +35 -15
  46. package/dist/builtin/mcp/proxy-info-modes.ts +49 -19
  47. package/dist/builtin/mcp/proxy-modes.ts +3 -3
  48. package/dist/builtin/mcp/session-cleanup-barrier.ts +43 -0
  49. package/dist/builtin/mcp/state-lease.ts +12 -0
  50. package/dist/builtin/mcp/ui-server.ts +8 -8
  51. package/dist/builtin/mcp/ui-session.ts +9 -18
  52. package/dist/builtin/subagents/CHANGELOG.md +66 -0
  53. package/dist/builtin/subagents/README.md +30 -29
  54. package/dist/builtin/subagents/agents/code-simplifier.md +2 -2
  55. package/dist/builtin/subagents/agents/codebase-analyzer.md +2 -2
  56. package/dist/builtin/subagents/agents/codebase-locator.md +2 -2
  57. package/dist/builtin/subagents/agents/codebase-online-researcher.md +2 -2
  58. package/dist/builtin/subagents/agents/codebase-pattern-finder.md +2 -2
  59. package/dist/builtin/subagents/agents/codebase-research-analyzer.md +2 -2
  60. package/dist/builtin/subagents/agents/codebase-research-locator.md +2 -2
  61. package/dist/builtin/subagents/agents/debugger.md +2 -2
  62. package/dist/builtin/subagents/agents/worker.md +2 -2
  63. package/dist/builtin/subagents/package.json +5 -5
  64. package/dist/builtin/subagents/prompts/review-loop.md +1 -1
  65. package/dist/builtin/subagents/skills/subagent/SKILL.md +37 -36
  66. package/dist/builtin/subagents/src/extension/api-lifecycle.ts +64 -0
  67. package/dist/builtin/subagents/src/extension/fanout-child.ts +44 -51
  68. package/dist/builtin/subagents/src/extension/index.ts +287 -307
  69. package/dist/builtin/subagents/src/extension/prompt-guidance.ts +7 -10
  70. package/dist/builtin/subagents/src/extension/schemas.ts +22 -5
  71. package/dist/builtin/subagents/src/extension/tool-description.ts +29 -0
  72. package/dist/builtin/subagents/src/intercom/intercom-bridge.ts +13 -2
  73. package/dist/builtin/subagents/src/intercom/result-intercom.ts +4 -4
  74. package/dist/builtin/subagents/src/runs/background/async-event-journal.ts +106 -0
  75. package/dist/builtin/subagents/src/runs/background/async-execution-common.ts +3 -2
  76. package/dist/builtin/subagents/src/runs/background/async-execution-single.ts +13 -2
  77. package/dist/builtin/subagents/src/runs/background/async-execution-types.ts +3 -0
  78. package/dist/builtin/subagents/src/runs/background/async-job-tracker.ts +1 -1
  79. package/dist/builtin/subagents/src/runs/background/completion-claims.ts +189 -0
  80. package/dist/builtin/subagents/src/runs/background/completion-dedupe.ts +44 -7
  81. package/dist/builtin/subagents/src/runs/background/completion-notification.ts +34 -0
  82. package/dist/builtin/subagents/src/runs/background/notify.ts +72 -22
  83. package/dist/builtin/subagents/src/runs/background/result-delivery-processor.ts +232 -0
  84. package/dist/builtin/subagents/src/runs/background/result-file-claims.ts +151 -0
  85. package/dist/builtin/subagents/src/runs/background/result-quarantine.ts +72 -0
  86. package/dist/builtin/subagents/src/runs/background/result-retry-scheduler.ts +48 -0
  87. package/dist/builtin/subagents/src/runs/background/result-status.ts +81 -0
  88. package/dist/builtin/subagents/src/runs/background/result-watcher-data.ts +59 -0
  89. package/dist/builtin/subagents/src/runs/background/result-watcher.ts +172 -238
  90. package/dist/builtin/subagents/src/runs/background/run-id-resolver.ts +3 -2
  91. package/dist/builtin/subagents/src/runs/background/stale-run-reconciler.ts +73 -14
  92. package/dist/builtin/subagents/src/runs/background/subagent-runner-streaming.ts +17 -13
  93. package/dist/builtin/subagents/src/runs/background/top-level-async.ts +1 -2
  94. package/dist/builtin/subagents/src/runs/foreground/chain-execution-dynamic-step.ts +1 -0
  95. package/dist/builtin/subagents/src/runs/foreground/chain-execution-parallel-runner.ts +1 -0
  96. package/dist/builtin/subagents/src/runs/foreground/chain-execution-parallel-step.ts +1 -0
  97. package/dist/builtin/subagents/src/runs/foreground/chain-execution-sequential-step.ts +7 -9
  98. package/dist/builtin/subagents/src/runs/foreground/chain-execution-types.ts +3 -13
  99. package/dist/builtin/subagents/src/runs/foreground/chain-execution.ts +2 -15
  100. package/dist/builtin/subagents/src/runs/foreground/execution-attempt-finalize.ts +2 -2
  101. package/dist/builtin/subagents/src/runs/foreground/execution-attempt.ts +53 -44
  102. package/dist/builtin/subagents/src/runs/foreground/execution-detach-reservations.ts +48 -0
  103. package/dist/builtin/subagents/src/runs/foreground/execution-detach-route.ts +17 -0
  104. package/dist/builtin/subagents/src/runs/foreground/execution-run-sync.ts +39 -26
  105. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-async.ts +3 -1
  106. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-chain.ts +3 -51
  107. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-context.ts +6 -11
  108. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-input.ts +11 -2
  109. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel-task.ts +2 -0
  110. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel.ts +5 -112
  111. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-resume.ts +2 -0
  112. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-single.ts +68 -118
  113. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-status.ts +79 -7
  114. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-types.ts +2 -2
  115. package/dist/builtin/subagents/src/runs/foreground/subagent-executor.ts +3 -0
  116. package/dist/builtin/subagents/src/runs/shared/pi-args.ts +2 -2
  117. package/dist/builtin/subagents/src/runs/shared/pi-spawn.ts +27 -11
  118. package/dist/builtin/subagents/src/shared/artifacts.ts +22 -11
  119. package/dist/builtin/subagents/src/shared/event-jsonl-writer.ts +294 -0
  120. package/dist/builtin/subagents/src/shared/exclusive-file-publication.ts +44 -0
  121. package/dist/builtin/subagents/src/shared/jsonl-writer.ts +1 -0
  122. package/dist/builtin/subagents/src/shared/model-info.ts +2 -2
  123. package/dist/builtin/subagents/src/shared/settings.ts +20 -10
  124. package/dist/builtin/subagents/src/shared/types-async.ts +3 -1
  125. package/dist/builtin/subagents/src/shared/types-config.ts +2 -0
  126. package/dist/builtin/subagents/src/shared/types-runtime.ts +3 -2
  127. package/dist/builtin/subagents/src/slash/slash-commands.ts +9 -12
  128. package/dist/builtin/subagents/src/slash/slash-live-state.ts +63 -32
  129. package/dist/builtin/subagents/src/tui/render-result.ts +7 -0
  130. package/dist/builtin/subagents/src/tui/render-stable-output.ts +1 -0
  131. package/dist/builtin/subagents/src/tui/render-widget.ts +128 -89
  132. package/dist/builtin/web-access/CHANGELOG.md +28 -0
  133. package/dist/builtin/web-access/README.md +4 -0
  134. package/dist/builtin/web-access/content-tools.ts +8 -3
  135. package/dist/builtin/web-access/index-heavy.ts +1 -1
  136. package/dist/builtin/web-access/index.ts +190 -46
  137. package/dist/builtin/web-access/lifecycle-lease.ts +38 -0
  138. package/dist/builtin/web-access/package.json +2 -2
  139. package/dist/builtin/web-access/result-renderers.ts +1 -1
  140. package/dist/builtin/web-access/summary-review.ts +1 -1
  141. package/dist/builtin/web-access/web-search-activity.ts +1 -1
  142. package/dist/builtin/web-access/web-search-return.ts +7 -0
  143. package/dist/builtin/web-access/web-search-summary.ts +1 -1
  144. package/dist/builtin/web-access/web-search-tool.ts +4 -2
  145. package/dist/builtin/workflows/CHANGELOG.md +68 -0
  146. package/dist/builtin/workflows/README.md +4 -4
  147. package/dist/builtin/workflows/builtin/deep-research-codebase-utils.ts +27 -4
  148. package/dist/builtin/workflows/builtin/goal-runner.ts +47 -26
  149. package/dist/builtin/workflows/builtin/open-claude-design-runner.ts +10 -0
  150. package/dist/builtin/workflows/builtin/ralph-core.ts +9 -9
  151. package/dist/builtin/workflows/builtin/ralph-models.ts +71 -36
  152. package/dist/builtin/workflows/builtin/ralph-runner.ts +20 -31
  153. package/dist/builtin/workflows/package.json +2 -2
  154. package/dist/builtin/workflows/src/durable/stage-primitive.ts +2 -1
  155. package/dist/builtin/workflows/src/engine/primitives/task.ts +2 -1
  156. package/dist/builtin/workflows/src/extension/workflow-prompts.ts +17 -22
  157. package/dist/builtin/workflows/src/extension/workflow-schema.ts +15 -2
  158. package/dist/builtin/workflows/src/runs/foreground/executor-hil.ts +1 -2
  159. package/dist/builtin/workflows/src/runs/shared/model-fallback-candidates.ts +1 -1
  160. package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +2 -2
  161. package/dist/builtin/workflows/src/shared/authoring-contract-stage.ts +2 -2
  162. package/dist/builtin/workflows/src/shared/resume-continuation.ts +2 -0
  163. package/dist/builtin/workflows/src/tui/stage-chat-view-archive-history.ts +1 -23
  164. package/dist/builtin/workflows/src/tui/stage-chat-view-footer-status.ts +54 -9
  165. package/dist/builtin/workflows/src/tui/stage-chat-view.ts +5 -2
  166. package/dist/cli/args.d.ts.map +1 -1
  167. package/dist/cli/args.js +2 -2
  168. package/dist/cli/args.js.map +1 -1
  169. package/dist/core/agent-session-events.d.ts.map +1 -1
  170. package/dist/core/agent-session-events.js +2 -1
  171. package/dist/core/agent-session-events.js.map +1 -1
  172. package/dist/core/agent-session-message-queue.d.ts.map +1 -1
  173. package/dist/core/agent-session-message-queue.js +1 -1
  174. package/dist/core/agent-session-message-queue.js.map +1 -1
  175. package/dist/core/agent-session-prompt.d.ts.map +1 -1
  176. package/dist/core/agent-session-prompt.js +1 -1
  177. package/dist/core/agent-session-prompt.js.map +1 -1
  178. package/dist/core/agent-session-retry.d.ts.map +1 -1
  179. package/dist/core/agent-session-retry.js +1 -1
  180. package/dist/core/agent-session-retry.js.map +1 -1
  181. package/dist/core/agent-session-services.d.ts.map +1 -1
  182. package/dist/core/agent-session-services.js +3 -2
  183. package/dist/core/agent-session-services.js.map +1 -1
  184. package/dist/core/agent-session-types.d.ts.map +1 -1
  185. package/dist/core/agent-session-types.js +1 -1
  186. package/dist/core/agent-session-types.js.map +1 -1
  187. package/dist/core/anthropic-thinking-guard.d.ts +5 -5
  188. package/dist/core/anthropic-thinking-guard.d.ts.map +1 -1
  189. package/dist/core/anthropic-thinking-guard.js +42 -32
  190. package/dist/core/anthropic-thinking-guard.js.map +1 -1
  191. package/dist/core/atomic-guide-command.d.ts.map +1 -1
  192. package/dist/core/atomic-guide-command.js +15 -15
  193. package/dist/core/atomic-guide-command.js.map +1 -1
  194. package/dist/core/auth-storage.d.ts.map +1 -1
  195. package/dist/core/auth-storage.js +14 -9
  196. package/dist/core/auth-storage.js.map +1 -1
  197. package/dist/core/compaction/compaction.d.ts +2 -0
  198. package/dist/core/compaction/compaction.d.ts.map +1 -1
  199. package/dist/core/compaction/compaction.js +79 -46
  200. package/dist/core/compaction/compaction.js.map +1 -1
  201. package/dist/core/compaction/context-assistant-turns.d.ts +42 -0
  202. package/dist/core/compaction/context-assistant-turns.d.ts.map +1 -0
  203. package/dist/core/compaction/context-assistant-turns.js +87 -0
  204. package/dist/core/compaction/context-assistant-turns.js.map +1 -0
  205. package/dist/core/compaction/context-compaction-critical.d.ts +1 -1
  206. package/dist/core/compaction/context-compaction-critical.d.ts.map +1 -1
  207. package/dist/core/compaction/context-compaction-critical.js +2 -2
  208. package/dist/core/compaction/context-compaction-critical.js.map +1 -1
  209. package/dist/core/compaction/context-compaction-eviction-alternates.d.ts +18 -0
  210. package/dist/core/compaction/context-compaction-eviction-alternates.d.ts.map +1 -0
  211. package/dist/core/compaction/context-compaction-eviction-alternates.js +186 -0
  212. package/dist/core/compaction/context-compaction-eviction-alternates.js.map +1 -0
  213. package/dist/core/compaction/context-compaction-eviction.d.ts +10 -2
  214. package/dist/core/compaction/context-compaction-eviction.d.ts.map +1 -1
  215. package/dist/core/compaction/context-compaction-eviction.js +196 -146
  216. package/dist/core/compaction/context-compaction-eviction.js.map +1 -1
  217. package/dist/core/compaction/context-compaction-prompt.d.ts.map +1 -1
  218. package/dist/core/compaction/context-compaction-prompt.js +1 -1
  219. package/dist/core/compaction/context-compaction-prompt.js.map +1 -1
  220. package/dist/core/compaction/context-compaction-types.d.ts +2 -0
  221. package/dist/core/compaction/context-compaction-types.d.ts.map +1 -1
  222. package/dist/core/compaction/context-compaction-types.js.map +1 -1
  223. package/dist/core/compaction/context-deletion-application.d.ts +5 -4
  224. package/dist/core/compaction/context-deletion-application.d.ts.map +1 -1
  225. package/dist/core/compaction/context-deletion-application.js +17 -15
  226. package/dist/core/compaction/context-deletion-application.js.map +1 -1
  227. package/dist/core/compaction/context-deletion-store.d.ts.map +1 -1
  228. package/dist/core/compaction/context-deletion-store.js +1 -1
  229. package/dist/core/compaction/context-deletion-store.js.map +1 -1
  230. package/dist/core/compaction/context-deletion-targets.d.ts +2 -1
  231. package/dist/core/compaction/context-deletion-targets.d.ts.map +1 -1
  232. package/dist/core/compaction/context-deletion-targets.js +36 -31
  233. package/dist/core/compaction/context-deletion-targets.js.map +1 -1
  234. package/dist/core/compaction/context-deletion-tool-helpers.d.ts.map +1 -1
  235. package/dist/core/compaction/context-deletion-tool-helpers.js +116 -43
  236. package/dist/core/compaction/context-deletion-tool-helpers.js.map +1 -1
  237. package/dist/core/compaction/context-transcript-analysis.d.ts +1 -2
  238. package/dist/core/compaction/context-transcript-analysis.d.ts.map +1 -1
  239. package/dist/core/compaction/context-transcript-analysis.js +33 -37
  240. package/dist/core/compaction/context-transcript-analysis.js.map +1 -1
  241. package/dist/core/copilot-model-synthesis.d.ts.map +1 -1
  242. package/dist/core/copilot-model-synthesis.js +3 -1
  243. package/dist/core/copilot-model-synthesis.js.map +1 -1
  244. package/dist/core/extensions/provider-types.d.ts +2 -7
  245. package/dist/core/extensions/provider-types.d.ts.map +1 -1
  246. package/dist/core/extensions/provider-types.js.map +1 -1
  247. package/dist/core/messages.d.ts +9 -0
  248. package/dist/core/messages.d.ts.map +1 -1
  249. package/dist/core/messages.js +100 -18
  250. package/dist/core/messages.js.map +1 -1
  251. package/dist/core/model-registry-builtins.d.ts.map +1 -1
  252. package/dist/core/model-registry-builtins.js +5 -0
  253. package/dist/core/model-registry-builtins.js.map +1 -1
  254. package/dist/core/model-registry-custom-loader.d.ts.map +1 -1
  255. package/dist/core/model-registry-custom-loader.js +49 -8
  256. package/dist/core/model-registry-custom-loader.js.map +1 -1
  257. package/dist/core/model-registry-dynamic.d.ts.map +1 -1
  258. package/dist/core/model-registry-dynamic.js +11 -5
  259. package/dist/core/model-registry-dynamic.js.map +1 -1
  260. package/dist/core/model-registry-loader.d.ts.map +1 -1
  261. package/dist/core/model-registry-loader.js +8 -0
  262. package/dist/core/model-registry-loader.js.map +1 -1
  263. package/dist/core/model-registry-schemas.d.ts +93 -8
  264. package/dist/core/model-registry-schemas.d.ts.map +1 -1
  265. package/dist/core/model-registry-schemas.js +24 -12
  266. package/dist/core/model-registry-schemas.js.map +1 -1
  267. package/dist/core/model-registry-types.d.ts +7 -6
  268. package/dist/core/model-registry-types.d.ts.map +1 -1
  269. package/dist/core/model-registry-types.js.map +1 -1
  270. package/dist/core/model-registry.d.ts +5 -0
  271. package/dist/core/model-registry.d.ts.map +1 -1
  272. package/dist/core/model-registry.js +23 -0
  273. package/dist/core/model-registry.js.map +1 -1
  274. package/dist/core/model-resolver-cli.d.ts.map +1 -1
  275. package/dist/core/model-resolver-cli.js +33 -5
  276. package/dist/core/model-resolver-cli.js.map +1 -1
  277. package/dist/core/model-resolver-initial.d.ts +6 -1
  278. package/dist/core/model-resolver-initial.d.ts.map +1 -1
  279. package/dist/core/model-resolver-initial.js +12 -7
  280. package/dist/core/model-resolver-initial.js.map +1 -1
  281. package/dist/core/model-resolver.d.ts +1 -1
  282. package/dist/core/model-resolver.d.ts.map +1 -1
  283. package/dist/core/model-resolver.js +1 -1
  284. package/dist/core/model-resolver.js.map +1 -1
  285. package/dist/core/resource-loader-context-files.d.ts +1 -0
  286. package/dist/core/resource-loader-context-files.d.ts.map +1 -1
  287. package/dist/core/resource-loader-context-files.js +13 -10
  288. package/dist/core/resource-loader-context-files.js.map +1 -1
  289. package/dist/core/sdk.d.ts.map +1 -1
  290. package/dist/core/sdk.js +2 -2
  291. package/dist/core/sdk.js.map +1 -1
  292. package/dist/core/session-entry-normalization.d.ts +7 -0
  293. package/dist/core/session-entry-normalization.d.ts.map +1 -0
  294. package/dist/core/session-entry-normalization.js +14 -0
  295. package/dist/core/session-entry-normalization.js.map +1 -0
  296. package/dist/core/session-manager-core.d.ts.map +1 -1
  297. package/dist/core/session-manager-core.js +1 -0
  298. package/dist/core/session-manager-core.js.map +1 -1
  299. package/dist/core/session-manager-history.d.ts +2 -2
  300. package/dist/core/session-manager-history.d.ts.map +1 -1
  301. package/dist/core/session-manager-history.js +127 -108
  302. package/dist/core/session-manager-history.js.map +1 -1
  303. package/dist/core/settings-manager-basic-accessors.d.ts +2 -2
  304. package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
  305. package/dist/core/settings-manager-basic-accessors.js.map +1 -1
  306. package/dist/core/settings-types.d.ts +1 -1
  307. package/dist/core/settings-types.d.ts.map +1 -1
  308. package/dist/core/settings-types.js.map +1 -1
  309. package/dist/core/tools/bash.d.ts.map +1 -1
  310. package/dist/core/tools/bash.js +11 -8
  311. package/dist/core/tools/bash.js.map +1 -1
  312. package/dist/main-session.d.ts.map +1 -1
  313. package/dist/main-session.js +1 -0
  314. package/dist/main-session.js.map +1 -1
  315. package/dist/modes/interactive/components/settings-selector-options.d.ts.map +1 -1
  316. package/dist/modes/interactive/components/settings-selector-options.js +3 -1
  317. package/dist/modes/interactive/components/settings-selector-options.js.map +1 -1
  318. package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
  319. package/dist/modes/interactive/components/thinking-selector.js +2 -1
  320. package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
  321. package/dist/modes/interactive/interactive-agent-events.d.ts.map +1 -1
  322. package/dist/modes/interactive/interactive-agent-events.js +2 -1
  323. package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
  324. package/dist/modes/interactive/interactive-child-ordering.d.ts +7 -0
  325. package/dist/modes/interactive/interactive-child-ordering.d.ts.map +1 -0
  326. package/dist/modes/interactive/interactive-child-ordering.js +26 -0
  327. package/dist/modes/interactive/interactive-child-ordering.js.map +1 -0
  328. package/dist/modes/interactive/interactive-deferred-startup.d.ts.map +1 -1
  329. package/dist/modes/interactive/interactive-deferred-startup.js +2 -2
  330. package/dist/modes/interactive/interactive-deferred-startup.js.map +1 -1
  331. package/dist/modes/interactive/interactive-mode-deps.d.ts +1 -1
  332. package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
  333. package/dist/modes/interactive/interactive-mode-deps.js +1 -1
  334. package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
  335. package/dist/modes/interactive/interactive-model-routing.d.ts.map +1 -1
  336. package/dist/modes/interactive/interactive-model-routing.js +8 -3
  337. package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
  338. package/dist/modes/interactive/theme/theme-class.d.ts +1 -1
  339. package/dist/modes/interactive/theme/theme-class.d.ts.map +1 -1
  340. package/dist/modes/interactive/theme/theme-class.js +2 -0
  341. package/dist/modes/interactive/theme/theme-class.js.map +1 -1
  342. package/dist/utils/clipboard-image.d.ts.map +1 -1
  343. package/dist/utils/clipboard-image.js +3 -0
  344. package/dist/utils/clipboard-image.js.map +1 -1
  345. package/docs/changelog.mdx +19 -0
  346. package/docs/compaction.md +55 -48
  347. package/docs/custom-provider.md +18 -5
  348. package/docs/extensions.md +7 -3
  349. package/docs/models.md +69 -10
  350. package/docs/providers.md +1 -1
  351. package/docs/quickstart.md +11 -7
  352. package/docs/rpc.md +2 -2
  353. package/docs/sdk.md +1 -1
  354. package/docs/settings.md +3 -3
  355. package/docs/subagents.md +36 -5
  356. package/docs/tools.md +1 -1
  357. package/docs/usage.md +4 -2
  358. package/docs/workflows.md +26 -43
  359. package/examples/extensions/preset.ts +2 -2
  360. package/examples/extensions/subagent/README.md +2 -2
  361. package/examples/extensions/subagent/index.ts +1 -2
  362. package/examples/extensions/subagent/schemas.ts +4 -1
  363. package/examples/sdk/12-full-control.ts +1 -1
  364. package/npm-shrinkwrap.json +48 -51
  365. package/package.json +7 -7
  366. package/dist/builtin/subagents/src/runs/foreground/chain-clarify-behavior.ts +0 -75
  367. package/dist/builtin/subagents/src/runs/foreground/chain-clarify-component.ts +0 -202
  368. package/dist/builtin/subagents/src/runs/foreground/chain-clarify-edit.ts +0 -97
  369. package/dist/builtin/subagents/src/runs/foreground/chain-clarify-editor.ts +0 -160
  370. package/dist/builtin/subagents/src/runs/foreground/chain-clarify-frame.ts +0 -72
  371. package/dist/builtin/subagents/src/runs/foreground/chain-clarify-render-modes.ts +0 -161
  372. package/dist/builtin/subagents/src/runs/foreground/chain-clarify-render-selectors.ts +0 -203
  373. package/dist/builtin/subagents/src/runs/foreground/chain-clarify-selectors.ts +0 -234
  374. package/dist/builtin/subagents/src/runs/foreground/chain-clarify-state.ts +0 -103
  375. package/dist/builtin/subagents/src/runs/foreground/chain-clarify-types.ts +0 -29
  376. package/dist/builtin/subagents/src/runs/foreground/chain-clarify.ts +0 -9
  377. package/dist/builtin/subagents/src/runs/foreground/chain-execution-clarify.ts +0 -117
@@ -0,0 +1,294 @@
1
+ import * as fs from "node:fs";
2
+ import * as path from "node:path";
3
+ import type { DrainableSource, JsonlWriteStream } from "./jsonl-writer.ts";
4
+
5
+ interface TelemetryState {
6
+ telemetryBytes: number;
7
+ telemetryTruncated: boolean;
8
+ }
9
+
10
+ interface SharedEventWriter extends TelemetryState {
11
+ stream: JsonlWriteStream;
12
+ sources: Set<DrainableSource>;
13
+ refs: number;
14
+ backpressured: boolean;
15
+ closed: boolean;
16
+ failed: boolean;
17
+ filePath: string;
18
+ key: string;
19
+ closingLines: string[];
20
+ settled: Promise<void>;
21
+ resolveSettled: () => void;
22
+ }
23
+
24
+ const writers = new Map<string, SharedEventWriter>();
25
+
26
+ interface TelemetryHydration extends TelemetryState {
27
+ dev: number;
28
+ ino: number;
29
+ size: number;
30
+ mtimeMs: number;
31
+ ctimeMs: number;
32
+ }
33
+
34
+ const hydrationCache = new Map<string, TelemetryHydration>();
35
+ const MAX_HYDRATION_ENTRIES = 512;
36
+ const HYDRATION_CHUNK_BYTES = 64 * 1024;
37
+ const TRUNCATION_MARKER = '"type":"subagent.child.telemetry_truncated"';
38
+ let hydrationScanCount = 0;
39
+ let hydrationScannedBytes = 0;
40
+
41
+ function keyFor(filePath: string): string {
42
+ return path.resolve(filePath);
43
+ }
44
+
45
+ function cacheHydration(key: string, hydration: TelemetryHydration): void {
46
+ hydrationCache.delete(key);
47
+ hydrationCache.set(key, hydration);
48
+ while (hydrationCache.size > MAX_HYDRATION_ENTRIES) {
49
+ const oldest = hydrationCache.keys().next().value as string | undefined;
50
+ if (oldest === undefined) break;
51
+ hydrationCache.delete(oldest);
52
+ }
53
+ }
54
+
55
+ function scanForTruncationMarker(filePath: string): boolean {
56
+ hydrationScanCount += 1;
57
+ const handle = fs.openSync(filePath, "r");
58
+ try {
59
+ const buffer = Buffer.allocUnsafe(HYDRATION_CHUNK_BYTES);
60
+ let offset = 0;
61
+ let overlap = "";
62
+ while (true) {
63
+ const count = fs.readSync(handle, buffer, 0, buffer.length, offset);
64
+ if (count === 0) return false;
65
+ hydrationScannedBytes += count;
66
+ const text = overlap + buffer.subarray(0, count).toString("utf-8");
67
+ if (text.includes(TRUNCATION_MARKER)) return true;
68
+ overlap = text.slice(-(TRUNCATION_MARKER.length - 1));
69
+ offset += count;
70
+ }
71
+ } finally {
72
+ fs.closeSync(handle);
73
+ }
74
+ }
75
+
76
+ function hydrationFromStat(stat: fs.Stats, state: TelemetryState): TelemetryHydration {
77
+ return { dev: Number(stat.dev), ino: Number(stat.ino), size: stat.size, mtimeMs: stat.mtimeMs, ctimeMs: stat.ctimeMs, ...state };
78
+ }
79
+
80
+ function existingTelemetryState(filePath: string, seed?: TelemetryState): TelemetryState {
81
+ const key = keyFor(filePath);
82
+ try {
83
+ const stat = fs.statSync(filePath);
84
+ const telemetryTruncated = Boolean(seed?.telemetryTruncated) || scanForTruncationMarker(filePath);
85
+ const telemetryBytes = Math.max(stat.size, seed?.telemetryBytes ?? 0);
86
+ cacheHydration(key, hydrationFromStat(stat, { telemetryBytes, telemetryTruncated }));
87
+ return { telemetryBytes, telemetryTruncated };
88
+ } catch {
89
+ hydrationCache.delete(key);
90
+ return seed
91
+ ? { telemetryBytes: seed.telemetryBytes, telemetryTruncated: seed.telemetryTruncated }
92
+ : { telemetryBytes: 0, telemetryTruncated: false };
93
+ }
94
+ }
95
+
96
+ function cacheSettledWriter(writer: SharedEventWriter): void {
97
+ try {
98
+ const stat = fs.statSync(writer.filePath);
99
+ cacheHydration(writer.key, hydrationFromStat(stat, {
100
+ telemetryBytes: Math.max(stat.size, writer.telemetryBytes),
101
+ telemetryTruncated: writer.telemetryTruncated,
102
+ }));
103
+ } catch { hydrationCache.delete(writer.key); }
104
+ }
105
+
106
+ export function resetEventWriterHydrationCacheForTests(): void {
107
+ hydrationCache.clear();
108
+ hydrationScanCount = 0;
109
+ hydrationScannedBytes = 0;
110
+ }
111
+
112
+ export function eventWriterHydrationCacheSizeForTests(): number {
113
+ return hydrationCache.size;
114
+ }
115
+
116
+ export function eventWriterHydrationScanStatsForTests(): { scans: number; bytes: number } {
117
+ return { scans: hydrationScanCount, bytes: hydrationScannedBytes };
118
+ }
119
+
120
+ function resumeSources(writer: SharedEventWriter): void {
121
+ for (const source of writer.sources) source.resume();
122
+ writer.sources.clear();
123
+ writer.backpressured = false;
124
+ }
125
+
126
+ function settleWriter(writer: SharedEventWriter): void {
127
+ if (!writer.failed) cacheSettledWriter(writer);
128
+ if (writers.get(writer.key) === writer) writers.delete(writer.key);
129
+ resumeSources(writer);
130
+ writer.resolveSettled();
131
+ }
132
+
133
+ function failWriter(writer: SharedEventWriter): void {
134
+ if (writer.failed) return;
135
+ writer.failed = true;
136
+ writer.closed = true;
137
+ settleWriter(writer);
138
+ }
139
+
140
+ function write(writer: SharedEventWriter, chunk: string): void {
141
+ if (writer.closed || writer.failed) return;
142
+ try {
143
+ const accepted = writer.stream.write(chunk);
144
+ if (!accepted && !writer.backpressured) {
145
+ writer.backpressured = true;
146
+ for (const source of writer.sources) source.pause();
147
+ writer.stream.once("drain", () => {
148
+ writer.backpressured = false;
149
+ if (!writer.closed && !writer.failed) for (const source of writer.sources) source.resume();
150
+ });
151
+ }
152
+ } catch {
153
+ failWriter(writer);
154
+ }
155
+ }
156
+
157
+ export interface EventWriterLease {
158
+ reserveTelemetry(bytes: number, maxBytes: number): boolean;
159
+ claimTruncationMarker(): boolean;
160
+ writeLine(line: string): void;
161
+ close(): Promise<void>;
162
+ }
163
+
164
+ type StreamFactory = (filePath: string) => JsonlWriteStream;
165
+
166
+ function createDeferredLease(
167
+ closingWriter: SharedEventWriter,
168
+ filePath: string,
169
+ source: DrainableSource,
170
+ createWriteStream: StreamFactory,
171
+ ): EventWriterLease {
172
+ const bufferedLines: string[] = [];
173
+ let inner: EventWriterLease | undefined;
174
+ let closePromise: Promise<void> | undefined;
175
+ const activate = async (): Promise<void> => {
176
+ await closingWriter.settled;
177
+ inner = acquireEventWriterInternal(filePath, source, createWriteStream, closingWriter);
178
+ if (!inner) return;
179
+ for (const line of bufferedLines) inner.writeLine(line);
180
+ bufferedLines.length = 0;
181
+ };
182
+ const activated = activate();
183
+ return {
184
+ reserveTelemetry(bytes, maxBytes) {
185
+ if (inner) return inner.reserveTelemetry(bytes, maxBytes);
186
+ if (closingWriter.telemetryTruncated || closingWriter.telemetryBytes + bytes > maxBytes) return false;
187
+ closingWriter.telemetryBytes += bytes;
188
+ return true;
189
+ },
190
+ claimTruncationMarker() {
191
+ if (inner) return inner.claimTruncationMarker();
192
+ if (closingWriter.telemetryTruncated) return false;
193
+ closingWriter.telemetryTruncated = true;
194
+ return true;
195
+ },
196
+ writeLine(line) {
197
+ if (!line.trim()) return;
198
+ if (inner) inner.writeLine(line);
199
+ else bufferedLines.push(line);
200
+ },
201
+ close() {
202
+ closePromise ??= activated.then(() => inner?.close());
203
+ return closePromise;
204
+ },
205
+ };
206
+ }
207
+
208
+ function createWriter(filePath: string, key: string, createWriteStream: StreamFactory, seed?: TelemetryState): SharedEventWriter | undefined {
209
+ let stream: JsonlWriteStream;
210
+ try {
211
+ stream = createWriteStream(filePath);
212
+ } catch {
213
+ return undefined;
214
+ }
215
+ let resolveSettled = () => {};
216
+ const settled = new Promise<void>((resolve) => { resolveSettled = resolve; });
217
+ const writer: SharedEventWriter = {
218
+ stream, sources: new Set(), refs: 0, backpressured: false,
219
+ ...existingTelemetryState(filePath, seed),
220
+ closed: false, failed: false, filePath, key, closingLines: [], settled, resolveSettled,
221
+ };
222
+ stream.on?.("error", () => failWriter(writer));
223
+ writers.set(key, writer);
224
+ return writer;
225
+ }
226
+
227
+ function acquireEventWriterInternal(
228
+ filePath: string,
229
+ source: DrainableSource,
230
+ createWriteStream: StreamFactory,
231
+ seed?: TelemetryState,
232
+ ): EventWriterLease | undefined {
233
+ const key = keyFor(filePath);
234
+ let writer = writers.get(key);
235
+ if (writer?.closed) return createDeferredLease(writer, filePath, source, createWriteStream);
236
+ writer ??= createWriter(filePath, key, createWriteStream, seed);
237
+ if (!writer) return undefined;
238
+ writer.refs += 1;
239
+ writer.sources.add(source);
240
+ if (writer.backpressured) source.pause();
241
+ let closePromise: Promise<void> | undefined;
242
+ return {
243
+ reserveTelemetry(bytes, maxBytes) {
244
+ if (writer!.failed || writer!.telemetryTruncated || writer!.telemetryBytes + bytes > maxBytes) return false;
245
+ writer!.telemetryBytes += bytes;
246
+ return true;
247
+ },
248
+ claimTruncationMarker() {
249
+ if (writer!.failed || writer!.telemetryTruncated) return false;
250
+ writer!.telemetryTruncated = true;
251
+ return true;
252
+ },
253
+ writeLine(line) {
254
+ if (line.trim()) write(writer!, `${line}\n`);
255
+ },
256
+ close() {
257
+ if (closePromise) return closePromise;
258
+ writer!.sources.delete(source);
259
+ writer!.refs -= 1;
260
+ if (writer!.refs > 0 || writer!.failed) return closePromise = Promise.resolve();
261
+ writer!.closed = true;
262
+ try {
263
+ writer!.stream.end(() => {
264
+ if (!writer!.failed) {
265
+ for (const line of writer!.closingLines) {
266
+ try { fs.appendFileSync(writer!.filePath, line); } catch { /* telemetry failure is non-fatal */ }
267
+ }
268
+ settleWriter(writer!);
269
+ }
270
+ });
271
+ } catch {
272
+ failWriter(writer!);
273
+ }
274
+ return closePromise = writer!.settled;
275
+ },
276
+ };
277
+ }
278
+
279
+ export function acquireEventWriter(
280
+ filePath: string,
281
+ source: DrainableSource,
282
+ createWriteStream: StreamFactory = (target) => fs.createWriteStream(target, { flags: "a" }),
283
+ ): EventWriterLease | undefined {
284
+ return acquireEventWriterInternal(filePath, source, createWriteStream);
285
+ }
286
+
287
+ /** Route lifecycle/control appends through an active child writer to avoid mixed handles. */
288
+ export function appendToActiveEventWriter(filePath: string, line: string): boolean {
289
+ const writer = writers.get(keyFor(filePath));
290
+ if (!writer) return false;
291
+ if (writer.closed) writer.closingLines.push(`${line}\n`);
292
+ else write(writer, `${line}\n`);
293
+ return true;
294
+ }
@@ -0,0 +1,44 @@
1
+ import * as fs from "node:fs";
2
+
3
+ export interface ExclusivePublicationFs {
4
+ linkSync?: typeof fs.linkSync;
5
+ copyFileSync?: typeof fs.copyFileSync;
6
+ unlinkSync: typeof fs.unlinkSync;
7
+ }
8
+
9
+ export function errorCode(error: unknown): string | undefined {
10
+ return typeof error === "object" && error !== null && "code" in error
11
+ ? (error as NodeJS.ErrnoException).code
12
+ : undefined;
13
+ }
14
+
15
+ /** Publish an existing file without ever replacing the destination. */
16
+ export function publishFileExclusive(
17
+ source: string,
18
+ destination: string,
19
+ fsApi: ExclusivePublicationFs = fs,
20
+ ): "published" | "exists" {
21
+ try {
22
+ (fsApi.linkSync ?? fs.linkSync)(source, destination);
23
+ return "published";
24
+ } catch (error) {
25
+ const code = errorCode(error);
26
+ if (code === "EEXIST") return "exists";
27
+ if (code !== "EPERM" && code !== "EACCES" && code !== "ENOTSUP" && code !== "EXDEV") throw error;
28
+ }
29
+ try {
30
+ (fsApi.copyFileSync ?? fs.copyFileSync)(source, destination, fs.constants.COPYFILE_EXCL);
31
+ return "published";
32
+ } catch (error) {
33
+ if (errorCode(error) === "EEXIST") return "exists";
34
+ throw error;
35
+ }
36
+ }
37
+
38
+ export function unlinkIfPresent(file: string, fsApi: Pick<typeof fs, "unlinkSync"> = fs): void {
39
+ try {
40
+ fsApi.unlinkSync(file);
41
+ } catch (error) {
42
+ if (errorCode(error) !== "ENOENT") throw error;
43
+ }
44
+ }
@@ -7,6 +7,7 @@ export interface DrainableSource {
7
7
 
8
8
  export interface JsonlWriteStream {
9
9
  write(chunk: string): boolean;
10
+ on?(event: "error", listener: (error: Error) => void): JsonlWriteStream;
10
11
  once(event: "drain", listener: () => void): JsonlWriteStream;
11
12
  end(callback?: () => void): void;
12
13
  }
@@ -1,4 +1,4 @@
1
- export const THINKING_LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh"] as const;
1
+ export const THINKING_LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh", "max"] as const;
2
2
  export type ThinkingLevel = typeof THINKING_LEVELS[number];
3
3
  export type ThinkingLevelMap = Partial<Record<ThinkingLevel, string | null>>;
4
4
 
@@ -87,7 +87,7 @@ export function getSupportedThinkingLevels(model: ModelInfo | undefined): Thinki
87
87
  const levels = THINKING_LEVELS.filter((level) => {
88
88
  const mapped = model.thinkingLevelMap?.[level];
89
89
  if (mapped === null) return false;
90
- if (level === "xhigh") return mapped !== undefined;
90
+ if (level === "xhigh" || level === "max") return mapped !== undefined;
91
91
  return true;
92
92
  });
93
93
  return levels;
@@ -286,15 +286,21 @@ export function suppressProgressForReadOnlyTask(behavior: ResolvedStepBehavior,
286
286
  return behavior.progress && taskDisallowsFileUpdates(policyTask) ? { ...behavior, progress: false } : behavior;
287
287
  }
288
288
 
289
+ /** Resolve single-agent progress, preserving read-only suppression only for inherited defaults. */
290
+ export function resolveSingleProgress(agentConfig: AgentConfig, override: boolean | undefined, task: string | undefined): boolean {
291
+ const behavior = resolveStepBehavior(agentConfig, { progress: override });
292
+ return override !== undefined ? behavior.progress : suppressProgressForReadOnlyTask(behavior, task).progress;
293
+ }
294
+
289
295
  // =============================================================================
290
296
  // Chain Instruction Injection
291
297
  // =============================================================================
292
298
 
293
- /**
294
- * Resolve a file path: absolute paths pass through, relative paths get chainDir prepended.
295
- */
296
- function resolveChainPath(filePath: string, chainDir: string): string {
297
- return path.isAbsolute(filePath) ? filePath : path.join(chainDir, filePath);
299
+ /** Build the common read prefix, resolving relative paths against the child's effective cwd. */
300
+ export function buildReadInstruction(reads: string[] | false | undefined, cwd: string): string {
301
+ if (!reads || reads.length === 0) return "";
302
+ const files = reads.map((file) => path.resolve(cwd, file));
303
+ return `[Read from: ${files.join(", ")}]`;
298
304
  }
299
305
 
300
306
  /**
@@ -302,9 +308,15 @@ function resolveChainPath(filePath: string, chainDir: string): string {
302
308
  * These are appended to the task to tell the agent what to read/write.
303
309
  */
304
310
  export function writeInitialProgressFile(progressDir: string): void {
311
+ fs.mkdirSync(progressDir, { recursive: true });
305
312
  fs.writeFileSync(path.join(progressDir, "progress.md"), INITIAL_PROGRESS_CONTENT);
306
313
  }
307
314
 
315
+ /** Add the child-facing instruction for a single-agent progress file. */
316
+ export function injectSingleProgressInstruction(task: string, progressDir: string): string {
317
+ return `${task}\n\n---\nCreate and maintain progress at: ${path.join(progressDir, "progress.md")}`;
318
+ }
319
+
308
320
  export function buildChainInstructions(
309
321
  behavior: ResolvedStepBehavior,
310
322
  chainDir: string,
@@ -315,14 +327,12 @@ export function buildChainInstructions(
315
327
  const suffixParts: string[] = [];
316
328
 
317
329
  // READS - prepend to override any hardcoded filenames in task text
318
- if (behavior.reads && behavior.reads.length > 0) {
319
- const files = behavior.reads.map((f) => resolveChainPath(f, chainDir));
320
- prefixParts.push(`[Read from: ${files.join(", ")}]`);
321
- }
330
+ const readInstruction = buildReadInstruction(behavior.reads, chainDir);
331
+ if (readInstruction) prefixParts.push(readInstruction);
322
332
 
323
333
  // OUTPUT - prepend so agent knows where to write
324
334
  if (behavior.output) {
325
- const outputPath = resolveChainPath(behavior.output, chainDir);
335
+ const outputPath = path.isAbsolute(behavior.output) ? behavior.output : path.join(chainDir, behavior.output);
326
336
  prefixParts.push(`[Write to: ${outputPath}]`);
327
337
  }
328
338
 
@@ -8,6 +8,7 @@ import type {
8
8
  ActivityState,
9
9
  ChainOutputMap,
10
10
  ModelAttempt,
11
+ SingleResult,
11
12
  SubagentResultStatus,
12
13
  SubagentRunMode,
13
14
  TokenUsage,
@@ -216,6 +217,7 @@ export interface ForegroundResumeChild {
216
217
  index: number;
217
218
  sessionFile?: string;
218
219
  status: SubagentResultStatus;
220
+ result?: SingleResult;
219
221
  }
220
222
 
221
223
  export interface ForegroundResumeRun {
@@ -256,7 +258,7 @@ export interface SubagentState {
256
258
  cleanupTimers: Map<string, ReturnType<typeof setTimeout>>;
257
259
  lastUiContext: ExtensionContext | null;
258
260
  poller: NodeJS.Timeout | null;
259
- completionSeen: Map<string, number>;
261
+ completionSeen: Map<string, number | { seenAt: number; signature?: string }>;
260
262
  watcher: FSWatcher | null;
261
263
  watcherRestartTimer: ReturnType<typeof setTimeout> | null;
262
264
  resultFileCoalescer: {
@@ -13,6 +13,7 @@ import type {
13
13
  MaxOutputConfig,
14
14
  OutputMode,
15
15
  ResolvedControlConfig,
16
+ SingleResult,
16
17
  } from "./types-results.ts";
17
18
 
18
19
  // ============================================================================
@@ -58,6 +59,7 @@ export interface RunSyncOptions {
58
59
  interruptSignal?: AbortSignal;
59
60
  allowIntercomDetach?: boolean;
60
61
  intercomEvents?: IntercomEventBus;
62
+ onDetachedExit?: (result: SingleResult) => void;
61
63
  onUpdate?: (r: AgentToolResult<Details>) => void;
62
64
  onControlEvent?: (event: ControlEvent) => void;
63
65
  controlConfig?: ResolvedControlConfig;
@@ -77,7 +77,7 @@ export function resolveTempScopeId(options?: {
77
77
  return "shared";
78
78
  }
79
79
 
80
- const MAX_PARALLEL = 8;
80
+ export const MAX_PARALLEL_TASKS = 50;
81
81
  export const MAX_CONCURRENCY = 4;
82
82
  export const TEMP_ROOT_DIR = path.join(os.tmpdir(), `${APP_NAME}-subagents-${resolveTempScopeId()}`);
83
83
  export const RESULTS_DIR = path.join(TEMP_ROOT_DIR, "async-subagent-results");
@@ -110,7 +110,8 @@ function normalizeTopLevelParallelValue(value: unknown): number | undefined {
110
110
  }
111
111
 
112
112
  export function resolveTopLevelParallelMaxTasks(value: unknown): number {
113
- return normalizeTopLevelParallelValue(value) ?? MAX_PARALLEL;
113
+ const configuredMax = normalizeTopLevelParallelValue(value);
114
+ return configuredMax === undefined ? MAX_PARALLEL_TASKS : Math.min(configuredMax, MAX_PARALLEL_TASKS);
114
115
  }
115
116
 
116
117
  export function resolveTopLevelParallelConcurrency(
@@ -160,7 +160,7 @@ async function requestSlashRun(
160
160
  if (done || !data || typeof data !== "object") return;
161
161
  const update = data as SlashSubagentUpdate;
162
162
  if (update.requestId !== requestId) return;
163
- applySlashUpdate(requestId, update);
163
+ applySlashUpdate(requestId, update, pi);
164
164
  if (!ctx.hasUI) return;
165
165
  const tool = update.currentTool ? ` ${update.currentTool}` : "";
166
166
  const count = update.toolCount ?? 0;
@@ -260,7 +260,7 @@ async function runSlashSubagent(
260
260
  ): Promise<void> {
261
261
  if (ctx.hasUI) ctx.ui.setToolsExpanded(false);
262
262
  const requestId = randomUUID();
263
- const initialDetails = buildSlashInitialResult(requestId, params);
263
+ const initialDetails = buildSlashInitialResult(requestId, params, pi);
264
264
  const initialText = extractSlashMessageText(initialDetails.result.content) || "Running subagent...";
265
265
  pi.sendMessage({
266
266
  customType: SLASH_RESULT_TYPE,
@@ -272,7 +272,7 @@ async function runSlashSubagent(
272
272
 
273
273
  try {
274
274
  const response = await requestSlashRun(pi, ctx, requestId, params);
275
- const finalDetails = finalizeSlashResult(response);
275
+ const finalDetails = finalizeSlashResult(response, pi);
276
276
  pi.sendMessage({
277
277
  customType: SLASH_RESULT_TYPE,
278
278
  content: buildSlashExportText(response),
@@ -288,7 +288,7 @@ async function runSlashSubagent(
288
288
  }
289
289
  } catch (error) {
290
290
  const message = error instanceof Error ? error.message : String(error);
291
- const failedDetails = failSlashResult(requestId, params, message);
291
+ const failedDetails = failSlashResult(requestId, params, message, pi);
292
292
  pi.sendMessage({
293
293
  customType: SLASH_RESULT_TYPE,
294
294
  content: `## Subagent result\n\n${message}`,
@@ -402,11 +402,8 @@ export function registerSlashCommands(
402
402
  if (!state.baseCwd) { ctx.ui.notify("Subagent session cwd is not initialized yet", "error"); return; }
403
403
  const agents = discoverAgents(state.baseCwd, "both").agents;
404
404
  if (!agents.find((a) => a.name === agentName)) { ctx.ui.notify(`Unknown agent: ${agentName}`, "error"); return; }
405
- let finalTask = task;
406
- if (inline.reads && Array.isArray(inline.reads) && inline.reads.length > 0) {
407
- finalTask = `[Read from: ${inline.reads.join(", ")}]\n\n${finalTask}`;
408
- }
409
- const params: SubagentParamsLike = { agent: agentName, task: finalTask, clarify: false, agentScope: "both" };
405
+ const params: SubagentParamsLike = { agent: agentName, task, agentScope: "both" };
406
+ if (inline.reads !== undefined) params.reads = inline.reads;
410
407
  if (inline.output !== undefined) params.output = inline.output;
411
408
  if (inline.outputMode !== undefined) params.outputMode = inline.outputMode;
412
409
  if (inline.skill !== undefined) params.skill = inline.skill;
@@ -433,7 +430,7 @@ export function registerSlashCommands(
433
430
  ...(config.skill !== undefined ? { skill: config.skill } : {}),
434
431
  ...(config.progress !== undefined ? { progress: config.progress } : {}),
435
432
  }));
436
- const params: SubagentParamsLike = { chain, task: parsed.task, clarify: false, agentScope: "both" };
433
+ const params: SubagentParamsLike = { chain, task: parsed.task, agentScope: "both" };
437
434
  if (bg) params.async = true;
438
435
  if (fork) params.context = "fork";
439
436
  await runSlashSubagent(pi, ctx, params);
@@ -462,7 +459,7 @@ export function registerSlashCommands(
462
459
  ctx.ui.notify(`Unknown chain: ${chainName}`, "error");
463
460
  return;
464
461
  }
465
- const params: SubagentParamsLike = { chain: mapSavedChainSteps(chain), task, clarify: false, agentScope: "both" };
462
+ const params: SubagentParamsLike = { chain: mapSavedChainSteps(chain), task, agentScope: "both" };
466
463
  if (bg) params.async = true;
467
464
  if (fork) params.context = "fork";
468
465
  await runSlashSubagent(pi, ctx, params);
@@ -485,7 +482,7 @@ export function registerSlashCommands(
485
482
  ...(config.skill !== undefined ? { skill: config.skill } : {}),
486
483
  ...(config.progress !== undefined ? { progress: config.progress } : {}),
487
484
  }));
488
- const params: SubagentParamsLike = { tasks, clarify: false, agentScope: "both" };
485
+ const params: SubagentParamsLike = { tasks, agentScope: "both" };
489
486
  if (bg) params.async = true;
490
487
  if (fork) params.context = "fork";
491
488
  await runSlashSubagent(pi, ctx, params);