@ashx-j/lunr 0.2.20 → 0.2.22

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 (528) hide show
  1. package/CHANGELOG.md +14 -2
  2. package/README.md +20 -4
  3. package/dist/builtin-extensions/index.d.ts.map +1 -1
  4. package/dist/builtin-extensions/index.js +1 -0
  5. package/dist/builtin-extensions/index.js.map +1 -1
  6. package/dist/builtin-extensions/lunr-browser.d.ts +3 -0
  7. package/dist/builtin-extensions/lunr-browser.d.ts.map +1 -0
  8. package/dist/builtin-extensions/lunr-browser.js +56 -0
  9. package/dist/builtin-extensions/lunr-browser.js.map +1 -0
  10. package/dist/builtin-extensions/lunr-todos.d.ts +6 -5
  11. package/dist/builtin-extensions/lunr-todos.d.ts.map +1 -1
  12. package/dist/builtin-extensions/lunr-todos.js +24 -7
  13. package/dist/builtin-extensions/lunr-todos.js.map +1 -1
  14. package/dist/builtin-extensions/pi-intercom/broker/spawn.d.ts.map +1 -1
  15. package/dist/builtin-extensions/pi-intercom/broker/spawn.js +30 -21
  16. package/dist/builtin-extensions/pi-intercom/broker/spawn.js.map +1 -1
  17. package/dist/builtin-extensions/pi-intercom/index.d.ts.map +1 -1
  18. package/dist/builtin-extensions/pi-intercom/index.js +15 -3
  19. package/dist/builtin-extensions/pi-intercom/index.js.map +1 -1
  20. package/dist/builtin-extensions/pi-subagents/src/extension/control-notices.d.ts +1 -1
  21. package/dist/builtin-extensions/pi-subagents/src/extension/control-notices.d.ts.map +1 -1
  22. package/dist/builtin-extensions/pi-subagents/src/extension/control-notices.js +5 -1
  23. package/dist/builtin-extensions/pi-subagents/src/extension/control-notices.js.map +1 -1
  24. package/dist/builtin-extensions/pi-subagents/src/extension/fanout-child.d.ts.map +1 -1
  25. package/dist/builtin-extensions/pi-subagents/src/extension/fanout-child.js +2 -2
  26. package/dist/builtin-extensions/pi-subagents/src/extension/fanout-child.js.map +1 -1
  27. package/dist/builtin-extensions/pi-subagents/src/extension/index.d.ts +8 -7
  28. package/dist/builtin-extensions/pi-subagents/src/extension/index.d.ts.map +1 -1
  29. package/dist/builtin-extensions/pi-subagents/src/extension/index.js +78 -31
  30. package/dist/builtin-extensions/pi-subagents/src/extension/index.js.map +1 -1
  31. package/dist/builtin-extensions/pi-subagents/src/extension/schemas.d.ts.map +1 -1
  32. package/dist/builtin-extensions/pi-subagents/src/extension/schemas.js +2 -2
  33. package/dist/builtin-extensions/pi-subagents/src/extension/schemas.js.map +1 -1
  34. package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.d.ts +4 -3
  35. package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.d.ts.map +1 -1
  36. package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.js +6 -2
  37. package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.js.map +1 -1
  38. package/dist/builtin-extensions/pi-subagents/src/intercom/communication.d.ts +17 -0
  39. package/dist/builtin-extensions/pi-subagents/src/intercom/communication.d.ts.map +1 -0
  40. package/dist/builtin-extensions/pi-subagents/src/intercom/communication.js +45 -0
  41. package/dist/builtin-extensions/pi-subagents/src/intercom/communication.js.map +1 -0
  42. package/dist/builtin-extensions/pi-subagents/src/intercom/intercom-bridge.d.ts.map +1 -1
  43. package/dist/builtin-extensions/pi-subagents/src/intercom/intercom-bridge.js +4 -11
  44. package/dist/builtin-extensions/pi-subagents/src/intercom/intercom-bridge.js.map +1 -1
  45. package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.d.ts +5 -1
  46. package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.d.ts.map +1 -1
  47. package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.js +186 -58
  48. package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.js.map +1 -1
  49. package/dist/builtin-extensions/pi-subagents/src/intercom/result-intercom.d.ts +1 -0
  50. package/dist/builtin-extensions/pi-subagents/src/intercom/result-intercom.d.ts.map +1 -1
  51. package/dist/builtin-extensions/pi-subagents/src/intercom/result-intercom.js +1 -1
  52. package/dist/builtin-extensions/pi-subagents/src/intercom/result-intercom.js.map +1 -1
  53. package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-ask.d.ts.map +1 -1
  54. package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-ask.js +5 -0
  55. package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-ask.js.map +1 -1
  56. package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-questions.d.ts +2 -0
  57. package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-questions.d.ts.map +1 -1
  58. package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-questions.js +3 -2
  59. package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-questions.js.map +1 -1
  60. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.d.ts +2 -0
  61. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.d.ts.map +1 -1
  62. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.js +4 -3
  63. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.js.map +1 -1
  64. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-job-tracker.d.ts.map +1 -1
  65. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-job-tracker.js +2 -0
  66. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-job-tracker.js.map +1 -1
  67. package/dist/builtin-extensions/pi-subagents/src/runs/background/auto-drain.d.ts +1 -0
  68. package/dist/builtin-extensions/pi-subagents/src/runs/background/auto-drain.d.ts.map +1 -1
  69. package/dist/builtin-extensions/pi-subagents/src/runs/background/auto-drain.js +2 -1
  70. package/dist/builtin-extensions/pi-subagents/src/runs/background/auto-drain.js.map +1 -1
  71. package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.d.ts +6 -2
  72. package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.d.ts.map +1 -1
  73. package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.js +23 -1
  74. package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.js.map +1 -1
  75. package/dist/builtin-extensions/pi-subagents/src/runs/background/result-watcher.d.ts.map +1 -1
  76. package/dist/builtin-extensions/pi-subagents/src/runs/background/result-watcher.js +1 -0
  77. package/dist/builtin-extensions/pi-subagents/src/runs/background/result-watcher.js.map +1 -1
  78. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.d.ts +100 -0
  79. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.d.ts.map +1 -1
  80. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.js +46 -31
  81. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.js.map +1 -1
  82. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.d.ts +1 -0
  83. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.d.ts.map +1 -1
  84. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.js +2 -0
  85. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.js.map +1 -1
  86. package/dist/builtin-extensions/pi-subagents/src/runs/background/top-level-async.d.ts +15 -2
  87. package/dist/builtin-extensions/pi-subagents/src/runs/background/top-level-async.d.ts.map +1 -1
  88. package/dist/builtin-extensions/pi-subagents/src/runs/background/top-level-async.js +14 -4
  89. package/dist/builtin-extensions/pi-subagents/src/runs/background/top-level-async.js.map +1 -1
  90. package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.d.ts.map +1 -1
  91. package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.js +1 -1
  92. package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.js.map +1 -1
  93. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.d.ts.map +1 -1
  94. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.js +1 -1
  95. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.js.map +1 -1
  96. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.d.ts +0 -1
  97. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.d.ts.map +1 -1
  98. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js +9 -9
  99. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js.map +1 -1
  100. package/dist/builtin-extensions/pi-subagents/src/runs/shared/completion-guard.d.ts +1 -1
  101. package/dist/builtin-extensions/pi-subagents/src/runs/shared/completion-guard.d.ts.map +1 -1
  102. package/dist/builtin-extensions/pi-subagents/src/runs/shared/completion-guard.js +1 -1
  103. package/dist/builtin-extensions/pi-subagents/src/runs/shared/completion-guard.js.map +1 -1
  104. package/dist/builtin-extensions/pi-subagents/src/runs/shared/parallel-utils.d.ts +1 -0
  105. package/dist/builtin-extensions/pi-subagents/src/runs/shared/parallel-utils.d.ts.map +1 -1
  106. package/dist/builtin-extensions/pi-subagents/src/runs/shared/parallel-utils.js.map +1 -1
  107. package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.d.ts +3 -0
  108. package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.d.ts.map +1 -1
  109. package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.js +5 -0
  110. package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.js.map +1 -1
  111. package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-control.d.ts +1 -0
  112. package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-control.d.ts.map +1 -1
  113. package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-control.js +3 -0
  114. package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-control.js.map +1 -1
  115. package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.d.ts.map +1 -1
  116. package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.js +1 -1
  117. package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.js.map +1 -1
  118. package/dist/builtin-extensions/pi-subagents/src/runs/shared/task-intent.d.ts +2 -2
  119. package/dist/builtin-extensions/pi-subagents/src/runs/shared/task-intent.d.ts.map +1 -1
  120. package/dist/builtin-extensions/pi-subagents/src/runs/shared/task-intent.js +5 -10
  121. package/dist/builtin-extensions/pi-subagents/src/runs/shared/task-intent.js.map +1 -1
  122. package/dist/builtin-extensions/pi-subagents/src/shared/async-guidance.d.ts +2 -0
  123. package/dist/builtin-extensions/pi-subagents/src/shared/async-guidance.d.ts.map +1 -0
  124. package/dist/builtin-extensions/pi-subagents/src/shared/async-guidance.js +3 -0
  125. package/dist/builtin-extensions/pi-subagents/src/shared/async-guidance.js.map +1 -0
  126. package/dist/builtin-extensions/pi-subagents/src/shared/types.d.ts +6 -0
  127. package/dist/builtin-extensions/pi-subagents/src/shared/types.d.ts.map +1 -1
  128. package/dist/builtin-extensions/pi-subagents/src/shared/types.js.map +1 -1
  129. package/dist/builtin-extensions/pi-subagents/src/slash/delegation-adapters.d.ts.map +1 -1
  130. package/dist/builtin-extensions/pi-subagents/src/slash/delegation-adapters.js.map +1 -1
  131. package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.d.ts +7 -0
  132. package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.d.ts.map +1 -1
  133. package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.js +11 -7
  134. package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.js.map +1 -1
  135. package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.d.ts +4 -0
  136. package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.d.ts.map +1 -1
  137. package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.js +22 -23
  138. package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.js.map +1 -1
  139. package/dist/builtin-extensions/pi-subagents/src/tui/communication.d.ts +18 -0
  140. package/dist/builtin-extensions/pi-subagents/src/tui/communication.d.ts.map +1 -0
  141. package/dist/builtin-extensions/pi-subagents/src/tui/communication.js +47 -0
  142. package/dist/builtin-extensions/pi-subagents/src/tui/communication.js.map +1 -0
  143. package/dist/builtin-extensions/pi-subagents/src/tui/render.d.ts +2 -0
  144. package/dist/builtin-extensions/pi-subagents/src/tui/render.d.ts.map +1 -1
  145. package/dist/builtin-extensions/pi-subagents/src/tui/render.js +237 -374
  146. package/dist/builtin-extensions/pi-subagents/src/tui/render.js.map +1 -1
  147. package/dist/builtin-extensions/pi-web-access/index.d.ts.map +1 -1
  148. package/dist/builtin-extensions/pi-web-access/index.js +11 -7
  149. package/dist/builtin-extensions/pi-web-access/index.js.map +1 -1
  150. package/dist/cli/args.d.ts.map +1 -1
  151. package/dist/cli/args.js +2 -1
  152. package/dist/cli/args.js.map +1 -1
  153. package/dist/cli/install-cli.d.ts.map +1 -1
  154. package/dist/cli/install-cli.js +15 -45
  155. package/dist/cli/install-cli.js.map +1 -1
  156. package/dist/core/agent-session-runtime.d.ts +9 -0
  157. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  158. package/dist/core/agent-session-runtime.js +126 -29
  159. package/dist/core/agent-session-runtime.js.map +1 -1
  160. package/dist/core/agent-session.d.ts +3 -0
  161. package/dist/core/agent-session.d.ts.map +1 -1
  162. package/dist/core/agent-session.js +20 -2
  163. package/dist/core/agent-session.js.map +1 -1
  164. package/dist/core/browser/network.d.ts +9 -0
  165. package/dist/core/browser/network.d.ts.map +1 -0
  166. package/dist/core/browser/network.js +146 -0
  167. package/dist/core/browser/network.js.map +1 -0
  168. package/dist/core/browser/runtime.d.ts +24 -0
  169. package/dist/core/browser/runtime.d.ts.map +1 -0
  170. package/dist/core/browser/runtime.js +289 -0
  171. package/dist/core/browser/runtime.js.map +1 -0
  172. package/dist/core/browser/schema.d.ts +16 -0
  173. package/dist/core/browser/schema.d.ts.map +1 -0
  174. package/dist/core/browser/schema.js +36 -0
  175. package/dist/core/browser/schema.js.map +1 -0
  176. package/dist/core/browser/settings.d.ts +8 -0
  177. package/dist/core/browser/settings.d.ts.map +1 -0
  178. package/dist/core/browser/settings.js +30 -0
  179. package/dist/core/browser/settings.js.map +1 -0
  180. package/dist/core/browser/setup.d.ts +2 -0
  181. package/dist/core/browser/setup.d.ts.map +1 -0
  182. package/dist/core/browser/setup.js +16 -0
  183. package/dist/core/browser/setup.js.map +1 -0
  184. package/dist/core/customize.d.ts +2 -0
  185. package/dist/core/customize.d.ts.map +1 -1
  186. package/dist/core/customize.js +17 -13
  187. package/dist/core/customize.js.map +1 -1
  188. package/dist/core/export-html/index.d.ts.map +1 -1
  189. package/dist/core/export-html/index.js +1 -1
  190. package/dist/core/export-html/index.js.map +1 -1
  191. package/dist/core/extensions/runner.d.ts +1 -0
  192. package/dist/core/extensions/runner.d.ts.map +1 -1
  193. package/dist/core/extensions/runner.js +1 -1
  194. package/dist/core/extensions/runner.js.map +1 -1
  195. package/dist/core/extensions/types.d.ts +1 -1
  196. package/dist/core/extensions/types.d.ts.map +1 -1
  197. package/dist/core/extensions/types.js.map +1 -1
  198. package/dist/core/install-features.d.ts.map +1 -1
  199. package/dist/core/install-features.js +10 -8
  200. package/dist/core/install-features.js.map +1 -1
  201. package/dist/core/memory-cap.d.ts.map +1 -1
  202. package/dist/core/memory-cap.js +5 -3
  203. package/dist/core/memory-cap.js.map +1 -1
  204. package/dist/core/model-tiers.d.ts.map +1 -1
  205. package/dist/core/model-tiers.js +9 -6
  206. package/dist/core/model-tiers.js.map +1 -1
  207. package/dist/core/permissions.d.ts.map +1 -1
  208. package/dist/core/permissions.js +9 -0
  209. package/dist/core/permissions.js.map +1 -1
  210. package/dist/core/plan-mode.d.ts.map +1 -1
  211. package/dist/core/plan-mode.js +3 -0
  212. package/dist/core/plan-mode.js.map +1 -1
  213. package/dist/core/process-registry.d.ts.map +1 -1
  214. package/dist/core/process-registry.js +6 -4
  215. package/dist/core/process-registry.js.map +1 -1
  216. package/dist/core/runtime-scope.d.ts +11 -0
  217. package/dist/core/runtime-scope.d.ts.map +1 -0
  218. package/dist/core/runtime-scope.js +3 -0
  219. package/dist/core/runtime-scope.js.map +1 -0
  220. package/dist/core/sdk.d.ts.map +1 -1
  221. package/dist/core/sdk.js +13 -0
  222. package/dist/core/sdk.js.map +1 -1
  223. package/dist/core/session-handoff.d.ts +35 -0
  224. package/dist/core/session-handoff.d.ts.map +1 -0
  225. package/dist/core/session-handoff.js +214 -0
  226. package/dist/core/session-handoff.js.map +1 -0
  227. package/dist/core/session-manager.d.ts +20 -0
  228. package/dist/core/session-manager.d.ts.map +1 -1
  229. package/dist/core/session-manager.js +184 -22
  230. package/dist/core/session-manager.js.map +1 -1
  231. package/dist/core/session-ownership.d.ts +28 -0
  232. package/dist/core/session-ownership.d.ts.map +1 -0
  233. package/dist/core/session-ownership.js +138 -0
  234. package/dist/core/session-ownership.js.map +1 -0
  235. package/dist/core/session-retention.d.ts.map +1 -1
  236. package/dist/core/session-retention.js +11 -2
  237. package/dist/core/session-retention.js.map +1 -1
  238. package/dist/core/settings-manager.d.ts +11 -0
  239. package/dist/core/settings-manager.d.ts.map +1 -1
  240. package/dist/core/settings-manager.js +29 -0
  241. package/dist/core/settings-manager.js.map +1 -1
  242. package/dist/core/slash-commands.d.ts.map +1 -1
  243. package/dist/core/slash-commands.js +2 -0
  244. package/dist/core/slash-commands.js.map +1 -1
  245. package/dist/core/subagent-spinner-setting.d.ts +6 -0
  246. package/dist/core/subagent-spinner-setting.d.ts.map +1 -0
  247. package/dist/core/subagent-spinner-setting.js +12 -0
  248. package/dist/core/subagent-spinner-setting.js.map +1 -0
  249. package/dist/core/subagent-spinner.d.ts +4 -0
  250. package/dist/core/subagent-spinner.d.ts.map +1 -0
  251. package/dist/core/subagent-spinner.js +6 -0
  252. package/dist/core/subagent-spinner.js.map +1 -0
  253. package/dist/core/system-prompt.d.ts.map +1 -1
  254. package/dist/core/system-prompt.js +5 -2
  255. package/dist/core/system-prompt.js.map +1 -1
  256. package/dist/core/todo-settings.d.ts +5 -0
  257. package/dist/core/todo-settings.d.ts.map +1 -0
  258. package/dist/core/todo-settings.js +7 -0
  259. package/dist/core/todo-settings.js.map +1 -0
  260. package/dist/core/tools/bash.d.ts.map +1 -1
  261. package/dist/core/tools/bash.js +4 -4
  262. package/dist/core/tools/bash.js.map +1 -1
  263. package/dist/core/tools/edit.d.ts.map +1 -1
  264. package/dist/core/tools/edit.js +5 -3
  265. package/dist/core/tools/edit.js.map +1 -1
  266. package/dist/core/tools/find.d.ts.map +1 -1
  267. package/dist/core/tools/find.js +4 -4
  268. package/dist/core/tools/find.js.map +1 -1
  269. package/dist/core/tools/grep.d.ts.map +1 -1
  270. package/dist/core/tools/grep.js +4 -4
  271. package/dist/core/tools/grep.js.map +1 -1
  272. package/dist/core/tools/ls.d.ts.map +1 -1
  273. package/dist/core/tools/ls.js +4 -4
  274. package/dist/core/tools/ls.js.map +1 -1
  275. package/dist/core/tools/read.d.ts.map +1 -1
  276. package/dist/core/tools/read.js +4 -4
  277. package/dist/core/tools/read.js.map +1 -1
  278. package/dist/core/tools/render-utils.d.ts +11 -2
  279. package/dist/core/tools/render-utils.d.ts.map +1 -1
  280. package/dist/core/tools/render-utils.js +31 -4
  281. package/dist/core/tools/render-utils.js.map +1 -1
  282. package/dist/core/tools/write.d.ts.map +1 -1
  283. package/dist/core/tools/write.js +4 -4
  284. package/dist/core/tools/write.js.map +1 -1
  285. package/dist/core/usage-service.d.ts.map +1 -1
  286. package/dist/core/usage-service.js +5 -3
  287. package/dist/core/usage-service.js.map +1 -1
  288. package/dist/gateway/adapters/discord.d.ts +12 -1
  289. package/dist/gateway/adapters/discord.d.ts.map +1 -1
  290. package/dist/gateway/adapters/discord.js +112 -17
  291. package/dist/gateway/adapters/discord.js.map +1 -1
  292. package/dist/gateway/adapters/telegram.d.ts +4 -2
  293. package/dist/gateway/adapters/telegram.d.ts.map +1 -1
  294. package/dist/gateway/adapters/telegram.js +34 -11
  295. package/dist/gateway/adapters/telegram.js.map +1 -1
  296. package/dist/gateway/agent-bridge.d.ts +14 -3
  297. package/dist/gateway/agent-bridge.d.ts.map +1 -1
  298. package/dist/gateway/agent-bridge.js +252 -60
  299. package/dist/gateway/agent-bridge.js.map +1 -1
  300. package/dist/gateway/approval.d.ts +1 -0
  301. package/dist/gateway/approval.d.ts.map +1 -1
  302. package/dist/gateway/approval.js +60 -18
  303. package/dist/gateway/approval.js.map +1 -1
  304. package/dist/gateway/authz.d.ts +2 -0
  305. package/dist/gateway/authz.d.ts.map +1 -1
  306. package/dist/gateway/authz.js +13 -0
  307. package/dist/gateway/authz.js.map +1 -1
  308. package/dist/gateway/buttons.d.ts +3 -1
  309. package/dist/gateway/buttons.d.ts.map +1 -1
  310. package/dist/gateway/buttons.js +18 -3
  311. package/dist/gateway/buttons.js.map +1 -1
  312. package/dist/gateway/command.d.ts.map +1 -1
  313. package/dist/gateway/command.js +49 -4
  314. package/dist/gateway/command.js.map +1 -1
  315. package/dist/gateway/commands.d.ts.map +1 -1
  316. package/dist/gateway/commands.js +18 -3
  317. package/dist/gateway/commands.js.map +1 -1
  318. package/dist/gateway/config.d.ts +5 -0
  319. package/dist/gateway/config.d.ts.map +1 -1
  320. package/dist/gateway/config.js +5 -0
  321. package/dist/gateway/config.js.map +1 -1
  322. package/dist/gateway/conversations.d.ts +14 -0
  323. package/dist/gateway/conversations.d.ts.map +1 -0
  324. package/dist/gateway/conversations.js +30 -0
  325. package/dist/gateway/conversations.js.map +1 -0
  326. package/dist/gateway/download.d.ts +2 -0
  327. package/dist/gateway/download.d.ts.map +1 -0
  328. package/dist/gateway/download.js +36 -0
  329. package/dist/gateway/download.js.map +1 -0
  330. package/dist/gateway/index.d.ts.map +1 -1
  331. package/dist/gateway/index.js +85 -26
  332. package/dist/gateway/index.js.map +1 -1
  333. package/dist/gateway/mobile-commands.d.ts +24 -0
  334. package/dist/gateway/mobile-commands.d.ts.map +1 -0
  335. package/dist/gateway/mobile-commands.js +422 -0
  336. package/dist/gateway/mobile-commands.js.map +1 -0
  337. package/dist/gateway/presenter.d.ts +16 -0
  338. package/dist/gateway/presenter.d.ts.map +1 -0
  339. package/dist/gateway/presenter.js +210 -0
  340. package/dist/gateway/presenter.js.map +1 -0
  341. package/dist/gateway/router.d.ts +1 -0
  342. package/dist/gateway/router.d.ts.map +1 -1
  343. package/dist/gateway/router.js +32 -3
  344. package/dist/gateway/router.js.map +1 -1
  345. package/dist/gateway/service.d.ts +46 -0
  346. package/dist/gateway/service.d.ts.map +1 -0
  347. package/dist/gateway/service.js +395 -0
  348. package/dist/gateway/service.js.map +1 -0
  349. package/dist/gateway/setup.d.ts +4 -0
  350. package/dist/gateway/setup.d.ts.map +1 -0
  351. package/dist/gateway/setup.js +146 -0
  352. package/dist/gateway/setup.js.map +1 -0
  353. package/dist/gateway/types.d.ts +4 -2
  354. package/dist/gateway/types.d.ts.map +1 -1
  355. package/dist/gateway/types.js.map +1 -1
  356. package/dist/index.d.ts +2 -0
  357. package/dist/index.d.ts.map +1 -1
  358. package/dist/index.js +2 -0
  359. package/dist/index.js.map +1 -1
  360. package/dist/main.d.ts.map +1 -1
  361. package/dist/main.js +2 -1
  362. package/dist/main.js.map +1 -1
  363. package/dist/modes/interactive/components/assistant-message.d.ts +11 -2
  364. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  365. package/dist/modes/interactive/components/assistant-message.js +53 -16
  366. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  367. package/dist/modes/interactive/components/copyable-text.d.ts +31 -0
  368. package/dist/modes/interactive/components/copyable-text.d.ts.map +1 -0
  369. package/dist/modes/interactive/components/copyable-text.js +165 -0
  370. package/dist/modes/interactive/components/copyable-text.js.map +1 -0
  371. package/dist/modes/interactive/components/custom-entry.d.ts +1 -0
  372. package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -1
  373. package/dist/modes/interactive/components/custom-entry.js +8 -0
  374. package/dist/modes/interactive/components/custom-entry.js.map +1 -1
  375. package/dist/modes/interactive/components/custom-message.d.ts +1 -0
  376. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  377. package/dist/modes/interactive/components/custom-message.js +8 -0
  378. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  379. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  380. package/dist/modes/interactive/components/session-selector.js +16 -0
  381. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  382. package/dist/modes/interactive/components/settings-selector.d.ts +9 -0
  383. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  384. package/dist/modes/interactive/components/settings-selector.js +111 -1
  385. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  386. package/dist/modes/interactive/extension-widget-order.d.ts +8 -0
  387. package/dist/modes/interactive/extension-widget-order.d.ts.map +1 -0
  388. package/dist/modes/interactive/extension-widget-order.js +37 -0
  389. package/dist/modes/interactive/extension-widget-order.js.map +1 -0
  390. package/dist/modes/interactive/interactive-mode.d.ts +3 -0
  391. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  392. package/dist/modes/interactive/interactive-mode.js +166 -29
  393. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  394. package/dist/node-runtime/agent-session-services-NQ6GKOIK.js +49 -0
  395. package/dist/node-runtime/{builtin-extensions-X4JMM4ZS.js → builtin-extensions-GVC6IFDU.js} +6 -4
  396. package/dist/node-runtime/{chunk-LTYWTR3V.js → chunk-2MI5OPMN.js} +17 -2
  397. package/dist/node-runtime/{chunk-W3CVH5RX.js → chunk-2TKODGBZ.js} +11 -6
  398. package/dist/node-runtime/chunk-4EULYYR4.js +62 -0
  399. package/dist/node-runtime/chunk-5BNJ4JUH.js +672 -0
  400. package/dist/node-runtime/{chunk-6N22HULO.js → chunk-5D7LC2ZQ.js} +7 -2
  401. package/dist/node-runtime/chunk-5ZH3ZFIZ.js +308 -0
  402. package/dist/node-runtime/{chunk-KBKMCJDU.js → chunk-5ZQXRPMC.js} +19 -4
  403. package/dist/node-runtime/{chunk-6KDIOJL3.js → chunk-6427XAWG.js} +3 -3
  404. package/dist/node-runtime/{chunk-BOHIDQT4.js → chunk-6B2POMK7.js} +1 -1
  405. package/dist/node-runtime/{chunk-RNBHABBA.js → chunk-7QWNYZDI.js} +7 -0
  406. package/dist/node-runtime/chunk-AZJHNQKQ.js +205 -0
  407. package/dist/node-runtime/chunk-BFNXONG3.js +521 -0
  408. package/dist/node-runtime/{chunk-IRPJXI6U.js → chunk-BX2RB477.js} +1 -1
  409. package/dist/node-runtime/chunk-CCCN2UCX.js +14 -0
  410. package/dist/node-runtime/{chunk-25I2BHAA.js → chunk-CSUZVNYE.js} +1 -1
  411. package/dist/node-runtime/{chunk-QZMODZQ2.js → chunk-E24EO34J.js} +2 -1
  412. package/dist/node-runtime/{chunk-QKFMBRAL.js → chunk-EQ63ANHL.js} +508 -140
  413. package/dist/node-runtime/{chunk-ELWEXVO5.js → chunk-GJSAD4AB.js} +216 -201
  414. package/dist/node-runtime/{chunk-AOFXZQKA.js → chunk-GMHJCCEN.js} +8 -8
  415. package/dist/node-runtime/{chunk-DDWHZ633.js → chunk-GNN7H3B7.js} +1 -1
  416. package/dist/node-runtime/chunk-GS66LV4M.js +2830 -0
  417. package/dist/node-runtime/{chunk-6BEIBLQ3.js → chunk-H3XF4UVQ.js} +1 -1
  418. package/dist/node-runtime/chunk-H4K3JDRB.js +47 -0
  419. package/dist/node-runtime/{chunk-AROOY4BB.js → chunk-HTFRRDSF.js} +2 -7
  420. package/dist/node-runtime/chunk-IMLCWLPI.js +9 -0
  421. package/dist/node-runtime/{chunk-4CSFRBCN.js → chunk-IQIEU7SB.js} +9 -674
  422. package/dist/node-runtime/{chunk-OPEK5RRY.js → chunk-IVXYUAJE.js} +1 -1
  423. package/dist/node-runtime/{chunk-AL2FMKKM.js → chunk-IWOWXRWU.js} +58 -48
  424. package/dist/node-runtime/chunk-KKUTQQV7.js +144 -0
  425. package/dist/node-runtime/chunk-LISUTZS3.js +19 -0
  426. package/dist/node-runtime/{chunk-K3646JTM.js → chunk-LMBNLFXQ.js} +25 -314
  427. package/dist/node-runtime/{chunk-7NBZ5P7I.js → chunk-NAY6UUQZ.js} +1 -1
  428. package/dist/node-runtime/chunk-OAR4TYZE.js +146 -0
  429. package/dist/node-runtime/{chunk-STERBGUB.js → chunk-OFKSVRV7.js} +2 -2
  430. package/dist/node-runtime/{chunk-JZQ7F36T.js → chunk-ORH324EP.js} +19 -3
  431. package/dist/node-runtime/{chunk-2SJB2AWP.js → chunk-PC2Z5TKZ.js} +3 -3
  432. package/dist/node-runtime/{chunk-46ECNOLF.js → chunk-QDGKKKUM.js} +97 -162
  433. package/dist/node-runtime/chunk-R3K2F5GI.js +122 -0
  434. package/dist/node-runtime/chunk-RMQZU2YU.js +117 -0
  435. package/dist/node-runtime/{chunk-JYNNB7DU.js → chunk-TDL7UWJ7.js} +283 -2999
  436. package/dist/node-runtime/{chunk-G6LRAP36.js → chunk-TQGPP4SC.js} +1 -1
  437. package/dist/node-runtime/chunk-UAEOTO52.js +119 -0
  438. package/dist/node-runtime/{chunk-4DJ6HEGH.js → chunk-UAFLNHSH.js} +18 -14
  439. package/dist/node-runtime/{chunk-AY6CAJSL.js → chunk-UJOCPOMX.js} +6 -3
  440. package/dist/node-runtime/chunk-UP2XBVH5.js +40 -0
  441. package/dist/node-runtime/{chunk-WJVFOIB5.js → chunk-UQUCFAJ3.js} +1 -1
  442. package/dist/node-runtime/chunk-URD2SLIT.js +1019 -0
  443. package/dist/node-runtime/chunk-US544NN6.js +13 -0
  444. package/dist/node-runtime/chunk-UWPJL22I.js +341 -0
  445. package/dist/node-runtime/chunk-V2A7CEXK.js +355 -0
  446. package/dist/node-runtime/chunk-VJPTNWAP.js +708 -0
  447. package/dist/node-runtime/{chunk-WKDK4C5P.js → chunk-VSSXXL36.js} +38 -164
  448. package/dist/node-runtime/{chunk-4I23VTC4.js → chunk-VWCE2HSZ.js} +21 -124
  449. package/dist/node-runtime/{chunk-CBGB57XT.js → chunk-WADV2VDS.js} +32 -1014
  450. package/dist/node-runtime/{chunk-GKLEQ3I4.js → chunk-XLTL257W.js} +126 -27
  451. package/dist/node-runtime/chunk-YPHAIRZT.js +10 -0
  452. package/dist/node-runtime/cli-runtime.js +2 -2
  453. package/dist/node-runtime/command-3JHHXOPX.js +45 -0
  454. package/dist/node-runtime/commands-2JVNFGMQ.js +36 -0
  455. package/dist/node-runtime/{commands-MV5KOZ64.js → commands-KAMO2T6P.js} +10 -10
  456. package/dist/node-runtime/config-RORQUQFG.js +20 -0
  457. package/dist/node-runtime/{customize-XEXL2DGQ.js → customize-VFJV3U6A.js} +2 -1
  458. package/dist/node-runtime/{direct-tool-executor-BK7CLEBX.js → direct-tool-executor-YAVOLDFY.js} +8 -8
  459. package/dist/node-runtime/{export-html-TEXVV5RP.js → export-html-KBFVV63J.js} +4 -3
  460. package/dist/node-runtime/{extension-input-O4HSAEM4.js → extension-input-K24TVKVW.js} +4 -4
  461. package/dist/node-runtime/{extension-selector-X5FCX43D.js → extension-selector-SPNF7EDR.js} +4 -4
  462. package/dist/node-runtime/{extract-XLQSJN4V.js → extract-EQJE7FZZ.js} +2 -2
  463. package/dist/node-runtime/{gateway-L4ANRTVE.js → gateway-VFO6SFKK.js} +275 -994
  464. package/dist/node-runtime/{gemini-search-U7SUMPQA.js → gemini-search-35OCRFLN.js} +1 -1
  465. package/dist/node-runtime/{gemini-url-context-PXWCBQHK.js → gemini-url-context-UQY3PHHW.js} +2 -2
  466. package/dist/node-runtime/index.js +105 -64
  467. package/dist/node-runtime/{init-3C7Z24OI.js → init-X2LIUB2H.js} +3 -3
  468. package/dist/node-runtime/{install-cli-EXMJQESX.js → install-cli-C3CF7O7N.js} +21 -82
  469. package/dist/node-runtime/interactive-mode-LOM6AIF6.js +72 -0
  470. package/dist/node-runtime/{interactive-view-ILS6TAN5.js → interactive-view-IDSCPPK7.js} +8 -8
  471. package/dist/node-runtime/lunr-browser-YNW7FTYX.js +87 -0
  472. package/dist/node-runtime/{lunr-cron-NNYTWTGF.js → lunr-cron-BKHGNBKT.js} +19 -5
  473. package/dist/node-runtime/main.js +45 -30
  474. package/dist/node-runtime/{memory-cap-3S4XRLNP.js → memory-cap-EL3KL4JJ.js} +2 -1
  475. package/dist/node-runtime/mobile-commands-HMP25WBC.js +32 -0
  476. package/dist/node-runtime/model-runtime-PLQKAG4B.js +16 -0
  477. package/dist/node-runtime/{model-tiers-NJLHUEGK.js → model-tiers-OU3U5CZG.js} +2 -1
  478. package/dist/node-runtime/{package-manager-cli-7RKSZGEN.js → package-manager-cli-VCK4E2RC.js} +23 -15
  479. package/dist/node-runtime/{pi-intercom-DDQMRNPJ.js → pi-intercom-HBPK5HSJ.js} +38 -34
  480. package/dist/node-runtime/{pi-mcp-adapter-GUFZWW54.js → pi-mcp-adapter-E6WULBKF.js} +4 -4
  481. package/dist/node-runtime/{pi-subagents-T5WMMLBB.js → pi-subagents-FEUDLJOE.js} +476 -412
  482. package/dist/node-runtime/{pi-web-access-2CQGFLT2.js → pi-web-access-WTGMNZ32.js} +15 -15
  483. package/dist/node-runtime/process-registry-4FAKZQOL.js +31 -0
  484. package/dist/node-runtime/{proxy-modes-V6YVFH3C.js → proxy-modes-OSQCWRBI.js} +9 -9
  485. package/dist/node-runtime/rpc-entry.js +46 -31
  486. package/dist/node-runtime/{rpc-mode-W5ZTLTMZ.js → rpc-mode-P5ODXPEG.js} +2 -2
  487. package/dist/node-runtime/runtime-4VA6JKNF.js +373 -0
  488. package/dist/node-runtime/{runtime-bridges-NJQERQ72.js → runtime-bridges-3XUQ46XW.js} +6 -5
  489. package/dist/node-runtime/service-ISSP6VHE.js +36 -0
  490. package/dist/node-runtime/session-handoff-HC7R5E24.js +33 -0
  491. package/dist/node-runtime/{session-manager-E7AREDTV.js → session-manager-CFN4UFM2.js} +2 -1
  492. package/dist/node-runtime/{session-selector-FJ7M2AIX.js → session-selector-LHRMJOKT.js} +5 -4
  493. package/dist/node-runtime/{settings-manager-GHPTUN7R.js → settings-manager-UUZ6NUXI.js} +8 -2
  494. package/dist/node-runtime/setup-JBKOLJ6F.js +18 -0
  495. package/dist/node-runtime/setup-NRXVZBLJ.js +155 -0
  496. package/dist/node-runtime/{subagent-executor-SRFC26SJ.js → subagent-executor-MLUMBWCP.js} +35 -63
  497. package/dist/node-runtime/theme-U7IGOA7O.js +68 -0
  498. package/dist/node-runtime/trust-manager-MMISNCYO.js +17 -0
  499. package/dist/node-runtime/{update-cli-L3JIBH2U.js → update-cli-4TP25CNW.js} +8 -2
  500. package/dist/node-runtime/usage-service-LFB2SWYV.js +37 -0
  501. package/dist/node-runtime/{video-extract-OYT5WKS5.js → video-extract-OOZHR7SU.js} +2 -2
  502. package/dist/node-runtime/{youtube-extract-TQYKGFGS.js → youtube-extract-FNPAUNHU.js} +6 -6
  503. package/docs/browser.md +86 -0
  504. package/docs/extensions.md +2 -0
  505. package/docs/features.md +99 -17
  506. package/docs/interactive-startup.md +2 -1
  507. package/docs/sessions.md +10 -0
  508. package/docs/settings.md +3 -1
  509. package/docs/tui.md +2 -0
  510. package/docs/usage.md +16 -0
  511. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  512. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  513. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  514. package/examples/extensions/gondolin/package-lock.json +2 -2
  515. package/examples/extensions/gondolin/package.json +1 -1
  516. package/examples/extensions/sandbox/package-lock.json +2 -2
  517. package/examples/extensions/sandbox/package.json +1 -1
  518. package/examples/extensions/with-deps/package-lock.json +2 -2
  519. package/examples/extensions/with-deps/package.json +1 -1
  520. package/package.json +7 -4
  521. package/scripts/install-browser.mjs +20 -0
  522. package/dist/node-runtime/agent-session-services-75JKASCW.js +0 -36
  523. package/dist/node-runtime/chunk-HQCKFM2O.js +0 -56
  524. package/dist/node-runtime/command-RBTRL55A.js +0 -13
  525. package/dist/node-runtime/interactive-mode-HPUNH7SV.js +0 -57
  526. package/dist/node-runtime/{chunk-UWQYRSYQ.js → chunk-YJMMG7C6.js} +25 -25
  527. package/dist/node-runtime/{mcp-panel-IIGMXQGP.js → mcp-panel-KTTFXJZ4.js} +3 -3
  528. package/dist/node-runtime/{src-BPQFJR76.js → src-IVPNZ2BX.js} +9 -9
@@ -6,7 +6,6 @@ import {
6
6
  ASYNC_DIR,
7
7
  DEFAULT_ARTIFACT_CONFIG,
8
8
  INTERCOM_DETACH_REQUEST_EVENT,
9
- MAX_WIDGET_JOBS,
10
9
  POLL_INTERVAL_MS,
11
10
  RESULTS_DIR,
12
11
  SLASH_RESULT_TYPE,
@@ -17,6 +16,7 @@ import {
17
16
  SLASH_SUBAGENT_UPDATE_EVENT,
18
17
  SLASH_TEXT_RESULT_TYPE,
19
18
  SUBAGENT_ASYNC_COMPLETE_EVENT,
19
+ SUBAGENT_ASYNC_GUIDANCE,
20
20
  SUBAGENT_ASYNC_STARTED_EVENT,
21
21
  SUBAGENT_CHILD_ENV,
22
22
  SUBAGENT_CONTROL_EVENT,
@@ -27,12 +27,14 @@ import {
27
27
  SUBAGENT_PARENT_SESSION_ENV,
28
28
  SUBAGENT_RESULT_INTERCOM_EVENT,
29
29
  SUBAGENT_STEERING_NOTICE_EVENT,
30
+ SUPERVISOR_PROGRESS_TYPE,
31
+ SUPERVISOR_REQUEST_TYPE,
30
32
  TEMP_ROOT_DIR,
31
33
  WIDGET_KEY,
32
- aggregateStepStatus,
33
34
  assertJsonSchemaObject,
34
35
  attachNestedChildrenToResultChildren,
35
36
  buildSubagentResultIntercomPayload,
37
+ childRowLabel,
36
38
  cleanupAllArtifactDirs,
37
39
  cleanupOldArtifacts,
38
40
  cleanupOldChainDirs,
@@ -45,11 +47,10 @@ import {
45
47
  formatAsyncRunProgressLabel,
46
48
  formatAsyncRunTranscript,
47
49
  formatCompactModelBadge,
48
- formatControlNoticeMessage,
49
50
  formatDuration,
50
51
  formatModelSelection,
51
52
  formatNestedAggregate,
52
- formatParallelOutcome,
53
+ formatNestedResultLines,
53
54
  formatTokens,
54
55
  formatToolCall,
55
56
  formatUsage,
@@ -60,9 +61,13 @@ import {
60
61
  getSingleResultOutput,
61
62
  handleSubagentControlNotice,
62
63
  hasLiveNestedDescendants,
64
+ isAsyncSubagentExecution,
65
+ legacySupervisorBody,
63
66
  listAsyncRuns,
67
+ normalizeAsyncLaunchConfig,
64
68
  normalizeParallelGroups,
65
69
  projectNestedRegistryForRoot,
70
+ readCommunication,
66
71
  readStatus,
67
72
  readSteerCapability,
68
73
  reconcileAsyncRun,
@@ -70,7 +75,9 @@ import {
70
75
  registerMainWatchdog,
71
76
  requestAsyncSteer,
72
77
  resolveAsyncRunLocation,
78
+ resolveCommunicationPeer,
73
79
  resolveCurrentSessionId,
80
+ resolveSubagentRequestParams,
74
81
  resolveSubagentResultStatus,
75
82
  resolveSubagentRunId,
76
83
  resolveTurnBudgetConfig,
@@ -79,33 +86,44 @@ import {
79
86
  sanitizeChildDescription,
80
87
  sanitizeSummary,
81
88
  shortenPath,
89
+ stopRequestPath,
90
+ subagentLaunchRunsAsync,
82
91
  summarizeAsyncStatus,
83
92
  updateAsyncJobNestedProjection,
84
93
  validateAcceptanceInput,
85
94
  validateExecutionAcceptance,
86
95
  validateToolBudgetConfig,
87
96
  writeAtomicJson
88
- } from "./chunk-46ECNOLF.js";
97
+ } from "./chunk-QDGKKKUM.js";
98
+ import {
99
+ formatControlNoticeMessage
100
+ } from "./chunk-OAR4TYZE.js";
101
+ import {
102
+ getSubagentSpinnerDefinition
103
+ } from "./chunk-US544NN6.js";
104
+ import "./chunk-5ZH3ZFIZ.js";
105
+ import "./chunk-CSUZVNYE.js";
106
+ import "./chunk-VSSXXL36.js";
107
+ import "./chunk-53YJI7JU.js";
108
+ import "./chunk-5ZQXRPMC.js";
109
+ import "./chunk-AD6VXAO7.js";
110
+ import "./chunk-LISUTZS3.js";
89
111
  import {
90
112
  createSubagentCancellation,
91
113
  registerSubagentCancellation
92
114
  } from "./chunk-BBUVIEZB.js";
93
- import "./chunk-25I2BHAA.js";
94
- import "./chunk-WKDK4C5P.js";
95
- import "./chunk-53YJI7JU.js";
96
- import "./chunk-KBKMCJDU.js";
115
+ import "./chunk-5D7LC2ZQ.js";
116
+ import "./chunk-M3LZLQW2.js";
117
+ import "./chunk-KKUTQQV7.js";
97
118
  import "./chunk-CSFI6YXL.js";
98
119
  import "./chunk-FVDOXRUD.js";
99
- import "./chunk-AD6VXAO7.js";
100
- import "./chunk-6N22HULO.js";
101
- import "./chunk-M3LZLQW2.js";
102
120
  import "./chunk-RQ2Q5IYR.js";
103
121
  import {
104
122
  keyText
105
- } from "./chunk-DDWHZ633.js";
123
+ } from "./chunk-GNN7H3B7.js";
106
124
  import {
107
125
  getMarkdownTheme
108
- } from "./chunk-RNBHABBA.js";
126
+ } from "./chunk-7QWNYZDI.js";
109
127
  import "./chunk-FQMM2EZ2.js";
110
128
  import "./chunk-Q4Q6D4IY.js";
111
129
  import "./chunk-BRJX2PRC.js";
@@ -115,7 +133,7 @@ import { randomUUID as randomUUID4 } from "node:crypto";
115
133
  import * as fs10 from "node:fs";
116
134
  import * as os from "node:os";
117
135
  import * as path12 from "node:path";
118
- import { Box, Container as Container2, Spacer as Spacer2, Text as Text2, truncateToWidth as truncateToWidth2, visibleWidth as visibleWidth3, wrapTextWithAnsi as wrapTextWithAnsi2 } from "@ashx-j/lunr-tui";
136
+ import { Box as Box2, Container as Container3, Spacer as Spacer2, Text as Text3, truncateToWidth as truncateToWidth2, visibleWidth as visibleWidth3, wrapTextWithAnsi as wrapTextWithAnsi2 } from "@ashx-j/lunr-tui";
119
137
 
120
138
  // packages/coding-agent/dist/builtin-extensions/pi-subagents/src/tui/render.js
121
139
  import { Container, Markdown, Spacer, Text, visibleWidth } from "@ashx-j/lunr-tui";
@@ -177,7 +195,11 @@ function wrapPlainText(text, maxWidth) {
177
195
  }
178
196
  return lines;
179
197
  }
180
- var RUNNING_FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"], STATIC_RUNNING_GLYPH = "\u25CF";
198
+ var STATIC_RUNNING_GLYPH = "\u25CF", SUBAGENT_PAINT_INTERVAL_MS = 80;
199
+ function selectedSubagentSpinner() {
200
+ let bridge = globalThis[/* @__PURE__ */ Symbol.for("@lunr/customize")];
201
+ return getSubagentSpinnerDefinition(bridge?.getSubagentSpinner?.() ?? "braille");
202
+ }
181
203
  function runningSeed(...values) {
182
204
  let seed;
183
205
  for (let value of values)
@@ -185,7 +207,14 @@ function runningSeed(...values) {
185
207
  return seed;
186
208
  }
187
209
  function runningGlyph(seed) {
188
- return seed === void 0 ? STATIC_RUNNING_GLYPH : RUNNING_FRAMES[Math.abs(seed) % RUNNING_FRAMES.length];
210
+ if (seed === void 0)
211
+ return STATIC_RUNNING_GLYPH;
212
+ let frames = selectedSubagentSpinner().frames;
213
+ return frames[Math.abs(seed) % frames.length];
214
+ }
215
+ function foregroundSpinnerFrame(timerFrame) {
216
+ let { interval } = selectedSubagentSpinner();
217
+ return Math.floor(Math.max(0, timerFrame) * SUBAGENT_PAINT_INTERVAL_MS / interval);
189
218
  }
190
219
  function progressRunningSeed(progress) {
191
220
  if (progress)
@@ -315,7 +344,8 @@ function formatCompactSubagentRow(theme, width, parts) {
315
344
  let stats = formatCompactRowStats(parts.tokens, parts.durationMs), body = [
316
345
  `${parts.prefix ?? ""}${parts.glyph} ${themeBold(theme, parts.description)}`,
317
346
  parts.modelBadge ? theme.fg("dim", parts.modelBadge) : "",
318
- theme.fg("dim", stats)
347
+ theme.fg("dim", stats),
348
+ parts.terminalStatus ? theme.fg("dim", parts.terminalStatus) : ""
319
349
  ].filter(Boolean).join(` ${theme.fg("dim", "\xB7")} `);
320
350
  return truncLine(body, width);
321
351
  }
@@ -353,6 +383,12 @@ function formatWidgetAgents(agents) {
353
383
  function widgetJobName(job) {
354
384
  return job.mode === "parallel" ? "parallel" : job.mode === "chain" ? "chain" : job.mode === "single" && job.agents?.length === 1 ? job.agents[0] : job.agents?.length ? formatWidgetAgents(job.agents) : job.mode ?? "subagent";
355
385
  }
386
+ function widgetActivity(job, now = Date.now()) {
387
+ let facts = [], snapshotNow = job.status === "running" ? now : job.updatedAt;
388
+ job.currentTool && job.currentToolStartedAt !== void 0 && snapshotNow !== void 0 ? facts.push(`${job.currentTool} ${formatDuration(Math.max(0, snapshotNow - job.currentToolStartedAt))}`) : job.currentTool && facts.push(job.currentTool), job.currentPath && facts.push(shortenPath(job.currentPath)), job.turnCount !== void 0 && facts.push(`${job.turnCount} turns`), job.toolCount !== void 0 && facts.push(`${job.toolCount} tools`);
389
+ let activity = buildLiveStatusLine(job, snapshotNow);
390
+ return activity && facts.length ? `${activity} \xB7 ${facts.join(" \xB7 ")}` : activity || (facts.length ? facts.join(" \xB7 ") : job.status === "running" ? "thinking\u2026" : job.status === "queued" ? "queued\u2026" : job.status === "paused" ? "Paused" : job.status === "stopped" ? "Stopped" : job.status === "failed" ? "Failed" : "Done");
391
+ }
356
392
  function widgetStepRunningSeed(step, fallbackIndex) {
357
393
  return runningSeed(fallbackIndex, step.index);
358
394
  }
@@ -365,14 +401,9 @@ function widgetStepsRunningSeed(steps) {
365
401
  function widgetJobRunningSeed(job) {
366
402
  return runningSeed(job.currentStep, job.runningSteps, widgetStepsRunningSeed(job.steps));
367
403
  }
368
- function widgetJobsRunningSeed(jobs) {
369
- let seed;
370
- for (let job of jobs)
371
- seed = runningSeed(seed, widgetJobRunningSeed(job));
372
- return seed;
373
- }
374
404
  function widgetAnimFrame(now = Date.now()) {
375
- return Math.floor(now / 80) % RUNNING_FRAMES.length;
405
+ let definition = selectedSubagentSpinner();
406
+ return Math.floor(now / definition.interval) % definition.frames.length;
376
407
  }
377
408
  function widgetStatusGlyph(job, theme, now = Date.now()) {
378
409
  return job.status === "running" ? theme.fg("accent", runningGlyph((widgetJobRunningSeed(job) ?? 0) + widgetAnimFrame(now))) : job.status === "queued" ? theme.fg("muted", "\u25E6") : job.status === "complete" ? theme.fg("success", "\u2713") : job.status === "paused" || job.status === "stopped" ? theme.fg("warning", "\u25A0") : theme.fg("error", "\u2717");
@@ -383,48 +414,6 @@ function widgetStepGlyph(status, theme, seed) {
383
414
  function widgetStepStatus(status, theme) {
384
415
  return status === "running" ? theme.fg("accent", "running") : status === "complete" || status === "completed" ? theme.fg("success", "complete") : status === "failed" ? theme.fg("error", "failed") : status === "paused" ? theme.fg("warning", "paused") : status === "stopped" ? theme.fg("warning", "stopped") : theme.fg("dim", status);
385
416
  }
386
- function widgetStepActivity(step, snapshotNow) {
387
- let facts = [];
388
- step.currentTool && step.currentToolStartedAt !== void 0 && snapshotNow !== void 0 ? facts.push(`${step.currentTool} ${formatDuration(Math.max(0, snapshotNow - step.currentToolStartedAt))}`) : step.currentTool && facts.push(step.currentTool), step.currentPath && facts.push(shortenPath(step.currentPath)), step.turnCount !== void 0 && facts.push(`${step.turnCount} turns`), step.toolCount !== void 0 && facts.push(`${step.toolCount} tools`), step.tokens?.total && facts.push(formatTokenStat(step.tokens.total));
389
- let activity = buildLiveStatusLine(step, snapshotNow);
390
- return activity && facts.length ? `${activity} \xB7 ${facts.join(" \xB7 ")}` : activity || facts.join(" \xB7 ");
391
- }
392
- function widgetChainDetails(job, theme, expanded = !1, width = getTermWidth()) {
393
- if (!job.steps?.length)
394
- return [];
395
- let total = job.chainStepCount ?? job.steps.length, lines = [];
396
- for (let span of buildAsyncChainStepSpans(total, job.steps.length, job.parallelGroups)) {
397
- let steps = job.steps.slice(span.start, span.start + span.count);
398
- if (span.isParallel) {
399
- let status = aggregateStepStatus(steps);
400
- lines.push(` ${widgetStepGlyph(status, theme, widgetStepsRunningSeed(steps))} Step ${span.stepIndex + 1}/${total}: ${themeBold(theme, "parallel group")} ${theme.fg("dim", "\xB7")} ${theme.fg("dim", formatParallelOutcome(steps, span.count))}`);
401
- continue;
402
- }
403
- let step = steps[0];
404
- if (!step) {
405
- lines.push(` ${theme.fg("dim", `\u25E6 Step ${span.stepIndex + 1}/${total}: pending`)}`);
406
- continue;
407
- }
408
- lines.push(...foregroundStyleWidgetStepLines(job, theme, step, "Step", span.stepIndex + 1, total, expanded, width));
409
- }
410
- return lines;
411
- }
412
- function widgetParallelAgentDetails(job, theme, expanded = !1, width = getTermWidth()) {
413
- if (!job.steps?.length)
414
- return [];
415
- if (job.mode !== "parallel" && job.mode !== "chain")
416
- return [];
417
- if (job.mode === "chain" && !job.activeParallelGroup && job.parallelGroups?.length)
418
- return widgetChainDetails(job, theme, expanded, width);
419
- let total = job.stepsTotal ?? job.steps.length, lines = [];
420
- for (let [index, step] of job.steps.entries()) {
421
- let marker = index === job.steps.length - 1 ? "\u2514" : "\u251C", activity = widgetStepActivity(step, job.updatedAt), itemTitle = job.mode === "parallel" || job.activeParallelGroup ? "Agent" : "Step", modelDisplay = modelThinkingBadge(theme, step.model, step.thinking, step.modelSelection);
422
- lines.push(` ${theme.fg("dim", `${marker} ${widgetStepGlyph(step.status, theme, widgetStepRunningSeed(step, index))} ${itemTitle} ${index + 1}/${total}: ${step.agent} \xB7 ${widgetStepStatus(step.status, theme)}${modelDisplay}${activity ? ` \xB7 ${activity}` : ""}`)}`);
423
- for (let nestedLine of formatNestedWidgetLines(step.children, theme, width, expanded, job.updatedAt, expanded ? 8 : 1))
424
- lines.push(` ${nestedLine}`);
425
- }
426
- return lines;
427
- }
428
417
  function parseParallelGroupAgentCount(label) {
429
418
  if (!label || !label.startsWith("[") || !label.endsWith("]"))
430
419
  return;
@@ -460,24 +449,16 @@ function buildChainStepSpans(details) {
460
449
  function isChainParallelGroupActive(details) {
461
450
  return details.mode !== "chain" || details.currentStepIndex === void 0 ? !1 : buildChainStepSpans(details).some((span) => span.stepIndex === details.currentStepIndex && span.isParallel);
462
451
  }
463
- function buildAsyncChainStepSpans(total, stepCount, parallelGroups = []) {
464
- let spans = [], flatIndex = 0;
465
- for (let stepIndex = 0; stepIndex < total; stepIndex++) {
466
- let group = parallelGroups.find((candidate) => candidate.stepIndex === stepIndex);
467
- if (group) {
468
- spans.push({ stepIndex, start: group.start, count: group.count, isParallel: !0 }), flatIndex = Math.max(flatIndex, group.start + group.count);
469
- continue;
470
- }
471
- spans.push({ stepIndex, start: flatIndex, count: flatIndex < stepCount ? 1 : 0, isParallel: !1 }), flatIndex++;
472
- }
473
- return spans;
474
- }
475
452
  function isDoneResult(result2) {
476
453
  let status = result2.progress?.status;
477
454
  return status === "completed" ? !0 : status === "running" || status === "pending" || result2.interrupted || result2.detached ? !1 : result2.exitCode === 0;
478
455
  }
479
456
  function workflowGraphHasStatus(details, statuses) {
480
- return details.workflowGraph?.nodes.some((node) => statuses.includes(node.status)) ?? !1;
457
+ let matches = (nodes) => nodes.some((node) => statuses.includes(node.status) || matches(node.children ?? []));
458
+ return matches(details.workflowGraph?.nodes ?? []);
459
+ }
460
+ function resultAtFlatIndex(details, flatIndex) {
461
+ return details.results.find((result2, arrayIndex) => (result2.progress?.index ?? result2.progressSummary?.index ?? arrayIndex) === flatIndex);
481
462
  }
482
463
  function buildChainRenderEntries(details, label) {
483
464
  if (details.mode !== "chain" || !label.hasParallelInChain || label.showActiveGroupOnly)
@@ -495,13 +476,17 @@ function buildChainRenderEntries(details, label) {
495
476
  });
496
477
  continue;
497
478
  }
498
- for (let index = span.start; index < span.start + span.count; index++)
479
+ for (let index = span.start; index < span.start + span.count; index++) {
480
+ let workflowStep = details.workflowGraph?.nodes.find((node) => node.stepIndex === span.stepIndex), workflowNode = workflowStep?.children?.find((node) => node.flatIndex === index) ?? (workflowStep?.flatIndex === index ? workflowStep : void 0), result2 = resultAtFlatIndex(details, index);
499
481
  entries.push({
500
482
  kind: "result",
501
483
  resultIndex: index,
502
484
  rowNumber: index + 1,
503
- agentName: details.results[index]?.agent ?? details.chainAgents?.[span.stepIndex] ?? `step-${span.stepIndex + 1}`
485
+ agentName: result2?.agent ?? workflowNode?.label ?? details.chainAgents?.[span.stepIndex] ?? `step-${span.stepIndex + 1}`,
486
+ status: workflowNode?.status ?? span.status,
487
+ error: workflowNode?.error ?? span.error
504
488
  });
489
+ }
505
490
  }
506
491
  return entries;
507
492
  }
@@ -566,15 +551,6 @@ function resultRowLabel(details, label, resultIndex, stepNumber) {
566
551
  }
567
552
  return label.itemTitle === "Agent" ? `Agent ${label.activeParallelGroup ? Math.max(1, stepNumber - label.groupStartIndex) : stepNumber}/${label.totalCount}` : `Step ${stepNumber}`;
568
553
  }
569
- function widgetStepStats(theme, step, now = Date.now()) {
570
- let running = step.status === "running", durationMs = step.durationMs !== void 0 ? step.durationMs + (running && step.lastActivityAt !== void 0 ? Math.max(0, now - step.lastActivityAt) : 0) : step.startedAt !== void 0 ? Math.max(0, (running ? now : step.endedAt ?? step.lastActivityAt ?? now) - step.startedAt) : void 0;
571
- return statJoin(theme, [
572
- step.turnCount !== void 0 ? `${step.turnCount} turns` : "",
573
- step.toolCount !== void 0 ? formatToolUseStat(step.toolCount) : "",
574
- step.tokens?.total ? formatTokenStat(step.tokens.total) : "",
575
- durationMs !== void 0 ? `${running ? "" : "ran for "}${formatDuration(durationMs)}` : ""
576
- ]);
577
- }
578
554
  function modelThinkingBadge(theme, model, thinking, selection) {
579
555
  let label = formatModelSelection(selection, model, thinking);
580
556
  return label ? theme.fg("dim", ` (${label})`) : "";
@@ -639,22 +615,15 @@ function formatNestedWidgetLines(children, theme, width, expanded, snapshotNow,
639
615
  };
640
616
  return append(children, 0, ""), lines.map((line) => truncLine(line, width));
641
617
  }
642
- function foregroundStyleWidgetStepLines(job, theme, step, itemTitle, index, total, expanded, width) {
643
- let status = widgetStepStatus(step.status, theme), stats = widgetStepStats(theme, step), modelDisplay = modelThinkingBadge(theme, step.model, step.thinking, step.modelSelection), lines = [` ${widgetStepGlyph(step.status, theme, widgetStepRunningSeed(step, index - 1))} ${itemTitle} ${index}/${total}: ${themeBold(theme, step.agent)} ${theme.fg("dim", "\xB7")} ${status}${modelDisplay}${stats ? ` ${theme.fg("dim", "\xB7")} ${stats}` : ""}`], activity = widgetStepActivityLine(step, width, expanded, job.updatedAt);
644
- activity && lines.push(` ${theme.fg("dim", `\u23BF ${activity}`)}`);
645
- for (let nestedLine of formatNestedWidgetLines(step.children, theme, width, expanded, job.updatedAt))
646
- lines.push(` ${nestedLine}`);
647
- if (step.status === "running" && (expanded || lines.push(` ${theme.fg("accent", liveDetailHintText())}`), expanded)) {
648
- let liveStatus = buildLiveStatusLine(step, job.updatedAt);
649
- liveStatus && liveStatus !== activity && lines.push(` ${theme.fg("accent", liveStatus)}`);
650
- for (let tool of step.recentTools?.slice(-3) ?? []) {
651
- let maxArgsLen = Math.max(40, width - 30), argsPreview = tool.args.length <= maxArgsLen ? tool.args : `${tool.args.slice(0, maxArgsLen)}...`;
652
- lines.push(` ${theme.fg("dim", `${tool.tool}${argsPreview ? `: ${argsPreview}` : ""}`)}`);
653
- }
654
- for (let line of step.recentOutput?.slice(-5) ?? [])
655
- lines.push(` ${theme.fg("dim", line)}`);
656
- }
657
- return lines;
618
+ function compactTerminalStatus(status) {
619
+ if (status === "failed")
620
+ return "failed";
621
+ if (status === "paused")
622
+ return "paused";
623
+ if (status === "stopped")
624
+ return "stopped";
625
+ if (status === "detached")
626
+ return "detached";
658
627
  }
659
628
  function compactJobProgress(job, step, now = Date.now()) {
660
629
  let running = (step?.status ?? job.status) === "running", tokens = step?.tokens?.total ?? job.totalTokens?.total ?? 0;
@@ -675,14 +644,6 @@ function compactJobLead(job, step) {
675
644
  task: step?.description ?? step?.agent
676
645
  }) || widgetJobName(job);
677
646
  }
678
- function activeJobStep(job) {
679
- let steps = job.steps ?? [];
680
- return steps.find((step) => step.status === "running") ?? steps.find((step) => step.status === "pending" || step.status === "queued") ?? steps[steps.length - 1];
681
- }
682
- function compactJobChildRows(job, theme, width, now = Date.now()) {
683
- let steps = job.steps ?? [];
684
- return steps.length <= 1 ? compactJobLines(job, steps[0], theme, width, now) : steps.flatMap((step) => compactJobLines(job, step, theme, width, now));
685
- }
686
647
  function compactJobLines(job, step, theme, width, now = Date.now()) {
687
648
  let running = (step?.status ?? job.status) === "running", lead = compactJobLead(job, step), modelBadge = formatCompactModelBadge(step?.modelSelection, step?.model), glyph = step ? widgetStepGlyph(step.status, theme, running ? (widgetStepRunningSeed(step, step.index) ?? 0) + widgetAnimFrame(now) : widgetStepRunningSeed(step, step.index)) : widgetStatusGlyph(job, theme, now), progress = compactJobProgress(job, step, now);
688
649
  return [formatCompactSubagentRow(theme, width, {
@@ -690,16 +651,10 @@ function compactJobLines(job, step, theme, width, now = Date.now()) {
690
651
  description: lead,
691
652
  modelBadge,
692
653
  tokens: progress.tokens,
693
- durationMs: progress.durationMs
654
+ durationMs: progress.durationMs,
655
+ terminalStatus: compactTerminalStatus(step?.status ?? job.status)
694
656
  })];
695
657
  }
696
- function buildSingleWidgetLines(job, theme, width, _expanded, now = Date.now()) {
697
- let steps = job.steps ?? [];
698
- return steps.length <= 1 ? compactJobLines(job, steps[0], theme, width, now) : steps.flatMap((step) => compactJobLines(job, step, theme, width, now));
699
- }
700
- function compactSingleWidgetLines(job, theme, width, now = Date.now()) {
701
- return buildSingleWidgetLines(job, theme, width, !1, now);
702
- }
703
658
  var RESERVED_NON_WIDGET_ROWS = 19, widgetLayoutSession;
704
659
  function resetWidgetLayoutSession() {
705
660
  widgetLayoutSession = void 0;
@@ -717,20 +672,6 @@ function currentTerminalColumns() {
717
672
  function widgetSessionMatches(expanded) {
718
673
  return widgetLayoutSession?.expanded === expanded && widgetLayoutSession.rows === currentTerminalRows() && widgetLayoutSession.columns === currentTerminalColumns();
719
674
  }
720
- function widgetHeaderCounts(jobs) {
721
- return {
722
- running: jobs.filter((job) => job.status === "running"),
723
- queued: jobs.filter((job) => job.status === "queued"),
724
- complete: jobs.filter((job) => job.status === "complete"),
725
- failed: jobs.filter((job) => job.status === "failed"),
726
- paused: jobs.filter((job) => job.status === "paused"),
727
- stopped: jobs.filter((job) => job.status === "stopped")
728
- };
729
- }
730
- function buildSingleLineWidgetLines(jobs, theme, width) {
731
- let counts = widgetHeaderCounts(jobs), hasActive = counts.running.length > 0 || counts.queued.length > 0, glyph = counts.running.length > 0 ? runningGlyph((widgetJobsRunningSeed(counts.running) ?? 0) + widgetAnimFrame()) : hasActive ? "\u25CF" : "\u25CB", parts = [];
732
- return counts.running.length > 0 && parts.push(`${counts.running.length}/${jobs.length} running`), counts.queued.length > 0 && parts.push(`${counts.queued.length} queued`), counts.failed.length > 0 && parts.push(`${counts.failed.length} failed`), counts.stopped.length > 0 && parts.push(`${counts.stopped.length} stopped`), counts.paused.length > 0 && parts.push(`${counts.paused.length} paused`), !hasActive && counts.complete.length > 0 && parts.push(`${counts.complete.length}/${jobs.length} done`), [truncLine(`${theme.fg(hasActive ? "accent" : "dim", glyph)} ${theme.fg(hasActive ? "accent" : "dim", "subagents")} (${parts.join(", ") || `${jobs.length} total`})`, width)];
733
- }
734
675
  function orderedWidgetJobs(jobs) {
735
676
  return [
736
677
  ...jobs.filter((job) => job.status === "running"),
@@ -738,68 +679,6 @@ function orderedWidgetJobs(jobs) {
738
679
  ...jobs.filter((job) => job.status !== "running" && job.status !== "queued")
739
680
  ];
740
681
  }
741
- function progressiveJobKey(job) {
742
- return job.asyncId;
743
- }
744
- function isProgressiveActiveJob(job) {
745
- return job?.status === "running" || job?.status === "queued";
746
- }
747
- function selectProgressiveJobKeys(jobs, previousKeys, bodyRows) {
748
- if (bodyRows <= 0)
749
- return [];
750
- let jobsByKey = new Map(jobs.map((job) => [progressiveJobKey(job), job])), selected = [], append = (key) => {
751
- selected.includes(key) || !jobsByKey.has(key) || selected.push(key);
752
- };
753
- for (let key of previousKeys)
754
- if (isProgressiveActiveJob(jobsByKey.get(key)) && (append(key), selected.length >= bodyRows))
755
- return selected;
756
- for (let job of orderedWidgetJobs(jobs)) {
757
- if (!isProgressiveActiveJob(job))
758
- continue;
759
- let key = progressiveJobKey(job);
760
- if (append(key), selected.length >= bodyRows)
761
- break;
762
- }
763
- if (selected.length >= bodyRows)
764
- return selected;
765
- for (let key of previousKeys)
766
- if (!isProgressiveActiveJob(jobsByKey.get(key)) && (append(key), selected.length >= bodyRows))
767
- return selected;
768
- for (let job of orderedWidgetJobs(jobs)) {
769
- let key = progressiveJobKey(job);
770
- if (append(key), selected.length >= bodyRows)
771
- break;
772
- }
773
- return selected;
774
- }
775
- function progressiveHeaderLine(jobs, theme, width) {
776
- let counts = widgetHeaderCounts(jobs), hasActive = counts.running.length > 0 || counts.queued.length > 0, glyph = counts.running.length > 0 ? runningGlyph((widgetJobsRunningSeed(counts.running) ?? 0) + widgetAnimFrame()) : hasActive ? "\u25CF" : "\u25CB", parts = [];
777
- return counts.running.length > 0 && parts.push(formatAgentRunningLabel(counts.running.length)), counts.queued.length > 0 && parts.push(`${counts.queued.length} queued`), hasActive || (counts.failed.length > 0 && parts.push(`${counts.failed.length} failed`), counts.stopped.length > 0 && parts.push(`${counts.stopped.length} stopped`), counts.paused.length > 0 && parts.push(`${counts.paused.length} paused`), counts.complete.length > 0 && parts.push(`${counts.complete.length}/${jobs.length} done`)), truncLine(`${theme.fg(hasActive ? "accent" : "dim", glyph)} ${theme.fg(hasActive ? "accent" : "dim", "Async agents")} ${theme.fg("dim", "\xB7")} ${theme.fg("dim", parts.join(", ") || `${jobs.length} total`)}`, width);
778
- }
779
- function progressiveJobLine(job, theme, width, now = Date.now()) {
780
- let row = compactJobLines(job, activeJobStep(job), theme, Math.max(1, width - 2), now)[0] ?? "";
781
- return row ? ` ${row}` : "";
782
- }
783
- function progressiveHiddenLine(hiddenJobs, theme, width) {
784
- let counts = widgetHeaderCounts(hiddenJobs), parts = [];
785
- counts.running.length > 0 && parts.push(`${counts.running.length} running`), counts.queued.length > 0 && parts.push(`${counts.queued.length} queued`);
786
- let finished = counts.complete.length + counts.failed.length + counts.paused.length + counts.stopped.length;
787
- return finished > 0 && parts.push(`${finished} finished`), truncLine(theme.fg("dim", ` +${hiddenJobs.length} more${parts.length ? ` (${parts.join(", ")})` : ""}`), width);
788
- }
789
- function buildProgressiveWidgetLines(jobs, theme, width, lockedRows, previousKeys) {
790
- let rowCount = Math.max(1, lockedRows);
791
- if (rowCount === 1)
792
- return { lines: buildSingleLineWidgetLines(jobs, theme, width), visibleJobKeys: [] };
793
- let bodyRows = rowCount - 1, visibleJobKeys = selectProgressiveJobKeys(jobs, previousKeys, bodyRows), jobsByKey = new Map(jobs.map((job) => [progressiveJobKey(job), job])), visibleJobs = visibleJobKeys.map((key) => jobsByKey.get(key)).filter((job) => !!job), hiddenJobs = jobs.filter((job) => !visibleJobKeys.includes(progressiveJobKey(job)));
794
- hiddenJobs.length > 0 && visibleJobs.length >= bodyRows && bodyRows > 0 && (visibleJobs = visibleJobs.slice(0, bodyRows - 1), visibleJobKeys = visibleJobs.map(progressiveJobKey), hiddenJobs = jobs.filter((job) => !visibleJobKeys.includes(progressiveJobKey(job))));
795
- let lines = [
796
- progressiveHeaderLine(jobs, theme, width),
797
- ...visibleJobs.map((job) => progressiveJobLine(job, theme, width))
798
- ];
799
- for (hiddenJobs.length > 0 && lines.length < rowCount && lines.push(progressiveHiddenLine(hiddenJobs, theme, width)); lines.length < rowCount; )
800
- lines.push(" ");
801
- return { lines: lines.slice(0, rowCount), visibleJobKeys };
802
- }
803
682
  function collapsedWidgetLineBudget(rows) {
804
683
  return Math.max(10, Math.min(14, Math.floor(rows * 0.35)));
805
684
  }
@@ -810,58 +689,41 @@ function fitWidgetLineBudget(lines, theme, width, expanded) {
810
689
  let visibleLines = Math.max(1, budget - 1), hiddenCount = lines.length - visibleLines, hint = expanded ? `\u2026 ${hiddenCount} live-detail lines hidden` : `\u2026 ${hiddenCount} lines hidden \xB7 ${liveDetailKeyText()} expands`;
811
690
  return [...lines.slice(0, visibleLines), truncLine(theme.fg("dim", hint), width)];
812
691
  }
813
- function fitAdaptiveWidgetLines(jobs, lines, theme, width, expanded) {
692
+ function fitAdaptiveWidgetLines(_jobs, lines, theme, width, expanded) {
814
693
  if (expanded)
815
694
  return resetWidgetLayoutSession(), fitWidgetLineBudget(lines, theme, width, !0);
816
- let hasMatchingSession = widgetSessionMatches(expanded), rows = currentTerminalRows(), columns = currentTerminalColumns(), availableRows = estimateAvailableWidgetRows();
817
- if (hasMatchingSession && widgetLayoutSession?.tier === "single-line")
818
- return buildSingleLineWidgetLines(jobs, theme, width);
819
- if (hasMatchingSession && widgetLayoutSession?.tier === "progressive" && widgetLayoutSession.lockedRows !== void 0) {
820
- let rendered2 = buildProgressiveWidgetLines(jobs, theme, width, widgetLayoutSession.lockedRows, widgetLayoutSession.visibleJobKeys);
821
- return widgetLayoutSession.visibleJobKeys = rendered2.visibleJobKeys, rendered2.lines;
822
- }
695
+ let rows = currentTerminalRows(), columns = currentTerminalColumns(), availableRows = estimateAvailableWidgetRows();
823
696
  if (lines.length <= availableRows)
824
- return widgetLayoutSession = { expanded, rows, columns, tier: "full", visibleJobKeys: [] }, fitWidgetLineBudget(lines, theme, width, !1);
825
- if (availableRows <= 2)
826
- return widgetLayoutSession = { expanded, rows, columns, tier: "single-line", visibleJobKeys: [] }, buildSingleLineWidgetLines(jobs, theme, width);
827
- let lockedRows = Math.min(availableRows, collapsedWidgetLineBudget(rows)), rendered = buildProgressiveWidgetLines(jobs, theme, width, lockedRows, []);
828
- return widgetLayoutSession = { expanded, rows, columns, tier: "progressive", lockedRows, visibleJobKeys: rendered.visibleJobKeys }, rendered.lines;
697
+ return widgetLayoutSession = { expanded, rows, columns, tier: "full" }, fitWidgetLineBudget(lines, theme, width, !1);
698
+ let lockedRows = widgetSessionMatches(expanded) && widgetLayoutSession?.tier === "progressive" ? widgetLayoutSession.lockedRows ?? 1 : Math.max(1, Math.min(availableRows, collapsedWidgetLineBudget(rows)));
699
+ if (widgetLayoutSession = { expanded, rows, columns, tier: "progressive", lockedRows }, lockedRows === 1)
700
+ return lines.slice(0, 1);
701
+ let visibleCount = Math.max(1, lockedRows - 1), visible = lines.slice(0, visibleCount), hidden = lines.length - visible.length;
702
+ for (hidden > 0 && visible.push(truncLine(theme.fg("dim", `+${hidden} more`), width)); visible.length < lockedRows; )
703
+ visible.push(" ");
704
+ return visible.slice(0, lockedRows);
705
+ }
706
+ function widgetExpandedDiagnostics(job, step, index, theme, width, now) {
707
+ let lines = [], status = step?.status ?? job.status, runLabel = step ? `${job.asyncId}:${step.index ?? index}` : job.asyncId;
708
+ lines.push(truncLine(theme.fg("dim", ` \u23BF run ${runLabel} \xB7 ${status}`), width));
709
+ let error = step?.error;
710
+ error && lines.push(truncLine(theme.fg("error", ` ${error}`), width));
711
+ let snapshotNow = status === "running" ? now : step?.endedAt ?? job.updatedAt, activity = step ? widgetStepActivityLine(step, Math.max(1, width - 4), !0, snapshotNow) : widgetActivity(job, now);
712
+ activity && lines.push(truncLine(theme.fg("dim", ` ${activity}`), width));
713
+ for (let tool of step?.recentTools?.slice(-3) ?? [])
714
+ lines.push(truncLine(theme.fg("dim", ` ${tool.tool}${tool.args ? `: ${tool.args}` : ""}`), width));
715
+ for (let output of step?.recentOutput?.slice(-5) ?? [])
716
+ lines.push(truncLine(theme.fg("dim", ` ${output}`), width));
717
+ for (let nestedLine of formatNestedWidgetLines(step?.children ?? job.nestedChildren, theme, width, !0, snapshotNow))
718
+ lines.push(truncLine(` ${nestedLine}`, width));
719
+ return lines;
829
720
  }
830
721
  function buildWidgetLines(jobs, theme, width = getTermWidth(), expanded = !1, now = Date.now()) {
831
- if (jobs.length === 0)
832
- return [];
833
- if (jobs.length === 1)
834
- return buildSingleWidgetLines(jobs[0], theme, width, expanded, now);
835
- let running = jobs.filter((job) => job.status === "running"), queued = jobs.filter((job) => job.status === "queued"), finished = jobs.filter((job) => job.status !== "running" && job.status !== "queued"), lines = [], hasActive = running.length > 0 || queued.length > 0, headerGlyph = running.length > 0 ? runningGlyph((widgetJobsRunningSeed(running) ?? 0) + widgetAnimFrame(now)) : hasActive ? "\u25CF" : "\u25CB";
836
- lines.push(truncLine(`${theme.fg(hasActive ? "accent" : "dim", headerGlyph)} ${theme.fg(hasActive ? "accent" : "dim", "Async agents")} ${theme.fg("dim", "\xB7 background")}`, width));
837
- let items = [], hiddenRunning = 0, hiddenFinished = 0, queuedSummaryShown = !1, slots = MAX_WIDGET_JOBS;
838
- for (let job of running) {
839
- if (slots <= 0) {
840
- hiddenRunning++;
841
- continue;
842
- }
843
- let row = compactJobChildRows(job, theme, Math.max(1, width - 3), now);
844
- items.push(expanded ? [...row, ...widgetParallelAgentDetails(job, theme, !0, width)] : row), slots--;
845
- }
846
- queued.length > 0 && slots > 0 && (items.push([`${theme.fg("muted", "\u25E6")} ${theme.fg("dim", `${queued.length} queued`)}`]), queuedSummaryShown = !0, slots--);
847
- for (let job of finished) {
848
- if (slots <= 0) {
849
- hiddenFinished++;
850
- continue;
851
- }
852
- let row = compactJobChildRows(job, theme, Math.max(1, width - 3), now);
853
- items.push(expanded ? [...row, ...widgetParallelAgentDetails(job, theme, !0, width)] : row), slots--;
854
- }
855
- let hiddenQueued = queued.length > 0 && !queuedSummaryShown ? queued.length : 0, hiddenTotal = hiddenRunning + hiddenFinished + hiddenQueued;
856
- if (hiddenTotal > 0) {
857
- let parts = [];
858
- hiddenRunning > 0 && parts.push(`${hiddenRunning} running`), hiddenQueued > 0 && parts.push(`${hiddenQueued} queued`), hiddenFinished > 0 && parts.push(`${hiddenFinished} finished`), items.push([theme.fg("dim", `+${hiddenTotal} more (${parts.join(", ")})`)]);
859
- }
860
- for (let i = 0; i < items.length; i++) {
861
- let item = items[i], last = i === items.length - 1, branch = last ? "\u2514\u2500" : "\u251C\u2500", continuation = last ? " " : "\u2502 ";
862
- lines.push(truncLine(`${theme.fg("dim", branch)} ${item[0]}`, width));
863
- for (let detail of item.slice(1))
864
- lines.push(truncLine(`${theme.fg("dim", continuation)} ${detail}`, width));
722
+ let lines = [];
723
+ for (let job of orderedWidgetJobs(jobs)) {
724
+ let steps = job.steps?.length ? job.steps : job.agents?.length ? job.agents.map((agent, index) => ({ agent, description: agent, status: job.status, index })) : [void 0];
725
+ for (let [index, step] of steps.entries())
726
+ lines.push(...compactJobLines(job, step, theme, width, now)), expanded && lines.push(...widgetExpandedDiagnostics(job, step, index, theme, width, now));
865
727
  }
866
728
  return lines;
867
729
  }
@@ -899,7 +761,7 @@ var activeWidget, SubagentAsyncWidget = class {
899
761
  startTimer() {
900
762
  this.timer || (this.timer = setInterval(() => {
901
763
  this.disposed || (this.invalidate(), this.requestRender?.());
902
- }, 80), this.timer.unref?.());
764
+ }, SUBAGENT_PAINT_INTERVAL_MS), this.timer.unref?.());
903
765
  }
904
766
  stopTimer() {
905
767
  this.timer && (clearInterval(this.timer), this.timer = void 0);
@@ -916,7 +778,7 @@ var activeWidget, SubagentAsyncWidget = class {
916
778
  return [];
917
779
  if (this.cachedLines && this.cachedWidth === width && !this.hasRunning())
918
780
  return this.cachedLines;
919
- let now = this.nowFn(), innerWidth = Math.max(1, width - 2), lines = this.expanded ? buildWidgetLines(this.jobs, theme, innerWidth, !0, now) : this.jobs.length === 1 ? compactSingleWidgetLines(this.jobs[0], theme, innerWidth, now) : buildWidgetLines(this.jobs, theme, innerWidth, !1, now), padded = fitAdaptiveWidgetLines(this.jobs, lines, theme, innerWidth, this.expanded).map((line) => {
781
+ let now = this.nowFn(), innerWidth = Math.max(1, width - 2), lines = buildWidgetLines(this.jobs, theme, innerWidth, this.expanded, now), padded = fitAdaptiveWidgetLines(this.jobs, lines, theme, innerWidth, this.expanded).map((line) => {
920
782
  let withPad = ` ${line}`, vis = visibleWidth(withPad);
921
783
  return withPad + " ".repeat(Math.max(0, width - vis));
922
784
  });
@@ -941,65 +803,71 @@ function renderWidget(ctx, jobs) {
941
803
  let widget = new SubagentAsyncWidget(jobs, void 0, { expanded, requestRender });
942
804
  activeWidget = widget, ctx.ui.setWidget(WIDGET_KEY, (_tui, theme) => (widget.setTheme(theme), widget));
943
805
  }
806
+ function compactResultTerminalStatus(result2) {
807
+ if (result2.stopped)
808
+ return "stopped";
809
+ if (result2.detached)
810
+ return "detached";
811
+ if (result2.interrupted)
812
+ return "paused";
813
+ if (result2.exitCode !== 0)
814
+ return "failed";
815
+ }
944
816
  function renderSingleCompact(d, r, theme, frame) {
945
- let output = r.truncation?.text || getSingleResultOutput(r), progress = r.progress || r.progressSummary, isRunning = r.progress?.status === "running", c = new Container(), width = getTermWidth() - 4, lead = compactRowLead({ description: r.description ?? r.agent, task: r.task }), modelBadge = formatCompactModelBadge(r.modelSelection ?? progress?.modelSelection, r.model ?? progress?.model);
946
- return c.addChild(animatedLine((f, now) => formatCompactSubagentRow(theme, width, {
947
- glyph: resultGlyph(r, output, theme, isRunning, void 0, f),
817
+ let output = r.truncation?.text || getSingleResultOutput(r), progress = r.progress || r.progressSummary, isRunning = r.progress?.status === "running", width = getTermWidth() - 4, lead = compactRowLead({ description: r.description ?? r.agent, task: r.task }), modelBadge = formatCompactModelBadge(r.modelSelection ?? progress?.modelSelection, r.model ?? progress?.model);
818
+ return animatedLine((animationTick, now) => formatCompactSubagentRow(theme, width, {
819
+ glyph: resultGlyph(r, output, theme, isRunning, void 0, foregroundSpinnerFrame(animationTick)),
948
820
  description: lead,
949
821
  modelBadge,
950
822
  tokens: compactResultTokens(r),
951
- durationMs: liveDurationMs(progress, isRunning, now)
952
- }), frame, isRunning)), !isRunning && (r.exitCode !== 0 || r.interrupted || r.detached || r.stopped) && c.addChild(new Text(truncLine(theme.fg(r.exitCode !== 0 ? "error" : "dim", ` \u23BF ${resultStatusLine(r, output)}`), width), 0, 0)), c;
823
+ durationMs: liveDurationMs(progress, isRunning, now),
824
+ terminalStatus: compactResultTerminalStatus(r)
825
+ }), frame, isRunning);
826
+ }
827
+ function progressStatusGlyph(progress, theme, frame) {
828
+ return !progress || progress.status === "pending" ? theme.fg("muted", "\u25E6") : progress.status === "running" ? theme.fg("accent", runningGlyph((progressRunningSeed(progress) ?? 0) + (frame ?? 0))) : progress.status === "completed" ? theme.fg("success", "\u2713") : progress.status === "failed" ? theme.fg("error", "\u2717") : theme.fg("warning", "\u25A0");
829
+ }
830
+ function flattenCompactWorkflowNodes(nodes) {
831
+ let rows = [];
832
+ for (let node of nodes)
833
+ node.children?.length ? rows.push(...flattenCompactWorkflowNodes(node.children)) : rows.push(node);
834
+ return rows;
835
+ }
836
+ function compactForegroundEntries(d) {
837
+ let workflowNodes = flattenCompactWorkflowNodes(d.workflowGraph?.nodes ?? []);
838
+ if (workflowNodes.length === 0) {
839
+ let progressCount2 = d.progress?.reduce((count2, entry) => Math.max(count2, entry.index + 1), 0) ?? 0, chainCount = d.mode === "chain" ? buildChainStepSpans(d).reduce((count2, span) => Math.max(count2, span.start + span.count), 0) : 0, count = Math.max(d.results.length, progressCount2, d.chainChildren?.length ?? 0, d.chainAgents?.length ?? 0, chainCount);
840
+ return Array.from({ length: count }, (_, flatIndex) => ({ flatIndex }));
841
+ }
842
+ let entries = workflowNodes.map((node) => ({ flatIndex: node.flatIndex, node })), seen = new Set(entries.flatMap((entry) => entry.flatIndex === void 0 ? [] : [entry.flatIndex])), progressCount = d.progress?.reduce((count, entry) => Math.max(count, entry.index + 1), 0) ?? 0, dataCount = Math.max(d.results.length, progressCount, d.chainChildren?.length ?? 0);
843
+ for (let flatIndex = 0; flatIndex < dataCount; flatIndex++)
844
+ seen.has(flatIndex) || entries.push({ flatIndex });
845
+ return entries;
953
846
  }
954
847
  function renderMultiCompact(d, theme, frame) {
955
- let hasRunning = d.progress?.some((p) => p.status === "running") || d.results.some((r) => r.progress?.status === "running") || workflowGraphHasStatus(d, ["running"]), stopped = d.results.some((r) => r.stopped && r.progress?.status !== "running") || workflowGraphHasStatus(d, ["stopped"]), failed = d.results.some((r) => !r.stopped && r.exitCode !== 0 && r.progress?.status !== "running") || workflowGraphHasStatus(d, ["failed"]), paused = d.results.some((r) => (r.interrupted || r.detached) && r.progress?.status !== "running") || workflowGraphHasStatus(d, ["paused", "detached"]), totalSummary = d.progressSummary;
956
- if (!totalSummary) {
957
- let sawProgress = !1, summary = { toolCount: 0, tokens: 0, durationMs: 0, lastActivityAt: void 0 };
958
- for (let r of d.results) {
959
- let prog = r.progress || r.progressSummary;
960
- prog && (sawProgress = !0, summary.toolCount += prog.toolCount, summary.tokens += prog.tokens, summary.durationMs = d.mode === "chain" ? summary.durationMs + prog.durationMs : Math.max(summary.durationMs, prog.durationMs), prog.status === "running" && prog.lastActivityAt !== void 0 && (summary.lastActivityAt = Math.max(summary.lastActivityAt ?? 0, prog.lastActivityAt)));
961
- }
962
- sawProgress && (totalSummary = summary);
963
- }
964
- let multiLabel = buildMultiProgressLabel(d, hasRunning), itemTitle = multiLabel.itemTitle, glyph = (f) => hasRunning ? theme.fg("accent", runningGlyph(f !== void 0 ? (runningSeed(progressRunningSeed(totalSummary), d.currentStepIndex) ?? 0) + f : runningSeed(progressRunningSeed(totalSummary), d.currentStepIndex))) : stopped ? theme.fg("warning", "\u25A0") : failed ? theme.fg("error", "\u2717") : paused ? theme.fg("warning", "\u25A0") : theme.fg("success", "\u2713"), contextBadge = d.context === "fork" ? theme.fg("warning", " [fork]") : "", c = new Container(), width = getTermWidth() - 4;
965
- c.addChild(animatedLine((f) => {
966
- let stats = statJoin(theme, [multiLabel.headerLabel, formatTotalCostStat(d.totalCost)]);
967
- return truncLine(`${glyph(f)} ${theme.fg("toolTitle", theme.bold(d.mode))}${contextBadge}${stats ? ` ${theme.fg("dim", "\xB7")} ${stats}` : ""}`, width);
968
- }, frame, hasRunning));
969
- let useResultsDirectly = multiLabel.hasParallelInChain || !d.chainAgents?.length, displayStart = multiLabel.showActiveGroupOnly ? multiLabel.groupStartIndex : 0, displayEnd = multiLabel.showActiveGroupOnly ? multiLabel.groupEndIndex : useResultsDirectly ? d.results.length : d.chainAgents.length, chainEntries = buildChainRenderEntries(d, multiLabel), renderEntries = chainEntries ?? Array.from({ length: displayEnd - displayStart }, (_, offset) => {
970
- let i = displayStart + offset, r = d.results[i], fallbackLabel = itemTitle.toLowerCase(), rowNumber = multiLabel.showActiveGroupOnly ? i - multiLabel.groupStartIndex + 1 : i + 1;
971
- return { kind: "result", resultIndex: i, rowNumber, agentName: useResultsDirectly ? r?.agent || `${fallbackLabel}-${rowNumber}` : d.chainAgents[i] || r?.agent || `${fallbackLabel}-${rowNumber}` };
972
- });
973
- for (let entry of renderEntries) {
974
- if (entry.kind === "placeholder") {
975
- let glyph2 = widgetStepGlyph(entry.status, theme), statusLabel = widgetStepStatus(entry.status, theme);
976
- c.addChild(new Text(truncLine(` ${glyph2} ${entry.stepLabel}: ${themeBold(theme, entry.agentName)} ${theme.fg("dim", "\xB7")} ${statusLabel}`, width), 0, 0)), entry.error && c.addChild(new Text(truncLine(theme.fg("error", ` \u23BF Error: ${entry.error}`), width), 0, 0));
977
- continue;
978
- }
979
- let i = entry.resultIndex, r = d.results[i], rowNumber = entry.rowNumber, agentName = entry.agentName;
980
- if (!r) {
981
- let pendingLabel = chainEntries ? resultRowLabel(d, multiLabel, i, rowNumber) : `${itemTitle} ${rowNumber}`;
982
- c.addChild(new Text(truncLine(theme.fg("dim", ` \u25E6 ${pendingLabel}: ${agentName} \xB7 pending`), width), 0, 0));
983
- continue;
984
- }
985
- let output = getSingleResultOutput(r), progressFromArray = d.progress?.find((p) => p.index === i) || d.progress?.find((p) => p.agent === r.agent && p.status === "running"), rProg = r.progress || progressFromArray || r.progressSummary, rRunning = rProg && "status" in rProg && rProg.status === "running", rPending = rProg && "status" in rProg && rProg.status === "pending", lead = compactRowLead({ description: r.description ?? agentName, task: r.task }), modelBadge = formatCompactModelBadge(r.modelSelection ?? (rProg && "modelSelection" in rProg ? rProg.modelSelection : void 0), r.model ?? (rProg && "model" in rProg ? rProg.model : void 0));
986
- c.addChild(animatedLine((f, now) => {
987
- let rowGlyph = rPending ? theme.fg("dim", "\u25E6") : resultGlyph(r, output, theme, rRunning, progressRunningSeed(rProg), f);
848
+ let c = new Container(), width = getTermWidth() - 4, entries = compactForegroundEntries(d);
849
+ for (let [rowIndex, entry] of entries.entries()) {
850
+ let flatIndex = entry.flatIndex, result2 = flatIndex === void 0 ? void 0 : resultAtFlatIndex(d, flatIndex), progress = result2?.progress ?? (flatIndex === void 0 ? void 0 : d.progress?.find((candidate) => candidate.index === flatIndex)) ?? result2?.progressSummary, status = progress?.status ?? entry.node?.status ?? "pending", description = compactRowLead({
851
+ description: result2?.description ?? progress?.description ?? entry.node?.label ?? (flatIndex === void 0 ? void 0 : d.chainChildren?.[flatIndex]?.description) ?? (flatIndex === void 0 ? void 0 : d.chainAgents?.[flatIndex]) ?? result2?.agent ?? progress?.agent,
852
+ task: result2?.task ?? progress?.task
853
+ }) || `child ${rowIndex + 1}`, running = status === "running", output = result2 ? getSingleResultOutput(result2) : "", modelBadge = formatCompactModelBadge(result2?.modelSelection ?? progress?.modelSelection, result2?.model ?? progress?.model);
854
+ c.addChild(animatedLine((animationTick, now) => {
855
+ let animationFrame = foregroundSpinnerFrame(animationTick);
988
856
  return formatCompactSubagentRow(theme, width, {
989
- glyph: rowGlyph,
990
- description: lead,
857
+ glyph: result2 ? resultGlyph(result2, output, theme, running, progressRunningSeed(progress), animationFrame) : progressStatusGlyph({ ...progress, status, index: flatIndex }, theme, animationFrame),
858
+ description,
991
859
  modelBadge,
992
- tokens: compactResultTokens(r),
993
- durationMs: liveDurationMs(rProg, !!rRunning, now),
994
- prefix: " "
860
+ tokens: result2 ? compactResultTokens(result2) : progress?.tokens ?? 0,
861
+ durationMs: liveDurationMs(progress, running, now),
862
+ terminalStatus: result2 ? compactResultTerminalStatus(result2) : compactTerminalStatus(status)
995
863
  });
996
- }, frame, !!rRunning)), !rPending && !rRunning && (r.exitCode !== 0 || r.interrupted || r.detached || r.stopped) && c.addChild(new Text(truncLine(theme.fg(r.exitCode !== 0 ? "error" : "dim", ` \u23BF ${resultStatusLine(r, output)}`), width), 0, 0));
864
+ }, frame, running));
997
865
  }
998
866
  return c;
999
867
  }
1000
868
  function renderSubagentResult(result2, options, theme, frame) {
1001
- let d = result2.details;
1002
- if (!d || !d.results.length) {
869
+ let d = result2.details, hasWorkflowRows = d?.mode !== "management" && !!(d?.workflowGraph?.nodes.length || d?.progress?.length || d?.chainChildren?.length);
870
+ if (!d || !d.results.length && !hasWorkflowRows) {
1003
871
  let t = result2.content[0], text = t?.type === "text" ? t.text : "(no output)", contextPrefix = d?.context === "fork" ? `${theme.fg("warning", "[fork]")} ` : "", width = getTermWidth() - 4;
1004
872
  if (!text.includes(`
1005
873
  `))
@@ -1020,7 +888,7 @@ function renderSubagentResult(result2, options, theme, frame) {
1020
888
  return fit3(`${icon2} ${theme.fg("toolTitle", theme.bold(r.agent))}${modelDisplay}${contextBadge2}${stats ? ` | ${stats}` : ""}`);
1021
889
  }, frame, isRunning)), c2.addChild(new Spacer(1));
1022
890
  let taskMaxLen = Math.max(20, w2 - 8), taskPreview = expanded || r.task.length <= taskMaxLen ? r.task : `${r.task.slice(0, taskMaxLen)}...`;
1023
- if (c2.addChild(new Text(fit3(theme.fg("dim", `Task: ${taskPreview}`)), 0, 0)), c2.addChild(new Spacer(1)), isRunning && r.progress) {
891
+ if (c2.addChild(new Text(fit3(theme.fg("dim", `Task: ${taskPreview}`)), 0, 0)), !isRunning && compactResultTerminalStatus(r) && c2.addChild(new Text(fit3(theme.fg(r.exitCode !== 0 ? "error" : "warning", resultStatusLine(r, output))), 0, 0)), c2.addChild(new Spacer(1)), isRunning && r.progress) {
1024
892
  let progressSnapshotNow = snapshotNowForProgress(r.progress), toolLine = formatCurrentToolLine(r.progress, w2, expanded, progressSnapshotNow);
1025
893
  toolLine && c2.addChild(new Text(fit3(theme.fg("warning", `> ${toolLine}`)), 0, 0));
1026
894
  let liveStatusLine = buildLiveStatusLine(r.progress, progressSnapshotNow);
@@ -1042,7 +910,7 @@ function renderSubagentResult(result2, options, theme, frame) {
1042
910
  }
1043
911
  if (!expanded)
1044
912
  return renderMultiCompact(d, theme, frame);
1045
- let hasRunning = d.progress?.some((p) => p.status === "running") || d.results.some((r) => r.progress?.status === "running") || workflowGraphHasStatus(d, ["running"]), ok = d.results.filter((r) => r.progress?.status === "completed" || r.exitCode === 0 && r.progress?.status !== "running").length, hasEmptyWithoutTarget = d.results.some((r) => r.exitCode === 0 && r.progress?.status !== "running" && hasEmptyTextOutputWithoutOutputTarget(r.task, getSingleResultOutput(r))), hasWorkflowFailure = workflowGraphHasStatus(d, ["failed"]), hasWorkflowStop = d.results.some((r) => r.stopped && r.progress?.status !== "running") || workflowGraphHasStatus(d, ["stopped"]), hasWorkflowPause = workflowGraphHasStatus(d, ["paused", "detached"]), icon = hasRunning ? theme.fg("warning", "running") : hasEmptyWithoutTarget ? theme.fg("warning", "warning") : hasWorkflowFailure ? theme.fg("error", "failed") : hasWorkflowStop ? theme.fg("warning", "stopped") : hasWorkflowPause ? theme.fg("warning", "paused") : ok === d.results.length ? theme.fg("success", "ok") : theme.fg("error", "failed"), totalSummary = d.progressSummary || d.results.reduce((acc, r) => {
913
+ let hasRunning = d.progress?.some((p) => p.status === "running") || d.results.some((r) => r.progress?.status === "running") || workflowGraphHasStatus(d, ["running"]), ok = d.results.filter((r) => r.progress?.status === "completed" || r.exitCode === 0 && r.progress?.status !== "running").length, hasEmptyWithoutTarget = d.results.some((r) => r.exitCode === 0 && r.progress?.status !== "running" && hasEmptyTextOutputWithoutOutputTarget(r.task, getSingleResultOutput(r))), hasWorkflowFailure = workflowGraphHasStatus(d, ["failed"]), hasWorkflowStop = d.results.some((r) => r.stopped && r.progress?.status !== "running") || workflowGraphHasStatus(d, ["stopped"]), hasWorkflowPause = workflowGraphHasStatus(d, ["paused", "detached"]), hasWorkflowPending = workflowGraphHasStatus(d, ["pending"]), icon = hasRunning ? theme.fg("warning", "running") : hasEmptyWithoutTarget ? theme.fg("warning", "warning") : hasWorkflowFailure ? theme.fg("error", "failed") : hasWorkflowStop ? theme.fg("warning", "stopped") : hasWorkflowPause ? theme.fg("warning", "paused") : hasWorkflowPending ? theme.fg("dim", "pending") : ok === d.results.length ? theme.fg("success", "ok") : theme.fg("error", "failed"), totalSummary = d.progressSummary || d.results.reduce((acc, r) => {
1046
914
  let prog = r.progress || r.progressSummary;
1047
915
  return prog && (acc.toolCount += prog.toolCount, acc.tokens += prog.tokens, acc.durationMs = d.mode === "chain" ? acc.durationMs + prog.durationMs : Math.max(acc.durationMs, prog.durationMs)), acc;
1048
916
  }, { toolCount: 0, tokens: 0, durationMs: 0 }), modeLabel = d.mode, contextBadge = d.context === "fork" ? theme.fg("warning", " [fork]") : "", multiLabel = buildMultiProgressLabel(d, hasRunning), itemTitle = multiLabel.itemTitle, chainVis = d.chainAgents?.length && !multiLabel.hasParallelInChain ? d.chainAgents.map((agent, i) => {
@@ -1056,10 +924,26 @@ function renderSubagentResult(result2, options, theme, frame) {
1056
924
  ].filter(Boolean), summaryStr = summaryParts.length ? ` | ${summaryParts.join(", ")}` : "";
1057
925
  return fit2(`${icon} ${theme.fg("toolTitle", theme.bold(modeLabel))}${contextBadge} \xB7 ${multiLabel.headerLabel}${summaryStr}`);
1058
926
  }, frame, hasRunning)), chainVis && c.addChild(new Text(fit2(` ${chainVis}`), 0, 0));
1059
- let useResultsDirectly = multiLabel.hasParallelInChain || !d.chainAgents?.length, displayStart = multiLabel.showActiveGroupOnly ? multiLabel.groupStartIndex : 0, displayEnd = multiLabel.showActiveGroupOnly ? multiLabel.groupEndIndex : useResultsDirectly ? d.results.length : d.chainAgents.length, chainEntries = buildChainRenderEntries(d, multiLabel), renderEntries = chainEntries ?? Array.from({ length: displayEnd - displayStart }, (_, offset) => {
1060
- let i = displayStart + offset, r = d.results[i], rowNumber = multiLabel.showActiveGroupOnly ? i - multiLabel.groupStartIndex + 1 : i + 1;
1061
- return { kind: "result", resultIndex: i, rowNumber, agentName: useResultsDirectly ? r?.agent || `step-${rowNumber}` : d.chainAgents[i] || r?.agent || `step-${rowNumber}` };
1062
- });
927
+ let chainEntries = buildChainRenderEntries(d, multiLabel), fallbackEntries = compactForegroundEntries(d).filter((entry) => !multiLabel.showActiveGroupOnly || entry.flatIndex === void 0 || entry.flatIndex >= multiLabel.groupStartIndex && entry.flatIndex < multiLabel.groupEndIndex).map((entry, rowIndex) => {
928
+ if (entry.flatIndex === void 0)
929
+ return {
930
+ kind: "placeholder",
931
+ rowNumber: entry.node?.stepIndex !== void 0 ? entry.node.stepIndex + 1 : rowIndex + 1,
932
+ stepLabel: `Step ${entry.node?.stepIndex !== void 0 ? entry.node.stepIndex + 1 : rowIndex + 1}`,
933
+ agentName: entry.node?.label ?? `step-${rowIndex + 1}`,
934
+ status: entry.node?.status ?? "pending",
935
+ error: entry.node?.error
936
+ };
937
+ let result3 = resultAtFlatIndex(d, entry.flatIndex), rowNumber = multiLabel.showActiveGroupOnly ? entry.flatIndex - multiLabel.groupStartIndex + 1 : entry.flatIndex + 1;
938
+ return {
939
+ kind: "result",
940
+ resultIndex: entry.flatIndex,
941
+ rowNumber,
942
+ agentName: result3?.agent ?? entry.node?.label ?? d.chainChildren?.[entry.flatIndex]?.description ?? d.chainAgents?.[entry.flatIndex] ?? `step-${rowNumber}`,
943
+ status: entry.node?.status,
944
+ error: entry.node?.error
945
+ };
946
+ }), renderEntries = chainEntries ?? fallbackEntries;
1063
947
  c.addChild(new Spacer(1));
1064
948
  for (let entry of renderEntries) {
1065
949
  if (entry.kind === "placeholder") {
@@ -1067,10 +951,10 @@ function renderSubagentResult(result2, options, theme, frame) {
1067
951
  c.addChild(new Text(fit2(` ${statusLabel} ${entry.stepLabel}: ${theme.bold(entry.agentName)}`), 0, 0)), c.addChild(new Text(theme.fg(entry.status === "failed" ? "error" : "dim", ` status: ${entry.status}`), 0, 0)), entry.error && c.addChild(new Text(theme.fg("error", ` error: ${entry.error}`), 0, 0)), c.addChild(new Spacer(1));
1068
952
  continue;
1069
953
  }
1070
- let i = entry.resultIndex, r = d.results[i], rowNumber = entry.rowNumber, agentName = entry.agentName;
954
+ let i = entry.resultIndex, r = resultAtFlatIndex(d, i), rowNumber = entry.rowNumber, agentName = entry.agentName;
1071
955
  if (!r) {
1072
- let pendingLabel = chainEntries ? resultRowLabel(d, multiLabel, i, rowNumber) : `${itemTitle} ${rowNumber}`;
1073
- c.addChild(new Text(fit2(theme.fg("dim", ` ${pendingLabel}: ${agentName}`)), 0, 0)), c.addChild(new Text(theme.fg("dim", " status: pending"), 0, 0)), c.addChild(new Spacer(1));
956
+ let rowLabel = chainEntries ? resultRowLabel(d, multiLabel, i, rowNumber) : `${itemTitle} ${rowNumber}`, status = entry.status ?? "pending";
957
+ c.addChild(new Text(fit2(theme.fg(status === "failed" ? "error" : "dim", ` ${rowLabel}: ${agentName}`)), 0, 0)), c.addChild(new Text(theme.fg(status === "failed" ? "error" : "dim", ` status: ${status}`), 0, 0)), entry.error && c.addChild(new Text(theme.fg("error", ` error: ${entry.error}`), 0, 0)), c.addChild(new Spacer(1));
1074
958
  continue;
1075
959
  }
1076
960
  let progressFromArray = d.progress?.find((p) => p.index === i) || d.progress?.find((p) => p.agent === r.agent && p.status === "running"), rProg = r.progress || progressFromArray || r.progressSummary, rRunning = rProg?.status === "running", stepNumber = typeof rProg?.index == "number" ? rProg.index + 1 : i + 1, resultOutput = getSingleResultOutput(r), statusIcon = rRunning ? theme.fg("warning", "running") : r.exitCode !== 0 ? theme.fg("error", "failed") : hasEmptyTextOutputWithoutOutputTarget(r.task, resultOutput) ? theme.fg("warning", "warning") : theme.fg("success", "done"), modelDisplay = modelThinkingBadge(theme, r.model, r.thinking ?? (rProg && "thinking" in rProg ? rProg.thinking : void 0), r.modelSelection ?? (rProg && "modelSelection" in rProg ? rProg.modelSelection : void 0)), stepLabel = resultRowLabel(d, multiLabel, i, stepNumber), toolCallLines = getToolCallLines(r, expanded);
@@ -1079,7 +963,7 @@ function renderSubagentResult(result2, options, theme, frame) {
1079
963
  return fit2(rRunning ? `${statusIcon} ${stepLabel}: ${theme.bold(theme.fg("warning", r.agent))}${modelDisplay}${stats ? ` | ${stats}` : ""}` : `${statusIcon} ${stepLabel}: ${theme.bold(r.agent)}${modelDisplay}${stats ? ` | ${stats}` : ""}`);
1080
964
  }, frame, rRunning));
1081
965
  let taskMaxLen = Math.max(20, w - 12), taskPreview = expanded || r.task.length <= taskMaxLen ? r.task : `${r.task.slice(0, taskMaxLen)}...`;
1082
- if (c.addChild(new Text(fit2(theme.fg("dim", ` task: ${taskPreview}`)), 0, 0)), r.skills?.length && c.addChild(new Text(fit2(theme.fg("dim", ` skills: ${r.skills.join(", ")}`)), 0, 0)), r.skillsWarning && c.addChild(new Text(fit2(theme.fg("warning", ` Warning: ${r.skillsWarning}`)), 0, 0)), r.attemptedModels && r.attemptedModels.length > 1 && c.addChild(new Text(fit2(theme.fg("dim", ` fallbacks: ${r.attemptedModels.join(" \u2192 ")}`)), 0, 0)), rRunning && rProg) {
966
+ if (c.addChild(new Text(fit2(theme.fg("dim", ` task: ${taskPreview}`)), 0, 0)), !rRunning && compactResultTerminalStatus(r) && c.addChild(new Text(fit2(theme.fg(r.exitCode !== 0 ? "error" : "warning", ` ${resultStatusLine(r, resultOutput)}`)), 0, 0)), r.skills?.length && c.addChild(new Text(fit2(theme.fg("dim", ` skills: ${r.skills.join(", ")}`)), 0, 0)), r.skillsWarning && c.addChild(new Text(fit2(theme.fg("warning", ` Warning: ${r.skillsWarning}`)), 0, 0)), r.attemptedModels && r.attemptedModels.length > 1 && c.addChild(new Text(fit2(theme.fg("dim", ` fallbacks: ${r.attemptedModels.join(" \u2192 ")}`)), 0, 0)), rRunning && rProg) {
1083
967
  rProg.skills?.length && c.addChild(new Text(fit2(theme.fg("accent", ` skills: ${rProg.skills.join(", ")}`)), 0, 0));
1084
968
  let progressSnapshotNow = snapshotNowForProgress(rProg), toolLine = formatCurrentToolLine(rProg, w, expanded, progressSnapshotNow);
1085
969
  toolLine && c.addChild(new Text(fit2(theme.fg("warning", ` > ${toolLine}`)), 0, 0));
@@ -1349,7 +1233,7 @@ var SkillOverride = Type.Unsafe({
1349
1233
  description: "Children always start with a fresh session. Fork context is not available."
1350
1234
  })),
1351
1235
  chainDir: Type.Optional(Type.String({ description: "Persistent chain artifact directory; defaults to user-scoped temp storage." })),
1352
- async: Type.Optional(Type.Boolean({ description: "Run in background (default: false, or per config)" })),
1236
+ async: Type.Optional(Type.Boolean({ description: "Run async in the background. Defaults to true when omitted; set false for immediate foreground results." })),
1353
1237
  timeoutMs: Type.Optional(Type.Integer({ minimum: 1, description: "Optional run-level timeout in ms for foreground and async/background runs. Alias of maxRuntimeMs." })),
1354
1238
  maxRuntimeMs: Type.Optional(Type.Integer({ minimum: 1, description: "Alias of timeoutMs for optional run-level timeout in foreground and async/background runs." })),
1355
1239
  turnBudget: Type.Optional(TurnBudgetOverride),
@@ -1360,7 +1244,7 @@ var SkillOverride = Type.Unsafe({
1360
1244
  share: Type.Optional(Type.Boolean({ description: "Upload session to GitHub Gist for sharing (default: false)" })),
1361
1245
  sessionDir: Type.Optional(Type.String({ description: "Directory to store session logs (default: temp; enables sessions even if share=false)" })),
1362
1246
  // Clarification TUI
1363
- clarify: Type.Optional(Type.Boolean({ description: "Show TUI to preview/edit before execution. Explicit clarify: true keeps the run foreground for the clarify UI; omitted clarify can still run in the background when async: true is set." })),
1247
+ clarify: Type.Optional(Type.Boolean({ description: "Show the interactive TUI preview/editor before execution. clarify:true keeps the run foreground even when async is omitted or true." })),
1364
1248
  control: Type.Optional(ControlOverrides),
1365
1249
  output: Type.Optional(Type.Unsafe({
1366
1250
  anyOf: [
@@ -1596,7 +1480,7 @@ function createAsyncJobTracker(pi, state, asyncDirRoot, options = {}) {
1596
1480
  if (parsed.type !== "subagent.control")
1597
1481
  return;
1598
1482
  let record = parsed;
1599
- if (!record.event || !Array.isArray(record.channels))
1483
+ if (!record.event || !Array.isArray(record.channels) || record.event.reason === "completion_guard")
1600
1484
  return;
1601
1485
  let payload = {
1602
1486
  event: record.event,
@@ -1922,7 +1806,7 @@ ${baseOutput}` : ""}` : output, sessionPath = result2.sessionFile ?? (resultChil
1922
1806
  asyncId: data.id,
1923
1807
  asyncDir: data.asyncDir
1924
1808
  });
1925
- payload.requestId = `async-result:${sessionId}:${completionKey}`, attempts.set(file, (attempts.get(file) ?? 0) + 1);
1809
+ payload.requestId = `async-result:${sessionId}:${completionKey}`, payload.ownerNotificationSessionId = sessionId, attempts.set(file, (attempts.get(file) ?? 0) + 1);
1926
1810
  let delivered = await deliverSubagentResultIntercomEvent(pi.events, payload);
1927
1811
  if (!isCurrent())
1928
1812
  return;
@@ -2527,7 +2411,7 @@ function substituteArgs(template, args) {
2527
2411
  return template.replace(/\$ARGUMENTS/g, all).replace(/\$@/g, all).replace(/\$\{(\d+):-([^}]*)\}/g, (_match, index, fallback) => args[Number(index) - 1] || fallback).replace(/\$(\d+)/g, (_match, index) => args[Number(index) - 1] ?? "");
2528
2412
  }
2529
2413
  function parseRuntimeOptions(words) {
2530
- let args = [], descriptionOverride, permissions, worktree = !1, bg = !1;
2414
+ let args = [], descriptionOverride, permissions, worktree = !1, async;
2531
2415
  for (let i = 0; i < words.length; i++) {
2532
2416
  let word = words[i];
2533
2417
  if (word === "--read-only") {
@@ -2543,7 +2427,11 @@ function parseRuntimeOptions(words) {
2543
2427
  continue;
2544
2428
  }
2545
2429
  if (word === "--bg" || word === "--async") {
2546
- bg = !0;
2430
+ async = !0;
2431
+ continue;
2432
+ }
2433
+ if (word === "--fg" || word === "--foreground") {
2434
+ async = !1;
2547
2435
  continue;
2548
2436
  }
2549
2437
  if (word === "--description") {
@@ -2557,7 +2445,7 @@ function parseRuntimeOptions(words) {
2557
2445
  }
2558
2446
  args.push(word);
2559
2447
  }
2560
- return { args, descriptionOverride, permissions, worktree, bg };
2448
+ return { args, descriptionOverride, permissions, worktree, async };
2561
2449
  }
2562
2450
  function splitChainDeclaration(input) {
2563
2451
  let delimiter = input.indexOf(" -- ");
@@ -2576,7 +2464,7 @@ function workflowParams(workflow, args, runtime) {
2576
2464
  ...workflow.skill !== void 0 ? { skill: workflow.skill } : {},
2577
2465
  ...workflow.cwd ? { cwd: workflow.cwd } : {},
2578
2466
  ...runtime.worktree || workflow.worktree ? { worktree: !0 } : {},
2579
- ...runtime.bg ? { async: !0 } : {}
2467
+ ...runtime.async !== void 0 ? { async: runtime.async } : {}
2580
2468
  };
2581
2469
  }
2582
2470
  function workflowChainStep(workflow, args, runtime) {
@@ -2624,7 +2512,7 @@ function registerPromptWorkflowCommands(input) {
2624
2512
  throw new Error(`Unknown prompt workflow in chain '${workflow.name}': ${stepName}`);
2625
2513
  return workflowChainStep(step, runtime.args, runtime);
2626
2514
  });
2627
- await run({ chain, task: runtime.args.join(" "), clarify: !1, ...runtime.bg ? { async: !0 } : {} }, ctx);
2515
+ await run({ chain, task: runtime.args.join(" "), clarify: !1, ...runtime.async !== void 0 ? { async: runtime.async } : {} }, ctx);
2628
2516
  return;
2629
2517
  }
2630
2518
  await run(workflowParams(workflow, runtime.args, runtime), ctx);
@@ -2652,7 +2540,7 @@ function registerPromptWorkflowCommands(input) {
2652
2540
  throw new Error(`Unknown prompt workflow: ${name}`);
2653
2541
  return workflowChainStep(workflow, runtime.args, runtime);
2654
2542
  });
2655
- await run({ chain, task: runtime.args.join(" "), clarify: !1, ...runtime.bg ? { async: !0 } : {} }, ctx);
2543
+ await run({ chain, task: runtime.args.join(" "), clarify: !1, ...runtime.async !== void 0 ? { async: runtime.async } : {} }, ctx);
2656
2544
  } catch (error) {
2657
2545
  ctx.ui.notify(error instanceof Error ? error.message : String(error), "error");
2658
2546
  }
@@ -3232,15 +3120,14 @@ var parseInlineConfig = (raw) => {
3232
3120
  let end = token.lastIndexOf("]");
3233
3121
  return { name: token.slice(0, bracket), config: parseInlineConfig(token.slice(bracket + 1, end !== -1 ? end : void 0)) };
3234
3122
  }, extractExecutionFlags = (rawArgs) => {
3235
- let args = rawArgs.trim(), bg = !1;
3123
+ let args = rawArgs.trim(), async;
3236
3124
  for (; ; ) {
3237
- if (args.endsWith(" --bg") || args === "--bg") {
3238
- bg = !0, args = args === "--bg" ? "" : args.slice(0, -5).trim();
3239
- continue;
3240
- }
3241
- break;
3125
+ let match = args.match(/(?:^|\s)(--bg|--async|--fg|--foreground)$/);
3126
+ if (!match)
3127
+ break;
3128
+ async ??= match[1] === "--bg" || match[1] === "--async", args = args.slice(0, match.index).trim();
3242
3129
  }
3243
- return { args, bg };
3130
+ return { args, async };
3244
3131
  };
3245
3132
  function sendSlashText(pi, text) {
3246
3133
  pi.sendMessage({ customType: SLASH_TEXT_RESULT_TYPE, content: text, display: !0 });
@@ -3821,16 +3708,16 @@ function registerSlashCommands(pi, state) {
3821
3708
  }
3822
3709
  };
3823
3710
  pi.registerCommand("run", {
3824
- description: "Run a prompt-defined child: /run description[tier=standard] task [--bg]",
3711
+ description: "Run an async prompt-defined child; add --foreground to wait inline",
3825
3712
  handler: async (args, ctx) => {
3826
- let { args: cleanedArgs, bg } = extractExecutionFlags(args), input = cleanedArgs.trim(), firstSpace = input.indexOf(" ");
3713
+ let { args: cleanedArgs, async } = extractExecutionFlags(args), input = cleanedArgs.trim(), firstSpace = input.indexOf(" ");
3827
3714
  if (!input) {
3828
- ctx.ui.notify("Usage: /run <description> <task> [--bg]", "error");
3715
+ ctx.ui.notify("Usage: /run <description> <task> [--foreground]", "error");
3829
3716
  return;
3830
3717
  }
3831
3718
  let { name: description, config: inline } = parseAgentToken(firstSpace === -1 ? input : input.slice(0, firstSpace)), task = firstSpace === -1 ? "" : input.slice(firstSpace + 1).trim();
3832
3719
  if (!description || !task || !inline.tier) {
3833
- ctx.ui.notify("Usage: /run <description>[tier=light|standard|heavy] <task> [--bg]", "error");
3720
+ ctx.ui.notify("Usage: /run <description>[tier=light|standard|heavy] <task> [--foreground]", "error");
3834
3721
  return;
3835
3722
  }
3836
3723
  let finalTask = task;
@@ -3838,21 +3725,21 @@ function registerSlashCommands(pi, state) {
3838
3725
 
3839
3726
  ${finalTask}`);
3840
3727
  let params = { description, permissions: inline.permissions ?? "full", tier: inline.tier, task: finalTask, clarify: !1 };
3841
- inline.output !== void 0 && (params.output = inline.output), inline.outputMode !== void 0 && (params.outputMode = inline.outputMode), inline.skill !== void 0 && (params.skill = inline.skill), bg && (params.async = !0), await runSlashSubagent(pi, ctx, params);
3728
+ inline.output !== void 0 && (params.output = inline.output), inline.outputMode !== void 0 && (params.outputMode = inline.outputMode), inline.skill !== void 0 && (params.skill = inline.skill), async !== void 0 && (params.async = async), await runSlashSubagent(pi, ctx, params);
3842
3729
  }
3843
3730
  }), pi.registerCommand("chain", {
3844
- description: 'Run prompt-defined children in sequence: /chain inspect "task" -> implement [--bg]',
3731
+ description: "Run prompt-defined children as an async sequence; add --foreground to wait inline",
3845
3732
  handler: async (args, ctx) => {
3846
- let { args: cleanedArgs, bg } = extractExecutionFlags(args), built = buildChainExpressionSteps(state, cleanedArgs, ctx);
3733
+ let { args: cleanedArgs, async } = extractExecutionFlags(args), built = buildChainExpressionSteps(state, cleanedArgs, ctx);
3847
3734
  if (!built)
3848
3735
  return;
3849
3736
  let params = { chain: built.chain, task: built.task, clarify: !1 };
3850
- bg && (params.async = !0), await runSlashSubagent(pi, ctx, params);
3737
+ async !== void 0 && (params.async = async), await runSlashSubagent(pi, ctx, params);
3851
3738
  }
3852
3739
  }), pi.registerCommand("parallel", {
3853
- description: 'Run prompt-defined children in parallel: /parallel inspect "task1" -> review "task2" [--bg]',
3740
+ description: "Run prompt-defined children async in parallel; add --foreground to wait inline",
3854
3741
  handler: async (args, ctx) => {
3855
- let { args: cleanedArgs, bg } = extractExecutionFlags(args), parsed = parseAgentArgs(state, cleanedArgs, "parallel", ctx);
3742
+ let { args: cleanedArgs, async } = extractExecutionFlags(args), parsed = parseAgentArgs(state, cleanedArgs, "parallel", ctx);
3856
3743
  if (!parsed)
3857
3744
  return;
3858
3745
  let tasks = parsed.steps.map(({ name, config, task: stepTask }) => ({
@@ -3877,7 +3764,7 @@ ${finalTask}`);
3877
3764
  return;
3878
3765
  }
3879
3766
  let params = { tasks, clarify: !1 };
3880
- bg && (params.async = !0), await runSlashSubagent(pi, ctx, params);
3767
+ async !== void 0 && (params.async = async), await runSlashSubagent(pi, ctx, params);
3881
3768
  }
3882
3769
  }), pi.registerCommand("subagent-cost", {
3883
3770
  description: "Show parent and subagent child usage cost for this session",
@@ -4591,6 +4478,7 @@ function parseQuestionRecord(raw) {
4591
4478
  runId: input.runId.trim(),
4592
4479
  childIndex,
4593
4480
  childId: input.childId.trim(),
4481
+ ...typeof input.childDescription == "string" && input.childDescription.trim() ? { childDescription: input.childDescription.trim() } : {},
4594
4482
  parentSessionId: input.parentSessionId.trim(),
4595
4483
  parentGeneration,
4596
4484
  ...incarnation ? { childIncarnation: incarnation } : {}
@@ -4699,6 +4587,7 @@ function createSupervisorQuestion(input) {
4699
4587
  runId: input.runId,
4700
4588
  childIndex: input.childIndex,
4701
4589
  childId: input.childId,
4590
+ ...input.childDescription ? { childDescription: input.childDescription } : {},
4702
4591
  parentSessionId: input.parentSessionId,
4703
4592
  parentGeneration: input.parentGeneration,
4704
4593
  ...input.childIncarnation ? { childIncarnation: input.childIncarnation } : {}
@@ -4764,8 +4653,7 @@ function formatParentQuestionForChild(question) {
4764
4653
  function formatSupervisorQuestionAnswer(question) {
4765
4654
  let state = supervisorQuestionPublicState(question), lines = [
4766
4655
  state === "answered" ? `Subagent answer (${question.id})` : `Subagent question ${state} (${question.id})`,
4767
- `Run: ${question.runId}`,
4768
- `Child: ${question.childId} [#${question.childIndex}]`,
4656
+ `From: ${question.childDescription ?? `Subagent ${question.childIndex + 1}`}`,
4769
4657
  `Decision: ${question.reason}`
4770
4658
  ];
4771
4659
  return state === "answered" && question.answer?.trim() ? lines.push("", question.answer.trim()) : question.cancelReason && lines.push("", question.cancelReason), lines.join(`
@@ -4922,8 +4810,9 @@ function askRunningAsyncChild(input) {
4922
4810
  let capability = readSteerCapability(resolved.location.asyncDir, child.index);
4923
4811
  if (!capability?.supported)
4924
4812
  throw new Error("This child is not ready to receive questions. Continue other work until it is ready; no question was queued.");
4925
- let incarnation = { pid: capability.pid, readyAt: capability.readyAt }, question = createSupervisorQuestion({
4813
+ let incarnation = { pid: capability.pid, readyAt: capability.readyAt }, step = status.steps?.[child.index], childDescription = resolveCommunicationPeer(input.state, status.runId, child.index, child.childId, step?.description ?? child.agent), question = createSupervisorQuestion({
4926
4814
  channelDir,
4815
+ childDescription,
4927
4816
  reason,
4928
4817
  message,
4929
4818
  runId: status.runId,
@@ -4953,12 +4842,50 @@ function askRunningAsyncChild(input) {
4953
4842
  runId: status.runId,
4954
4843
  childIndex: child.index,
4955
4844
  childId: child.childId,
4845
+ communication: { direction: "to", peer: childDescription, message, kind: "question" },
4956
4846
  delivered: !1,
4957
4847
  answered: !1
4958
4848
  }
4959
4849
  };
4960
4850
  }
4961
4851
 
4852
+ // packages/coding-agent/dist/builtin-extensions/pi-subagents/src/tui/communication.js
4853
+ import { Box, Container as Container2, Text as Text2 } from "@ashx-j/lunr-tui";
4854
+ function renderCommunicationBody(communication, theme) {
4855
+ let direction = communication.direction === "from" ? "From" : "To";
4856
+ return new Text2(`${theme.fg("muted", `${direction}: ${communication.peer}`)}
4857
+
4858
+ ${communication.message}`, 0, 0);
4859
+ }
4860
+ function renderCommunicationCard(communication, expanded, theme) {
4861
+ let box = new Box(1, 1, (text) => theme.bg("toolSuccessBg", text));
4862
+ return box.addChild(new Text2(theme.fg("toolTitle", theme.bold(`\u25CF subagent ${communication.kind}`)), 0, 0)), expanded && box.addChild(renderCommunicationBody(communication, theme)), box;
4863
+ }
4864
+ function renderCommunicationCall(name, args, theme, context, communication) {
4865
+ let container = new Container2(), details = context?.result?.details, saved = readCommunication(details?.communication) ?? communication, action = args.action ?? (args.reason === "need_decision" ? "request" : args.reason === "interview_request" ? "interview" : args.reason === "progress_update" ? "progress" : args.reason);
4866
+ return container.addChild(new Text2(theme.fg("toolTitle", theme.bold(`${name}${action ? ` ${action}` : ""}`)), 0, 0)), context?.expanded && saved && container.addChild(renderCommunicationBody(saved, theme)), container;
4867
+ }
4868
+ function renderCommunicationResult(content, details, expanded, isError, theme) {
4869
+ let container = new Container2();
4870
+ if (!expanded)
4871
+ return container;
4872
+ if (isError)
4873
+ container.addChild(new Text2(theme.fg("error", content.filter((part) => part.type === "text").map((part) => part.text ?? "").join(`
4874
+ `)), 0, 0));
4875
+ else {
4876
+ let saved = details;
4877
+ saved?.response ? container.addChild(new Text2(`
4878
+ ${theme.fg("muted", "From: Supervisor")}
4879
+
4880
+ ${saved.response}`, 0, 0)) : saved?.steering?.state ? container.addChild(new Text2(`
4881
+ Delivery: ${saved.steering.state === "recovered" ? "recovered; replacement launched" : saved.steering.state}`, 0, 0)) : saved?.asyncId && saved.communication ? container.addChild(new Text2(`
4882
+ Continuation launched.`, 0, 0)) : saved?.state && saved.communication ? container.addChild(new Text2(`
4883
+ ${saved.state === "pending" ? "Question queued; awaiting an answer." : saved.state}`, 0, 0)) : saved?.communication || container.addChild(new Text2(content.filter((part) => part.type === "text").map((part) => part.text ?? "").join(`
4884
+ `), 0, 0));
4885
+ }
4886
+ return container;
4887
+ }
4888
+
4962
4889
  // packages/coding-agent/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.js
4963
4890
  var REQUESTS_DIR = "requests", REPLIES_DIR = "replies", NATIVE_SUPERVISOR_TOOL_NAME = "subagent_supervisor";
4964
4891
  var MAX_MESSAGE_BYTES2 = 64 * 1024, DEFAULT_ASK_TIMEOUT_MS2 = 600 * 1e3, CHANNEL_POLL_MS = Math.min(POLL_INTERVAL_MS, 500), STALE_EMPTY_CHANNEL_AGE_MS = 60 * 1e3, STALE_EMPTY_CHANNEL_CLEANUP_INTERVAL_MS = 60 * 1e3, PARENT_ASK_DESCRIPTION = [
@@ -4970,11 +4897,13 @@ var MAX_MESSAGE_BYTES2 = 64 * 1024, DEFAULT_ASK_TIMEOUT_MS2 = 600 * 1e3, CHANNEL
4970
4897
  "Use pending or list to find child requests awaiting your reply; status reports channel availability. Free-form send is unsupported. Asking never revives a child or changes its assignment.",
4971
4898
  'Reply: { action: "reply", replyTo: "<requestId>", message: "..." }'
4972
4899
  ].join(" "), CHILD_CONTACT_DESCRIPTION = [
4973
- "Contact the parent/supervisor session for a blocking decision, structured interview, progress update, or reply to a parent question.",
4900
+ "Contact the supervisor for decisions outside your assigned authority, safety concerns, or blockers. Make reversible implementation choices within your scope yourself.",
4901
+ "need_decision/interview_request wait for a reply: state the blocked decision, evidence, and recommended choice. Consolidate related questions; continue independent work before opening a blocking request.",
4902
+ "Return one self-contained final report with outcomes, verification, blockers, and artifact paths; the runtime delivers it. Routine work already appears in activity indicators.",
4974
4903
  "For parent questions use action='reply' with replyTo set to the question id. Answer from current findings and uncertainty; do not start extra investigation just to reply. Continue the assigned task after replying.",
4975
4904
  "Do not open a blocking need_decision while a parent question is already outstanding for this child."
4976
4905
  ].join(" "), ContactSupervisorParamsSchema = Type2.Object({
4977
- reason: Type2.Optional(Type2.String({ enum: ["need_decision", "interview_request", "progress_update"] })),
4906
+ reason: Type2.Optional(Type2.String({ enum: ["need_decision", "interview_request", "progress_update", "handoff"] })),
4978
4907
  message: Type2.Optional(Type2.String()),
4979
4908
  interview: Type2.Optional(Type2.Unsafe({ type: "object", additionalProperties: !0 })),
4980
4909
  action: Type2.Optional(Type2.String({ enum: ["reply"] })),
@@ -4998,6 +4927,40 @@ function safeSegment2(value) {
4998
4927
  function replyPath(channelDir, requestId) {
4999
4928
  return path8.join(channelDir, REPLIES_DIR, `${safeSegment2(requestId)}.json`);
5000
4929
  }
4930
+ function communicationKind(reason) {
4931
+ return reason === "progress_update" ? "progress" : reason === "handoff" ? "handoff" : reason === "interview_request" ? "interview" : "request";
4932
+ }
4933
+ function communicationBody(message, interview, protocolVersion) {
4934
+ let body = protocolVersion === 2 ? message : legacySupervisorBody(message);
4935
+ return interview !== void 0 && protocolVersion === 2 ? `${body}
4936
+
4937
+ ${JSON.stringify(interview, null, 2)}` : body;
4938
+ }
4939
+ function requestCommunication(request, state) {
4940
+ return {
4941
+ direction: "from",
4942
+ peer: resolveCommunicationPeer(state, request.runId, request.childIndex, request.agent, request.description),
4943
+ message: communicationBody(request.message, request.interview, request.protocolVersion),
4944
+ kind: communicationKind(request.reason)
4945
+ };
4946
+ }
4947
+ function registerSupervisorRenderers(pi, state) {
4948
+ for (let customType of [SUPERVISOR_REQUEST_TYPE, SUBAGENT_SUPERVISOR_ANSWER_TYPE])
4949
+ pi.registerMessageRenderer(customType, (message, options, theme) => {
4950
+ let details = message.details, communication = readCommunication(details?.communication) ?? {
4951
+ direction: "from",
4952
+ peer: details?.runId ? resolveCommunicationPeer(state, details.runId, details.childIndex ?? 0, details.childId ?? details.agent) : "Subagent",
4953
+ message: legacySupervisorBody(typeof message.content == "string" ? message.content : message.content.filter((part) => part.type === "text").map((part) => part.text).join(`
4954
+ `)),
4955
+ kind: customType === SUBAGENT_SUPERVISOR_ANSWER_TYPE ? "answer" : communicationKind(details?.reason)
4956
+ };
4957
+ return renderCommunicationCard(communication, options.expanded, theme);
4958
+ });
4959
+ pi.registerEntryRenderer(SUPERVISOR_PROGRESS_TYPE, (entry, options, theme) => {
4960
+ let communication = readCommunication(entry.data?.communication);
4961
+ return communication ? renderCommunicationCard(communication, options.expanded, theme) : void 0;
4962
+ });
4963
+ }
5001
4964
  function askTimeoutMs2() {
5002
4965
  let parsed = Number(process.env.PI_INTERCOM_ASK_TIMEOUT_MS);
5003
4966
  return Number.isFinite(parsed) && parsed > 0 ? parsed : DEFAULT_ASK_TIMEOUT_MS2;
@@ -5012,7 +4975,7 @@ function hasTool(pi, name) {
5012
4975
  function parseRequestFile(file, channelDir) {
5013
4976
  try {
5014
4977
  let parsed = JSON.parse(fs7.readFileSync(file, "utf-8"));
5015
- return parsed.type !== "subagent.supervisor.request" || typeof parsed.id != "string" || !parsed.id || parsed.reason !== "need_decision" && parsed.reason !== "interview_request" && parsed.reason !== "progress_update" || typeof parsed.message != "string" || !parsed.message || typeof parsed.runId != "string" || typeof parsed.agent != "string" || typeof parsed.childIndex != "number" ? void 0 : { ...parsed, channelDir, requestFile: file };
4978
+ return parsed.type !== "subagent.supervisor.request" || parsed.supervisorSessionId !== void 0 && (typeof parsed.supervisorSessionId != "string" || !parsed.supervisorSessionId.trim()) || typeof parsed.id != "string" || !parsed.id || parsed.reason !== "need_decision" && parsed.reason !== "interview_request" && parsed.reason !== "progress_update" && parsed.reason !== "handoff" || parsed.protocolVersion !== void 0 && parsed.protocolVersion !== 2 || parsed.protocolVersion === 2 && parsed.expectsReply !== (parsed.reason === "need_decision" || parsed.reason === "interview_request") || parsed.reason === "handoff" && parsed.protocolVersion !== 2 || parsed.description !== void 0 && typeof parsed.description != "string" || typeof parsed.message != "string" || !parsed.message || typeof parsed.runId != "string" || typeof parsed.agent != "string" || typeof parsed.childIndex != "number" ? void 0 : { ...parsed, channelDir, requestFile: file };
5016
4979
  } catch {
5017
4980
  return;
5018
4981
  }
@@ -5022,7 +4985,7 @@ function hasPendingBlockingSupervisorRequest(runId, sessionId, now = Date.now())
5022
4985
  return !1;
5023
4986
  for (let { channelDir, file } of listRequestFiles()) {
5024
4987
  let request = parseRequestFile(file, channelDir);
5025
- if (request?.expectsReply && request.runId === runId && !(sessionId && request.orchestratorSessionId && request.orchestratorSessionId !== sessionId) && !fs7.existsSync(replyPath(request.channelDir, request.id)) && !(now > requestExpiresAt(request, now)))
4988
+ if (request?.expectsReply && request.runId === runId && !(sessionId && (request.supervisorSessionId ?? request.orchestratorSessionId) !== sessionId) && !fs7.existsSync(replyPath(request.channelDir, request.id)) && !(now > requestExpiresAt(request, now)))
5026
4989
  return !0;
5027
4990
  }
5028
4991
  return !1;
@@ -5117,9 +5080,16 @@ function currentContextSessionId(state, ctx) {
5117
5080
  }
5118
5081
  return state.currentSessionId ?? void 0;
5119
5082
  }
5083
+ function currentSupervisorSessionId(state, ctx) {
5084
+ try {
5085
+ return ctx.sessionManager.getSessionFile?.() ?? currentContextSessionId(state, ctx);
5086
+ } catch {
5087
+ return state.currentSessionId ?? void 0;
5088
+ }
5089
+ }
5120
5090
  function requestMatchesContext(request, state, ctx) {
5121
- let currentSessionId = currentContextSessionId(state, ctx);
5122
- return !!(currentSessionId && request.orchestratorSessionId === currentSessionId);
5091
+ let currentSessionId = request.supervisorSessionId !== void 0 ? currentSupervisorSessionId(state, ctx) : currentContextSessionId(state, ctx);
5092
+ return !!(currentSessionId && (request.supervisorSessionId ?? request.orchestratorSessionId) === currentSessionId);
5123
5093
  }
5124
5094
  function removeRequestFile(file) {
5125
5095
  try {
@@ -5131,22 +5101,26 @@ function requestExpiresAt(request, now) {
5131
5101
  let expiresAt = request.expiresAt;
5132
5102
  return typeof expiresAt == "number" && Number.isFinite(expiresAt) ? expiresAt : Number.isFinite(request.createdAt) ? request.createdAt + askTimeoutMs2() : now;
5133
5103
  }
5134
- function requestRunInactive(request, state) {
5104
+ function requestRunState(request, state) {
5135
5105
  if (state.foregroundControls.has(request.runId))
5136
- return !1;
5106
+ return "active";
5137
5107
  let foregroundRun = state.foregroundRuns?.get(request.runId), foregroundChild = foregroundRun?.children.find((child) => child.index === request.childIndex && child.agent === request.agent) ?? foregroundRun?.children[request.childIndex];
5138
5108
  if (foregroundChild)
5139
- return foregroundChild.status !== "detached";
5140
- let asyncJob = state.asyncJobs.get(request.runId);
5141
- if (!asyncJob)
5142
- return !1;
5143
- if (asyncJob.status === "complete" || asyncJob.status === "failed" || asyncJob.status === "paused")
5144
- return !0;
5145
- let stepStatus = asyncJob.steps?.[request.childIndex]?.status;
5146
- return stepStatus === "complete" || stepStatus === "completed" || stepStatus === "failed" || stepStatus === "paused";
5109
+ return foregroundChild.status === "stopped" ? "stopped" : foregroundChild.status === "detached" ? "active" : "inactive";
5110
+ let job = state.asyncJobs.get(request.runId) ?? state.fleetJobs?.get(request.runId), asyncDir = job?.asyncDir ?? path8.join(ASYNC_DIR, safeSegment2(request.runId)), status = readStatus(asyncDir), runStatus = status?.state ?? job?.status, stepStatus = (status?.steps ?? job?.steps)?.[request.childIndex]?.status;
5111
+ return fs7.existsSync(stopRequestPath(asyncDir)) || runStatus === "stopped" || job?.status === "stopped" || status?.stopped || stepStatus === "stopped" ? "stopped" : ["complete", "failed", "paused"].includes(runStatus ?? "") || ["complete", "completed", "failed", "paused"].includes(stepStatus ?? "") ? "inactive" : "active";
5147
5112
  }
5148
5113
  function requestLifecycle(request, state, ctx, now) {
5149
- return ctx && !requestMatchesContext(request, state, ctx) ? "wrong-session" : fs7.existsSync(request.requestFile) ? request.expectsReply && fs7.existsSync(replyPath(request.channelDir, request.id)) ? "resolved" : request.expectsReply && now > requestExpiresAt(request, now) ? "expired" : request.expectsReply && requestRunInactive(request, state) ? "inactive" : "pending" : "missing";
5114
+ if (ctx && !requestMatchesContext(request, state, ctx))
5115
+ return "wrong-session";
5116
+ if (!fs7.existsSync(request.requestFile))
5117
+ return "missing";
5118
+ if (request.expectsReply && fs7.existsSync(replyPath(request.channelDir, request.id)))
5119
+ return "resolved";
5120
+ if (request.expectsReply && now > requestExpiresAt(request, now))
5121
+ return "expired";
5122
+ let runState = requestRunState(request, state);
5123
+ return runState === "stopped" || request.expectsReply && runState === "inactive" ? "inactive" : "pending";
5150
5124
  }
5151
5125
  function cleanupRequestLifecycle(request, lifecycle) {
5152
5126
  (lifecycle === "resolved" || lifecycle === "expired" || lifecycle === "inactive") && removeRequestFile(request.requestFile);
@@ -5162,9 +5136,9 @@ function formatPendingLine(request) {
5162
5136
  let replyHint = request.expectsReply ? ` Reply: ${NATIVE_SUPERVISOR_TOOL_NAME}({ action: "reply", replyTo: "${request.id}", message: "..." })` : "";
5163
5137
  return `- ${request.id}: ${request.agent} [${request.runId}#${request.childIndex}] ${request.reason}.${replyHint}`;
5164
5138
  }
5165
- function requestVisibleText(request) {
5166
- let lines = [request.message];
5167
- return request.expectsReply && lines.push("", `Reply with: ${NATIVE_SUPERVISOR_TOOL_NAME}({ action: "reply", replyTo: "${request.id}", message: "..." })`), lines.join(`
5139
+ function requestVisibleText(request, communication) {
5140
+ let lines = [`From: ${communication.peer}`, "", communication.message];
5141
+ return request.reason === "interview_request" && lines.push("", "Reply with JSON matching the requested interview shape."), request.expectsReply && lines.push("", `Reply with: ${NATIVE_SUPERVISOR_TOOL_NAME}({ action: "reply", replyTo: "${request.id}", message: "..." })`), lines.join(`
5168
5142
  `);
5169
5143
  }
5170
5144
  function writeReply(request, message) {
@@ -5213,6 +5187,13 @@ function buildParentIntercomTool(pending, state, name = "intercom") {
5213
5187
  label: name === "intercom" ? "Intercom" : "Subagent Supervisor",
5214
5188
  description: PARENT_ASK_DESCRIPTION,
5215
5189
  parameters: ParentSupervisorParamsSchema,
5190
+ renderCall(args, theme, context) {
5191
+ let request = args.action === "reply" ? pending.get(args.replyTo) : void 0, peer = request ? requestCommunication(request, state).peer : args.id ? resolveCommunicationPeer(state, args.id, args.index ?? 0, args.childId) : "Subagent";
5192
+ return renderCommunicationCall(name, args, theme, context, args.message ? { direction: "to", peer, message: args.message, kind: args.action === "ask" ? "question" : "reply" } : void 0);
5193
+ },
5194
+ renderResult(result2, options, theme, context) {
5195
+ return renderCommunicationResult(result2.content, result2.details, options.expanded, context.isError, theme);
5196
+ },
5216
5197
  async execute(_id, params) {
5217
5198
  refreshPendingRequests(pending, state, state.lastUiContext ?? void 0);
5218
5199
  let input = params;
@@ -5225,7 +5206,7 @@ function buildParentIntercomTool(pending, state, name = "intercom") {
5225
5206
  }
5226
5207
  if (input.action === "reply") {
5227
5208
  let request = resolvePendingRequest(pending, input);
5228
- return writeReply(request, input.message ?? ""), pending.delete(request.id), { content: [{ type: "text", text: `Replied to supervisor request ${request.id}.` }], details: { replyTo: request.id, runId: request.runId, agent: request.agent } };
5209
+ return writeReply(request, input.message ?? ""), pending.delete(request.id), { content: [{ type: "text", text: `Replied to ${requestCommunication(request, state).peer}.` }], details: { replyTo: request.id, runId: request.runId, agent: request.agent, communication: { ...requestCommunication(request, state), direction: "to", kind: "reply", message: input.message } } };
5229
5210
  }
5230
5211
  if (input.action === "ask")
5231
5212
  return askRunningAsyncChild({
@@ -5244,32 +5225,33 @@ function buildParentIntercomTool(pending, state, name = "intercom") {
5244
5225
  };
5245
5226
  }
5246
5227
  function questionMatchesParentContext(question, state, ctx) {
5247
- let sessionId = currentContextSessionId(state, ctx);
5228
+ let sessionId = currentSupervisorSessionId(state, ctx);
5248
5229
  return !(!sessionId || question.parentSessionId !== sessionId || (state.sessionGeneration ?? 0) !== question.parentGeneration);
5249
5230
  }
5250
- function notifyQuestionTerminal(pi, question, channelDir) {
5231
+ function notifyQuestionTerminal(pi, question, channelDir, state) {
5251
5232
  if (!supervisorQuestionIsTerminal(question) || question.notifiedAt || (pi.events?.emit(SUBAGENT_QUESTION_EVENT, {
5252
5233
  questionId: question.id,
5253
5234
  state: supervisorQuestionPublicState(question),
5254
5235
  runId: question.runId
5255
5236
  }), isQuestionWaitActive(question.id)) || !claimQuestionNotification(channelDir, question.id))
5256
5237
  return;
5257
- let state = supervisorQuestionPublicState(question);
5238
+ let outcome = supervisorQuestionPublicState(question), communication = { direction: "from", peer: question.childDescription ?? resolveCommunicationPeer(state, question.runId, question.childIndex, question.childId), message: question.answer ?? question.cancelReason ?? outcome, kind: "answer" };
5258
5239
  pi.sendMessage({
5259
5240
  customType: SUBAGENT_SUPERVISOR_ANSWER_TYPE,
5260
5241
  content: formatSupervisorQuestionAnswer(question),
5261
- display: state === "answered",
5242
+ display: outcome === "answered",
5262
5243
  details: {
5263
5244
  questionId: question.id,
5264
- state,
5245
+ state: outcome,
5246
+ communication,
5265
5247
  runId: question.runId,
5266
5248
  childIndex: question.childIndex,
5267
5249
  childId: question.childId,
5268
5250
  reason: question.reason,
5269
- answered: state === "answered",
5251
+ answered: outcome === "answered",
5270
5252
  delivered: !!question.deliveredAt
5271
5253
  }
5272
- }, { triggerTurn: state === "answered" });
5254
+ }, { triggerTurn: outcome === "answered" });
5273
5255
  }
5274
5256
  function pollSupervisorQuestions(pi, state, ctx) {
5275
5257
  for (let channelDir of listSupervisorChannelDirs())
@@ -5277,11 +5259,11 @@ function pollSupervisorQuestions(pi, state, ctx) {
5277
5259
  if (!questionMatchesParentContext(question, state, ctx))
5278
5260
  continue;
5279
5261
  let current = reconcileAsyncQuestion(channelDir, question, state);
5280
- notifyQuestionTerminal(pi, current, channelDir);
5262
+ notifyQuestionTerminal(pi, current, channelDir, state);
5281
5263
  }
5282
5264
  }
5283
5265
  function createNativeSupervisorChannel(pi, state) {
5284
- let pending = /* @__PURE__ */ new Map(), seenFiles = /* @__PURE__ */ new Set(), poller, lastStaleCleanupAt = 0, registerParentTools = () => {
5266
+ let pending = /* @__PURE__ */ new Map(), seenFiles = /* @__PURE__ */ new Set(), deliveredRequests = /* @__PURE__ */ new Set(), poller, lastStaleCleanupAt = 0, registerParentTools = () => {
5285
5267
  hasTool(pi, NATIVE_SUPERVISOR_TOOL_NAME) || pi.registerTool(buildParentIntercomTool(pending, state, NATIVE_SUPERVISOR_TOOL_NAME)), hasTool(pi, "intercom") || pi.registerTool(buildParentIntercomTool(pending, state));
5286
5268
  }, cleanupStaleChannelsIfDue = () => {
5287
5269
  let nowMs = Date.now();
@@ -5322,19 +5304,25 @@ function createNativeSupervisorChannel(pi, state) {
5322
5304
  seenFiles.add(file), cleanupRequestLifecycle(request, lifecycle);
5323
5305
  continue;
5324
5306
  }
5325
- if (seenFiles.add(file), request.expectsReply ? pending.set(request.id, request) : removeRequestFile(request.requestFile), pi.sendMessage({
5326
- customType: "subagent_supervisor_request",
5327
- content: requestVisibleText(request),
5307
+ if (request.expectsReply && pending.set(request.id, request), deliveredRequests.has(request.id)) {
5308
+ seenFiles.add(file);
5309
+ continue;
5310
+ }
5311
+ let communication = requestCommunication(request, state), details = {
5312
+ id: request.id,
5313
+ reason: request.reason,
5314
+ expectsReply: request.expectsReply,
5315
+ runId: request.runId,
5316
+ agent: request.agent,
5317
+ childIndex: request.childIndex,
5318
+ communication
5319
+ };
5320
+ if (request.reason === "progress_update" && request.protocolVersion === 2 ? pi.appendEntry(SUPERVISOR_PROGRESS_TYPE, details) : pi.sendMessage({
5321
+ customType: SUPERVISOR_REQUEST_TYPE,
5322
+ content: requestVisibleText(request, communication),
5328
5323
  display: !0,
5329
- details: {
5330
- id: request.id,
5331
- reason: request.reason,
5332
- expectsReply: request.expectsReply,
5333
- runId: request.runId,
5334
- agent: request.agent,
5335
- childIndex: request.childIndex
5336
- }
5337
- }), request.expectsReply) {
5324
+ details
5325
+ }, { triggerTurn: request.expectsReply || request.reason === "handoff" }), deliveredRequests.add(request.id), seenFiles.add(file), request.expectsReply || removeRequestFile(request.requestFile), request.expectsReply) {
5338
5326
  let job = state.asyncJobs.get(request.runId);
5339
5327
  job && (job.activityState = "needs_attention");
5340
5328
  let events = pi.events;
@@ -5355,10 +5343,17 @@ function createNativeSupervisorChannel(pi, state) {
5355
5343
  };
5356
5344
  return {
5357
5345
  start: () => {
5358
- poller || (registerParentTools(), poll(), poller = setInterval(poll, CHANNEL_POLL_MS), poller.unref?.());
5346
+ if (!poller) {
5347
+ registerParentTools();
5348
+ for (let entry of state.lastUiContext?.sessionManager.getBranch?.() ?? []) {
5349
+ let data = entry.type === "custom_message" && entry.customType === SUPERVISOR_REQUEST_TYPE ? entry.details : entry.type === "custom" && entry.customType === SUPERVISOR_PROGRESS_TYPE ? entry.data : void 0;
5350
+ data && typeof data == "object" && "id" in data && typeof data.id == "string" && deliveredRequests.add(data.id);
5351
+ }
5352
+ poll(), poller = setInterval(poll, CHANNEL_POLL_MS), poller.unref?.();
5353
+ }
5359
5354
  },
5360
5355
  dispose: () => {
5361
- cancelOwnedQuestions("parent supervisor channel disposed"), poller && clearInterval(poller), poller = void 0, pending.clear(), seenFiles.clear();
5356
+ cancelOwnedQuestions("parent supervisor channel disposed"), poller && clearInterval(poller), poller = void 0, pending.clear(), seenFiles.clear(), deliveredRequests.clear();
5362
5357
  },
5363
5358
  pending,
5364
5359
  cancelOwnedQuestions,
@@ -5930,6 +5925,8 @@ async function waitForSubagents(params, signal, deps) {
5930
5925
  ].join(", ");
5931
5926
  if (signal?.aborted)
5932
5927
  return result(`Wait aborted after ${formatDuration(now() - startedAt)}. Still active: ${stillActive}.`, !0);
5928
+ if (deps.shouldYield?.())
5929
+ return result("Wait yielded for pending session messages; background work remains active.");
5933
5930
  if (now() - startedAt >= timeoutMs)
5934
5931
  return result(`Wait timed out after ${formatDuration(timeoutMs)} with ${activeInitialRuns.length} async run(s) and ${activeInitialProviderItems.length} provider item(s) still active: ${stillActive}. The work keeps going; call subagent_wait again or inspect subagent status.`, !0);
5935
5932
  try {
@@ -5965,7 +5962,7 @@ function registerWaitTool(pi, state, enabled = resolveWaitToolConfig().enabled,
5965
5962
  label: "Subagent Wait",
5966
5963
  description: `Block until background work owned by this session changes, then return.
5967
5964
 
5968
- In an interactive chat, do not call this merely to wait: return control to the user and let Pi wake the session on completion. Call it when the current request must run to completion in this turn, when a skill cannot return before its work finishes, or in a non-interactive run where there is no next turn.
5965
+ Call this when the current turn or skill must finish after its children. For normal interactive completion, yield and let lunR wake the session. Headless sessions auto-drain current-session work after the agent turn.
5969
5966
 
5970
5967
  \u2022 { } \u2014 return when the first initially active async run or registered provider item finishes, or when a subagent needs attention.
5971
5968
  \u2022 { all: true } \u2014 wait for every async run and provider item that was active when the call began.
@@ -6005,7 +6002,7 @@ async function drainOutstandingWork(deps) {
6005
6002
  if (!Number.isFinite(timeoutMs) || timeoutMs <= 0)
6006
6003
  throw new Error("Auto-drain timeoutMs must be a positive finite number.");
6007
6004
  let deadlineAt = now() + timeoutMs, hasWork = deps.hasWork ?? hasOutstandingWork, wait = deps.wait ?? waitForSubagents;
6008
- for (; hasWork(sessionId, now()); ) {
6005
+ for (; !deps.hasPendingMessages?.() && hasWork(sessionId, now()); ) {
6009
6006
  let remainingMs = deadlineAt - now();
6010
6007
  if (remainingMs <= 0)
6011
6008
  throw new Error(`Auto-drain timed out after ${timeoutMs}ms with background work still active in session '${sessionId}'.`);
@@ -6014,6 +6011,7 @@ async function drainOutstandingWork(deps) {
6014
6011
  events: deps.events,
6015
6012
  now,
6016
6013
  stopOnAttention: !1,
6014
+ shouldYield: deps.hasPendingMessages,
6017
6015
  failOnFailedRuns: !0
6018
6016
  });
6019
6017
  if (waitResult.isError)
@@ -6165,7 +6163,32 @@ function buildCompletionDetails(result2) {
6165
6163
  status,
6166
6164
  ...result2.source ? { source: result2.source } : {},
6167
6165
  ...taskInfo ? { taskInfo } : {},
6168
- resultPreview: summary,
6166
+ resultPreview: [
6167
+ result2.id ? `Run: ${result2.id}` : void 0,
6168
+ result2.asyncDir ? `Async dir: ${result2.asyncDir}` : void 0,
6169
+ result2.results?.length ? result2.results.map((child, index) => {
6170
+ let output = child.summary ?? (child.error ? `${child.error}
6171
+
6172
+ Output:
6173
+ ${child.output}` : child.output), report = child.acceptance?.childReport, childIndex = child.index ?? index;
6174
+ return [
6175
+ `${childIndex + 1}. ${child.agent} [${child.status ?? resolveSubagentResultStatus({ success: child.success, state: result2.state })}]`,
6176
+ child.artifactPath ? `Output artifact: ${child.artifactPath}` : void 0,
6177
+ child.sessionPath ? `Session: ${child.sessionPath}` : void 0,
6178
+ child.sessionPath && result2.id && result2.source !== "foreground" ? `Revive: subagent({ action: "resume", id: ${JSON.stringify(result2.id)}, index: ${childIndex}, message: "..." })` : void 0,
6179
+ ...formatNestedResultLines(child.children),
6180
+ output,
6181
+ report ? `\`\`\`acceptance-report
6182
+ ${JSON.stringify(report, null, 2)}
6183
+ \`\`\`` : void 0
6184
+ ].filter((line) => line !== void 0).join(`
6185
+ `);
6186
+ }).join(`
6187
+
6188
+ `) : summary
6189
+ ].filter((line) => line !== void 0).join(`
6190
+
6191
+ `),
6169
6192
  ...typeof result2.durationMs == "number" ? { durationMs: result2.durationMs } : {},
6170
6193
  ...session ? { sessionLabel: session.label, sessionValue: session.value } : {}
6171
6194
  };
@@ -6278,16 +6301,17 @@ var CUSTOM_TOOL_DESCRIPTION_FILE = "subagent-tool-description.md", CUSTOM_TOOL_D
6278
6301
  \u2022 Choose the lowest tier that can reliably complete the task.
6279
6302
  \u2022 light: Use for simple, straightforward tasks that require little reasoning. Good for quick checks, finding information, collecting facts for research, inspecting a small amount of code, or verifying a specific fact.
6280
6303
  \u2022 standard: Use for moderately difficult work and everyday coding tasks. Good for writing simple code, fixing a clearly described bug, reviewing a focused change, or completing work with clear requirements. Use heavy when the task requires deep architectural understanding or complex reasoning.
6281
- \u2022 heavy: Use for complex or ambiguous tasks that require deep reasoning and strong code understanding. Good for implementing complex plans, debugging difficult or poorly understood problems, reviewing large or high-risk changes, and making architectural decisions.`, SUBAGENT_SAFETY_GUIDANCE = `SAFETY-CRITICAL SUBAGENT GUIDANCE:
6304
+ \u2022 heavy: Use for complex or ambiguous tasks that require deep reasoning and strong code understanding. Good for implementing complex plans, debugging difficult or poorly understood problems, reviewing large or high-risk changes, and making architectural decisions.`, SUBAGENT_COORDINATION_GUIDANCE = "Define file ownership, local decision authority, and required outputs at launch. Establish shared contracts before dependent parallel work; use chains and artifacts to pass results. Native child intercom reaches the supervisor only, not siblings. Reserve parent relays for actionable exceptions, not routine progress or implementation approvals.", SUBAGENT_SAFETY_GUIDANCE = `SAFETY-CRITICAL SUBAGENT GUIDANCE:
6282
6305
  \u2022 Prompt children directly. There is no agent roster. Every execution task needs task (the full child prompt) and description (a concise UI label).
6283
6306
  \u2022 Every executable child chooses exactly one of tier: "light"|"standard"|"heavy" (default) or model: "provider/id" when the user names a model. Do not pass both, and do not use inherit. Missing, disabled, unconfigured, unavailable, or unauthenticated selections fail before launch.
6284
6307
  \u2022 Optional thinking (off/minimal/low/medium/high/xhigh/max) is only valid with an explicit model. Tier launches use the configured tier thinking level.
6285
6308
  ${SUBAGENT_TIER_GUIDANCE}
6286
6309
  \u2022 permissions is "full" or "read-only". Omitted permissions means full. Plan-mode parents must pass permissions: "read-only"; full or omitted launches are rejected.
6287
6310
  \u2022 Keep execution and control separate: omit action for SINGLE/PARALLEL/CHAIN execution; use action only for status/interrupt/stop/resume/steer/append-step/doctor/watchdog.status|check|recommend-model/schedule*.
6288
- \u2022 Async/background runs: launch with async:true only when work can proceed independently. Do not sleep or poll status just to wait. In an interactive session, normally return control and let lunR wake you; use subagent_wait when this request must run to completion in the current turn or skill. Headless sessions auto-drain current-session work.
6311
+ \u2022 ${SUBAGENT_ASYNC_GUIDANCE}
6289
6312
  \u2022 Child-safety boundary: ordinary children are not orchestrators and must not run subagents. Only explicitly configured fanout children may use the child-safe subagent tool, still bounded by depth/session limits.
6290
6313
  \u2022 Writing/review safety: keep one full-access writer for the same cwd/worktree. Use fresh-context permissions: "read-only" children for independent review, then have the parent synthesize and apply fixes as the sole writer unless an isolated worktree was intentionally requested.
6314
+ \u2022 ${SUBAGENT_COORDINATION_GUIDANCE}
6291
6315
  \u2022 Artifacts/status essentials: chain outputs live under {chain_dir}; async runs expose asyncId/asyncDir with status.json, events.jsonl, output logs, and status via { action: "status", id }. Include output paths and residual risks when reporting results.`, FULL_SUBAGENT_TOOL_DESCRIPTION = `Delegate work to generic children by prompting them directly. There are no named agent types.
6292
6316
 
6293
6317
  EXECUTION (use exactly ONE mode):
@@ -6339,6 +6363,7 @@ EXECUTE:
6339
6363
  \u2022 description is required (single-line, max 80 chars, UI only). task is the full child prompt. permissions omitted = full. Plan-mode parents must pass permissions:"read-only".
6340
6364
  \u2022 Exactly one of tier:"light"|"standard"|"heavy" (default) or model:"provider/id" when the user names a model. thinking only with model. No inherit; fail closed on unavailable selections. Children always start fresh. timeoutMs/maxRuntimeMs apply to foreground and async/background runs.
6341
6365
  ${SUBAGENT_TIER_GUIDANCE}
6366
+ \u2022 ${SUBAGENT_COORDINATION_GUIDANCE}
6342
6367
  \u2022 Chain templates may use {task}, {previous}, {chain_dir}, and named outputs. Parallel worktree isolation requires a clean git repo.
6343
6368
  \u2022 Chain example: { chain: [{task:"Analyze {task}", description:"Analyze request", tier:"standard"}, {parallel: [{task:"Check {previous}", description:"Check prior result", tier:"light", permissions:"read-only", count: 3}]}] }
6344
6369
 
@@ -6348,7 +6373,7 @@ CONTROL:
6348
6373
  \u2022 Opt-in schedule actions: schedule, schedule-list, schedule-status, schedule-cancel. Schedule only explicit delayed runs the user asked for.
6349
6374
 
6350
6375
  ASYNC / WAIT:
6351
- \u2022 async:true detaches background work. Do not sleep or poll just to wait. Interactive sessions normally yield for completion notifications; use subagent_wait for run-to-completion turns or skills. Headless sessions auto-drain current-session work.
6376
+ \u2022 ${SUBAGENT_ASYNC_GUIDANCE}
6352
6377
  \u2022 Status and artifacts live under asyncId/asyncDir with status.json, events.jsonl, output logs, session files, and { action:"status", id:"..." }.
6353
6378
 
6354
6379
  SAFETY:
@@ -6478,30 +6503,58 @@ function effectiveParallelTaskCount(tasks) {
6478
6503
  return total + count;
6479
6504
  }, 0);
6480
6505
  }
6481
- function callIsAsync(args, asyncByDefault) {
6482
- return args?.clarify === !0 ? !1 : args?.async === !0 ? !0 : args?.async === !1 ? !1 : asyncByDefault === !0;
6483
- }
6484
- function renderSubagentCall(args, theme, context, options) {
6506
+ function matchingActionJobs(state, requestedId) {
6507
+ let jobs = /* @__PURE__ */ new Map();
6508
+ for (let job of state.asyncJobs.values())
6509
+ jobs.set(job.asyncId, job);
6510
+ for (let job of state.fleetJobs?.values() ?? [])
6511
+ jobs.set(job.asyncId, job);
6512
+ let exact = jobs.get(requestedId);
6513
+ return exact ? [exact] : [...jobs.values()].filter((job) => job.asyncId.startsWith(requestedId));
6514
+ }
6515
+ function resolveSubagentActionDisplayTitle(args, state) {
6516
+ let requestedId = (args.id || args.runId || "").trim();
6517
+ if (!requestedId)
6518
+ return;
6519
+ let matches = matchingActionJobs(state, requestedId);
6520
+ if (matches.length !== 1)
6521
+ return;
6522
+ let job = matches[0], steps = job.steps ?? [];
6523
+ if (Number.isInteger(args.index)) {
6524
+ let step = steps.find((candidate) => candidate.index === args.index) ?? steps[args.index];
6525
+ return step ? childRowLabel(step) : void 0;
6526
+ }
6527
+ if (steps.length === 1)
6528
+ return childRowLabel(steps[0]);
6529
+ if (steps.length > 1)
6530
+ return `${job.mode ?? "subagent"} run`;
6531
+ if (job.agents?.length === 1)
6532
+ return job.agents[0];
6533
+ if (job.agents?.length)
6534
+ return `${job.mode ?? "subagent"} run`;
6535
+ }
6536
+ function renderSubagentCall(rawArgs, theme, context, options) {
6537
+ let args = resolveSubagentRequestParams(rawArgs);
6485
6538
  if (args.action) {
6486
- let target = args.id || args.runId || "";
6487
- return new Text2(`${theme.fg("toolTitle", theme.bold("subagent "))}${args.action}${target ? ` ${theme.fg("accent", target)}` : ""}`, 0, 0);
6539
+ let resolvedTitle = context?.result?.details?.displayTitle || options?.resolveActionTitle?.(args), target = resolvedTitle || args.id || args.runId || "";
6540
+ return (args.action === "steer" || args.action === "resume") && args.message ? renderCommunicationCall("subagent", args, theme, context, { direction: "to", peer: resolvedTitle || "Subagent", kind: "steer", message: args.message }) : new Text3(`${theme.fg("toolTitle", theme.bold("subagent "))}${args.action}${target ? ` ${theme.fg("accent", target)}` : ""}`, 0, 0);
6488
6541
  }
6489
- let isParallel = (args.tasks?.length ?? 0) > 0, parallelCount = effectiveParallelTaskCount(args.tasks), asyncMark = callIsAsync(args, options?.asyncByDefault) ? `${theme.fg("warning", "async")} ` : "";
6542
+ let isParallel = (args.tasks?.length ?? 0) > 0, parallelCount = effectiveParallelTaskCount(args.tasks), asyncMark = subagentLaunchRunsAsync(args) ? `${theme.fg("warning", "async")} ` : "";
6490
6543
  if (args.chain?.length)
6491
- return new Text2(`${theme.fg("toolTitle", theme.bold("subagent "))}${asyncMark}chain (${args.chain.length})`, 0, 0);
6544
+ return new Text3(`${theme.fg("toolTitle", theme.bold("subagent "))}${asyncMark}chain (${args.chain.length})`, 0, 0);
6492
6545
  if (isParallel)
6493
- return new Text2(`${theme.fg("toolTitle", theme.bold("subagent "))}${asyncMark}parallel (${parallelCount})`, 0, 0);
6546
+ return new Text3(`${theme.fg("toolTitle", theme.bold("subagent "))}${asyncMark}parallel (${parallelCount})`, 0, 0);
6494
6547
  let description = !context?.result && !context?.isPartial && !context?.expanded && !context?.isError ? theme.fg("accent", args.description || args.task || "?") : "", title = theme.fg("toolTitle", theme.bold("subagent")), rest = [asyncMark.trim() ? theme.fg("warning", "async") : "", description].filter(Boolean).join(" ");
6495
- return new Text2(rest ? `${title} ${rest}` : title, 0, 0);
6548
+ return new Text3(rest ? `${title} ${rest}` : title, 0, 0);
6496
6549
  }
6497
6550
  function renderSubagentNotify(details, theme) {
6498
6551
  let status = typeof details?.status == "string" ? details.status : "", icon = status === "completed" ? theme.fg("success", "\u2713") : status === "failed" ? theme.fg("error", "\u2717") : theme.fg("warning", "\u25A0"), title = details?.agent || "child";
6499
- return new Text2(`${icon} ${theme.bold(title)} ${theme.fg("dim", status)}`, 0, 0);
6552
+ return new Text3(`${icon} ${theme.bold(title)} ${theme.fg("dim", status)}`, 0, 0);
6500
6553
  }
6501
6554
  function ensureSubagentResultAnimation(context) {
6502
6555
  let state = context.state;
6503
6556
  state.subagentResultAnimationTimer || typeof context.invalidate == "function" && (state.frame === void 0 && (state.frame = 0), state.subagentResultAnimationTimer = setInterval(() => {
6504
- state.frame = ((state.frame ?? 0) + 1) % 10;
6557
+ state.frame = (state.frame ?? 0) + 1;
6505
6558
  try {
6506
6559
  let entries = state.animEntries;
6507
6560
  if (entries?.length && typeof context.requestRender == "function") {
@@ -6513,7 +6566,7 @@ function ensureSubagentResultAnimation(context) {
6513
6566
  context.invalidate();
6514
6567
  } catch {
6515
6568
  }
6516
- }, 80));
6569
+ }, SUBAGENT_PAINT_INTERVAL_MS));
6517
6570
  }
6518
6571
  function isSlashResultError(result2) {
6519
6572
  return result2.details?.results.some((entry) => entry.exitCode !== 0 && entry.progress?.status !== "running") || !1;
@@ -6523,14 +6576,14 @@ function isStaleExtensionContextError(error) {
6523
6576
  }
6524
6577
  function rebuildSlashResultContainer(container, result2, options, theme) {
6525
6578
  container.clear(), container.addChild(new Spacer2(1));
6526
- let boxTheme = isSlashResultRunning(result2) ? "toolPendingBg" : isSlashResultError(result2) ? "toolErrorBg" : "toolSuccessBg", box = new Box(1, 1, (text) => theme.bg(boxTheme, text));
6579
+ let boxTheme = isSlashResultRunning(result2) ? "toolPendingBg" : isSlashResultError(result2) ? "toolErrorBg" : "toolSuccessBg", box = new Box2(1, 1, (text) => theme.bg(boxTheme, text));
6527
6580
  box.addChild(renderSubagentResult(result2, options, theme)), container.addChild(box);
6528
6581
  }
6529
6582
  function createSlashResultComponent(details, options, theme) {
6530
- let container = new Container2(), lastVersion = -1;
6583
+ let container = new Container3(), lastVersion = -1;
6531
6584
  return container.render = (width) => {
6532
6585
  let snapshot = getSlashRenderableSnapshot(details);
6533
- return (snapshot.version !== lastVersion || isSlashResultRunning(snapshot.result)) && (lastVersion = snapshot.version, rebuildSlashResultContainer(container, snapshot.result, options, theme)), Container2.prototype.render.call(container, width);
6586
+ return (snapshot.version !== lastVersion || isSlashResultRunning(snapshot.result)) && (lastVersion = snapshot.version, rebuildSlashResultContainer(container, snapshot.result, options, theme)), Container3.prototype.render.call(container, width);
6534
6587
  }, container;
6535
6588
  }
6536
6589
  function registerSubagentExtension(pi) {
@@ -6543,7 +6596,7 @@ function registerSubagentExtension(pi) {
6543
6596
  } catch {
6544
6597
  }
6545
6598
  ensureAccessibleDir(RESULTS_DIR), ensureAccessibleDir(ASYNC_DIR), cleanupOldChainDirs();
6546
- let config = loadConfig(), waitToolConfig = resolveWaitToolConfig(config.waitTool), asyncByDefault = config.asyncByDefault === !0, tempArtifactsDir = getArtifactsDir(null);
6599
+ let config = normalizeAsyncLaunchConfig(loadConfig()), waitToolConfig = resolveWaitToolConfig(config.waitTool), tempArtifactsDir = getArtifactsDir(null);
6547
6600
  cleanupAllArtifactDirs(DEFAULT_ARTIFACT_CONFIG.cleanupDays);
6548
6601
  let state = {
6549
6602
  baseCwd: "",
@@ -6594,18 +6647,17 @@ function registerSubagentExtension(pi) {
6594
6647
  }), markLaunchReady = () => {
6595
6648
  launchReady || (launchReady = !0, pendingLaunches.delete(launchReadyPromise), pendingAsyncLaunches.delete(launchReadyPromise), resolveLaunchReady());
6596
6649
  };
6597
- pendingLaunches.add(launchReadyPromise), (params.task || params.tasks || params.chain) && !params.clarify && (params.async === !0 || params.async === void 0 && asyncByDefault || config.forceTopLevelAsync === !0) && pendingAsyncLaunches.add(launchReadyPromise);
6650
+ pendingLaunches.add(launchReadyPromise), isAsyncSubagentExecution(resolveSubagentRequestParams(params)) && pendingAsyncLaunches.add(launchReadyPromise);
6598
6651
  try {
6599
6652
  let currentGeneration = generation;
6600
6653
  if (signal?.throwIfAborted(), !executorPromise) {
6601
- let pending = import("./subagent-executor-SRFC26SJ.js").then(({ createSubagentExecutor }) => {
6654
+ let pending = import("./subagent-executor-MLUMBWCP.js").then(({ createSubagentExecutor }) => {
6602
6655
  if (generation !== currentGeneration)
6603
6656
  throw new Error("Subagent session changed before initialization");
6604
6657
  return createSubagentExecutor({
6605
6658
  pi,
6606
6659
  state,
6607
6660
  config,
6608
- asyncByDefault,
6609
6661
  waitToolEnabled: waitToolConfig.enabled,
6610
6662
  handleScheduledRunAction: (params2, ctx2) => scheduledRunManager.handleToolCall(params2, ctx2),
6611
6663
  watchdog: mainWatchdog,
@@ -6628,24 +6680,32 @@ function registerSubagentExtension(pi) {
6628
6680
  }
6629
6681
  }
6630
6682
  };
6631
- executorExecute = executor.execute, pi.registerMessageRenderer(SLASH_RESULT_TYPE, (message, options, theme) => {
6683
+ executorExecute = executor.execute, registerSupervisorRenderers(pi, state), pi.registerMessageRenderer(SLASH_RESULT_TYPE, (message, options, theme) => {
6632
6684
  let details = resolveSlashMessageDetails(message.details);
6633
6685
  if (details)
6634
6686
  return createSlashResultComponent(details, options, theme);
6635
6687
  }), pi.registerMessageRenderer(SLASH_TEXT_RESULT_TYPE, (message, _options, _theme) => {
6636
6688
  let content = typeof message.content == "string" ? message.content : message.content.filter((entry) => entry.type === "text").map((entry) => entry.text).join(`
6637
6689
  `);
6638
- return new Text2(content, 0, 0);
6690
+ return new Text3(content, 0, 0);
6639
6691
  }), pi.registerMessageRenderer("subagent-notify", (message, _options, theme) => {
6640
6692
  let content = typeof message.content == "string" ? message.content : "", details = message.details ?? parseSubagentNotifyContent(content);
6641
- return details ? renderSubagentNotify(details, theme) : new Text2(content, 0, 0);
6693
+ return details ? renderSubagentNotify(details, theme) : new Text3(content, 0, 0);
6642
6694
  }), pi.registerMessageRenderer(SUBAGENT_STEERING_MESSAGE_TYPE, (message, _options, theme) => {
6643
6695
  let details = message.details;
6644
6696
  if (details)
6645
- return new Text2(theme.fg(details.state === "recovered" ? "warning" : "error", formatSteeringNotice(details)), 0, 0);
6697
+ return new Text3(theme.fg(details.state === "recovered" ? "warning" : "error", formatSteeringNotice(details)), 0, 0);
6646
6698
  }), pi.registerMessageRenderer(SUBAGENT_CONTROL_MESSAGE_TYPE, () => {
6647
6699
  });
6648
- let executeSubagentCollapsed = (id, params, signal, onUpdate, ctx) => (ctx.hasUI && ctx.ui.setToolsExpanded(!1), executor.execute(id, params, signal, onUpdate, ctx)), slashBridge = registerSlashSubagentBridge({
6700
+ let executeSubagentCollapsed = async (id, params, signal, onUpdate, ctx) => {
6701
+ ctx.hasUI && ctx.ui.setToolsExpanded(!1);
6702
+ let isCommunication = (params.action === "steer" || params.action === "resume") && typeof params.message == "string", displayTitle = isCommunication ? resolveSubagentActionDisplayTitle(params, state) : void 0, jobs = isCommunication ? matchingActionJobs(state, (params.id || params.runId || "").trim()) : [], targetNames = new Map(jobs.length === 1 ? jobs[0].steps?.map((step, index) => [step.index ?? index, childRowLabel(step)]) : []), result2 = await executor.execute(id, params, signal, onUpdate, ctx);
6703
+ if (displayTitle && result2.details && (result2.details.displayTitle = displayTitle), isCommunication && result2.details) {
6704
+ let targets = result2.details.steering?.targets.map((target) => targetNames.get(target.index) ?? `Subagent ${target.index + 1}`), peer = targets?.length ? targets.join(", ") : displayTitle || "Subagent";
6705
+ result2.details.communication = { direction: "to", peer, kind: "steer", message: params.message };
6706
+ }
6707
+ return result2;
6708
+ }, slashBridge = registerSlashSubagentBridge({
6649
6709
  events: pi.events,
6650
6710
  getContext: () => state.lastUiContext,
6651
6711
  execute: (id, params, signal, onUpdate, ctx) => executeSubagentCollapsed(id, params, signal, onUpdate, ctx)
@@ -6670,8 +6730,12 @@ function registerSubagentExtension(pi) {
6670
6730
  execute(id, params, signal, onUpdate, ctx) {
6671
6731
  return executeSubagentCollapsed(id, params, signal, onUpdate, ctx);
6672
6732
  },
6673
- renderCall: (args, theme, context) => renderSubagentCall(args, theme, context, { asyncByDefault }),
6733
+ renderCall: (args, theme, context) => renderSubagentCall(args, theme, context, {
6734
+ resolveActionTitle: (params) => resolveSubagentActionDisplayTitle(params, state)
6735
+ }),
6674
6736
  renderResult(result2, options, theme, context) {
6737
+ if (result2.details?.communication)
6738
+ return renderCommunicationResult(result2.content, result2.details, options.expanded, context.isError, theme);
6675
6739
  subagentResultIsRunning(result2) ? ensureSubagentResultAnimation(context) : clearLegacyResultAnimationTimer(context);
6676
6740
  let state2 = context.state, entries = [];
6677
6741
  state2.animEntries = entries, subagentAnimSink.current = entries;
@@ -6689,7 +6753,7 @@ function registerSubagentExtension(pi) {
6689
6753
  launches.length !== 0 && await awaitWithAbort(Promise.all(launches).then(() => {
6690
6754
  }), signal);
6691
6755
  }), pi.on("agent_end", async (_event, ctx) => {
6692
- ctx.hasUI || await drainOutstandingWork({ state, events: pi.events });
6756
+ ctx.hasUI || await drainOutstandingWork({ state, events: pi.events, hasPendingMessages: () => ctx.hasPendingMessages() });
6693
6757
  }), registerSlashCommands(pi, state);
6694
6758
  let eventUnsubscribeStoreKey = "__piSubagentEventUnsubscribes", controlNoticeSeenStoreKey = "__piSubagentVisibleControlNotices", previousEventUnsubscribes = globalStore[eventUnsubscribeStoreKey];
6695
6759
  if (Array.isArray(previousEventUnsubscribes)) {