@bastani/atomic 0.9.19-alpha.1 → 0.9.19-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (698) hide show
  1. package/CHANGELOG.md +94 -0
  2. package/dist/builtin/intercom/CHANGELOG.md +16 -0
  3. package/dist/builtin/intercom/README.md +21 -11
  4. package/dist/builtin/intercom/broker/broker.ts +73 -9
  5. package/dist/builtin/intercom/broker/client.ts +4 -0
  6. package/dist/builtin/intercom/broker/framing.ts +5 -2
  7. package/dist/builtin/intercom/broker/group-membership.ts +4 -2
  8. package/dist/builtin/intercom/broker/presence-handler.ts +14 -0
  9. package/dist/builtin/intercom/broker/send-handler.ts +34 -5
  10. package/dist/builtin/intercom/broker/terminal-questions.ts +29 -0
  11. package/dist/builtin/intercom/index.bundle.mjs +936 -740
  12. package/dist/builtin/intercom/package.json +2 -2
  13. package/dist/builtin/intercom/recipient-purpose.ts +9 -0
  14. package/dist/builtin/intercom/recoverable-disconnect.ts +2 -3
  15. package/dist/builtin/intercom/retry-policy.ts +4 -2
  16. package/dist/builtin/intercom/skills/intercom/SKILL.md +5 -4
  17. package/dist/builtin/intercom/types.ts +16 -2
  18. package/dist/builtin/mcp/CHANGELOG.md +6 -0
  19. package/dist/builtin/mcp/README.md +2 -0
  20. package/dist/builtin/mcp/index.bundle.mjs +2201 -12000
  21. package/dist/builtin/mcp/package.json +2 -2
  22. package/dist/builtin/subagents/CHANGELOG.md +27 -0
  23. package/dist/builtin/subagents/README.md +33 -12
  24. package/dist/builtin/subagents/agents/code-simplifier.md +1 -1
  25. package/dist/builtin/subagents/agents/codebase-analyzer.md +1 -1
  26. package/dist/builtin/subagents/agents/codebase-locator.md +2 -2
  27. package/dist/builtin/subagents/agents/codebase-online-researcher.md +1 -1
  28. package/dist/builtin/subagents/agents/codebase-pattern-finder.md +2 -2
  29. package/dist/builtin/subagents/agents/codebase-research-analyzer.md +1 -1
  30. package/dist/builtin/subagents/agents/codebase-research-locator.md +2 -2
  31. package/dist/builtin/subagents/agents/debugger.md +1 -1
  32. package/dist/builtin/subagents/agents/worker.md +1 -1
  33. package/dist/builtin/subagents/package.json +2 -2
  34. package/dist/builtin/subagents/skills/herdr/LICENSE +201 -0
  35. package/dist/builtin/subagents/skills/herdr/SKILL.md +202 -0
  36. package/dist/builtin/subagents/skills/subagent/SKILL.md +14 -10
  37. package/dist/builtin/subagents/skills/tmux/SKILL.md +1 -1
  38. package/dist/builtin/subagents/src/extension/index.bundle.mjs +1284 -609
  39. package/dist/builtin/web-access/index.bundle.mjs +26280 -26274
  40. package/dist/builtin/web-access/package.json +2 -2
  41. package/dist/builtin/workflows/CHANGELOG.md +38 -0
  42. package/dist/builtin/workflows/README.md +1 -1
  43. package/dist/builtin/workflows/builtin/adversarial-verification.js +5 -7
  44. package/dist/builtin/workflows/builtin/{chunk-reqr3sr3.js → chunk-1kx4aggw.js} +22 -22
  45. package/dist/builtin/workflows/builtin/{chunk-42s7sw0b.js → chunk-62v3gg9f.js} +9 -9
  46. package/dist/builtin/workflows/builtin/{chunk-wgccch41.js → chunk-6w6cvk6b.js} +16 -16
  47. package/dist/builtin/workflows/builtin/{chunk-zbekjqew.js → chunk-a2kdsqn8.js} +4 -4
  48. package/dist/builtin/workflows/builtin/{chunk-ze5x3d1r.js → chunk-fg9esgkj.js} +7 -7
  49. package/dist/builtin/workflows/builtin/{chunk-n8h4yyew.js → chunk-g0csgs7w.js} +11 -11
  50. package/dist/builtin/workflows/builtin/{chunk-79fjkcvh.js → chunk-hbnwv56f.js} +17 -17
  51. package/dist/builtin/workflows/builtin/{chunk-ed4jfn5t.js → chunk-mygmtz6e.js} +43 -43
  52. package/dist/builtin/workflows/builtin/{chunk-7430zyas.js → chunk-p8jjwfg6.js} +1 -1
  53. package/dist/builtin/workflows/builtin/{chunk-hqpe2cyx.js → chunk-r9qq7xfj.js} +49 -49
  54. package/dist/builtin/workflows/builtin/{chunk-k3w87x8y.js → chunk-t6x2d78s.js} +10 -10
  55. package/dist/builtin/workflows/builtin/{chunk-6fqs7c01.js → chunk-z0d03ktm.js} +1 -1
  56. package/dist/builtin/workflows/builtin/{chunk-b0v2xab1.js → chunk-zggjyg5z.js} +221 -23
  57. package/dist/builtin/workflows/builtin/classify-and-act.js +5 -6
  58. package/dist/builtin/workflows/builtin/fan-out-and-synthesize.js +3 -4
  59. package/dist/builtin/workflows/builtin/generate-and-filter.js +5 -6
  60. package/dist/builtin/workflows/builtin/goal.js +7 -8
  61. package/dist/builtin/workflows/builtin/index.js +20 -22
  62. package/dist/builtin/workflows/builtin/loop-until-done.js +5 -6
  63. package/dist/builtin/workflows/builtin/open-claude-design.js +3 -3
  64. package/dist/builtin/workflows/builtin/ralph.js +7 -8
  65. package/dist/builtin/workflows/builtin/steering-context.js +3 -3
  66. package/dist/builtin/workflows/builtin/tournament.js +5 -7
  67. package/dist/builtin/workflows/package.json +2 -2
  68. package/dist/builtin/workflows/src/extension/index.bundle.mjs +26654 -25831
  69. package/dist/builtin/workflows/src/index.js +907 -473
  70. package/dist/cli/config-selector.js.map +1 -1
  71. package/dist/cli/startup-ui.d.ts +1 -1
  72. package/dist/cli/startup-ui.js.map +1 -1
  73. package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
  74. package/dist/core/agent-session-auto-compaction.js +5 -4
  75. package/dist/core/agent-session-auto-compaction.js.map +1 -1
  76. package/dist/core/agent-session-bash.d.ts +1 -1
  77. package/dist/core/agent-session-bash.d.ts.map +1 -1
  78. package/dist/core/agent-session-bash.js +5 -1
  79. package/dist/core/agent-session-bash.js.map +1 -1
  80. package/dist/core/agent-session-compaction.d.ts +1 -1
  81. package/dist/core/agent-session-compaction.js.map +1 -1
  82. package/dist/core/agent-session-custom-message-commit.d.ts +1 -1
  83. package/dist/core/agent-session-custom-message-commit.js.map +1 -1
  84. package/dist/core/agent-session-delivery-forwarding.d.ts +1 -1
  85. package/dist/core/agent-session-delivery-forwarding.js.map +1 -1
  86. package/dist/core/agent-session-events.d.ts.map +1 -1
  87. package/dist/core/agent-session-events.js +5 -0
  88. package/dist/core/agent-session-events.js.map +1 -1
  89. package/dist/core/agent-session-export.d.ts +1 -1
  90. package/dist/core/agent-session-export.js.map +1 -1
  91. package/dist/core/agent-session-extension-bindings.d.ts +8 -1
  92. package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
  93. package/dist/core/agent-session-extension-bindings.js +45 -3
  94. package/dist/core/agent-session-extension-bindings.js.map +1 -1
  95. package/dist/core/agent-session-message-queue.d.ts +1 -1
  96. package/dist/core/agent-session-message-queue.js.map +1 -1
  97. package/dist/core/agent-session-methods.d.ts +14 -7
  98. package/dist/core/agent-session-methods.d.ts.map +1 -1
  99. package/dist/core/agent-session-methods.js.map +1 -1
  100. package/dist/core/agent-session-prompt.d.ts +2 -2
  101. package/dist/core/agent-session-prompt.d.ts.map +1 -1
  102. package/dist/core/agent-session-prompt.js +22 -18
  103. package/dist/core/agent-session-prompt.js.map +1 -1
  104. package/dist/core/agent-session-runtime-auth.d.ts +1 -1
  105. package/dist/core/agent-session-runtime-auth.js.map +1 -1
  106. package/dist/core/agent-session-runtime.d.ts +13 -4
  107. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  108. package/dist/core/agent-session-runtime.js +27 -4
  109. package/dist/core/agent-session-runtime.js.map +1 -1
  110. package/dist/core/agent-session-services.d.ts +5 -1
  111. package/dist/core/agent-session-services.d.ts.map +1 -1
  112. package/dist/core/agent-session-services.js +44 -34
  113. package/dist/core/agent-session-services.js.map +1 -1
  114. package/dist/core/agent-session-state.d.ts +1 -1
  115. package/dist/core/agent-session-state.js.map +1 -1
  116. package/dist/core/agent-session-tasks.d.ts +9 -0
  117. package/dist/core/agent-session-tasks.d.ts.map +1 -0
  118. package/dist/core/agent-session-tasks.js +113 -0
  119. package/dist/core/agent-session-tasks.js.map +1 -0
  120. package/dist/core/agent-session-tool-registry.d.ts +1 -0
  121. package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
  122. package/dist/core/agent-session-tool-registry.js +30 -5
  123. package/dist/core/agent-session-tool-registry.js.map +1 -1
  124. package/dist/core/agent-session-tree.d.ts.map +1 -1
  125. package/dist/core/agent-session-tree.js +3 -0
  126. package/dist/core/agent-session-tree.js.map +1 -1
  127. package/dist/core/agent-session-types.d.ts +2 -2
  128. package/dist/core/agent-session-types.js.map +1 -1
  129. package/dist/core/agent-session.d.ts +4 -1
  130. package/dist/core/agent-session.d.ts.map +1 -1
  131. package/dist/core/agent-session.js +7 -1
  132. package/dist/core/agent-session.js.map +1 -1
  133. package/dist/core/bash-executor.d.ts +1 -1
  134. package/dist/core/bash-executor.js.map +1 -1
  135. package/dist/core/export-html/index.js.map +1 -1
  136. package/dist/core/export-html/tool-renderer.d.ts +1 -1
  137. package/dist/core/export-html/tool-renderer.js.map +1 -1
  138. package/dist/core/extension-session-state.js.map +1 -1
  139. package/dist/core/extensions/agent-events.d.ts +4 -4
  140. package/dist/core/extensions/agent-events.d.ts.map +1 -1
  141. package/dist/core/extensions/agent-events.js.map +1 -1
  142. package/dist/core/extensions/api-types.d.ts +8 -2
  143. package/dist/core/extensions/api-types.d.ts.map +1 -1
  144. package/dist/core/extensions/api-types.js.map +1 -1
  145. package/dist/core/extensions/context-types.d.ts +9 -0
  146. package/dist/core/extensions/context-types.d.ts.map +1 -1
  147. package/dist/core/extensions/context-types.js.map +1 -1
  148. package/dist/core/extensions/event-results.d.ts +1 -1
  149. package/dist/core/extensions/event-results.js.map +1 -1
  150. package/dist/core/extensions/event-types.d.ts +2 -1
  151. package/dist/core/extensions/event-types.d.ts.map +1 -1
  152. package/dist/core/extensions/event-types.js.map +1 -1
  153. package/dist/core/extensions/index.d.ts +2 -1
  154. package/dist/core/extensions/index.d.ts.map +1 -1
  155. package/dist/core/extensions/index.js.map +1 -1
  156. package/dist/core/extensions/loader-api.d.ts +1 -1
  157. package/dist/core/extensions/loader-api.d.ts.map +1 -1
  158. package/dist/core/extensions/loader-api.js +7 -0
  159. package/dist/core/extensions/loader-api.js.map +1 -1
  160. package/dist/core/extensions/loader-core.d.ts +1 -1
  161. package/dist/core/extensions/loader-core.js.map +1 -1
  162. package/dist/core/extensions/loader-discovery.d.ts +1 -1
  163. package/dist/core/extensions/loader-discovery.js.map +1 -1
  164. package/dist/core/extensions/loader-runtime.d.ts.map +1 -1
  165. package/dist/core/extensions/loader-runtime.js +3 -0
  166. package/dist/core/extensions/loader-runtime.js.map +1 -1
  167. package/dist/core/extensions/loader.d.ts +1 -1
  168. package/dist/core/extensions/loader.js.map +1 -1
  169. package/dist/core/extensions/message-types.d.ts +1 -1
  170. package/dist/core/extensions/message-types.js.map +1 -1
  171. package/dist/core/extensions/runner-context.d.ts +11 -1
  172. package/dist/core/extensions/runner-context.d.ts.map +1 -1
  173. package/dist/core/extensions/runner-context.js +41 -2
  174. package/dist/core/extensions/runner-context.js.map +1 -1
  175. package/dist/core/extensions/runner-events.d.ts +1 -1
  176. package/dist/core/extensions/runner-events.d.ts.map +1 -1
  177. package/dist/core/extensions/runner-events.js +17 -2
  178. package/dist/core/extensions/runner-events.js.map +1 -1
  179. package/dist/core/extensions/runner-ui.js.map +1 -1
  180. package/dist/core/extensions/runner.d.ts +17 -2
  181. package/dist/core/extensions/runner.d.ts.map +1 -1
  182. package/dist/core/extensions/runner.js +68 -18
  183. package/dist/core/extensions/runner.js.map +1 -1
  184. package/dist/core/extensions/runtime-types.d.ts +4 -1
  185. package/dist/core/extensions/runtime-types.d.ts.map +1 -1
  186. package/dist/core/extensions/runtime-types.js.map +1 -1
  187. package/dist/core/extensions/tool-types.d.ts +1 -1
  188. package/dist/core/extensions/tool-types.js.map +1 -1
  189. package/dist/core/extensions/types.d.ts +1 -0
  190. package/dist/core/extensions/types.d.ts.map +1 -1
  191. package/dist/core/extensions/types.js.map +1 -1
  192. package/dist/core/extensions/ui-types.d.ts +5 -1
  193. package/dist/core/extensions/ui-types.d.ts.map +1 -1
  194. package/dist/core/extensions/ui-types.js.map +1 -1
  195. package/dist/core/extensions/workflow-activity-hub.d.ts +25 -0
  196. package/dist/core/extensions/workflow-activity-hub.d.ts.map +1 -0
  197. package/dist/core/extensions/workflow-activity-hub.js +183 -0
  198. package/dist/core/extensions/workflow-activity-hub.js.map +1 -0
  199. package/dist/core/extensions/workflow-events.d.ts +118 -0
  200. package/dist/core/extensions/workflow-events.d.ts.map +1 -0
  201. package/dist/core/extensions/workflow-events.js +2 -0
  202. package/dist/core/extensions/workflow-events.js.map +1 -0
  203. package/dist/core/footer-data-provider.d.ts +8 -4
  204. package/dist/core/footer-data-provider.d.ts.map +1 -1
  205. package/dist/core/footer-data-provider.js +97 -11
  206. package/dist/core/footer-data-provider.js.map +1 -1
  207. package/dist/core/index.d.ts +3 -3
  208. package/dist/core/index.js.map +1 -1
  209. package/dist/core/keybindings.d.ts +27 -2
  210. package/dist/core/keybindings.d.ts.map +1 -1
  211. package/dist/core/keybindings.js +7 -2
  212. package/dist/core/keybindings.js.map +1 -1
  213. package/dist/core/mandatory-runtime-tools.d.ts +1 -1
  214. package/dist/core/mandatory-runtime-tools.js.map +1 -1
  215. package/dist/core/model-fallback-failures.js +2 -2
  216. package/dist/core/model-fallback-failures.js.map +1 -1
  217. package/dist/core/model-registry.d.ts +5 -1
  218. package/dist/core/model-registry.d.ts.map +1 -1
  219. package/dist/core/model-registry.js +8 -0
  220. package/dist/core/model-registry.js.map +1 -1
  221. package/dist/core/model-resolver-defaults.js +1 -1
  222. package/dist/core/model-resolver-defaults.js.map +1 -1
  223. package/dist/core/resource-loader-assets.js.map +1 -1
  224. package/dist/core/resource-loader-core.d.ts +1 -1
  225. package/dist/core/resource-loader-core.js.map +1 -1
  226. package/dist/core/resource-loader-internals.d.ts +2 -2
  227. package/dist/core/resource-loader-internals.js.map +1 -1
  228. package/dist/core/resource-loader-reload.d.ts +2 -0
  229. package/dist/core/resource-loader-reload.d.ts.map +1 -1
  230. package/dist/core/resource-loader-reload.js +231 -191
  231. package/dist/core/resource-loader-reload.js.map +1 -1
  232. package/dist/core/resource-loader-types.d.ts +4 -2
  233. package/dist/core/resource-loader-types.d.ts.map +1 -1
  234. package/dist/core/resource-loader-types.js.map +1 -1
  235. package/dist/core/sdk-exports.d.ts +2 -2
  236. package/dist/core/sdk-exports.js.map +1 -1
  237. package/dist/core/sdk-types.d.ts +2 -2
  238. package/dist/core/sdk-types.js.map +1 -1
  239. package/dist/core/sdk.js.map +1 -1
  240. package/dist/core/settings-manager-core.d.ts.map +1 -1
  241. package/dist/core/settings-manager-core.js +10 -4
  242. package/dist/core/settings-manager-core.js.map +1 -1
  243. package/dist/core/settings-storage.d.ts +1 -0
  244. package/dist/core/settings-storage.d.ts.map +1 -1
  245. package/dist/core/settings-storage.js +18 -0
  246. package/dist/core/settings-storage.js.map +1 -1
  247. package/dist/core/settings-types.d.ts +11 -0
  248. package/dist/core/settings-types.d.ts.map +1 -1
  249. package/dist/core/settings-types.js.map +1 -1
  250. package/dist/core/slash-commands.d.ts.map +1 -1
  251. package/dist/core/slash-commands.js +2 -0
  252. package/dist/core/slash-commands.js.map +1 -1
  253. package/dist/core/system-prompt.d.ts.map +1 -1
  254. package/dist/core/system-prompt.js +5 -6
  255. package/dist/core/system-prompt.js.map +1 -1
  256. package/dist/core/tasks/agent-adapter.d.ts +32 -0
  257. package/dist/core/tasks/agent-adapter.d.ts.map +1 -0
  258. package/dist/core/tasks/agent-adapter.js +71 -0
  259. package/dist/core/tasks/agent-adapter.js.map +1 -0
  260. package/dist/core/tasks/command-output.d.ts +15 -0
  261. package/dist/core/tasks/command-output.d.ts.map +1 -0
  262. package/dist/core/tasks/command-output.js +29 -0
  263. package/dist/core/tasks/command-output.js.map +1 -0
  264. package/dist/core/tasks/completion-ordering.d.ts +11 -0
  265. package/dist/core/tasks/completion-ordering.d.ts.map +1 -0
  266. package/dist/core/tasks/completion-ordering.js +19 -0
  267. package/dist/core/tasks/completion-ordering.js.map +1 -0
  268. package/dist/core/tasks/completion.d.ts +36 -0
  269. package/dist/core/tasks/completion.d.ts.map +1 -0
  270. package/dist/core/tasks/completion.js +115 -0
  271. package/dist/core/tasks/completion.js.map +1 -0
  272. package/dist/core/tasks/contracts.d.ts +404 -0
  273. package/dist/core/tasks/contracts.d.ts.map +1 -0
  274. package/dist/core/tasks/contracts.js +2 -0
  275. package/dist/core/tasks/contracts.js.map +1 -0
  276. package/dist/core/tasks/execution-scope.d.ts +10 -0
  277. package/dist/core/tasks/execution-scope.d.ts.map +1 -0
  278. package/dist/core/tasks/execution-scope.js +27 -0
  279. package/dist/core/tasks/execution-scope.js.map +1 -0
  280. package/dist/core/tasks/owner-store.d.ts +53 -0
  281. package/dist/core/tasks/owner-store.d.ts.map +1 -0
  282. package/dist/core/tasks/owner-store.js +155 -0
  283. package/dist/core/tasks/owner-store.js.map +1 -0
  284. package/dist/core/tasks/supervisor.d.ts +121 -0
  285. package/dist/core/tasks/supervisor.d.ts.map +1 -0
  286. package/dist/core/tasks/supervisor.js +916 -0
  287. package/dist/core/tasks/supervisor.js.map +1 -0
  288. package/dist/core/tasks/transcript.d.ts +23 -0
  289. package/dist/core/tasks/transcript.d.ts.map +1 -0
  290. package/dist/core/tasks/transcript.js +74 -0
  291. package/dist/core/tasks/transcript.js.map +1 -0
  292. package/dist/core/tools/ask-user-question/ask-user-question.d.ts +2 -2
  293. package/dist/core/tools/ask-user-question/ask-user-question.d.ts.map +1 -1
  294. package/dist/core/tools/ask-user-question/ask-user-question.js +8 -4
  295. package/dist/core/tools/ask-user-question/ask-user-question.js.map +1 -1
  296. package/dist/core/tools/ask-user-question/state/build-questionnaire.d.ts +1 -1
  297. package/dist/core/tools/ask-user-question/state/build-questionnaire.js.map +1 -1
  298. package/dist/core/tools/ask-user-question/state/questionnaire-session.d.ts +1 -1
  299. package/dist/core/tools/ask-user-question/state/questionnaire-session.js.map +1 -1
  300. package/dist/core/tools/ask-user-question/view/components/multi-select-view.d.ts +1 -1
  301. package/dist/core/tools/ask-user-question/view/components/multi-select-view.js.map +1 -1
  302. package/dist/core/tools/ask-user-question/view/components/preview/markdown-content-cache.d.ts +1 -1
  303. package/dist/core/tools/ask-user-question/view/components/preview/markdown-content-cache.js.map +1 -1
  304. package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.d.ts +1 -1
  305. package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.js.map +1 -1
  306. package/dist/core/tools/ask-user-question/view/components/submit-picker.d.ts +1 -1
  307. package/dist/core/tools/ask-user-question/view/components/submit-picker.js.map +1 -1
  308. package/dist/core/tools/ask-user-question/view/components/tab-bar.d.ts +1 -1
  309. package/dist/core/tools/ask-user-question/view/components/tab-bar.js.map +1 -1
  310. package/dist/core/tools/ask-user-question/view/dialog-builder.d.ts +1 -1
  311. package/dist/core/tools/ask-user-question/view/dialog-builder.js.map +1 -1
  312. package/dist/core/tools/ask-user-question/view/tab-content-strategy.d.ts +1 -1
  313. package/dist/core/tools/ask-user-question/view/tab-content-strategy.js.map +1 -1
  314. package/dist/core/tools/bash-pty-native.d.ts +18 -3
  315. package/dist/core/tools/bash-pty-native.d.ts.map +1 -1
  316. package/dist/core/tools/bash-pty-native.js +116 -1
  317. package/dist/core/tools/bash-pty-native.js.map +1 -1
  318. package/dist/core/tools/bash.d.ts +11 -4
  319. package/dist/core/tools/bash.d.ts.map +1 -1
  320. package/dist/core/tools/bash.js +52 -8
  321. package/dist/core/tools/bash.js.map +1 -1
  322. package/dist/core/tools/edit.d.ts.map +1 -1
  323. package/dist/core/tools/edit.js +1 -2
  324. package/dist/core/tools/edit.js.map +1 -1
  325. package/dist/core/tools/find.js.map +1 -1
  326. package/dist/core/tools/grep.js.map +1 -1
  327. package/dist/core/tools/index.d.ts +2 -2
  328. package/dist/core/tools/index.js.map +1 -1
  329. package/dist/core/tools/ls.js.map +1 -1
  330. package/dist/core/tools/powershell.d.ts +20 -10
  331. package/dist/core/tools/powershell.d.ts.map +1 -1
  332. package/dist/core/tools/powershell.js +32 -7
  333. package/dist/core/tools/powershell.js.map +1 -1
  334. package/dist/core/tools/read.d.ts.map +1 -1
  335. package/dist/core/tools/read.js +1 -2
  336. package/dist/core/tools/read.js.map +1 -1
  337. package/dist/core/tools/render-utils.d.ts +1 -1
  338. package/dist/core/tools/render-utils.js.map +1 -1
  339. package/dist/core/tools/resource-selectors.d.ts.map +1 -1
  340. package/dist/core/tools/resource-selectors.js +15 -7
  341. package/dist/core/tools/resource-selectors.js.map +1 -1
  342. package/dist/core/tools/search.js.map +1 -1
  343. package/dist/core/tools/todos-render.d.ts +1 -1
  344. package/dist/core/tools/todos-render.js.map +1 -1
  345. package/dist/core/tools/write.d.ts.map +1 -1
  346. package/dist/core/tools/write.js +1 -2
  347. package/dist/core/tools/write.js.map +1 -1
  348. package/dist/core/workflow-stage-admission.d.ts +10 -0
  349. package/dist/core/workflow-stage-admission.d.ts.map +1 -1
  350. package/dist/core/workflow-stage-admission.js +24 -0
  351. package/dist/core/workflow-stage-admission.js.map +1 -1
  352. package/dist/extensions/herdr/activity.d.ts +15 -0
  353. package/dist/extensions/herdr/activity.d.ts.map +1 -0
  354. package/dist/extensions/herdr/activity.js +24 -0
  355. package/dist/extensions/herdr/activity.js.map +1 -0
  356. package/dist/extensions/herdr/environment.d.ts +7 -0
  357. package/dist/extensions/herdr/environment.d.ts.map +1 -0
  358. package/dist/extensions/herdr/environment.js +6 -0
  359. package/dist/extensions/herdr/environment.js.map +1 -0
  360. package/dist/extensions/herdr/index.d.ts +9 -0
  361. package/dist/extensions/herdr/index.d.ts.map +1 -0
  362. package/dist/extensions/herdr/index.js +225 -0
  363. package/dist/extensions/herdr/index.js.map +1 -0
  364. package/dist/extensions/herdr/pane-owner.d.ts +30 -0
  365. package/dist/extensions/herdr/pane-owner.d.ts.map +1 -0
  366. package/dist/extensions/herdr/pane-owner.js +111 -0
  367. package/dist/extensions/herdr/pane-owner.js.map +1 -0
  368. package/dist/extensions/herdr/transport.d.ts +8 -0
  369. package/dist/extensions/herdr/transport.d.ts.map +1 -0
  370. package/dist/extensions/herdr/transport.js +28 -0
  371. package/dist/extensions/herdr/transport.js.map +1 -0
  372. package/dist/extensions/index.d.ts.map +1 -1
  373. package/dist/extensions/index.js +2 -0
  374. package/dist/extensions/index.js.map +1 -1
  375. package/dist/extensions/llama/huggingface-ui.d.ts +1 -1
  376. package/dist/extensions/llama/huggingface-ui.js.map +1 -1
  377. package/dist/extensions/llama/ui.js.map +1 -1
  378. package/dist/index-extensions.d.ts +3 -2
  379. package/dist/index-extensions.d.ts.map +1 -1
  380. package/dist/index-extensions.js.map +1 -1
  381. package/dist/index.d.ts +11 -3
  382. package/dist/index.d.ts.map +1 -1
  383. package/dist/index.js +8 -0
  384. package/dist/index.js.map +1 -1
  385. package/dist/main-session.js.map +1 -1
  386. package/dist/main.d.ts.map +1 -1
  387. package/dist/main.js +149 -69
  388. package/dist/main.js.map +1 -1
  389. package/dist/modes/interactive/components/armin.js.map +1 -1
  390. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  391. package/dist/modes/interactive/components/atomic-banner.d.ts +1 -1
  392. package/dist/modes/interactive/components/atomic-banner.js.map +1 -1
  393. package/dist/modes/interactive/components/atomic-working-status.js.map +1 -1
  394. package/dist/modes/interactive/components/bash-execution.js.map +1 -1
  395. package/dist/modes/interactive/components/bordered-loader.d.ts +1 -1
  396. package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
  397. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
  398. package/dist/modes/interactive/components/chat-message-renderer.d.ts +12 -0
  399. package/dist/modes/interactive/components/chat-message-renderer.d.ts.map +1 -1
  400. package/dist/modes/interactive/components/chat-message-renderer.js +44 -0
  401. package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
  402. package/dist/modes/interactive/components/chat-session-host-actions.d.ts +1 -1
  403. package/dist/modes/interactive/components/chat-session-host-actions.d.ts.map +1 -1
  404. package/dist/modes/interactive/components/chat-session-host-actions.js +43 -8
  405. package/dist/modes/interactive/components/chat-session-host-actions.js.map +1 -1
  406. package/dist/modes/interactive/components/chat-session-host-editor.d.ts +1 -1
  407. package/dist/modes/interactive/components/chat-session-host-editor.js.map +1 -1
  408. package/dist/modes/interactive/components/chat-session-host-events.d.ts +2 -2
  409. package/dist/modes/interactive/components/chat-session-host-events.js.map +1 -1
  410. package/dist/modes/interactive/components/chat-session-host-rendering.d.ts +2 -2
  411. package/dist/modes/interactive/components/chat-session-host-rendering.d.ts.map +1 -1
  412. package/dist/modes/interactive/components/chat-session-host-rendering.js +12 -3
  413. package/dist/modes/interactive/components/chat-session-host-rendering.js.map +1 -1
  414. package/dist/modes/interactive/components/chat-session-host-runtime.d.ts +4 -5
  415. package/dist/modes/interactive/components/chat-session-host-runtime.d.ts.map +1 -1
  416. package/dist/modes/interactive/components/chat-session-host-runtime.js +8 -6
  417. package/dist/modes/interactive/components/chat-session-host-runtime.js.map +1 -1
  418. package/dist/modes/interactive/components/chat-session-host-state.d.ts +7 -2
  419. package/dist/modes/interactive/components/chat-session-host-state.d.ts.map +1 -1
  420. package/dist/modes/interactive/components/chat-session-host-state.js +1 -0
  421. package/dist/modes/interactive/components/chat-session-host-state.js.map +1 -1
  422. package/dist/modes/interactive/components/chat-session-host-terminal-cleanup.d.ts +1 -1
  423. package/dist/modes/interactive/components/chat-session-host-terminal-cleanup.js.map +1 -1
  424. package/dist/modes/interactive/components/chat-session-host-types.d.ts +8 -3
  425. package/dist/modes/interactive/components/chat-session-host-types.d.ts.map +1 -1
  426. package/dist/modes/interactive/components/chat-session-host-types.js.map +1 -1
  427. package/dist/modes/interactive/components/chat-session-host-utils.d.ts +1 -1
  428. package/dist/modes/interactive/components/chat-session-host-utils.d.ts.map +1 -1
  429. package/dist/modes/interactive/components/chat-session-host-utils.js +2 -0
  430. package/dist/modes/interactive/components/chat-session-host-utils.js.map +1 -1
  431. package/dist/modes/interactive/components/chat-session-host.d.ts +17 -2
  432. package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
  433. package/dist/modes/interactive/components/chat-session-host.js +97 -1
  434. package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
  435. package/dist/modes/interactive/components/chat-transcript.d.ts +1 -0
  436. package/dist/modes/interactive/components/chat-transcript.d.ts.map +1 -1
  437. package/dist/modes/interactive/components/chat-transcript.js +1 -1
  438. package/dist/modes/interactive/components/chat-transcript.js.map +1 -1
  439. package/dist/modes/interactive/components/compaction-boundary-message.js.map +1 -1
  440. package/dist/modes/interactive/components/config-selector-list.js.map +1 -1
  441. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  442. package/dist/modes/interactive/components/custom-editor.js.map +1 -1
  443. package/dist/modes/interactive/components/custom-entry.js.map +1 -1
  444. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  445. package/dist/modes/interactive/components/custom-message.js +12 -0
  446. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  447. package/dist/modes/interactive/components/daxnuts.js.map +1 -1
  448. package/dist/modes/interactive/components/diff.js.map +1 -1
  449. package/dist/modes/interactive/components/dynamic-border.js.map +1 -1
  450. package/dist/modes/interactive/components/earendil-announcement.js.map +1 -1
  451. package/dist/modes/interactive/components/extension-editor.js.map +1 -1
  452. package/dist/modes/interactive/components/extension-input.js.map +1 -1
  453. package/dist/modes/interactive/components/extension-selector.js.map +1 -1
  454. package/dist/modes/interactive/components/first-time-setup.d.ts +1 -1
  455. package/dist/modes/interactive/components/first-time-setup.js.map +1 -1
  456. package/dist/modes/interactive/components/footer.d.ts +7 -6
  457. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  458. package/dist/modes/interactive/components/footer.js +27 -9
  459. package/dist/modes/interactive/components/footer.js.map +1 -1
  460. package/dist/modes/interactive/components/host-input-form-mount.js.map +1 -1
  461. package/dist/modes/interactive/components/host-input-form.d.ts +1 -1
  462. package/dist/modes/interactive/components/host-input-form.js.map +1 -1
  463. package/dist/modes/interactive/components/index.d.ts +2 -2
  464. package/dist/modes/interactive/components/index.js.map +1 -1
  465. package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
  466. package/dist/modes/interactive/components/login-dialog.js.map +1 -1
  467. package/dist/modes/interactive/components/mermaid.d.ts +1 -1
  468. package/dist/modes/interactive/components/mermaid.js.map +1 -1
  469. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  470. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  471. package/dist/modes/interactive/components/reserved-bottom-overlay.js.map +1 -1
  472. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
  473. package/dist/modes/interactive/components/session-selector-header.js.map +1 -1
  474. package/dist/modes/interactive/components/session-selector-list.js.map +1 -1
  475. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  476. package/dist/modes/interactive/components/settings-selector-items.js.map +1 -1
  477. package/dist/modes/interactive/components/settings-selector-submenus.d.ts +1 -1
  478. package/dist/modes/interactive/components/settings-selector-submenus.js.map +1 -1
  479. package/dist/modes/interactive/components/settings-selector-types.d.ts +1 -1
  480. package/dist/modes/interactive/components/settings-selector-types.js.map +1 -1
  481. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  482. package/dist/modes/interactive/components/show-images-selector.js.map +1 -1
  483. package/dist/modes/interactive/components/skill-invocation-message.d.ts +1 -1
  484. package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
  485. package/dist/modes/interactive/components/task-completion-message.d.ts +13 -0
  486. package/dist/modes/interactive/components/task-completion-message.d.ts.map +1 -0
  487. package/dist/modes/interactive/components/task-completion-message.js +65 -0
  488. package/dist/modes/interactive/components/task-completion-message.js.map +1 -0
  489. package/dist/modes/interactive/components/task-detail.d.ts +27 -0
  490. package/dist/modes/interactive/components/task-detail.d.ts.map +1 -0
  491. package/dist/modes/interactive/components/task-detail.js +107 -0
  492. package/dist/modes/interactive/components/task-detail.js.map +1 -0
  493. package/dist/modes/interactive/components/task-inspector.d.ts +50 -0
  494. package/dist/modes/interactive/components/task-inspector.d.ts.map +1 -0
  495. package/dist/modes/interactive/components/task-inspector.js +599 -0
  496. package/dist/modes/interactive/components/task-inspector.js.map +1 -0
  497. package/dist/modes/interactive/components/task-list.d.ts +18 -0
  498. package/dist/modes/interactive/components/task-list.d.ts.map +1 -0
  499. package/dist/modes/interactive/components/task-list.js +59 -0
  500. package/dist/modes/interactive/components/task-list.js.map +1 -0
  501. package/dist/modes/interactive/components/task-live-transcript.d.ts +17 -0
  502. package/dist/modes/interactive/components/task-live-transcript.d.ts.map +1 -0
  503. package/dist/modes/interactive/components/task-live-transcript.js +33 -0
  504. package/dist/modes/interactive/components/task-live-transcript.js.map +1 -0
  505. package/dist/modes/interactive/components/task-navigation.d.ts +38 -0
  506. package/dist/modes/interactive/components/task-navigation.d.ts.map +1 -0
  507. package/dist/modes/interactive/components/task-navigation.js +93 -0
  508. package/dist/modes/interactive/components/task-navigation.js.map +1 -0
  509. package/dist/modes/interactive/components/task-row.d.ts +34 -0
  510. package/dist/modes/interactive/components/task-row.d.ts.map +1 -0
  511. package/dist/modes/interactive/components/task-row.js +158 -0
  512. package/dist/modes/interactive/components/task-row.js.map +1 -0
  513. package/dist/modes/interactive/components/theme-selector.js.map +1 -1
  514. package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
  515. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  516. package/dist/modes/interactive/components/transcript-follow-indicator.js.map +1 -1
  517. package/dist/modes/interactive/components/tree-selector-component.js.map +1 -1
  518. package/dist/modes/interactive/components/tree-selector-content.js.map +1 -1
  519. package/dist/modes/interactive/components/tree-selector-help.js.map +1 -1
  520. package/dist/modes/interactive/components/tree-selector-label-input.js.map +1 -1
  521. package/dist/modes/interactive/components/tree-selector-list.js.map +1 -1
  522. package/dist/modes/interactive/components/trust-selector.js.map +1 -1
  523. package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
  524. package/dist/modes/interactive/components/user-message.js.map +1 -1
  525. package/dist/modes/interactive/components/working-status.js.map +1 -1
  526. package/dist/modes/interactive/interactive-agent-events.js +8 -2
  527. package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
  528. package/dist/modes/interactive/interactive-auth-login.js +3 -1
  529. package/dist/modes/interactive/interactive-auth-login.js.map +1 -1
  530. package/dist/modes/interactive/interactive-autocomplete.js +9 -30
  531. package/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
  532. package/dist/modes/interactive/interactive-deferred-startup.js +2 -1
  533. package/dist/modes/interactive/interactive-deferred-startup.js.map +1 -1
  534. package/dist/modes/interactive/interactive-extension-context.js +14 -4
  535. package/dist/modes/interactive/interactive-extension-context.js.map +1 -1
  536. package/dist/modes/interactive/interactive-extension-custom-ui.js +52 -4
  537. package/dist/modes/interactive/interactive-extension-custom-ui.js.map +1 -1
  538. package/dist/modes/interactive/interactive-extension-runtime.js +1 -0
  539. package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
  540. package/dist/modes/interactive/interactive-extension-widgets.js +9 -1
  541. package/dist/modes/interactive/interactive-extension-widgets.js.map +1 -1
  542. package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
  543. package/dist/modes/interactive/interactive-input-handling.js +19 -0
  544. package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
  545. package/dist/modes/interactive/interactive-mode-base.d.ts +6 -1
  546. package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
  547. package/dist/modes/interactive/interactive-mode-base.js +4 -1
  548. package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
  549. package/dist/modes/interactive/interactive-mode-deps.d.ts +6 -6
  550. package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
  551. package/dist/modes/interactive/interactive-mode-surface.d.ts +2 -1
  552. package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
  553. package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
  554. package/dist/modes/interactive/interactive-mode.d.ts +1 -0
  555. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  556. package/dist/modes/interactive/interactive-mode.js +3 -0
  557. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  558. package/dist/modes/interactive/interactive-process-lifecycle.js +4 -1
  559. package/dist/modes/interactive/interactive-process-lifecycle.js.map +1 -1
  560. package/dist/modes/interactive/interactive-render-chat.js +2 -0
  561. package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
  562. package/dist/modes/interactive/interactive-session-routing.js +33 -23
  563. package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
  564. package/dist/modes/interactive/interactive-session-runtime.js +1 -0
  565. package/dist/modes/interactive/interactive-session-runtime.js.map +1 -1
  566. package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
  567. package/dist/modes/interactive/interactive-summarization-retry-events.js +2 -2
  568. package/dist/modes/interactive/interactive-summarization-retry-events.js.map +1 -1
  569. package/dist/modes/interactive/interactive-task-projection.d.ts +13 -0
  570. package/dist/modes/interactive/interactive-task-projection.d.ts.map +1 -0
  571. package/dist/modes/interactive/interactive-task-projection.js +72 -0
  572. package/dist/modes/interactive/interactive-task-projection.js.map +1 -0
  573. package/dist/modes/interactive/interactive-tui.js.map +1 -1
  574. package/dist/modes/interactive/interactive-windows-subshell.d.ts +17 -0
  575. package/dist/modes/interactive/interactive-windows-subshell.d.ts.map +1 -0
  576. package/dist/modes/interactive/interactive-windows-subshell.js +92 -0
  577. package/dist/modes/interactive/interactive-windows-subshell.js.map +1 -0
  578. package/dist/modes/interactive/skill-command-autocomplete.d.ts +12 -0
  579. package/dist/modes/interactive/skill-command-autocomplete.d.ts.map +1 -0
  580. package/dist/modes/interactive/skill-command-autocomplete.js +69 -0
  581. package/dist/modes/interactive/skill-command-autocomplete.js.map +1 -0
  582. package/dist/modes/interactive/theme/theme-class.d.ts.map +1 -1
  583. package/dist/modes/interactive/theme/theme-class.js +4 -1
  584. package/dist/modes/interactive/theme/theme-class.js.map +1 -1
  585. package/dist/modes/interactive/theme/theme-controller.d.ts +1 -1
  586. package/dist/modes/interactive/theme/theme-controller.js.map +1 -1
  587. package/dist/modes/interactive-engine/create-isolated-runtime.d.ts +1 -1
  588. package/dist/modes/interactive-engine/create-isolated-runtime.js.map +1 -1
  589. package/dist/modes/interactive-engine/engine-custom-ui.d.ts +5 -9
  590. package/dist/modes/interactive-engine/engine-custom-ui.d.ts.map +1 -1
  591. package/dist/modes/interactive-engine/engine-custom-ui.js +14 -5
  592. package/dist/modes/interactive-engine/engine-custom-ui.js.map +1 -1
  593. package/dist/modes/interactive-engine/engine-dialog-host.d.ts +2 -2
  594. package/dist/modes/interactive-engine/engine-dialog-host.js.map +1 -1
  595. package/dist/modes/interactive-engine/engine-project-trust.d.ts +10 -0
  596. package/dist/modes/interactive-engine/engine-project-trust.d.ts.map +1 -0
  597. package/dist/modes/interactive-engine/engine-project-trust.js +28 -0
  598. package/dist/modes/interactive-engine/engine-project-trust.js.map +1 -0
  599. package/dist/modes/interactive-engine/engine-render-service.d.ts +1 -1
  600. package/dist/modes/interactive-engine/engine-render-service.js.map +1 -1
  601. package/dist/modes/interactive-engine/extension-ui-bridge.d.ts +3 -1
  602. package/dist/modes/interactive-engine/extension-ui-bridge.d.ts.map +1 -1
  603. package/dist/modes/interactive-engine/extension-ui-bridge.js +6 -0
  604. package/dist/modes/interactive-engine/extension-ui-bridge.js.map +1 -1
  605. package/dist/modes/interactive-engine/input-form-host.d.ts +2 -2
  606. package/dist/modes/interactive-engine/input-form-host.js.map +1 -1
  607. package/dist/modes/interactive-engine/isolated-auth.d.ts +1 -1
  608. package/dist/modes/interactive-engine/isolated-auth.js.map +1 -1
  609. package/dist/modes/interactive-engine/isolated-runtime.d.ts +5 -2
  610. package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
  611. package/dist/modes/interactive-engine/isolated-runtime.js +40 -3
  612. package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
  613. package/dist/modes/interactive-engine/protocol.d.ts +9 -0
  614. package/dist/modes/interactive-engine/protocol.d.ts.map +1 -1
  615. package/dist/modes/interactive-engine/protocol.js +8 -0
  616. package/dist/modes/interactive-engine/protocol.js.map +1 -1
  617. package/dist/modes/interactive-engine/remote-component.d.ts +2 -2
  618. package/dist/modes/interactive-engine/remote-component.d.ts.map +1 -1
  619. package/dist/modes/interactive-engine/remote-component.js +3 -2
  620. package/dist/modes/interactive-engine/remote-component.js.map +1 -1
  621. package/dist/modes/interactive-engine/remote-model-catalog.d.ts +1 -1
  622. package/dist/modes/interactive-engine/remote-model-catalog.js.map +1 -1
  623. package/dist/modes/interactive-engine/remote-renderer.d.ts +1 -1
  624. package/dist/modes/interactive-engine/remote-renderer.js.map +1 -1
  625. package/dist/modes/interactive-engine/session-picker-host.d.ts +2 -2
  626. package/dist/modes/interactive-engine/session-picker-host.js.map +1 -1
  627. package/dist/modes/json-event.d.ts +1 -1
  628. package/dist/modes/json-event.js.map +1 -1
  629. package/dist/modes/print-mode.js.map +1 -1
  630. package/dist/modes/rpc/rpc-bash-request-owners.d.ts +2 -2
  631. package/dist/modes/rpc/rpc-bash-request-owners.js.map +1 -1
  632. package/dist/modes/rpc/rpc-client-api.d.ts +2 -2
  633. package/dist/modes/rpc/rpc-client-api.d.ts.map +1 -1
  634. package/dist/modes/rpc/rpc-client-api.js +2 -2
  635. package/dist/modes/rpc/rpc-client-api.js.map +1 -1
  636. package/dist/modes/rpc/rpc-client-waits.d.ts +1 -1
  637. package/dist/modes/rpc/rpc-client-waits.js.map +1 -1
  638. package/dist/modes/rpc/rpc-client.d.ts +3 -1
  639. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  640. package/dist/modes/rpc/rpc-client.js +20 -0
  641. package/dist/modes/rpc/rpc-client.js.map +1 -1
  642. package/dist/modes/rpc/rpc-command-handler.d.ts +4 -2
  643. package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
  644. package/dist/modes/rpc/rpc-command-handler.js +12 -4
  645. package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
  646. package/dist/modes/rpc/rpc-extension-ui.d.ts +1 -1
  647. package/dist/modes/rpc/rpc-extension-ui.js.map +1 -1
  648. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  649. package/dist/modes/rpc/rpc-mode.js +11 -2
  650. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  651. package/dist/modes/rpc/rpc-provider-auth.d.ts +1 -1
  652. package/dist/modes/rpc/rpc-provider-auth.js.map +1 -1
  653. package/dist/modes/rpc/rpc-session-binding.d.ts +4 -1
  654. package/dist/modes/rpc/rpc-session-binding.d.ts.map +1 -1
  655. package/dist/modes/rpc/rpc-session-binding.js +35 -1
  656. package/dist/modes/rpc/rpc-session-binding.js.map +1 -1
  657. package/dist/modes/rpc/rpc-types.d.ts +13 -1
  658. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  659. package/dist/modes/rpc/rpc-types.js.map +1 -1
  660. package/dist/modes/rpc/task-ui-bridge.d.ts +9 -0
  661. package/dist/modes/rpc/task-ui-bridge.d.ts.map +1 -0
  662. package/dist/modes/rpc/task-ui-bridge.js +146 -0
  663. package/dist/modes/rpc/task-ui-bridge.js.map +1 -0
  664. package/dist/self-update-plan.js.map +1 -1
  665. package/docs/background-tasks.md +199 -0
  666. package/docs/compaction.md +2 -0
  667. package/docs/development.md +3 -1
  668. package/docs/docs.json +2 -0
  669. package/docs/environment-variables.md +1 -1
  670. package/docs/extensions.md +108 -6
  671. package/docs/herdr.md +106 -0
  672. package/docs/intercom.md +38 -35
  673. package/docs/keybindings.md +19 -2
  674. package/docs/models/evals.md +222 -147
  675. package/docs/models/model-selection.md +20 -14
  676. package/docs/models/pareto-efficiency.md +2 -2
  677. package/docs/providers.md +48 -46
  678. package/docs/quickstart.md +1 -1
  679. package/docs/sdk.md +244 -0
  680. package/docs/settings.md +15 -3
  681. package/docs/skills.md +23 -1
  682. package/docs/subagents.md +71 -9
  683. package/docs/themes.md +4 -0
  684. package/docs/tools.md +25 -0
  685. package/docs/tui.md +29 -2
  686. package/docs/usage.md +4 -0
  687. package/docs/windows.md +4 -4
  688. package/docs/workflows/api-reference.md +13 -4
  689. package/docs/workflows/operations.md +42 -1
  690. package/docs/workflows/reliable-design.md +35 -4
  691. package/docs/workflows/verification.md +21 -4
  692. package/docs/workflows.md +3 -1
  693. package/npm-shrinkwrap.json +781 -661
  694. package/package.json +10 -10
  695. /package/dist/builtin/workflows/builtin/{chunk-cg9tmks0.js → chunk-n1910xc4.js} +0 -0
  696. /package/dist/builtin/workflows/builtin/{chunk-wpckd35c.js → chunk-rc5ec5xx.js} +0 -0
  697. /package/dist/builtin/workflows/builtin/{chunk-7at6dnkr.js → chunk-tgt0s5e5.js} +0 -0
  698. /package/dist/builtin/workflows/builtin/{chunk-bfkmzv9h.js → chunk-xtxcq5tj.js} +0 -0
@@ -74,17 +74,17 @@ var require_visit = __commonJS(function(exports) {
74
74
  visit.BREAK = BREAK;
75
75
  visit.SKIP = SKIP;
76
76
  visit.REMOVE = REMOVE;
77
- function visit_(key, node, visitor, path2) {
78
- const ctrl = callVisitor(key, node, visitor, path2);
77
+ function visit_(key, node, visitor, path) {
78
+ const ctrl = callVisitor(key, node, visitor, path);
79
79
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
80
- replaceNode(key, path2, ctrl);
81
- return visit_(key, ctrl, visitor, path2);
80
+ replaceNode(key, path, ctrl);
81
+ return visit_(key, ctrl, visitor, path);
82
82
  }
83
83
  if (typeof ctrl !== "symbol") {
84
84
  if (identity.isCollection(node)) {
85
- path2 = Object.freeze(path2.concat(node));
85
+ path = Object.freeze(path.concat(node));
86
86
  for (let i = 0;i < node.items.length; ++i) {
87
- const ci = visit_(i, node.items[i], visitor, path2);
87
+ const ci = visit_(i, node.items[i], visitor, path);
88
88
  if (typeof ci === "number")
89
89
  i = ci - 1;
90
90
  else if (ci === BREAK)
@@ -95,13 +95,13 @@ var require_visit = __commonJS(function(exports) {
95
95
  }
96
96
  }
97
97
  } else if (identity.isPair(node)) {
98
- path2 = Object.freeze(path2.concat(node));
99
- const ck = visit_("key", node.key, visitor, path2);
98
+ path = Object.freeze(path.concat(node));
99
+ const ck = visit_("key", node.key, visitor, path);
100
100
  if (ck === BREAK)
101
101
  return BREAK;
102
102
  else if (ck === REMOVE)
103
103
  node.key = null;
104
- const cv = visit_("value", node.value, visitor, path2);
104
+ const cv = visit_("value", node.value, visitor, path);
105
105
  if (cv === BREAK)
106
106
  return BREAK;
107
107
  else if (cv === REMOVE)
@@ -122,17 +122,17 @@ var require_visit = __commonJS(function(exports) {
122
122
  visitAsync.BREAK = BREAK;
123
123
  visitAsync.SKIP = SKIP;
124
124
  visitAsync.REMOVE = REMOVE;
125
- async function visitAsync_(key, node, visitor, path2) {
126
- const ctrl = await callVisitor(key, node, visitor, path2);
125
+ async function visitAsync_(key, node, visitor, path) {
126
+ const ctrl = await callVisitor(key, node, visitor, path);
127
127
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
128
- replaceNode(key, path2, ctrl);
129
- return visitAsync_(key, ctrl, visitor, path2);
128
+ replaceNode(key, path, ctrl);
129
+ return visitAsync_(key, ctrl, visitor, path);
130
130
  }
131
131
  if (typeof ctrl !== "symbol") {
132
132
  if (identity.isCollection(node)) {
133
- path2 = Object.freeze(path2.concat(node));
133
+ path = Object.freeze(path.concat(node));
134
134
  for (let i = 0;i < node.items.length; ++i) {
135
- const ci = await visitAsync_(i, node.items[i], visitor, path2);
135
+ const ci = await visitAsync_(i, node.items[i], visitor, path);
136
136
  if (typeof ci === "number")
137
137
  i = ci - 1;
138
138
  else if (ci === BREAK)
@@ -143,13 +143,13 @@ var require_visit = __commonJS(function(exports) {
143
143
  }
144
144
  }
145
145
  } else if (identity.isPair(node)) {
146
- path2 = Object.freeze(path2.concat(node));
147
- const ck = await visitAsync_("key", node.key, visitor, path2);
146
+ path = Object.freeze(path.concat(node));
147
+ const ck = await visitAsync_("key", node.key, visitor, path);
148
148
  if (ck === BREAK)
149
149
  return BREAK;
150
150
  else if (ck === REMOVE)
151
151
  node.key = null;
152
- const cv = await visitAsync_("value", node.value, visitor, path2);
152
+ const cv = await visitAsync_("value", node.value, visitor, path);
153
153
  if (cv === BREAK)
154
154
  return BREAK;
155
155
  else if (cv === REMOVE)
@@ -176,23 +176,23 @@ var require_visit = __commonJS(function(exports) {
176
176
  }
177
177
  return visitor;
178
178
  }
179
- function callVisitor(key, node, visitor, path2) {
179
+ function callVisitor(key, node, visitor, path) {
180
180
  if (typeof visitor === "function")
181
- return visitor(key, node, path2);
181
+ return visitor(key, node, path);
182
182
  if (identity.isMap(node))
183
- return visitor.Map?.(key, node, path2);
183
+ return visitor.Map?.(key, node, path);
184
184
  if (identity.isSeq(node))
185
- return visitor.Seq?.(key, node, path2);
185
+ return visitor.Seq?.(key, node, path);
186
186
  if (identity.isPair(node))
187
- return visitor.Pair?.(key, node, path2);
187
+ return visitor.Pair?.(key, node, path);
188
188
  if (identity.isScalar(node))
189
- return visitor.Scalar?.(key, node, path2);
189
+ return visitor.Scalar?.(key, node, path);
190
190
  if (identity.isAlias(node))
191
- return visitor.Alias?.(key, node, path2);
191
+ return visitor.Alias?.(key, node, path);
192
192
  return;
193
193
  }
194
- function replaceNode(key, path2, node) {
195
- const parent = path2[path2.length - 1];
194
+ function replaceNode(key, path, node) {
195
+ const parent = path[path.length - 1];
196
196
  if (identity.isCollection(parent)) {
197
197
  parent.items[key] = node;
198
198
  } else if (identity.isPair(parent)) {
@@ -483,8 +483,8 @@ var require_toJS = __commonJS(function(exports) {
483
483
  return value.toJSON(arg, ctx);
484
484
  const data = { aliasCount: 0, count: 1, res: undefined };
485
485
  ctx.anchors.set(value, data);
486
- ctx.onCreate = (res2) => {
487
- data.res = res2;
486
+ ctx.onCreate = (res) => {
487
+ data.res = res;
488
488
  delete ctx.onCreate;
489
489
  };
490
490
  const res = value.toJSON(arg, ctx);
@@ -528,8 +528,8 @@ var require_Node = __commonJS(function(exports) {
528
528
  };
529
529
  const res = toJS.toJS(this, "", ctx);
530
530
  if (typeof onAnchor === "function")
531
- for (const { count, res: res2 } of ctx.anchors.values())
532
- onAnchor(res2, count);
531
+ for (const { count, res } of ctx.anchors.values())
532
+ onAnchor(res, count);
533
533
  return typeof reviver === "function" ? applyReviver.applyReviver(reviver, { "": res }, "", res) : res;
534
534
  }
535
535
  }
@@ -583,16 +583,16 @@ var require_Alias = __commonJS(function(exports) {
583
583
  toJSON(_arg, ctx) {
584
584
  if (!ctx)
585
585
  return { source: this.source };
586
- const { anchors: anchors2, doc, maxAliasCount } = ctx;
586
+ const { anchors, doc, maxAliasCount } = ctx;
587
587
  const source = this.resolve(doc, ctx);
588
588
  if (!source) {
589
589
  const msg = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
590
590
  throw new ReferenceError(msg);
591
591
  }
592
- let data = anchors2.get(source);
592
+ let data = anchors.get(source);
593
593
  if (!data) {
594
594
  toJS.toJS(source, null, ctx);
595
- data = anchors2.get(source);
595
+ data = anchors.get(source);
596
596
  }
597
597
  if (data?.res === undefined) {
598
598
  const msg = "This should not happen: Alias anchor was not resolved?";
@@ -601,7 +601,7 @@ var require_Alias = __commonJS(function(exports) {
601
601
  if (maxAliasCount >= 0) {
602
602
  data.count += 1;
603
603
  if (data.aliasCount === 0)
604
- data.aliasCount = getAliasCount(doc, source, anchors2);
604
+ data.aliasCount = getAliasCount(doc, source, anchors);
605
605
  if (data.count * data.aliasCount > maxAliasCount) {
606
606
  const msg = "Excessive alias count indicates a resource exhaustion attack";
607
607
  throw new ReferenceError(msg);
@@ -623,22 +623,22 @@ var require_Alias = __commonJS(function(exports) {
623
623
  return src;
624
624
  }
625
625
  }
626
- function getAliasCount(doc, node, anchors2) {
626
+ function getAliasCount(doc, node, anchors) {
627
627
  if (identity.isAlias(node)) {
628
628
  const source = node.resolve(doc);
629
- const anchor = anchors2 && source && anchors2.get(source);
629
+ const anchor = anchors && source && anchors.get(source);
630
630
  return anchor ? anchor.count * anchor.aliasCount : 0;
631
631
  } else if (identity.isCollection(node)) {
632
632
  let count = 0;
633
633
  for (const item of node.items) {
634
- const c = getAliasCount(doc, item, anchors2);
634
+ const c = getAliasCount(doc, item, anchors);
635
635
  if (c > count)
636
636
  count = c;
637
637
  }
638
638
  return count;
639
639
  } else if (identity.isPair(node)) {
640
- const kc = getAliasCount(doc, node.key, anchors2);
641
- const vc = getAliasCount(doc, node.value, anchors2);
640
+ const kc = getAliasCount(doc, node.key, anchors);
641
+ const vc = getAliasCount(doc, node.value, anchors);
642
642
  return Math.max(kc, vc);
643
643
  }
644
644
  return 1;
@@ -723,10 +723,10 @@ var require_createNode = __commonJS(function(exports) {
723
723
  value = value.toJSON();
724
724
  }
725
725
  if (!value || typeof value !== "object") {
726
- const node2 = new Scalar.Scalar(value);
726
+ const node = new Scalar.Scalar(value);
727
727
  if (ref)
728
- ref.node = node2;
729
- return node2;
728
+ ref.node = node;
729
+ return node;
730
730
  }
731
731
  tagObj = value instanceof Map ? schema[identity.MAP] : (Symbol.iterator in Object(value)) ? schema[identity.SEQ] : schema[identity.MAP];
732
732
  }
@@ -751,10 +751,10 @@ var require_Collection = __commonJS(function(exports) {
751
751
  var createNode = require_createNode();
752
752
  var identity = require_identity();
753
753
  var Node = require_Node();
754
- function collectionFromPath(schema, path2, value) {
754
+ function collectionFromPath(schema, path, value) {
755
755
  let v = value;
756
- for (let i = path2.length - 1;i >= 0; --i) {
757
- const k = path2[i];
756
+ for (let i = path.length - 1;i >= 0; --i) {
757
+ const k = path[i];
758
758
  if (typeof k === "number" && Number.isInteger(k) && k >= 0) {
759
759
  const a = [];
760
760
  a[k] = v;
@@ -773,7 +773,7 @@ var require_Collection = __commonJS(function(exports) {
773
773
  sourceObjects: new Map
774
774
  });
775
775
  }
776
- var isEmptyPath = (path2) => path2 == null || typeof path2 === "object" && !!path2[Symbol.iterator]().next().done;
776
+ var isEmptyPath = (path) => path == null || typeof path === "object" && !!path[Symbol.iterator]().next().done;
777
777
 
778
778
  class Collection extends Node.NodeBase {
779
779
  constructor(type, schema) {
@@ -794,11 +794,11 @@ var require_Collection = __commonJS(function(exports) {
794
794
  copy.range = this.range.slice();
795
795
  return copy;
796
796
  }
797
- addIn(path2, value) {
798
- if (isEmptyPath(path2))
797
+ addIn(path, value) {
798
+ if (isEmptyPath(path))
799
799
  this.add(value);
800
800
  else {
801
- const [key, ...rest] = path2;
801
+ const [key, ...rest] = path;
802
802
  const node = this.get(key, true);
803
803
  if (identity.isCollection(node))
804
804
  node.addIn(rest, value);
@@ -808,8 +808,8 @@ var require_Collection = __commonJS(function(exports) {
808
808
  throw new Error(`Expected YAML collection at ${key}. Remaining path: ${rest}`);
809
809
  }
810
810
  }
811
- deleteIn(path2) {
812
- const [key, ...rest] = path2;
811
+ deleteIn(path) {
812
+ const [key, ...rest] = path;
813
813
  if (rest.length === 0)
814
814
  return this.delete(key);
815
815
  const node = this.get(key, true);
@@ -818,8 +818,8 @@ var require_Collection = __commonJS(function(exports) {
818
818
  else
819
819
  throw new Error(`Expected YAML collection at ${key}. Remaining path: ${rest}`);
820
820
  }
821
- getIn(path2, keepScalar) {
822
- const [key, ...rest] = path2;
821
+ getIn(path, keepScalar) {
822
+ const [key, ...rest] = path;
823
823
  const node = this.get(key, true);
824
824
  if (rest.length === 0)
825
825
  return !keepScalar && identity.isScalar(node) ? node.value : node;
@@ -834,15 +834,15 @@ var require_Collection = __commonJS(function(exports) {
834
834
  return n == null || allowScalar && identity.isScalar(n) && n.value == null && !n.commentBefore && !n.comment && !n.tag;
835
835
  });
836
836
  }
837
- hasIn(path2) {
838
- const [key, ...rest] = path2;
837
+ hasIn(path) {
838
+ const [key, ...rest] = path;
839
839
  if (rest.length === 0)
840
840
  return this.has(key);
841
841
  const node = this.get(key, true);
842
842
  return identity.isCollection(node) ? node.hasIn(rest) : false;
843
843
  }
844
- setIn(path2, value) {
845
- const [key, ...rest] = path2;
844
+ setIn(path, value) {
845
+ const [key, ...rest] = path;
846
846
  if (rest.length === 0) {
847
847
  this.set(key, value);
848
848
  } else {
@@ -975,17 +975,17 @@ var require_foldFlowLines = __commonJS(function(exports) {
975
975
  if (onFold)
976
976
  onFold();
977
977
  let res = text.slice(0, folds[0]);
978
- for (let i2 = 0;i2 < folds.length; ++i2) {
979
- const fold = folds[i2];
980
- const end2 = folds[i2 + 1] || text.length;
978
+ for (let i = 0;i < folds.length; ++i) {
979
+ const fold = folds[i];
980
+ const end = folds[i + 1] || text.length;
981
981
  if (fold === 0)
982
982
  res = `
983
- ${indent}${text.slice(0, end2)}`;
983
+ ${indent}${text.slice(0, end)}`;
984
984
  else {
985
985
  if (mode === FOLD_QUOTED && escapedFolds[fold])
986
986
  res += `${text[fold]}\\`;
987
987
  res += `
988
- ${indent}${text.slice(fold + 1, end2)}`;
988
+ ${indent}${text.slice(fold + 1, end)}`;
989
989
  }
990
990
  }
991
991
  return res;
@@ -1621,15 +1621,15 @@ var require_merge = __commonJS(function(exports) {
1621
1621
  if (!identity.isMap(source))
1622
1622
  throw new Error("Merge sources must be maps or map aliases");
1623
1623
  const srcMap = source.toJSON(null, ctx, Map);
1624
- for (const [key, value2] of srcMap) {
1624
+ for (const [key, value] of srcMap) {
1625
1625
  if (map instanceof Map) {
1626
1626
  if (!map.has(key))
1627
- map.set(key, value2);
1627
+ map.set(key, value);
1628
1628
  } else if (map instanceof Set) {
1629
1629
  map.add(key);
1630
1630
  } else if (!Object.prototype.hasOwnProperty.call(map, key)) {
1631
1631
  Object.defineProperty(map, key, {
1632
- value: value2,
1632
+ value,
1633
1633
  writable: true,
1634
1634
  enumerable: true,
1635
1635
  configurable: true
@@ -1752,8 +1752,8 @@ var require_stringifyCollection = __commonJS(function(exports) {
1752
1752
  var stringifyComment = require_stringifyComment();
1753
1753
  function stringifyCollection(collection, ctx, options) {
1754
1754
  const flow = ctx.inFlow ?? collection.flow;
1755
- const stringify2 = flow ? stringifyFlowCollection : stringifyBlockCollection;
1756
- return stringify2(collection, ctx, options);
1755
+ const stringify = flow ? stringifyFlowCollection : stringifyBlockCollection;
1756
+ return stringify(collection, ctx, options);
1757
1757
  }
1758
1758
  function stringifyBlockCollection({ comment, items }, ctx, { blockItemPrefix, flowChars, itemIndent, onChompKeep, onComment }) {
1759
1759
  const { indent, options: { commentString } } = ctx;
@@ -1762,13 +1762,13 @@ var require_stringifyCollection = __commonJS(function(exports) {
1762
1762
  const lines = [];
1763
1763
  for (let i = 0;i < items.length; ++i) {
1764
1764
  const item = items[i];
1765
- let comment2 = null;
1765
+ let comment = null;
1766
1766
  if (identity.isNode(item)) {
1767
1767
  if (!chompKeep && item.spaceBefore)
1768
1768
  lines.push("");
1769
1769
  addCommentBefore(ctx, lines, item.commentBefore, chompKeep);
1770
1770
  if (item.comment)
1771
- comment2 = item.comment;
1771
+ comment = item.comment;
1772
1772
  } else if (identity.isPair(item)) {
1773
1773
  const ik = identity.isNode(item.key) ? item.key : null;
1774
1774
  if (ik) {
@@ -1778,12 +1778,12 @@ var require_stringifyCollection = __commonJS(function(exports) {
1778
1778
  }
1779
1779
  }
1780
1780
  chompKeep = false;
1781
- let str2 = stringify.stringify(item, itemCtx, () => comment2 = null, () => chompKeep = true);
1782
- if (comment2)
1783
- str2 += stringifyComment.lineComment(str2, itemIndent, commentString(comment2));
1784
- if (chompKeep && comment2)
1781
+ let str = stringify.stringify(item, itemCtx, () => comment = null, () => chompKeep = true);
1782
+ if (comment)
1783
+ str += stringifyComment.lineComment(str, itemIndent, commentString(comment));
1784
+ if (chompKeep && comment)
1785
1785
  chompKeep = false;
1786
- lines.push(blockItemPrefix + str2);
1786
+ lines.push(blockItemPrefix + str);
1787
1787
  }
1788
1788
  let str;
1789
1789
  if (lines.length === 0) {
@@ -2033,10 +2033,10 @@ var require_map = __commonJS(function(exports) {
2033
2033
  default: true,
2034
2034
  nodeClass: YAMLMap.YAMLMap,
2035
2035
  tag: "tag:yaml.org,2002:map",
2036
- resolve(map2, onError) {
2037
- if (!identity.isMap(map2))
2036
+ resolve(map, onError) {
2037
+ if (!identity.isMap(map))
2038
2038
  onError("Expected a mapping for this tag");
2039
- return map2;
2039
+ return map;
2040
2040
  },
2041
2041
  createNode: (schema, obj, ctx) => YAMLMap.YAMLMap.from(schema, obj, ctx)
2042
2042
  };
@@ -2145,10 +2145,10 @@ var require_seq = __commonJS(function(exports) {
2145
2145
  default: true,
2146
2146
  nodeClass: YAMLSeq.YAMLSeq,
2147
2147
  tag: "tag:yaml.org,2002:seq",
2148
- resolve(seq2, onError) {
2149
- if (!identity.isSeq(seq2))
2148
+ resolve(seq, onError) {
2149
+ if (!identity.isSeq(seq))
2150
2150
  onError("Expected a sequence for this tag");
2151
- return seq2;
2151
+ return seq;
2152
2152
  },
2153
2153
  createNode: (schema, obj, ctx) => YAMLSeq.YAMLSeq.from(schema, obj, ctx)
2154
2154
  };
@@ -2494,8 +2494,8 @@ ${cn.comment}` : item.comment;
2494
2494
  }
2495
2495
  function createPairs(schema, iterable, ctx) {
2496
2496
  const { replacer } = ctx;
2497
- const pairs2 = new YAMLSeq.YAMLSeq(schema);
2498
- pairs2.tag = "tag:yaml.org,2002:pairs";
2497
+ const pairs = new YAMLSeq.YAMLSeq(schema);
2498
+ pairs.tag = "tag:yaml.org,2002:pairs";
2499
2499
  let i = 0;
2500
2500
  if (iterable && Symbol.iterator in Object(iterable))
2501
2501
  for (let it of iterable) {
@@ -2519,9 +2519,9 @@ ${cn.comment}` : item.comment;
2519
2519
  } else {
2520
2520
  key = it;
2521
2521
  }
2522
- pairs2.items.push(Pair.createPair(key, value, ctx));
2522
+ pairs.items.push(Pair.createPair(key, value, ctx));
2523
2523
  }
2524
- return pairs2;
2524
+ return pairs;
2525
2525
  }
2526
2526
  var pairs = {
2527
2527
  collection: "seq",
@@ -2575,9 +2575,9 @@ var require_omap = __commonJS(function(exports) {
2575
2575
  }
2576
2576
  static from(schema, iterable, ctx) {
2577
2577
  const pairs$1 = pairs.createPairs(schema, iterable, ctx);
2578
- const omap2 = new this;
2579
- omap2.items = pairs$1.items;
2580
- return omap2;
2578
+ const omap = new this;
2579
+ omap.items = pairs$1.items;
2580
+ return omap;
2581
2581
  }
2582
2582
  }
2583
2583
  YAMLOMap.tag = "tag:yaml.org,2002:omap";
@@ -2703,8 +2703,8 @@ var require_int2 = __commonJS(function(exports) {
2703
2703
  str = `0x${str}`;
2704
2704
  break;
2705
2705
  }
2706
- const n2 = BigInt(str);
2707
- return sign === "-" ? BigInt(-1) * n2 : n2;
2706
+ const n = BigInt(str);
2707
+ return sign === "-" ? BigInt(-1) * n : n;
2708
2708
  }
2709
2709
  const n = parseInt(str, radix);
2710
2710
  return sign === "-" ? -1 * n : n;
@@ -2808,14 +2808,14 @@ var require_set = __commonJS(function(exports) {
2808
2808
  }
2809
2809
  static from(schema, iterable, ctx) {
2810
2810
  const { replacer } = ctx;
2811
- const set2 = new this(schema);
2811
+ const set = new this(schema);
2812
2812
  if (iterable && Symbol.iterator in Object(iterable))
2813
2813
  for (let value of iterable) {
2814
2814
  if (typeof replacer === "function")
2815
2815
  value = replacer.call(iterable, value, value);
2816
- set2.items.push(Pair.createPair(value, null, ctx));
2816
+ set.items.push(Pair.createPair(value, null, ctx));
2817
2817
  }
2818
- return set2;
2818
+ return set;
2819
2819
  }
2820
2820
  }
2821
2821
  YAMLSet.tag = "tag:yaml.org,2002:set";
@@ -2848,7 +2848,7 @@ var require_timestamp = __commonJS(function(exports) {
2848
2848
  const sign = str[0];
2849
2849
  const parts = sign === "-" || sign === "+" ? str.substring(1) : str;
2850
2850
  const num = (n) => asBigInt ? BigInt(n) : Number(n);
2851
- const res = parts.replace(/_/g, "").split(":").reduce((res2, p) => res2 * num(60) + num(p), num(0));
2851
+ const res = parts.replace(/_/g, "").split(":").reduce((res, p) => res * num(60) + num(p), num(0));
2852
2852
  return sign === "-" ? num(-1) * res : res;
2853
2853
  }
2854
2854
  function stringifySexagesimal(node) {
@@ -3039,16 +3039,16 @@ var require_tags = __commonJS(function(exports) {
3039
3039
  }
3040
3040
  if (addMergeTag)
3041
3041
  tags = tags.concat(merge.merge);
3042
- return tags.reduce((tags2, tag) => {
3042
+ return tags.reduce((tags, tag) => {
3043
3043
  const tagObj = typeof tag === "string" ? tagsByName[tag] : tag;
3044
3044
  if (!tagObj) {
3045
3045
  const tagName = JSON.stringify(tag);
3046
3046
  const keys = Object.keys(tagsByName).map((key) => JSON.stringify(key)).join(", ");
3047
3047
  throw new Error(`Unknown custom tag ${tagName}; use one of ${keys}`);
3048
3048
  }
3049
- if (!tags2.includes(tagObj))
3050
- tags2.push(tagObj);
3051
- return tags2;
3049
+ if (!tags.includes(tagObj))
3050
+ tags.push(tagObj);
3051
+ return tags;
3052
3052
  }, []);
3053
3053
  }
3054
3054
  exports.coreKnownTags = coreKnownTags;
@@ -3235,9 +3235,9 @@ var require_Document = __commonJS(function(exports) {
3235
3235
  if (assertCollection(this.contents))
3236
3236
  this.contents.add(value);
3237
3237
  }
3238
- addIn(path2, value) {
3238
+ addIn(path, value) {
3239
3239
  if (assertCollection(this.contents))
3240
- this.contents.addIn(path2, value);
3240
+ this.contents.addIn(path, value);
3241
3241
  }
3242
3242
  createAlias(node, name) {
3243
3243
  if (!node.anchor) {
@@ -3286,30 +3286,30 @@ var require_Document = __commonJS(function(exports) {
3286
3286
  delete(key) {
3287
3287
  return assertCollection(this.contents) ? this.contents.delete(key) : false;
3288
3288
  }
3289
- deleteIn(path2) {
3290
- if (Collection.isEmptyPath(path2)) {
3289
+ deleteIn(path) {
3290
+ if (Collection.isEmptyPath(path)) {
3291
3291
  if (this.contents == null)
3292
3292
  return false;
3293
3293
  this.contents = null;
3294
3294
  return true;
3295
3295
  }
3296
- return assertCollection(this.contents) ? this.contents.deleteIn(path2) : false;
3296
+ return assertCollection(this.contents) ? this.contents.deleteIn(path) : false;
3297
3297
  }
3298
3298
  get(key, keepScalar) {
3299
3299
  return identity.isCollection(this.contents) ? this.contents.get(key, keepScalar) : undefined;
3300
3300
  }
3301
- getIn(path2, keepScalar) {
3302
- if (Collection.isEmptyPath(path2))
3301
+ getIn(path, keepScalar) {
3302
+ if (Collection.isEmptyPath(path))
3303
3303
  return !keepScalar && identity.isScalar(this.contents) ? this.contents.value : this.contents;
3304
- return identity.isCollection(this.contents) ? this.contents.getIn(path2, keepScalar) : undefined;
3304
+ return identity.isCollection(this.contents) ? this.contents.getIn(path, keepScalar) : undefined;
3305
3305
  }
3306
3306
  has(key) {
3307
3307
  return identity.isCollection(this.contents) ? this.contents.has(key) : false;
3308
3308
  }
3309
- hasIn(path2) {
3310
- if (Collection.isEmptyPath(path2))
3309
+ hasIn(path) {
3310
+ if (Collection.isEmptyPath(path))
3311
3311
  return this.contents !== undefined;
3312
- return identity.isCollection(this.contents) ? this.contents.hasIn(path2) : false;
3312
+ return identity.isCollection(this.contents) ? this.contents.hasIn(path) : false;
3313
3313
  }
3314
3314
  set(key, value) {
3315
3315
  if (this.contents == null) {
@@ -3318,13 +3318,13 @@ var require_Document = __commonJS(function(exports) {
3318
3318
  this.contents.set(key, value);
3319
3319
  }
3320
3320
  }
3321
- setIn(path2, value) {
3322
- if (Collection.isEmptyPath(path2)) {
3321
+ setIn(path, value) {
3322
+ if (Collection.isEmptyPath(path)) {
3323
3323
  this.contents = value;
3324
3324
  } else if (this.contents == null) {
3325
- this.contents = Collection.collectionFromPath(this.schema, Array.from(path2), value);
3325
+ this.contents = Collection.collectionFromPath(this.schema, Array.from(path), value);
3326
3326
  } else if (assertCollection(this.contents)) {
3327
- this.contents.setIn(path2, value);
3327
+ this.contents.setIn(path, value);
3328
3328
  }
3329
3329
  }
3330
3330
  setSchema(version, options = {}) {
@@ -3375,8 +3375,8 @@ var require_Document = __commonJS(function(exports) {
3375
3375
  };
3376
3376
  const res = toJS.toJS(this.contents, jsonArg ?? "", ctx);
3377
3377
  if (typeof onAnchor === "function")
3378
- for (const { count, res: res2 } of ctx.anchors.values())
3379
- onAnchor(res2, count);
3378
+ for (const { count, res } of ctx.anchors.values())
3379
+ onAnchor(res, count);
3380
3380
  return typeof reviver === "function" ? applyReviver.applyReviver(reviver, { "": res }, "", res) : res;
3381
3381
  }
3382
3382
  toJSON(jsonArg, onAnchor) {
@@ -4130,12 +4130,12 @@ var require_resolve_block_scalar = __commonJS(function(exports) {
4130
4130
  break;
4131
4131
  }
4132
4132
  if (chompStart === 0) {
4133
- const value2 = header.chomp === "+" && lines.length > 0 ? `
4133
+ const value = header.chomp === "+" && lines.length > 0 ? `
4134
4134
  `.repeat(Math.max(1, lines.length - 1)) : "";
4135
- let end2 = start + header.length;
4135
+ let end = start + header.length;
4136
4136
  if (scalar.source)
4137
- end2 += scalar.source.length;
4138
- return { value: value2, type, comment: header.comment, range: [start, end2, end2] };
4137
+ end += scalar.source.length;
4138
+ return { value, type, comment: header.comment, range: [start, end, end] };
4139
4139
  }
4140
4140
  let trimIndent = scalar.indent + header.indent;
4141
4141
  let offset = scalar.offset + header.length;
@@ -4584,9 +4584,9 @@ var require_compose_scalar = __commonJS(function(exports) {
4584
4584
  return schema[identity.SCALAR];
4585
4585
  }
4586
4586
  function findScalarTagByTest({ atKey, directives, schema }, value, token, onError) {
4587
- const tag = schema.tags.find((tag2) => (tag2.default === true || atKey && tag2.default === "key") && tag2.test?.test(value)) || schema[identity.SCALAR];
4587
+ const tag = schema.tags.find((tag) => (tag.default === true || atKey && tag.default === "key") && tag.test?.test(value)) || schema[identity.SCALAR];
4588
4588
  if (schema.compat) {
4589
- const compat = schema.compat.find((tag2) => tag2.default && tag2.test?.test(value)) ?? schema[identity.SCALAR];
4589
+ const compat = schema.compat.find((tag) => tag.default && tag.test?.test(value)) ?? schema[identity.SCALAR];
4590
4590
  if (tag.tag !== compat.tag) {
4591
4591
  const ts = directives.tagString(tag.tag);
4592
4592
  const cs = directives.tagString(compat.tag);
@@ -5221,9 +5221,9 @@ var require_cst_visit = __commonJS(function(exports) {
5221
5221
  visit.BREAK = BREAK;
5222
5222
  visit.SKIP = SKIP;
5223
5223
  visit.REMOVE = REMOVE;
5224
- visit.itemAtPath = (cst, path2) => {
5224
+ visit.itemAtPath = (cst, path) => {
5225
5225
  let item = cst;
5226
- for (const [field, index] of path2) {
5226
+ for (const [field, index] of path) {
5227
5227
  const tok = item?.[field];
5228
5228
  if (tok && "items" in tok) {
5229
5229
  item = tok.items[index];
@@ -5232,23 +5232,23 @@ var require_cst_visit = __commonJS(function(exports) {
5232
5232
  }
5233
5233
  return item;
5234
5234
  };
5235
- visit.parentCollection = (cst, path2) => {
5236
- const parent = visit.itemAtPath(cst, path2.slice(0, -1));
5237
- const field = path2[path2.length - 1][0];
5235
+ visit.parentCollection = (cst, path) => {
5236
+ const parent = visit.itemAtPath(cst, path.slice(0, -1));
5237
+ const field = path[path.length - 1][0];
5238
5238
  const coll = parent?.[field];
5239
5239
  if (coll && "items" in coll)
5240
5240
  return coll;
5241
5241
  throw new Error("Parent collection not found");
5242
5242
  };
5243
- function _visit(path2, item, visitor) {
5244
- let ctrl = visitor(item, path2);
5243
+ function _visit(path, item, visitor) {
5244
+ let ctrl = visitor(item, path);
5245
5245
  if (typeof ctrl === "symbol")
5246
5246
  return ctrl;
5247
5247
  for (const field of ["key", "value"]) {
5248
5248
  const token = item[field];
5249
5249
  if (token && "items" in token) {
5250
5250
  for (let i = 0;i < token.items.length; ++i) {
5251
- const ci = _visit(Object.freeze(path2.concat([[field, i]])), token.items[i], visitor);
5251
+ const ci = _visit(Object.freeze(path.concat([[field, i]])), token.items[i], visitor);
5252
5252
  if (typeof ci === "number")
5253
5253
  i = ci - 1;
5254
5254
  else if (ci === BREAK)
@@ -5259,10 +5259,10 @@ var require_cst_visit = __commonJS(function(exports) {
5259
5259
  }
5260
5260
  }
5261
5261
  if (typeof ctrl === "function" && field === "key")
5262
- ctrl = ctrl(item, path2);
5262
+ ctrl = ctrl(item, path);
5263
5263
  }
5264
5264
  }
5265
- return typeof ctrl === "function" ? ctrl(item, path2) : ctrl;
5265
+ return typeof ctrl === "function" ? ctrl(item, path) : ctrl;
5266
5266
  }
5267
5267
  exports.visit = visit;
5268
5268
  });
@@ -5742,18 +5742,18 @@ var require_lexer = __commonJS(function(exports) {
5742
5742
  let indent = 0;
5743
5743
  let ch;
5744
5744
  loop:
5745
- for (let i2 = this.pos;ch = this.buffer[i2]; ++i2) {
5745
+ for (let i = this.pos;ch = this.buffer[i]; ++i) {
5746
5746
  switch (ch) {
5747
5747
  case " ":
5748
5748
  indent += 1;
5749
5749
  break;
5750
5750
  case `
5751
5751
  `:
5752
- nl = i2;
5752
+ nl = i;
5753
5753
  indent = 0;
5754
5754
  break;
5755
5755
  case "\r": {
5756
- const next = this.buffer[i2 + 1];
5756
+ const next = this.buffer[i + 1];
5757
5757
  if (!next && !this.atEnd)
5758
5758
  return this.setNext("block-scalar");
5759
5759
  if (next === `
@@ -5796,16 +5796,16 @@ var require_lexer = __commonJS(function(exports) {
5796
5796
  nl = i - 1;
5797
5797
  } else if (!this.blockScalarKeep) {
5798
5798
  do {
5799
- let i2 = nl - 1;
5800
- let ch2 = this.buffer[i2];
5801
- if (ch2 === "\r")
5802
- ch2 = this.buffer[--i2];
5803
- const lastChar = i2;
5804
- while (ch2 === " ")
5805
- ch2 = this.buffer[--i2];
5806
- if (ch2 === `
5807
- ` && i2 >= this.pos && i2 + 1 + indent > lastChar)
5808
- nl = i2;
5799
+ let i = nl - 1;
5800
+ let ch = this.buffer[i];
5801
+ if (ch === "\r")
5802
+ ch = this.buffer[--i];
5803
+ const lastChar = i;
5804
+ while (ch === " ")
5805
+ ch = this.buffer[--i];
5806
+ if (ch === `
5807
+ ` && i >= this.pos && i + 1 + indent > lastChar)
5808
+ nl = i;
5809
5809
  else
5810
5810
  break;
5811
5811
  } while (true);
@@ -6492,12 +6492,12 @@ var require_parser = __commonJS(function(exports) {
6492
6492
  if (includesToken(it.start, "newline")) {
6493
6493
  Object.assign(it, { key: null, sep: [this.sourceToken] });
6494
6494
  } else {
6495
- const start2 = getFirstKeyStartProps(it.start);
6495
+ const start = getFirstKeyStartProps(it.start);
6496
6496
  this.stack.push({
6497
6497
  type: "block-map",
6498
6498
  offset: this.offset,
6499
6499
  indent: this.indent,
6500
- items: [{ start: start2, key: null, sep: [this.sourceToken] }]
6500
+ items: [{ start, key: null, sep: [this.sourceToken] }]
6501
6501
  });
6502
6502
  }
6503
6503
  } else if (it.value) {
@@ -6510,7 +6510,7 @@ var require_parser = __commonJS(function(exports) {
6510
6510
  items: [{ start, key: null, sep: [this.sourceToken] }]
6511
6511
  });
6512
6512
  } else if (isFlowToken(it.key) && !includesToken(it.sep, "newline")) {
6513
- const start2 = getFirstKeyStartProps(it.start);
6513
+ const start = getFirstKeyStartProps(it.start);
6514
6514
  const key = it.key;
6515
6515
  const sep = it.sep;
6516
6516
  sep.push(this.sourceToken);
@@ -6520,7 +6520,7 @@ var require_parser = __commonJS(function(exports) {
6520
6520
  type: "block-map",
6521
6521
  offset: this.offset,
6522
6522
  indent: this.indent,
6523
- items: [{ start: start2, key, sep }]
6523
+ items: [{ start, key, sep }]
6524
6524
  });
6525
6525
  } else if (start.length > 0) {
6526
6526
  it.sep = it.sep.concat(start, this.sourceToken);
@@ -6549,14 +6549,14 @@ var require_parser = __commonJS(function(exports) {
6549
6549
  case "scalar":
6550
6550
  case "single-quoted-scalar":
6551
6551
  case "double-quoted-scalar": {
6552
- const fs3 = this.flowScalar(this.type);
6552
+ const fs = this.flowScalar(this.type);
6553
6553
  if (atNextItem || it.value) {
6554
- map.items.push({ start, key: fs3, sep: [] });
6554
+ map.items.push({ start, key: fs, sep: [] });
6555
6555
  this.onKeyLine = true;
6556
6556
  } else if (it.sep) {
6557
- this.stack.push(fs3);
6557
+ this.stack.push(fs);
6558
6558
  } else {
6559
- Object.assign(it, { key: fs3, sep: [] });
6559
+ Object.assign(it, { key: fs, sep: [] });
6560
6560
  this.onKeyLine = true;
6561
6561
  }
6562
6562
  return;
@@ -6684,13 +6684,13 @@ var require_parser = __commonJS(function(exports) {
6684
6684
  case "scalar":
6685
6685
  case "single-quoted-scalar":
6686
6686
  case "double-quoted-scalar": {
6687
- const fs3 = this.flowScalar(this.type);
6687
+ const fs = this.flowScalar(this.type);
6688
6688
  if (!it || it.value)
6689
- fc.items.push({ start: [], key: fs3, sep: [] });
6689
+ fc.items.push({ start: [], key: fs, sep: [] });
6690
6690
  else if (it.sep)
6691
- this.stack.push(fs3);
6691
+ this.stack.push(fs);
6692
6692
  else
6693
- Object.assign(it, { key: fs3, sep: [] });
6693
+ Object.assign(it, { key: fs, sep: [] });
6694
6694
  return;
6695
6695
  }
6696
6696
  case "flow-map-end":
@@ -6864,22 +6864,22 @@ var require_public_api = __commonJS(function(exports) {
6864
6864
  return { lineCounter: lineCounter$1, prettyErrors };
6865
6865
  }
6866
6866
  function parseAllDocuments(source, options = {}) {
6867
- const { lineCounter: lineCounter2, prettyErrors } = parseOptions(options);
6868
- const parser$1 = new parser.Parser(lineCounter2?.addNewLine);
6867
+ const { lineCounter, prettyErrors } = parseOptions(options);
6868
+ const parser$1 = new parser.Parser(lineCounter?.addNewLine);
6869
6869
  const composer$1 = new composer.Composer(options);
6870
6870
  const docs = Array.from(composer$1.compose(parser$1.parse(source)));
6871
- if (prettyErrors && lineCounter2)
6871
+ if (prettyErrors && lineCounter)
6872
6872
  for (const doc of docs) {
6873
- doc.errors.forEach(errors.prettifyError(source, lineCounter2));
6874
- doc.warnings.forEach(errors.prettifyError(source, lineCounter2));
6873
+ doc.errors.forEach(errors.prettifyError(source, lineCounter));
6874
+ doc.warnings.forEach(errors.prettifyError(source, lineCounter));
6875
6875
  }
6876
6876
  if (docs.length > 0)
6877
6877
  return docs;
6878
6878
  return Object.assign([], { empty: true }, composer$1.streamInfo());
6879
6879
  }
6880
6880
  function parseDocument(source, options = {}) {
6881
- const { lineCounter: lineCounter2, prettyErrors } = parseOptions(options);
6882
- const parser$1 = new parser.Parser(lineCounter2?.addNewLine);
6881
+ const { lineCounter, prettyErrors } = parseOptions(options);
6882
+ const parser$1 = new parser.Parser(lineCounter?.addNewLine);
6883
6883
  const composer$1 = new composer.Composer(options);
6884
6884
  let doc = null;
6885
6885
  for (const _doc of composer$1.compose(parser$1.parse(source), true, source.length)) {
@@ -6890,9 +6890,9 @@ var require_public_api = __commonJS(function(exports) {
6890
6890
  break;
6891
6891
  }
6892
6892
  }
6893
- if (prettyErrors && lineCounter2) {
6894
- doc.errors.forEach(errors.prettifyError(source, lineCounter2));
6895
- doc.warnings.forEach(errors.prettifyError(source, lineCounter2));
6893
+ if (prettyErrors && lineCounter) {
6894
+ doc.errors.forEach(errors.prettifyError(source, lineCounter));
6895
+ doc.warnings.forEach(errors.prettifyError(source, lineCounter));
6896
6896
  }
6897
6897
  return doc;
6898
6898
  }
@@ -6949,16 +6949,16 @@ import * as os8 from "node:os";
6949
6949
  import * as path23 from "node:path";
6950
6950
  import {
6951
6951
  APP_NAME as APP_NAME3,
6952
- keyHintIfBound as keyHintIfBound3
6952
+ keyHintIfBound as keyHintIfBound5
6953
6953
  } from "@bastani/atomic";
6954
6954
  import {
6955
6955
  Box,
6956
6956
  Container as Container4,
6957
6957
  Spacer as Spacer2,
6958
- Text as Text4,
6959
- truncateToWidth,
6960
- visibleWidth as visibleWidth2,
6961
- wrapTextWithAnsi
6958
+ Text as Text5,
6959
+ truncateToWidth as truncateToWidth4,
6960
+ visibleWidth as visibleWidth4,
6961
+ wrapTextWithAnsi as wrapTextWithAnsi2
6962
6962
  } from "@earendil-works/pi-tui";
6963
6963
 
6964
6964
  // dist/builtin/subagents/src/agents/agent-discovery.ts
@@ -7234,7 +7234,7 @@ function readSubagentSettings(filePath) {
7234
7234
  }
7235
7235
  function readMergedSubagentSettings(filePaths) {
7236
7236
  let settings = EMPTY_SUBAGENT_SETTINGS;
7237
- let path2 = null;
7237
+ let path = null;
7238
7238
  for (let i = filePaths.length - 1;i >= 0; i--) {
7239
7239
  const filePath = filePaths[i];
7240
7240
  if (!fs2.existsSync(filePath))
@@ -7244,9 +7244,9 @@ function readMergedSubagentSettings(filePaths) {
7244
7244
  disableBuiltins: next.disableBuiltins ?? settings.disableBuiltins,
7245
7245
  overrides: { ...settings.overrides, ...next.overrides }
7246
7246
  };
7247
- path2 = filePath;
7247
+ path = filePath;
7248
7248
  }
7249
- return { settings, path: path2 };
7249
+ return { settings, path };
7250
7250
  }
7251
7251
  function applyBuiltinOverride(agent, override, meta) {
7252
7252
  const next = {
@@ -8169,7 +8169,7 @@ var DEFAULT_INTERCOM_BRIDGE_TEMPLATE = `The inherited thread is reference-only.
8169
8169
 
8170
8170
  Use contact_supervisor first. It resolves the supervisor session "{orchestratorTarget}" and run metadata automatically.
8171
8171
  - Need a decision, blocked, approval, or product/API/scope ambiguity: contact_supervisor({ reason: "need_decision", message: "<question>" })
8172
- - A claimed decision or interview ends this child. Do not wait for or expect a reply in this run; the supervisor receives a dynamic [TASK_CONTEXT] handoff and may launch a fresh subagent with a new run identity and the answer.
8172
+ - In parallel runs, blocking requests wait here and the supervisor's correlated reply lets this same child continue; siblings keep running. Do not request a replacement launch. A single-child claimed decision/interview instead ends with a dynamic [TASK_CONTEXT] fresh-child handoff; follow the actual tool result.
8173
8173
  - Do not ask for clarification when the only conflict is review-only/no-edit versus progress-writing or artifact-writing instructions. Review-only/no-edit wins; leave files unchanged and mention the conflict in your final result only if it matters.
8174
8174
  - Meaningful progress or unexpected discoveries that change the plan: contact_supervisor({ reason: "progress_update", message: "UPDATE: <summary>" })
8175
8175
  - Generic intercom is lower-level plumbing/fallback only: intercom({ action: "ask", to: "{orchestratorTarget}", message: "<question>" })
@@ -8483,9 +8483,9 @@ function resolveTempScopeId(options) {
8483
8483
  if (username)
8484
8484
  return `user-${sanitizeTempScopeSegment(username)}`;
8485
8485
  } catch {}
8486
- const homedir5 = env.USERPROFILE ?? env.HOME;
8487
- if (homedir5)
8488
- return `home-${sanitizeTempScopeSegment(homedir5)}`;
8486
+ const homedir = env.USERPROFILE ?? env.HOME;
8487
+ if (homedir)
8488
+ return `home-${sanitizeTempScopeSegment(homedir)}`;
8489
8489
  const resolveHomedir = options && Object.hasOwn(options, "homedir") ? options.homedir : os4.homedir;
8490
8490
  try {
8491
8491
  const fallbackHomedir = resolveHomedir?.();
@@ -8504,7 +8504,7 @@ var SLASH_SUBAGENT_STARTED_EVENT = "subagent:slash:started";
8504
8504
  var SLASH_SUBAGENT_RESPONSE_EVENT = "subagent:slash:response";
8505
8505
  var SLASH_SUBAGENT_UPDATE_EVENT = "subagent:slash:update";
8506
8506
  var SLASH_SUBAGENT_CANCEL_EVENT = "subagent:slash:cancel";
8507
- var SUBAGENT_ACTIONS = ["list", "get", "create", "update", "delete", "status", "interrupt"];
8507
+ var SUBAGENT_ACTIONS = ["list", "get", "create", "update", "delete", "status", "interrupt", "wait"];
8508
8508
  var DEFAULT_FORK_PREAMBLE = "You are a delegated subagent running from a fork of the parent session. " + "Treat the inherited conversation as reference-only context, not a live thread to continue. " + "Do not continue or answer prior messages as if they are waiting for a reply. " + "Your sole job is to execute the task below and return a focused result for that task using your tools.";
8509
8509
  function normalizeTopLevelParallelValue(value) {
8510
8510
  const parsed = typeof value === "number" ? value : typeof value === "string" ? Number(value) : NaN;
@@ -8892,8 +8892,8 @@ function collectInstalledPackageSkillPaths(cwd) {
8892
8892
  continue;
8893
8893
  if (!scopeEntry.isDirectory() && !scopeEntry.isSymbolicLink())
8894
8894
  continue;
8895
- const pkgRoot2 = path7.join(scopeDir, scopeEntry.name);
8896
- results.push(...extractSkillPathsFromPackageRoot(pkgRoot2, dir.source, true));
8895
+ const pkgRoot = path7.join(scopeDir, scopeEntry.name);
8896
+ results.push(...extractSkillPathsFromPackageRoot(pkgRoot, dir.source, true));
8897
8897
  }
8898
8898
  continue;
8899
8899
  }
@@ -10012,9 +10012,12 @@ function handleSubagentControlNotice(input) {
10012
10012
  }
10013
10013
 
10014
10014
  // dist/builtin/subagents/src/runs/inprocess/runner.ts
10015
+ import { randomUUID } from "node:crypto";
10015
10016
  import { appendFileSync as appendFileSync2, existsSync as existsSync10, mkdirSync as mkdirSync4, statSync as statSync4 } from "node:fs";
10016
10017
  import { basename as basename2, dirname as dirname7, join as join10, relative as relative2, resolve as resolve6 } from "node:path";
10017
10018
  import {
10019
+ applyAssistantMessageDelta,
10020
+ beginStreamingAssistantMessage,
10018
10021
  createAgentSession,
10019
10022
  DefaultResourceLoader,
10020
10023
  getAgentDir as getAgentDir2,
@@ -10025,6 +10028,7 @@ import {
10025
10028
  import {
10026
10029
  SubagentControl
10027
10030
  } from "@bastani/atomic-natives";
10031
+ import { clampThinkingLevel } from "@bastani/pi-ai/compat";
10028
10032
 
10029
10033
  // dist/builtin/subagents/src/shared/artifacts.ts
10030
10034
  import * as fs10 from "node:fs";
@@ -10449,14 +10453,14 @@ function waitForExecutionCapacity(delayMs, signals) {
10449
10453
  return new Promise((resolveWait) => {
10450
10454
  let settled = false;
10451
10455
  let timer;
10452
- const settle = (result2) => {
10456
+ const settle = (result) => {
10453
10457
  if (settled)
10454
10458
  return;
10455
10459
  settled = true;
10456
10460
  clearTimeout(timer);
10457
10461
  signals.abort.removeEventListener("abort", onAbort);
10458
10462
  signals.interrupt.removeEventListener("abort", onInterrupt);
10459
- resolveWait(result2);
10463
+ resolveWait(result);
10460
10464
  };
10461
10465
  const onAbort = () => settle("abort");
10462
10466
  const onInterrupt = () => settle("interrupt");
@@ -10504,10 +10508,10 @@ function createTestSession(sessionManager, spec) {
10504
10508
  let aborted = false;
10505
10509
  let settlePromptAbort;
10506
10510
  const messages = [];
10507
- const promptAbort = new Promise((resolve7, reject) => {
10511
+ const promptAbort = new Promise((resolve, reject) => {
10508
10512
  settlePromptAbort = () => {
10509
10513
  if (testOptions.abortResolvesPrompt)
10510
- resolve7("aborted");
10514
+ resolve("aborted");
10511
10515
  else
10512
10516
  reject(new Error("aborted"));
10513
10517
  };
@@ -10592,6 +10596,9 @@ function createTestSession(sessionManager, spec) {
10592
10596
  }
10593
10597
  if (testOptions.fallbackBeforeGate)
10594
10598
  emitFallback();
10599
+ for (const event of testOptions.beforeGateEvents ?? [])
10600
+ for (const listener of listeners)
10601
+ listener(event);
10595
10602
  if (testOptions.promptGate) {
10596
10603
  const gateResult = await Promise.race([
10597
10604
  testOptions.promptGate.then(() => "released"),
@@ -10646,7 +10653,7 @@ function createTestSession(sessionManager, spec) {
10646
10653
  tokens: zeroTokens,
10647
10654
  cost: 0
10648
10655
  }),
10649
- dispose: () => {}
10656
+ dispose: testOptions.dispose ?? (() => {})
10650
10657
  };
10651
10658
  }
10652
10659
  function nativeStatus(value) {
@@ -10655,14 +10662,14 @@ function nativeStatus(value) {
10655
10662
  function nativeCause(value) {
10656
10663
  return value;
10657
10664
  }
10658
- function refusal(result2) {
10659
- if (!result2.refusal)
10665
+ function refusal(result) {
10666
+ if (!result.refusal)
10660
10667
  return {};
10661
10668
  return {
10662
10669
  refusal: {
10663
- kind: result2.refusal.kind,
10664
- reason: result2.refusal.reason,
10665
- ...result2.refusal.maxDepth === undefined ? {} : { maxDepth: result2.refusal.maxDepth }
10670
+ kind: result.refusal.kind,
10671
+ reason: result.refusal.reason,
10672
+ ...result.refusal.maxDepth === undefined ? {} : { maxDepth: result.refusal.maxDepth }
10666
10673
  }
10667
10674
  };
10668
10675
  }
@@ -10701,10 +10708,10 @@ function attemptStatus(termination) {
10701
10708
  }
10702
10709
  function boundedEnvelope(output, artifactPath, maxOutput) {
10703
10710
  const config = { ...DEFAULT_MAX_OUTPUT, ...maxOutput };
10704
- const result2 = truncateOutput(output, config, artifactPath);
10705
- return result2.truncated && artifactPath ? `${result2.text}
10711
+ const result = truncateOutput(output, config, artifactPath);
10712
+ return result.truncated && artifactPath ? `${result.text}
10706
10713
 
10707
- Full output: ${artifactPath}` : result2.text;
10714
+ Full output: ${artifactPath}` : result.text;
10708
10715
  }
10709
10716
  function canonicalArtifactPaths(artifactsDir, childPath) {
10710
10717
  const prefix = childPath.replaceAll("/", "_");
@@ -10829,13 +10836,13 @@ class SubagentControlRuntime {
10829
10836
  const native = this.native.admitChildSession({ taskName: spec.taskName, agentName: spec.agent.name, cwd: spec.cwd }, { path: parent.path, depth: parent.depth });
10830
10837
  if (!native.child)
10831
10838
  return refusal(native);
10832
- const identity2 = native.child;
10839
+ const identity = native.child;
10833
10840
  const childModePolicy = resolveChildModePolicy(spec);
10834
- const sessionDir = spec.sessionFile ? dirname7(spec.sessionFile) : sessionDirectory(this.sessionRoot, identity2.path);
10841
+ const sessionDir = spec.sessionFile ? dirname7(spec.sessionFile) : sessionDirectory(this.sessionRoot, identity.path);
10835
10842
  mkdirSync4(sessionDir, { recursive: true });
10836
10843
  return {
10837
10844
  admitted: AdmittedChild.create({
10838
- identity: identity2,
10845
+ identity,
10839
10846
  spec,
10840
10847
  policy: {
10841
10848
  ...childModePolicy,
@@ -10849,7 +10856,7 @@ class SubagentControlRuntime {
10849
10856
  thinkingLevel: spec.thinkingLevel ?? spec.agent.thinking,
10850
10857
  intercomGroup: parent.intercomGroup,
10851
10858
  intercom: spec.intercom,
10852
- depth: identity2.depth
10859
+ depth: identity.depth
10853
10860
  },
10854
10861
  sessionDir,
10855
10862
  sessionFile: spec.sessionFile,
@@ -10857,12 +10864,22 @@ class SubagentControlRuntime {
10857
10864
  })
10858
10865
  };
10859
10866
  }
10860
- async runChildAttempt(admitted, candidate, signals, onModelChange) {
10867
+ async runChildAttempt(admitted, candidate, signals, onModelChange, taskHooks, onCleanup) {
10861
10868
  const candidateModelId = modelIdForCandidate(candidate, admitted.policy.model);
10862
10869
  const configuredThinking = candidate.thinkingLevel ?? admitted.policy.thinkingLevel;
10863
10870
  let effectiveModelId = candidateModelId;
10864
10871
  let effectiveThinking = initialThinkingForAttempt(candidateModelId, configuredThinking);
10865
10872
  let attemptedModels = candidateModelId ? [candidateModelId] : [];
10873
+ const selectedModel = candidate.model ?? admitted.policy.model;
10874
+ if (selectedModel)
10875
+ taskHooks?.reportActivity({
10876
+ reportId: `${randomUUID()}:admission-model`,
10877
+ change: {
10878
+ kind: "model",
10879
+ model: `${selectedModel.provider}/${selectedModel.id}`,
10880
+ thinking: configuredThinking === undefined ? undefined : clampThinkingLevel(selectedModel, configuredThinking)
10881
+ }
10882
+ });
10866
10883
  let guard;
10867
10884
  let retryDelayMs = CAPACITY_RETRY_INITIAL_DELAY_MS;
10868
10885
  for (;; ) {
@@ -10914,6 +10931,7 @@ class SubagentControlRuntime {
10914
10931
  const token = guard.token;
10915
10932
  this.attemptTokens.set(admitted.identity.path, token);
10916
10933
  let session;
10934
+ const executionEnded = new AbortController;
10917
10935
  let activeSessionManager;
10918
10936
  let termination;
10919
10937
  let terminating;
@@ -10948,6 +10966,7 @@ class SubagentControlRuntime {
10948
10966
  mkdirSync4(dirname7(admitted.sessionFile), { recursive: true });
10949
10967
  const sessionManager = admitted.sessionFile ? SessionManager.open(admitted.sessionFile, admitted.sessionDir, admitted.policy.cwd) : SessionManager.create(admitted.policy.cwd, admitted.sessionDir, workflow ? { internal: true, workflow } : { internal: true });
10950
10968
  activeSessionManager = sessionManager;
10969
+ taskHooks?.bindTranscript?.(sessionManager);
10951
10970
  if (workflow)
10952
10971
  sessionManager.markSessionInternal(workflow);
10953
10972
  let created;
@@ -10987,7 +11006,7 @@ class SubagentControlRuntime {
10987
11006
  sessionManager,
10988
11007
  settingsManager,
10989
11008
  orchestrationContext: admitted.spec.parent?.orchestrationContext,
10990
- subagentPolicy: admitted.policy,
11009
+ subagentPolicy: { ...admitted.policy, executionEnded: executionEnded.signal },
10991
11010
  systemPromptTransform,
10992
11011
  initialContextTransform: promptBehavior.initialContextTransform
10993
11012
  })).session
@@ -10995,6 +11014,14 @@ class SubagentControlRuntime {
10995
11014
  await created.session.extensionRunner.emit({ type: "session_start", reason: "startup" });
10996
11015
  }
10997
11016
  session = created.session;
11017
+ const transcriptSession = session;
11018
+ let observedStreamingMessage;
11019
+ taskHooks?.bindTranscript?.({
11020
+ getSessionId: () => sessionManager.getSessionId(),
11021
+ getEntries: () => sessionManager.getEntries(),
11022
+ subscribe: (listener) => transcriptSession.subscribe(listener),
11023
+ getStreamingMessage: () => observedStreamingMessage
11024
+ });
10998
11025
  const initialModelId = modelIdForSession(session) ?? candidateModelId;
10999
11026
  effectiveModelId = initialModelId;
11000
11027
  effectiveThinking = thinkingLevelForSession(session) ?? initialThinkingForAttempt(candidateModelId, configuredThinking);
@@ -11015,10 +11042,11 @@ class SubagentControlRuntime {
11015
11042
  lastActivityAt: Date.now()
11016
11043
  };
11017
11044
  const attemptStartedAt = Date.now();
11045
+ const activityPrefix = randomUUID();
11018
11046
  let lastProgressEmit = 0;
11019
11047
  const emitProgress = (force) => {
11020
11048
  const onProgress = admitted.spec.onProgress;
11021
- if (!onProgress)
11049
+ if (!onProgress && !taskHooks)
11022
11050
  return;
11023
11051
  const now = Date.now();
11024
11052
  if (!force && now - lastProgressEmit < 400)
@@ -11026,11 +11054,38 @@ class SubagentControlRuntime {
11026
11054
  lastProgressEmit = now;
11027
11055
  progressState.durationMs = now - attemptStartedAt;
11028
11056
  progressState.lastActivityAt = now;
11029
- onProgress({ ...progressState, recentTools: [...progressState.recentTools] });
11057
+ taskHooks?.reportActivity({
11058
+ reportId: `${activityPrefix}:metrics-${++activitySequence}`,
11059
+ change: {
11060
+ kind: "metrics",
11061
+ elapsedMs: progressState.durationMs,
11062
+ toolCount: progressState.toolCount,
11063
+ tokenCount: progressState.tokens
11064
+ }
11065
+ });
11066
+ onProgress?.({ ...progressState, recentTools: [...progressState.recentTools] });
11030
11067
  };
11068
+ let activitySequence = 0;
11069
+ const reportModel = () => taskHooks?.reportActivity({
11070
+ reportId: `${activityPrefix}:model-${++activitySequence}`,
11071
+ change: { kind: "model", model: effectiveModelId, thinking: effectiveThinking }
11072
+ });
11073
+ reportModel();
11031
11074
  unsubscribe = session.subscribe((event) => {
11032
11075
  writeEvent(admitted.spec.artifactJsonlPath, event);
11076
+ if (event.type === "message_start" && event.message.role === "assistant")
11077
+ observedStreamingMessage = beginStreamingAssistantMessage(event.message);
11078
+ else if (event.type === "message_update" && observedStreamingMessage)
11079
+ applyAssistantMessageDelta(observedStreamingMessage, event.assistantMessageEvent);
11080
+ else if (event.type === "message_end" && event.message.role === "assistant")
11081
+ observedStreamingMessage = undefined;
11033
11082
  const emission = progressEmissionFor(event.type);
11083
+ if (event.type === "tool_execution_start") {
11084
+ taskHooks?.reportActivity({
11085
+ reportId: `${activityPrefix}:tool-${++activitySequence}`,
11086
+ change: { kind: "action", tool: event.toolName, text: safeArgsPreview(event.args) }
11087
+ });
11088
+ }
11034
11089
  if (event.type === "agent_start") {
11035
11090
  this.native.publishChildStatus(admitted.identity.path, nativeStatus("running"));
11036
11091
  } else if (event.type === "tool_execution_start") {
@@ -11068,10 +11123,13 @@ class SubagentControlRuntime {
11068
11123
  effectiveModelId = event.to;
11069
11124
  progressState.model = event.to;
11070
11125
  onModelChange?.(effectiveModelId, effectiveThinking);
11126
+ reportModel();
11127
+ emitProgress(true);
11071
11128
  } else if (event.type === "thinking_level_changed") {
11072
11129
  effectiveThinking = event.level;
11073
11130
  progressState.thinking = effectiveThinking;
11074
11131
  onModelChange?.(effectiveModelId, effectiveThinking);
11132
+ reportModel();
11075
11133
  emitProgress(true);
11076
11134
  }
11077
11135
  });
@@ -11160,6 +11218,7 @@ class SubagentControlRuntime {
11160
11218
  ...skillReport
11161
11219
  };
11162
11220
  } finally {
11221
+ executionEnded.abort();
11163
11222
  signals.abort.removeEventListener("abort", abortListener);
11164
11223
  signals.interrupt.removeEventListener("abort", interruptListener);
11165
11224
  try {
@@ -11168,16 +11227,36 @@ class SubagentControlRuntime {
11168
11227
  try {
11169
11228
  activeSessionManager?.flush();
11170
11229
  } catch {}
11171
- try {
11172
- session?.dispose();
11173
- } catch {}
11230
+ if (onCleanup) {
11231
+ onCleanup((async () => {
11232
+ try {
11233
+ await session?.dispose();
11234
+ return { kind: "reaped" };
11235
+ } catch (error) {
11236
+ return {
11237
+ kind: "failed",
11238
+ resources: [
11239
+ {
11240
+ resource: "agent-session",
11241
+ code: "CleanupFailed",
11242
+ message: error instanceof Error ? error.message : String(error)
11243
+ }
11244
+ ]
11245
+ };
11246
+ }
11247
+ })());
11248
+ } else {
11249
+ try {
11250
+ session?.dispose();
11251
+ } catch {}
11252
+ }
11174
11253
  if (this.attemptTokens.get(admitted.identity.path) === token)
11175
11254
  this.attemptTokens.delete(admitted.identity.path);
11176
11255
  if (this.attemptTerminators.get(admitted.identity.path) === terminate)
11177
11256
  this.attemptTerminators.delete(admitted.identity.path);
11178
11257
  }
11179
11258
  }
11180
- startAttempt(admitted, candidate, signals) {
11259
+ startAttempt(admitted, candidate, signals, taskHooks) {
11181
11260
  const initialModel = modelIdForCandidate(candidate, admitted.policy.model);
11182
11261
  const initialThinking = initialThinkingForAttempt(initialModel, candidate.thinkingLevel ?? admitted.policy.thinkingLevel);
11183
11262
  const running = {
@@ -11196,19 +11275,26 @@ class SubagentControlRuntime {
11196
11275
  envelope: "uninitialized"
11197
11276
  })
11198
11277
  };
11278
+ let cleanup = Promise.resolve({ kind: "reaped" });
11199
11279
  running.promise = this.runChildAttempt(admitted, candidate, signals, (model, thinking) => {
11200
11280
  running.currentModel = model;
11201
11281
  running.currentThinking = thinking;
11202
- }).then((result2) => {
11203
- running.status = result2.status;
11282
+ }, taskHooks, taskHooks ? (result) => {
11283
+ cleanup = result;
11284
+ } : undefined).then((result) => {
11285
+ running.status = result.status;
11204
11286
  this.runningAttempts.delete(running.id);
11205
- return result2;
11287
+ return result;
11206
11288
  });
11207
11289
  running.terminate = (cause) => this.terminateRunningAttempt(running, cause);
11208
11290
  running.promise.catch(() => {
11209
11291
  return;
11210
11292
  });
11211
11293
  this.runningAttempts.set(running.id, running);
11294
+ taskHooks?.onExecution({
11295
+ result: running.promise,
11296
+ cleanup: running.promise.then(() => cleanup, () => cleanup)
11297
+ });
11212
11298
  return running;
11213
11299
  }
11214
11300
  continueDetached(running, _reason) {
@@ -11349,6 +11435,21 @@ function childLines(control, id) {
11349
11435
  }
11350
11436
  return control.listChildren().map((child) => `${child.path} — ${child.status} (${child.loaded ? "loaded" : "cold"})`);
11351
11437
  }
11438
+ function statusGroup(control, id) {
11439
+ return {
11440
+ parentPath: control.parent.path,
11441
+ children: canonicalChildren(control).filter((child) => !id || id === control.parent.path || child.path === id).map((child) => {
11442
+ const delivered = control.getDeliveredResult(child.path);
11443
+ const metadata = control.getChildMetadata(child.path) ?? delivered;
11444
+ return {
11445
+ ...child,
11446
+ sessionFile: delivered?.sessionFile,
11447
+ ...metadata?.model === undefined ? {} : { model: metadata.model },
11448
+ ...metadata?.thinking === undefined ? {} : { thinking: metadata.thinking }
11449
+ };
11450
+ })
11451
+ };
11452
+ }
11352
11453
  function inspectInProcessChildStatus(id) {
11353
11454
  if (id) {
11354
11455
  const control = findSubagentControl(id);
@@ -11361,19 +11462,17 @@ function inspectInProcessChildStatus(id) {
11361
11462
  return;
11362
11463
  return {
11363
11464
  content: [{ type: "text", text }],
11364
- details: { mode: "management", results: [] }
11465
+ details: { mode: "management", results: [], statusGroups: [statusGroup(control, id)] }
11365
11466
  };
11366
11467
  }
11367
- const lines = listSubagentControls().flatMap((control) => [
11368
- `Parent: ${control.parent.path}`,
11369
- ...childLines(control)
11370
- ]);
11468
+ const controls = listSubagentControls();
11469
+ const lines = controls.flatMap((control) => [`Parent: ${control.parent.path}`, ...childLines(control)]);
11371
11470
  if (lines.length === 0)
11372
11471
  return;
11373
11472
  return {
11374
11473
  content: [{ type: "text", text: lines.join(`
11375
11474
  `) }],
11376
- details: { mode: "management", results: [] }
11475
+ details: { mode: "management", results: [], statusGroups: controls.map((control) => statusGroup(control)) }
11377
11476
  };
11378
11477
  }
11379
11478
  async function interruptInProcessChild(id) {
@@ -11481,8 +11580,8 @@ function registerBurstDisplay(callIds, taskCount) {
11481
11580
  }
11482
11581
  return display;
11483
11582
  }
11484
- function updateBurstDisplay(display, result2) {
11485
- display.result = result2;
11583
+ function updateBurstDisplay(display, result) {
11584
+ display.result = result;
11486
11585
  }
11487
11586
  function getBurstDisplay(callId) {
11488
11587
  const display = displayByCallId.get(callId);
@@ -11503,20 +11602,17 @@ function resolveRequestedCwd(runtimeCwd, requestedCwd) {
11503
11602
 
11504
11603
  // dist/builtin/subagents/src/runs/foreground/subagent-executor-live-update.ts
11505
11604
  var liveResultIndices = new WeakMap;
11506
- function markLiveResultIndices(result2, indices) {
11507
- liveResultIndices.set(result2, indices);
11605
+ function markLiveResultIndices(result, indices) {
11606
+ liveResultIndices.set(result, indices);
11508
11607
  }
11509
- function getLiveResultIndices(result2) {
11510
- return liveResultIndices.get(result2);
11608
+ function getLiveResultIndices(result) {
11609
+ return liveResultIndices.get(result);
11511
11610
  }
11512
11611
 
11513
11612
  // dist/builtin/subagents/src/runs/foreground/subagent-executor-parent-ask-projection.ts
11514
11613
  var parentAskHandoffs = new WeakMap;
11515
- function markParentAskHandoff(result2, handoff) {
11516
- parentAskHandoffs.set(result2, handoff);
11517
- }
11518
- function getParentAskHandoff(result2) {
11519
- return parentAskHandoffs.get(result2);
11614
+ function getParentAskHandoff(result) {
11615
+ return parentAskHandoffs.get(result);
11520
11616
  }
11521
11617
 
11522
11618
  // dist/builtin/subagents/src/runs/foreground/subagent-executor-types.ts
@@ -11656,11 +11752,11 @@ function formatStandardParallelContent(results) {
11656
11752
  error: child.error
11657
11753
  })), (index, agent) => `=== Task ${index + 1}: ${agent} ===`);
11658
11754
  }
11659
- function projectParentAskContent(result2, route, projectedResults) {
11660
- const handoff = getParentAskHandoff(result2);
11755
+ function projectParentAskContent(result, route, projectedResults) {
11756
+ const handoff = getParentAskHandoff(result);
11661
11757
  if (!handoff)
11662
11758
  return;
11663
- const originalItem = result2.content.length === 1 && result2.content[0]?.type === "text" ? result2.content[0] : { type: "text", text: "" };
11759
+ const originalItem = result.content.length === 1 && result.content[0]?.type === "text" ? result.content[0] : { type: "text", text: "" };
11664
11760
  const routeEnd = route.start + route.length;
11665
11761
  const inRoute = (index) => index >= route.start && index < routeEnd;
11666
11762
  if (!inRoute(handoff.askingChildIndex)) {
@@ -11680,16 +11776,16 @@ function projectParentAskContent(result2, route, projectedResults) {
11680
11776
  }
11681
11777
  ];
11682
11778
  }
11683
- function projectParallelContent(result2, sharedResults, projectedResults, route, live) {
11779
+ function projectParallelContent(result, sharedResults, projectedResults, route, live) {
11684
11780
  const projectedText = formatStandardParallelContent(projectedResults);
11685
11781
  if (live)
11686
11782
  return [{ type: "text", text: projectedText }];
11687
- const parentAskContent = projectParentAskContent(result2, route, projectedResults);
11783
+ const parentAskContent = projectParentAskContent(result, route, projectedResults);
11688
11784
  if (parentAskContent)
11689
11785
  return parentAskContent;
11690
- if (result2.content.length !== 1 || result2.content[0]?.type !== "text")
11691
- return result2.content;
11692
- const originalItem = result2.content[0];
11786
+ if (result.content.length !== 1 || result.content[0]?.type !== "text")
11787
+ return result.content;
11788
+ const originalItem = result.content[0];
11693
11789
  const originalText = originalItem.text;
11694
11790
  const sharedText = formatStandardParallelContent(sharedResults);
11695
11791
  if (originalText === sharedText)
@@ -11699,13 +11795,13 @@ function projectParallelContent(result2, sharedResults, projectedResults, route,
11699
11795
  `)) {
11700
11796
  return [{ ...originalItem, text: `${projectedText}${originalText.slice(sharedText.length)}` }];
11701
11797
  }
11702
- return result2.content;
11798
+ return result.content;
11703
11799
  }
11704
- function projectResult(result2, route, live = false) {
11705
- const sharedDetails = result2.details;
11800
+ function projectResult(result, route, live = false) {
11801
+ const sharedDetails = result.details;
11706
11802
  if (!sharedDetails || !live && sharedDetails.results.length === 0)
11707
- return result2;
11708
- const liveIndices = live ? getLiveResultIndices(result2) : undefined;
11803
+ return result;
11804
+ const liveIndices = live ? getLiveResultIndices(result) : undefined;
11709
11805
  const results = liveIndices ? sharedDetails.results.filter((_child, index) => {
11710
11806
  const resultIndex = liveIndices[index];
11711
11807
  return resultIndex !== undefined && resultIndex >= route.start && resultIndex < route.start + route.length;
@@ -11714,8 +11810,8 @@ function projectResult(result2, route, live = false) {
11714
11810
  const controlEvents = sharedDetails.controlEvents?.filter((event) => event.index !== undefined && event.index >= route.start && event.index < route.start + route.length).map((event) => ({ ...event, index: event.index - route.start }));
11715
11811
  const artifactFiles = results.flatMap((child) => child.artifactPaths ? [child.artifactPaths] : []);
11716
11812
  return {
11717
- content: projectParallelContent(result2, sharedDetails.results, results, route, live),
11718
- ...result2.isError !== undefined ? { isError: result2.isError } : {},
11813
+ content: projectParallelContent(result, sharedDetails.results, results, route, live),
11814
+ ...result.isError !== undefined ? { isError: result.isError } : {},
11719
11815
  details: {
11720
11816
  mode: "parallel",
11721
11817
  ...sharedDetails.runId !== undefined ? { runId: sharedDetails.runId } : {},
@@ -11729,11 +11825,11 @@ function projectResult(result2, route, live = false) {
11729
11825
  }
11730
11826
  };
11731
11827
  }
11732
- function resolveItem(item, result2) {
11828
+ function resolveItem(item, result) {
11733
11829
  if (item.settled)
11734
11830
  return;
11735
11831
  item.settled = true;
11736
- item.resolve(result2);
11832
+ item.resolve(result);
11737
11833
  }
11738
11834
  function rejectItem(item, reason) {
11739
11835
  if (item.settled)
@@ -11804,10 +11900,10 @@ function createExecutionBurstDispatcher(input) {
11804
11900
  };
11805
11901
  input.setActive(true);
11806
11902
  try {
11807
- const result2 = await input.execute(first.id, merged.params, first.signal, onUpdate, first.ctx);
11808
- updateBurstDisplay(display, result2);
11903
+ const result = await input.execute(first.id, merged.params, first.signal, onUpdate, first.ctx);
11904
+ updateBurstDisplay(display, result);
11809
11905
  for (let index = 0;index < items.length; index++) {
11810
- resolveItem(items[index], projectResult(result2, merged.routes[index]));
11906
+ resolveItem(items[index], projectResult(result, merged.routes[index]));
11811
11907
  }
11812
11908
  } catch (error) {
11813
11909
  const rejection = error instanceof Error ? error : new Error(String(error));
@@ -11827,8 +11923,8 @@ function createExecutionBurstDispatcher(input) {
11827
11923
  return (id, params, signal, onUpdate, ctx) => {
11828
11924
  if (input.isActive())
11829
11925
  return Promise.resolve(input.duplicateResult(params));
11830
- return new Promise((resolve8, reject) => {
11831
- queue.push({ id, params, signal, onUpdate, ctx, settled: false, resolve: resolve8, reject });
11926
+ return new Promise((resolve, reject) => {
11927
+ queue.push({ id, params, signal, onUpdate, ctx, settled: false, resolve, reject });
11832
11928
  if (!flushScheduled) {
11833
11929
  flushScheduled = true;
11834
11930
  setImmediate(flush);
@@ -11838,7 +11934,7 @@ function createExecutionBurstDispatcher(input) {
11838
11934
  }
11839
11935
 
11840
11936
  // dist/builtin/subagents/src/runs/foreground/subagent-executor-context.ts
11841
- import { randomUUID } from "node:crypto";
11937
+ import { randomUUID as randomUUID2 } from "node:crypto";
11842
11938
  import * as fs13 from "node:fs";
11843
11939
  import * as path13 from "node:path";
11844
11940
 
@@ -12081,13 +12177,13 @@ function normalizeRepeatedParallelCounts(params) {
12081
12177
  return { error: buildRequestedModeError(params, expandedTasks.error) };
12082
12178
  return { params: { ...params, tasks: expandedTasks.tasks } };
12083
12179
  }
12084
- function withForkContext(result2, context) {
12085
- if (context !== "fork" || !result2.details)
12086
- return result2;
12180
+ function withForkContext(result, context) {
12181
+ if (context !== "fork" || !result.details)
12182
+ return result;
12087
12183
  return {
12088
- ...result2,
12184
+ ...result,
12089
12185
  details: {
12090
- ...result2.details,
12186
+ ...result.details,
12091
12187
  context: "fork"
12092
12188
  }
12093
12189
  };
@@ -12166,7 +12262,7 @@ function prepareExecutionContext(input) {
12166
12262
  });
12167
12263
  const agents = intercomBridge.active ? discoveredAgents.map((agent) => applyIntercomBridgeToAgent(agent, intercomBridge)) : discoveredAgents;
12168
12264
  const parallelAgentConfigs = intercomBridge.active ? resolvedTaskAgents?.map((agent) => applyIntercomBridgeToAgent(agent, intercomBridge)) : resolvedTaskAgents;
12169
- const runId = randomUUID().slice(0, 8);
12265
+ const runId = randomUUID2().slice(0, 8);
12170
12266
  const shareEnabled = effectiveParams.share === true;
12171
12267
  const hasTasks = (effectiveParams.tasks?.length ?? 0) > 0;
12172
12268
  const hasSingle = !hasTasks && Boolean(effectiveParams.agent);
@@ -12272,10 +12368,10 @@ function resolveCandidateModel(candidateId, lookup, preferredProvider) {
12272
12368
  const slash = baseModel.indexOf("/");
12273
12369
  if (slash < 0) {
12274
12370
  const available = lookup.getAvailable().filter((entry) => entry.id === baseModel);
12275
- const model2 = available.find((entry) => entry.provider === preferredProvider) ?? (available.length === 1 ? available[0] : undefined);
12276
- if (!model2)
12371
+ const model = available.find((entry) => entry.provider === preferredProvider) ?? (available.length === 1 ? available[0] : undefined);
12372
+ if (!model)
12277
12373
  return;
12278
- return thinkingLevel === undefined ? { model: model2 } : { model: model2, thinkingLevel };
12374
+ return thinkingLevel === undefined ? { model } : { model, thinkingLevel };
12279
12375
  }
12280
12376
  const provider = baseModel.slice(0, slash);
12281
12377
  const modelId = baseModel.slice(slash + 1);
@@ -12289,7 +12385,7 @@ function createCandidateModelResolver(lookup, preferredProvider) {
12289
12385
  }
12290
12386
 
12291
12387
  // dist/builtin/subagents/src/runs/shared/intercom-group.ts
12292
- import { randomUUID as randomUUID2 } from "node:crypto";
12388
+ import { randomUUID as randomUUID3 } from "node:crypto";
12293
12389
  import { readRuntimeIntercomGroup } from "@bastani/atomic";
12294
12390
  function normalizeAutoGroupSentinel(group) {
12295
12391
  if (group === undefined || group === true)
@@ -12313,14 +12409,14 @@ function inheritedIntercomGroup(ctx) {
12313
12409
  function resolveChildIntercomGroup(explicit, inherited, sharedAutoGroup) {
12314
12410
  const normalized = normalizeAutoGroupSentinel(explicit);
12315
12411
  if (normalized === true)
12316
- return sharedAutoGroup ?? randomUUID2();
12412
+ return sharedAutoGroup ?? randomUUID3();
12317
12413
  if (typeof normalized === "string" && normalized.trim().length > 0)
12318
12414
  return normalized.trim();
12319
12415
  return inherited;
12320
12416
  }
12321
12417
  function sharedAutoGroupForSet(setGroup, items) {
12322
12418
  const needsAuto = normalizeAutoGroupSentinel(setGroup) === true || items.some((item) => normalizeAutoGroupSentinel(item.group) === true);
12323
- return needsAuto ? randomUUID2() : undefined;
12419
+ return needsAuto ? randomUUID3() : undefined;
12324
12420
  }
12325
12421
 
12326
12422
  // dist/builtin/subagents/src/runs/shared/model-fallback.ts
@@ -12499,8 +12595,8 @@ function hasTrackedPathComponent(runGit, repo, relativePath) {
12499
12595
  let candidate = "";
12500
12596
  for (const component of components) {
12501
12597
  candidate = candidate ? `${candidate}/${component}` : component;
12502
- const result2 = runGit(repo, ["ls-files", "--stage", "--", candidate]);
12503
- if (result2.stdout.split(/\r?\n/).some((line) => line.slice(line.indexOf("\t") + 1) === candidate))
12598
+ const result = runGit(repo, ["ls-files", "--stage", "--", candidate]);
12599
+ if (result.stdout.split(/\r?\n/).some((line) => line.slice(line.indexOf("\t") + 1) === candidate))
12504
12600
  return true;
12505
12601
  }
12506
12602
  return false;
@@ -12533,9 +12629,9 @@ function configureHooks(runGit, mainRoot) {
12533
12629
  const current = runGit(mainRoot, ["config", "--get", "core.hooksPath"]);
12534
12630
  if (current.status === 0 && path16.resolve(mainRoot, current.stdout.trim()) === desired)
12535
12631
  return;
12536
- const result2 = runGit(mainRoot, ["config", "core.hooksPath", desired]);
12537
- if (result2.status !== 0)
12538
- throw new Error(result2.stderr.trim() || "failed to configure shared core.hooksPath");
12632
+ const result = runGit(mainRoot, ["config", "core.hooksPath", desired]);
12633
+ if (result.status !== 0)
12634
+ throw new Error(result.stderr.trim() || "failed to configure shared core.hooksPath");
12539
12635
  }
12540
12636
  function copyIncludes(runGit, mainRoot, worktreeRoot) {
12541
12637
  if (!fs15.existsSync(path16.join(mainRoot, ".worktreeinclude")))
@@ -12659,24 +12755,24 @@ function findCanonicalGitRoot(cwd) {
12659
12755
  // dist/builtin/subagents/src/runs/shared/worktree.ts
12660
12756
  var DEFAULT_WORKTREE_SETUP_HOOK_TIMEOUT_MS = 30000;
12661
12757
  function runGit(cwd, args) {
12662
- const result2 = spawnSync("git", ["-C", cwd, ...args], {
12758
+ const result = spawnSync("git", ["-C", cwd, ...args], {
12663
12759
  encoding: "utf-8",
12664
12760
  env: createGitEnvironment({}, createChildProcessEnvironment3())
12665
12761
  });
12666
12762
  return {
12667
- stdout: result2.stdout ?? "",
12668
- stderr: result2.stderr ?? "",
12669
- status: result2.status
12763
+ stdout: result.stdout ?? "",
12764
+ stderr: result.stderr ?? "",
12765
+ status: result.status
12670
12766
  };
12671
12767
  }
12672
12768
  function runGitChecked(cwd, args) {
12673
- const result2 = runGit(cwd, args);
12674
- if (result2.status !== 0) {
12769
+ const result = runGit(cwd, args);
12770
+ if (result.status !== 0) {
12675
12771
  const command = `git -C ${cwd} ${args.join(" ")}`;
12676
- const message = result2.stderr.trim() || result2.stdout.trim() || `${command} failed`;
12772
+ const message = result.stderr.trim() || result.stdout.trim() || `${command} failed`;
12677
12773
  throw new Error(message);
12678
12774
  }
12679
- return result2.stdout;
12775
+ return result.stdout;
12680
12776
  }
12681
12777
  function originDefaultBranch(mainRoot) {
12682
12778
  const symbolic = runGit(mainRoot, ["symbolic-ref", "--short", "refs/remotes/origin/HEAD"]);
@@ -12798,18 +12894,18 @@ function normalizeSyntheticPath(worktreePath, rawPath) {
12798
12894
  if (path18.isAbsolute(trimmed))
12799
12895
  throw new Error(`synthetic path must be relative: ${rawPath}`);
12800
12896
  const resolved = path18.resolve(worktreePath, trimmed);
12801
- const relative4 = path18.relative(worktreePath, resolved);
12802
- if (!relative4 || relative4 === ".") {
12897
+ const relative = path18.relative(worktreePath, resolved);
12898
+ if (!relative || relative === ".") {
12803
12899
  throw new Error(`synthetic path cannot target the worktree root: ${rawPath}`);
12804
12900
  }
12805
- if (relative4 === ".." || relative4.startsWith(`..${path18.sep}`) || path18.isAbsolute(relative4)) {
12901
+ if (relative === ".." || relative.startsWith(`..${path18.sep}`) || path18.isAbsolute(relative)) {
12806
12902
  throw new Error(`synthetic path escapes the worktree root: ${rawPath}`);
12807
12903
  }
12808
- return path18.normalize(relative4);
12904
+ return path18.normalize(relative);
12809
12905
  }
12810
12906
  function hasTrackedEntries(worktreePath, relativePath) {
12811
- const result2 = runGit(worktreePath, ["ls-files", "--", relativePath]);
12812
- return result2.status === 0 && result2.stdout.trim().length > 0;
12907
+ const result = runGit(worktreePath, ["ls-files", "--", relativePath]);
12908
+ return result.status === 0 && result.stdout.trim().length > 0;
12813
12909
  }
12814
12910
  function parseWorktreeSetupHookOutput(rawStdout) {
12815
12911
  const trimmed = rawStdout.trim();
@@ -12832,7 +12928,7 @@ function isSpuriousHookStdinWriteFailure(code, status) {
12832
12928
  return code === "EPIPE" && status !== null;
12833
12929
  }
12834
12930
  function runWorktreeSetupHook(hook, input) {
12835
- const result2 = spawnSync(hook.hookPath, [], {
12931
+ const result = spawnSync(hook.hookPath, [], {
12836
12932
  cwd: input.worktreePath,
12837
12933
  encoding: "utf-8",
12838
12934
  input: JSON.stringify(input),
@@ -12840,20 +12936,20 @@ function runWorktreeSetupHook(hook, input) {
12840
12936
  timeout: hook.timeoutMs,
12841
12937
  shell: false
12842
12938
  });
12843
- if (result2.error) {
12844
- const code = "code" in result2.error && typeof result2.error.code === "string" ? result2.error.code : undefined;
12939
+ if (result.error) {
12940
+ const code = "code" in result.error && typeof result.error.code === "string" ? result.error.code : undefined;
12845
12941
  if (code === "ETIMEDOUT") {
12846
12942
  throw new Error(`worktree setup hook timed out after ${hook.timeoutMs}ms`);
12847
12943
  }
12848
- if (!isSpuriousHookStdinWriteFailure(code, result2.status)) {
12849
- throw new Error(`worktree setup hook failed: ${result2.error.message}`);
12944
+ if (!isSpuriousHookStdinWriteFailure(code, result.status)) {
12945
+ throw new Error(`worktree setup hook failed: ${result.error.message}`);
12850
12946
  }
12851
12947
  }
12852
- if (result2.status !== 0) {
12853
- const details = result2.stderr.trim() || result2.stdout.trim() || "no output";
12854
- throw new Error(`worktree setup hook failed with exit code ${result2.status}: ${details}`);
12948
+ if (result.status !== 0) {
12949
+ const details = result.stderr.trim() || result.stdout.trim() || "no output";
12950
+ throw new Error(`worktree setup hook failed with exit code ${result.status}: ${details}`);
12855
12951
  }
12856
- const output = parseWorktreeSetupHookOutput(result2.stdout);
12952
+ const output = parseWorktreeSetupHookOutput(result.stdout);
12857
12953
  if (output.syntheticPaths === undefined)
12858
12954
  return [];
12859
12955
  if (!Array.isArray(output.syntheticPaths)) {
@@ -12924,8 +13020,8 @@ function createSingleWorktree(mainRoot, cwdRelative, runId, index, baseRef, base
12924
13020
  }
12925
13021
  function removeSyntheticPath(worktree, syntheticPath) {
12926
13022
  const resolved = path18.resolve(worktree.path, syntheticPath);
12927
- const relative4 = path18.relative(worktree.path, resolved);
12928
- if (!relative4 || relative4 === "." || relative4 === ".." || relative4.startsWith(`..${path18.sep}`) || path18.isAbsolute(relative4)) {
13023
+ const relative = path18.relative(worktree.path, resolved);
13024
+ if (!relative || relative === "." || relative === ".." || relative.startsWith(`..${path18.sep}`) || path18.isAbsolute(relative)) {
12929
13025
  return;
12930
13026
  }
12931
13027
  let stat;
@@ -13187,29 +13283,205 @@ function findDuplicateParallelOutputPath(input) {
13187
13283
  return;
13188
13284
  }
13189
13285
 
13190
- // dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel-task.ts
13191
- function skippedParallelResult(task, taskText, error) {
13286
+ // dist/builtin/subagents/src/runs/foreground/task-execution.ts
13287
+ function taskToolResult(response, host) {
13192
13288
  return {
13193
- agent: task.agent,
13194
- task: taskText,
13195
- status: "skipped",
13196
- messages: [],
13197
- usage: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, cost: 0, turns: 0 },
13198
- error
13289
+ content: [{ type: "text", text: JSON.stringify(response) }],
13290
+ details: {
13291
+ mode: "single",
13292
+ results: [],
13293
+ taskResponse: response,
13294
+ taskRecords: taskResponseRecords(response, host)
13295
+ },
13296
+ ...response.kind === "unstarted" ? { isError: true } : {}
13297
+ };
13298
+ }
13299
+ function taskResponseRecords(response, host) {
13300
+ const outcomes = response.kind === "parallel" ? response.slots.map((slot) => slot.outcome) : [response];
13301
+ const ids = new Set(outcomes.flatMap((outcome) => outcome.kind === "admitted" ? [outcome.observation.taskId] : []));
13302
+ const watched = host?.watchOwnerTasks();
13303
+ if (!watched?.ok)
13304
+ return [];
13305
+ try {
13306
+ return watched.value.snapshot.tasks.filter((task) => ids.has(task.ref.taskId));
13307
+ } finally {
13308
+ watched.value.dispose();
13309
+ }
13310
+ }
13311
+ async function runAgentTask(input) {
13312
+ let yieldWait;
13313
+ let pendingYield = false;
13314
+ const registered = Promise.withResolvers();
13315
+ const started = await input.host.startAgentTask({ kind: "agent", agent: input.agent, task: input.intentTask ?? input.task, cwd: input.options.cwd ?? input.cwd }, `${input.options.runId}:${input.options.index ?? 0}`, (context) => {
13316
+ const cleaned = Promise.withResolvers();
13317
+ let executionBound = false;
13318
+ const result = registered.promise.then(async () => {
13319
+ try {
13320
+ const child = await input.runtime.runSync(input.cwd, input.agents, input.agent, input.task, {
13321
+ ...input.options,
13322
+ signal: context.signal,
13323
+ taskExecution: {
13324
+ signal: context.signal,
13325
+ reportActivity: context.reportActivity,
13326
+ bindTranscript: (session) => context.bindTranscript({
13327
+ getSessionId: () => session.getSessionId(),
13328
+ getEntries: () => session.getEntries(),
13329
+ ...session.subscribe ? { subscribe: session.subscribe.bind(session) } : {},
13330
+ ...session.getStreamingMessage ? { getStreamingMessage: session.getStreamingMessage.bind(session) } : {},
13331
+ ...input.options.intercomSessionName ? {
13332
+ completionSource: {
13333
+ runId: input.options.runId,
13334
+ intercomTarget: input.options.intercomSessionName
13335
+ }
13336
+ } : {}
13337
+ }),
13338
+ onExecution: (execution) => {
13339
+ executionBound = true;
13340
+ execution.cleanup.then(cleaned.resolve, (error) => cleaned.resolve({
13341
+ kind: "failed",
13342
+ resources: [{ resource: "agent-session", code: "CleanupFailed", message: String(error) }]
13343
+ }));
13344
+ },
13345
+ yieldTaskWait: () => {
13346
+ if (yieldWait)
13347
+ yieldWait("intercom-coordination");
13348
+ else
13349
+ pendingYield = true;
13350
+ }
13351
+ }
13352
+ });
13353
+ if (child.model !== undefined || child.thinking !== undefined)
13354
+ context.reportActivity({
13355
+ reportId: "terminal-model",
13356
+ change: { kind: "model", model: child.model, thinking: child.thinking }
13357
+ });
13358
+ input.onTerminal?.(child);
13359
+ const text = input.outputText?.(child) ?? getSingleResultOutput(child);
13360
+ const bytes = Buffer.from(text);
13361
+ context.reportActivity({
13362
+ reportId: "terminal-output",
13363
+ change: { kind: "output", offset: "0", bytesBase64: bytes.toString("base64") }
13364
+ });
13365
+ const output = {
13366
+ ownerId: context.ref.ownerId,
13367
+ taskId: context.ref.taskId,
13368
+ artifactId: `output:${context.ref.taskId}`,
13369
+ byteCount: String(bytes.length),
13370
+ omittedRanges: []
13371
+ };
13372
+ if (child.interrupted)
13373
+ return {
13374
+ kind: "cancelled",
13375
+ cause: input.options.interruptSignal?.aborted ? "parent-handoff" : "owner-close",
13376
+ output
13377
+ };
13378
+ return child.status === "ok" ? { kind: "completed", output } : {
13379
+ kind: "failed",
13380
+ code: "AgentFailed",
13381
+ message: child.error ?? child.envelope ?? "Agent failed",
13382
+ output
13383
+ };
13384
+ } finally {
13385
+ if (!executionBound)
13386
+ cleaned.resolve({ kind: "reaped" });
13387
+ }
13388
+ });
13389
+ return { result, cleanup: cleaned.promise };
13390
+ }, input.schedule);
13391
+ if (!started.ok)
13392
+ return { kind: "unstarted", reason: { kind: "rejected", error: started.error } };
13393
+ const yieldForIntercom = () => {
13394
+ if (yieldWait)
13395
+ yieldWait("intercom-coordination");
13396
+ else
13397
+ pendingYield = true;
13199
13398
  };
13399
+ input.options.intercomDetachSignal?.addEventListener("abort", yieldForIntercom, { once: true });
13400
+ if (input.options.intercomDetachSignal?.aborted)
13401
+ yieldForIntercom();
13402
+ const observation = input.host.observeAgentLaunch(started.value.taskId, input.wait, (yieldRegistered) => {
13403
+ yieldWait = yieldRegistered;
13404
+ if (pendingYield)
13405
+ yieldRegistered("intercom-coordination");
13406
+ registered.resolve();
13407
+ });
13408
+ registered.resolve();
13409
+ const observed = await observation.finally(() => input.options.intercomDetachSignal?.removeEventListener("abort", yieldForIntercom));
13410
+ if (!observed.ok)
13411
+ throw new Error(`${observed.error.code}: ${observed.error.message}`);
13412
+ return { kind: "admitted", observation: observed.value };
13413
+ }
13414
+
13415
+ // dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel-task.ts
13416
+ function runUnboundParallelTask(options, agent, task, schedule, run) {
13417
+ const observed = Promise.withResolvers();
13418
+ const finished = Promise.withResolvers();
13419
+ let started = false;
13420
+ let yielded = false;
13421
+ const yieldQueued = () => {
13422
+ if (started)
13423
+ return;
13424
+ yielded = true;
13425
+ observed.resolve({
13426
+ agent,
13427
+ task,
13428
+ status: "continued",
13429
+ detached: true,
13430
+ detachedReason: "intercom-coordination",
13431
+ messages: [],
13432
+ usage: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, cost: 0, turns: 0 }
13433
+ });
13434
+ };
13435
+ options.intercomDetachSignal?.addEventListener("abort", yieldQueued, { once: true });
13436
+ schedule(async () => {
13437
+ started = true;
13438
+ try {
13439
+ const result = await run({
13440
+ ...options,
13441
+ onDetachedExit: (result) => {
13442
+ try {
13443
+ options.onDetachedExit?.(result);
13444
+ } finally {
13445
+ finished.resolve();
13446
+ }
13447
+ }
13448
+ });
13449
+ observed.resolve(result);
13450
+ if (!result.detached) {
13451
+ finished.resolve();
13452
+ if (yielded)
13453
+ options.onDetachedExit?.(result);
13454
+ }
13455
+ await finished.promise;
13456
+ } catch (error) {
13457
+ observed.reject(error);
13458
+ }
13459
+ });
13460
+ if (options.intercomDetachSignal?.aborted)
13461
+ yieldQueued();
13462
+ return observed.promise.finally(() => options.intercomDetachSignal?.removeEventListener("abort", yieldQueued));
13200
13463
  }
13201
13464
  async function runForegroundParallelTasks(input) {
13202
13465
  const intercomDetachController = new AbortController;
13203
- const parentAskController = new AbortController;
13204
- const startedIndices = new Set;
13205
- const activeIndices = new Set;
13206
- return mapConcurrent(input.tasks, input.concurrencyLimit, async (task, index) => {
13207
- if (parentAskController.signal.aborted) {
13208
- return skippedParallelResult(task, input.taskTexts[index] ?? task.task, "Skipped after parent ask handoff");
13209
- }
13210
- if (intercomDetachController.signal.aborted) {
13211
- return skippedParallelResult(task, input.taskTexts[index] ?? task.task, "Skipped after foreground group detached for intercom coordination");
13466
+ const host = input.ctx.getAgentTaskHost?.();
13467
+ let active = 0;
13468
+ const queued = [];
13469
+ const pump = () => {
13470
+ while (active < input.concurrencyLimit && queued.length > 0) {
13471
+ const dispatch = queued.shift();
13472
+ active++;
13473
+ const release = () => {
13474
+ active--;
13475
+ pump();
13476
+ };
13477
+ dispatch().then(release, release);
13212
13478
  }
13479
+ };
13480
+ const schedule = (dispatch) => {
13481
+ queued.push(dispatch);
13482
+ pump();
13483
+ };
13484
+ return mapConcurrent(input.tasks, input.tasks.length, async (task, index) => {
13213
13485
  const behavior = input.behaviors[index];
13214
13486
  const effectiveSkills = behavior?.skills;
13215
13487
  const taskCwd = resolveParallelTaskCwd(task, input.paramsCwd, input.worktreeSetup, index);
@@ -13219,19 +13491,7 @@ async function runForegroundParallelTasks(input) {
13219
13491
  const taskText = injectSingleOutputInstruction(`${readInstructions.prefix}${input.taskTexts[index]}${progressInstructions.suffix}`, outputPath);
13220
13492
  const childIntercomTarget = input.childIntercomTarget?.(task.agent, index);
13221
13493
  const supervisorAuthorization = await requestSupervisorAuthorization(input.intercomEvents, childIntercomTarget);
13222
- if (parentAskController.signal.aborted) {
13223
- return skippedParallelResult(task, input.taskTexts[index] ?? task.task, "Skipped after parent ask handoff");
13224
- }
13225
- if (intercomDetachController.signal.aborted) {
13226
- return skippedParallelResult(task, input.taskTexts[index] ?? task.task, "Skipped after foreground group detached for intercom coordination");
13227
- }
13228
13494
  const interruptController = new AbortController;
13229
- const interruptForParentAsk = () => interruptController.abort();
13230
- parentAskController.signal.addEventListener("abort", interruptForParentAsk, { once: true });
13231
- if (parentAskController.signal.aborted)
13232
- interruptController.abort();
13233
- startedIndices.add(index);
13234
- activeIndices.add(index);
13235
13495
  if (input.foregroundControl) {
13236
13496
  input.foregroundControl.currentAgent = task.agent;
13237
13497
  input.foregroundControl.currentIndex = index;
@@ -13275,21 +13535,9 @@ async function runForegroundParallelTasks(input) {
13275
13535
  supervisorAuthorization,
13276
13536
  orchestratorIntercomTarget: input.orchestratorIntercomTarget,
13277
13537
  intercomGroup: resolveChildIntercomGroup(task.group ?? input.setIntercomGroup, inheritedIntercomGroup(input.ctx), input.sharedAutoIntercomGroup),
13278
- onDetachedExit: (result2) => input.onDetachedExit?.(index, result2),
13538
+ onDetachedExit: (result) => input.onDetachedExit?.(index, result),
13279
13539
  intercomDetachSignal: intercomDetachController.signal,
13280
13540
  onIntercomDetachCommit: () => intercomDetachController.abort(),
13281
- onParentAskHandoff: input.onParentAskHandoff ? (request) => {
13282
- if (parentAskController.signal.aborted)
13283
- return;
13284
- request.taskContext = input.tasks[request.index]?.task ?? "";
13285
- input.onParentAskHandoff?.({
13286
- askingChildIndex: request.index,
13287
- releasedChildIndices: [...activeIndices].sort((left, right) => left - right),
13288
- unlaunchedChildIndices: input.tasks.map((_, taskIndex) => taskIndex).filter((taskIndex) => !startedIndices.has(taskIndex)),
13289
- request
13290
- });
13291
- parentAskController.abort();
13292
- } : undefined,
13293
13541
  modelOverride: input.modelOverrides[index],
13294
13542
  availableModels: input.availableModels,
13295
13543
  knownModelProviders: input.knownModelProviders,
@@ -13319,12 +13567,12 @@ async function runForegroundParallelTasks(input) {
13319
13567
  input.liveResults[index] = stepResults[0];
13320
13568
  if (stepProgress.length > 0)
13321
13569
  input.liveProgress[index] = stepProgress[0];
13322
- const indexedResults = input.liveResults.flatMap((result2, resultIndex) => result2 === undefined ? [] : [{ result: result2, index: resultIndex }]);
13323
- const mergedResults = indexedResults.map(({ result: result2 }) => result2);
13570
+ const indexedResults = input.liveResults.flatMap((result, resultIndex) => result === undefined ? [] : [{ result, index: resultIndex }]);
13571
+ const mergedResults = indexedResults.map(({ result }) => result);
13324
13572
  const mergedProgress = input.liveProgress.filter((progress) => progress !== undefined);
13325
13573
  const controlEvents = progressUpdate.details?.controlEvents?.map((event) => ({ ...event, index }));
13326
13574
  const artifactDir = progressUpdate.details?.artifacts?.dir;
13327
- const artifactFiles = mergedResults.flatMap((result2) => result2.artifactPaths ? [result2.artifactPaths] : []);
13575
+ const artifactFiles = mergedResults.flatMap((result) => result.artifactPaths ? [result.artifactPaths] : []);
13328
13576
  const aggregateUpdate = {
13329
13577
  content: progressUpdate.content,
13330
13578
  details: {
@@ -13341,9 +13589,39 @@ async function runForegroundParallelTasks(input) {
13341
13589
  } : undefined
13342
13590
  };
13343
13591
  input.onExecution?.(index, input.ctx.cwd, runOptions);
13344
- return input.runtime.runSync(input.ctx.cwd, taskAgents, task.agent, taskText, runOptions).finally(() => {
13345
- activeIndices.delete(index);
13346
- parentAskController.signal.removeEventListener("abort", interruptForParentAsk);
13592
+ if (host) {
13593
+ if (input.wait?.kind !== "foreground") {
13594
+ runOptions.intercomDetachSignal = undefined;
13595
+ runOptions.onIntercomDetachCommit = undefined;
13596
+ }
13597
+ let terminalChild;
13598
+ const response = await runAgentTask({
13599
+ host,
13600
+ cwd: input.ctx.cwd,
13601
+ agents: taskAgents,
13602
+ agent: task.agent,
13603
+ task: taskText,
13604
+ intentTask: task.task,
13605
+ options: runOptions,
13606
+ wait: input.wait,
13607
+ runtime: input.runtime,
13608
+ schedule: (dispatch) => schedule(() => dispatch().finally(() => input.onTaskTerminal?.(index))),
13609
+ onTerminal: (child) => {
13610
+ terminalChild = child;
13611
+ }
13612
+ });
13613
+ if (terminalChild)
13614
+ return { ...terminalChild, taskResponse: response };
13615
+ return {
13616
+ agent: task.agent,
13617
+ task: task.task,
13618
+ status: "continued",
13619
+ messages: [],
13620
+ usage: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, cost: 0, turns: 0 },
13621
+ taskResponse: response
13622
+ };
13623
+ }
13624
+ return runUnboundParallelTask(runOptions, task.agent, taskText, schedule, (options) => input.runtime.runSync(input.ctx.cwd, taskAgents, task.agent, taskText, options)).finally(() => {
13347
13625
  if (input.foregroundControl?.currentIndex === index) {
13348
13626
  input.foregroundControl.interrupt = undefined;
13349
13627
  input.foregroundControl.updatedAt = Date.now();
@@ -13356,7 +13634,7 @@ async function runForegroundParallelTasks(input) {
13356
13634
  import { isStaleExtensionContextError as isStaleExtensionContextError4 } from "@bastani/atomic";
13357
13635
 
13358
13636
  // dist/builtin/subagents/src/intercom/result-intercom.ts
13359
- import { randomUUID as randomUUID3 } from "node:crypto";
13637
+ import { randomUUID as randomUUID4 } from "node:crypto";
13360
13638
  import { isStaleExtensionContextError as isStaleExtensionContextError3 } from "@bastani/atomic";
13361
13639
  function resolveSubagentResultStatus(input) {
13362
13640
  if (input.detached || input.status === "continued")
@@ -13491,8 +13769,8 @@ async function deliverSubagentResultIntercomEvent(events, payload, timeoutMs = 5
13491
13769
  async function deliverSubagentIntercomMessageEvent(events, to, message, timeoutMs = 500, extra = {}) {
13492
13770
  if (typeof events.on !== "function" || typeof events.emit !== "function")
13493
13771
  return false;
13494
- const requestId = typeof extra.requestId === "string" ? extra.requestId : randomUUID3();
13495
- return new Promise((resolve14) => {
13772
+ const requestId = typeof extra.requestId === "string" ? extra.requestId : randomUUID4();
13773
+ return new Promise((resolve) => {
13496
13774
  let settled = false;
13497
13775
  let unsubscribe;
13498
13776
  let timer;
@@ -13508,7 +13786,7 @@ async function deliverSubagentIntercomMessageEvent(events, to, message, timeoutM
13508
13786
  if (!isStaleExtensionContextError3(error))
13509
13787
  throw error;
13510
13788
  }
13511
- resolve14(delivered);
13789
+ resolve(delivered);
13512
13790
  };
13513
13791
  try {
13514
13792
  unsubscribe = events.on(SUBAGENT_RESULT_INTERCOM_DELIVERY_EVENT, (data) => {
@@ -13534,9 +13812,9 @@ async function deliverSubagentIntercomMessageEvent(events, to, message, timeoutM
13534
13812
  }
13535
13813
  });
13536
13814
  }
13537
- function stripSingleResultOutputs(result2) {
13815
+ function stripSingleResultOutputs(result) {
13538
13816
  return {
13539
- ...result2,
13817
+ ...result,
13540
13818
  messages: undefined,
13541
13819
  finalOutput: undefined,
13542
13820
  truncation: undefined
@@ -13583,14 +13861,14 @@ function formatSubagentResultReceipt(input) {
13583
13861
 
13584
13862
  // dist/builtin/subagents/src/runs/foreground/completion-notification.ts
13585
13863
  function deliverLocalCompletionNotification(events, payload, notificationId) {
13586
- return new Promise((resolve14, reject) => {
13864
+ return new Promise((resolve, reject) => {
13587
13865
  let settled = false;
13588
13866
  let deferred = false;
13589
13867
  const finish = (delivered) => {
13590
13868
  if (settled)
13591
13869
  return;
13592
13870
  settled = true;
13593
- resolve14(delivered);
13871
+ resolve(delivered);
13594
13872
  };
13595
13873
  const fail = (error) => {
13596
13874
  if (settled)
@@ -13713,28 +13991,28 @@ function createForegroundControlNotifier(data, deps) {
13713
13991
  function workflowStageAcceptsDetachedNotification(ctx) {
13714
13992
  return ctx.orchestrationContext?.messageAdmission?.isOpen() !== false;
13715
13993
  }
13716
- function resultSummaryForIntercom(result2) {
13717
- const output = getSingleResultOutput(result2);
13718
- if (result2.status === "error" && result2.error) {
13719
- return output ? `${result2.error}
13994
+ function resultSummaryForIntercom(result) {
13995
+ const output = getSingleResultOutput(result);
13996
+ if (result.status === "error" && result.error) {
13997
+ return output ? `${result.error}
13720
13998
 
13721
13999
  Output:
13722
- ${output}` : result2.error;
14000
+ ${output}` : result.error;
13723
14001
  }
13724
- return output || result2.error || "(no output)";
14002
+ return output || result.error || "(no output)";
13725
14003
  }
13726
14004
  function notifyDetachedForegroundChildExit(input) {
13727
- const { pi, runId, index, result: result2 } = input;
14005
+ const { pi, runId, index, result } = input;
13728
14006
  deliverLocalCompletionNotification(pi.events, {
13729
14007
  id: runId,
13730
14008
  runId,
13731
- agent: result2.agent,
13732
- status: result2.status,
13733
- summary: resultSummaryForIntercom(result2),
13734
- ...result2.interrupted ? { state: "interrupted" } : {},
14009
+ agent: result.agent,
14010
+ status: result.status,
14011
+ summary: resultSummaryForIntercom(result),
14012
+ ...result.interrupted ? { state: "interrupted" } : {},
13735
14013
  timestamp: Date.now(),
13736
- ...result2.progressSummary?.durationMs !== undefined ? { durationMs: result2.progressSummary.durationMs } : {},
13737
- ...result2.sessionFile ? { sessionFile: result2.sessionFile } : {},
14014
+ ...result.progressSummary?.durationMs !== undefined ? { durationMs: result.progressSummary.durationMs } : {},
14015
+ ...result.sessionFile ? { sessionFile: result.sessionFile } : {},
13738
14016
  ...input.totalTasks !== undefined && input.totalTasks > 1 ? { taskIndex: index, totalTasks: input.totalTasks } : {},
13739
14017
  noticeLabel: "Detached subagent task"
13740
14018
  }, `foreground-detach-${runId}-${index}`).catch((error) => {
@@ -13746,20 +14024,20 @@ function notifyDetachedForegroundChildExit(input) {
13746
14024
  async function emitForegroundResultIntercom(input) {
13747
14025
  if (!input.intercomBridge.active || !input.intercomBridge.orchestratorTarget)
13748
14026
  return null;
13749
- const children = input.results.flatMap((result2, index) => result2.detached ? [] : [
14027
+ const children = input.results.flatMap((result, index) => result.detached ? [] : [
13750
14028
  {
13751
- agent: result2.agent,
14029
+ agent: result.agent,
13752
14030
  status: resolveSubagentResultStatus({
13753
- status: result2.status,
13754
- interrupted: result2.interrupted,
13755
- detached: result2.detached
14031
+ status: result.status,
14032
+ interrupted: result.interrupted,
14033
+ detached: result.detached
13756
14034
  }),
13757
- summary: resultSummaryForIntercom(result2),
14035
+ summary: resultSummaryForIntercom(result),
13758
14036
  index,
13759
- ...result2.cause ? { cause: result2.cause } : {},
13760
- artifactPath: result2.artifactPaths?.outputPath,
13761
- sessionPath: result2.sessionFile,
13762
- intercomTarget: resolveSubagentIntercomTarget(input.runId, result2.agent, index)
14037
+ ...result.cause ? { cause: result.cause } : {},
14038
+ artifactPath: result.artifactPaths?.outputPath,
14039
+ sessionPath: result.sessionFile,
14040
+ intercomTarget: resolveSubagentIntercomTarget(input.runId, result.agent, index)
13763
14041
  }
13764
14042
  ]);
13765
14043
  if (children.length === 0)
@@ -13870,7 +14148,6 @@ async function runParallelPath(data, deps) {
13870
14148
  });
13871
14149
  if (errorResult)
13872
14150
  return errorResult;
13873
- let parentAsk;
13874
14151
  try {
13875
14152
  const duplicateOutputError = findDuplicateParallelOutputPath({
13876
14153
  tasks,
@@ -13897,7 +14174,9 @@ async function runParallelPath(data, deps) {
13897
14174
  }
13898
14175
  }
13899
14176
  const results = await runForegroundParallelTasks({
13900
- onDetachedExit: (index, result2) => {
14177
+ wait: params.wait,
14178
+ onTaskTerminal: (index) => detachedCleanup.recover(index),
14179
+ onDetachedExit: (index, result) => {
13901
14180
  try {
13902
14181
  if (workflowStageAcceptsDetachedNotification(ctx)) {
13903
14182
  notifyDetachedForegroundChildExit({
@@ -13906,17 +14185,13 @@ async function runParallelPath(data, deps) {
13906
14185
  mode: "parallel",
13907
14186
  index,
13908
14187
  totalTasks: tasks.length,
13909
- result: result2
14188
+ result
13910
14189
  });
13911
14190
  }
13912
14191
  } finally {
13913
14192
  detachedCleanup.recover(index);
13914
14193
  }
13915
14194
  },
13916
- onParentAskHandoff: (handoff) => {
13917
- if (!parentAsk)
13918
- parentAsk = handoff;
13919
- },
13920
14195
  tasks,
13921
14196
  taskTexts,
13922
14197
  agents,
@@ -13954,38 +14229,48 @@ async function runParallelPath(data, deps) {
13954
14229
  worktreeSetup,
13955
14230
  runtime: deps.runtime
13956
14231
  });
14232
+ if (ctx.getAgentTaskHost) {
14233
+ const response = {
14234
+ kind: "parallel",
14235
+ slots: results.map((result, ordinal) => ({
14236
+ ordinal,
14237
+ outcome: result.taskResponse ?? {
14238
+ kind: "unstarted",
14239
+ reason: { kind: "skipped", cause: "parallel-group-detach" }
14240
+ }
14241
+ }))
14242
+ };
14243
+ worktreeCleanupDeferred = detachedCleanup.defer(response.slots.flatMap(({ ordinal, outcome }) => outcome.kind === "admitted" && outcome.observation.kind === "yielded" ? [ordinal] : []));
14244
+ return {
14245
+ content: [{ type: "text", text: JSON.stringify(response) }],
14246
+ details: {
14247
+ mode: "parallel",
14248
+ results: [],
14249
+ taskResponse: response,
14250
+ taskRecords: taskResponseRecords(response, ctx.getAgentTaskHost())
14251
+ }
14252
+ };
14253
+ }
13957
14254
  for (let i = 0;i < results.length; i++) {
13958
14255
  const run = results[i];
13959
14256
  recordRun(run.agent, taskTexts[i], run.status, run.progressSummary?.durationMs ?? 0);
13960
14257
  }
13961
- for (const result2 of results) {
13962
- if (result2.progress)
13963
- allProgress.push(result2.progress);
13964
- if (result2.artifactPaths)
13965
- allArtifactPaths.push(result2.artifactPaths);
14258
+ for (const result of results) {
14259
+ if (result.progress)
14260
+ allProgress.push(result.progress);
14261
+ if (result.artifactPaths)
14262
+ allArtifactPaths.push(result.artifactPaths);
13966
14263
  }
13967
- const interrupted = results.find((result2) => result2.interrupted && !isParentCancellation(result2.cause));
14264
+ const interrupted = results.find((result) => result.interrupted && !isParentCancellation(result.cause));
13968
14265
  const details = compactForegroundDetails({
13969
14266
  mode: "parallel",
13970
14267
  runId,
13971
14268
  results,
13972
- parentAskYielded: parentAsk !== undefined,
14269
+ parentAskYielded: false,
13973
14270
  progress: params.includeProgress ? allProgress : undefined,
13974
14271
  artifacts: allArtifactPaths.length ? { dir: artifactsDir, files: allArtifactPaths } : undefined
13975
14272
  });
13976
- if (parentAsk) {
13977
- const worktreeSuffix2 = buildParallelWorktreeSuffix(worktreeSetup, artifactsDir, tasks);
13978
- const handoffText = formatParentAskHandoffOutput(parentAsk);
13979
- const yieldedResult = {
13980
- content: [{ type: "text", text: worktreeSuffix2 ? `${handoffText}
13981
-
13982
- ${worktreeSuffix2}` : handoffText }],
13983
- details
13984
- };
13985
- markParentAskHandoff(yieldedResult, parentAsk);
13986
- return yieldedResult;
13987
- }
13988
- if (interrupted && !results.some((result2) => isParentCancellation(result2.cause) && (result2.interrupted || result2.status === "interrupted"))) {
14273
+ if (interrupted && !results.some((result) => isParentCancellation(result.cause) && (result.interrupted || result.status === "interrupted"))) {
13989
14274
  return {
13990
14275
  content: [
13991
14276
  {
@@ -13996,15 +14281,15 @@ ${worktreeSuffix2}` : handoffText }],
13996
14281
  details
13997
14282
  };
13998
14283
  }
13999
- const detachedIndex = results.findIndex((result2) => result2.detached);
14284
+ const detachedIndex = results.findIndex((result) => result.detached);
14000
14285
  const detached = detachedIndex >= 0 ? results[detachedIndex] : undefined;
14001
- worktreeCleanupDeferred = detachedCleanup.defer(results.flatMap((result2, index) => result2.detached ? [index] : []));
14286
+ worktreeCleanupDeferred = detachedCleanup.defer(results.flatMap((result, index) => result.detached ? [index] : []));
14002
14287
  if (detached) {
14003
14288
  return {
14004
14289
  content: [
14005
14290
  {
14006
14291
  type: "text",
14007
- text: `Parallel run detached for intercom coordination (${detached.agent}). Reply to the supervisor request first. After the child exits, launch fresh follow-up work if needed.`
14292
+ text: `Parallel observation yielded for intercom coordination (${detached.agent}). The original children continue; reply to any pending ask without relaunching them.`
14008
14293
  }
14009
14294
  ],
14010
14295
  details
@@ -14024,12 +14309,12 @@ ${worktreeSuffix2}` : handoffText }],
14024
14309
  };
14025
14310
  }
14026
14311
  const worktreeSuffix = buildParallelWorktreeSuffix(worktreeSetup, artifactsDir, tasks);
14027
- const childContent = formatParallelResultContent(results.map((result2) => ({
14028
- agent: result2.agent,
14029
- output: result2.truncation?.text || getSingleResultOutput(result2),
14030
- status: result2.status,
14031
- error: result2.error,
14032
- ...result2.cause ? { cause: result2.cause } : {}
14312
+ const childContent = formatParallelResultContent(results.map((result) => ({
14313
+ agent: result.agent,
14314
+ output: result.truncation?.text || getSingleResultOutput(result),
14315
+ status: result.status,
14316
+ error: result.error,
14317
+ ...result.cause ? { cause: result.cause } : {}
14033
14318
  })), (i, agent) => `=== Task ${i + 1}: ${agent} ===`);
14034
14319
  const fullContent = worktreeSuffix ? `${childContent}
14035
14320
 
@@ -14132,8 +14417,9 @@ function matchesIntercomDetachRoute(event, expected) {
14132
14417
  // dist/builtin/subagents/src/runs/foreground/execution-intercom-detach.ts
14133
14418
  function registerExecutionIntercomDetach(options, state) {
14134
14419
  const reservations = new IntercomDetachReservations;
14420
+ let taskWaitYielded = false;
14135
14421
  const unsubscribe = options.intercomEvents?.on?.(INTERCOM_DETACH_REQUEST_EVENT, (payload) => {
14136
- if (!options.allowIntercomDetach || state.isUnavailable())
14422
+ if (!options.allowIntercomDetach || state.isUnavailable() || taskWaitYielded)
14137
14423
  return;
14138
14424
  if (!payload || typeof payload !== "object")
14139
14425
  return;
@@ -14150,11 +14436,26 @@ function registerExecutionIntercomDetach(options, state) {
14150
14436
  }
14151
14437
  if (event.phase !== "commit" || state.isDetached() || !reservations.commit(event))
14152
14438
  return;
14153
- options.onIntercomDetachCommit?.();
14154
- state.detach();
14439
+ if (options.taskExecution) {
14440
+ taskWaitYielded = true;
14441
+ options.taskExecution.yieldTaskWait("intercom-coordination");
14442
+ options.onIntercomDetachCommit?.();
14443
+ } else {
14444
+ options.onIntercomDetachCommit?.();
14445
+ state.detach();
14446
+ }
14155
14447
  options.intercomEvents?.emit?.(INTERCOM_DETACH_RESPONSE_EVENT, { ...event, accepted: true });
14156
14448
  });
14157
- const detachSibling = () => state.detach();
14449
+ const detachSibling = () => {
14450
+ if (options.taskExecution) {
14451
+ if (state.isUnavailable() || taskWaitYielded)
14452
+ return;
14453
+ taskWaitYielded = true;
14454
+ options.taskExecution.yieldTaskWait("intercom-coordination");
14455
+ } else {
14456
+ state.detach();
14457
+ }
14458
+ };
14158
14459
  options.intercomDetachSignal?.addEventListener("abort", detachSibling, { once: true });
14159
14460
  if (options.intercomDetachSignal?.aborted)
14160
14461
  detachSibling();
@@ -14273,7 +14574,7 @@ function resultFromOutcome(agent, task, outcome, startedAt, artifactPaths) {
14273
14574
  const output = outcome.status === "ok" ? outcome.output : outcome.envelope;
14274
14575
  const model = outcome.model;
14275
14576
  const thinking = outcome.thinking;
14276
- const result2 = {
14577
+ const result = {
14277
14578
  agent: agent.name,
14278
14579
  task,
14279
14580
  status,
@@ -14299,7 +14600,7 @@ function resultFromOutcome(agent, task, outcome, startedAt, artifactPaths) {
14299
14600
  },
14300
14601
  ...artifactPaths ? { artifactPaths } : {}
14301
14602
  };
14302
- return result2;
14603
+ return result;
14303
14604
  }
14304
14605
  function refusedResult(agent, task, reason) {
14305
14606
  return {
@@ -14431,9 +14732,9 @@ ${task}`);
14431
14732
  const startedAt = Date.now();
14432
14733
  const neverAbort = new AbortController().signal;
14433
14734
  const running = control.startAttempt(admission.admitted, { model: resolvedCandidate?.model, modelId: candidate, thinkingLevel: spec.thinkingLevel }, {
14434
- abort: options.signal ?? neverAbort,
14735
+ abort: options.taskExecution?.signal ?? options.signal ?? neverAbort,
14435
14736
  interrupt: options.interruptSignal ?? neverAbort
14436
- });
14737
+ }, options.taskExecution);
14437
14738
  if (options.onUpdate) {
14438
14739
  const launchModel = running.currentModel ?? candidate;
14439
14740
  spec.onProgress?.({
@@ -14453,8 +14754,8 @@ ${task}`);
14453
14754
  }
14454
14755
  let detached = false;
14455
14756
  let resolveContinuation;
14456
- const continuation = new Promise((resolve14) => {
14457
- resolveContinuation = resolve14;
14757
+ const continuation = new Promise((resolve) => {
14758
+ resolveContinuation = resolve;
14458
14759
  });
14459
14760
  const detachCleanup = registerExecutionIntercomDetach(options, {
14460
14761
  isUnavailable: () => running.status !== "running",
@@ -14490,10 +14791,10 @@ ${task}`);
14490
14791
  timestamp: Date.now(),
14491
14792
  artifactsDir: options.artifactsDir
14492
14793
  }, { artifactsDir: options.artifactsDir, artifactPaths, artifactsDisabled, maxOutput: options.maxOutput });
14493
- const delivered2 = control.getDeliveredResult(continuedOutcome.path);
14494
- if (delivered2) {
14495
- recovered.envelope = delivered2.envelope;
14496
- recovered.finalOutput = delivered2.envelope;
14794
+ const delivered = control.getDeliveredResult(continuedOutcome.path);
14795
+ if (delivered) {
14796
+ recovered.envelope = delivered.envelope;
14797
+ recovered.finalOutput = delivered.envelope;
14497
14798
  }
14498
14799
  options.onDetachedExit?.(recovered);
14499
14800
  });
@@ -14535,37 +14836,37 @@ ${task}`);
14535
14836
  detachCleanup();
14536
14837
  parentAskCleanup();
14537
14838
  const outcome = winner.value;
14538
- const result2 = resultFromOutcome(agent, task, outcome, startedAt, artifactPaths);
14839
+ const result = resultFromOutcome(agent, task, outcome, startedAt, artifactPaths);
14539
14840
  if (filteredCandidates.skippedAttempts.length)
14540
- result2.modelAttempts = [...filteredCandidates.skippedAttempts, ...result2.modelAttempts ?? []];
14841
+ result.modelAttempts = [...filteredCandidates.skippedAttempts, ...result.modelAttempts ?? []];
14541
14842
  await control.deliverChildResult({
14542
14843
  path: outcome.path,
14543
14844
  status: outcome.status,
14544
14845
  ...outcome.status === "error" || outcome.status === "interrupted" && outcome.cause ? { cause: outcome.cause } : {},
14545
14846
  stats: outcome.stats,
14546
14847
  envelope: outcome.envelope,
14547
- ...result2.model === undefined ? {} : { model: result2.model },
14548
- ...result2.thinking === undefined ? {} : { thinking: result2.thinking },
14848
+ ...result.model === undefined ? {} : { model: result.model },
14849
+ ...result.thinking === undefined ? {} : { thinking: result.thinking },
14549
14850
  sessionFile: outcome.sessionFile,
14550
14851
  timestamp: Date.now(),
14551
14852
  artifactsDir: options.artifactsDir
14552
14853
  }, { artifactsDir: options.artifactsDir, artifactPaths, artifactsDisabled, maxOutput: options.maxOutput });
14553
14854
  const delivered = control.getDeliveredResult(outcome.path);
14554
14855
  if (delivered) {
14555
- result2.envelope = delivered.envelope;
14556
- result2.finalOutput = delivered.envelope;
14856
+ result.envelope = delivered.envelope;
14857
+ result.finalOutput = delivered.envelope;
14557
14858
  }
14558
14859
  const update = {
14559
- content: [{ type: "text", text: result2.finalOutput ?? "(no output)" }],
14860
+ content: [{ type: "text", text: result.finalOutput ?? "(no output)" }],
14560
14861
  details: {
14561
14862
  mode: "single",
14562
14863
  runId: options.runId,
14563
- results: [result2],
14564
- progress: result2.progress ? [result2.progress] : undefined
14864
+ results: [result],
14865
+ progress: result.progress ? [result.progress] : undefined
14565
14866
  }
14566
14867
  };
14567
14868
  options.onUpdate?.(update);
14568
- return result2;
14869
+ return result;
14569
14870
  }
14570
14871
  async function runSync(runtimeCwd, agents, agentName, task, options) {
14571
14872
  const agent = agents.find((candidate) => candidate.name === agentName);
@@ -14593,15 +14894,15 @@ function resolveSubagentExecutorRuntimeDeps(overrides) {
14593
14894
  // dist/builtin/subagents/src/runs/foreground/subagent-executor-single.ts
14594
14895
  import * as fs18 from "node:fs";
14595
14896
  import * as path20 from "node:path";
14596
- function formatFailedSingleRunOutput(result2, displayOutput) {
14597
- const error = result2.error || "Failed";
14897
+ function formatFailedSingleRunOutput(result, displayOutput) {
14898
+ const error = result.error || "Failed";
14598
14899
  const output = displayOutput.trim();
14599
14900
  const lines = [error];
14600
14901
  if (output && output !== error.trim()) {
14601
14902
  lines.push("", "Output:", output);
14602
14903
  }
14603
- if (result2.artifactPaths?.outputPath) {
14604
- lines.push("", `Output artifact: ${result2.artifactPaths.outputPath}`);
14904
+ if (result.artifactPaths?.outputPath) {
14905
+ lines.push("", `Output artifact: ${result.artifactPaths.outputPath}`);
14605
14906
  }
14606
14907
  return lines.join(`
14607
14908
  `);
@@ -14753,10 +15054,10 @@ async function runSinglePath(data, deps) {
14753
15054
  parentAsk = request;
14754
15055
  interruptController.abort();
14755
15056
  },
14756
- onDetachedExit: (result2) => {
15057
+ onDetachedExit: (result) => {
14757
15058
  cleanupTransientProgress(progressDir, artifactConfig.enabled);
14758
- if (result2 && workflowStageAcceptsDetachedNotification(ctx)) {
14759
- notifyDetachedForegroundChildExit({ pi: deps.pi, runId, mode: "single", index: 0, result: result2 });
15059
+ if (result && workflowStageAcceptsDetachedNotification(ctx)) {
15060
+ notifyDetachedForegroundChildExit({ pi: deps.pi, runId, mode: "single", index: 0, result });
14760
15061
  }
14761
15062
  },
14762
15063
  index: 0,
@@ -14769,7 +15070,34 @@ async function runSinglePath(data, deps) {
14769
15070
  currentThinkingLevel: ctx.thinkingLevel,
14770
15071
  skills: effectiveSkills
14771
15072
  };
14772
- r = await deps.runtime.runSync(ctx.cwd, agents, params.agent, task, runOptions);
15073
+ if (ctx.getAgentTaskHost) {
15074
+ let settledChild;
15075
+ const response = await runAgentTask({
15076
+ host: ctx.getAgentTaskHost(),
15077
+ cwd: ctx.cwd,
15078
+ agents,
15079
+ agent: params.agent,
15080
+ task,
15081
+ intentTask: handoffTaskContext,
15082
+ options: runOptions,
15083
+ wait: params.wait,
15084
+ runtime: deps.runtime,
15085
+ onTerminal: (child) => {
15086
+ settledChild = child;
15087
+ cleanupTransientProgress(progressDir, artifactConfig.enabled);
15088
+ },
15089
+ outputText: (child) => parentAsk && child.interrupted ? formatParentAskHandoffOutput({
15090
+ askingChildIndex: 0,
15091
+ releasedChildIndices: [0],
15092
+ unlaunchedChildIndices: [],
15093
+ request: parentAsk
15094
+ }) : getSingleResultOutput(child)
15095
+ });
15096
+ if (!parentAsk || !settledChild?.interrupted)
15097
+ return taskToolResult(response, ctx.getAgentTaskHost());
15098
+ r = settledChild;
15099
+ } else
15100
+ r = await deps.runtime.runSync(ctx.cwd, agents, params.agent, task, runOptions);
14773
15101
  } catch (error) {
14774
15102
  cleanupTransientProgress(progressDir, artifactConfig.enabled);
14775
15103
  throw error;
@@ -14887,7 +15215,7 @@ async function runSinglePath(data, deps) {
14887
15215
 
14888
15216
  // dist/builtin/subagents/src/runs/foreground/subagent-executor.ts
14889
15217
  var MUTATING_MANAGEMENT_ACTIONS = new Set(["create", "update", "delete"]);
14890
- var READ_ONLY_MANAGEMENT_ACTIONS = new Set(["list", "get", "status"]);
15218
+ var READ_ONLY_MANAGEMENT_ACTIONS = new Set(["list", "get", "status", "wait"]);
14891
15219
  var FANOUT_REFUSAL_MESSAGE = "Subagent fanout is not authorized for this child.";
14892
15220
  async function handleManagementRequest(input) {
14893
15221
  const { params, paramsWithResolvedCwd, requestCwd, ctx, deps } = input;
@@ -14925,6 +15253,51 @@ async function handleManagementRequest(input) {
14925
15253
  if (childRefusal)
14926
15254
  return childRefusal;
14927
15255
  }
15256
+ if (action === "wait") {
15257
+ const observed = ctx.getAgentTaskHost && params.id !== undefined ? await ctx.getAgentTaskHost().waitForTask(params.id, params.budgetMs) : { ok: false, error: { code: "UnknownTask", message: "Task not found in this owner" } };
15258
+ return {
15259
+ content: [{ type: "text", text: JSON.stringify(observed.ok ? observed.value : observed.error) }],
15260
+ details: {
15261
+ mode: "management",
15262
+ results: [],
15263
+ ...observed.ok ? {
15264
+ taskResponse: { kind: "admitted", observation: observed.value },
15265
+ taskRecords: taskResponseRecords({ kind: "admitted", observation: observed.value }, ctx.getAgentTaskHost?.())
15266
+ } : { taskError: observed.error.message }
15267
+ },
15268
+ ...!observed.ok ? { isError: true } : {}
15269
+ };
15270
+ }
15271
+ const targetTaskId = paramsWithResolvedCwd.id ?? paramsWithResolvedCwd.runId;
15272
+ if ((action === "status" || action === "interrupt") && ctx.getAgentTaskHost && targetTaskId) {
15273
+ const host = ctx.getAgentTaskHost();
15274
+ const taskId = targetTaskId;
15275
+ if (host.resolveTask(taskId).ok) {
15276
+ if (action === "interrupt") {
15277
+ const cancelled = await host.cancelTask(taskId, "user");
15278
+ if (!cancelled.ok)
15279
+ return {
15280
+ content: [{ type: "text", text: cancelled.error.message }],
15281
+ isError: true,
15282
+ details: { mode: "management", results: [], taskError: cancelled.error.message }
15283
+ };
15284
+ }
15285
+ const watched = host.watchOwnerTasks();
15286
+ if (watched.ok) {
15287
+ const records = watched.value.snapshot.tasks.filter((task) => task.ref.taskId === taskId);
15288
+ watched.value.dispose();
15289
+ return {
15290
+ content: [{ type: "text", text: JSON.stringify(records) }],
15291
+ details: { mode: "management", results: [], taskRecords: records }
15292
+ };
15293
+ }
15294
+ return {
15295
+ content: [{ type: "text", text: watched.error.message }],
15296
+ isError: true,
15297
+ details: { mode: "management", results: [], taskError: watched.error.message }
15298
+ };
15299
+ }
15300
+ }
14928
15301
  if (action === "status") {
14929
15302
  const targetRunId = paramsWithResolvedCwd.id ?? paramsWithResolvedCwd.runId;
14930
15303
  const inProcess = inspectInProcessChildStatus(targetRunId);
@@ -15008,12 +15381,12 @@ function createSubagentExecutor(rawDeps) {
15008
15381
  const prepared = built.prepared;
15009
15382
  try {
15010
15383
  if (prepared.hasTasks && prepared.effectiveParams.tasks) {
15011
- const result2 = await runParallelPath(prepared.execData, deps);
15012
- return withForkContext(result2, prepared.effectiveParams.context);
15384
+ const result = await runParallelPath(prepared.execData, deps);
15385
+ return withForkContext(result, prepared.effectiveParams.context);
15013
15386
  }
15014
15387
  if (prepared.hasSingle) {
15015
- const result2 = await runSinglePath(prepared.execData, deps);
15016
- return withForkContext(result2, prepared.effectiveParams.context);
15388
+ const result = await runSinglePath(prepared.execData, deps);
15389
+ return withForkContext(result, prepared.effectiveParams.context);
15017
15390
  }
15018
15391
  } catch (error) {
15019
15392
  return toExecutionErrorResult(prepared.effectiveParams, error);
@@ -15215,28 +15588,28 @@ function resolveProgressModel(update, entry) {
15215
15588
  return byIndex.model;
15216
15589
  }
15217
15590
  if (entry.agent) {
15218
- const byAgent = results.find((result2) => result2.agent === entry.agent && typeof result2.model === "string");
15591
+ const byAgent = results.find((result) => result.agent === entry.agent && typeof result.model === "string");
15219
15592
  if (byAgent?.model)
15220
15593
  return byAgent.model;
15221
15594
  }
15222
- const firstWithModel = results.find((result2) => typeof result2.model === "string");
15595
+ const firstWithModel = results.find((result) => typeof result.model === "string");
15223
15596
  return firstWithModel?.model;
15224
15597
  }
15225
15598
  function toolCallSummaryText(summary) {
15226
15599
  const text = typeof summary.expandedText === "string" && summary.expandedText.trim().length > 0 ? summary.expandedText.trim() : typeof summary.text === "string" ? summary.text.trim() : "";
15227
15600
  return text || undefined;
15228
15601
  }
15229
- function buildDelegationMessages(result2, fallbackText) {
15230
- if (Array.isArray(result2.messages) && result2.messages.length > 0)
15231
- return result2.messages;
15232
- const toolCallSummaries = (result2.toolCalls ?? []).flatMap((summary) => {
15233
- const text2 = toolCallSummaryText(summary);
15234
- return text2 ? [`- ${text2}`] : [];
15602
+ function buildDelegationMessages(result, fallbackText) {
15603
+ if (Array.isArray(result.messages) && result.messages.length > 0)
15604
+ return result.messages;
15605
+ const toolCallSummaries = (result.toolCalls ?? []).flatMap((summary) => {
15606
+ const text = toolCallSummaryText(summary);
15607
+ return text ? [`- ${text}`] : [];
15235
15608
  });
15236
15609
  const toolCallText = toolCallSummaries.length > 0 ? `Tool calls:
15237
15610
  ${toolCallSummaries.join(`
15238
15611
  `)}` : undefined;
15239
- const text = typeof result2.finalOutput === "string" && result2.finalOutput.trim().length > 0 ? result2.finalOutput.trim() : fallbackText;
15612
+ const text = typeof result.finalOutput === "string" && result.finalOutput.trim().length > 0 ? result.finalOutput.trim() : fallbackText;
15240
15613
  const contentText = [toolCallText, text].filter((part) => Boolean(part)).join(`
15241
15614
 
15242
15615
  `);
@@ -15247,15 +15620,15 @@ ${toolCallSummaries.join(`
15247
15620
  function toDelegationUpdate(requestId, update) {
15248
15621
  const progress = update.details?.progress?.[0];
15249
15622
  const taskProgress = update.details?.progress?.map((entry) => {
15250
- const lastOutput2 = entry.recentOutput?.[entry.recentOutput.length - 1];
15251
- const safeLastOutput2 = typeof lastOutput2 === "string" && lastOutput2.trim() && lastOutput2 !== "(running...)" ? lastOutput2 : undefined;
15623
+ const lastOutput = entry.recentOutput?.[entry.recentOutput.length - 1];
15624
+ const safeLastOutput = typeof lastOutput === "string" && lastOutput.trim() && lastOutput !== "(running...)" ? lastOutput : undefined;
15252
15625
  return {
15253
15626
  index: entry.index,
15254
15627
  agent: entry.agent ?? "delegate",
15255
15628
  status: entry.status,
15256
15629
  currentTool: entry.currentTool,
15257
15630
  currentToolArgs: entry.currentToolArgs,
15258
- recentOutput: safeLastOutput2,
15631
+ recentOutput: safeLastOutput,
15259
15632
  recentOutputLines: filterRecentOutput(entry.recentOutput),
15260
15633
  recentTools: sanitizeRecentTools(entry.recentTools),
15261
15634
  model: resolveProgressModel(update, entry),
@@ -15345,7 +15718,7 @@ function registerPromptTemplateDelegationBridge(options) {
15345
15718
  return;
15346
15719
  }
15347
15720
  try {
15348
- const result2 = await options.execute(request.requestId, request, controller.signal, ctx, (update) => {
15721
+ const result = await options.execute(request.requestId, request, controller.signal, ctx, (update) => {
15349
15722
  const payload = toDelegationUpdate(request.requestId, update);
15350
15723
  if (!payload)
15351
15724
  return;
@@ -15353,10 +15726,10 @@ function registerPromptTemplateDelegationBridge(options) {
15353
15726
  controller.abort();
15354
15727
  }
15355
15728
  });
15356
- const contentText = firstTextContent(result2.content);
15357
- const messages = buildDelegationMessages(result2.details?.results?.[0] ?? {}, contentText);
15729
+ const contentText = firstTextContent(result.content);
15730
+ const messages = buildDelegationMessages(result.details?.results?.[0] ?? {}, contentText);
15358
15731
  const parallelResults = request.tasks ? request.tasks.map((task, index) => {
15359
- const step = result2.details?.results?.[index];
15732
+ const step = result.details?.results?.[index];
15360
15733
  if (!step) {
15361
15734
  return {
15362
15735
  agent: task.agent,
@@ -15378,8 +15751,8 @@ function registerPromptTemplateDelegationBridge(options) {
15378
15751
  messages,
15379
15752
  ...parallelResults ? { parallelResults } : {},
15380
15753
  ...contentText ? { contentText } : {},
15381
- isError: result2.isError === true,
15382
- errorText: result2.isError ? contentText : undefined
15754
+ isError: result.isError === true,
15755
+ errorText: result.isError ? contentText : undefined
15383
15756
  };
15384
15757
  emitBridgeEvent(options.events, PROMPT_TEMPLATE_SUBAGENT_RESPONSE_EVENT, response, settlement);
15385
15758
  } catch (error) {
@@ -15487,7 +15860,7 @@ function registerSlashSubagentBridge(options) {
15487
15860
  return;
15488
15861
  }
15489
15862
  try {
15490
- const result2 = await options.execute(requestId, params, controller.signal, (update) => {
15863
+ const result = await options.execute(requestId, params, controller.signal, (update) => {
15491
15864
  const progress = update.details?.progress;
15492
15865
  const first = progress?.[0];
15493
15866
  const payload = {
@@ -15502,9 +15875,9 @@ function registerSlashSubagentBridge(options) {
15502
15875
  }, ctx);
15503
15876
  const response = {
15504
15877
  requestId,
15505
- result: result2,
15506
- isError: result2.isError === true,
15507
- errorText: result2.isError ? result2.content.find((c) => c.type === "text")?.text : undefined
15878
+ result,
15879
+ isError: result.isError === true,
15880
+ errorText: result.isError ? result.content.find((c) => c.type === "text")?.text : undefined
15508
15881
  };
15509
15882
  emitBridgeEvent(options.events, SLASH_SUBAGENT_RESPONSE_EVENT, response, settlement);
15510
15883
  } catch (error) {
@@ -15542,8 +15915,166 @@ function registerSlashSubagentBridge(options) {
15542
15915
  };
15543
15916
  }
15544
15917
 
15918
+ // dist/builtin/subagents/src/tui/agent-browser.ts
15919
+ import {
15920
+ Input,
15921
+ matchesKey,
15922
+ truncateToWidth,
15923
+ visibleWidth,
15924
+ wrapTextWithAnsi
15925
+ } from "@earendil-works/pi-tui";
15926
+ var sources = ["project", "user", "builtin"];
15927
+ var sourceLabels = { project: "Project agents", user: "User agents", builtin: "Built-in agents" };
15928
+ var clean = (text) => text.replace(/\x1b\[[0-?]*[ -/]*[@-~]/g, "").replace(/[\x00-\x1f\x7f-\x9f]/g, " ");
15929
+
15930
+ class AgentBrowser {
15931
+ theme;
15932
+ close;
15933
+ height;
15934
+ search = new Input({ prompt: "Search: ", placeholder: "name, role, or source" });
15935
+ index = 0;
15936
+ detail = false;
15937
+ scroll = 0;
15938
+ agents;
15939
+ get focused() {
15940
+ return this.search.focused;
15941
+ }
15942
+ set focused(value) {
15943
+ this.search.focused = value;
15944
+ }
15945
+ constructor(agents, theme, close, height, query = "") {
15946
+ this.theme = theme;
15947
+ this.close = close;
15948
+ this.height = height;
15949
+ this.agents = sources.flatMap((source) => agents.filter((agent) => agent.source === source).sort((a, b) => a.name.localeCompare(b.name)));
15950
+ this.search.setValue(query);
15951
+ this.search.handleInput("\x05");
15952
+ }
15953
+ invalidate() {}
15954
+ matches() {
15955
+ const query = this.search.getValue().toLowerCase().trim();
15956
+ return this.agents.filter((agent) => `${agent.name} ${agent.description} ${agent.source}`.toLowerCase().includes(query));
15957
+ }
15958
+ handleInput(data) {
15959
+ if (matchesKey(data, "escape") || matchesKey(data, "ctrl+c")) {
15960
+ if (this.detail) {
15961
+ this.detail = false;
15962
+ this.scroll = 0;
15963
+ } else
15964
+ this.close();
15965
+ return true;
15966
+ }
15967
+ if (this.detail) {
15968
+ if (matchesKey(data, "up"))
15969
+ this.scroll = Math.max(0, this.scroll - 1);
15970
+ else if (matchesKey(data, "down"))
15971
+ this.scroll++;
15972
+ else if (matchesKey(data, "pageDown"))
15973
+ this.scroll += 10;
15974
+ else if (matchesKey(data, "pageUp"))
15975
+ this.scroll = Math.max(0, this.scroll - 10);
15976
+ else if (matchesKey(data, "enter")) {
15977
+ this.detail = false;
15978
+ this.scroll = 0;
15979
+ }
15980
+ return true;
15981
+ }
15982
+ const agents = this.matches();
15983
+ if (matchesKey(data, "up"))
15984
+ this.index = Math.max(0, this.index - 1);
15985
+ else if (matchesKey(data, "down"))
15986
+ this.index = Math.min(Math.max(0, agents.length - 1), this.index + 1);
15987
+ else if (matchesKey(data, "enter"))
15988
+ this.detail = agents.length > 0;
15989
+ else {
15990
+ this.search.handleInput(data);
15991
+ this.index = 0;
15992
+ }
15993
+ return true;
15994
+ }
15995
+ render(width) {
15996
+ const theme = this.theme;
15997
+ const budget = Math.max(4, this.height() - 6);
15998
+ const framed = width >= 24 && budget >= 7;
15999
+ const inner = Math.max(1, width - (framed ? 4 : 0));
16000
+ const agents = this.matches();
16001
+ const agent = agents[this.index];
16002
+ const title = this.detail && agent ? agent.name : "Agents";
16003
+ const heading = theme.bold(truncateToWidth(clean(title), Math.max(1, width - 6)));
16004
+ const top = theme.fg("borderMuted", "╭─ ") + heading + theme.fg("borderMuted", ` ${"─".repeat(Math.max(0, width - visibleWidth(heading) - 5))}╮`);
16005
+ const body = [];
16006
+ let selectedRow = 0;
16007
+ if (this.detail && agent) {
16008
+ const section = (label, value) => {
16009
+ body.push("", theme.fg("muted", theme.bold(label)), ...wrapTextWithAnsi(clean(value), inner));
16010
+ };
16011
+ body.push(theme.fg("dim", `${sourceLabels[agent.source]} · ${agent.defaultContext ?? "fresh"} context`));
16012
+ section("Description", agent.description || "No description provided.");
16013
+ section("Model", agent.model ?? "Inherits the current model");
16014
+ if (agent.fallbackModels?.length)
16015
+ section("Fallbacks", agent.fallbackModels.join(" → "));
16016
+ section("Tools", agent.tools ? agent.tools.join(", ") || "None" : "Inherited tools");
16017
+ if (agent.skills?.length)
16018
+ section("Skills", agent.skills.join(", "));
16019
+ section("Definition", agent.filePath);
16020
+ section("System prompt", agent.systemPrompt || "No additional system prompt.");
16021
+ } else {
16022
+ if (!agents.length)
16023
+ body.push(theme.fg("muted", "No matching agents."), theme.fg("dim", "Try a name, role, or source."));
16024
+ for (const source of sources) {
16025
+ const group = agents.filter((agent) => agent.source === source);
16026
+ if (!group.length)
16027
+ continue;
16028
+ body.push(theme.fg("muted", theme.bold(`${sourceLabels[source]} (${group.length})`)));
16029
+ for (const item of group) {
16030
+ const selected = item === agent;
16031
+ if (selected)
16032
+ selectedRow = body.length;
16033
+ const name = `${selected ? "›" : " "} ${clean(item.name)}`;
16034
+ body.push(selected ? theme.fg("accent", theme.bold(name)) : name);
16035
+ if (selected)
16036
+ body.push(theme.fg("muted", ` ${clean(item.description)}`));
16037
+ }
16038
+ body.push("");
16039
+ }
16040
+ }
16041
+ const pinned = this.detail ? [] : this.search.render(inner);
16042
+ const room = Math.max(1, budget - (framed ? 3 : 2) - pinned.length);
16043
+ this.scroll = Math.min(this.scroll, Math.max(0, body.length - room));
16044
+ const offset = this.detail ? this.scroll : Math.max(0, selectedRow - room + Math.min(2, room));
16045
+ const rows = [...pinned, ...body.slice(offset, offset + room)].map((line) => {
16046
+ const text = truncateToWidth(line, inner);
16047
+ if (!framed)
16048
+ return text;
16049
+ return theme.fg("borderMuted", "│ ") + text + " ".repeat(Math.max(0, inner - visibleWidth(text))) + theme.fg("borderMuted", " │");
16050
+ });
16051
+ const hint = this.detail ? "↑↓ scroll · Enter / Esc back" : "Type to filter · ↑↓ select · Enter details · Esc close";
16052
+ return [
16053
+ framed ? top : heading,
16054
+ ...rows,
16055
+ ...framed ? [theme.fg("borderMuted", `╰${"─".repeat(Math.max(0, width - 2))}╯`)] : [],
16056
+ theme.fg("dim", hint)
16057
+ ].map((line) => truncateToWidth(line, width));
16058
+ }
16059
+ }
16060
+
15545
16061
  // dist/builtin/subagents/src/slash/slash-commands.ts
15546
- function registerSlashCommands(_pi, _state) {}
16062
+ function registerSlashCommands(pi, _state) {
16063
+ pi.registerCommand("agents", {
16064
+ description: "Browse available subagents and inspect their configuration",
16065
+ handler: async (args, ctx) => {
16066
+ if (!ctx.hasUI) {
16067
+ ctx.ui.notify("Use subagent action=list to list agents outside interactive mode.", "info");
16068
+ return;
16069
+ }
16070
+ const { agents } = discoverAgents(ctx.cwd, "both");
16071
+ await ctx.ui.custom((tui, theme, _keys, done) => {
16072
+ const browser = new AgentBrowser(agents, theme, () => done(), () => tui.terminal.rows, args.trim());
16073
+ return browser;
16074
+ }, { purpose: "navigation" });
16075
+ }
16076
+ });
16077
+ }
15547
16078
 
15548
16079
  // dist/builtin/subagents/src/slash/slash-live-state.ts
15549
16080
  var defaultStoreOwner = {};
@@ -15607,16 +16138,16 @@ function clearSlashSnapshots(owner) {
15607
16138
  }
15608
16139
 
15609
16140
  // dist/builtin/subagents/src/tui/render-layout.ts
15610
- import { visibleWidth } from "@earendil-works/pi-tui";
16141
+ import { visibleWidth as visibleWidth2 } from "@earendil-works/pi-tui";
15611
16142
  function getTermWidth() {
15612
16143
  return process.stdout.columns || 120;
15613
16144
  }
15614
16145
  var segmenter = new Intl.Segmenter(undefined, { granularity: "grapheme" });
15615
16146
  function truncLine(text, maxWidth) {
15616
- if (visibleWidth(text) <= maxWidth)
16147
+ if (visibleWidth2(text) <= maxWidth)
15617
16148
  return text;
15618
16149
  const targetWidth = maxWidth - 1;
15619
- let result2 = "";
16150
+ let result = "";
15620
16151
  let currentWidth = 0;
15621
16152
  let activeStyles = [];
15622
16153
  let i = 0;
@@ -15624,7 +16155,7 @@ function truncLine(text, maxWidth) {
15624
16155
  const ansiMatch = text.slice(i).match(/^\x1b\[[0-9;]*m/);
15625
16156
  if (ansiMatch) {
15626
16157
  const code = ansiMatch[0];
15627
- result2 += code;
16158
+ result += code;
15628
16159
  if (code === "\x1B[0m" || code === "\x1B[m") {
15629
16160
  activeStyles = [];
15630
16161
  } else {
@@ -15640,16 +16171,16 @@ function truncLine(text, maxWidth) {
15640
16171
  const textPortion = text.slice(i, end);
15641
16172
  for (const seg of segmenter.segment(textPortion)) {
15642
16173
  const grapheme = seg.segment;
15643
- const graphemeWidth = visibleWidth(grapheme);
16174
+ const graphemeWidth = visibleWidth2(grapheme);
15644
16175
  if (currentWidth + graphemeWidth > targetWidth) {
15645
- return `${result2 + activeStyles.join("")}…`;
16176
+ return `${result + activeStyles.join("")}…`;
15646
16177
  }
15647
- result2 += grapheme;
16178
+ result += grapheme;
15648
16179
  currentWidth += graphemeWidth;
15649
16180
  }
15650
16181
  i = end;
15651
16182
  }
15652
- return `${result2 + activeStyles.join("")}…`;
16183
+ return `${result + activeStyles.join("")}…`;
15653
16184
  }
15654
16185
  var PULSE_FRAMES = ["·", "•", "●", "•"];
15655
16186
  function pulseGlyph(frame) {
@@ -15657,8 +16188,8 @@ function pulseGlyph(frame) {
15657
16188
  return PULSE_FRAMES[index % PULSE_FRAMES.length];
15658
16189
  }
15659
16190
  // dist/builtin/subagents/src/tui/render-result.ts
15660
- import { getMarkdownTheme, keyHintIfBound as keyHintIfBound2 } from "@bastani/atomic";
15661
- import { Container as Container2, Markdown, Spacer, Text as Text2 } from "@earendil-works/pi-tui";
16191
+ import { getMarkdownTheme, keyHintIfBound as keyHintIfBound3 } from "@bastani/atomic";
16192
+ import { Container as Container2, Markdown, Spacer, Text as Text3 } from "@earendil-works/pi-tui";
15662
16193
 
15663
16194
  // dist/builtin/subagents/src/tui/render-event-formatting.ts
15664
16195
  function modelThinkingBadge(theme, model, thinking) {
@@ -15694,13 +16225,13 @@ function formatAgentRunningLabel(count) {
15694
16225
  }
15695
16226
 
15696
16227
  // dist/builtin/subagents/src/tui/render-progress.ts
15697
- function isDoneResult(result2) {
15698
- const status = result2.progress?.status;
16228
+ function isDoneResult(result) {
16229
+ const status = result.progress?.status;
15699
16230
  if (status === "completed")
15700
16231
  return true;
15701
16232
  if (status === "running" || status === "pending")
15702
16233
  return false;
15703
- if (result2.interrupted || result2.detached || result2.status !== "ok")
16234
+ if (result.interrupted || result.detached || result.status !== "ok")
15704
16235
  return false;
15705
16236
  return true;
15706
16237
  }
@@ -15714,20 +16245,20 @@ function buildMultiProgressLabel(details, hasRunning) {
15714
16245
  statuses[progress.index] = progress.status;
15715
16246
  }
15716
16247
  for (let i = 0;i < details.results.length; i++) {
15717
- const result2 = details.results[i];
15718
- const progressFromArray = details.progress?.find((progress) => progress.index === i) || details.progress?.find((progress) => progress.agent === result2.agent && progress.status === "running");
15719
- const index = result2.progress?.index ?? progressFromArray?.index ?? i;
16248
+ const result = details.results[i];
16249
+ const progressFromArray = details.progress?.find((progress) => progress.index === i) || details.progress?.find((progress) => progress.agent === result.agent && progress.status === "running");
16250
+ const index = result.progress?.index ?? progressFromArray?.index ?? i;
15720
16251
  if (index < 0 || index >= totalCount)
15721
16252
  continue;
15722
- const status = result2.progress?.status ?? (result2.interrupted || result2.status === "interrupted" ? "interrupted" : result2.detached || result2.status === "continued" ? "detached" : result2.status === "ok" ? "completed" : "failed");
16253
+ const status = result.progress?.status ?? (result.interrupted || result.status === "interrupted" ? "interrupted" : result.detached || result.status === "continued" ? "detached" : result.status === "ok" ? "completed" : "failed");
15723
16254
  statuses[index] = status;
15724
16255
  }
15725
16256
  const running = statuses.filter((status) => status === "running").length;
15726
- const done2 = statuses.filter((status) => status === "completed").length;
15727
- const cancelled = details.results.filter((result2) => isParentCancellation(result2.cause) && (result2.interrupted || result2.status === "interrupted")).length;
15728
- const headerLabel2 = hasRunning ? `${formatAgentRunningLabel(running)} · ${done2}/${totalCount} done` : cancelled > 0 ? `${done2}/${totalCount} done · ${cancelled} cancelled` : `${done2}/${totalCount} done`;
16257
+ const done = statuses.filter((status) => status === "completed").length;
16258
+ const cancelled = details.results.filter((result) => isParentCancellation(result.cause) && (result.interrupted || result.status === "interrupted")).length;
16259
+ const headerLabel = hasRunning ? `${formatAgentRunningLabel(running)} · ${done}/${totalCount} done` : cancelled > 0 ? `${done}/${totalCount} done · ${cancelled} cancelled` : `${done}/${totalCount} done`;
15729
16260
  return {
15730
- headerLabel: headerLabel2,
16261
+ headerLabel,
15731
16262
  itemTitle,
15732
16263
  totalCount,
15733
16264
  groupStartIndex: 0,
@@ -15788,11 +16319,11 @@ function hasEmptyTextOutputWithoutOutputTarget(task, output) {
15788
16319
  return false;
15789
16320
  return !extractOutputTarget(task);
15790
16321
  }
15791
- function getToolCallLines(result2, expanded) {
15792
- if (result2.messages) {
15793
- return getDisplayItems(result2.messages).filter((item) => item.type === "tool").map((item) => formatToolCall(item.name, item.args, expanded));
16322
+ function getToolCallLines(result, expanded) {
16323
+ if (result.messages) {
16324
+ return getDisplayItems(result.messages).filter((item) => item.type === "tool").map((item) => formatToolCall(item.name, item.args, expanded));
15794
16325
  }
15795
- return result2.toolCalls?.map((toolCall) => expanded ? toolCall.expandedText : toolCall.text) ?? [];
16326
+ return result.toolCalls?.map((toolCall) => expanded ? toolCall.expandedText : toolCall.text) ?? [];
15796
16327
  }
15797
16328
  function snapshotNowForProgress(progress, now) {
15798
16329
  if (now !== undefined)
@@ -15857,33 +16388,33 @@ function firstOutputLine(text) {
15857
16388
  return text.split(`
15858
16389
  `).find((line) => line.trim())?.trim() ?? "";
15859
16390
  }
15860
- function resultStatusLine(result2, output) {
15861
- if (result2.detached)
15862
- return result2.detachedReason ? `Detached: ${result2.detachedReason}` : "Detached";
15863
- if (result2.status === "continued")
16391
+ function resultStatusLine(result, output) {
16392
+ if (result.detached)
16393
+ return result.detachedReason ? `Detached: ${result.detachedReason}` : "Detached";
16394
+ if (result.status === "continued")
15864
16395
  return "Continued";
15865
- if (isParentCancellation(result2.cause) && (result2.interrupted || result2.status === "interrupted"))
16396
+ if (isParentCancellation(result.cause) && (result.interrupted || result.status === "interrupted"))
15866
16397
  return "Cancelled";
15867
- if (result2.interrupted || result2.status === "interrupted")
16398
+ if (result.interrupted || result.status === "interrupted")
15868
16399
  return "Interrupted";
15869
- if (result2.status === "skipped")
15870
- return result2.error ? `Skipped: ${result2.error}` : "Skipped";
15871
- if (result2.status === "error")
15872
- return `Error: ${result2.error ?? (firstOutputLine(output) || "failed")}`;
15873
- if (hasEmptyTextOutputWithoutOutputTarget(result2.task, output))
16400
+ if (result.status === "skipped")
16401
+ return result.error ? `Skipped: ${result.error}` : "Skipped";
16402
+ if (result.status === "error")
16403
+ return `Error: ${result.error ?? (firstOutputLine(output) || "failed")}`;
16404
+ if (hasEmptyTextOutputWithoutOutputTarget(result.task, output))
15874
16405
  return "Done (no text output)";
15875
16406
  return "Done";
15876
16407
  }
15877
- function resultGlyph(result2, output, theme, running = result2.progress?.status === "running", pulseFrame) {
16408
+ function resultGlyph(result, output, theme, running = result.progress?.status === "running", pulseFrame) {
15878
16409
  if (running)
15879
16410
  return theme.fg("accent", pulseGlyph(pulseFrame));
15880
- if (result2.detached || result2.status === "continued")
16411
+ if (result.detached || result.status === "continued")
15881
16412
  return theme.fg("warning", "■");
15882
- if (result2.interrupted || result2.status === "interrupted" || result2.status === "skipped")
16413
+ if (result.interrupted || result.status === "interrupted" || result.status === "skipped")
15883
16414
  return theme.fg("warning", "■");
15884
- if (result2.status === "error")
16415
+ if (result.status === "error")
15885
16416
  return theme.fg("error", "✗");
15886
- if (hasEmptyTextOutputWithoutOutputTarget(result2.task, output))
16417
+ if (hasEmptyTextOutputWithoutOutputTarget(result.task, output))
15887
16418
  return theme.fg("warning", "✓");
15888
16419
  return theme.fg("success", "✓");
15889
16420
  }
@@ -16011,10 +16542,10 @@ function renderMultiCompact(d, theme, now, pulseFrame) {
16011
16542
  const stepNumber = r.progress?.index !== undefined ? r.progress.index + 1 : progressFromArray?.index !== undefined ? progressFromArray.index + 1 : i + 1;
16012
16543
  const stepStats = formatProgressStats(theme, rProg, true, now);
16013
16544
  const modelDisplay = modelThinkingBadge(theme, r.model ?? rProg?.model, r.thinking ?? rProg?.thinking);
16014
- const glyph2 = rPending ? theme.fg("dim", "◦") : resultGlyph(r, output, theme, rRunning, pulseFrame);
16545
+ const glyph = rPending ? theme.fg("dim", "◦") : resultGlyph(r, output, theme, rRunning, pulseFrame);
16015
16546
  const pendingLabel = rPending ? ` ${theme.fg("dim", "· pending")}` : "";
16016
16547
  const stepLabel = resultRowLabel(d, multiLabel, i, stepNumber);
16017
- const line = `${glyph2} ${stepLabel}: ${themeBold(theme, agentName)}${modelDisplay}${stepStats ? ` ${theme.fg("dim", "·")} ${stepStats}` : ""}${pendingLabel}`;
16548
+ const line = `${glyph} ${stepLabel}: ${themeBold(theme, agentName)}${modelDisplay}${stepStats ? ` ${theme.fg("dim", "·")} ${stepStats}` : ""}${pendingLabel}`;
16018
16549
  c.addChild(new Text(truncLine(` ${line}`, width), 0, 0));
16019
16550
  if (rRunning && rProg && "status" in rProg) {
16020
16551
  const activity = compactCurrentActivity(rProg, now);
@@ -16061,10 +16592,10 @@ function progressRenderKey(progress) {
16061
16592
  progress.currentPath ?? ""
16062
16593
  ].join(":");
16063
16594
  }
16064
- function subagentResultRenderKey(result2, options) {
16065
- const details = result2.details;
16595
+ function subagentResultRenderKey(result, options) {
16596
+ const details = result.details;
16066
16597
  if (!details)
16067
- return `${options.isPartial ? "partial" : "final"}:${result2.content.length}`;
16598
+ return `${options.isPartial ? "partial" : "final"}:${result.content.length}`;
16068
16599
  const progressKeys = [
16069
16600
  ...(details.progress ?? []).map(progressRenderKey),
16070
16601
  ...details.results.map((entry) => [
@@ -16088,22 +16619,89 @@ function subagentResultRenderKey(result2, options) {
16088
16619
  ].join("|");
16089
16620
  }
16090
16621
 
16622
+ // dist/builtin/subagents/src/tui/render-status.ts
16623
+ import { keyHintIfBound as keyHintIfBound2 } from "@bastani/atomic";
16624
+ import { stripTerminalSequences, Text as Text2, truncateToWidth as truncateToWidth2, visibleWidth as visibleWidth3 } from "@earendil-works/pi-tui";
16625
+ var COMPACT_CHILD_LIMIT = 6;
16626
+ var statusStyles = {
16627
+ pending: { glyph: "○", label: "Pending", color: "dim" },
16628
+ running: { glyph: "∀", label: "Running", color: "accent" },
16629
+ ok: { glyph: "✓", label: "Completed", color: "success" },
16630
+ error: { glyph: "✗", label: "Failed", color: "error" },
16631
+ interrupted: { glyph: "■", label: "Interrupted", color: "warning" },
16632
+ continued: { glyph: "■", label: "Continued", color: "warning" }
16633
+ };
16634
+ var displayText = (value) => stripTerminalSequences(value).replace(/[\x00-\x1f\x7f-\x9f]/g, " ");
16635
+ function childStatusLines(child, expanded, theme, width) {
16636
+ const style = statusStyles[child.status];
16637
+ const name = displayText(child.path.split("/").at(-1) || child.taskName);
16638
+ const label = expanded ? name : displayText(truncateToWidth2(name, Math.max(1, width - visibleWidth3(style.label) - 5), "…"));
16639
+ const heading = `${theme.fg(style.color, style.glyph)} ${theme.fg("toolTitle", theme.bold(label))}${theme.fg("dim", " · ")}${theme.fg(style.color, style.label)}`;
16640
+ const model = formatModelThinking(child.model, child.thinking);
16641
+ const metadata = model ? [theme.fg("dim", ` ${displayText(model)}`)] : [];
16642
+ if (!expanded)
16643
+ return [heading, ...metadata];
16644
+ return [
16645
+ heading,
16646
+ ...metadata,
16647
+ theme.fg("dim", ` Path: ${displayText(child.path)}`),
16648
+ theme.fg("dim", ` Parent: ${displayText(child.parentPath)} · Depth: ${child.depth}`),
16649
+ theme.fg("dim", ` Task: ${displayText(child.taskName)}`),
16650
+ theme.fg("dim", ` Residency: ${child.loaded ? "loaded" : "cold"}`),
16651
+ ...child.cause ? [theme.fg("muted", ` Cause: ${displayText(child.cause)}`)] : [],
16652
+ ...child.sessionFile ? [theme.fg("dim", ` Session: ${displayText(child.sessionFile)}`)] : []
16653
+ ];
16654
+ }
16655
+ function statusLines(groups, expanded, theme, width) {
16656
+ const total = groups.reduce((sum, group) => sum + group.children.length, 0);
16657
+ const lines = total > 1 ? [theme.fg("muted", `${total} agents`)] : [];
16658
+ let shown = 0;
16659
+ for (const group of groups) {
16660
+ const children = expanded ? group.children : group.children.slice(0, COMPACT_CHILD_LIMIT - shown);
16661
+ if (!children.length && !expanded)
16662
+ continue;
16663
+ if (groups.length > 1 || !children.length)
16664
+ lines.push(theme.fg("dim", `Run ${displayText(group.parentPath)}`));
16665
+ lines.push(...children.length ? children.flatMap((child) => childStatusLines(child, expanded, theme, width)) : [theme.fg("muted", " No subagents")]);
16666
+ shown += children.length;
16667
+ }
16668
+ if (!lines.length)
16669
+ lines.push(theme.fg("muted", "No subagents"));
16670
+ if (shown < total)
16671
+ lines.push(theme.fg("muted", `… ${total - shown} more agents`));
16672
+ const hint = !expanded && keyHintIfBound2("app.tools.expand", "to expand");
16673
+ if (hint)
16674
+ lines.push(theme.fg("dim", hint));
16675
+ return lines;
16676
+ }
16677
+ function renderSubagentStatus(groups, expanded, theme) {
16678
+ return {
16679
+ invalidate() {},
16680
+ render(width) {
16681
+ if (width <= 0)
16682
+ return [];
16683
+ return new Text2(statusLines(groups, expanded, theme, width).join(`
16684
+ `), 0, 0).render(width);
16685
+ }
16686
+ };
16687
+ }
16688
+
16091
16689
  // dist/builtin/subagents/src/tui/render-result.ts
16092
- function parentAskOutput(result2) {
16093
- if (!result2.details?.parentAskYielded)
16690
+ function parentAskOutput(result) {
16691
+ if (!result.details?.parentAskYielded)
16094
16692
  return;
16095
- return result2.content.find((part) => part.type === "text")?.text;
16693
+ return result.content.find((part) => part.type === "text")?.text;
16096
16694
  }
16097
16695
  function appendParentAskOutput(component, output, theme) {
16098
16696
  if (!output)
16099
16697
  return component;
16100
16698
  const container = new Container2;
16101
16699
  container.addChild(component);
16102
- container.addChild(new Text2(theme.fg("accent", output), 0, 0));
16700
+ container.addChild(new Text3(theme.fg("accent", output), 0, 0));
16103
16701
  return container;
16104
16702
  }
16105
- function renderLiveSubagentResult(result2, options, theme, context) {
16106
- const nextKey = subagentResultRenderKey(result2, options);
16703
+ function renderLiveSubagentResult(result, options, theme, context) {
16704
+ const nextKey = subagentResultRenderKey(result, options);
16107
16705
  if (context.state.subagentResultSnapshotKey !== nextKey) {
16108
16706
  context.state.subagentResultSnapshotKey = nextKey;
16109
16707
  context.state.subagentResultSnapshotNow = Date.now();
@@ -16112,110 +16710,112 @@ function renderLiveSubagentResult(result2, options, theme, context) {
16112
16710
  context.state.subagentResultSnapshotNow ??= Date.now();
16113
16711
  context.state.subagentResultPulseFrame ??= 0;
16114
16712
  clearResultAnimationTimer(context);
16115
- return renderSubagentResult(result2, {
16713
+ return renderSubagentResult(result, {
16116
16714
  ...options,
16117
16715
  now: context.state.subagentResultSnapshotNow,
16118
16716
  pulseFrame: context.state.subagentResultPulseFrame
16119
16717
  }, theme);
16120
16718
  }
16121
- function renderSubagentResult(result2, options, theme) {
16122
- const d = result2.details;
16719
+ function renderSubagentResult(result, options, theme) {
16720
+ const d = result.details;
16721
+ if (d?.statusGroups)
16722
+ return renderSubagentStatus(d.statusGroups, options.expanded, theme);
16123
16723
  const liveMultiProgress = d?.mode === "parallel" && (d?.progress?.length ?? 0) > 0;
16124
16724
  if (!d?.results.length && !liveMultiProgress) {
16125
- const t = result2.content[0];
16725
+ const t = result.content[0];
16126
16726
  const text = t?.type === "text" ? t.text : "(no output)";
16127
16727
  const contextPrefix = d?.context === "fork" ? `${theme.fg("warning", "[fork]")} ` : "";
16128
- return new Text2(truncLine(`${contextPrefix}${text}`, getTermWidth() - 4), 0, 0);
16728
+ return new Text3(truncLine(`${contextPrefix}${text}`, getTermWidth() - 4), 0, 0);
16129
16729
  }
16130
16730
  const expanded = options.expanded;
16131
16731
  const mdTheme = getMarkdownTheme();
16132
- const handoffOutput = parentAskOutput(result2);
16732
+ const handoffOutput = parentAskOutput(result);
16133
16733
  if (d.mode === "single" && d.results.length === 1) {
16134
16734
  const r = d.results[0];
16135
16735
  if (!expanded)
16136
16736
  return appendParentAskOutput(renderSingleCompact(d, r, theme, options.now, options.pulseFrame), handoffOutput, theme);
16137
16737
  const isRunning = r.progress?.status === "running";
16138
- const icon2 = isRunning ? theme.fg("warning", "running") : d.parentAskYielded ? theme.fg("warning", "yielded") : r.detached || r.status === "continued" ? theme.fg("warning", "detached") : isParentCancellation(r.cause) && (r.interrupted || r.status === "interrupted") ? theme.fg("warning", "cancelled") : r.status === "ok" ? theme.fg("success", "ok") : theme.fg("error", "failed");
16139
- const contextBadge2 = d.context === "fork" ? theme.fg("warning", " [fork]") : "";
16738
+ const icon = isRunning ? theme.fg("warning", "running") : d.parentAskYielded ? theme.fg("warning", "yielded") : r.detached || r.status === "continued" ? theme.fg("warning", "detached") : isParentCancellation(r.cause) && (r.interrupted || r.status === "interrupted") ? theme.fg("warning", "cancelled") : r.status === "ok" ? theme.fg("success", "ok") : theme.fg("error", "failed");
16739
+ const contextBadge = d.context === "fork" ? theme.fg("warning", " [fork]") : "";
16140
16740
  const output = r.truncation?.text || getSingleResultOutput(r);
16141
16741
  const progressInfo = isRunning && r.progress ? ` | ${r.progress.toolCount} tools, ${formatTokens(r.progress.tokens)} tok, ${formatDuration(displayProgressDurationMs(r.progress, options.now))}` : r.progressSummary ? ` | ${r.progressSummary.toolCount} tools, ${formatTokens(r.progressSummary.tokens)} tok, ${formatDuration(r.progressSummary.durationMs)}` : "";
16142
- const w2 = getTermWidth() - 4;
16143
- const fit2 = (text) => expanded ? text : truncLine(text, w2);
16742
+ const w = getTermWidth() - 4;
16743
+ const fit = (text) => expanded ? text : truncLine(text, w);
16144
16744
  const modelDisplay = modelThinkingBadge(theme, r.model, r.thinking);
16145
16745
  const toolCallLines = getToolCallLines(r, expanded);
16146
- const c2 = new Container2;
16147
- c2.addChild(new Text2(fit2(`${icon2} ${theme.fg("toolTitle", theme.bold(r.agent))}${modelDisplay}${contextBadge2}${progressInfo}`), 0, 0));
16148
- c2.addChild(new Spacer(1));
16149
- const taskMaxLen = Math.max(20, w2 - 8);
16746
+ const c = new Container2;
16747
+ c.addChild(new Text3(fit(`${icon} ${theme.fg("toolTitle", theme.bold(r.agent))}${modelDisplay}${contextBadge}${progressInfo}`), 0, 0));
16748
+ c.addChild(new Spacer(1));
16749
+ const taskMaxLen = Math.max(20, w - 8);
16150
16750
  const taskPreview = expanded || r.task.length <= taskMaxLen ? r.task : `${r.task.slice(0, taskMaxLen)}...`;
16151
- c2.addChild(new Text2(fit2(theme.fg("dim", `Task: ${taskPreview}`)), 0, 0));
16152
- c2.addChild(new Spacer(1));
16751
+ c.addChild(new Text3(fit(theme.fg("dim", `Task: ${taskPreview}`)), 0, 0));
16752
+ c.addChild(new Spacer(1));
16153
16753
  if (isRunning && r.progress) {
16154
16754
  const progressSnapshotNow = snapshotNowForProgress(r.progress, options.now);
16155
- const toolLine = formatCurrentToolLine(r.progress, w2, expanded, progressSnapshotNow);
16755
+ const toolLine = formatCurrentToolLine(r.progress, w, expanded, progressSnapshotNow);
16156
16756
  if (toolLine) {
16157
- c2.addChild(new Text2(fit2(theme.fg("warning", `> ${toolLine}`)), 0, 0));
16757
+ c.addChild(new Text3(fit(theme.fg("warning", `> ${toolLine}`)), 0, 0));
16158
16758
  }
16159
16759
  const liveStatusLine = buildLiveStatusLine(r.progress, progressSnapshotNow);
16160
16760
  if (liveStatusLine) {
16161
- c2.addChild(new Text2(fit2(theme.fg("accent", liveStatusLine)), 0, 0));
16761
+ c.addChild(new Text3(fit(theme.fg("accent", liveStatusLine)), 0, 0));
16162
16762
  }
16163
- const expandHint = keyHintIfBound2("app.tools.expand", "for live detail");
16763
+ const expandHint = keyHintIfBound3("app.tools.expand", "for live detail");
16164
16764
  if (expandHint)
16165
- c2.addChild(new Text2(fit2(theme.fg("accent", `Press ${expandHint}`)), 0, 0));
16765
+ c.addChild(new Text3(fit(theme.fg("accent", `Press ${expandHint}`)), 0, 0));
16166
16766
  if (r.artifactPaths) {
16167
- c2.addChild(new Text2(fit2(theme.fg("dim", `Artifacts: ${shortenPath(r.artifactPaths.outputPath)}`)), 0, 0));
16767
+ c.addChild(new Text3(fit(theme.fg("dim", `Artifacts: ${shortenPath(r.artifactPaths.outputPath)}`)), 0, 0));
16168
16768
  }
16169
16769
  if (r.progress.recentTools?.length) {
16170
16770
  for (const t of r.progress.recentTools.slice(-3)) {
16171
- const maxArgsLen = Math.max(40, w2 - 24);
16771
+ const maxArgsLen = Math.max(40, w - 24);
16172
16772
  const argsPreview = expanded || t.args.length <= maxArgsLen ? t.args : `${t.args.slice(0, maxArgsLen)}...`;
16173
- c2.addChild(new Text2(fit2(theme.fg("dim", `${t.tool}: ${argsPreview}`)), 0, 0));
16773
+ c.addChild(new Text3(fit(theme.fg("dim", `${t.tool}: ${argsPreview}`)), 0, 0));
16174
16774
  }
16175
16775
  }
16176
16776
  for (const line of (r.progress.recentOutput ?? []).slice(-5)) {
16177
- c2.addChild(new Text2(fit2(theme.fg("dim", ` ${line}`)), 0, 0));
16777
+ c.addChild(new Text3(fit(theme.fg("dim", ` ${line}`)), 0, 0));
16178
16778
  }
16179
16779
  if (toolLine || liveStatusLine || r.progress.recentTools?.length || r.progress.recentOutput?.length || r.artifactPaths) {
16180
- c2.addChild(new Spacer(1));
16780
+ c.addChild(new Spacer(1));
16181
16781
  }
16182
16782
  }
16183
16783
  if (expanded) {
16184
16784
  for (const line of toolCallLines) {
16185
- c2.addChild(new Text2(fit2(theme.fg("muted", line)), 0, 0));
16785
+ c.addChild(new Text3(fit(theme.fg("muted", line)), 0, 0));
16186
16786
  }
16187
16787
  if (toolCallLines.length)
16188
- c2.addChild(new Spacer(1));
16788
+ c.addChild(new Spacer(1));
16189
16789
  }
16190
16790
  if (output)
16191
- c2.addChild(new Markdown(output, 0, 0, mdTheme));
16192
- c2.addChild(new Spacer(1));
16791
+ c.addChild(new Markdown(output, 0, 0, mdTheme));
16792
+ c.addChild(new Spacer(1));
16193
16793
  if (r.skills?.length) {
16194
- c2.addChild(new Text2(fit2(theme.fg("dim", `Skills: ${r.skills.join(", ")}`)), 0, 0));
16794
+ c.addChild(new Text3(fit(theme.fg("dim", `Skills: ${r.skills.join(", ")}`)), 0, 0));
16195
16795
  }
16196
16796
  if (r.skillsWarning) {
16197
- c2.addChild(new Text2(fit2(theme.fg("warning", `Warning: ${r.skillsWarning}`)), 0, 0));
16797
+ c.addChild(new Text3(fit(theme.fg("warning", `Warning: ${r.skillsWarning}`)), 0, 0));
16198
16798
  }
16199
16799
  if (r.attemptedModels && r.attemptedModels.length > 1) {
16200
- c2.addChild(new Text2(fit2(theme.fg("dim", `Fallbacks: ${r.attemptedModels.join(" → ")}`)), 0, 0));
16800
+ c.addChild(new Text3(fit(theme.fg("dim", `Fallbacks: ${r.attemptedModels.join(" → ")}`)), 0, 0));
16201
16801
  }
16202
- c2.addChild(new Text2(fit2(theme.fg("dim", formatUsage(r.usage))), 0, 0));
16802
+ c.addChild(new Text3(fit(theme.fg("dim", formatUsage(r.usage))), 0, 0));
16203
16803
  if (r.sessionFile) {
16204
- c2.addChild(new Text2(fit2(theme.fg("dim", `Session: ${shortenPath(r.sessionFile)}`)), 0, 0));
16804
+ c.addChild(new Text3(fit(theme.fg("dim", `Session: ${shortenPath(r.sessionFile)}`)), 0, 0));
16205
16805
  }
16206
16806
  if (!isRunning && r.artifactPaths) {
16207
- c2.addChild(new Spacer(1));
16208
- c2.addChild(new Text2(fit2(theme.fg("dim", `Artifacts: ${shortenPath(r.artifactPaths.outputPath)}`)), 0, 0));
16807
+ c.addChild(new Spacer(1));
16808
+ c.addChild(new Text3(fit(theme.fg("dim", `Artifacts: ${shortenPath(r.artifactPaths.outputPath)}`)), 0, 0));
16209
16809
  }
16210
- return appendParentAskOutput(c2, handoffOutput, theme);
16810
+ return appendParentAskOutput(c, handoffOutput, theme);
16211
16811
  }
16212
16812
  if (!expanded)
16213
16813
  return appendParentAskOutput(renderMultiCompact(d, theme, options.now, options.pulseFrame), handoffOutput, theme);
16214
16814
  const hasRunning = d.progress?.some((p) => p.status === "running") || d.results.some((r) => r.progress?.status === "running");
16215
16815
  const ok = d.results.filter((r) => r.progress?.status === "completed" || r.status === "ok" && r.progress?.status !== "running").length;
16216
16816
  const hasEmptyWithoutTarget = d.results.some((r) => r.status === "ok" && r.progress?.status !== "running" && hasEmptyTextOutputWithoutOutputTarget(r.task, getSingleResultOutput(r)));
16217
- const hasCancelled = d.results.some((result3) => isParentCancellation(result3.cause) && (result3.interrupted || result3.status === "interrupted"));
16218
- const icon = hasRunning ? theme.fg("warning", "running") : d.parentAskYielded ? theme.fg("warning", "yielded") : hasEmptyWithoutTarget ? theme.fg("warning", "warning") : ok === d.results.length ? theme.fg("success", "ok") : d.results.some((result3) => result3.status === "error") ? theme.fg("error", "failed") : hasCancelled ? theme.fg("warning", "cancelled") : theme.fg("error", "failed");
16817
+ const hasCancelled = d.results.some((result) => isParentCancellation(result.cause) && (result.interrupted || result.status === "interrupted"));
16818
+ const icon = hasRunning ? theme.fg("warning", "running") : d.parentAskYielded ? theme.fg("warning", "yielded") : hasEmptyWithoutTarget ? theme.fg("warning", "warning") : ok === d.results.length ? theme.fg("success", "ok") : d.results.some((result) => result.status === "error") ? theme.fg("error", "failed") : hasCancelled ? theme.fg("warning", "cancelled") : theme.fg("error", "failed");
16219
16819
  const totalSummary = d.progressSummary || d.results.reduce((acc, r) => {
16220
16820
  const prog = r.progress || r.progressSummary;
16221
16821
  if (prog) {
@@ -16232,7 +16832,7 @@ function renderSubagentResult(result2, options, theme) {
16232
16832
  const w = getTermWidth() - 4;
16233
16833
  const fit = (text) => expanded ? text : truncLine(text, w);
16234
16834
  const c = new Container2;
16235
- c.addChild(new Text2(fit(`${icon} ${theme.fg("toolTitle", theme.bold(modeLabel))}${contextBadge} · ${multiLabel.headerLabel}${summaryStr}`), 0, 0));
16835
+ c.addChild(new Text3(fit(`${icon} ${theme.fg("toolTitle", theme.bold(modeLabel))}${contextBadge} · ${multiLabel.headerLabel}${summaryStr}`), 0, 0));
16236
16836
  const progressSpan = d.progress?.length ? Math.max(...d.progress.map((p) => p.index + 1)) : 0;
16237
16837
  const resultsSpan = Math.max(d.results.length, progressSpan, d.mode === "parallel" ? d.totalSteps ?? 0 : 0);
16238
16838
  const displayStart = multiLabel.showActiveGroupOnly ? multiLabel.groupStartIndex : 0;
@@ -16260,20 +16860,20 @@ function renderSubagentResult(result2, options, theme) {
16260
16860
  if (runningProg) {
16261
16861
  const runningStats = ` | ${runningProg.toolCount} tools, ${formatDuration(displayProgressDurationMs(runningProg, options.now))}`;
16262
16862
  const runningBadge = modelThinkingBadge(theme, runningProg.model, runningProg.thinking);
16263
- c.addChild(new Text2(fit(`${theme.fg("warning", "running")} ${rowLabel}: ${theme.bold(theme.fg("warning", agentName))}${runningBadge}${runningStats}`), 0, 0));
16863
+ c.addChild(new Text3(fit(`${theme.fg("warning", "running")} ${rowLabel}: ${theme.bold(theme.fg("warning", agentName))}${runningBadge}${runningStats}`), 0, 0));
16264
16864
  const progressSnapshotNow = snapshotNowForProgress(runningProg, options.now);
16265
16865
  const liveStatusLine = buildLiveStatusLine(runningProg, progressSnapshotNow);
16266
16866
  if (liveStatusLine) {
16267
- c.addChild(new Text2(fit(theme.fg("accent", ` ${liveStatusLine}`)), 0, 0));
16867
+ c.addChild(new Text3(fit(theme.fg("accent", ` ${liveStatusLine}`)), 0, 0));
16268
16868
  }
16269
- const expandHint = keyHintIfBound2("app.tools.expand", "for live detail");
16869
+ const expandHint = keyHintIfBound3("app.tools.expand", "for live detail");
16270
16870
  if (expandHint)
16271
- c.addChild(new Text2(fit(theme.fg("accent", ` Press ${expandHint}`)), 0, 0));
16871
+ c.addChild(new Text3(fit(theme.fg("accent", ` Press ${expandHint}`)), 0, 0));
16272
16872
  c.addChild(new Spacer(1));
16273
16873
  continue;
16274
16874
  }
16275
- c.addChild(new Text2(fit(theme.fg("dim", ` ${rowLabel}: ${agentName}`)), 0, 0));
16276
- c.addChild(new Text2(theme.fg("dim", ` status: pending`), 0, 0));
16875
+ c.addChild(new Text3(fit(theme.fg("dim", ` ${rowLabel}: ${agentName}`)), 0, 0));
16876
+ c.addChild(new Text3(theme.fg("dim", ` status: pending`), 0, 0));
16277
16877
  c.addChild(new Spacer(1));
16278
16878
  continue;
16279
16879
  }
@@ -16288,60 +16888,60 @@ function renderSubagentResult(result2, options, theme) {
16288
16888
  const stepLabel = resultRowLabel(d, multiLabel, i, stepNumber);
16289
16889
  const stepHeader = rRunning ? `${statusIcon} ${stepLabel}: ${theme.bold(theme.fg("warning", r.agent))}${modelDisplay}${stats}` : `${statusIcon} ${stepLabel}: ${theme.bold(r.agent)}${modelDisplay}${stats}`;
16290
16890
  const toolCallLines = getToolCallLines(r, expanded);
16291
- c.addChild(new Text2(fit(stepHeader), 0, 0));
16891
+ c.addChild(new Text3(fit(stepHeader), 0, 0));
16292
16892
  const taskMaxLen = Math.max(20, w - 12);
16293
16893
  const taskPreview = expanded || r.task.length <= taskMaxLen ? r.task : `${r.task.slice(0, taskMaxLen)}...`;
16294
- c.addChild(new Text2(fit(theme.fg("dim", ` task: ${taskPreview}`)), 0, 0));
16894
+ c.addChild(new Text3(fit(theme.fg("dim", ` task: ${taskPreview}`)), 0, 0));
16295
16895
  const outputTarget = extractOutputTarget(r.task);
16296
16896
  if (outputTarget) {
16297
- c.addChild(new Text2(fit(theme.fg("dim", ` output: ${outputTarget}`)), 0, 0));
16897
+ c.addChild(new Text3(fit(theme.fg("dim", ` output: ${outputTarget}`)), 0, 0));
16298
16898
  }
16299
16899
  if (r.skills?.length) {
16300
- c.addChild(new Text2(fit(theme.fg("dim", ` skills: ${r.skills.join(", ")}`)), 0, 0));
16900
+ c.addChild(new Text3(fit(theme.fg("dim", ` skills: ${r.skills.join(", ")}`)), 0, 0));
16301
16901
  }
16302
16902
  if (r.skillsWarning) {
16303
- c.addChild(new Text2(fit(theme.fg("warning", ` Warning: ${r.skillsWarning}`)), 0, 0));
16903
+ c.addChild(new Text3(fit(theme.fg("warning", ` Warning: ${r.skillsWarning}`)), 0, 0));
16304
16904
  }
16305
16905
  if (r.attemptedModels && r.attemptedModels.length > 1) {
16306
- c.addChild(new Text2(fit(theme.fg("dim", ` fallbacks: ${r.attemptedModels.join(" → ")}`)), 0, 0));
16906
+ c.addChild(new Text3(fit(theme.fg("dim", ` fallbacks: ${r.attemptedModels.join(" → ")}`)), 0, 0));
16307
16907
  }
16308
16908
  if (rRunning && rProg) {
16309
16909
  if (rProg.skills?.length) {
16310
- c.addChild(new Text2(fit(theme.fg("accent", ` skills: ${rProg.skills.join(", ")}`)), 0, 0));
16910
+ c.addChild(new Text3(fit(theme.fg("accent", ` skills: ${rProg.skills.join(", ")}`)), 0, 0));
16311
16911
  }
16312
16912
  const progressSnapshotNow = snapshotNowForProgress(rProg, options.now);
16313
16913
  const toolLine = formatCurrentToolLine(rProg, w, expanded, progressSnapshotNow);
16314
16914
  if (toolLine) {
16315
- c.addChild(new Text2(fit(theme.fg("warning", ` > ${toolLine}`)), 0, 0));
16915
+ c.addChild(new Text3(fit(theme.fg("warning", ` > ${toolLine}`)), 0, 0));
16316
16916
  }
16317
16917
  const liveStatusLine = buildLiveStatusLine(rProg, progressSnapshotNow);
16318
16918
  if (liveStatusLine) {
16319
- c.addChild(new Text2(fit(theme.fg("accent", ` ${liveStatusLine}`)), 0, 0));
16919
+ c.addChild(new Text3(fit(theme.fg("accent", ` ${liveStatusLine}`)), 0, 0));
16320
16920
  }
16321
- const expandHint = keyHintIfBound2("app.tools.expand", "for live detail");
16921
+ const expandHint = keyHintIfBound3("app.tools.expand", "for live detail");
16322
16922
  if (expandHint)
16323
- c.addChild(new Text2(fit(theme.fg("accent", ` Press ${expandHint}`)), 0, 0));
16923
+ c.addChild(new Text3(fit(theme.fg("accent", ` Press ${expandHint}`)), 0, 0));
16324
16924
  if (r.artifactPaths) {
16325
- c.addChild(new Text2(fit(theme.fg("dim", ` artifacts: ${shortenPath(r.artifactPaths.outputPath)}`)), 0, 0));
16925
+ c.addChild(new Text3(fit(theme.fg("dim", ` artifacts: ${shortenPath(r.artifactPaths.outputPath)}`)), 0, 0));
16326
16926
  }
16327
16927
  if (rProg.recentTools?.length) {
16328
16928
  for (const t of rProg.recentTools.slice(-3)) {
16329
16929
  const maxArgsLen = Math.max(40, w - 30);
16330
16930
  const argsPreview = expanded || t.args.length <= maxArgsLen ? t.args : `${t.args.slice(0, maxArgsLen)}...`;
16331
- c.addChild(new Text2(fit(theme.fg("dim", ` ${t.tool}: ${argsPreview}`)), 0, 0));
16931
+ c.addChild(new Text3(fit(theme.fg("dim", ` ${t.tool}: ${argsPreview}`)), 0, 0));
16332
16932
  }
16333
16933
  }
16334
16934
  const recentLines = (rProg.recentOutput ?? []).slice(-5);
16335
16935
  for (const line of recentLines) {
16336
- c.addChild(new Text2(fit(theme.fg("dim", ` ${line}`)), 0, 0));
16936
+ c.addChild(new Text3(fit(theme.fg("dim", ` ${line}`)), 0, 0));
16337
16937
  }
16338
16938
  }
16339
16939
  if (!rRunning && r.artifactPaths) {
16340
- c.addChild(new Text2(fit(theme.fg("dim", ` artifacts: ${shortenPath(r.artifactPaths.outputPath)}`)), 0, 0));
16940
+ c.addChild(new Text3(fit(theme.fg("dim", ` artifacts: ${shortenPath(r.artifactPaths.outputPath)}`)), 0, 0));
16341
16941
  }
16342
16942
  if (expanded && !rRunning) {
16343
16943
  for (const line of toolCallLines) {
16344
- c.addChild(new Text2(fit(theme.fg("muted", ` ${line}`)), 0, 0));
16944
+ c.addChild(new Text3(fit(theme.fg("muted", ` ${line}`)), 0, 0));
16345
16945
  }
16346
16946
  if (toolCallLines.length)
16347
16947
  c.addChild(new Spacer(1));
@@ -16350,7 +16950,7 @@ function renderSubagentResult(result2, options, theme) {
16350
16950
  }
16351
16951
  if (d.artifacts) {
16352
16952
  c.addChild(new Spacer(1));
16353
- c.addChild(new Text2(fit(theme.fg("dim", `Artifacts dir: ${shortenPath(d.artifacts.dir)}`)), 0, 0));
16953
+ c.addChild(new Text3(fit(theme.fg("dim", `Artifacts dir: ${shortenPath(d.artifacts.dir)}`)), 0, 0));
16354
16954
  }
16355
16955
  return appendParentAskOutput(c, handoffOutput, theme);
16356
16956
  }
@@ -16463,11 +17063,12 @@ function parseSubagentNotifyContent(content) {
16463
17063
  var DEFAULT_PROMPT_GUIDANCE = [
16464
17064
  `**Subagent orchestration**: Use subagents for focused specialist work inside workflows or as bounded delegation when a workflow would be unnecessary overhead.
16465
17065
  - Unless the user explicitly chooses inline execution for the specified task, workflows are the default for non-trivial structured work with verifiable objectives; use a workflow for implementation, review, or retry pipelines and let its stages delegate specialists.
16466
- - Explicit requests such as "inline", "do this directly", or "don't use a workflow", and equivalent wording, override that default even for complex tasks. Do not create or launch a hidden/nested workflow or pressure the user to reapprove the choice. Preserve appropriate testing, review and evidence inline, and unrelated safety and authorization constraints. Apply the preference only to the specified task. Quoted examples and questions about inline code are not execution-mode instructions.
17066
+ - Explicit requests such as "quickly", "inline", "do this directly", or "don't use a workflow", and equivalent wording, override that default even for complex tasks. Treat "quickly" as an inline execution choice, not a request for a faster workflow. Do not create or launch a hidden/nested workflow or pressure the user to reapprove the choice. Preserve appropriate testing, review and evidence inline, and unrelated safety and authorization constraints. Apply the preference only to the specified task. Quoted examples and questions about inline code are not execution-mode instructions; neither are descriptions of software that should run quickly.
16467
17067
  - On a switch from an active workflow to inline, notify the controlling session to safely hold/stop the affected run, reconcile completed work and in-flight side effects, then continue inline without duplicate execution. Do not claim completed work was undone.
16468
17068
  - Use a single subagent for a focused specialty or parallel tasks for independent work. Keep substantial-overlap tasks together rather than duplicating investigation across agents.
16469
17069
  - Delegate noisy or context-heavy command investigation when isolation helps, but run concise commands inline when that is simpler.
16470
- - Foreground execution is the only subagent execution mode; do not duplicate a delegated job while waiting. Workflow stages may still run their own durable work in the background.
17070
+ - Background subagents are supported in owner-bound sessions: omitted wait or wait:{kind:"background"} yields after admission while the child continues. Use wait:{kind:"foreground",budgetMs:30000} for foreground-first observation. A yielded observation never means the task stopped. Do not duplicate delegated work; observe the existing task or await its completion notice. The UI shows compact status below the prompt, and /tasks opens inspection only when invoked.
17071
+ - Choose foreground-first or background observation for each authorized call based on whether the next action needs the result; do not ask the user merely to select a mode. Foreground observation automatically yields on budget expiry while the same task continues. Wait for terminal completion before starting dependent work. Execution mode does not bypass tool permissions, delegation boundaries, or owner lifetime.
16471
17072
  - Use the debugger subagent for actual failures that need reproduction, root-cause diagnosis, and a validated fix; additional debugger or research delegates are optional when they add a distinct useful angle.
16472
17073
  - Let each named agent use its declared model and fallback policy: omit the explicit model argument unless the user requests an exact model or a documented task requirement needs one, and record the reason for any override before launch. Do not choose an ad hoc model merely for diversity.
16473
17074
  - If an agent has no declared model or fallback policy, consult packages/coding-agent/docs/models/model-selection.md for the role's Pareto-efficient recommendations and packages/coding-agent/docs/models/evals.md for the measured per-evaluation scores by task type, then use workflow({ action: "models" }) when available to inspect the configured catalog. Pin only a returned fullId and only append a thinking level listed for that entry. If the catalog tool is unavailable, the catalog is empty, or no recommended model is present, leave the child unpinned and state the limitation rather than inventing a model. Do not inspect credentials or infer why a model is absent.
@@ -16546,6 +17147,14 @@ var ControlOverrides = Type.Object({
16546
17147
  }))
16547
17148
  });
16548
17149
  var SubagentParams = Type.Object({
17150
+ wait: Type.Optional(Type.Object({
17151
+ kind: Type.String({
17152
+ enum: ["background", "foreground"],
17153
+ description: "Wait policy kind. 'background' yields immediately; 'foreground' waits up to budgetMs."
17154
+ }),
17155
+ budgetMs: Type.Optional(Type.Number({ description: "Foreground wait budget in milliseconds (kind='foreground' only)." }))
17156
+ }, { additionalProperties: false })),
17157
+ budgetMs: Type.Optional(Type.Number({ description: "Foreground wait budget in milliseconds." })),
16549
17158
  agent: Type.Optional(Type.String({ description: "Agent name (SINGLE mode) or target for management get/update/delete" })),
16550
17159
  task: Type.Optional(Type.String({ description: "Task (SINGLE mode, optional for self-contained agents)" })),
16551
17160
  action: Type.Optional(Type.String({
@@ -16621,7 +17230,10 @@ CONTROL:
16621
17230
  • { action: "interrupt", id?: "..." } - soft-interrupt the current child turn; the child is terminal for continuation, so follow-up work starts a fresh launch`;
16622
17231
 
16623
17232
  // dist/builtin/subagents/src/extension/tool-rendering.ts
16624
- import { Container as Container3, Text as Text3 } from "@earendil-works/pi-tui";
17233
+ import { keyHintIfBound as keyHintIfBound4 } from "@bastani/atomic";
17234
+ import { Container as Container3, Text as Text4, truncateToWidth as truncateToWidth3 } from "@earendil-works/pi-tui";
17235
+ var renderRequests = new WeakMap;
17236
+ var displayText2 = (text) => text.replace(/\x1b\[[0-?]*[ -/]*[@-~]/g, "").replace(/[\x00-\x1f\x7f-\x9f]/g, " ");
16625
17237
  function effectiveParallelTaskCount(tasks) {
16626
17238
  if (!tasks || tasks.length === 0)
16627
17239
  return 0;
@@ -16631,25 +17243,88 @@ function effectiveParallelTaskCount(tasks) {
16631
17243
  }, 0);
16632
17244
  }
16633
17245
  function renderSubagentToolCall(args, theme, context) {
17246
+ renderRequests.set(context.state, args);
16634
17247
  const burst = getBurstDisplay(context.toolCallId);
16635
17248
  if (burst && !burst.owner)
16636
17249
  return new Container3;
16637
17250
  if (args.action) {
16638
- const target = args.agent || "";
16639
- return new Text3(`${theme.fg("toolTitle", theme.bold("subagent "))}${args.action}${target ? ` ${theme.fg("accent", target)}` : ""}`, 0, 0);
17251
+ const target = args.agent || args.id || args.runId || "";
17252
+ return new Text4(`${theme.fg("toolTitle", theme.bold("subagent "))}${args.action}${target ? ` ${theme.fg(args.action === "status" ? "dim" : "accent", displayText2(target))}` : ""}`, 0, 0);
16640
17253
  }
16641
17254
  if (burst) {
16642
- return new Text3(`${theme.fg("toolTitle", theme.bold("subagent "))}parallel (${burst.taskCount})`, 0, 0);
17255
+ return new Text4(`${theme.fg("toolTitle", theme.bold("subagent "))}parallel (${burst.taskCount})`, 0, 0);
16643
17256
  }
16644
17257
  const isParallel = (args.tasks?.length ?? 0) > 0;
16645
17258
  const parallelCount = effectiveParallelTaskCount(args.tasks);
16646
- return new Text3(isParallel ? `${theme.fg("toolTitle", theme.bold("subagent "))}parallel (${parallelCount})` : `${theme.fg("toolTitle", theme.bold("subagent "))}${theme.fg("accent", args.agent || "?")}`, 0, 0);
17259
+ return new Text4(isParallel ? `${theme.fg("toolTitle", theme.bold("subagent "))}parallel (${parallelCount})` : `${theme.fg("toolTitle", theme.bold("subagent "))}${theme.fg("accent", displayText2(args.agent || "?"))}${args.task ? `
17260
+ ${theme.fg("muted", displayText2(truncateToWidth3(displayText2(args.task), 100)))}` : ""}`, 0, 0);
16647
17261
  }
16648
- function renderSubagentToolResult(result2, options, theme, context) {
17262
+ function renderSubagentToolResult(result, options, theme, context) {
16649
17263
  const burst = getBurstDisplay(context.toolCallId);
16650
17264
  if (burst && !burst.owner)
16651
17265
  return new Container3;
16652
- return renderLiveSubagentResult(burst?.result ?? result2, options, theme, context);
17266
+ result = burst?.result ?? result;
17267
+ if (result.details?.taskError)
17268
+ return new Text4(theme.fg("error", `✗ ${displayText2(result.details.taskError)}`), 0, 0);
17269
+ if (result.details?.taskRecords && !result.details.taskResponse) {
17270
+ const lines = result.details.taskRecords.flatMap((task) => {
17271
+ const state = task.execution.kind === "settled" ? task.execution.result.kind : task.execution.kind;
17272
+ return [
17273
+ theme.bold(`${displayText2(task.agentName ?? "bash")} · ${state}`),
17274
+ ...task.kind === "agent" ? [
17275
+ theme.fg("dim", displayText2(formatModelThinking(task.model, task.thinking) || "model / thinking unavailable"))
17276
+ ] : [],
17277
+ theme.fg("muted", displayText2(task.title)),
17278
+ ...options.expanded ? [theme.fg("dim", task.ref.taskId)] : [],
17279
+ ...task.execution.kind === "settled" && task.execution.result.kind === "failed" ? [theme.fg("error", displayText2(task.execution.result.message))] : []
17280
+ ];
17281
+ });
17282
+ return new Text4([...lines, theme.fg("dim", "/tasks to inspect output and manage tasks")].join(`
17283
+ `), 0, 0);
17284
+ }
17285
+ const response = result.details?.taskResponse;
17286
+ const request = renderRequests.get(context.state);
17287
+ if (response) {
17288
+ const outcomes = response.kind === "parallel" ? response.slots.map((slot) => slot.outcome) : [response];
17289
+ const labels = request && !burst ? [
17290
+ ...request.agent ? [{ agent: request.agent, task: request.task ?? "" }] : [],
17291
+ ...(request.tasks ?? []).flatMap((task) => Array.from({ length: Math.min(50, Math.max(1, task.count ?? 1)) }, () => task))
17292
+ ] : [];
17293
+ const lines = outcomes.map((outcome, index) => {
17294
+ if (outcome.kind === "unstarted")
17295
+ return theme.fg("error", outcome.reason.kind === "rejected" ? `✗ ${index + 1}. Not started · ${displayText2(outcome.reason.error.message)}` : `○ ${index + 1}. Skipped`);
17296
+ const observation = outcome.observation;
17297
+ const state = observation.kind === "yielded" ? request?.action === "wait" ? "Still running in background" : "Launched in background" : observation.result.kind === "completed" ? "Completed" : observation.result.kind === "failed" ? "Failed" : "Stopped";
17298
+ const icon = observation.kind === "yielded" ? "∀" : observation.result.kind === "completed" ? "✓" : observation.result.kind === "failed" ? "✗" : "○";
17299
+ const color = observation.kind === "yielded" ? "accent" : observation.result.kind === "failed" ? "error" : observation.result.kind === "completed" ? "success" : "warning";
17300
+ const identity = labels[index];
17301
+ const name = outcomes.length > 1 ? `${index + 1}. ${identity ? displayText2(identity.agent) : "Agent"} · ` : "";
17302
+ const summary = theme.fg(color, `${icon} ${name}${state}`);
17303
+ const task = result.details?.taskRecords?.find((task) => task.ref.taskId === observation.taskId);
17304
+ const model = theme.fg("dim", `
17305
+ ${displayText2(formatModelThinking(task?.model, task?.thinking) || "model / thinking unavailable")}`);
17306
+ const metadata = options.expanded ? theme.fg("dim", `
17307
+ ${observation.taskId}${identity?.task ? ` · ${displayText2(identity.task)}` : ""}`) : "";
17308
+ const error = observation.kind === "settled" && observation.result.kind === "failed" ? `
17309
+ ${theme.fg("error", displayText2(observation.result.message))}` : "";
17310
+ return summary + model + metadata + error;
17311
+ });
17312
+ const heading = outcomes.length > 1 ? [theme.bold(`${outcomes.length} agent tasks`)] : [];
17313
+ return new Text4([
17314
+ ...heading,
17315
+ ...lines.map((line, index) => outcomes.length > 1 ? `${index === lines.length - 1 ? "└─" : "├─"} ${line}` : line),
17316
+ theme.fg("dim", "/tasks to inspect output and manage tasks")
17317
+ ].join(`
17318
+ `), 0, 0);
17319
+ }
17320
+ const text = result.content.find((part) => part.type === "text");
17321
+ if (text?.type === "text" && text.text.startsWith("Executable agents:")) {
17322
+ const count = text.text.split(`
17323
+ `).filter((line) => line.startsWith("- ") && line !== "- (none)").length;
17324
+ return new Text4(options.expanded ? text.text : `${theme.bold(`${count} available agents`)}
17325
+ ${theme.fg("dim", ["/agents to browse", keyHintIfBound4("app.tools.expand", "Expand")].filter(Boolean).map((hint, index) => index ? `(${hint})` : hint).join(" · "))}`, 0, 0);
17326
+ }
17327
+ return renderLiveSubagentResult(burst?.result ?? result, options, theme, context);
16653
17328
  }
16654
17329
  // dist/builtin/subagents/src/extension/api-lifecycle.ts
16655
17330
  function getWeakMap(key) {
@@ -16861,18 +17536,18 @@ function getSubagentSessionRoot(parentSessionFile) {
16861
17536
  function expandTilde2(p) {
16862
17537
  return p.startsWith("~/") ? path23.join(os8.homedir(), p.slice(2)) : p;
16863
17538
  }
16864
- function isSlashResultRunning(result2) {
16865
- return result2.details?.progress?.some((entry) => entry.status === "running") || result2.details?.results.some((entry) => entry.progress?.status === "running") || false;
17539
+ function isSlashResultRunning(result) {
17540
+ return result.details?.progress?.some((entry) => entry.status === "running") || result.details?.results.some((entry) => entry.progress?.status === "running") || false;
16866
17541
  }
16867
- function isSlashResultError(result2) {
16868
- return result2.details?.results.some((entry) => entry.status === "error" && entry.progress?.status !== "running") || false;
17542
+ function isSlashResultError(result) {
17543
+ return result.details?.results.some((entry) => entry.status === "error" && entry.progress?.status !== "running") || false;
16869
17544
  }
16870
- function rebuildSlashResultContainer(container, result2, options, theme) {
17545
+ function rebuildSlashResultContainer(container, result, options, theme) {
16871
17546
  container.clear();
16872
17547
  container.addChild(new Spacer2(1));
16873
- const boxTheme = isSlashResultRunning(result2) ? "toolPendingBg" : isSlashResultError(result2) ? "toolErrorBg" : "toolSuccessBg";
17548
+ const boxTheme = isSlashResultRunning(result) ? "toolPendingBg" : isSlashResultError(result) ? "toolErrorBg" : "toolSuccessBg";
16874
17549
  const box = new Box(1, 1, (text) => theme.bg(boxTheme, text));
16875
- box.addChild(renderSubagentResult(result2, options, theme));
17550
+ box.addChild(renderSubagentResult(result, options, theme));
16876
17551
  container.addChild(box);
16877
17552
  }
16878
17553
  function createSlashResultComponent(details, options, theme, owner) {
@@ -16896,7 +17571,7 @@ function renderSubagentNotification(message, options, theme) {
16896
17571
  const content = typeof message.content === "string" ? message.content : "";
16897
17572
  const details = message.details ?? parseSubagentNotifyContent(content);
16898
17573
  if (!details)
16899
- return new Text4(content, 0, 0);
17574
+ return new Text5(content, 0, 0);
16900
17575
  const icon = details.status === "completed" ? theme.fg("success", "✓") : details.status === "interrupted" ? theme.fg("warning", "■") : theme.fg("error", "✗");
16901
17576
  const parts = [];
16902
17577
  if (details.taskInfo)
@@ -16916,7 +17591,7 @@ function renderSubagentNotification(message, options, theme) {
16916
17591
  }
16917
17592
  if (!options.expanded && trimmedPreview.includes(`
16918
17593
  `)) {
16919
- const expandHint = keyHintIfBound3("app.tools.expand", "full notification");
17594
+ const expandHint = keyHintIfBound5("app.tools.expand", "full notification");
16920
17595
  if (expandHint)
16921
17596
  text += `
16922
17597
  ${expandHint}`;
@@ -16929,7 +17604,7 @@ function renderSubagentNotification(message, options, theme) {
16929
17604
  container.addChild(new Spacer2(1));
16930
17605
  const boxTheme = details.status === "completed" ? "toolSuccessBg" : details.status === "failed" ? "toolErrorBg" : "toolPendingBg";
16931
17606
  const box = new Box(1, 1, (line) => theme.bg(boxTheme, line));
16932
- box.addChild(new Text4(text, 0, 0));
17607
+ box.addChild(new Text5(text, 0, 0));
16933
17608
  container.addChild(box);
16934
17609
  return container;
16935
17610
  }
@@ -16945,16 +17620,16 @@ class SubagentControlNoticeComponent {
16945
17620
  render(width) {
16946
17621
  const eventLabel = this.details.event.type.replaceAll("_", " ");
16947
17622
  if (width < 3)
16948
- return [truncateToWidth(`Subagent ${eventLabel}`, width)];
17623
+ return [truncateToWidth4(`Subagent ${eventLabel}`, width)];
16949
17624
  const bodyWidth = Math.max(1, width - 2);
16950
17625
  const borderChar = "─";
16951
17626
  const header = ` ⚠ Subagent ${eventLabel}: ${this.details.event.agent} `;
16952
- const headerText = truncateToWidth(header, bodyWidth, "");
16953
- const headerPadding = Math.max(0, bodyWidth - visibleWidth2(headerText));
17627
+ const headerText = truncateToWidth4(header, bodyWidth, "");
17628
+ const headerPadding = Math.max(0, bodyWidth - visibleWidth4(headerText));
16954
17629
  const lines = [this.theme.fg("accent", `╭${headerText}${borderChar.repeat(headerPadding)}╮`)];
16955
- for (const line of wrapTextWithAnsi(formatSubagentControlNotice(this.details), bodyWidth)) {
16956
- const text = truncateToWidth(line, bodyWidth, "");
16957
- const padding = Math.max(0, bodyWidth - visibleWidth2(text));
17630
+ for (const line of wrapTextWithAnsi2(formatSubagentControlNotice(this.details), bodyWidth)) {
17631
+ const text = truncateToWidth4(line, bodyWidth, "");
17632
+ const padding = Math.max(0, bodyWidth - visibleWidth4(text));
16958
17633
  lines.push(this.theme.fg("accent", `│${text}${" ".repeat(padding)}│`));
16959
17634
  }
16960
17635
  lines.push(this.theme.fg("accent", `╰${borderChar.repeat(bodyWidth)}╯`));
@@ -17072,8 +17747,8 @@ function registerSubagentExtension(pi) {
17072
17747
  renderCall(args, theme, context) {
17073
17748
  return renderSubagentToolCall(args, theme, context);
17074
17749
  },
17075
- renderResult(result2, options, theme, context) {
17076
- return renderSubagentToolResult(result2, options, theme, context);
17750
+ renderResult(result, options, theme, context) {
17751
+ return renderSubagentToolResult(result, options, theme, context);
17077
17752
  }
17078
17753
  };
17079
17754
  pi.registerTool(tool);