@ashx-j/lunr-dev 0.2.13-dev.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2280) hide show
  1. package/CHANGELOG.md +5055 -0
  2. package/README.md +25 -0
  3. package/dist/builtin-extensions/ashxj-spinners.d.ts +7 -0
  4. package/dist/builtin-extensions/ashxj-spinners.d.ts.map +1 -0
  5. package/dist/builtin-extensions/ashxj-spinners.js +282 -0
  6. package/dist/builtin-extensions/ashxj-spinners.js.map +1 -0
  7. package/dist/builtin-extensions/ashxj-thinking.d.ts +66 -0
  8. package/dist/builtin-extensions/ashxj-thinking.d.ts.map +1 -0
  9. package/dist/builtin-extensions/ashxj-thinking.js +321 -0
  10. package/dist/builtin-extensions/ashxj-thinking.js.map +1 -0
  11. package/dist/builtin-extensions/ashxj-tui.d.ts +148 -0
  12. package/dist/builtin-extensions/ashxj-tui.d.ts.map +1 -0
  13. package/dist/builtin-extensions/ashxj-tui.js +679 -0
  14. package/dist/builtin-extensions/ashxj-tui.js.map +1 -0
  15. package/dist/builtin-extensions/index.d.ts +34 -0
  16. package/dist/builtin-extensions/index.d.ts.map +1 -0
  17. package/dist/builtin-extensions/index.js +81 -0
  18. package/dist/builtin-extensions/index.js.map +1 -0
  19. package/dist/builtin-extensions/lunr-cron.d.ts +26 -0
  20. package/dist/builtin-extensions/lunr-cron.d.ts.map +1 -0
  21. package/dist/builtin-extensions/lunr-cron.js +351 -0
  22. package/dist/builtin-extensions/lunr-cron.js.map +1 -0
  23. package/dist/builtin-extensions/lunr-local-providers/index.d.ts +20 -0
  24. package/dist/builtin-extensions/lunr-local-providers/index.d.ts.map +1 -0
  25. package/dist/builtin-extensions/lunr-local-providers/index.js +130 -0
  26. package/dist/builtin-extensions/lunr-local-providers/index.js.map +1 -0
  27. package/dist/builtin-extensions/lunr-local-providers/local-servers.d.ts +51 -0
  28. package/dist/builtin-extensions/lunr-local-providers/local-servers.d.ts.map +1 -0
  29. package/dist/builtin-extensions/lunr-local-providers/local-servers.js +130 -0
  30. package/dist/builtin-extensions/lunr-local-providers/local-servers.js.map +1 -0
  31. package/dist/builtin-extensions/lunr-plan-tools.d.ts +25 -0
  32. package/dist/builtin-extensions/lunr-plan-tools.d.ts.map +1 -0
  33. package/dist/builtin-extensions/lunr-plan-tools.js +59 -0
  34. package/dist/builtin-extensions/lunr-plan-tools.js.map +1 -0
  35. package/dist/builtin-extensions/lunr-skill-creator/index.d.ts +12 -0
  36. package/dist/builtin-extensions/lunr-skill-creator/index.d.ts.map +1 -0
  37. package/dist/builtin-extensions/lunr-skill-creator/index.js +18 -0
  38. package/dist/builtin-extensions/lunr-skill-creator/index.js.map +1 -0
  39. package/dist/builtin-extensions/lunr-skill-creator/skills/skill-creator/SKILL.md +68 -0
  40. package/dist/builtin-extensions/lunr-todos.d.ts +50 -0
  41. package/dist/builtin-extensions/lunr-todos.d.ts.map +1 -0
  42. package/dist/builtin-extensions/lunr-todos.js +210 -0
  43. package/dist/builtin-extensions/lunr-todos.js.map +1 -0
  44. package/dist/builtin-extensions/narumiruna-pi-goal/src/accounting.d.ts +23 -0
  45. package/dist/builtin-extensions/narumiruna-pi-goal/src/accounting.d.ts.map +1 -0
  46. package/dist/builtin-extensions/narumiruna-pi-goal/src/accounting.js +77 -0
  47. package/dist/builtin-extensions/narumiruna-pi-goal/src/accounting.js.map +1 -0
  48. package/dist/builtin-extensions/narumiruna-pi-goal/src/command.d.ts +18 -0
  49. package/dist/builtin-extensions/narumiruna-pi-goal/src/command.d.ts.map +1 -0
  50. package/dist/builtin-extensions/narumiruna-pi-goal/src/command.js +165 -0
  51. package/dist/builtin-extensions/narumiruna-pi-goal/src/command.js.map +1 -0
  52. package/dist/builtin-extensions/narumiruna-pi-goal/src/commands.d.ts +19 -0
  53. package/dist/builtin-extensions/narumiruna-pi-goal/src/commands.d.ts.map +1 -0
  54. package/dist/builtin-extensions/narumiruna-pi-goal/src/commands.js +499 -0
  55. package/dist/builtin-extensions/narumiruna-pi-goal/src/commands.js.map +1 -0
  56. package/dist/builtin-extensions/narumiruna-pi-goal/src/goal.d.ts +10 -0
  57. package/dist/builtin-extensions/narumiruna-pi-goal/src/goal.d.ts.map +1 -0
  58. package/dist/builtin-extensions/narumiruna-pi-goal/src/goal.js +885 -0
  59. package/dist/builtin-extensions/narumiruna-pi-goal/src/goal.js.map +1 -0
  60. package/dist/builtin-extensions/narumiruna-pi-goal/src/persistence.d.ts +57 -0
  61. package/dist/builtin-extensions/narumiruna-pi-goal/src/persistence.d.ts.map +1 -0
  62. package/dist/builtin-extensions/narumiruna-pi-goal/src/persistence.js +225 -0
  63. package/dist/builtin-extensions/narumiruna-pi-goal/src/persistence.js.map +1 -0
  64. package/dist/builtin-extensions/narumiruna-pi-goal/src/prompts.d.ts +20 -0
  65. package/dist/builtin-extensions/narumiruna-pi-goal/src/prompts.d.ts.map +1 -0
  66. package/dist/builtin-extensions/narumiruna-pi-goal/src/prompts.js +75 -0
  67. package/dist/builtin-extensions/narumiruna-pi-goal/src/prompts.js.map +1 -0
  68. package/dist/builtin-extensions/narumiruna-pi-goal/src/queue.d.ts +16 -0
  69. package/dist/builtin-extensions/narumiruna-pi-goal/src/queue.d.ts.map +1 -0
  70. package/dist/builtin-extensions/narumiruna-pi-goal/src/queue.js +67 -0
  71. package/dist/builtin-extensions/narumiruna-pi-goal/src/queue.js.map +1 -0
  72. package/dist/builtin-extensions/narumiruna-pi-goal/src/runtime.d.ts +158 -0
  73. package/dist/builtin-extensions/narumiruna-pi-goal/src/runtime.d.ts.map +1 -0
  74. package/dist/builtin-extensions/narumiruna-pi-goal/src/runtime.js +835 -0
  75. package/dist/builtin-extensions/narumiruna-pi-goal/src/runtime.js.map +1 -0
  76. package/dist/builtin-extensions/narumiruna-pi-goal/src/settings.d.ts +22 -0
  77. package/dist/builtin-extensions/narumiruna-pi-goal/src/settings.d.ts.map +1 -0
  78. package/dist/builtin-extensions/narumiruna-pi-goal/src/settings.js +64 -0
  79. package/dist/builtin-extensions/narumiruna-pi-goal/src/settings.js.map +1 -0
  80. package/dist/builtin-extensions/pi-intercom/broker/broker.d.ts +2 -0
  81. package/dist/builtin-extensions/pi-intercom/broker/broker.d.ts.map +1 -0
  82. package/dist/builtin-extensions/pi-intercom/broker/broker.js +541 -0
  83. package/dist/builtin-extensions/pi-intercom/broker/broker.js.map +1 -0
  84. package/dist/builtin-extensions/pi-intercom/broker/client.d.ts +39 -0
  85. package/dist/builtin-extensions/pi-intercom/broker/client.d.ts.map +1 -0
  86. package/dist/builtin-extensions/pi-intercom/broker/client.js +484 -0
  87. package/dist/builtin-extensions/pi-intercom/broker/client.js.map +1 -0
  88. package/dist/builtin-extensions/pi-intercom/broker/framing.d.ts +14 -0
  89. package/dist/builtin-extensions/pi-intercom/broker/framing.d.ts.map +1 -0
  90. package/dist/builtin-extensions/pi-intercom/broker/framing.js +74 -0
  91. package/dist/builtin-extensions/pi-intercom/broker/framing.js.map +1 -0
  92. package/dist/builtin-extensions/pi-intercom/broker/paths.d.ts +22 -0
  93. package/dist/builtin-extensions/pi-intercom/broker/paths.d.ts.map +1 -0
  94. package/dist/builtin-extensions/pi-intercom/broker/paths.js +88 -0
  95. package/dist/builtin-extensions/pi-intercom/broker/paths.js.map +1 -0
  96. package/dist/builtin-extensions/pi-intercom/broker/spawn.d.ts +27 -0
  97. package/dist/builtin-extensions/pi-intercom/broker/spawn.d.ts.map +1 -0
  98. package/dist/builtin-extensions/pi-intercom/broker/spawn.js +313 -0
  99. package/dist/builtin-extensions/pi-intercom/broker/spawn.js.map +1 -0
  100. package/dist/builtin-extensions/pi-intercom/config.d.ts +22 -0
  101. package/dist/builtin-extensions/pi-intercom/config.d.ts.map +1 -0
  102. package/dist/builtin-extensions/pi-intercom/config.js +103 -0
  103. package/dist/builtin-extensions/pi-intercom/config.js.map +1 -0
  104. package/dist/builtin-extensions/pi-intercom/index.d.ts +3 -0
  105. package/dist/builtin-extensions/pi-intercom/index.d.ts.map +1 -0
  106. package/dist/builtin-extensions/pi-intercom/index.js +1800 -0
  107. package/dist/builtin-extensions/pi-intercom/index.js.map +1 -0
  108. package/dist/builtin-extensions/pi-intercom/reply-tracker.d.ts +27 -0
  109. package/dist/builtin-extensions/pi-intercom/reply-tracker.d.ts.map +1 -0
  110. package/dist/builtin-extensions/pi-intercom/reply-tracker.js +101 -0
  111. package/dist/builtin-extensions/pi-intercom/reply-tracker.js.map +1 -0
  112. package/dist/builtin-extensions/pi-intercom/types.d.ts +84 -0
  113. package/dist/builtin-extensions/pi-intercom/types.d.ts.map +1 -0
  114. package/dist/builtin-extensions/pi-intercom/types.js +2 -0
  115. package/dist/builtin-extensions/pi-intercom/types.js.map +1 -0
  116. package/dist/builtin-extensions/pi-intercom/ui/compose.d.ts +27 -0
  117. package/dist/builtin-extensions/pi-intercom/ui/compose.d.ts.map +1 -0
  118. package/dist/builtin-extensions/pi-intercom/ui/compose.js +112 -0
  119. package/dist/builtin-extensions/pi-intercom/ui/compose.js.map +1 -0
  120. package/dist/builtin-extensions/pi-intercom/ui/inline-message.d.ts +15 -0
  121. package/dist/builtin-extensions/pi-intercom/ui/inline-message.d.ts.map +1 -0
  122. package/dist/builtin-extensions/pi-intercom/ui/inline-message.js +86 -0
  123. package/dist/builtin-extensions/pi-intercom/ui/inline-message.js.map +1 -0
  124. package/dist/builtin-extensions/pi-intercom/ui/session-list.d.ts +18 -0
  125. package/dist/builtin-extensions/pi-intercom/ui/session-list.d.ts.map +1 -0
  126. package/dist/builtin-extensions/pi-intercom/ui/session-list.js +134 -0
  127. package/dist/builtin-extensions/pi-intercom/ui/session-list.js.map +1 -0
  128. package/dist/builtin-extensions/pi-lsp-extension/bemol-extension/bemol.d.ts +81 -0
  129. package/dist/builtin-extensions/pi-lsp-extension/bemol-extension/bemol.d.ts.map +1 -0
  130. package/dist/builtin-extensions/pi-lsp-extension/bemol-extension/bemol.js +273 -0
  131. package/dist/builtin-extensions/pi-lsp-extension/bemol-extension/bemol.js.map +1 -0
  132. package/dist/builtin-extensions/pi-lsp-extension/bemol-extension/index.d.ts +13 -0
  133. package/dist/builtin-extensions/pi-lsp-extension/bemol-extension/index.d.ts.map +1 -0
  134. package/dist/builtin-extensions/pi-lsp-extension/bemol-extension/index.js +163 -0
  135. package/dist/builtin-extensions/pi-lsp-extension/bemol-extension/index.js.map +1 -0
  136. package/dist/builtin-extensions/pi-lsp-extension/bemol-extension/locks.d.ts +34 -0
  137. package/dist/builtin-extensions/pi-lsp-extension/bemol-extension/locks.d.ts.map +1 -0
  138. package/dist/builtin-extensions/pi-lsp-extension/bemol-extension/locks.js +148 -0
  139. package/dist/builtin-extensions/pi-lsp-extension/bemol-extension/locks.js.map +1 -0
  140. package/dist/builtin-extensions/pi-lsp-extension/src/file-sync.d.ts +59 -0
  141. package/dist/builtin-extensions/pi-lsp-extension/src/file-sync.d.ts.map +1 -0
  142. package/dist/builtin-extensions/pi-lsp-extension/src/file-sync.js +172 -0
  143. package/dist/builtin-extensions/pi-lsp-extension/src/file-sync.js.map +1 -0
  144. package/dist/builtin-extensions/pi-lsp-extension/src/index.d.ts +25 -0
  145. package/dist/builtin-extensions/pi-lsp-extension/src/index.d.ts.map +1 -0
  146. package/dist/builtin-extensions/pi-lsp-extension/src/index.js +521 -0
  147. package/dist/builtin-extensions/pi-lsp-extension/src/index.js.map +1 -0
  148. package/dist/builtin-extensions/pi-lsp-extension/src/lsp-client.d.ts +80 -0
  149. package/dist/builtin-extensions/pi-lsp-extension/src/lsp-client.d.ts.map +1 -0
  150. package/dist/builtin-extensions/pi-lsp-extension/src/lsp-client.js +366 -0
  151. package/dist/builtin-extensions/pi-lsp-extension/src/lsp-client.js.map +1 -0
  152. package/dist/builtin-extensions/pi-lsp-extension/src/lsp-daemon.d.ts +22 -0
  153. package/dist/builtin-extensions/pi-lsp-extension/src/lsp-daemon.d.ts.map +1 -0
  154. package/dist/builtin-extensions/pi-lsp-extension/src/lsp-daemon.js +476 -0
  155. package/dist/builtin-extensions/pi-lsp-extension/src/lsp-daemon.js.map +1 -0
  156. package/dist/builtin-extensions/pi-lsp-extension/src/lsp-manager.d.ts +141 -0
  157. package/dist/builtin-extensions/pi-lsp-extension/src/lsp-manager.d.ts.map +1 -0
  158. package/dist/builtin-extensions/pi-lsp-extension/src/lsp-manager.js +633 -0
  159. package/dist/builtin-extensions/pi-lsp-extension/src/lsp-manager.js.map +1 -0
  160. package/dist/builtin-extensions/pi-lsp-extension/src/resolve-provider.d.ts +30 -0
  161. package/dist/builtin-extensions/pi-lsp-extension/src/resolve-provider.d.ts.map +1 -0
  162. package/dist/builtin-extensions/pi-lsp-extension/src/resolve-provider.js +52 -0
  163. package/dist/builtin-extensions/pi-lsp-extension/src/resolve-provider.js.map +1 -0
  164. package/dist/builtin-extensions/pi-lsp-extension/src/shared/constants.d.ts +12 -0
  165. package/dist/builtin-extensions/pi-lsp-extension/src/shared/constants.d.ts.map +1 -0
  166. package/dist/builtin-extensions/pi-lsp-extension/src/shared/constants.js +18 -0
  167. package/dist/builtin-extensions/pi-lsp-extension/src/shared/constants.js.map +1 -0
  168. package/dist/builtin-extensions/pi-lsp-extension/src/shared/debug.d.ts +10 -0
  169. package/dist/builtin-extensions/pi-lsp-extension/src/shared/debug.d.ts.map +1 -0
  170. package/dist/builtin-extensions/pi-lsp-extension/src/shared/debug.js +18 -0
  171. package/dist/builtin-extensions/pi-lsp-extension/src/shared/debug.js.map +1 -0
  172. package/dist/builtin-extensions/pi-lsp-extension/src/shared/format.d.ts +9 -0
  173. package/dist/builtin-extensions/pi-lsp-extension/src/shared/format.d.ts.map +1 -0
  174. package/dist/builtin-extensions/pi-lsp-extension/src/shared/format.js +29 -0
  175. package/dist/builtin-extensions/pi-lsp-extension/src/shared/format.js.map +1 -0
  176. package/dist/builtin-extensions/pi-lsp-extension/src/shared/language-map.d.ts +10 -0
  177. package/dist/builtin-extensions/pi-lsp-extension/src/shared/language-map.d.ts.map +1 -0
  178. package/dist/builtin-extensions/pi-lsp-extension/src/shared/language-map.js +51 -0
  179. package/dist/builtin-extensions/pi-lsp-extension/src/shared/language-map.js.map +1 -0
  180. package/dist/builtin-extensions/pi-lsp-extension/src/shared/resolve-position.d.ts +33 -0
  181. package/dist/builtin-extensions/pi-lsp-extension/src/shared/resolve-position.d.ts.map +1 -0
  182. package/dist/builtin-extensions/pi-lsp-extension/src/shared/resolve-position.js +191 -0
  183. package/dist/builtin-extensions/pi-lsp-extension/src/shared/resolve-position.js.map +1 -0
  184. package/dist/builtin-extensions/pi-lsp-extension/src/shared/timing.d.ts +14 -0
  185. package/dist/builtin-extensions/pi-lsp-extension/src/shared/timing.d.ts.map +1 -0
  186. package/dist/builtin-extensions/pi-lsp-extension/src/shared/timing.js +15 -0
  187. package/dist/builtin-extensions/pi-lsp-extension/src/shared/timing.js.map +1 -0
  188. package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-actions.d.ts +23 -0
  189. package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-actions.d.ts.map +1 -0
  190. package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-actions.js +259 -0
  191. package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-actions.js.map +1 -0
  192. package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-overview.d.ts +23 -0
  193. package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-overview.d.ts.map +1 -0
  194. package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-overview.js +197 -0
  195. package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-overview.js.map +1 -0
  196. package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-rewrite.d.ts +23 -0
  197. package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-rewrite.d.ts.map +1 -0
  198. package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-rewrite.js +131 -0
  199. package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-rewrite.js.map +1 -0
  200. package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-search.d.ts +18 -0
  201. package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-search.d.ts.map +1 -0
  202. package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-search.js +87 -0
  203. package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-search.js.map +1 -0
  204. package/dist/builtin-extensions/pi-lsp-extension/src/tools/completions.d.ts +34 -0
  205. package/dist/builtin-extensions/pi-lsp-extension/src/tools/completions.d.ts.map +1 -0
  206. package/dist/builtin-extensions/pi-lsp-extension/src/tools/completions.js +347 -0
  207. package/dist/builtin-extensions/pi-lsp-extension/src/tools/completions.js.map +1 -0
  208. package/dist/builtin-extensions/pi-lsp-extension/src/tools/definition.d.ts +20 -0
  209. package/dist/builtin-extensions/pi-lsp-extension/src/tools/definition.d.ts.map +1 -0
  210. package/dist/builtin-extensions/pi-lsp-extension/src/tools/definition.js +166 -0
  211. package/dist/builtin-extensions/pi-lsp-extension/src/tools/definition.js.map +1 -0
  212. package/dist/builtin-extensions/pi-lsp-extension/src/tools/diagnostics.d.ts +22 -0
  213. package/dist/builtin-extensions/pi-lsp-extension/src/tools/diagnostics.d.ts.map +1 -0
  214. package/dist/builtin-extensions/pi-lsp-extension/src/tools/diagnostics.js +228 -0
  215. package/dist/builtin-extensions/pi-lsp-extension/src/tools/diagnostics.js.map +1 -0
  216. package/dist/builtin-extensions/pi-lsp-extension/src/tools/hover.d.ts +19 -0
  217. package/dist/builtin-extensions/pi-lsp-extension/src/tools/hover.d.ts.map +1 -0
  218. package/dist/builtin-extensions/pi-lsp-extension/src/tools/hover.js +143 -0
  219. package/dist/builtin-extensions/pi-lsp-extension/src/tools/hover.js.map +1 -0
  220. package/dist/builtin-extensions/pi-lsp-extension/src/tools/references.d.ts +20 -0
  221. package/dist/builtin-extensions/pi-lsp-extension/src/tools/references.d.ts.map +1 -0
  222. package/dist/builtin-extensions/pi-lsp-extension/src/tools/references.js +98 -0
  223. package/dist/builtin-extensions/pi-lsp-extension/src/tools/references.js.map +1 -0
  224. package/dist/builtin-extensions/pi-lsp-extension/src/tools/rename.d.ts +22 -0
  225. package/dist/builtin-extensions/pi-lsp-extension/src/tools/rename.d.ts.map +1 -0
  226. package/dist/builtin-extensions/pi-lsp-extension/src/tools/rename.js +150 -0
  227. package/dist/builtin-extensions/pi-lsp-extension/src/tools/rename.js.map +1 -0
  228. package/dist/builtin-extensions/pi-lsp-extension/src/tools/symbols.d.ts +18 -0
  229. package/dist/builtin-extensions/pi-lsp-extension/src/tools/symbols.d.ts.map +1 -0
  230. package/dist/builtin-extensions/pi-lsp-extension/src/tools/symbols.js +211 -0
  231. package/dist/builtin-extensions/pi-lsp-extension/src/tools/symbols.js.map +1 -0
  232. package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/parser-manager.d.ts +44 -0
  233. package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/parser-manager.d.ts.map +1 -0
  234. package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/parser-manager.js +188 -0
  235. package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/parser-manager.js.map +1 -0
  236. package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/pattern-compiler.d.ts +58 -0
  237. package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/pattern-compiler.d.ts.map +1 -0
  238. package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/pattern-compiler.js +260 -0
  239. package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/pattern-compiler.js.map +1 -0
  240. package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/rewrite-engine.d.ts +33 -0
  241. package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/rewrite-engine.d.ts.map +1 -0
  242. package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/rewrite-engine.js +102 -0
  243. package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/rewrite-engine.js.map +1 -0
  244. package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/search-engine.d.ts +38 -0
  245. package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/search-engine.d.ts.map +1 -0
  246. package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/search-engine.js +276 -0
  247. package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/search-engine.js.map +1 -0
  248. package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/symbol-extractor.d.ts +77 -0
  249. package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/symbol-extractor.d.ts.map +1 -0
  250. package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/symbol-extractor.js +339 -0
  251. package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/symbol-extractor.js.map +1 -0
  252. package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/workspace-index.d.ts +51 -0
  253. package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/workspace-index.d.ts.map +1 -0
  254. package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/workspace-index.js +219 -0
  255. package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/workspace-index.js.map +1 -0
  256. package/dist/builtin-extensions/pi-lsp-extension/src/workspace-provider.d.ts +45 -0
  257. package/dist/builtin-extensions/pi-lsp-extension/src/workspace-provider.d.ts.map +1 -0
  258. package/dist/builtin-extensions/pi-lsp-extension/src/workspace-provider.js +30 -0
  259. package/dist/builtin-extensions/pi-lsp-extension/src/workspace-provider.js.map +1 -0
  260. package/dist/builtin-extensions/pi-mcp-adapter/abort.d.ts +3 -0
  261. package/dist/builtin-extensions/pi-mcp-adapter/abort.d.ts.map +1 -0
  262. package/dist/builtin-extensions/pi-mcp-adapter/abort.js +37 -0
  263. package/dist/builtin-extensions/pi-mcp-adapter/abort.js.map +1 -0
  264. package/dist/builtin-extensions/pi-mcp-adapter/agent-dir.d.ts +3 -0
  265. package/dist/builtin-extensions/pi-mcp-adapter/agent-dir.d.ts.map +1 -0
  266. package/dist/builtin-extensions/pi-mcp-adapter/agent-dir.js +22 -0
  267. package/dist/builtin-extensions/pi-mcp-adapter/agent-dir.js.map +1 -0
  268. package/dist/builtin-extensions/pi-mcp-adapter/commands.d.ts +18 -0
  269. package/dist/builtin-extensions/pi-mcp-adapter/commands.d.ts.map +1 -0
  270. package/dist/builtin-extensions/pi-mcp-adapter/commands.js +327 -0
  271. package/dist/builtin-extensions/pi-mcp-adapter/commands.js.map +1 -0
  272. package/dist/builtin-extensions/pi-mcp-adapter/config.d.ts +79 -0
  273. package/dist/builtin-extensions/pi-mcp-adapter/config.d.ts.map +1 -0
  274. package/dist/builtin-extensions/pi-mcp-adapter/config.js +557 -0
  275. package/dist/builtin-extensions/pi-mcp-adapter/config.js.map +1 -0
  276. package/dist/builtin-extensions/pi-mcp-adapter/consent-manager.d.ts +14 -0
  277. package/dist/builtin-extensions/pi-mcp-adapter/consent-manager.d.ts.map +1 -0
  278. package/dist/builtin-extensions/pi-mcp-adapter/consent-manager.js +61 -0
  279. package/dist/builtin-extensions/pi-mcp-adapter/consent-manager.js.map +1 -0
  280. package/dist/builtin-extensions/pi-mcp-adapter/direct-tools.d.ts +11 -0
  281. package/dist/builtin-extensions/pi-mcp-adapter/direct-tools.d.ts.map +1 -0
  282. package/dist/builtin-extensions/pi-mcp-adapter/direct-tools.js +374 -0
  283. package/dist/builtin-extensions/pi-mcp-adapter/direct-tools.js.map +1 -0
  284. package/dist/builtin-extensions/pi-mcp-adapter/elicitation-handler.d.ts +18 -0
  285. package/dist/builtin-extensions/pi-mcp-adapter/elicitation-handler.d.ts.map +1 -0
  286. package/dist/builtin-extensions/pi-mcp-adapter/elicitation-handler.js +309 -0
  287. package/dist/builtin-extensions/pi-mcp-adapter/elicitation-handler.js.map +1 -0
  288. package/dist/builtin-extensions/pi-mcp-adapter/error-signal.d.ts +16 -0
  289. package/dist/builtin-extensions/pi-mcp-adapter/error-signal.d.ts.map +1 -0
  290. package/dist/builtin-extensions/pi-mcp-adapter/error-signal.js +23 -0
  291. package/dist/builtin-extensions/pi-mcp-adapter/error-signal.js.map +1 -0
  292. package/dist/builtin-extensions/pi-mcp-adapter/errors.d.ts +100 -0
  293. package/dist/builtin-extensions/pi-mcp-adapter/errors.d.ts.map +1 -0
  294. package/dist/builtin-extensions/pi-mcp-adapter/errors.js +167 -0
  295. package/dist/builtin-extensions/pi-mcp-adapter/errors.js.map +1 -0
  296. package/dist/builtin-extensions/pi-mcp-adapter/glimpse-ui.d.ts +10 -0
  297. package/dist/builtin-extensions/pi-mcp-adapter/glimpse-ui.d.ts.map +1 -0
  298. package/dist/builtin-extensions/pi-mcp-adapter/glimpse-ui.js +77 -0
  299. package/dist/builtin-extensions/pi-mcp-adapter/glimpse-ui.js.map +1 -0
  300. package/dist/builtin-extensions/pi-mcp-adapter/host-html-template.d.ts +17 -0
  301. package/dist/builtin-extensions/pi-mcp-adapter/host-html-template.d.ts.map +1 -0
  302. package/dist/builtin-extensions/pi-mcp-adapter/host-html-template.js +413 -0
  303. package/dist/builtin-extensions/pi-mcp-adapter/host-html-template.js.map +1 -0
  304. package/dist/builtin-extensions/pi-mcp-adapter/index.d.ts +3 -0
  305. package/dist/builtin-extensions/pi-mcp-adapter/index.d.ts.map +1 -0
  306. package/dist/builtin-extensions/pi-mcp-adapter/index.js +334 -0
  307. package/dist/builtin-extensions/pi-mcp-adapter/index.js.map +1 -0
  308. package/dist/builtin-extensions/pi-mcp-adapter/init.d.ts +11 -0
  309. package/dist/builtin-extensions/pi-mcp-adapter/init.d.ts.map +1 -0
  310. package/dist/builtin-extensions/pi-mcp-adapter/init.js +296 -0
  311. package/dist/builtin-extensions/pi-mcp-adapter/init.js.map +1 -0
  312. package/dist/builtin-extensions/pi-mcp-adapter/lifecycle.d.ts +30 -0
  313. package/dist/builtin-extensions/pi-mcp-adapter/lifecycle.d.ts.map +1 -0
  314. package/dist/builtin-extensions/pi-mcp-adapter/lifecycle.js +80 -0
  315. package/dist/builtin-extensions/pi-mcp-adapter/lifecycle.js.map +1 -0
  316. package/dist/builtin-extensions/pi-mcp-adapter/logger.d.ts +52 -0
  317. package/dist/builtin-extensions/pi-mcp-adapter/logger.d.ts.map +1 -0
  318. package/dist/builtin-extensions/pi-mcp-adapter/logger.js +132 -0
  319. package/dist/builtin-extensions/pi-mcp-adapter/logger.js.map +1 -0
  320. package/dist/builtin-extensions/pi-mcp-adapter/mcp-auth-flow.d.ts +86 -0
  321. package/dist/builtin-extensions/pi-mcp-adapter/mcp-auth-flow.d.ts.map +1 -0
  322. package/dist/builtin-extensions/pi-mcp-adapter/mcp-auth-flow.js +482 -0
  323. package/dist/builtin-extensions/pi-mcp-adapter/mcp-auth-flow.js.map +1 -0
  324. package/dist/builtin-extensions/pi-mcp-adapter/mcp-auth.d.ts +104 -0
  325. package/dist/builtin-extensions/pi-mcp-adapter/mcp-auth.d.ts.map +1 -0
  326. package/dist/builtin-extensions/pi-mcp-adapter/mcp-auth.js +252 -0
  327. package/dist/builtin-extensions/pi-mcp-adapter/mcp-auth.js.map +1 -0
  328. package/dist/builtin-extensions/pi-mcp-adapter/mcp-callback-server.d.ts +45 -0
  329. package/dist/builtin-extensions/pi-mcp-adapter/mcp-callback-server.d.ts.map +1 -0
  330. package/dist/builtin-extensions/pi-mcp-adapter/mcp-callback-server.js +305 -0
  331. package/dist/builtin-extensions/pi-mcp-adapter/mcp-callback-server.js.map +1 -0
  332. package/dist/builtin-extensions/pi-mcp-adapter/mcp-oauth-provider.d.ts +111 -0
  333. package/dist/builtin-extensions/pi-mcp-adapter/mcp-oauth-provider.d.ts.map +1 -0
  334. package/dist/builtin-extensions/pi-mcp-adapter/mcp-oauth-provider.js +302 -0
  335. package/dist/builtin-extensions/pi-mcp-adapter/mcp-oauth-provider.js.map +1 -0
  336. package/dist/builtin-extensions/pi-mcp-adapter/mcp-output-guard.d.ts +59 -0
  337. package/dist/builtin-extensions/pi-mcp-adapter/mcp-output-guard.d.ts.map +1 -0
  338. package/dist/builtin-extensions/pi-mcp-adapter/mcp-output-guard.js +325 -0
  339. package/dist/builtin-extensions/pi-mcp-adapter/mcp-output-guard.js.map +1 -0
  340. package/dist/builtin-extensions/pi-mcp-adapter/mcp-panel.d.ts +64 -0
  341. package/dist/builtin-extensions/pi-mcp-adapter/mcp-panel.d.ts.map +1 -0
  342. package/dist/builtin-extensions/pi-mcp-adapter/mcp-panel.js +777 -0
  343. package/dist/builtin-extensions/pi-mcp-adapter/mcp-panel.js.map +1 -0
  344. package/dist/builtin-extensions/pi-mcp-adapter/mcp-setup-panel.d.ts +77 -0
  345. package/dist/builtin-extensions/pi-mcp-adapter/mcp-setup-panel.d.ts.map +1 -0
  346. package/dist/builtin-extensions/pi-mcp-adapter/mcp-setup-panel.js +490 -0
  347. package/dist/builtin-extensions/pi-mcp-adapter/mcp-setup-panel.js.map +1 -0
  348. package/dist/builtin-extensions/pi-mcp-adapter/metadata-cache.d.ts +32 -0
  349. package/dist/builtin-extensions/pi-mcp-adapter/metadata-cache.d.ts.map +1 -0
  350. package/dist/builtin-extensions/pi-mcp-adapter/metadata-cache.js +160 -0
  351. package/dist/builtin-extensions/pi-mcp-adapter/metadata-cache.js.map +1 -0
  352. package/dist/builtin-extensions/pi-mcp-adapter/npx-resolver.d.ts +7 -0
  353. package/dist/builtin-extensions/pi-mcp-adapter/npx-resolver.d.ts.map +1 -0
  354. package/dist/builtin-extensions/pi-mcp-adapter/npx-resolver.js +388 -0
  355. package/dist/builtin-extensions/pi-mcp-adapter/npx-resolver.js.map +1 -0
  356. package/dist/builtin-extensions/pi-mcp-adapter/oauth-handler.d.ts +19 -0
  357. package/dist/builtin-extensions/pi-mcp-adapter/oauth-handler.d.ts.map +1 -0
  358. package/dist/builtin-extensions/pi-mcp-adapter/oauth-handler.js +53 -0
  359. package/dist/builtin-extensions/pi-mcp-adapter/oauth-handler.js.map +1 -0
  360. package/dist/builtin-extensions/pi-mcp-adapter/onboarding-state.d.ts +13 -0
  361. package/dist/builtin-extensions/pi-mcp-adapter/onboarding-state.d.ts.map +1 -0
  362. package/dist/builtin-extensions/pi-mcp-adapter/onboarding-state.js +58 -0
  363. package/dist/builtin-extensions/pi-mcp-adapter/onboarding-state.js.map +1 -0
  364. package/dist/builtin-extensions/pi-mcp-adapter/panel-keys.d.ts +17 -0
  365. package/dist/builtin-extensions/pi-mcp-adapter/panel-keys.d.ts.map +1 -0
  366. package/dist/builtin-extensions/pi-mcp-adapter/panel-keys.js +17 -0
  367. package/dist/builtin-extensions/pi-mcp-adapter/panel-keys.js.map +1 -0
  368. package/dist/builtin-extensions/pi-mcp-adapter/proxy-modes.d.ts +14 -0
  369. package/dist/builtin-extensions/pi-mcp-adapter/proxy-modes.d.ts.map +1 -0
  370. package/dist/builtin-extensions/pi-mcp-adapter/proxy-modes.js +853 -0
  371. package/dist/builtin-extensions/pi-mcp-adapter/proxy-modes.js.map +1 -0
  372. package/dist/builtin-extensions/pi-mcp-adapter/resource-tools.d.ts +2 -0
  373. package/dist/builtin-extensions/pi-mcp-adapter/resource-tools.d.ts.map +1 -0
  374. package/dist/builtin-extensions/pi-mcp-adapter/resource-tools.js +16 -0
  375. package/dist/builtin-extensions/pi-mcp-adapter/resource-tools.js.map +1 -0
  376. package/dist/builtin-extensions/pi-mcp-adapter/sampling-handler.d.ts +16 -0
  377. package/dist/builtin-extensions/pi-mcp-adapter/sampling-handler.d.ts.map +1 -0
  378. package/dist/builtin-extensions/pi-mcp-adapter/sampling-handler.js +209 -0
  379. package/dist/builtin-extensions/pi-mcp-adapter/sampling-handler.js.map +1 -0
  380. package/dist/builtin-extensions/pi-mcp-adapter/server-manager.d.ts +58 -0
  381. package/dist/builtin-extensions/pi-mcp-adapter/server-manager.d.ts.map +1 -0
  382. package/dist/builtin-extensions/pi-mcp-adapter/server-manager.js +403 -0
  383. package/dist/builtin-extensions/pi-mcp-adapter/server-manager.js.map +1 -0
  384. package/dist/builtin-extensions/pi-mcp-adapter/state.d.ts +41 -0
  385. package/dist/builtin-extensions/pi-mcp-adapter/state.d.ts.map +1 -0
  386. package/dist/builtin-extensions/pi-mcp-adapter/state.js +2 -0
  387. package/dist/builtin-extensions/pi-mcp-adapter/state.js.map +1 -0
  388. package/dist/builtin-extensions/pi-mcp-adapter/tool-metadata.d.ts +11 -0
  389. package/dist/builtin-extensions/pi-mcp-adapter/tool-metadata.d.ts.map +1 -0
  390. package/dist/builtin-extensions/pi-mcp-adapter/tool-metadata.js +178 -0
  391. package/dist/builtin-extensions/pi-mcp-adapter/tool-metadata.js.map +1 -0
  392. package/dist/builtin-extensions/pi-mcp-adapter/tool-registrar.d.ts +11 -0
  393. package/dist/builtin-extensions/pi-mcp-adapter/tool-registrar.d.ts.map +1 -0
  394. package/dist/builtin-extensions/pi-mcp-adapter/tool-registrar.js +66 -0
  395. package/dist/builtin-extensions/pi-mcp-adapter/tool-registrar.js.map +1 -0
  396. package/dist/builtin-extensions/pi-mcp-adapter/tool-result-renderer.d.ts +35 -0
  397. package/dist/builtin-extensions/pi-mcp-adapter/tool-result-renderer.d.ts.map +1 -0
  398. package/dist/builtin-extensions/pi-mcp-adapter/tool-result-renderer.js +107 -0
  399. package/dist/builtin-extensions/pi-mcp-adapter/tool-result-renderer.js.map +1 -0
  400. package/dist/builtin-extensions/pi-mcp-adapter/types.d.ts +286 -0
  401. package/dist/builtin-extensions/pi-mcp-adapter/types.d.ts.map +1 -0
  402. package/dist/builtin-extensions/pi-mcp-adapter/types.js +94 -0
  403. package/dist/builtin-extensions/pi-mcp-adapter/types.js.map +1 -0
  404. package/dist/builtin-extensions/pi-mcp-adapter/ui-resource-handler.d.ts +10 -0
  405. package/dist/builtin-extensions/pi-mcp-adapter/ui-resource-handler.d.ts.map +1 -0
  406. package/dist/builtin-extensions/pi-mcp-adapter/ui-resource-handler.js +118 -0
  407. package/dist/builtin-extensions/pi-mcp-adapter/ui-resource-handler.js.map +1 -0
  408. package/dist/builtin-extensions/pi-mcp-adapter/ui-server.d.ts +37 -0
  409. package/dist/builtin-extensions/pi-mcp-adapter/ui-server.d.ts.map +1 -0
  410. package/dist/builtin-extensions/pi-mcp-adapter/ui-server.js +524 -0
  411. package/dist/builtin-extensions/pi-mcp-adapter/ui-server.js.map +1 -0
  412. package/dist/builtin-extensions/pi-mcp-adapter/ui-session.d.ts +27 -0
  413. package/dist/builtin-extensions/pi-mcp-adapter/ui-session.d.ts.map +1 -0
  414. package/dist/builtin-extensions/pi-mcp-adapter/ui-session.js +311 -0
  415. package/dist/builtin-extensions/pi-mcp-adapter/ui-session.js.map +1 -0
  416. package/dist/builtin-extensions/pi-mcp-adapter/ui-stream-types.d.ts +105 -0
  417. package/dist/builtin-extensions/pi-mcp-adapter/ui-stream-types.d.ts.map +1 -0
  418. package/dist/builtin-extensions/pi-mcp-adapter/ui-stream-types.js +60 -0
  419. package/dist/builtin-extensions/pi-mcp-adapter/ui-stream-types.js.map +1 -0
  420. package/dist/builtin-extensions/pi-mcp-adapter/utils.d.ts +18 -0
  421. package/dist/builtin-extensions/pi-mcp-adapter/utils.d.ts.map +1 -0
  422. package/dist/builtin-extensions/pi-mcp-adapter/utils.js +112 -0
  423. package/dist/builtin-extensions/pi-mcp-adapter/utils.js.map +1 -0
  424. package/dist/builtin-extensions/pi-mcp-adapter/vitest.config.d.ts +3 -0
  425. package/dist/builtin-extensions/pi-mcp-adapter/vitest.config.d.ts.map +1 -0
  426. package/dist/builtin-extensions/pi-mcp-adapter/vitest.config.js +15 -0
  427. package/dist/builtin-extensions/pi-mcp-adapter/vitest.config.js.map +1 -0
  428. package/dist/builtin-extensions/pi-ollama-cloud/index.d.ts +30 -0
  429. package/dist/builtin-extensions/pi-ollama-cloud/index.d.ts.map +1 -0
  430. package/dist/builtin-extensions/pi-ollama-cloud/index.js +99 -0
  431. package/dist/builtin-extensions/pi-ollama-cloud/index.js.map +1 -0
  432. package/dist/builtin-extensions/pi-ollama-cloud/models.d.ts +49 -0
  433. package/dist/builtin-extensions/pi-ollama-cloud/models.d.ts.map +1 -0
  434. package/dist/builtin-extensions/pi-ollama-cloud/models.generated.d.ts +3 -0
  435. package/dist/builtin-extensions/pi-ollama-cloud/models.generated.d.ts.map +1 -0
  436. package/dist/builtin-extensions/pi-ollama-cloud/models.generated.js +1135 -0
  437. package/dist/builtin-extensions/pi-ollama-cloud/models.generated.js.map +1 -0
  438. package/dist/builtin-extensions/pi-ollama-cloud/models.js +239 -0
  439. package/dist/builtin-extensions/pi-ollama-cloud/models.js.map +1 -0
  440. package/dist/builtin-extensions/pi-ollama-cloud/thinking-levels.d.ts +40 -0
  441. package/dist/builtin-extensions/pi-ollama-cloud/thinking-levels.d.ts.map +1 -0
  442. package/dist/builtin-extensions/pi-ollama-cloud/thinking-levels.js +80 -0
  443. package/dist/builtin-extensions/pi-ollama-cloud/thinking-levels.js.map +1 -0
  444. package/dist/builtin-extensions/pi-ollama-cloud/utils.d.ts +9 -0
  445. package/dist/builtin-extensions/pi-ollama-cloud/utils.d.ts.map +1 -0
  446. package/dist/builtin-extensions/pi-ollama-cloud/utils.js +52 -0
  447. package/dist/builtin-extensions/pi-ollama-cloud/utils.js.map +1 -0
  448. package/dist/builtin-extensions/pi-prompt-template-model/args.d.ts +56 -0
  449. package/dist/builtin-extensions/pi-prompt-template-model/args.d.ts.map +1 -0
  450. package/dist/builtin-extensions/pi-prompt-template-model/args.js +555 -0
  451. package/dist/builtin-extensions/pi-prompt-template-model/args.js.map +1 -0
  452. package/dist/builtin-extensions/pi-prompt-template-model/chain-parser.d.ts +22 -0
  453. package/dist/builtin-extensions/pi-prompt-template-model/chain-parser.d.ts.map +1 -0
  454. package/dist/builtin-extensions/pi-prompt-template-model/chain-parser.js +249 -0
  455. package/dist/builtin-extensions/pi-prompt-template-model/chain-parser.js.map +1 -0
  456. package/dist/builtin-extensions/pi-prompt-template-model/deterministic-renderer.d.ts +20 -0
  457. package/dist/builtin-extensions/pi-prompt-template-model/deterministic-renderer.d.ts.map +1 -0
  458. package/dist/builtin-extensions/pi-prompt-template-model/deterministic-renderer.js +102 -0
  459. package/dist/builtin-extensions/pi-prompt-template-model/deterministic-renderer.js.map +1 -0
  460. package/dist/builtin-extensions/pi-prompt-template-model/deterministic-step.d.ts +30 -0
  461. package/dist/builtin-extensions/pi-prompt-template-model/deterministic-step.d.ts.map +1 -0
  462. package/dist/builtin-extensions/pi-prompt-template-model/deterministic-step.js +260 -0
  463. package/dist/builtin-extensions/pi-prompt-template-model/deterministic-step.js.map +1 -0
  464. package/dist/builtin-extensions/pi-prompt-template-model/index.d.ts +3 -0
  465. package/dist/builtin-extensions/pi-prompt-template-model/index.d.ts.map +1 -0
  466. package/dist/builtin-extensions/pi-prompt-template-model/index.js +1403 -0
  467. package/dist/builtin-extensions/pi-prompt-template-model/index.js.map +1 -0
  468. package/dist/builtin-extensions/pi-prompt-template-model/loop-utils.d.ts +8 -0
  469. package/dist/builtin-extensions/pi-prompt-template-model/loop-utils.d.ts.map +1 -0
  470. package/dist/builtin-extensions/pi-prompt-template-model/loop-utils.js +164 -0
  471. package/dist/builtin-extensions/pi-prompt-template-model/loop-utils.js.map +1 -0
  472. package/dist/builtin-extensions/pi-prompt-template-model/model-selection.d.ts +22 -0
  473. package/dist/builtin-extensions/pi-prompt-template-model/model-selection.d.ts.map +1 -0
  474. package/dist/builtin-extensions/pi-prompt-template-model/model-selection.js +82 -0
  475. package/dist/builtin-extensions/pi-prompt-template-model/model-selection.js.map +1 -0
  476. package/dist/builtin-extensions/pi-prompt-template-model/notifications.d.ts +6 -0
  477. package/dist/builtin-extensions/pi-prompt-template-model/notifications.d.ts.map +1 -0
  478. package/dist/builtin-extensions/pi-prompt-template-model/notifications.js +21 -0
  479. package/dist/builtin-extensions/pi-prompt-template-model/notifications.js.map +1 -0
  480. package/dist/builtin-extensions/pi-prompt-template-model/prompt-execution.d.ts +24 -0
  481. package/dist/builtin-extensions/pi-prompt-template-model/prompt-execution.d.ts.map +1 -0
  482. package/dist/builtin-extensions/pi-prompt-template-model/prompt-execution.js +56 -0
  483. package/dist/builtin-extensions/pi-prompt-template-model/prompt-execution.js.map +1 -0
  484. package/dist/builtin-extensions/pi-prompt-template-model/prompt-loader.d.ts +80 -0
  485. package/dist/builtin-extensions/pi-prompt-template-model/prompt-loader.d.ts.map +1 -0
  486. package/dist/builtin-extensions/pi-prompt-template-model/prompt-loader.js +1234 -0
  487. package/dist/builtin-extensions/pi-prompt-template-model/prompt-loader.js.map +1 -0
  488. package/dist/builtin-extensions/pi-prompt-template-model/skill-loaded-renderer.d.ts +11 -0
  489. package/dist/builtin-extensions/pi-prompt-template-model/skill-loaded-renderer.d.ts.map +1 -0
  490. package/dist/builtin-extensions/pi-prompt-template-model/skill-loaded-renderer.js +31 -0
  491. package/dist/builtin-extensions/pi-prompt-template-model/skill-loaded-renderer.js.map +1 -0
  492. package/dist/builtin-extensions/pi-prompt-template-model/subagent-renderer.d.ts +43 -0
  493. package/dist/builtin-extensions/pi-prompt-template-model/subagent-renderer.d.ts.map +1 -0
  494. package/dist/builtin-extensions/pi-prompt-template-model/subagent-renderer.js +177 -0
  495. package/dist/builtin-extensions/pi-prompt-template-model/subagent-renderer.js.map +1 -0
  496. package/dist/builtin-extensions/pi-prompt-template-model/subagent-runtime.d.ts +97 -0
  497. package/dist/builtin-extensions/pi-prompt-template-model/subagent-runtime.d.ts.map +1 -0
  498. package/dist/builtin-extensions/pi-prompt-template-model/subagent-runtime.js +64 -0
  499. package/dist/builtin-extensions/pi-prompt-template-model/subagent-runtime.js.map +1 -0
  500. package/dist/builtin-extensions/pi-prompt-template-model/subagent-step.d.ts +48 -0
  501. package/dist/builtin-extensions/pi-prompt-template-model/subagent-step.d.ts.map +1 -0
  502. package/dist/builtin-extensions/pi-prompt-template-model/subagent-step.js +550 -0
  503. package/dist/builtin-extensions/pi-prompt-template-model/subagent-step.js.map +1 -0
  504. package/dist/builtin-extensions/pi-prompt-template-model/subagent-widget.d.ts +8 -0
  505. package/dist/builtin-extensions/pi-prompt-template-model/subagent-widget.d.ts.map +1 -0
  506. package/dist/builtin-extensions/pi-prompt-template-model/subagent-widget.js +230 -0
  507. package/dist/builtin-extensions/pi-prompt-template-model/subagent-widget.js.map +1 -0
  508. package/dist/builtin-extensions/pi-prompt-template-model/template-conditionals.d.ts +10 -0
  509. package/dist/builtin-extensions/pi-prompt-template-model/template-conditionals.d.ts.map +1 -0
  510. package/dist/builtin-extensions/pi-prompt-template-model/template-conditionals.js +226 -0
  511. package/dist/builtin-extensions/pi-prompt-template-model/template-conditionals.js.map +1 -0
  512. package/dist/builtin-extensions/pi-prompt-template-model/tool-manager.d.ts +17 -0
  513. package/dist/builtin-extensions/pi-prompt-template-model/tool-manager.d.ts.map +1 -0
  514. package/dist/builtin-extensions/pi-prompt-template-model/tool-manager.js +201 -0
  515. package/dist/builtin-extensions/pi-prompt-template-model/tool-manager.js.map +1 -0
  516. package/dist/builtin-extensions/pi-subagents/index.d.ts +2 -0
  517. package/dist/builtin-extensions/pi-subagents/index.d.ts.map +1 -0
  518. package/dist/builtin-extensions/pi-subagents/index.js +3 -0
  519. package/dist/builtin-extensions/pi-subagents/index.js.map +1 -0
  520. package/dist/builtin-extensions/pi-subagents/src/agents/frontmatter.d.ts +11 -0
  521. package/dist/builtin-extensions/pi-subagents/src/agents/frontmatter.d.ts.map +1 -0
  522. package/dist/builtin-extensions/pi-subagents/src/agents/frontmatter.js +84 -0
  523. package/dist/builtin-extensions/pi-subagents/src/agents/frontmatter.js.map +1 -0
  524. package/dist/builtin-extensions/pi-subagents/src/agents/skills.d.ts +33 -0
  525. package/dist/builtin-extensions/pi-subagents/src/agents/skills.d.ts.map +1 -0
  526. package/dist/builtin-extensions/pi-subagents/src/agents/skills.js +674 -0
  527. package/dist/builtin-extensions/pi-subagents/src/agents/skills.js.map +1 -0
  528. package/dist/builtin-extensions/pi-subagents/src/api/background-work.d.ts +35 -0
  529. package/dist/builtin-extensions/pi-subagents/src/api/background-work.d.ts.map +1 -0
  530. package/dist/builtin-extensions/pi-subagents/src/api/background-work.js +162 -0
  531. package/dist/builtin-extensions/pi-subagents/src/api/background-work.js.map +1 -0
  532. package/dist/builtin-extensions/pi-subagents/src/api/delegation.d.ts +113 -0
  533. package/dist/builtin-extensions/pi-subagents/src/api/delegation.d.ts.map +1 -0
  534. package/dist/builtin-extensions/pi-subagents/src/api/delegation.js +10 -0
  535. package/dist/builtin-extensions/pi-subagents/src/api/delegation.js.map +1 -0
  536. package/dist/builtin-extensions/pi-subagents/src/extension/chain-validation.d.ts +34 -0
  537. package/dist/builtin-extensions/pi-subagents/src/extension/chain-validation.d.ts.map +1 -0
  538. package/dist/builtin-extensions/pi-subagents/src/extension/chain-validation.js +125 -0
  539. package/dist/builtin-extensions/pi-subagents/src/extension/chain-validation.js.map +1 -0
  540. package/dist/builtin-extensions/pi-subagents/src/extension/config.d.ts +6 -0
  541. package/dist/builtin-extensions/pi-subagents/src/extension/config.d.ts.map +1 -0
  542. package/dist/builtin-extensions/pi-subagents/src/extension/config.js +37 -0
  543. package/dist/builtin-extensions/pi-subagents/src/extension/config.js.map +1 -0
  544. package/dist/builtin-extensions/pi-subagents/src/extension/control-notices.d.ts +21 -0
  545. package/dist/builtin-extensions/pi-subagents/src/extension/control-notices.d.ts.map +1 -0
  546. package/dist/builtin-extensions/pi-subagents/src/extension/control-notices.js +70 -0
  547. package/dist/builtin-extensions/pi-subagents/src/extension/control-notices.js.map +1 -0
  548. package/dist/builtin-extensions/pi-subagents/src/extension/doctor.d.ts +31 -0
  549. package/dist/builtin-extensions/pi-subagents/src/extension/doctor.d.ts.map +1 -0
  550. package/dist/builtin-extensions/pi-subagents/src/extension/doctor.js +152 -0
  551. package/dist/builtin-extensions/pi-subagents/src/extension/doctor.js.map +1 -0
  552. package/dist/builtin-extensions/pi-subagents/src/extension/fanout-child.d.ts +3 -0
  553. package/dist/builtin-extensions/pi-subagents/src/extension/fanout-child.d.ts.map +1 -0
  554. package/dist/builtin-extensions/pi-subagents/src/extension/fanout-child.js +174 -0
  555. package/dist/builtin-extensions/pi-subagents/src/extension/fanout-child.js.map +1 -0
  556. package/dist/builtin-extensions/pi-subagents/src/extension/index.d.ts +17 -0
  557. package/dist/builtin-extensions/pi-subagents/src/extension/index.d.ts.map +1 -0
  558. package/dist/builtin-extensions/pi-subagents/src/extension/index.js +565 -0
  559. package/dist/builtin-extensions/pi-subagents/src/extension/index.js.map +1 -0
  560. package/dist/builtin-extensions/pi-subagents/src/extension/rpc.d.ts +57 -0
  561. package/dist/builtin-extensions/pi-subagents/src/extension/rpc.d.ts.map +1 -0
  562. package/dist/builtin-extensions/pi-subagents/src/extension/rpc.js +291 -0
  563. package/dist/builtin-extensions/pi-subagents/src/extension/rpc.js.map +1 -0
  564. package/dist/builtin-extensions/pi-subagents/src/extension/schemas.d.ts +228 -0
  565. package/dist/builtin-extensions/pi-subagents/src/extension/schemas.d.ts.map +1 -0
  566. package/dist/builtin-extensions/pi-subagents/src/extension/schemas.js +305 -0
  567. package/dist/builtin-extensions/pi-subagents/src/extension/schemas.js.map +1 -0
  568. package/dist/builtin-extensions/pi-subagents/src/extension/steering-notices.d.ts +15 -0
  569. package/dist/builtin-extensions/pi-subagents/src/extension/steering-notices.d.ts.map +1 -0
  570. package/dist/builtin-extensions/pi-subagents/src/extension/steering-notices.js +23 -0
  571. package/dist/builtin-extensions/pi-subagents/src/extension/steering-notices.js.map +1 -0
  572. package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.d.ts +12 -0
  573. package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.d.ts.map +1 -0
  574. package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.js +209 -0
  575. package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.js.map +1 -0
  576. package/dist/builtin-extensions/pi-subagents/src/intercom/intercom-bridge.d.ts +35 -0
  577. package/dist/builtin-extensions/pi-subagents/src/intercom/intercom-bridge.d.ts.map +1 -0
  578. package/dist/builtin-extensions/pi-subagents/src/intercom/intercom-bridge.js +144 -0
  579. package/dist/builtin-extensions/pi-subagents/src/intercom/intercom-bridge.js.map +1 -0
  580. package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.d.ts +36 -0
  581. package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.d.ts.map +1 -0
  582. package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.js +626 -0
  583. package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.js.map +1 -0
  584. package/dist/builtin-extensions/pi-subagents/src/intercom/result-intercom.d.ts +31 -0
  585. package/dist/builtin-extensions/pi-subagents/src/intercom/result-intercom.d.ts.map +1 -0
  586. package/dist/builtin-extensions/pi-subagents/src/intercom/result-intercom.js +331 -0
  587. package/dist/builtin-extensions/pi-subagents/src/intercom/result-intercom.js.map +1 -0
  588. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.d.ts +166 -0
  589. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.d.ts.map +1 -0
  590. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.js +1049 -0
  591. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.js.map +1 -0
  592. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-job-tracker.d.ts +20 -0
  593. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-job-tracker.d.ts.map +1 -0
  594. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-job-tracker.js +500 -0
  595. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-job-tracker.js.map +1 -0
  596. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-resume.d.ts +65 -0
  597. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-resume.d.ts.map +1 -0
  598. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-resume.js +512 -0
  599. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-resume.js.map +1 -0
  600. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-status.d.ts +96 -0
  601. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-status.d.ts.map +1 -0
  602. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-status.js +336 -0
  603. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-status.js.map +1 -0
  604. package/dist/builtin-extensions/pi-subagents/src/runs/background/auto-drain.d.ts +15 -0
  605. package/dist/builtin-extensions/pi-subagents/src/runs/background/auto-drain.d.ts.map +1 -0
  606. package/dist/builtin-extensions/pi-subagents/src/runs/background/auto-drain.js +47 -0
  607. package/dist/builtin-extensions/pi-subagents/src/runs/background/auto-drain.js.map +1 -0
  608. package/dist/builtin-extensions/pi-subagents/src/runs/background/chain-append.d.ts +31 -0
  609. package/dist/builtin-extensions/pi-subagents/src/runs/background/chain-append.d.ts.map +1 -0
  610. package/dist/builtin-extensions/pi-subagents/src/runs/background/chain-append.js +260 -0
  611. package/dist/builtin-extensions/pi-subagents/src/runs/background/chain-append.js.map +1 -0
  612. package/dist/builtin-extensions/pi-subagents/src/runs/background/chain-root-attachment.d.ts +35 -0
  613. package/dist/builtin-extensions/pi-subagents/src/runs/background/chain-root-attachment.d.ts.map +1 -0
  614. package/dist/builtin-extensions/pi-subagents/src/runs/background/chain-root-attachment.js +146 -0
  615. package/dist/builtin-extensions/pi-subagents/src/runs/background/chain-root-attachment.js.map +1 -0
  616. package/dist/builtin-extensions/pi-subagents/src/runs/background/completion-batcher.d.ts +52 -0
  617. package/dist/builtin-extensions/pi-subagents/src/runs/background/completion-batcher.d.ts.map +1 -0
  618. package/dist/builtin-extensions/pi-subagents/src/runs/background/completion-batcher.js +119 -0
  619. package/dist/builtin-extensions/pi-subagents/src/runs/background/completion-batcher.js.map +1 -0
  620. package/dist/builtin-extensions/pi-subagents/src/runs/background/completion-dedupe.d.ts +14 -0
  621. package/dist/builtin-extensions/pi-subagents/src/runs/background/completion-dedupe.d.ts.map +1 -0
  622. package/dist/builtin-extensions/pi-subagents/src/runs/background/completion-dedupe.js +55 -0
  623. package/dist/builtin-extensions/pi-subagents/src/runs/background/completion-dedupe.js.map +1 -0
  624. package/dist/builtin-extensions/pi-subagents/src/runs/background/control-channel.d.ts +182 -0
  625. package/dist/builtin-extensions/pi-subagents/src/runs/background/control-channel.d.ts.map +1 -0
  626. package/dist/builtin-extensions/pi-subagents/src/runs/background/control-channel.js +487 -0
  627. package/dist/builtin-extensions/pi-subagents/src/runs/background/control-channel.js.map +1 -0
  628. package/dist/builtin-extensions/pi-subagents/src/runs/background/fleet-view.d.ts +43 -0
  629. package/dist/builtin-extensions/pi-subagents/src/runs/background/fleet-view.d.ts.map +1 -0
  630. package/dist/builtin-extensions/pi-subagents/src/runs/background/fleet-view.js +518 -0
  631. package/dist/builtin-extensions/pi-subagents/src/runs/background/fleet-view.js.map +1 -0
  632. package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.d.ts +63 -0
  633. package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.d.ts.map +1 -0
  634. package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.js +202 -0
  635. package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.js.map +1 -0
  636. package/dist/builtin-extensions/pi-subagents/src/runs/background/parallel-groups.d.ts +4 -0
  637. package/dist/builtin-extensions/pi-subagents/src/runs/background/parallel-groups.d.ts.map +1 -0
  638. package/dist/builtin-extensions/pi-subagents/src/runs/background/parallel-groups.js +47 -0
  639. package/dist/builtin-extensions/pi-subagents/src/runs/background/parallel-groups.js.map +1 -0
  640. package/dist/builtin-extensions/pi-subagents/src/runs/background/result-watcher.d.ts +22 -0
  641. package/dist/builtin-extensions/pi-subagents/src/runs/background/result-watcher.d.ts.map +1 -0
  642. package/dist/builtin-extensions/pi-subagents/src/runs/background/result-watcher.js +247 -0
  643. package/dist/builtin-extensions/pi-subagents/src/runs/background/result-watcher.js.map +1 -0
  644. package/dist/builtin-extensions/pi-subagents/src/runs/background/run-id-resolver.d.ts +23 -0
  645. package/dist/builtin-extensions/pi-subagents/src/runs/background/run-id-resolver.d.ts.map +1 -0
  646. package/dist/builtin-extensions/pi-subagents/src/runs/background/run-id-resolver.js +91 -0
  647. package/dist/builtin-extensions/pi-subagents/src/runs/background/run-id-resolver.js.map +1 -0
  648. package/dist/builtin-extensions/pi-subagents/src/runs/background/run-status.d.ts +24 -0
  649. package/dist/builtin-extensions/pi-subagents/src/runs/background/run-status.d.ts.map +1 -0
  650. package/dist/builtin-extensions/pi-subagents/src/runs/background/run-status.js +453 -0
  651. package/dist/builtin-extensions/pi-subagents/src/runs/background/run-status.js.map +1 -0
  652. package/dist/builtin-extensions/pi-subagents/src/runs/background/scheduled-runs.d.ts +52 -0
  653. package/dist/builtin-extensions/pi-subagents/src/runs/background/scheduled-runs.d.ts.map +1 -0
  654. package/dist/builtin-extensions/pi-subagents/src/runs/background/scheduled-runs.js +473 -0
  655. package/dist/builtin-extensions/pi-subagents/src/runs/background/scheduled-runs.js.map +1 -0
  656. package/dist/builtin-extensions/pi-subagents/src/runs/background/stale-run-reconciler.d.ts +34 -0
  657. package/dist/builtin-extensions/pi-subagents/src/runs/background/stale-run-reconciler.d.ts.map +1 -0
  658. package/dist/builtin-extensions/pi-subagents/src/runs/background/stale-run-reconciler.js +351 -0
  659. package/dist/builtin-extensions/pi-subagents/src/runs/background/stale-run-reconciler.js.map +1 -0
  660. package/dist/builtin-extensions/pi-subagents/src/runs/background/steering.d.ts +44 -0
  661. package/dist/builtin-extensions/pi-subagents/src/runs/background/steering.d.ts.map +1 -0
  662. package/dist/builtin-extensions/pi-subagents/src/runs/background/steering.js +228 -0
  663. package/dist/builtin-extensions/pi-subagents/src/runs/background/steering.js.map +1 -0
  664. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.d.ts +2 -0
  665. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.d.ts.map +1 -0
  666. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.js +3534 -0
  667. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.js.map +1 -0
  668. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.d.ts +95 -0
  669. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.d.ts.map +1 -0
  670. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.js +387 -0
  671. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.js.map +1 -0
  672. package/dist/builtin-extensions/pi-subagents/src/runs/background/top-level-async.d.ts +8 -0
  673. package/dist/builtin-extensions/pi-subagents/src/runs/background/top-level-async.d.ts.map +1 -0
  674. package/dist/builtin-extensions/pi-subagents/src/runs/background/top-level-async.js +6 -0
  675. package/dist/builtin-extensions/pi-subagents/src/runs/background/top-level-async.js.map +1 -0
  676. package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-config.d.ts +7 -0
  677. package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-config.d.ts.map +1 -0
  678. package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-config.js +34 -0
  679. package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-config.js.map +1 -0
  680. package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.d.ts +4 -0
  681. package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.d.ts.map +1 -0
  682. package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.js +24 -0
  683. package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.js.map +1 -0
  684. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/async-steering-action.d.ts +23 -0
  685. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/async-steering-action.d.ts.map +1 -0
  686. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/async-steering-action.js +230 -0
  687. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/async-steering-action.js.map +1 -0
  688. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-clarify.d.ts +127 -0
  689. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-clarify.d.ts.map +1 -0
  690. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-clarify.js +1161 -0
  691. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-clarify.js.map +1 -0
  692. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.d.ts +82 -0
  693. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.d.ts.map +1 -0
  694. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.js +1042 -0
  695. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.js.map +1 -0
  696. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.d.ts +10 -0
  697. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.d.ts.map +1 -0
  698. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.js +1439 -0
  699. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.js.map +1 -0
  700. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.d.ts +85 -0
  701. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.d.ts.map +1 -0
  702. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js +3468 -0
  703. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js.map +1 -0
  704. package/dist/builtin-extensions/pi-subagents/src/runs/shared/acceptance.d.ts +65 -0
  705. package/dist/builtin-extensions/pi-subagents/src/runs/shared/acceptance.d.ts.map +1 -0
  706. package/dist/builtin-extensions/pi-subagents/src/runs/shared/acceptance.js +1113 -0
  707. package/dist/builtin-extensions/pi-subagents/src/runs/shared/acceptance.js.map +1 -0
  708. package/dist/builtin-extensions/pi-subagents/src/runs/shared/chain-outputs.d.ts +19 -0
  709. package/dist/builtin-extensions/pi-subagents/src/runs/shared/chain-outputs.d.ts.map +1 -0
  710. package/dist/builtin-extensions/pi-subagents/src/runs/shared/chain-outputs.js +106 -0
  711. package/dist/builtin-extensions/pi-subagents/src/runs/shared/chain-outputs.js.map +1 -0
  712. package/dist/builtin-extensions/pi-subagents/src/runs/shared/child-protocol.d.ts +27 -0
  713. package/dist/builtin-extensions/pi-subagents/src/runs/shared/child-protocol.d.ts.map +1 -0
  714. package/dist/builtin-extensions/pi-subagents/src/runs/shared/child-protocol.js +108 -0
  715. package/dist/builtin-extensions/pi-subagents/src/runs/shared/child-protocol.js.map +1 -0
  716. package/dist/builtin-extensions/pi-subagents/src/runs/shared/child-tools.d.ts +25 -0
  717. package/dist/builtin-extensions/pi-subagents/src/runs/shared/child-tools.d.ts.map +1 -0
  718. package/dist/builtin-extensions/pi-subagents/src/runs/shared/child-tools.js +51 -0
  719. package/dist/builtin-extensions/pi-subagents/src/runs/shared/child-tools.js.map +1 -0
  720. package/dist/builtin-extensions/pi-subagents/src/runs/shared/completion-guard.d.ts +19 -0
  721. package/dist/builtin-extensions/pi-subagents/src/runs/shared/completion-guard.d.ts.map +1 -0
  722. package/dist/builtin-extensions/pi-subagents/src/runs/shared/completion-guard.js +51 -0
  723. package/dist/builtin-extensions/pi-subagents/src/runs/shared/completion-guard.js.map +1 -0
  724. package/dist/builtin-extensions/pi-subagents/src/runs/shared/dynamic-fanout.d.ts +49 -0
  725. package/dist/builtin-extensions/pi-subagents/src/runs/shared/dynamic-fanout.d.ts.map +1 -0
  726. package/dist/builtin-extensions/pi-subagents/src/runs/shared/dynamic-fanout.js +291 -0
  727. package/dist/builtin-extensions/pi-subagents/src/runs/shared/dynamic-fanout.js.map +1 -0
  728. package/dist/builtin-extensions/pi-subagents/src/runs/shared/long-running-guard.d.ts +33 -0
  729. package/dist/builtin-extensions/pi-subagents/src/runs/shared/long-running-guard.d.ts.map +1 -0
  730. package/dist/builtin-extensions/pi-subagents/src/runs/shared/long-running-guard.js +152 -0
  731. package/dist/builtin-extensions/pi-subagents/src/runs/shared/long-running-guard.js.map +1 -0
  732. package/dist/builtin-extensions/pi-subagents/src/runs/shared/mcp-direct-tool-allowlist.d.ts +18 -0
  733. package/dist/builtin-extensions/pi-subagents/src/runs/shared/mcp-direct-tool-allowlist.d.ts.map +1 -0
  734. package/dist/builtin-extensions/pi-subagents/src/runs/shared/mcp-direct-tool-allowlist.js +326 -0
  735. package/dist/builtin-extensions/pi-subagents/src/runs/shared/mcp-direct-tool-allowlist.js.map +1 -0
  736. package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.d.ts +83 -0
  737. package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.d.ts.map +1 -0
  738. package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.js +299 -0
  739. package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.js.map +1 -0
  740. package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-scope.d.ts +49 -0
  741. package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-scope.d.ts.map +1 -0
  742. package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-scope.js +98 -0
  743. package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-scope.js.map +1 -0
  744. package/dist/builtin-extensions/pi-subagents/src/runs/shared/nested-events.d.ts +121 -0
  745. package/dist/builtin-extensions/pi-subagents/src/runs/shared/nested-events.d.ts.map +1 -0
  746. package/dist/builtin-extensions/pi-subagents/src/runs/shared/nested-events.js +881 -0
  747. package/dist/builtin-extensions/pi-subagents/src/runs/shared/nested-events.js.map +1 -0
  748. package/dist/builtin-extensions/pi-subagents/src/runs/shared/nested-path.d.ts +11 -0
  749. package/dist/builtin-extensions/pi-subagents/src/runs/shared/nested-path.d.ts.map +1 -0
  750. package/dist/builtin-extensions/pi-subagents/src/runs/shared/nested-path.js +50 -0
  751. package/dist/builtin-extensions/pi-subagents/src/runs/shared/nested-path.js.map +1 -0
  752. package/dist/builtin-extensions/pi-subagents/src/runs/shared/nested-render.d.ts +19 -0
  753. package/dist/builtin-extensions/pi-subagents/src/runs/shared/nested-render.d.ts.map +1 -0
  754. package/dist/builtin-extensions/pi-subagents/src/runs/shared/nested-render.js +109 -0
  755. package/dist/builtin-extensions/pi-subagents/src/runs/shared/nested-render.js.map +1 -0
  756. package/dist/builtin-extensions/pi-subagents/src/runs/shared/parallel-utils.d.ts +106 -0
  757. package/dist/builtin-extensions/pi-subagents/src/runs/shared/parallel-utils.d.ts.map +1 -0
  758. package/dist/builtin-extensions/pi-subagents/src/runs/shared/parallel-utils.js +112 -0
  759. package/dist/builtin-extensions/pi-subagents/src/runs/shared/parallel-utils.js.map +1 -0
  760. package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.d.ts +87 -0
  761. package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.d.ts.map +1 -0
  762. package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.js +260 -0
  763. package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.js.map +1 -0
  764. package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-spawn.d.ts +25 -0
  765. package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-spawn.d.ts.map +1 -0
  766. package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-spawn.js +111 -0
  767. package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-spawn.js.map +1 -0
  768. package/dist/builtin-extensions/pi-subagents/src/runs/shared/run-history.d.ts +11 -0
  769. package/dist/builtin-extensions/pi-subagents/src/runs/shared/run-history.d.ts.map +1 -0
  770. package/dist/builtin-extensions/pi-subagents/src/runs/shared/run-history.js +57 -0
  771. package/dist/builtin-extensions/pi-subagents/src/runs/shared/run-history.js.map +1 -0
  772. package/dist/builtin-extensions/pi-subagents/src/runs/shared/session-lease.d.ts +54 -0
  773. package/dist/builtin-extensions/pi-subagents/src/runs/shared/session-lease.d.ts.map +1 -0
  774. package/dist/builtin-extensions/pi-subagents/src/runs/shared/session-lease.js +244 -0
  775. package/dist/builtin-extensions/pi-subagents/src/runs/shared/session-lease.js.map +1 -0
  776. package/dist/builtin-extensions/pi-subagents/src/runs/shared/single-output.d.ts +50 -0
  777. package/dist/builtin-extensions/pi-subagents/src/runs/shared/single-output.d.ts.map +1 -0
  778. package/dist/builtin-extensions/pi-subagents/src/runs/shared/single-output.js +202 -0
  779. package/dist/builtin-extensions/pi-subagents/src/runs/shared/single-output.js.map +1 -0
  780. package/dist/builtin-extensions/pi-subagents/src/runs/shared/structured-output.d.ts +22 -0
  781. package/dist/builtin-extensions/pi-subagents/src/runs/shared/structured-output.d.ts.map +1 -0
  782. package/dist/builtin-extensions/pi-subagents/src/runs/shared/structured-output.js +67 -0
  783. package/dist/builtin-extensions/pi-subagents/src/runs/shared/structured-output.js.map +1 -0
  784. package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-control.d.ts +35 -0
  785. package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-control.d.ts.map +1 -0
  786. package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-control.js +187 -0
  787. package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-control.js.map +1 -0
  788. package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.d.ts +22 -0
  789. package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.d.ts.map +1 -0
  790. package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.js +438 -0
  791. package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.js.map +1 -0
  792. package/dist/builtin-extensions/pi-subagents/src/runs/shared/task-intent.d.ts +35 -0
  793. package/dist/builtin-extensions/pi-subagents/src/runs/shared/task-intent.d.ts.map +1 -0
  794. package/dist/builtin-extensions/pi-subagents/src/runs/shared/task-intent.js +157 -0
  795. package/dist/builtin-extensions/pi-subagents/src/runs/shared/task-intent.js.map +1 -0
  796. package/dist/builtin-extensions/pi-subagents/src/runs/shared/tool-availability.d.ts +13 -0
  797. package/dist/builtin-extensions/pi-subagents/src/runs/shared/tool-availability.d.ts.map +1 -0
  798. package/dist/builtin-extensions/pi-subagents/src/runs/shared/tool-availability.js +51 -0
  799. package/dist/builtin-extensions/pi-subagents/src/runs/shared/tool-availability.js.map +1 -0
  800. package/dist/builtin-extensions/pi-subagents/src/runs/shared/tool-budget.d.ts +16 -0
  801. package/dist/builtin-extensions/pi-subagents/src/runs/shared/tool-budget.d.ts.map +1 -0
  802. package/dist/builtin-extensions/pi-subagents/src/runs/shared/tool-budget.js +74 -0
  803. package/dist/builtin-extensions/pi-subagents/src/runs/shared/tool-budget.js.map +1 -0
  804. package/dist/builtin-extensions/pi-subagents/src/runs/shared/turn-budget.d.ts +14 -0
  805. package/dist/builtin-extensions/pi-subagents/src/runs/shared/turn-budget.d.ts.map +1 -0
  806. package/dist/builtin-extensions/pi-subagents/src/runs/shared/turn-budget.js +66 -0
  807. package/dist/builtin-extensions/pi-subagents/src/runs/shared/turn-budget.js.map +1 -0
  808. package/dist/builtin-extensions/pi-subagents/src/runs/shared/workflow-graph.d.ts +30 -0
  809. package/dist/builtin-extensions/pi-subagents/src/runs/shared/workflow-graph.d.ts.map +1 -0
  810. package/dist/builtin-extensions/pi-subagents/src/runs/shared/workflow-graph.js +200 -0
  811. package/dist/builtin-extensions/pi-subagents/src/runs/shared/workflow-graph.js.map +1 -0
  812. package/dist/builtin-extensions/pi-subagents/src/runs/shared/worktree.d.ts +49 -0
  813. package/dist/builtin-extensions/pi-subagents/src/runs/shared/worktree.d.ts.map +1 -0
  814. package/dist/builtin-extensions/pi-subagents/src/runs/shared/worktree.js +473 -0
  815. package/dist/builtin-extensions/pi-subagents/src/runs/shared/worktree.js.map +1 -0
  816. package/dist/builtin-extensions/pi-subagents/src/shared/artifacts.d.ts +13 -0
  817. package/dist/builtin-extensions/pi-subagents/src/shared/artifacts.d.ts.map +1 -0
  818. package/dist/builtin-extensions/pi-subagents/src/shared/artifacts.js +104 -0
  819. package/dist/builtin-extensions/pi-subagents/src/shared/artifacts.js.map +1 -0
  820. package/dist/builtin-extensions/pi-subagents/src/shared/atomic-json.d.ts +17 -0
  821. package/dist/builtin-extensions/pi-subagents/src/shared/atomic-json.d.ts.map +1 -0
  822. package/dist/builtin-extensions/pi-subagents/src/shared/atomic-json.js +68 -0
  823. package/dist/builtin-extensions/pi-subagents/src/shared/atomic-json.js.map +1 -0
  824. package/dist/builtin-extensions/pi-subagents/src/shared/child-spec.d.ts +70 -0
  825. package/dist/builtin-extensions/pi-subagents/src/shared/child-spec.d.ts.map +1 -0
  826. package/dist/builtin-extensions/pi-subagents/src/shared/child-spec.js +153 -0
  827. package/dist/builtin-extensions/pi-subagents/src/shared/child-spec.js.map +1 -0
  828. package/dist/builtin-extensions/pi-subagents/src/shared/child-transcript.d.ts +36 -0
  829. package/dist/builtin-extensions/pi-subagents/src/shared/child-transcript.d.ts.map +1 -0
  830. package/dist/builtin-extensions/pi-subagents/src/shared/child-transcript.js +173 -0
  831. package/dist/builtin-extensions/pi-subagents/src/shared/child-transcript.js.map +1 -0
  832. package/dist/builtin-extensions/pi-subagents/src/shared/file-coalescer.d.ts +11 -0
  833. package/dist/builtin-extensions/pi-subagents/src/shared/file-coalescer.d.ts.map +1 -0
  834. package/dist/builtin-extensions/pi-subagents/src/shared/file-coalescer.js +26 -0
  835. package/dist/builtin-extensions/pi-subagents/src/shared/file-coalescer.js.map +1 -0
  836. package/dist/builtin-extensions/pi-subagents/src/shared/fork-context.d.ts +44 -0
  837. package/dist/builtin-extensions/pi-subagents/src/shared/fork-context.d.ts.map +1 -0
  838. package/dist/builtin-extensions/pi-subagents/src/shared/fork-context.js +158 -0
  839. package/dist/builtin-extensions/pi-subagents/src/shared/fork-context.js.map +1 -0
  840. package/dist/builtin-extensions/pi-subagents/src/shared/formatters.d.ts +34 -0
  841. package/dist/builtin-extensions/pi-subagents/src/shared/formatters.d.ts.map +1 -0
  842. package/dist/builtin-extensions/pi-subagents/src/shared/formatters.js +128 -0
  843. package/dist/builtin-extensions/pi-subagents/src/shared/formatters.js.map +1 -0
  844. package/dist/builtin-extensions/pi-subagents/src/shared/jsonl-writer.d.ts +20 -0
  845. package/dist/builtin-extensions/pi-subagents/src/shared/jsonl-writer.d.ts.map +1 -0
  846. package/dist/builtin-extensions/pi-subagents/src/shared/jsonl-writer.js +59 -0
  847. package/dist/builtin-extensions/pi-subagents/src/shared/jsonl-writer.js.map +1 -0
  848. package/dist/builtin-extensions/pi-subagents/src/shared/lunr-child-context.d.ts +21 -0
  849. package/dist/builtin-extensions/pi-subagents/src/shared/lunr-child-context.d.ts.map +1 -0
  850. package/dist/builtin-extensions/pi-subagents/src/shared/lunr-child-context.js +22 -0
  851. package/dist/builtin-extensions/pi-subagents/src/shared/lunr-child-context.js.map +1 -0
  852. package/dist/builtin-extensions/pi-subagents/src/shared/model-info.d.ts +31 -0
  853. package/dist/builtin-extensions/pi-subagents/src/shared/model-info.d.ts.map +1 -0
  854. package/dist/builtin-extensions/pi-subagents/src/shared/model-info.js +68 -0
  855. package/dist/builtin-extensions/pi-subagents/src/shared/model-info.js.map +1 -0
  856. package/dist/builtin-extensions/pi-subagents/src/shared/post-exit-stdio-guard.d.ts +17 -0
  857. package/dist/builtin-extensions/pi-subagents/src/shared/post-exit-stdio-guard.d.ts.map +1 -0
  858. package/dist/builtin-extensions/pi-subagents/src/shared/post-exit-stdio-guard.js +72 -0
  859. package/dist/builtin-extensions/pi-subagents/src/shared/post-exit-stdio-guard.js.map +1 -0
  860. package/dist/builtin-extensions/pi-subagents/src/shared/session-identity.d.ts +7 -0
  861. package/dist/builtin-extensions/pi-subagents/src/shared/session-identity.d.ts.map +1 -0
  862. package/dist/builtin-extensions/pi-subagents/src/shared/session-identity.js +7 -0
  863. package/dist/builtin-extensions/pi-subagents/src/shared/session-identity.js.map +1 -0
  864. package/dist/builtin-extensions/pi-subagents/src/shared/session-tokens.d.ts +3 -0
  865. package/dist/builtin-extensions/pi-subagents/src/shared/session-tokens.d.ts.map +1 -0
  866. package/dist/builtin-extensions/pi-subagents/src/shared/session-tokens.js +49 -0
  867. package/dist/builtin-extensions/pi-subagents/src/shared/session-tokens.js.map +1 -0
  868. package/dist/builtin-extensions/pi-subagents/src/shared/settings.d.ts +141 -0
  869. package/dist/builtin-extensions/pi-subagents/src/shared/settings.d.ts.map +1 -0
  870. package/dist/builtin-extensions/pi-subagents/src/shared/settings.js +254 -0
  871. package/dist/builtin-extensions/pi-subagents/src/shared/settings.js.map +1 -0
  872. package/dist/builtin-extensions/pi-subagents/src/shared/status-format.d.ts +10 -0
  873. package/dist/builtin-extensions/pi-subagents/src/shared/status-format.d.ts.map +1 -0
  874. package/dist/builtin-extensions/pi-subagents/src/shared/status-format.js +61 -0
  875. package/dist/builtin-extensions/pi-subagents/src/shared/status-format.js.map +1 -0
  876. package/dist/builtin-extensions/pi-subagents/src/shared/types.d.ts +1166 -0
  877. package/dist/builtin-extensions/pi-subagents/src/shared/types.d.ts.map +1 -0
  878. package/dist/builtin-extensions/pi-subagents/src/shared/types.js +229 -0
  879. package/dist/builtin-extensions/pi-subagents/src/shared/types.js.map +1 -0
  880. package/dist/builtin-extensions/pi-subagents/src/shared/utils.d.ts +52 -0
  881. package/dist/builtin-extensions/pi-subagents/src/shared/utils.d.ts.map +1 -0
  882. package/dist/builtin-extensions/pi-subagents/src/shared/utils.js +562 -0
  883. package/dist/builtin-extensions/pi-subagents/src/shared/utils.js.map +1 -0
  884. package/dist/builtin-extensions/pi-subagents/src/slash/delegation-adapters.d.ts +149 -0
  885. package/dist/builtin-extensions/pi-subagents/src/slash/delegation-adapters.d.ts.map +1 -0
  886. package/dist/builtin-extensions/pi-subagents/src/slash/delegation-adapters.js +321 -0
  887. package/dist/builtin-extensions/pi-subagents/src/slash/delegation-adapters.js.map +1 -0
  888. package/dist/builtin-extensions/pi-subagents/src/slash/delegation-request.d.ts +11 -0
  889. package/dist/builtin-extensions/pi-subagents/src/slash/delegation-request.d.ts.map +1 -0
  890. package/dist/builtin-extensions/pi-subagents/src/slash/delegation-request.js +102 -0
  891. package/dist/builtin-extensions/pi-subagents/src/slash/delegation-request.js.map +1 -0
  892. package/dist/builtin-extensions/pi-subagents/src/slash/prompt-template-bridge.d.ts +25 -0
  893. package/dist/builtin-extensions/pi-subagents/src/slash/prompt-template-bridge.d.ts.map +1 -0
  894. package/dist/builtin-extensions/pi-subagents/src/slash/prompt-template-bridge.js +200 -0
  895. package/dist/builtin-extensions/pi-subagents/src/slash/prompt-template-bridge.js.map +1 -0
  896. package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.d.ts +23 -0
  897. package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.d.ts.map +1 -0
  898. package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.js +294 -0
  899. package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.js.map +1 -0
  900. package/dist/builtin-extensions/pi-subagents/src/slash/slash-bridge.d.ts +31 -0
  901. package/dist/builtin-extensions/pi-subagents/src/slash/slash-bridge.d.ts.map +1 -0
  902. package/dist/builtin-extensions/pi-subagents/src/slash/slash-bridge.js +117 -0
  903. package/dist/builtin-extensions/pi-subagents/src/slash/slash-bridge.js.map +1 -0
  904. package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.d.ts +52 -0
  905. package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.d.ts.map +1 -0
  906. package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.js +1097 -0
  907. package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.js.map +1 -0
  908. package/dist/builtin-extensions/pi-subagents/src/slash/slash-live-state.d.ts +22 -0
  909. package/dist/builtin-extensions/pi-subagents/src/slash/slash-live-state.d.ts.map +1 -0
  910. package/dist/builtin-extensions/pi-subagents/src/slash/slash-live-state.js +246 -0
  911. package/dist/builtin-extensions/pi-subagents/src/slash/slash-live-state.js.map +1 -0
  912. package/dist/builtin-extensions/pi-subagents/src/tui/fleet.d.ts +78 -0
  913. package/dist/builtin-extensions/pi-subagents/src/tui/fleet.d.ts.map +1 -0
  914. package/dist/builtin-extensions/pi-subagents/src/tui/fleet.js +401 -0
  915. package/dist/builtin-extensions/pi-subagents/src/tui/fleet.js.map +1 -0
  916. package/dist/builtin-extensions/pi-subagents/src/tui/render-helpers.d.ts +13 -0
  917. package/dist/builtin-extensions/pi-subagents/src/tui/render-helpers.d.ts.map +1 -0
  918. package/dist/builtin-extensions/pi-subagents/src/tui/render-helpers.js +74 -0
  919. package/dist/builtin-extensions/pi-subagents/src/tui/render-helpers.js.map +1 -0
  920. package/dist/builtin-extensions/pi-subagents/src/tui/render.d.ts +45 -0
  921. package/dist/builtin-extensions/pi-subagents/src/tui/render.d.ts.map +1 -0
  922. package/dist/builtin-extensions/pi-subagents/src/tui/render.js +1715 -0
  923. package/dist/builtin-extensions/pi-subagents/src/tui/render.js.map +1 -0
  924. package/dist/builtin-extensions/pi-subagents/src/watchdog/change-signature.d.ts +8 -0
  925. package/dist/builtin-extensions/pi-subagents/src/watchdog/change-signature.d.ts.map +1 -0
  926. package/dist/builtin-extensions/pi-subagents/src/watchdog/change-signature.js +123 -0
  927. package/dist/builtin-extensions/pi-subagents/src/watchdog/change-signature.js.map +1 -0
  928. package/dist/builtin-extensions/pi-subagents/src/watchdog/child-status.d.ts +58 -0
  929. package/dist/builtin-extensions/pi-subagents/src/watchdog/child-status.d.ts.map +1 -0
  930. package/dist/builtin-extensions/pi-subagents/src/watchdog/child-status.js +160 -0
  931. package/dist/builtin-extensions/pi-subagents/src/watchdog/child-status.js.map +1 -0
  932. package/dist/builtin-extensions/pi-subagents/src/watchdog/emission-guard.d.ts +34 -0
  933. package/dist/builtin-extensions/pi-subagents/src/watchdog/emission-guard.d.ts.map +1 -0
  934. package/dist/builtin-extensions/pi-subagents/src/watchdog/emission-guard.js +96 -0
  935. package/dist/builtin-extensions/pi-subagents/src/watchdog/emission-guard.js.map +1 -0
  936. package/dist/builtin-extensions/pi-subagents/src/watchdog/lsp-diagnostics.d.ts +18 -0
  937. package/dist/builtin-extensions/pi-subagents/src/watchdog/lsp-diagnostics.d.ts.map +1 -0
  938. package/dist/builtin-extensions/pi-subagents/src/watchdog/lsp-diagnostics.js +485 -0
  939. package/dist/builtin-extensions/pi-subagents/src/watchdog/lsp-diagnostics.js.map +1 -0
  940. package/dist/builtin-extensions/pi-subagents/src/watchdog/model-selection.d.ts +21 -0
  941. package/dist/builtin-extensions/pi-subagents/src/watchdog/model-selection.d.ts.map +1 -0
  942. package/dist/builtin-extensions/pi-subagents/src/watchdog/model-selection.js +151 -0
  943. package/dist/builtin-extensions/pi-subagents/src/watchdog/model-selection.js.map +1 -0
  944. package/dist/builtin-extensions/pi-subagents/src/watchdog/register-child.d.ts +4 -0
  945. package/dist/builtin-extensions/pi-subagents/src/watchdog/register-child.d.ts.map +1 -0
  946. package/dist/builtin-extensions/pi-subagents/src/watchdog/register-child.js +111 -0
  947. package/dist/builtin-extensions/pi-subagents/src/watchdog/register-child.js.map +1 -0
  948. package/dist/builtin-extensions/pi-subagents/src/watchdog/register-main.d.ts +10 -0
  949. package/dist/builtin-extensions/pi-subagents/src/watchdog/register-main.d.ts.map +1 -0
  950. package/dist/builtin-extensions/pi-subagents/src/watchdog/register-main.js +407 -0
  951. package/dist/builtin-extensions/pi-subagents/src/watchdog/register-main.js.map +1 -0
  952. package/dist/builtin-extensions/pi-subagents/src/watchdog/render.d.ts +12 -0
  953. package/dist/builtin-extensions/pi-subagents/src/watchdog/render.d.ts.map +1 -0
  954. package/dist/builtin-extensions/pi-subagents/src/watchdog/render.js +55 -0
  955. package/dist/builtin-extensions/pi-subagents/src/watchdog/render.js.map +1 -0
  956. package/dist/builtin-extensions/pi-subagents/src/watchdog/review.d.ts +29 -0
  957. package/dist/builtin-extensions/pi-subagents/src/watchdog/review.d.ts.map +1 -0
  958. package/dist/builtin-extensions/pi-subagents/src/watchdog/review.js +245 -0
  959. package/dist/builtin-extensions/pi-subagents/src/watchdog/review.js.map +1 -0
  960. package/dist/builtin-extensions/pi-subagents/src/watchdog/runtime.d.ts +142 -0
  961. package/dist/builtin-extensions/pi-subagents/src/watchdog/runtime.d.ts.map +1 -0
  962. package/dist/builtin-extensions/pi-subagents/src/watchdog/runtime.js +648 -0
  963. package/dist/builtin-extensions/pi-subagents/src/watchdog/runtime.js.map +1 -0
  964. package/dist/builtin-extensions/pi-subagents/src/watchdog/settings.d.ts +30 -0
  965. package/dist/builtin-extensions/pi-subagents/src/watchdog/settings.d.ts.map +1 -0
  966. package/dist/builtin-extensions/pi-subagents/src/watchdog/settings.js +486 -0
  967. package/dist/builtin-extensions/pi-subagents/src/watchdog/settings.js.map +1 -0
  968. package/dist/builtin-extensions/pi-subagents/src/watchdog/tool-actions.d.ts +18 -0
  969. package/dist/builtin-extensions/pi-subagents/src/watchdog/tool-actions.d.ts.map +1 -0
  970. package/dist/builtin-extensions/pi-subagents/src/watchdog/tool-actions.js +150 -0
  971. package/dist/builtin-extensions/pi-subagents/src/watchdog/tool-actions.js.map +1 -0
  972. package/dist/builtin-extensions/pi-subagents/src/watchdog/turn-delta.d.ts +10 -0
  973. package/dist/builtin-extensions/pi-subagents/src/watchdog/turn-delta.d.ts.map +1 -0
  974. package/dist/builtin-extensions/pi-subagents/src/watchdog/turn-delta.js +159 -0
  975. package/dist/builtin-extensions/pi-subagents/src/watchdog/turn-delta.js.map +1 -0
  976. package/dist/builtin-extensions/pi-subagents/src/watchdog/types.d.ts +143 -0
  977. package/dist/builtin-extensions/pi-subagents/src/watchdog/types.d.ts.map +1 -0
  978. package/dist/builtin-extensions/pi-subagents/src/watchdog/types.js +31 -0
  979. package/dist/builtin-extensions/pi-subagents/src/watchdog/types.js.map +1 -0
  980. package/dist/builtin-extensions/pi-subagents/src/watchdog/warning-format.d.ts +8 -0
  981. package/dist/builtin-extensions/pi-subagents/src/watchdog/warning-format.d.ts.map +1 -0
  982. package/dist/builtin-extensions/pi-subagents/src/watchdog/warning-format.js +62 -0
  983. package/dist/builtin-extensions/pi-subagents/src/watchdog/warning-format.js.map +1 -0
  984. package/dist/builtin-extensions/pi-tps.d.ts +3 -0
  985. package/dist/builtin-extensions/pi-tps.d.ts.map +1 -0
  986. package/dist/builtin-extensions/pi-tps.js +89 -0
  987. package/dist/builtin-extensions/pi-tps.js.map +1 -0
  988. package/dist/builtin-extensions/pi-web-access/activity.d.ts +34 -0
  989. package/dist/builtin-extensions/pi-web-access/activity.d.ts.map +1 -0
  990. package/dist/builtin-extensions/pi-web-access/activity.js +68 -0
  991. package/dist/builtin-extensions/pi-web-access/activity.js.map +1 -0
  992. package/dist/builtin-extensions/pi-web-access/brave.d.ts +4 -0
  993. package/dist/builtin-extensions/pi-web-access/brave.d.ts.map +1 -0
  994. package/dist/builtin-extensions/pi-web-access/brave.js +185 -0
  995. package/dist/builtin-extensions/pi-web-access/brave.js.map +1 -0
  996. package/dist/builtin-extensions/pi-web-access/chrome-cookies.d.ts +9 -0
  997. package/dist/builtin-extensions/pi-web-access/chrome-cookies.d.ts.map +1 -0
  998. package/dist/builtin-extensions/pi-web-access/chrome-cookies.js +299 -0
  999. package/dist/builtin-extensions/pi-web-access/chrome-cookies.js.map +1 -0
  1000. package/dist/builtin-extensions/pi-web-access/curator-page.d.ts +13 -0
  1001. package/dist/builtin-extensions/pi-web-access/curator-page.d.ts.map +1 -0
  1002. package/dist/builtin-extensions/pi-web-access/curator-page.js +3382 -0
  1003. package/dist/builtin-extensions/pi-web-access/curator-page.js.map +1 -0
  1004. package/dist/builtin-extensions/pi-web-access/curator-server.d.ts +71 -0
  1005. package/dist/builtin-extensions/pi-web-access/curator-server.d.ts.map +1 -0
  1006. package/dist/builtin-extensions/pi-web-access/curator-server.js +604 -0
  1007. package/dist/builtin-extensions/pi-web-access/curator-server.js.map +1 -0
  1008. package/dist/builtin-extensions/pi-web-access/exa.d.ts +10 -0
  1009. package/dist/builtin-extensions/pi-web-access/exa.d.ts.map +1 -0
  1010. package/dist/builtin-extensions/pi-web-access/exa.js +391 -0
  1011. package/dist/builtin-extensions/pi-web-access/exa.js.map +1 -0
  1012. package/dist/builtin-extensions/pi-web-access/extract.d.ts +48 -0
  1013. package/dist/builtin-extensions/pi-web-access/extract.d.ts.map +1 -0
  1014. package/dist/builtin-extensions/pi-web-access/extract.js +619 -0
  1015. package/dist/builtin-extensions/pi-web-access/extract.js.map +1 -0
  1016. package/dist/builtin-extensions/pi-web-access/fetch-params.d.ts +21 -0
  1017. package/dist/builtin-extensions/pi-web-access/fetch-params.d.ts.map +1 -0
  1018. package/dist/builtin-extensions/pi-web-access/fetch-params.js +44 -0
  1019. package/dist/builtin-extensions/pi-web-access/fetch-params.js.map +1 -0
  1020. package/dist/builtin-extensions/pi-web-access/gemini-api.d.ts +18 -0
  1021. package/dist/builtin-extensions/pi-web-access/gemini-api.d.ts.map +1 -0
  1022. package/dist/builtin-extensions/pi-web-access/gemini-api.js +120 -0
  1023. package/dist/builtin-extensions/pi-web-access/gemini-api.js.map +1 -0
  1024. package/dist/builtin-extensions/pi-web-access/gemini-search.d.ts +14 -0
  1025. package/dist/builtin-extensions/pi-web-access/gemini-search.d.ts.map +1 -0
  1026. package/dist/builtin-extensions/pi-web-access/gemini-search.js +371 -0
  1027. package/dist/builtin-extensions/pi-web-access/gemini-search.js.map +1 -0
  1028. package/dist/builtin-extensions/pi-web-access/gemini-url-context.d.ts +4 -0
  1029. package/dist/builtin-extensions/pi-web-access/gemini-url-context.d.ts.map +1 -0
  1030. package/dist/builtin-extensions/pi-web-access/gemini-url-context.js +101 -0
  1031. package/dist/builtin-extensions/pi-web-access/gemini-url-context.js.map +1 -0
  1032. package/dist/builtin-extensions/pi-web-access/gemini-web-config.d.ts +4 -0
  1033. package/dist/builtin-extensions/pi-web-access/gemini-web-config.d.ts.map +1 -0
  1034. package/dist/builtin-extensions/pi-web-access/gemini-web-config.js +43 -0
  1035. package/dist/builtin-extensions/pi-web-access/gemini-web-config.js.map +1 -0
  1036. package/dist/builtin-extensions/pi-web-access/gemini-web.d.ts +12 -0
  1037. package/dist/builtin-extensions/pi-web-access/gemini-web.d.ts.map +1 -0
  1038. package/dist/builtin-extensions/pi-web-access/gemini-web.js +331 -0
  1039. package/dist/builtin-extensions/pi-web-access/gemini-web.js.map +1 -0
  1040. package/dist/builtin-extensions/pi-web-access/github-api.d.ts +7 -0
  1041. package/dist/builtin-extensions/pi-web-access/github-api.d.ts.map +1 -0
  1042. package/dist/builtin-extensions/pi-web-access/github-api.js +161 -0
  1043. package/dist/builtin-extensions/pi-web-access/github-api.js.map +1 -0
  1044. package/dist/builtin-extensions/pi-web-access/github-extract.d.ts +13 -0
  1045. package/dist/builtin-extensions/pi-web-access/github-extract.d.ts.map +1 -0
  1046. package/dist/builtin-extensions/pi-web-access/github-extract.js +558 -0
  1047. package/dist/builtin-extensions/pi-web-access/github-extract.js.map +1 -0
  1048. package/dist/builtin-extensions/pi-web-access/index.d.ts +3 -0
  1049. package/dist/builtin-extensions/pi-web-access/index.d.ts.map +1 -0
  1050. package/dist/builtin-extensions/pi-web-access/index.js +2165 -0
  1051. package/dist/builtin-extensions/pi-web-access/index.js.map +1 -0
  1052. package/dist/builtin-extensions/pi-web-access/openai-search.d.ts +13 -0
  1053. package/dist/builtin-extensions/pi-web-access/openai-search.d.ts.map +1 -0
  1054. package/dist/builtin-extensions/pi-web-access/openai-search.js +374 -0
  1055. package/dist/builtin-extensions/pi-web-access/openai-search.js.map +1 -0
  1056. package/dist/builtin-extensions/pi-web-access/parallel.d.ts +12 -0
  1057. package/dist/builtin-extensions/pi-web-access/parallel.d.ts.map +1 -0
  1058. package/dist/builtin-extensions/pi-web-access/parallel.js +316 -0
  1059. package/dist/builtin-extensions/pi-web-access/parallel.js.map +1 -0
  1060. package/dist/builtin-extensions/pi-web-access/pdf-extract.d.ts +26 -0
  1061. package/dist/builtin-extensions/pi-web-access/pdf-extract.d.ts.map +1 -0
  1062. package/dist/builtin-extensions/pi-web-access/pdf-extract.js +150 -0
  1063. package/dist/builtin-extensions/pi-web-access/pdf-extract.js.map +1 -0
  1064. package/dist/builtin-extensions/pi-web-access/perplexity.d.ts +20 -0
  1065. package/dist/builtin-extensions/pi-web-access/perplexity.d.ts.map +1 -0
  1066. package/dist/builtin-extensions/pi-web-access/perplexity.js +150 -0
  1067. package/dist/builtin-extensions/pi-web-access/perplexity.js.map +1 -0
  1068. package/dist/builtin-extensions/pi-web-access/render-search-chrome.d.ts +37 -0
  1069. package/dist/builtin-extensions/pi-web-access/render-search-chrome.d.ts.map +1 -0
  1070. package/dist/builtin-extensions/pi-web-access/render-search-chrome.js +107 -0
  1071. package/dist/builtin-extensions/pi-web-access/render-search-chrome.js.map +1 -0
  1072. package/dist/builtin-extensions/pi-web-access/render-search-error.d.ts +57 -0
  1073. package/dist/builtin-extensions/pi-web-access/render-search-error.d.ts.map +1 -0
  1074. package/dist/builtin-extensions/pi-web-access/render-search-error.js +131 -0
  1075. package/dist/builtin-extensions/pi-web-access/render-search-error.js.map +1 -0
  1076. package/dist/builtin-extensions/pi-web-access/rsc-extract.d.ts +12 -0
  1077. package/dist/builtin-extensions/pi-web-access/rsc-extract.d.ts.map +1 -0
  1078. package/dist/builtin-extensions/pi-web-access/rsc-extract.js +330 -0
  1079. package/dist/builtin-extensions/pi-web-access/rsc-extract.js.map +1 -0
  1080. package/dist/builtin-extensions/pi-web-access/ssrf-protection.d.ts +24 -0
  1081. package/dist/builtin-extensions/pi-web-access/ssrf-protection.d.ts.map +1 -0
  1082. package/dist/builtin-extensions/pi-web-access/ssrf-protection.js +255 -0
  1083. package/dist/builtin-extensions/pi-web-access/ssrf-protection.js.map +1 -0
  1084. package/dist/builtin-extensions/pi-web-access/storage.d.ts +25 -0
  1085. package/dist/builtin-extensions/pi-web-access/storage.d.ts.map +1 -0
  1086. package/dist/builtin-extensions/pi-web-access/storage.js +49 -0
  1087. package/dist/builtin-extensions/pi-web-access/storage.js.map +1 -0
  1088. package/dist/builtin-extensions/pi-web-access/summary-model-scope.d.ts +13 -0
  1089. package/dist/builtin-extensions/pi-web-access/summary-model-scope.d.ts.map +1 -0
  1090. package/dist/builtin-extensions/pi-web-access/summary-model-scope.js +86 -0
  1091. package/dist/builtin-extensions/pi-web-access/summary-model-scope.js.map +1 -0
  1092. package/dist/builtin-extensions/pi-web-access/summary-review.d.ts +21 -0
  1093. package/dist/builtin-extensions/pi-web-access/summary-review.d.ts.map +1 -0
  1094. package/dist/builtin-extensions/pi-web-access/summary-review.js +278 -0
  1095. package/dist/builtin-extensions/pi-web-access/summary-review.js.map +1 -0
  1096. package/dist/builtin-extensions/pi-web-access/tavily.d.ts +8 -0
  1097. package/dist/builtin-extensions/pi-web-access/tavily.d.ts.map +1 -0
  1098. package/dist/builtin-extensions/pi-web-access/tavily.js +184 -0
  1099. package/dist/builtin-extensions/pi-web-access/tavily.js.map +1 -0
  1100. package/dist/builtin-extensions/pi-web-access/utils.d.ts +12 -0
  1101. package/dist/builtin-extensions/pi-web-access/utils.d.ts.map +1 -0
  1102. package/dist/builtin-extensions/pi-web-access/utils.js +61 -0
  1103. package/dist/builtin-extensions/pi-web-access/utils.js.map +1 -0
  1104. package/dist/builtin-extensions/pi-web-access/video-extract.d.ts +14 -0
  1105. package/dist/builtin-extensions/pi-web-access/video-extract.d.ts.map +1 -0
  1106. package/dist/builtin-extensions/pi-web-access/video-extract.js +324 -0
  1107. package/dist/builtin-extensions/pi-web-access/video-extract.js.map +1 -0
  1108. package/dist/builtin-extensions/pi-web-access/youtube-extract.d.ts +27 -0
  1109. package/dist/builtin-extensions/pi-web-access/youtube-extract.d.ts.map +1 -0
  1110. package/dist/builtin-extensions/pi-web-access/youtube-extract.js +282 -0
  1111. package/dist/builtin-extensions/pi-web-access/youtube-extract.js.map +1 -0
  1112. package/dist/builtin-extensions/simple-pi-memory.d.ts +55 -0
  1113. package/dist/builtin-extensions/simple-pi-memory.d.ts.map +1 -0
  1114. package/dist/builtin-extensions/simple-pi-memory.js +263 -0
  1115. package/dist/builtin-extensions/simple-pi-memory.js.map +1 -0
  1116. package/dist/bun/cli.d.ts +3 -0
  1117. package/dist/bun/cli.d.ts.map +1 -0
  1118. package/dist/bun/cli.js +12 -0
  1119. package/dist/bun/cli.js.map +1 -0
  1120. package/dist/bun/register-bedrock.d.ts +2 -0
  1121. package/dist/bun/register-bedrock.d.ts.map +1 -0
  1122. package/dist/bun/register-bedrock.js +4 -0
  1123. package/dist/bun/register-bedrock.js.map +1 -0
  1124. package/dist/bun/restore-sandbox-env.d.ts +17 -0
  1125. package/dist/bun/restore-sandbox-env.d.ts.map +1 -0
  1126. package/dist/bun/restore-sandbox-env.js +36 -0
  1127. package/dist/bun/restore-sandbox-env.js.map +1 -0
  1128. package/dist/catalog/models.json +1 -0
  1129. package/dist/catalog/providers/amazon-bedrock.json +1 -0
  1130. package/dist/catalog/providers/ant-ling.json +1 -0
  1131. package/dist/catalog/providers/anthropic.json +1 -0
  1132. package/dist/catalog/providers/azure-openai-responses.json +1 -0
  1133. package/dist/catalog/providers/cerebras.json +1 -0
  1134. package/dist/catalog/providers/cloudflare-ai-gateway.json +1 -0
  1135. package/dist/catalog/providers/cloudflare-workers-ai.json +1 -0
  1136. package/dist/catalog/providers/deepseek.json +1 -0
  1137. package/dist/catalog/providers/fireworks.json +1 -0
  1138. package/dist/catalog/providers/github-copilot.json +1 -0
  1139. package/dist/catalog/providers/google-vertex.json +1 -0
  1140. package/dist/catalog/providers/google.json +1 -0
  1141. package/dist/catalog/providers/groq.json +1 -0
  1142. package/dist/catalog/providers/huggingface.json +1 -0
  1143. package/dist/catalog/providers/kimi-coding.json +1 -0
  1144. package/dist/catalog/providers/minimax-cn.json +1 -0
  1145. package/dist/catalog/providers/minimax.json +1 -0
  1146. package/dist/catalog/providers/mistral.json +1 -0
  1147. package/dist/catalog/providers/moonshotai-cn.json +1 -0
  1148. package/dist/catalog/providers/moonshotai.json +1 -0
  1149. package/dist/catalog/providers/nvidia.json +1 -0
  1150. package/dist/catalog/providers/openai-codex.json +1 -0
  1151. package/dist/catalog/providers/openai.json +1 -0
  1152. package/dist/catalog/providers/opencode-go.json +1 -0
  1153. package/dist/catalog/providers/opencode.json +1 -0
  1154. package/dist/catalog/providers/openrouter.json +1 -0
  1155. package/dist/catalog/providers/qwen-cloud-cn.json +1 -0
  1156. package/dist/catalog/providers/qwen-cloud.json +1 -0
  1157. package/dist/catalog/providers/qwen-token-plan-cn.json +1 -0
  1158. package/dist/catalog/providers/qwen-token-plan.json +1 -0
  1159. package/dist/catalog/providers/together.json +1 -0
  1160. package/dist/catalog/providers/vercel-ai-gateway.json +1 -0
  1161. package/dist/catalog/providers/xai.json +1 -0
  1162. package/dist/catalog/providers/xiaomi-token-plan-ams.json +1 -0
  1163. package/dist/catalog/providers/xiaomi-token-plan-cn.json +1 -0
  1164. package/dist/catalog/providers/xiaomi-token-plan-sgp.json +1 -0
  1165. package/dist/catalog/providers/xiaomi.json +1 -0
  1166. package/dist/catalog/providers/zai-coding-cn.json +1 -0
  1167. package/dist/catalog/providers/zai.json +1 -0
  1168. package/dist/catalog/providers.json +1 -0
  1169. package/dist/catalog/publication.json +6 -0
  1170. package/dist/cli/args.d.ts +57 -0
  1171. package/dist/cli/args.d.ts.map +1 -0
  1172. package/dist/cli/args.js +381 -0
  1173. package/dist/cli/args.js.map +1 -0
  1174. package/dist/cli/config-selector.d.ts +16 -0
  1175. package/dist/cli/config-selector.d.ts.map +1 -0
  1176. package/dist/cli/config-selector.js +31 -0
  1177. package/dist/cli/config-selector.js.map +1 -0
  1178. package/dist/cli/file-processor.d.ts +15 -0
  1179. package/dist/cli/file-processor.d.ts.map +1 -0
  1180. package/dist/cli/file-processor.js +70 -0
  1181. package/dist/cli/file-processor.js.map +1 -0
  1182. package/dist/cli/initial-message.d.ts +18 -0
  1183. package/dist/cli/initial-message.d.ts.map +1 -0
  1184. package/dist/cli/initial-message.js +22 -0
  1185. package/dist/cli/initial-message.js.map +1 -0
  1186. package/dist/cli/install-cli.d.ts +13 -0
  1187. package/dist/cli/install-cli.d.ts.map +1 -0
  1188. package/dist/cli/install-cli.js +352 -0
  1189. package/dist/cli/install-cli.js.map +1 -0
  1190. package/dist/cli/list-models.d.ts +9 -0
  1191. package/dist/cli/list-models.d.ts.map +1 -0
  1192. package/dist/cli/list-models.js +98 -0
  1193. package/dist/cli/list-models.js.map +1 -0
  1194. package/dist/cli/project-trust.d.ts +10 -0
  1195. package/dist/cli/project-trust.d.ts.map +1 -0
  1196. package/dist/cli/project-trust.js +48 -0
  1197. package/dist/cli/project-trust.js.map +1 -0
  1198. package/dist/cli/read-secret.d.ts +6 -0
  1199. package/dist/cli/read-secret.d.ts.map +1 -0
  1200. package/dist/cli/read-secret.js +62 -0
  1201. package/dist/cli/read-secret.js.map +1 -0
  1202. package/dist/cli/session-picker.d.ts +10 -0
  1203. package/dist/cli/session-picker.d.ts.map +1 -0
  1204. package/dist/cli/session-picker.js +36 -0
  1205. package/dist/cli/session-picker.js.map +1 -0
  1206. package/dist/cli/startup-ui.d.ts +20 -0
  1207. package/dist/cli/startup-ui.d.ts.map +1 -0
  1208. package/dist/cli/startup-ui.js +190 -0
  1209. package/dist/cli/startup-ui.js.map +1 -0
  1210. package/dist/cli/update-cli.d.ts +18 -0
  1211. package/dist/cli/update-cli.d.ts.map +1 -0
  1212. package/dist/cli/update-cli.js +87 -0
  1213. package/dist/cli/update-cli.js.map +1 -0
  1214. package/dist/cli.d.ts +3 -0
  1215. package/dist/cli.d.ts.map +1 -0
  1216. package/dist/cli.js +57 -0
  1217. package/dist/cli.js.map +1 -0
  1218. package/dist/config.d.ts +85 -0
  1219. package/dist/config.d.ts.map +1 -0
  1220. package/dist/config.js +212 -0
  1221. package/dist/config.js.map +1 -0
  1222. package/dist/core/agent-session-runtime.d.ts +119 -0
  1223. package/dist/core/agent-session-runtime.d.ts.map +1 -0
  1224. package/dist/core/agent-session-runtime.js +306 -0
  1225. package/dist/core/agent-session-runtime.js.map +1 -0
  1226. package/dist/core/agent-session-services.d.ts +85 -0
  1227. package/dist/core/agent-session-services.d.ts.map +1 -0
  1228. package/dist/core/agent-session-services.js +127 -0
  1229. package/dist/core/agent-session-services.js.map +1 -0
  1230. package/dist/core/agent-session.d.ts +670 -0
  1231. package/dist/core/agent-session.d.ts.map +1 -0
  1232. package/dist/core/agent-session.js +2933 -0
  1233. package/dist/core/agent-session.js.map +1 -0
  1234. package/dist/core/auth-guidance.d.ts +5 -0
  1235. package/dist/core/auth-guidance.d.ts.map +1 -0
  1236. package/dist/core/auth-guidance.js +21 -0
  1237. package/dist/core/auth-guidance.js.map +1 -0
  1238. package/dist/core/auth-storage.d.ts +56 -0
  1239. package/dist/core/auth-storage.d.ts.map +1 -0
  1240. package/dist/core/auth-storage.js +261 -0
  1241. package/dist/core/auth-storage.js.map +1 -0
  1242. package/dist/core/bash-executor.d.ts +32 -0
  1243. package/dist/core/bash-executor.d.ts.map +1 -0
  1244. package/dist/core/bash-executor.js +111 -0
  1245. package/dist/core/bash-executor.js.map +1 -0
  1246. package/dist/core/cache-stats.d.ts +49 -0
  1247. package/dist/core/cache-stats.d.ts.map +1 -0
  1248. package/dist/core/cache-stats.js +101 -0
  1249. package/dist/core/cache-stats.js.map +1 -0
  1250. package/dist/core/catalog-merge.d.ts +46 -0
  1251. package/dist/core/catalog-merge.d.ts.map +1 -0
  1252. package/dist/core/catalog-merge.js +138 -0
  1253. package/dist/core/catalog-merge.js.map +1 -0
  1254. package/dist/core/compaction/branch-summarization.d.ts +92 -0
  1255. package/dist/core/compaction/branch-summarization.d.ts.map +1 -0
  1256. package/dist/core/compaction/branch-summarization.js +249 -0
  1257. package/dist/core/compaction/branch-summarization.js.map +1 -0
  1258. package/dist/core/compaction/compaction.d.ts +121 -0
  1259. package/dist/core/compaction/compaction.d.ts.map +1 -0
  1260. package/dist/core/compaction/compaction.js +600 -0
  1261. package/dist/core/compaction/compaction.js.map +1 -0
  1262. package/dist/core/compaction/index.d.ts +7 -0
  1263. package/dist/core/compaction/index.d.ts.map +1 -0
  1264. package/dist/core/compaction/index.js +7 -0
  1265. package/dist/core/compaction/index.js.map +1 -0
  1266. package/dist/core/compaction/utils.d.ts +38 -0
  1267. package/dist/core/compaction/utils.d.ts.map +1 -0
  1268. package/dist/core/compaction/utils.js +153 -0
  1269. package/dist/core/compaction/utils.js.map +1 -0
  1270. package/dist/core/context-breakdown.d.ts +89 -0
  1271. package/dist/core/context-breakdown.d.ts.map +1 -0
  1272. package/dist/core/context-breakdown.js +175 -0
  1273. package/dist/core/context-breakdown.js.map +1 -0
  1274. package/dist/core/cron/fire-guard.d.ts +16 -0
  1275. package/dist/core/cron/fire-guard.d.ts.map +1 -0
  1276. package/dist/core/cron/fire-guard.js +24 -0
  1277. package/dist/core/cron/fire-guard.js.map +1 -0
  1278. package/dist/core/cron/jobs.d.ts +162 -0
  1279. package/dist/core/cron/jobs.d.ts.map +1 -0
  1280. package/dist/core/cron/jobs.js +545 -0
  1281. package/dist/core/cron/jobs.js.map +1 -0
  1282. package/dist/core/cron/origin-context.d.ts +22 -0
  1283. package/dist/core/cron/origin-context.d.ts.map +1 -0
  1284. package/dist/core/cron/origin-context.js +22 -0
  1285. package/dist/core/cron/origin-context.js.map +1 -0
  1286. package/dist/core/cron/scheduler.d.ts +51 -0
  1287. package/dist/core/cron/scheduler.d.ts.map +1 -0
  1288. package/dist/core/cron/scheduler.js +165 -0
  1289. package/dist/core/cron/scheduler.js.map +1 -0
  1290. package/dist/core/customize.d.ts +37 -0
  1291. package/dist/core/customize.d.ts.map +1 -0
  1292. package/dist/core/customize.js +72 -0
  1293. package/dist/core/customize.js.map +1 -0
  1294. package/dist/core/defaults.d.ts +3 -0
  1295. package/dist/core/defaults.d.ts.map +1 -0
  1296. package/dist/core/defaults.js +2 -0
  1297. package/dist/core/defaults.js.map +1 -0
  1298. package/dist/core/diagnostics.d.ts +15 -0
  1299. package/dist/core/diagnostics.d.ts.map +1 -0
  1300. package/dist/core/diagnostics.js +2 -0
  1301. package/dist/core/diagnostics.js.map +1 -0
  1302. package/dist/core/event-bus.d.ts +9 -0
  1303. package/dist/core/event-bus.d.ts.map +1 -0
  1304. package/dist/core/event-bus.js +25 -0
  1305. package/dist/core/event-bus.js.map +1 -0
  1306. package/dist/core/exec.d.ts +29 -0
  1307. package/dist/core/exec.d.ts.map +1 -0
  1308. package/dist/core/exec.js +75 -0
  1309. package/dist/core/exec.js.map +1 -0
  1310. package/dist/core/experimental.d.ts +2 -0
  1311. package/dist/core/experimental.d.ts.map +1 -0
  1312. package/dist/core/experimental.js +4 -0
  1313. package/dist/core/experimental.js.map +1 -0
  1314. package/dist/core/export-html/ansi-to-html.d.ts +22 -0
  1315. package/dist/core/export-html/ansi-to-html.d.ts.map +1 -0
  1316. package/dist/core/export-html/ansi-to-html.js +249 -0
  1317. package/dist/core/export-html/ansi-to-html.js.map +1 -0
  1318. package/dist/core/export-html/index.d.ts +37 -0
  1319. package/dist/core/export-html/index.d.ts.map +1 -0
  1320. package/dist/core/export-html/index.js +226 -0
  1321. package/dist/core/export-html/index.js.map +1 -0
  1322. package/dist/core/export-html/template.css +1066 -0
  1323. package/dist/core/export-html/template.html +55 -0
  1324. package/dist/core/export-html/template.js +1864 -0
  1325. package/dist/core/export-html/tool-renderer.d.ts +34 -0
  1326. package/dist/core/export-html/tool-renderer.d.ts.map +1 -0
  1327. package/dist/core/export-html/tool-renderer.js +108 -0
  1328. package/dist/core/export-html/tool-renderer.js.map +1 -0
  1329. package/dist/core/export-html/vendor/highlight.min.js +1213 -0
  1330. package/dist/core/export-html/vendor/marked.min.js +78 -0
  1331. package/dist/core/extensions/host-static.d.ts +2 -0
  1332. package/dist/core/extensions/host-static.d.ts.map +1 -0
  1333. package/dist/core/extensions/host-static.js +15 -0
  1334. package/dist/core/extensions/host-static.js.map +1 -0
  1335. package/dist/core/extensions/index.d.ts +12 -0
  1336. package/dist/core/extensions/index.d.ts.map +1 -0
  1337. package/dist/core/extensions/index.js +9 -0
  1338. package/dist/core/extensions/index.js.map +1 -0
  1339. package/dist/core/extensions/loader.d.ts +33 -0
  1340. package/dist/core/extensions/loader.d.ts.map +1 -0
  1341. package/dist/core/extensions/loader.js +588 -0
  1342. package/dist/core/extensions/loader.js.map +1 -0
  1343. package/dist/core/extensions/runner.d.ts +172 -0
  1344. package/dist/core/extensions/runner.d.ts.map +1 -0
  1345. package/dist/core/extensions/runner.js +935 -0
  1346. package/dist/core/extensions/runner.js.map +1 -0
  1347. package/dist/core/extensions/types.d.ts +1263 -0
  1348. package/dist/core/extensions/types.d.ts.map +1 -0
  1349. package/dist/core/extensions/types.js +45 -0
  1350. package/dist/core/extensions/types.js.map +1 -0
  1351. package/dist/core/extensions/wrapper.d.ts +20 -0
  1352. package/dist/core/extensions/wrapper.d.ts.map +1 -0
  1353. package/dist/core/extensions/wrapper.js +41 -0
  1354. package/dist/core/extensions/wrapper.js.map +1 -0
  1355. package/dist/core/footer-data-provider.d.ts +64 -0
  1356. package/dist/core/footer-data-provider.d.ts.map +1 -0
  1357. package/dist/core/footer-data-provider.js +373 -0
  1358. package/dist/core/footer-data-provider.js.map +1 -0
  1359. package/dist/core/grok-cli-auth.d.ts +42 -0
  1360. package/dist/core/grok-cli-auth.d.ts.map +1 -0
  1361. package/dist/core/grok-cli-auth.js +327 -0
  1362. package/dist/core/grok-cli-auth.js.map +1 -0
  1363. package/dist/core/http-dispatcher.d.ts +22 -0
  1364. package/dist/core/http-dispatcher.d.ts.map +1 -0
  1365. package/dist/core/http-dispatcher.js +91 -0
  1366. package/dist/core/http-dispatcher.js.map +1 -0
  1367. package/dist/core/index.d.ts +13 -0
  1368. package/dist/core/index.d.ts.map +1 -0
  1369. package/dist/core/index.js +13 -0
  1370. package/dist/core/index.js.map +1 -0
  1371. package/dist/core/injected-prompt.d.ts +20 -0
  1372. package/dist/core/injected-prompt.d.ts.map +1 -0
  1373. package/dist/core/injected-prompt.js +64 -0
  1374. package/dist/core/injected-prompt.js.map +1 -0
  1375. package/dist/core/install-features.d.ts +106 -0
  1376. package/dist/core/install-features.d.ts.map +1 -0
  1377. package/dist/core/install-features.js +392 -0
  1378. package/dist/core/install-features.js.map +1 -0
  1379. package/dist/core/install-layout.d.ts +18 -0
  1380. package/dist/core/install-layout.d.ts.map +1 -0
  1381. package/dist/core/install-layout.js +54 -0
  1382. package/dist/core/install-layout.js.map +1 -0
  1383. package/dist/core/keybindings.d.ts +373 -0
  1384. package/dist/core/keybindings.d.ts.map +1 -0
  1385. package/dist/core/keybindings.js +309 -0
  1386. package/dist/core/keybindings.js.map +1 -0
  1387. package/dist/core/live-catalog.d.ts +74 -0
  1388. package/dist/core/live-catalog.d.ts.map +1 -0
  1389. package/dist/core/live-catalog.js +351 -0
  1390. package/dist/core/live-catalog.js.map +1 -0
  1391. package/dist/core/memory-cap.d.ts +23 -0
  1392. package/dist/core/memory-cap.d.ts.map +1 -0
  1393. package/dist/core/memory-cap.js +32 -0
  1394. package/dist/core/memory-cap.js.map +1 -0
  1395. package/dist/core/messages.d.ts +77 -0
  1396. package/dist/core/messages.d.ts.map +1 -0
  1397. package/dist/core/messages.js +123 -0
  1398. package/dist/core/messages.js.map +1 -0
  1399. package/dist/core/model-config-writer.d.ts +24 -0
  1400. package/dist/core/model-config-writer.d.ts.map +1 -0
  1401. package/dist/core/model-config-writer.js +84 -0
  1402. package/dist/core/model-config-writer.js.map +1 -0
  1403. package/dist/core/model-config.d.ts +512 -0
  1404. package/dist/core/model-config.d.ts.map +1 -0
  1405. package/dist/core/model-config.js +243 -0
  1406. package/dist/core/model-config.js.map +1 -0
  1407. package/dist/core/model-registry.d.ts +39 -0
  1408. package/dist/core/model-registry.d.ts.map +1 -0
  1409. package/dist/core/model-registry.js +89 -0
  1410. package/dist/core/model-registry.js.map +1 -0
  1411. package/dist/core/model-resolver.d.ts +121 -0
  1412. package/dist/core/model-resolver.d.ts.map +1 -0
  1413. package/dist/core/model-resolver.js +536 -0
  1414. package/dist/core/model-resolver.js.map +1 -0
  1415. package/dist/core/model-runtime.d.ts +135 -0
  1416. package/dist/core/model-runtime.d.ts.map +1 -0
  1417. package/dist/core/model-runtime.js +696 -0
  1418. package/dist/core/model-runtime.js.map +1 -0
  1419. package/dist/core/model-tiers.d.ts +43 -0
  1420. package/dist/core/model-tiers.d.ts.map +1 -0
  1421. package/dist/core/model-tiers.js +78 -0
  1422. package/dist/core/model-tiers.js.map +1 -0
  1423. package/dist/core/models-store.d.ts +17 -0
  1424. package/dist/core/models-store.d.ts.map +1 -0
  1425. package/dist/core/models-store.js +57 -0
  1426. package/dist/core/models-store.js.map +1 -0
  1427. package/dist/core/official-catalog.d.ts +79 -0
  1428. package/dist/core/official-catalog.d.ts.map +1 -0
  1429. package/dist/core/official-catalog.js +404 -0
  1430. package/dist/core/official-catalog.js.map +1 -0
  1431. package/dist/core/output-guard.d.ts +7 -0
  1432. package/dist/core/output-guard.d.ts.map +1 -0
  1433. package/dist/core/output-guard.js +89 -0
  1434. package/dist/core/output-guard.js.map +1 -0
  1435. package/dist/core/package-manager.d.ts +201 -0
  1436. package/dist/core/package-manager.d.ts.map +1 -0
  1437. package/dist/core/package-manager.js +2035 -0
  1438. package/dist/core/package-manager.js.map +1 -0
  1439. package/dist/core/permission-mode-control.d.ts +27 -0
  1440. package/dist/core/permission-mode-control.d.ts.map +1 -0
  1441. package/dist/core/permission-mode-control.js +39 -0
  1442. package/dist/core/permission-mode-control.js.map +1 -0
  1443. package/dist/core/permission-mode.d.ts +19 -0
  1444. package/dist/core/permission-mode.d.ts.map +1 -0
  1445. package/dist/core/permission-mode.js +26 -0
  1446. package/dist/core/permission-mode.js.map +1 -0
  1447. package/dist/core/permissions.d.ts +110 -0
  1448. package/dist/core/permissions.d.ts.map +1 -0
  1449. package/dist/core/permissions.js +438 -0
  1450. package/dist/core/permissions.js.map +1 -0
  1451. package/dist/core/plan-mode.d.ts +39 -0
  1452. package/dist/core/plan-mode.d.ts.map +1 -0
  1453. package/dist/core/plan-mode.js +429 -0
  1454. package/dist/core/plan-mode.js.map +1 -0
  1455. package/dist/core/process-registry.d.ts +40 -0
  1456. package/dist/core/process-registry.d.ts.map +1 -0
  1457. package/dist/core/process-registry.js +190 -0
  1458. package/dist/core/process-registry.js.map +1 -0
  1459. package/dist/core/project-trust.d.ts +15 -0
  1460. package/dist/core/project-trust.d.ts.map +1 -0
  1461. package/dist/core/project-trust.js +59 -0
  1462. package/dist/core/project-trust.js.map +1 -0
  1463. package/dist/core/prompt-templates.d.ts +53 -0
  1464. package/dist/core/prompt-templates.d.ts.map +1 -0
  1465. package/dist/core/prompt-templates.js +236 -0
  1466. package/dist/core/prompt-templates.js.map +1 -0
  1467. package/dist/core/provider-attribution.d.ts +4 -0
  1468. package/dist/core/provider-attribution.d.ts.map +1 -0
  1469. package/dist/core/provider-attribution.js +31 -0
  1470. package/dist/core/provider-attribution.js.map +1 -0
  1471. package/dist/core/provider-composer.d.ts +55 -0
  1472. package/dist/core/provider-composer.d.ts.map +1 -0
  1473. package/dist/core/provider-composer.js +375 -0
  1474. package/dist/core/provider-composer.js.map +1 -0
  1475. package/dist/core/radius.d.ts +2 -0
  1476. package/dist/core/radius.d.ts.map +1 -0
  1477. package/dist/core/radius.js +2 -0
  1478. package/dist/core/radius.js.map +1 -0
  1479. package/dist/core/resolve-config-value.d.ts +30 -0
  1480. package/dist/core/resolve-config-value.d.ts.map +1 -0
  1481. package/dist/core/resolve-config-value.js +247 -0
  1482. package/dist/core/resolve-config-value.js.map +1 -0
  1483. package/dist/core/resource-loader.d.ts +211 -0
  1484. package/dist/core/resource-loader.d.ts.map +1 -0
  1485. package/dist/core/resource-loader.js +848 -0
  1486. package/dist/core/resource-loader.js.map +1 -0
  1487. package/dist/core/rollback.d.ts +80 -0
  1488. package/dist/core/rollback.d.ts.map +1 -0
  1489. package/dist/core/rollback.js +659 -0
  1490. package/dist/core/rollback.js.map +1 -0
  1491. package/dist/core/runtime-credentials.d.ts +15 -0
  1492. package/dist/core/runtime-credentials.d.ts.map +1 -0
  1493. package/dist/core/runtime-credentials.js +36 -0
  1494. package/dist/core/runtime-credentials.js.map +1 -0
  1495. package/dist/core/sdk.d.ts +106 -0
  1496. package/dist/core/sdk.d.ts.map +1 -0
  1497. package/dist/core/sdk.js +264 -0
  1498. package/dist/core/sdk.js.map +1 -0
  1499. package/dist/core/search-curator.d.ts +23 -0
  1500. package/dist/core/search-curator.d.ts.map +1 -0
  1501. package/dist/core/search-curator.js +34 -0
  1502. package/dist/core/search-curator.js.map +1 -0
  1503. package/dist/core/session-cwd.d.ts +19 -0
  1504. package/dist/core/session-cwd.d.ts.map +1 -0
  1505. package/dist/core/session-cwd.js +38 -0
  1506. package/dist/core/session-cwd.js.map +1 -0
  1507. package/dist/core/session-manager.d.ts +352 -0
  1508. package/dist/core/session-manager.d.ts.map +1 -0
  1509. package/dist/core/session-manager.js +1319 -0
  1510. package/dist/core/session-manager.js.map +1 -0
  1511. package/dist/core/session-retention.d.ts +17 -0
  1512. package/dist/core/session-retention.d.ts.map +1 -0
  1513. package/dist/core/session-retention.js +69 -0
  1514. package/dist/core/session-retention.js.map +1 -0
  1515. package/dist/core/settings-manager.d.ts +392 -0
  1516. package/dist/core/settings-manager.d.ts.map +1 -0
  1517. package/dist/core/settings-manager.js +1165 -0
  1518. package/dist/core/settings-manager.js.map +1 -0
  1519. package/dist/core/skills.d.ts +60 -0
  1520. package/dist/core/skills.d.ts.map +1 -0
  1521. package/dist/core/skills.js +387 -0
  1522. package/dist/core/skills.js.map +1 -0
  1523. package/dist/core/slash-commands.d.ts +15 -0
  1524. package/dist/core/slash-commands.d.ts.map +1 -0
  1525. package/dist/core/slash-commands.js +54 -0
  1526. package/dist/core/slash-commands.js.map +1 -0
  1527. package/dist/core/source-info.d.ts +18 -0
  1528. package/dist/core/source-info.d.ts.map +1 -0
  1529. package/dist/core/source-info.js +19 -0
  1530. package/dist/core/source-info.js.map +1 -0
  1531. package/dist/core/subagent-permission-inherit.d.ts +50 -0
  1532. package/dist/core/subagent-permission-inherit.d.ts.map +1 -0
  1533. package/dist/core/subagent-permission-inherit.js +67 -0
  1534. package/dist/core/subagent-permission-inherit.js.map +1 -0
  1535. package/dist/core/subscriptions.d.ts +64 -0
  1536. package/dist/core/subscriptions.d.ts.map +1 -0
  1537. package/dist/core/subscriptions.js +259 -0
  1538. package/dist/core/subscriptions.js.map +1 -0
  1539. package/dist/core/swarm.d.ts +54 -0
  1540. package/dist/core/swarm.d.ts.map +1 -0
  1541. package/dist/core/swarm.js +119 -0
  1542. package/dist/core/swarm.js.map +1 -0
  1543. package/dist/core/system-prompt.d.ts +30 -0
  1544. package/dist/core/system-prompt.d.ts.map +1 -0
  1545. package/dist/core/system-prompt.js +97 -0
  1546. package/dist/core/system-prompt.js.map +1 -0
  1547. package/dist/core/timings.d.ts +11 -0
  1548. package/dist/core/timings.d.ts.map +1 -0
  1549. package/dist/core/timings.js +46 -0
  1550. package/dist/core/timings.js.map +1 -0
  1551. package/dist/core/tools/bash.d.ts +69 -0
  1552. package/dist/core/tools/bash.d.ts.map +1 -0
  1553. package/dist/core/tools/bash.js +403 -0
  1554. package/dist/core/tools/bash.js.map +1 -0
  1555. package/dist/core/tools/edit-diff.d.ts +106 -0
  1556. package/dist/core/tools/edit-diff.d.ts.map +1 -0
  1557. package/dist/core/tools/edit-diff.js +424 -0
  1558. package/dist/core/tools/edit-diff.js.map +1 -0
  1559. package/dist/core/tools/edit.d.ts +51 -0
  1560. package/dist/core/tools/edit.d.ts.map +1 -0
  1561. package/dist/core/tools/edit.js +303 -0
  1562. package/dist/core/tools/edit.js.map +1 -0
  1563. package/dist/core/tools/file-mutation-queue.d.ts +6 -0
  1564. package/dist/core/tools/file-mutation-queue.d.ts.map +1 -0
  1565. package/dist/core/tools/file-mutation-queue.js +52 -0
  1566. package/dist/core/tools/file-mutation-queue.js.map +1 -0
  1567. package/dist/core/tools/find.d.ts +35 -0
  1568. package/dist/core/tools/find.d.ts.map +1 -0
  1569. package/dist/core/tools/find.js +325 -0
  1570. package/dist/core/tools/find.js.map +1 -0
  1571. package/dist/core/tools/grep.d.ts +37 -0
  1572. package/dist/core/tools/grep.d.ts.map +1 -0
  1573. package/dist/core/tools/grep.js +324 -0
  1574. package/dist/core/tools/grep.js.map +1 -0
  1575. package/dist/core/tools/index.d.ts +40 -0
  1576. package/dist/core/tools/index.d.ts.map +1 -0
  1577. package/dist/core/tools/index.js +112 -0
  1578. package/dist/core/tools/index.js.map +1 -0
  1579. package/dist/core/tools/ls.d.ts +37 -0
  1580. package/dist/core/tools/ls.d.ts.map +1 -0
  1581. package/dist/core/tools/ls.js +185 -0
  1582. package/dist/core/tools/ls.js.map +1 -0
  1583. package/dist/core/tools/output-accumulator.d.ts +52 -0
  1584. package/dist/core/tools/output-accumulator.d.ts.map +1 -0
  1585. package/dist/core/tools/output-accumulator.js +184 -0
  1586. package/dist/core/tools/output-accumulator.js.map +1 -0
  1587. package/dist/core/tools/path-utils.d.ts +10 -0
  1588. package/dist/core/tools/path-utils.d.ts.map +1 -0
  1589. package/dist/core/tools/path-utils.js +99 -0
  1590. package/dist/core/tools/path-utils.js.map +1 -0
  1591. package/dist/core/tools/read.d.ts +35 -0
  1592. package/dist/core/tools/read.d.ts.map +1 -0
  1593. package/dist/core/tools/read.js +289 -0
  1594. package/dist/core/tools/read.js.map +1 -0
  1595. package/dist/core/tools/render-utils.d.ts +74 -0
  1596. package/dist/core/tools/render-utils.d.ts.map +1 -0
  1597. package/dist/core/tools/render-utils.js +150 -0
  1598. package/dist/core/tools/render-utils.js.map +1 -0
  1599. package/dist/core/tools/tool-definition-wrapper.d.ts +14 -0
  1600. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -0
  1601. package/dist/core/tools/tool-definition-wrapper.js +34 -0
  1602. package/dist/core/tools/tool-definition-wrapper.js.map +1 -0
  1603. package/dist/core/tools/truncate.d.ts +70 -0
  1604. package/dist/core/tools/truncate.d.ts.map +1 -0
  1605. package/dist/core/tools/truncate.js +215 -0
  1606. package/dist/core/tools/truncate.js.map +1 -0
  1607. package/dist/core/tools/write.d.ts +26 -0
  1608. package/dist/core/tools/write.d.ts.map +1 -0
  1609. package/dist/core/tools/write.js +219 -0
  1610. package/dist/core/tools/write.js.map +1 -0
  1611. package/dist/core/trust-manager.d.ts +36 -0
  1612. package/dist/core/trust-manager.d.ts.map +1 -0
  1613. package/dist/core/trust-manager.js +202 -0
  1614. package/dist/core/trust-manager.js.map +1 -0
  1615. package/dist/core/update-check.d.ts +35 -0
  1616. package/dist/core/update-check.d.ts.map +1 -0
  1617. package/dist/core/update-check.js +117 -0
  1618. package/dist/core/update-check.js.map +1 -0
  1619. package/dist/core/usage-adapters/kimi-coding.d.ts +11 -0
  1620. package/dist/core/usage-adapters/kimi-coding.d.ts.map +1 -0
  1621. package/dist/core/usage-adapters/kimi-coding.js +78 -0
  1622. package/dist/core/usage-adapters/kimi-coding.js.map +1 -0
  1623. package/dist/core/usage-adapters/openai-codex.d.ts +4 -0
  1624. package/dist/core/usage-adapters/openai-codex.d.ts.map +1 -0
  1625. package/dist/core/usage-adapters/openai-codex.js +185 -0
  1626. package/dist/core/usage-adapters/openai-codex.js.map +1 -0
  1627. package/dist/core/usage-adapters/shared.d.ts +20 -0
  1628. package/dist/core/usage-adapters/shared.d.ts.map +1 -0
  1629. package/dist/core/usage-adapters/shared.js +75 -0
  1630. package/dist/core/usage-adapters/shared.js.map +1 -0
  1631. package/dist/core/usage-adapters/xai.d.ts +21 -0
  1632. package/dist/core/usage-adapters/xai.d.ts.map +1 -0
  1633. package/dist/core/usage-adapters/xai.js +81 -0
  1634. package/dist/core/usage-adapters/xai.js.map +1 -0
  1635. package/dist/core/usage-adapters/zai.d.ts +14 -0
  1636. package/dist/core/usage-adapters/zai.d.ts.map +1 -0
  1637. package/dist/core/usage-adapters/zai.js +67 -0
  1638. package/dist/core/usage-adapters/zai.js.map +1 -0
  1639. package/dist/core/usage-history.d.ts +63 -0
  1640. package/dist/core/usage-history.d.ts.map +1 -0
  1641. package/dist/core/usage-history.js +239 -0
  1642. package/dist/core/usage-history.js.map +1 -0
  1643. package/dist/core/usage-limit.d.ts +17 -0
  1644. package/dist/core/usage-limit.d.ts.map +1 -0
  1645. package/dist/core/usage-limit.js +79 -0
  1646. package/dist/core/usage-limit.js.map +1 -0
  1647. package/dist/core/usage-service.d.ts +75 -0
  1648. package/dist/core/usage-service.d.ts.map +1 -0
  1649. package/dist/core/usage-service.js +180 -0
  1650. package/dist/core/usage-service.js.map +1 -0
  1651. package/dist/core/user-models.d.ts +50 -0
  1652. package/dist/core/user-models.d.ts.map +1 -0
  1653. package/dist/core/user-models.js +192 -0
  1654. package/dist/core/user-models.js.map +1 -0
  1655. package/dist/dev-cli.d.ts +3 -0
  1656. package/dist/dev-cli.d.ts.map +1 -0
  1657. package/dist/dev-cli.js +5 -0
  1658. package/dist/dev-cli.js.map +1 -0
  1659. package/dist/gateway/adapters/discord.d.ts +251 -0
  1660. package/dist/gateway/adapters/discord.d.ts.map +1 -0
  1661. package/dist/gateway/adapters/discord.js +693 -0
  1662. package/dist/gateway/adapters/discord.js.map +1 -0
  1663. package/dist/gateway/adapters/telegram.d.ts +187 -0
  1664. package/dist/gateway/adapters/telegram.d.ts.map +1 -0
  1665. package/dist/gateway/adapters/telegram.js +581 -0
  1666. package/dist/gateway/adapters/telegram.js.map +1 -0
  1667. package/dist/gateway/agent-bridge.d.ts +144 -0
  1668. package/dist/gateway/agent-bridge.d.ts.map +1 -0
  1669. package/dist/gateway/agent-bridge.js +477 -0
  1670. package/dist/gateway/agent-bridge.js.map +1 -0
  1671. package/dist/gateway/approval.d.ts +34 -0
  1672. package/dist/gateway/approval.d.ts.map +1 -0
  1673. package/dist/gateway/approval.js +152 -0
  1674. package/dist/gateway/approval.js.map +1 -0
  1675. package/dist/gateway/authz.d.ts +21 -0
  1676. package/dist/gateway/authz.d.ts.map +1 -0
  1677. package/dist/gateway/authz.js +61 -0
  1678. package/dist/gateway/authz.js.map +1 -0
  1679. package/dist/gateway/buttons.d.ts +58 -0
  1680. package/dist/gateway/buttons.d.ts.map +1 -0
  1681. package/dist/gateway/buttons.js +269 -0
  1682. package/dist/gateway/buttons.js.map +1 -0
  1683. package/dist/gateway/command.d.ts +8 -0
  1684. package/dist/gateway/command.d.ts.map +1 -0
  1685. package/dist/gateway/command.js +17 -0
  1686. package/dist/gateway/command.js.map +1 -0
  1687. package/dist/gateway/commands.d.ts +43 -0
  1688. package/dist/gateway/commands.d.ts.map +1 -0
  1689. package/dist/gateway/commands.js +644 -0
  1690. package/dist/gateway/commands.js.map +1 -0
  1691. package/dist/gateway/config.d.ts +53 -0
  1692. package/dist/gateway/config.d.ts.map +1 -0
  1693. package/dist/gateway/config.js +136 -0
  1694. package/dist/gateway/config.js.map +1 -0
  1695. package/dist/gateway/cron.d.ts +72 -0
  1696. package/dist/gateway/cron.d.ts.map +1 -0
  1697. package/dist/gateway/cron.js +331 -0
  1698. package/dist/gateway/cron.js.map +1 -0
  1699. package/dist/gateway/index.d.ts +31 -0
  1700. package/dist/gateway/index.d.ts.map +1 -0
  1701. package/dist/gateway/index.js +233 -0
  1702. package/dist/gateway/index.js.map +1 -0
  1703. package/dist/gateway/pairing.d.ts +44 -0
  1704. package/dist/gateway/pairing.d.ts.map +1 -0
  1705. package/dist/gateway/pairing.js +171 -0
  1706. package/dist/gateway/pairing.js.map +1 -0
  1707. package/dist/gateway/router.d.ts +48 -0
  1708. package/dist/gateway/router.d.ts.map +1 -0
  1709. package/dist/gateway/router.js +215 -0
  1710. package/dist/gateway/router.js.map +1 -0
  1711. package/dist/gateway/session-keys.d.ts +18 -0
  1712. package/dist/gateway/session-keys.d.ts.map +1 -0
  1713. package/dist/gateway/session-keys.js +26 -0
  1714. package/dist/gateway/session-keys.js.map +1 -0
  1715. package/dist/gateway/store.d.ts +28 -0
  1716. package/dist/gateway/store.d.ts.map +1 -0
  1717. package/dist/gateway/store.js +93 -0
  1718. package/dist/gateway/store.js.map +1 -0
  1719. package/dist/gateway/stream.d.ts +55 -0
  1720. package/dist/gateway/stream.d.ts.map +1 -0
  1721. package/dist/gateway/stream.js +107 -0
  1722. package/dist/gateway/stream.js.map +1 -0
  1723. package/dist/gateway/text.d.ts +18 -0
  1724. package/dist/gateway/text.d.ts.map +1 -0
  1725. package/dist/gateway/text.js +136 -0
  1726. package/dist/gateway/text.js.map +1 -0
  1727. package/dist/gateway/types.d.ts +95 -0
  1728. package/dist/gateway/types.d.ts.map +1 -0
  1729. package/dist/gateway/types.js +9 -0
  1730. package/dist/gateway/types.js.map +1 -0
  1731. package/dist/index.d.ts +35 -0
  1732. package/dist/index.d.ts.map +1 -0
  1733. package/dist/index.js +47 -0
  1734. package/dist/index.js.map +1 -0
  1735. package/dist/main.d.ts +22 -0
  1736. package/dist/main.d.ts.map +1 -0
  1737. package/dist/main.js +861 -0
  1738. package/dist/main.js.map +1 -0
  1739. package/dist/migrations.d.ts +48 -0
  1740. package/dist/migrations.d.ts.map +1 -0
  1741. package/dist/migrations.js +375 -0
  1742. package/dist/migrations.js.map +1 -0
  1743. package/dist/modes/index.d.ts +9 -0
  1744. package/dist/modes/index.d.ts.map +1 -0
  1745. package/dist/modes/index.js +8 -0
  1746. package/dist/modes/index.js.map +1 -0
  1747. package/dist/modes/interactive/assets/clankolas.png +0 -0
  1748. package/dist/modes/interactive/components/armin.d.ts +34 -0
  1749. package/dist/modes/interactive/components/armin.d.ts.map +1 -0
  1750. package/dist/modes/interactive/components/armin.js +333 -0
  1751. package/dist/modes/interactive/components/armin.js.map +1 -0
  1752. package/dist/modes/interactive/components/assistant-message.d.ts +41 -0
  1753. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -0
  1754. package/dist/modes/interactive/components/assistant-message.js +333 -0
  1755. package/dist/modes/interactive/components/assistant-message.js.map +1 -0
  1756. package/dist/modes/interactive/components/bash-execution.d.ts +32 -0
  1757. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -0
  1758. package/dist/modes/interactive/components/bash-execution.js +171 -0
  1759. package/dist/modes/interactive/components/bash-execution.js.map +1 -0
  1760. package/dist/modes/interactive/components/boot-ascii.d.ts +6 -0
  1761. package/dist/modes/interactive/components/boot-ascii.d.ts.map +1 -0
  1762. package/dist/modes/interactive/components/boot-ascii.js +6 -0
  1763. package/dist/modes/interactive/components/boot-ascii.js.map +1 -0
  1764. package/dist/modes/interactive/components/boot-screen.d.ts +22 -0
  1765. package/dist/modes/interactive/components/boot-screen.d.ts.map +1 -0
  1766. package/dist/modes/interactive/components/boot-screen.js +53 -0
  1767. package/dist/modes/interactive/components/boot-screen.js.map +1 -0
  1768. package/dist/modes/interactive/components/bordered-loader.d.ts +16 -0
  1769. package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -0
  1770. package/dist/modes/interactive/components/bordered-loader.js +54 -0
  1771. package/dist/modes/interactive/components/bordered-loader.js.map +1 -0
  1772. package/dist/modes/interactive/components/branch-summary-message.d.ts +16 -0
  1773. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -0
  1774. package/dist/modes/interactive/components/branch-summary-message.js +44 -0
  1775. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -0
  1776. package/dist/modes/interactive/components/compaction-summary-message.d.ts +16 -0
  1777. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -0
  1778. package/dist/modes/interactive/components/compaction-summary-message.js +45 -0
  1779. package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -0
  1780. package/dist/modes/interactive/components/config-selector.d.ts +102 -0
  1781. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -0
  1782. package/dist/modes/interactive/components/config-selector.js +761 -0
  1783. package/dist/modes/interactive/components/config-selector.js.map +1 -0
  1784. package/dist/modes/interactive/components/context-view.d.ts +13 -0
  1785. package/dist/modes/interactive/components/context-view.d.ts.map +1 -0
  1786. package/dist/modes/interactive/components/context-view.js +44 -0
  1787. package/dist/modes/interactive/components/context-view.js.map +1 -0
  1788. package/dist/modes/interactive/components/countdown-timer.d.ts +14 -0
  1789. package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -0
  1790. package/dist/modes/interactive/components/countdown-timer.js +33 -0
  1791. package/dist/modes/interactive/components/countdown-timer.js.map +1 -0
  1792. package/dist/modes/interactive/components/custom-editor.d.ts +21 -0
  1793. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -0
  1794. package/dist/modes/interactive/components/custom-editor.js +70 -0
  1795. package/dist/modes/interactive/components/custom-editor.js.map +1 -0
  1796. package/dist/modes/interactive/components/custom-entry.d.ts +19 -0
  1797. package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -0
  1798. package/dist/modes/interactive/components/custom-entry.js +52 -0
  1799. package/dist/modes/interactive/components/custom-entry.js.map +1 -0
  1800. package/dist/modes/interactive/components/custom-message.d.ts +20 -0
  1801. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -0
  1802. package/dist/modes/interactive/components/custom-message.js +79 -0
  1803. package/dist/modes/interactive/components/custom-message.js.map +1 -0
  1804. package/dist/modes/interactive/components/daxnuts.d.ts +23 -0
  1805. package/dist/modes/interactive/components/daxnuts.d.ts.map +1 -0
  1806. package/dist/modes/interactive/components/daxnuts.js +140 -0
  1807. package/dist/modes/interactive/components/daxnuts.js.map +1 -0
  1808. package/dist/modes/interactive/components/diff.d.ts +12 -0
  1809. package/dist/modes/interactive/components/diff.d.ts.map +1 -0
  1810. package/dist/modes/interactive/components/diff.js +133 -0
  1811. package/dist/modes/interactive/components/diff.js.map +1 -0
  1812. package/dist/modes/interactive/components/dynamic-border.d.ts +15 -0
  1813. package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -0
  1814. package/dist/modes/interactive/components/dynamic-border.js +21 -0
  1815. package/dist/modes/interactive/components/dynamic-border.js.map +1 -0
  1816. package/dist/modes/interactive/components/earendil-announcement.d.ts +5 -0
  1817. package/dist/modes/interactive/components/earendil-announcement.d.ts.map +1 -0
  1818. package/dist/modes/interactive/components/earendil-announcement.js +40 -0
  1819. package/dist/modes/interactive/components/earendil-announcement.js.map +1 -0
  1820. package/dist/modes/interactive/components/exit-card.d.ts +22 -0
  1821. package/dist/modes/interactive/components/exit-card.d.ts.map +1 -0
  1822. package/dist/modes/interactive/components/exit-card.js +69 -0
  1823. package/dist/modes/interactive/components/exit-card.js.map +1 -0
  1824. package/dist/modes/interactive/components/extension-editor.d.ts +22 -0
  1825. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -0
  1826. package/dist/modes/interactive/components/extension-editor.js +128 -0
  1827. package/dist/modes/interactive/components/extension-editor.js.map +1 -0
  1828. package/dist/modes/interactive/components/extension-input.d.ts +23 -0
  1829. package/dist/modes/interactive/components/extension-input.d.ts.map +1 -0
  1830. package/dist/modes/interactive/components/extension-input.js +61 -0
  1831. package/dist/modes/interactive/components/extension-input.js.map +1 -0
  1832. package/dist/modes/interactive/components/extension-selector.d.ts +30 -0
  1833. package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -0
  1834. package/dist/modes/interactive/components/extension-selector.js +106 -0
  1835. package/dist/modes/interactive/components/extension-selector.js.map +1 -0
  1836. package/dist/modes/interactive/components/first-time-setup.d.ts +25 -0
  1837. package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -0
  1838. package/dist/modes/interactive/components/first-time-setup.js +99 -0
  1839. package/dist/modes/interactive/components/first-time-setup.js.map +1 -0
  1840. package/dist/modes/interactive/components/footer.d.ts +30 -0
  1841. package/dist/modes/interactive/components/footer.d.ts.map +1 -0
  1842. package/dist/modes/interactive/components/footer.js +230 -0
  1843. package/dist/modes/interactive/components/footer.js.map +1 -0
  1844. package/dist/modes/interactive/components/index.d.ts +34 -0
  1845. package/dist/modes/interactive/components/index.d.ts.map +1 -0
  1846. package/dist/modes/interactive/components/index.js +35 -0
  1847. package/dist/modes/interactive/components/index.js.map +1 -0
  1848. package/dist/modes/interactive/components/injected-prompt-message.d.ts +21 -0
  1849. package/dist/modes/interactive/components/injected-prompt-message.d.ts.map +1 -0
  1850. package/dist/modes/interactive/components/injected-prompt-message.js +51 -0
  1851. package/dist/modes/interactive/components/injected-prompt-message.js.map +1 -0
  1852. package/dist/modes/interactive/components/keybinding-hints.d.ts +13 -0
  1853. package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -0
  1854. package/dist/modes/interactive/components/keybinding-hints.js +36 -0
  1855. package/dist/modes/interactive/components/keybinding-hints.js.map +1 -0
  1856. package/dist/modes/interactive/components/login-dialog.d.ts +52 -0
  1857. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -0
  1858. package/dist/modes/interactive/components/login-dialog.js +188 -0
  1859. package/dist/modes/interactive/components/login-dialog.js.map +1 -0
  1860. package/dist/modes/interactive/components/model-selector.d.ts +61 -0
  1861. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -0
  1862. package/dist/modes/interactive/components/model-selector.js +320 -0
  1863. package/dist/modes/interactive/components/model-selector.js.map +1 -0
  1864. package/dist/modes/interactive/components/oauth-selector.d.ts +33 -0
  1865. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -0
  1866. package/dist/modes/interactive/components/oauth-selector.js +163 -0
  1867. package/dist/modes/interactive/components/oauth-selector.js.map +1 -0
  1868. package/dist/modes/interactive/components/plan-message.d.ts +17 -0
  1869. package/dist/modes/interactive/components/plan-message.d.ts.map +1 -0
  1870. package/dist/modes/interactive/components/plan-message.js +43 -0
  1871. package/dist/modes/interactive/components/plan-message.js.map +1 -0
  1872. package/dist/modes/interactive/components/processes-selector.d.ts +20 -0
  1873. package/dist/modes/interactive/components/processes-selector.d.ts.map +1 -0
  1874. package/dist/modes/interactive/components/processes-selector.js +175 -0
  1875. package/dist/modes/interactive/components/processes-selector.js.map +1 -0
  1876. package/dist/modes/interactive/components/scoped-models-selector.d.ts +42 -0
  1877. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -0
  1878. package/dist/modes/interactive/components/scoped-models-selector.js +293 -0
  1879. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -0
  1880. package/dist/modes/interactive/components/session-selector-search.d.ts +23 -0
  1881. package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -0
  1882. package/dist/modes/interactive/components/session-selector-search.js +155 -0
  1883. package/dist/modes/interactive/components/session-selector-search.js.map +1 -0
  1884. package/dist/modes/interactive/components/session-selector.d.ts +95 -0
  1885. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -0
  1886. package/dist/modes/interactive/components/session-selector.js +857 -0
  1887. package/dist/modes/interactive/components/session-selector.js.map +1 -0
  1888. package/dist/modes/interactive/components/settings-selector.d.ts +157 -0
  1889. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -0
  1890. package/dist/modes/interactive/components/settings-selector.js +1273 -0
  1891. package/dist/modes/interactive/components/settings-selector.js.map +1 -0
  1892. package/dist/modes/interactive/components/show-images-selector.d.ts +10 -0
  1893. package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -0
  1894. package/dist/modes/interactive/components/show-images-selector.js +39 -0
  1895. package/dist/modes/interactive/components/show-images-selector.js.map +1 -0
  1896. package/dist/modes/interactive/components/skill-invocation-message.d.ts +17 -0
  1897. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -0
  1898. package/dist/modes/interactive/components/skill-invocation-message.js +47 -0
  1899. package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -0
  1900. package/dist/modes/interactive/components/status-indicator.d.ts +28 -0
  1901. package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -0
  1902. package/dist/modes/interactive/components/status-indicator.js +60 -0
  1903. package/dist/modes/interactive/components/status-indicator.js.map +1 -0
  1904. package/dist/modes/interactive/components/theme-selector.d.ts +11 -0
  1905. package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -0
  1906. package/dist/modes/interactive/components/theme-selector.js +50 -0
  1907. package/dist/modes/interactive/components/theme-selector.js.map +1 -0
  1908. package/dist/modes/interactive/components/thinking-selector.d.ts +11 -0
  1909. package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -0
  1910. package/dist/modes/interactive/components/thinking-selector.js +52 -0
  1911. package/dist/modes/interactive/components/thinking-selector.js.map +1 -0
  1912. package/dist/modes/interactive/components/thinking-summary.d.ts +36 -0
  1913. package/dist/modes/interactive/components/thinking-summary.d.ts.map +1 -0
  1914. package/dist/modes/interactive/components/thinking-summary.js +96 -0
  1915. package/dist/modes/interactive/components/thinking-summary.js.map +1 -0
  1916. package/dist/modes/interactive/components/thinking-tail.d.ts +22 -0
  1917. package/dist/modes/interactive/components/thinking-tail.d.ts.map +1 -0
  1918. package/dist/modes/interactive/components/thinking-tail.js +27 -0
  1919. package/dist/modes/interactive/components/thinking-tail.js.map +1 -0
  1920. package/dist/modes/interactive/components/tool-execution.d.ts +81 -0
  1921. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -0
  1922. package/dist/modes/interactive/components/tool-execution.js +473 -0
  1923. package/dist/modes/interactive/components/tool-execution.js.map +1 -0
  1924. package/dist/modes/interactive/components/tree-selector.d.ts +94 -0
  1925. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -0
  1926. package/dist/modes/interactive/components/tree-selector.js +1245 -0
  1927. package/dist/modes/interactive/components/tree-selector.js.map +1 -0
  1928. package/dist/modes/interactive/components/trust-selector.d.ts +23 -0
  1929. package/dist/modes/interactive/components/trust-selector.d.ts.map +1 -0
  1930. package/dist/modes/interactive/components/trust-selector.js +91 -0
  1931. package/dist/modes/interactive/components/trust-selector.js.map +1 -0
  1932. package/dist/modes/interactive/components/usage-view.d.ts +42 -0
  1933. package/dist/modes/interactive/components/usage-view.d.ts.map +1 -0
  1934. package/dist/modes/interactive/components/usage-view.js +140 -0
  1935. package/dist/modes/interactive/components/usage-view.js.map +1 -0
  1936. package/dist/modes/interactive/components/user-message-selector.d.ts +30 -0
  1937. package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -0
  1938. package/dist/modes/interactive/components/user-message-selector.js +114 -0
  1939. package/dist/modes/interactive/components/user-message-selector.js.map +1 -0
  1940. package/dist/modes/interactive/components/user-message.d.ts +17 -0
  1941. package/dist/modes/interactive/components/user-message.d.ts.map +1 -0
  1942. package/dist/modes/interactive/components/user-message.js +63 -0
  1943. package/dist/modes/interactive/components/user-message.js.map +1 -0
  1944. package/dist/modes/interactive/components/visual-truncate.d.ts +24 -0
  1945. package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -0
  1946. package/dist/modes/interactive/components/visual-truncate.js +33 -0
  1947. package/dist/modes/interactive/components/visual-truncate.js.map +1 -0
  1948. package/dist/modes/interactive/interactive-mode.d.ts +508 -0
  1949. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -0
  1950. package/dist/modes/interactive/interactive-mode.js +6867 -0
  1951. package/dist/modes/interactive/interactive-mode.js.map +1 -0
  1952. package/dist/modes/interactive/model-search.d.ts +12 -0
  1953. package/dist/modes/interactive/model-search.d.ts.map +1 -0
  1954. package/dist/modes/interactive/model-search.js +15 -0
  1955. package/dist/modes/interactive/model-search.js.map +1 -0
  1956. package/dist/modes/interactive/skill-tag-autocomplete.d.ts +13 -0
  1957. package/dist/modes/interactive/skill-tag-autocomplete.d.ts.map +1 -0
  1958. package/dist/modes/interactive/skill-tag-autocomplete.js +72 -0
  1959. package/dist/modes/interactive/skill-tag-autocomplete.js.map +1 -0
  1960. package/dist/modes/interactive/smooth-streaming.d.ts +43 -0
  1961. package/dist/modes/interactive/smooth-streaming.d.ts.map +1 -0
  1962. package/dist/modes/interactive/smooth-streaming.js +182 -0
  1963. package/dist/modes/interactive/smooth-streaming.js.map +1 -0
  1964. package/dist/modes/interactive/theme/moon.json +83 -0
  1965. package/dist/modes/interactive/theme/theme-controller.d.ts +29 -0
  1966. package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -0
  1967. package/dist/modes/interactive/theme/theme-controller.js +97 -0
  1968. package/dist/modes/interactive/theme/theme-controller.js.map +1 -0
  1969. package/dist/modes/interactive/theme/theme-schema.json +363 -0
  1970. package/dist/modes/interactive/theme/theme.d.ts +128 -0
  1971. package/dist/modes/interactive/theme/theme.d.ts.map +1 -0
  1972. package/dist/modes/interactive/theme/theme.js +1092 -0
  1973. package/dist/modes/interactive/theme/theme.js.map +1 -0
  1974. package/dist/modes/print-mode.d.ts +28 -0
  1975. package/dist/modes/print-mode.d.ts.map +1 -0
  1976. package/dist/modes/print-mode.js +132 -0
  1977. package/dist/modes/print-mode.js.map +1 -0
  1978. package/dist/modes/rpc/jsonl.d.ts +17 -0
  1979. package/dist/modes/rpc/jsonl.d.ts.map +1 -0
  1980. package/dist/modes/rpc/jsonl.js +49 -0
  1981. package/dist/modes/rpc/jsonl.js.map +1 -0
  1982. package/dist/modes/rpc/rpc-client.d.ts +242 -0
  1983. package/dist/modes/rpc/rpc-client.d.ts.map +1 -0
  1984. package/dist/modes/rpc/rpc-client.js +481 -0
  1985. package/dist/modes/rpc/rpc-client.js.map +1 -0
  1986. package/dist/modes/rpc/rpc-mode.d.ts +20 -0
  1987. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -0
  1988. package/dist/modes/rpc/rpc-mode.js +635 -0
  1989. package/dist/modes/rpc/rpc-mode.js.map +1 -0
  1990. package/dist/modes/rpc/rpc-types.d.ts +446 -0
  1991. package/dist/modes/rpc/rpc-types.d.ts.map +1 -0
  1992. package/dist/modes/rpc/rpc-types.js +8 -0
  1993. package/dist/modes/rpc/rpc-types.js.map +1 -0
  1994. package/dist/package-manager-cli.d.ts +8 -0
  1995. package/dist/package-manager-cli.d.ts.map +1 -0
  1996. package/dist/package-manager-cli.js +378 -0
  1997. package/dist/package-manager-cli.js.map +1 -0
  1998. package/dist/rpc-entry.d.ts +3 -0
  1999. package/dist/rpc-entry.d.ts.map +1 -0
  2000. package/dist/rpc-entry.js +10 -0
  2001. package/dist/rpc-entry.js.map +1 -0
  2002. package/dist/startup/interactive-shell.d.ts +55 -0
  2003. package/dist/startup/interactive-shell.d.ts.map +1 -0
  2004. package/dist/startup/interactive-shell.js +263 -0
  2005. package/dist/startup/interactive-shell.js.map +1 -0
  2006. package/dist/startup/launch-routing.d.ts +8 -0
  2007. package/dist/startup/launch-routing.d.ts.map +1 -0
  2008. package/dist/startup/launch-routing.js +30 -0
  2009. package/dist/startup/launch-routing.js.map +1 -0
  2010. package/dist/startup/startup-milestones.d.ts +4 -0
  2011. package/dist/startup/startup-milestones.d.ts.map +1 -0
  2012. package/dist/startup/startup-milestones.js +13 -0
  2013. package/dist/startup/startup-milestones.js.map +1 -0
  2014. package/dist/utils/ansi.d.ts +2 -0
  2015. package/dist/utils/ansi.d.ts.map +1 -0
  2016. package/dist/utils/ansi.js +52 -0
  2017. package/dist/utils/ansi.js.map +1 -0
  2018. package/dist/utils/child-process.d.ts +18 -0
  2019. package/dist/utils/child-process.d.ts.map +1 -0
  2020. package/dist/utils/child-process.js +106 -0
  2021. package/dist/utils/child-process.js.map +1 -0
  2022. package/dist/utils/clipboard-image.d.ts +11 -0
  2023. package/dist/utils/clipboard-image.d.ts.map +1 -0
  2024. package/dist/utils/clipboard-image.js +304 -0
  2025. package/dist/utils/clipboard-image.js.map +1 -0
  2026. package/dist/utils/clipboard-native.d.ts +11 -0
  2027. package/dist/utils/clipboard-native.d.ts.map +1 -0
  2028. package/dist/utils/clipboard-native.js +20 -0
  2029. package/dist/utils/clipboard-native.js.map +1 -0
  2030. package/dist/utils/clipboard.d.ts +4 -0
  2031. package/dist/utils/clipboard.d.ts.map +1 -0
  2032. package/dist/utils/clipboard.js +130 -0
  2033. package/dist/utils/clipboard.js.map +1 -0
  2034. package/dist/utils/deprecation.d.ts +4 -0
  2035. package/dist/utils/deprecation.d.ts.map +1 -0
  2036. package/dist/utils/deprecation.js +13 -0
  2037. package/dist/utils/deprecation.js.map +1 -0
  2038. package/dist/utils/exif-orientation.d.ts +5 -0
  2039. package/dist/utils/exif-orientation.d.ts.map +1 -0
  2040. package/dist/utils/exif-orientation.js +158 -0
  2041. package/dist/utils/exif-orientation.js.map +1 -0
  2042. package/dist/utils/frontmatter.d.ts +8 -0
  2043. package/dist/utils/frontmatter.d.ts.map +1 -0
  2044. package/dist/utils/frontmatter.js +26 -0
  2045. package/dist/utils/frontmatter.js.map +1 -0
  2046. package/dist/utils/fs-watch.d.ts +5 -0
  2047. package/dist/utils/fs-watch.d.ts.map +1 -0
  2048. package/dist/utils/fs-watch.js +25 -0
  2049. package/dist/utils/fs-watch.js.map +1 -0
  2050. package/dist/utils/git.d.ts +26 -0
  2051. package/dist/utils/git.d.ts.map +1 -0
  2052. package/dist/utils/git.js +195 -0
  2053. package/dist/utils/git.js.map +1 -0
  2054. package/dist/utils/html.d.ts +7 -0
  2055. package/dist/utils/html.d.ts.map +1 -0
  2056. package/dist/utils/html.js +40 -0
  2057. package/dist/utils/html.js.map +1 -0
  2058. package/dist/utils/image-convert.d.ts +10 -0
  2059. package/dist/utils/image-convert.d.ts.map +1 -0
  2060. package/dist/utils/image-convert.js +45 -0
  2061. package/dist/utils/image-convert.js.map +1 -0
  2062. package/dist/utils/image-process.d.ts +18 -0
  2063. package/dist/utils/image-process.d.ts.map +1 -0
  2064. package/dist/utils/image-process.js +83 -0
  2065. package/dist/utils/image-process.js.map +1 -0
  2066. package/dist/utils/image-resize-core.d.ts +30 -0
  2067. package/dist/utils/image-resize-core.d.ts.map +1 -0
  2068. package/dist/utils/image-resize-core.js +124 -0
  2069. package/dist/utils/image-resize-core.js.map +1 -0
  2070. package/dist/utils/image-resize-worker.d.ts +2 -0
  2071. package/dist/utils/image-resize-worker.d.ts.map +1 -0
  2072. package/dist/utils/image-resize-worker.js +31 -0
  2073. package/dist/utils/image-resize-worker.js.map +1 -0
  2074. package/dist/utils/image-resize.d.ts +16 -0
  2075. package/dist/utils/image-resize.d.ts.map +1 -0
  2076. package/dist/utils/image-resize.js +97 -0
  2077. package/dist/utils/image-resize.js.map +1 -0
  2078. package/dist/utils/json.d.ts +3 -0
  2079. package/dist/utils/json.d.ts.map +1 -0
  2080. package/dist/utils/json.js +7 -0
  2081. package/dist/utils/json.js.map +1 -0
  2082. package/dist/utils/mime.d.ts +3 -0
  2083. package/dist/utils/mime.d.ts.map +1 -0
  2084. package/dist/utils/mime.js +110 -0
  2085. package/dist/utils/mime.js.map +1 -0
  2086. package/dist/utils/open-browser.d.ts +9 -0
  2087. package/dist/utils/open-browser.d.ts.map +1 -0
  2088. package/dist/utils/open-browser.js +22 -0
  2089. package/dist/utils/open-browser.js.map +1 -0
  2090. package/dist/utils/paths.d.ts +31 -0
  2091. package/dist/utils/paths.d.ts.map +1 -0
  2092. package/dist/utils/paths.js +92 -0
  2093. package/dist/utils/paths.js.map +1 -0
  2094. package/dist/utils/photon.d.ts +21 -0
  2095. package/dist/utils/photon.d.ts.map +1 -0
  2096. package/dist/utils/photon.js +121 -0
  2097. package/dist/utils/photon.js.map +1 -0
  2098. package/dist/utils/pi-user-agent.d.ts +2 -0
  2099. package/dist/utils/pi-user-agent.d.ts.map +1 -0
  2100. package/dist/utils/pi-user-agent.js +5 -0
  2101. package/dist/utils/pi-user-agent.js.map +1 -0
  2102. package/dist/utils/shell.d.ts +31 -0
  2103. package/dist/utils/shell.d.ts.map +1 -0
  2104. package/dist/utils/shell.js +202 -0
  2105. package/dist/utils/shell.js.map +1 -0
  2106. package/dist/utils/sleep.d.ts +5 -0
  2107. package/dist/utils/sleep.d.ts.map +1 -0
  2108. package/dist/utils/sleep.js +17 -0
  2109. package/dist/utils/sleep.js.map +1 -0
  2110. package/dist/utils/syntax-highlight.d.ts +12 -0
  2111. package/dist/utils/syntax-highlight.d.ts.map +1 -0
  2112. package/dist/utils/syntax-highlight.js +118 -0
  2113. package/dist/utils/syntax-highlight.js.map +1 -0
  2114. package/dist/utils/tools-manager.d.ts +3 -0
  2115. package/dist/utils/tools-manager.d.ts.map +1 -0
  2116. package/dist/utils/tools-manager.js +328 -0
  2117. package/dist/utils/tools-manager.js.map +1 -0
  2118. package/docs/compaction.md +396 -0
  2119. package/docs/containerization.md +111 -0
  2120. package/docs/custom-provider.md +735 -0
  2121. package/docs/development.md +104 -0
  2122. package/docs/docs.json +160 -0
  2123. package/docs/extensions.md +2913 -0
  2124. package/docs/features.md +102 -0
  2125. package/docs/images/doom-extension.png +0 -0
  2126. package/docs/images/exy.png +0 -0
  2127. package/docs/images/interactive-mode.png +0 -0
  2128. package/docs/images/tree-view.png +0 -0
  2129. package/docs/index.md +88 -0
  2130. package/docs/json.md +82 -0
  2131. package/docs/keybindings.md +202 -0
  2132. package/docs/models.md +540 -0
  2133. package/docs/packages.md +224 -0
  2134. package/docs/prompt-templates.md +95 -0
  2135. package/docs/providers.md +308 -0
  2136. package/docs/quickstart.md +200 -0
  2137. package/docs/rpc.md +1474 -0
  2138. package/docs/sdk.md +1185 -0
  2139. package/docs/security.md +59 -0
  2140. package/docs/session-format.md +422 -0
  2141. package/docs/sessions.md +146 -0
  2142. package/docs/settings.md +341 -0
  2143. package/docs/shell-aliases.md +13 -0
  2144. package/docs/skills.md +241 -0
  2145. package/docs/terminal-setup.md +155 -0
  2146. package/docs/termux.md +127 -0
  2147. package/docs/themes.md +295 -0
  2148. package/docs/tmux.md +63 -0
  2149. package/docs/tui.md +927 -0
  2150. package/docs/usage.md +337 -0
  2151. package/docs/windows.md +25 -0
  2152. package/examples/README.md +27 -0
  2153. package/examples/extensions/README.md +213 -0
  2154. package/examples/extensions/auto-commit-on-exit.ts +49 -0
  2155. package/examples/extensions/bash-spawn-hook.ts +30 -0
  2156. package/examples/extensions/bookmark.ts +50 -0
  2157. package/examples/extensions/border-status-editor.ts +150 -0
  2158. package/examples/extensions/built-in-tool-renderer.ts +249 -0
  2159. package/examples/extensions/claude-rules.ts +86 -0
  2160. package/examples/extensions/commands.ts +72 -0
  2161. package/examples/extensions/confirm-destructive.ts +59 -0
  2162. package/examples/extensions/custom-compaction.ts +128 -0
  2163. package/examples/extensions/custom-footer.ts +64 -0
  2164. package/examples/extensions/custom-header.ts +73 -0
  2165. package/examples/extensions/custom-provider-anthropic/index.ts +604 -0
  2166. package/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
  2167. package/examples/extensions/custom-provider-anthropic/package.json +19 -0
  2168. package/examples/extensions/custom-provider-gitlab-duo/index.ts +404 -0
  2169. package/examples/extensions/custom-provider-gitlab-duo/package.json +16 -0
  2170. package/examples/extensions/custom-provider-gitlab-duo/test.ts +82 -0
  2171. package/examples/extensions/dirty-repo-guard.ts +56 -0
  2172. package/examples/extensions/doom-overlay/README.md +46 -0
  2173. package/examples/extensions/doom-overlay/doom/build/doom.js +21 -0
  2174. package/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
  2175. package/examples/extensions/doom-overlay/doom/build.sh +152 -0
  2176. package/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -0
  2177. package/examples/extensions/doom-overlay/doom-component.ts +132 -0
  2178. package/examples/extensions/doom-overlay/doom-engine.ts +173 -0
  2179. package/examples/extensions/doom-overlay/doom-keys.ts +104 -0
  2180. package/examples/extensions/doom-overlay/index.ts +74 -0
  2181. package/examples/extensions/doom-overlay/wad-finder.ts +51 -0
  2182. package/examples/extensions/dynamic-resources/SKILL.md +8 -0
  2183. package/examples/extensions/dynamic-resources/dynamic.json +79 -0
  2184. package/examples/extensions/dynamic-resources/dynamic.md +5 -0
  2185. package/examples/extensions/dynamic-resources/index.ts +15 -0
  2186. package/examples/extensions/dynamic-tools.ts +74 -0
  2187. package/examples/extensions/entry-renderer.ts +41 -0
  2188. package/examples/extensions/event-bus.ts +43 -0
  2189. package/examples/extensions/file-trigger.ts +41 -0
  2190. package/examples/extensions/git-checkpoint.ts +53 -0
  2191. package/examples/extensions/git-merge-and-resolve.ts +115 -0
  2192. package/examples/extensions/github-issue-autocomplete.ts +185 -0
  2193. package/examples/extensions/gondolin/index.ts +531 -0
  2194. package/examples/extensions/gondolin/package-lock.json +185 -0
  2195. package/examples/extensions/gondolin/package.json +19 -0
  2196. package/examples/extensions/handoff.ts +191 -0
  2197. package/examples/extensions/hello.ts +26 -0
  2198. package/examples/extensions/hidden-thinking-label.ts +53 -0
  2199. package/examples/extensions/inline-bash.ts +94 -0
  2200. package/examples/extensions/input-transform-streaming.ts +39 -0
  2201. package/examples/extensions/input-transform.ts +43 -0
  2202. package/examples/extensions/interactive-shell.ts +196 -0
  2203. package/examples/extensions/kimi-deferred-tools.ts +61 -0
  2204. package/examples/extensions/mac-system-theme.ts +47 -0
  2205. package/examples/extensions/message-renderer.ts +59 -0
  2206. package/examples/extensions/minimal-mode.ts +426 -0
  2207. package/examples/extensions/modal-editor.ts +85 -0
  2208. package/examples/extensions/model-status.ts +31 -0
  2209. package/examples/extensions/notify.ts +55 -0
  2210. package/examples/extensions/overlay-qa-tests.ts +1450 -0
  2211. package/examples/extensions/overlay-test.ts +153 -0
  2212. package/examples/extensions/permission-gate.ts +34 -0
  2213. package/examples/extensions/pirate.ts +47 -0
  2214. package/examples/extensions/plan-mode/README.md +68 -0
  2215. package/examples/extensions/plan-mode/index.ts +390 -0
  2216. package/examples/extensions/plan-mode/utils.ts +168 -0
  2217. package/examples/extensions/preset.ts +436 -0
  2218. package/examples/extensions/project-trust.ts +64 -0
  2219. package/examples/extensions/prompt-customizer.ts +97 -0
  2220. package/examples/extensions/protected-paths.ts +30 -0
  2221. package/examples/extensions/provider-payload.ts +18 -0
  2222. package/examples/extensions/qna.ts +122 -0
  2223. package/examples/extensions/question.ts +286 -0
  2224. package/examples/extensions/questionnaire.ts +448 -0
  2225. package/examples/extensions/rainbow-editor.ts +88 -0
  2226. package/examples/extensions/reload-runtime.ts +37 -0
  2227. package/examples/extensions/rpc-demo.ts +118 -0
  2228. package/examples/extensions/sandbox/index.ts +321 -0
  2229. package/examples/extensions/sandbox/package-lock.json +92 -0
  2230. package/examples/extensions/sandbox/package.json +19 -0
  2231. package/examples/extensions/send-user-message.ts +97 -0
  2232. package/examples/extensions/session-name.ts +27 -0
  2233. package/examples/extensions/shutdown-command.ts +63 -0
  2234. package/examples/extensions/snake.ts +343 -0
  2235. package/examples/extensions/space-invaders.ts +560 -0
  2236. package/examples/extensions/ssh.ts +220 -0
  2237. package/examples/extensions/status-line.ts +32 -0
  2238. package/examples/extensions/structured-output.ts +65 -0
  2239. package/examples/extensions/subagent/README.md +177 -0
  2240. package/examples/extensions/subagent/agents/planner.md +37 -0
  2241. package/examples/extensions/subagent/agents/reviewer.md +35 -0
  2242. package/examples/extensions/subagent/agents/scout.md +50 -0
  2243. package/examples/extensions/subagent/agents/worker.md +24 -0
  2244. package/examples/extensions/subagent/agents.ts +126 -0
  2245. package/examples/extensions/subagent/index.ts +1015 -0
  2246. package/examples/extensions/subagent/prompts/implement-and-review.md +10 -0
  2247. package/examples/extensions/subagent/prompts/implement.md +10 -0
  2248. package/examples/extensions/subagent/prompts/scout-and-plan.md +9 -0
  2249. package/examples/extensions/summarize.ts +207 -0
  2250. package/examples/extensions/system-prompt-header.ts +17 -0
  2251. package/examples/extensions/tic-tac-toe.ts +1008 -0
  2252. package/examples/extensions/timed-confirm.ts +70 -0
  2253. package/examples/extensions/titlebar-spinner.ts +58 -0
  2254. package/examples/extensions/todo.ts +298 -0
  2255. package/examples/extensions/tool-override.ts +144 -0
  2256. package/examples/extensions/tools.ts +146 -0
  2257. package/examples/extensions/trigger-compact.ts +50 -0
  2258. package/examples/extensions/truncated-tool.ts +195 -0
  2259. package/examples/extensions/widget-placement.ts +9 -0
  2260. package/examples/extensions/with-deps/index.ts +32 -0
  2261. package/examples/extensions/with-deps/package-lock.json +31 -0
  2262. package/examples/extensions/with-deps/package.json +22 -0
  2263. package/examples/extensions/working-indicator.ts +123 -0
  2264. package/examples/extensions/working-message-test.ts +25 -0
  2265. package/examples/rpc-extension-ui.ts +632 -0
  2266. package/examples/sdk/01-minimal.ts +26 -0
  2267. package/examples/sdk/02-custom-model.ts +50 -0
  2268. package/examples/sdk/03-custom-prompt.ts +75 -0
  2269. package/examples/sdk/04-skills.ts +55 -0
  2270. package/examples/sdk/05-tools.ts +48 -0
  2271. package/examples/sdk/06-extensions.ts +99 -0
  2272. package/examples/sdk/07-context-files.ts +47 -0
  2273. package/examples/sdk/08-prompt-templates.ts +51 -0
  2274. package/examples/sdk/09-api-keys-and-oauth.ts +34 -0
  2275. package/examples/sdk/10-settings.ts +53 -0
  2276. package/examples/sdk/11-sessions.ts +52 -0
  2277. package/examples/sdk/12-full-control.ts +72 -0
  2278. package/examples/sdk/13-session-runtime.ts +67 -0
  2279. package/examples/sdk/README.md +144 -0
  2280. package/package.json +115 -0
@@ -0,0 +1,3468 @@
1
+ // @ts-nocheck
2
+ import { randomUUID } from "node:crypto";
3
+ import * as fs from "node:fs";
4
+ import * as path from "node:path";
5
+ import { snapshotParentPermissionMode } from "../../../../../core/subagent-permission-inherit.js";
6
+ import { normalizeChildSpec } from "../../shared/child-spec.js";
7
+ import { getArtifactsDir, getProjectChainRunsDir } from "../../shared/artifacts.js";
8
+ import { ChainClarifyComponent } from "./chain-clarify.js";
9
+ import { toModelInfo } from "../../shared/model-info.js";
10
+ import { executeChain } from "./chain-execution.js";
11
+ import { buildDoctorReport } from "../../extension/doctor.js";
12
+ import { clearPendingForegroundControlNotices } from "../../extension/control-notices.js";
13
+ import { runSync } from "./execution.js";
14
+ import { handleWatchdogToolAction, WATCHDOG_TOOL_ACTIONS } from "../../watchdog/tool-actions.js";
15
+ import { buildModelCandidates, resolveEffectiveSubagentModel, resolveTierModelOverride } from "../shared/model-fallback.js";
16
+ import { aggregateParallelOutputs } from "../shared/parallel-utils.js";
17
+ import { recordRun } from "../shared/run-history.js";
18
+ import { buildChainInstructions, writeInitialProgressFile, getStepAgents, isParallelStep, isDynamicParallelStep, resolveStepBehavior, suppressProgressForReadOnlyTask, taskDisallowsFileUpdates, } from "../../shared/settings.js";
19
+ import { discoverAvailableSkills, normalizeSkillInput } from "../../agents/skills.js";
20
+ import { buildAsyncRunnerSteps, executeAsyncChain, executeAsyncSingle, formatAsyncStartedMessage, isAsyncAvailable } from "../background/async-execution.js";
21
+ import { enqueueChainAppendRequest, readPendingChainAppendRequests, runnerStepOutputNames } from "../background/chain-append.js";
22
+ import { ChainOutputValidationError, validateChainOutputBindingsWithContext } from "../shared/chain-outputs.js";
23
+ import { validateExecutionAcceptance } from "../shared/acceptance.js";
24
+ import { createForkContextResolver, forkedChildRequiresThinkingOff } from "../../shared/fork-context.js";
25
+ import { lunrContextPolicy } from "../../shared/lunr-child-context.js";
26
+ import { resolveCurrentSessionId } from "../../shared/session-identity.js";
27
+ import { applyIntercomBridgeToAgent, INTERCOM_BRIDGE_MARKER, resolveIntercomBridge, resolveIntercomSessionTarget, resolveSubagentIntercomTarget } from "../../intercom/intercom-bridge.js";
28
+ import { formatControlIntercomMessage, formatControlNoticeMessage, resolveControlConfig, shouldNotifyControlEvent } from "../shared/subagent-control.js";
29
+ import { resolveTurnBudgetConfig } from "../shared/turn-budget.js";
30
+ import { validateToolBudgetConfig } from "../shared/tool-budget.js";
31
+ import { finalizeSingleOutput, injectSingleOutputInstruction, normalizeSingleOutputOverride, resolveSingleOutputPath, validateFileOnlyOutputMode } from "../shared/single-output.js";
32
+ import { compactForegroundDetails, getSingleResultOutput, mapConcurrent, readStatus, resolveChildCwd, sumResultsCost, sumResultsUsage } from "../../shared/utils.js";
33
+ import { DEFAULT_GLOBAL_CONCURRENCY_LIMIT, Semaphore } from "../shared/parallel-utils.js";
34
+ import { attachNestedChildrenToResultChildren, buildSubagentResultIntercomPayload, deliverSubagentIntercomMessageEvent, deliverSubagentResultIntercomEvent, formatSubagentResultReceipt, resolveSubagentResultStatus, stripDetailsOutputsForIntercomReceipt, } from "../../intercom/result-intercom.js";
35
+ import { buildRevivedAsyncTask, interruptLiveAsyncResumeTarget, resolveAsyncResumeTarget, resolveAsyncRunLocation } from "../background/async-resume.js";
36
+ import { deliverInterruptRequest, deliverStopRequest, requestAsyncSteer } from "../background/control-channel.js";
37
+ import { waitForSteeringAction } from "../background/steering.js";
38
+ import { steerAsyncRun } from "./async-steering-action.js";
39
+ import { reconcileAsyncRun } from "../background/stale-run-reconciler.js";
40
+ import { resolveAsyncRootResultPath } from "../background/chain-root-attachment.js";
41
+ import { attachRootChildrenToSteps, createNestedRoute, readNestedControlResults, resolveInheritedNestedRouteFromEnv, resolveNestedAsyncDir, resolveNestedParentAddressFromEnv, updateForegroundNestedProjection, writeNestedControlRequest, writeNestedEvent } from "../shared/nested-events.js";
42
+ import { resolveSubagentRunId } from "../background/run-id-resolver.js";
43
+ import { formatNestedRunStatusLines } from "../shared/nested-render.js";
44
+ import { inspectSubagentStatus } from "../background/run-status.js";
45
+ import { applyForceTopLevelAsyncOverride } from "../background/top-level-async.js";
46
+ import { cleanupWorktrees, createWorktrees, diffWorktrees, findWorktreeTaskCwdConflict, formatWorktreeDiffSummary, formatWorktreeTaskCwdConflict, } from "../shared/worktree.js";
47
+ import { ASYNC_DIR, DEFAULT_ARTIFACT_CONFIG, DEFAULT_FORK_PREAMBLE, RESULTS_DIR, SUBAGENT_ACTIONS, SUBAGENT_CONTROL_EVENT, SUBAGENT_CONTROL_INTERCOM_EVENT, SUBAGENT_FOREGROUND_COMPLETE_EVENT, checkSubagentDepth, resolveMaxSubagentSpawnsPerSession, resolveTopLevelParallelConcurrency, resolveTopLevelParallelMaxTasks, resolveChildMaxSubagentDepth, resolveCurrentMaxSubagentDepth, wrapForkTask, } from "../../shared/types.js";
48
+ const MUTATING_MANAGEMENT_ACTIONS = new Set(["create", "update", "delete", "eject", "disable", "enable", "reset", "watchdog.configure"]);
49
+ function resolveRequestedCwd(runtimeCwd, requestedCwd) {
50
+ return requestedCwd ? path.resolve(runtimeCwd, requestedCwd) : runtimeCwd;
51
+ }
52
+ function getForegroundControl(state, runId) {
53
+ if (runId)
54
+ return state.foregroundControls.get(runId);
55
+ if (state.lastForegroundControlId) {
56
+ const latest = state.foregroundControls.get(state.lastForegroundControlId);
57
+ if (latest)
58
+ return latest;
59
+ }
60
+ let newest;
61
+ for (const control of state.foregroundControls.values()) {
62
+ if (!newest || control.updatedAt > newest.updatedAt)
63
+ newest = control;
64
+ }
65
+ return newest;
66
+ }
67
+ function formatForegroundActivity(control) {
68
+ const facts = [];
69
+ if (control.currentTool && control.currentToolStartedAt)
70
+ facts.push(`tool ${control.currentTool} for ${Math.floor(Math.max(0, Date.now() - control.currentToolStartedAt) / 1000)}s`);
71
+ else if (control.currentTool)
72
+ facts.push(`tool ${control.currentTool}`);
73
+ if (control.currentPath)
74
+ facts.push(`path ${control.currentPath}`);
75
+ if (control.turnCount !== undefined)
76
+ facts.push(`${control.turnCount} turns`);
77
+ if (control.tokens !== undefined)
78
+ facts.push(`${control.tokens} tokens`);
79
+ if (control.toolCount !== undefined)
80
+ facts.push(`${control.toolCount} tools`);
81
+ if (!control.lastActivityAt) {
82
+ if (control.currentActivityState === "needs_attention")
83
+ return ["needs attention", ...facts].join(" | ");
84
+ if (control.currentActivityState === "active_long_running")
85
+ return ["active but long-running", ...facts].join(" | ");
86
+ return facts.length ? facts.join(" | ") : undefined;
87
+ }
88
+ const seconds = Math.floor(Math.max(0, Date.now() - control.lastActivityAt) / 1000);
89
+ if (control.currentActivityState === "needs_attention")
90
+ return [`no activity for ${seconds}s`, ...facts].join(" | ");
91
+ if (control.currentActivityState === "active_long_running")
92
+ return [`active but long-running; last activity ${seconds}s ago`, ...facts].join(" | ");
93
+ return [`active ${seconds}s ago`, ...facts].join(" | ");
94
+ }
95
+ function nestedResolutionScopeForExecutor(deps) {
96
+ if (deps.allowMutatingManagementActions !== false)
97
+ return undefined;
98
+ const route = resolveInheritedNestedRouteFromEnv();
99
+ const address = route ? resolveNestedParentAddressFromEnv() : undefined;
100
+ return {
101
+ routes: route ? [route] : [],
102
+ ...(address ? { descendantOf: { parentRunId: address.parentRunId, ...(address.parentStepIndex !== undefined ? { parentStepIndex: address.parentStepIndex } : {}) } } : {}),
103
+ };
104
+ }
105
+ function trustedSessionRootsForStatus(ctx, deps) {
106
+ const roots = deps.config.defaultSessionDir ? [path.resolve(deps.expandTilde(deps.config.defaultSessionDir))] : [];
107
+ const parentSessionFile = ctx.sessionManager.getSessionFile() ?? null;
108
+ if (parentSessionFile)
109
+ roots.push(deps.getSubagentSessionRoot(parentSessionFile));
110
+ return [...new Set(roots)];
111
+ }
112
+ function reserveSubagentSpawns(input) {
113
+ if (input.requested <= 0)
114
+ return undefined;
115
+ const maxSpawns = resolveMaxSubagentSpawnsPerSession(input.config.maxSubagentSpawnsPerSession);
116
+ if (maxSpawns === undefined)
117
+ return undefined;
118
+ if (input.state.subagentSpawns?.sessionId !== input.sessionId) {
119
+ input.state.subagentSpawns = { sessionId: input.sessionId, count: 0 };
120
+ }
121
+ const used = input.state.subagentSpawns.count;
122
+ if (used + input.requested > maxSpawns) {
123
+ return {
124
+ content: [{ type: "text", text: `Subagent spawn limit reached for this session (${used}/${maxSpawns} used, ${input.requested} requested). Complete the work directly or start a new session.` }],
125
+ isError: true,
126
+ details: { mode: input.mode, results: [] },
127
+ };
128
+ }
129
+ input.state.subagentSpawns.count = used + input.requested;
130
+ return undefined;
131
+ }
132
+ function countRequestedSubagentSpawns(params, config) {
133
+ if (params.tasks)
134
+ return params.tasks.length;
135
+ if (params.chain) {
136
+ return params.chain.reduce((total, step) => {
137
+ if (isDynamicParallelStep(step))
138
+ return total + (step.expand.maxItems ?? config.chain?.dynamicFanout?.maxItems ?? 0);
139
+ return total + getStepAgents(step).length;
140
+ }, 0);
141
+ }
142
+ return params.agent ? 1 : 0;
143
+ }
144
+ function foregroundStatusResult(control) {
145
+ let nestedWarning;
146
+ try {
147
+ updateForegroundNestedProjection(control);
148
+ }
149
+ catch (error) {
150
+ nestedWarning = `Nested status unavailable: ${error instanceof Error ? error.message : String(error)}`;
151
+ }
152
+ const activity = formatForegroundActivity(control);
153
+ const lines = [
154
+ `Run: ${control.runId}`,
155
+ "State: running",
156
+ `Mode: ${control.mode}`,
157
+ control.currentAgent ? `Current: ${control.currentAgent}${control.currentIndex !== undefined ? ` step ${control.currentIndex + 1}` : ""}` : undefined,
158
+ activity ? `Activity: ${activity}` : undefined,
159
+ ].filter((line) => Boolean(line));
160
+ lines.push(...formatNestedRunStatusLines(control.nestedChildren, { indent: "", commandHints: true, maxLines: 20 }));
161
+ if (nestedWarning)
162
+ lines.push(`Warning: ${nestedWarning}`);
163
+ return { content: [{ type: "text", text: lines.join("\n") }], details: { mode: "management", results: [] } };
164
+ }
165
+ function trimRememberedForegroundRuns(state) {
166
+ if (!state.foregroundRuns)
167
+ return;
168
+ while (state.foregroundRuns.size > 50) {
169
+ const oldestTerminal = [...state.foregroundRuns.values()]
170
+ .filter((run) => !run.children.some((child) => child.status === "detached"))
171
+ .sort((left, right) => left.updatedAt - right.updatedAt)[0];
172
+ if (!oldestTerminal)
173
+ break;
174
+ state.foregroundRuns.delete(oldestTerminal.runId);
175
+ }
176
+ }
177
+ function rememberForegroundRun(state, input) {
178
+ state.foregroundRuns ??= new Map();
179
+ const previous = state.foregroundRuns.get(input.runId);
180
+ const updatedAt = Date.now();
181
+ state.foregroundRuns.set(input.runId, {
182
+ runId: input.runId,
183
+ mode: input.mode,
184
+ cwd: input.cwd,
185
+ ...(input.sessionId ? { sessionId: input.sessionId } : {}),
186
+ updatedAt,
187
+ children: input.results.map((result, index) => {
188
+ const child = {
189
+ agent: result.agent,
190
+ index,
191
+ status: resolveSubagentResultStatus({ exitCode: result.exitCode, interrupted: result.interrupted, detached: result.detached }),
192
+ updatedAt,
193
+ ...(result.exitCode !== undefined ? { exitCode: result.exitCode } : {}),
194
+ ...(result.error ? { error: result.error } : {}),
195
+ ...(result.finalOutput ? { finalOutput: result.finalOutput } : {}),
196
+ ...(result.outputMode ? { outputMode: result.outputMode } : {}),
197
+ ...(result.savedOutputPath ? { savedOutputPath: result.savedOutputPath } : {}),
198
+ ...(result.outputSaveError ? { outputSaveError: result.outputSaveError } : {}),
199
+ ...(result.sessionFile ? { sessionFile: result.sessionFile } : {}),
200
+ ...(result.artifactPaths ? { artifactPaths: result.artifactPaths } : {}),
201
+ ...(result.transcriptPath ? { transcriptPath: result.transcriptPath } : {}),
202
+ ...(result.transcriptError ? { transcriptError: result.transcriptError } : {}),
203
+ ...(result.detachedReason ? { detachedReason: result.detachedReason } : {}),
204
+ ...(result.acceptance ? { acceptance: result.acceptance } : {}),
205
+ };
206
+ const recovered = previous?.children[index];
207
+ return child.status === "detached" && recovered && recovered.status !== "detached" ? recovered : child;
208
+ }),
209
+ });
210
+ trimRememberedForegroundRuns(state);
211
+ }
212
+ function updateRememberedForegroundChild(state, input) {
213
+ state.foregroundRuns ??= new Map();
214
+ const updatedAt = Date.now();
215
+ let run = state.foregroundRuns.get(input.runId);
216
+ if (!run) {
217
+ run = { runId: input.runId, mode: input.mode, cwd: input.cwd, ...(input.sessionId ? { sessionId: input.sessionId } : {}), updatedAt, children: [] };
218
+ state.foregroundRuns.set(input.runId, run);
219
+ }
220
+ run.updatedAt = updatedAt;
221
+ const child = run.children[input.index] ?? { agent: input.result.agent, index: input.index, status: "detached" };
222
+ run.children[input.index] = {
223
+ ...child,
224
+ agent: input.result.agent,
225
+ index: input.index,
226
+ status: input.result.acceptance?.status === "rejected"
227
+ ? "failed"
228
+ : resolveSubagentResultStatus({ exitCode: input.result.exitCode, interrupted: input.result.interrupted, detached: false }),
229
+ updatedAt,
230
+ ...(input.result.exitCode !== undefined ? { exitCode: input.result.exitCode } : {}),
231
+ ...(input.result.error ? { error: input.result.error } : {}),
232
+ ...(input.result.finalOutput ? { finalOutput: input.result.finalOutput } : {}),
233
+ outputMode: input.result.outputMode,
234
+ savedOutputPath: input.result.savedOutputPath,
235
+ outputSaveError: input.result.outputSaveError,
236
+ ...(input.result.sessionFile ? { sessionFile: input.result.sessionFile } : {}),
237
+ ...(input.result.artifactPaths ? { artifactPaths: input.result.artifactPaths } : {}),
238
+ ...(input.result.transcriptPath ? { transcriptPath: input.result.transcriptPath } : {}),
239
+ ...(input.result.transcriptError ? { transcriptError: input.result.transcriptError } : {}),
240
+ ...(input.result.detachedReason ? { detachedReason: input.result.detachedReason } : {}),
241
+ ...(input.result.acceptance ? { acceptance: input.result.acceptance } : {}),
242
+ };
243
+ trimRememberedForegroundRuns(state);
244
+ const output = getSingleResultOutput(input.result).trim();
245
+ const success = input.result.exitCode === 0 && input.result.acceptance?.status !== "rejected";
246
+ const summary = !success && input.result.error
247
+ ? `${input.result.error}${output ? `\n\nOutput:\n${output}` : ""}`
248
+ : output || input.result.error || "Detached child exited without final output.";
249
+ input.events.emit(SUBAGENT_FOREGROUND_COMPLETE_EVENT, {
250
+ id: `${input.runId}:${input.index}`,
251
+ runId: input.runId,
252
+ source: "foreground",
253
+ mode: input.mode,
254
+ agent: input.result.agent,
255
+ success,
256
+ summary,
257
+ exitCode: input.result.exitCode,
258
+ state: success ? "complete" : "failed",
259
+ timestamp: updatedAt,
260
+ cwd: input.cwd,
261
+ sessionFile: input.result.sessionFile,
262
+ sessionId: input.sessionId,
263
+ taskIndex: input.index,
264
+ });
265
+ }
266
+ function resolveForegroundResumeTarget(params, state) {
267
+ const requested = (params.id ?? params.runId)?.trim();
268
+ if (!requested || !state.foregroundRuns?.size || !state.currentSessionId)
269
+ return undefined;
270
+ const sessionRuns = [...state.foregroundRuns.values()].filter((run) => run.sessionId === state.currentSessionId);
271
+ const direct = sessionRuns.find((run) => run.runId === requested);
272
+ const matches = direct ? [direct] : sessionRuns.filter((run) => run.runId.startsWith(requested));
273
+ if (matches.length === 0)
274
+ return undefined;
275
+ if (matches.length > 1)
276
+ throw new Error(`Ambiguous foreground run id prefix '${requested}' matched: ${matches.map((run) => run.runId).join(", ")}. Provide a longer id.`);
277
+ const run = matches[0];
278
+ if (run.children.some((child) => child.status === "detached"))
279
+ throw new Error(`Foreground run '${run.runId}' is detached for intercom coordination and cannot be revived safely while any child may still be live. Reply to the supervisor request first, then wait with subagent_wait({ id: "${run.runId}" }); use status to recover the result and do not launch a replacement while it remains detached.`);
280
+ if (run.children.length > 1 && params.index === undefined)
281
+ throw new Error(`Foreground run '${run.runId}' has ${run.children.length} children. Provide index to choose one.`);
282
+ const index = params.index ?? 0;
283
+ if (!Number.isInteger(index))
284
+ throw new Error(`Foreground run '${run.runId}' index must be an integer.`);
285
+ if (index < 0 || index >= run.children.length)
286
+ throw new Error(`Foreground run '${run.runId}' has ${run.children.length} children. Index ${index} is out of range.`);
287
+ const child = run.children[index];
288
+ if (!child.sessionFile)
289
+ throw new Error(`Foreground run '${run.runId}' child ${index} does not have a persisted session file to resume from.`);
290
+ if (path.extname(child.sessionFile) !== ".jsonl")
291
+ throw new Error(`Foreground run '${run.runId}' child ${index} session file must be a .jsonl file: ${child.sessionFile}`);
292
+ const sessionFile = path.resolve(child.sessionFile);
293
+ if (!fs.existsSync(sessionFile))
294
+ throw new Error(`Foreground run '${run.runId}' child ${index} session file does not exist: ${child.sessionFile}`);
295
+ return { runId: run.runId, mode: run.mode, state: "complete", agent: child.agent, index, intercomTarget: resolveSubagentIntercomTarget(run.runId, child.agent, index), cwd: run.cwd, sessionFile };
296
+ }
297
+ function isAsyncRunNotFound(error) {
298
+ return error instanceof Error && error.message.startsWith("Async run not found.");
299
+ }
300
+ function isResumeAmbiguity(error) {
301
+ return error instanceof Error && /Ambiguous .*run id prefix/.test(error.message);
302
+ }
303
+ function resumeTargetExact(target, requested) {
304
+ return target?.runId === requested;
305
+ }
306
+ function escapeRegExp(value) {
307
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
308
+ }
309
+ function isExactResumeError(error, source, requested) {
310
+ if (!(error instanceof Error) || !requested)
311
+ return false;
312
+ return new RegExp(`\\b${source} run '${escapeRegExp(requested)}'`, "i").test(error.message);
313
+ }
314
+ function resolveResumeTarget(params, state, options = {}) {
315
+ const requested = (params.id ?? params.runId)?.trim() ?? "";
316
+ let foregroundTarget;
317
+ let foregroundError;
318
+ let asyncTarget;
319
+ let asyncError;
320
+ try {
321
+ const target = resolveForegroundResumeTarget(params, state);
322
+ if (target)
323
+ foregroundTarget = { kind: "revive", source: "foreground", ...target };
324
+ }
325
+ catch (error) {
326
+ foregroundError = error;
327
+ }
328
+ try {
329
+ asyncTarget = { source: "async", ...resolveAsyncResumeTarget(params, {}, { requireSessionFile: options.asyncRequireSessionFile }) };
330
+ }
331
+ catch (error) {
332
+ asyncError = error;
333
+ }
334
+ if (foregroundTarget && asyncTarget) {
335
+ const foregroundExact = resumeTargetExact(foregroundTarget, requested);
336
+ const asyncExact = resumeTargetExact(asyncTarget, requested);
337
+ if (foregroundExact && !asyncExact)
338
+ return foregroundTarget;
339
+ if (asyncExact && !foregroundExact)
340
+ return asyncTarget;
341
+ throw new Error(`Resume id '${requested}' is ambiguous between foreground run '${foregroundTarget.runId}' and async run '${asyncTarget.runId}'. Provide a full run id.`);
342
+ }
343
+ if (foregroundTarget) {
344
+ if (isExactResumeError(asyncError, "async", requested))
345
+ throw asyncError;
346
+ if (isResumeAmbiguity(asyncError) && !resumeTargetExact(foregroundTarget, requested))
347
+ throw asyncError;
348
+ return foregroundTarget;
349
+ }
350
+ if (asyncTarget) {
351
+ if (isExactResumeError(foregroundError, "foreground", requested))
352
+ throw foregroundError;
353
+ if (isResumeAmbiguity(foregroundError) && !resumeTargetExact(asyncTarget, requested))
354
+ throw foregroundError;
355
+ return asyncTarget;
356
+ }
357
+ if (foregroundError && !isAsyncRunNotFound(asyncError))
358
+ throw foregroundError;
359
+ if (foregroundError)
360
+ throw foregroundError;
361
+ if (asyncError)
362
+ throw asyncError;
363
+ throw new Error("Run not found. Provide id or runId.");
364
+ }
365
+ function getAsyncInterruptTarget(state, runId, location, options = {}) {
366
+ if (location?.asyncDir) {
367
+ return {
368
+ asyncId: location.resolvedId ?? runId ?? path.basename(location.asyncDir),
369
+ asyncDir: location.asyncDir,
370
+ };
371
+ }
372
+ if (runId) {
373
+ const direct = state.asyncJobs.get(runId);
374
+ if (direct)
375
+ return { asyncId: direct.asyncId, asyncDir: direct.asyncDir };
376
+ if (options.fallbackToNewest === false)
377
+ return undefined;
378
+ }
379
+ let newest;
380
+ for (const job of state.asyncJobs.values()) {
381
+ if (job.status !== "running")
382
+ continue;
383
+ if (!newest || (job.updatedAt ?? 0) > newest.updatedAt) {
384
+ newest = { asyncId: job.asyncId, asyncDir: job.asyncDir, updatedAt: job.updatedAt ?? 0 };
385
+ }
386
+ }
387
+ return newest ? { asyncId: newest.asyncId, asyncDir: newest.asyncDir } : undefined;
388
+ }
389
+ function emitControlNotification(input) {
390
+ if (!shouldNotifyControlEvent(input.controlConfig, input.event))
391
+ return;
392
+ const childIntercomTarget = input.intercomBridge.active
393
+ ? resolveSubagentIntercomTarget(input.event.runId, input.event.agent, input.event.index)
394
+ : undefined;
395
+ const payload = {
396
+ event: input.event,
397
+ source: "foreground",
398
+ childIntercomTarget,
399
+ noticeText: formatControlNoticeMessage(input.event, childIntercomTarget),
400
+ };
401
+ if (input.controlConfig.notifyChannels.includes("event")) {
402
+ input.pi.events.emit(SUBAGENT_CONTROL_EVENT, payload);
403
+ }
404
+ if (input.event.type !== "active_long_running" && input.controlConfig.notifyChannels.includes("intercom") && input.intercomBridge.active && input.intercomBridge.orchestratorTarget) {
405
+ input.pi.events.emit(SUBAGENT_CONTROL_INTERCOM_EVENT, {
406
+ ...payload,
407
+ to: input.intercomBridge.orchestratorTarget,
408
+ message: formatControlIntercomMessage(input.event, childIntercomTarget),
409
+ });
410
+ }
411
+ }
412
+ function interruptAsyncRun(state, runId, kill, location) {
413
+ const target = getAsyncInterruptTarget(state, runId, location);
414
+ if (!target)
415
+ return null;
416
+ const status = reconcileAsyncRun(target.asyncDir, { kill }).status;
417
+ if (!status || status.state !== "running" || typeof status.pid !== "number") {
418
+ return {
419
+ content: [{ type: "text", text: `No running async run with an interrupt-capable pid was found for '${runId ?? "current"}'.` }],
420
+ isError: true,
421
+ details: { mode: "management", results: [] },
422
+ };
423
+ }
424
+ try {
425
+ deliverInterruptRequest({ asyncDir: target.asyncDir, pid: status.pid, kill, source: "interrupt-action" });
426
+ const tracked = state.asyncJobs.get(target.asyncId);
427
+ if (tracked) {
428
+ tracked.activityState = undefined;
429
+ tracked.updatedAt = Date.now();
430
+ }
431
+ return {
432
+ content: [{ type: "text", text: `Interrupt requested for async run ${target.asyncId}.` }],
433
+ details: { mode: "management", results: [] },
434
+ };
435
+ }
436
+ catch (error) {
437
+ const message = error instanceof Error ? error.message : String(error);
438
+ return {
439
+ content: [{ type: "text", text: `Failed to interrupt async run ${target.asyncId}: ${message}` }],
440
+ isError: true,
441
+ details: { mode: "management", results: [] },
442
+ };
443
+ }
444
+ }
445
+ function stopAsyncRun(state, runId, kill, location) {
446
+ const target = getAsyncInterruptTarget(state, runId, location, { fallbackToNewest: false });
447
+ if (!target)
448
+ return null;
449
+ const status = reconcileAsyncRun(target.asyncDir, { kill }).status;
450
+ if (state.currentSessionId && status?.sessionId !== state.currentSessionId) {
451
+ return {
452
+ content: [{ type: "text", text: `Async run '${target.asyncId}' was not found in the active session.` }],
453
+ isError: true,
454
+ details: { mode: "management", results: [] },
455
+ };
456
+ }
457
+ if (!status || (status.state !== "running" && status.state !== "queued")) {
458
+ return {
459
+ content: [{ type: "text", text: `No running or queued async run was found for '${runId ?? "current"}'.` }],
460
+ isError: true,
461
+ details: { mode: "management", results: [] },
462
+ };
463
+ }
464
+ try {
465
+ deliverStopRequest({ asyncDir: target.asyncDir, pid: typeof status.pid === "number" ? status.pid : undefined, kill, source: "stop-action" });
466
+ const tracked = state.asyncJobs.get(target.asyncId);
467
+ if (tracked) {
468
+ tracked.activityState = undefined;
469
+ tracked.updatedAt = Date.now();
470
+ }
471
+ return {
472
+ content: [{ type: "text", text: `Stop requested for async run ${target.asyncId}.` }],
473
+ details: { mode: "management", results: [] },
474
+ };
475
+ }
476
+ catch (error) {
477
+ const message = error instanceof Error ? error.message : String(error);
478
+ return {
479
+ content: [{ type: "text", text: `Failed to stop async run ${target.asyncId}: ${message}` }],
480
+ isError: true,
481
+ details: { mode: "management", results: [] },
482
+ };
483
+ }
484
+ }
485
+ function duplicateNames(names) {
486
+ const seen = new Set();
487
+ const duplicates = new Set();
488
+ for (const name of names) {
489
+ if (seen.has(name))
490
+ duplicates.add(name);
491
+ else
492
+ seen.add(name);
493
+ }
494
+ return [...duplicates];
495
+ }
496
+ function appendStepToAsyncChain(input) {
497
+ const targetRunId = input.params.id ?? input.params.runId;
498
+ if (!targetRunId) {
499
+ return {
500
+ content: [{ type: "text", text: "action='append-step' requires id." }],
501
+ isError: true,
502
+ details: { mode: "management", results: [] },
503
+ };
504
+ }
505
+ if (!input.params.chain || input.params.chain.length !== 1) {
506
+ return {
507
+ content: [{ type: "text", text: "action='append-step' requires chain with exactly one step." }],
508
+ isError: true,
509
+ details: { mode: "management", results: [] },
510
+ };
511
+ }
512
+ const acceptanceErrors = validateExecutionAcceptance(input.params);
513
+ if (acceptanceErrors.length > 0) {
514
+ return {
515
+ content: [{ type: "text", text: `Cannot append step: ${acceptanceErrors.join(" ")}` }],
516
+ isError: true,
517
+ details: { mode: "management", results: [] },
518
+ };
519
+ }
520
+ let resolved;
521
+ try {
522
+ resolved = resolveSubagentRunId(targetRunId, { state: input.deps.state, nested: nestedResolutionScopeForExecutor(input.deps) });
523
+ }
524
+ catch (error) {
525
+ const message = error instanceof Error ? error.message : String(error);
526
+ return { content: [{ type: "text", text: message }], isError: true, details: { mode: "management", results: [] } };
527
+ }
528
+ if (!resolved) {
529
+ return {
530
+ content: [{ type: "text", text: `No async chain run found for '${targetRunId}'.` }],
531
+ isError: true,
532
+ details: { mode: "management", results: [] },
533
+ };
534
+ }
535
+ if (resolved.kind !== "async" || !resolved.location.asyncDir) {
536
+ return {
537
+ content: [{ type: "text", text: `Run '${resolved.id}' is not an append-capable async chain run.` }],
538
+ isError: true,
539
+ details: { mode: "management", results: [] },
540
+ };
541
+ }
542
+ const status = readStatus(resolved.location.asyncDir);
543
+ if (!status) {
544
+ return {
545
+ content: [{ type: "text", text: `No async run status found for '${resolved.id}'.` }],
546
+ isError: true,
547
+ details: { mode: "management", results: [] },
548
+ };
549
+ }
550
+ if (status.mode !== "chain") {
551
+ return {
552
+ content: [{ type: "text", text: `Run '${resolved.id}' is ${status.mode}; only active chain runs accept appended steps.` }],
553
+ isError: true,
554
+ details: { mode: "management", results: [] },
555
+ };
556
+ }
557
+ if (status.state !== "running") {
558
+ return {
559
+ content: [{ type: "text", text: `Run '${resolved.id}' is ${status.state}; only running chain runs accept appended steps.` }],
560
+ isError: true,
561
+ details: { mode: "management", results: [] },
562
+ };
563
+ }
564
+ const stillInProgress = (status.steps ?? []).some((step) => step.status === "running" || step.status === "pending") || (status.pendingAppends ?? 0) > 0;
565
+ if (!stillInProgress) {
566
+ return {
567
+ content: [{ type: "text", text: `Run '${resolved.id}' has no running or pending chain steps left; append-step must target an in-progress chain.` }],
568
+ isError: true,
569
+ details: { mode: "management", results: [] },
570
+ };
571
+ }
572
+ const pendingAppendRequests = readPendingChainAppendRequests(resolved.location.asyncDir);
573
+ const reservedOutputNames = new Set([
574
+ ...Object.keys(status.outputs ?? {}),
575
+ ...(status.steps ?? []).map((step) => step.outputName).filter((name) => Boolean(name)),
576
+ ...pendingAppendRequests.flatMap((request) => runnerStepOutputNames(request.steps)),
577
+ ]);
578
+ try {
579
+ validateChainOutputBindingsWithContext(input.params.chain, { maxItems: input.deps.config.chain?.dynamicFanout?.maxItems }, {
580
+ priorOutputNames: reservedOutputNames,
581
+ startStepIndex: status.chainStepCount ?? status.steps?.length ?? 0,
582
+ });
583
+ }
584
+ catch (error) {
585
+ if (!(error instanceof ChainOutputValidationError))
586
+ throw error;
587
+ return {
588
+ content: [{ type: "text", text: `Cannot append step to run '${resolved.id}': ${error.message}` }],
589
+ isError: true,
590
+ details: { mode: "management", results: [] },
591
+ };
592
+ }
593
+ let appendParams;
594
+ const appendChildRunId = `${resolved.id}-append-${randomUUID().slice(0, 8)}`;
595
+ try {
596
+ appendParams = internalizePromptDrivenChildren(input.params, {
597
+ runId: appendChildRunId,
598
+ parentMode: snapshotParentPermissionMode(input.deps.state.currentSessionId),
599
+ dynamicFanoutMaxItems: input.deps.config.chain?.dynamicFanout?.maxItems,
600
+ }).params;
601
+ }
602
+ catch (error) {
603
+ return {
604
+ content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
605
+ isError: true,
606
+ details: { mode: "management", results: [] },
607
+ };
608
+ }
609
+ const contextPolicy = resolveExplicitContextPolicy(appendParams);
610
+ const chainSkillInput = normalizeSkillInput(appendParams.skill);
611
+ const chainSkills = chainSkillInput === false ? [] : (chainSkillInput ?? []);
612
+ const asyncCtx = {
613
+ pi: input.deps.pi,
614
+ cwd: input.ctx.cwd,
615
+ currentSessionId: resolveCurrentSessionId(input.ctx.sessionManager),
616
+ parentSessionId: input.ctx.sessionManager.getSessionId() ?? undefined,
617
+ currentModelProvider: input.ctx.model?.provider,
618
+ currentModel: input.ctx.model,
619
+ modelScope: undefined,
620
+ };
621
+ const built = buildAsyncRunnerSteps(resolved.id, {
622
+ chain: wrapChainTasksForFork(appendParams.chain, contextPolicy),
623
+ task: appendParams.task,
624
+ resultMode: "chain",
625
+ ctx: asyncCtx,
626
+ availableModels: input.ctx.modelRegistry.getAvailable().map(toModelInfo),
627
+ cwd: status.cwd ?? input.requestCwd,
628
+ chainSkills,
629
+ dynamicFanoutMaxItems: input.deps.config.chain?.dynamicFanout?.maxItems,
630
+ maxSubagentDepth: resolveCurrentMaxSubagentDepth(input.deps.config.maxSubagentDepth),
631
+ waitToolEnabled: input.deps.waitToolEnabled,
632
+ asyncDir: resolved.location.asyncDir,
633
+ childIdRunId: appendChildRunId,
634
+ validateOutputBindings: false,
635
+ });
636
+ if ("error" in built) {
637
+ return {
638
+ content: [{ type: "text", text: built.error }],
639
+ isError: true,
640
+ details: { mode: "management", results: [] },
641
+ };
642
+ }
643
+ const appendedOutputNames = runnerStepOutputNames(built.steps);
644
+ const duplicateAppendedOutputs = duplicateNames(appendedOutputNames);
645
+ if (duplicateAppendedOutputs.length > 0) {
646
+ return {
647
+ content: [{ type: "text", text: `Cannot append step to run '${resolved.id}': duplicate output name in appended step: ${duplicateAppendedOutputs.join(", ")}.` }],
648
+ isError: true,
649
+ details: { mode: "management", results: [] },
650
+ };
651
+ }
652
+ const pendingOutputNames = new Set(pendingAppendRequests.flatMap((request) => runnerStepOutputNames(request.steps)));
653
+ const pendingDuplicateOutputs = appendedOutputNames.filter((name) => pendingOutputNames.has(name));
654
+ if (pendingDuplicateOutputs.length > 0) {
655
+ return {
656
+ content: [{ type: "text", text: `Cannot append step to run '${resolved.id}': output name already belongs to a pending append: ${pendingDuplicateOutputs.join(", ")}.` }],
657
+ isError: true,
658
+ details: { mode: "management", results: [] },
659
+ };
660
+ }
661
+ try {
662
+ const result = enqueueChainAppendRequest({
663
+ asyncDir: resolved.location.asyncDir,
664
+ runId: resolved.id,
665
+ steps: built.steps,
666
+ });
667
+ const stepText = built.steps.length === 1 ? "step" : "steps";
668
+ return {
669
+ content: [{
670
+ type: "text",
671
+ text: `Append queued for chain run ${resolved.id}: ${built.steps.length} ${stepText}. It becomes eligible after the chain's already-queued steps finish. Pending appends: ${result.pendingCount}.`,
672
+ }],
673
+ details: { mode: "management", results: [], asyncId: resolved.id, asyncDir: resolved.location.asyncDir },
674
+ };
675
+ }
676
+ catch (error) {
677
+ const message = error instanceof Error ? error.message : String(error);
678
+ return {
679
+ content: [{ type: "text", text: `Failed to append step to chain run ${resolved.id}: ${message}` }],
680
+ isError: true,
681
+ details: { mode: "management", results: [] },
682
+ };
683
+ }
684
+ }
685
+ function nestedRunSessionFile(run) {
686
+ return run.sessionFile ?? (run.steps?.length === 1 ? run.steps[0]?.sessionFile : undefined);
687
+ }
688
+ function nestedRunAgent(run) {
689
+ return run.agent ?? run.agents?.[0] ?? (run.steps?.length === 1 ? run.steps[0]?.agent : undefined);
690
+ }
691
+ function pathWithin(base, candidate) {
692
+ const resolvedBase = path.resolve(base);
693
+ const resolvedCandidate = path.resolve(candidate);
694
+ return resolvedCandidate === resolvedBase || resolvedCandidate.startsWith(`${resolvedBase}${path.sep}`);
695
+ }
696
+ function validateNestedSessionFile(run, trustedSessionRoots) {
697
+ const sessionFile = nestedRunSessionFile(run);
698
+ if (!sessionFile)
699
+ throw new Error(`Nested run '${run.id}' does not have a persisted session file to resume from.`);
700
+ if (path.extname(sessionFile) !== ".jsonl")
701
+ throw new Error(`Nested run '${run.id}' session file must be a .jsonl file: ${sessionFile}`);
702
+ const resolved = path.resolve(sessionFile);
703
+ if (!path.isAbsolute(sessionFile))
704
+ throw new Error(`Nested run '${run.id}' session file must be absolute: ${sessionFile}`);
705
+ if (!fs.existsSync(resolved))
706
+ throw new Error(`Nested run '${run.id}' session file does not exist: ${sessionFile}`);
707
+ const stat = fs.lstatSync(resolved);
708
+ if (!stat.isFile() || stat.isSymbolicLink())
709
+ throw new Error(`Nested run '${run.id}' session file is not a regular file: ${sessionFile}`);
710
+ const realSessionFile = fs.realpathSync(resolved);
711
+ const trustedRoots = trustedSessionRoots
712
+ .filter((root) => fs.existsSync(root))
713
+ .map((root) => fs.realpathSync(root));
714
+ if (!trustedRoots.some((root) => pathWithin(root, realSessionFile))) {
715
+ throw new Error(`Nested run '${run.id}' session file is outside trusted nested session roots: ${sessionFile}`);
716
+ }
717
+ if (!realSessionFile.split(path.sep).includes(run.id)) {
718
+ throw new Error(`Nested run '${run.id}' session file is not under that nested run's session directory: ${sessionFile}`);
719
+ }
720
+ return realSessionFile;
721
+ }
722
+ function resolveNestedResumeTarget(match, trustedSessionRoots) {
723
+ const run = match.match.run;
724
+ if (run.state === "running" || run.state === "queued")
725
+ throw new Error(`Nested run '${run.id}' is live; route the follow-up to the owner process instead.`);
726
+ const agent = nestedRunAgent(run);
727
+ if (!agent)
728
+ throw new Error(`Could not determine child agent for nested run '${run.id}'.`);
729
+ const state = run.state === "complete" || run.state === "failed" || run.state === "paused" || run.state === "stopped" ? run.state : "failed";
730
+ const asyncDir = resolveNestedAsyncDir(match.match.rootRunId, run);
731
+ return {
732
+ kind: "revive",
733
+ source: "nested",
734
+ runId: run.id,
735
+ state,
736
+ agent,
737
+ index: 0,
738
+ intercomTarget: resolveSubagentIntercomTarget(run.id, agent, 0),
739
+ cwd: asyncDir ? path.dirname(asyncDir) : undefined,
740
+ sessionFile: validateNestedSessionFile(run, trustedSessionRoots),
741
+ };
742
+ }
743
+ async function waitForNestedControlResult(target, requestId, timeoutMs = 1_000) {
744
+ const deadline = Date.now() + timeoutMs;
745
+ while (Date.now() < deadline) {
746
+ const result = readNestedControlResults(target.match.route).find((candidate) => candidate.requestId === requestId && candidate.targetRunId === target.match.run.id);
747
+ if (result)
748
+ return result;
749
+ await new Promise((resolve) => setTimeout(resolve, 50));
750
+ }
751
+ return undefined;
752
+ }
753
+ async function sendNestedControlRequest(target, action, message) {
754
+ const requestId = randomUUID();
755
+ writeNestedControlRequest(target.match.route, {
756
+ ts: Date.now(),
757
+ requestId,
758
+ targetRunId: target.match.run.id,
759
+ action,
760
+ ...(message ? { message } : {}),
761
+ });
762
+ return waitForNestedControlResult(target, requestId);
763
+ }
764
+ function directNestedAsyncInterrupt(target) {
765
+ const run = target.match.run;
766
+ const asyncDir = resolveNestedAsyncDir(target.match.rootRunId, run);
767
+ if (!asyncDir)
768
+ return undefined;
769
+ const status = reconcileAsyncRun(asyncDir, { resultsDir: path.join(RESULTS_DIR, "nested", target.match.rootRunId) }).status;
770
+ const pid = typeof status?.pid === "number" && status.pid > 0 ? status.pid : run.pid;
771
+ if (!status || status.state !== "running" || typeof pid !== "number" || pid <= 0)
772
+ return undefined;
773
+ try {
774
+ deliverInterruptRequest({ asyncDir, pid, source: "nested-interrupt" });
775
+ return { content: [{ type: "text", text: `Interrupt requested for nested async run ${run.id}.` }], details: { mode: "management", results: [] } };
776
+ }
777
+ catch (error) {
778
+ const message = error instanceof Error ? error.message : String(error);
779
+ return { content: [{ type: "text", text: `Failed to interrupt nested async run ${run.id}: ${message}` }], isError: true, details: { mode: "management", results: [] } };
780
+ }
781
+ }
782
+ async function directNestedAsyncSteer(input) {
783
+ const run = input.target.match.run;
784
+ const asyncDir = resolveNestedAsyncDir(input.target.match.rootRunId, run);
785
+ if (!asyncDir)
786
+ return undefined;
787
+ const status = reconcileAsyncRun(asyncDir, { resultsDir: path.join(RESULTS_DIR, "nested", input.target.match.rootRunId) }).status;
788
+ if (!status || (status.state !== "running" && status.state !== "queued"))
789
+ return undefined;
790
+ const steps = status.steps ?? [];
791
+ if (input.index !== undefined) {
792
+ if (input.index < 0 || input.index >= steps.length)
793
+ return { content: [{ type: "text", text: `Nested async run ${run.id} has ${steps.length} children. Index ${input.index} is out of range.` }], isError: true, details: { mode: "management", results: [] } };
794
+ const step = steps[input.index];
795
+ if (step && step.status !== "running" && step.status !== "pending")
796
+ return { content: [{ type: "text", text: `Nested async run ${run.id} child ${input.index} is ${step.status} and cannot be steered.` }], isError: true, details: { mode: "management", results: [] } };
797
+ }
798
+ const runningIndexes = steps
799
+ .map((step, index) => step.status === "running" ? index : undefined)
800
+ .filter((index) => index !== undefined);
801
+ const effectiveTargetIndex = input.index ?? (status.mode === "single" && runningIndexes.length === 0 && steps[0]?.status === "pending" ? 0 : undefined);
802
+ const targetIndexes = effectiveTargetIndex !== undefined ? [effectiveTargetIndex] : runningIndexes;
803
+ if (targetIndexes.length === 0)
804
+ return { content: [{ type: "text", text: `Nested async run ${run.id} has no running child to steer.` }], isError: true, details: { mode: "management", results: [] } };
805
+ const requestId = randomUUID();
806
+ try {
807
+ requestAsyncSteer(asyncDir, {
808
+ message: input.message,
809
+ ...(effectiveTargetIndex !== undefined ? { targetIndex: effectiveTargetIndex } : { targetIndexes }),
810
+ source: "nested-steer",
811
+ id: requestId,
812
+ });
813
+ }
814
+ catch (error) {
815
+ return { content: [{ type: "text", text: `Failed to queue steering for nested async run ${run.id}: ${error instanceof Error ? error.message : String(error)}` }], isError: true, details: { mode: "management", results: [] } };
816
+ }
817
+ const targets = targetIndexes.map((index) => ({ index, state: steps[index]?.status === "pending" ? "scheduled" : "pending" }));
818
+ if (targets.every((target) => target.state === "scheduled")) {
819
+ const scheduled = { requestId, state: "scheduled", sourceRunId: run.id, targets };
820
+ return { content: [{ type: "text", text: `Steering scheduled for nested async run ${run.id} (request ${requestId}).` }], details: { mode: "management", results: [], steering: scheduled } };
821
+ }
822
+ const waited = await waitForSteeringAction({ asyncDir, sourceRunId: run.id, requestId, timeoutMs: 3_000, signal: input.signal });
823
+ const result = waited ?? { requestId, state: "pending", sourceRunId: run.id, targets };
824
+ const stateText = result.state === "delivered" ? "delivered" : result.state === "failed" ? "failed" : result.state === "partial" ? "partial" : "pending";
825
+ return { content: [{ type: "text", text: `Steering ${stateText} for nested async run ${run.id} (request ${requestId}).` }], ...(result.state === "failed" || result.state === "partial" ? { isError: true } : {}), details: { mode: "management", results: [], steering: result } };
826
+ }
827
+ async function interruptNestedRun(target) {
828
+ const run = target.match.run;
829
+ if (run.state === "complete")
830
+ return { content: [{ type: "text", text: `Nested run ${run.id} is already complete and cannot be interrupted.` }], isError: true, details: { mode: "management", results: [] } };
831
+ if (run.state === "failed")
832
+ return { content: [{ type: "text", text: `Nested run ${run.id} has failed and cannot be interrupted.` }], isError: true, details: { mode: "management", results: [] } };
833
+ if (run.state === "paused")
834
+ return { content: [{ type: "text", text: `Nested run ${run.id} is already paused.` }], isError: true, details: { mode: "management", results: [] } };
835
+ const result = await sendNestedControlRequest(target, "interrupt");
836
+ if (result)
837
+ return { content: [{ type: "text", text: result.message }], isError: result.ok ? undefined : true, details: { mode: "management", results: [] } };
838
+ const direct = directNestedAsyncInterrupt(target);
839
+ if (direct)
840
+ return direct;
841
+ return { content: [{ type: "text", text: `Nested run ${run.id} owner is not reachable and no safe direct async interrupt fallback is available.` }], isError: true, details: { mode: "management", results: [] } };
842
+ }
843
+ async function resumeLiveNestedRun(input) {
844
+ const run = input.target.match.run;
845
+ const result = await sendNestedControlRequest(input.target, "resume", input.message);
846
+ if (result)
847
+ return { content: [{ type: "text", text: result.message }], isError: result.ok ? undefined : true, details: { mode: "management", results: [] } };
848
+ return { content: [{ type: "text", text: `Nested run ${run.id} appears live but its owner route is not reachable. Wait for completion, then retry action='resume'.` }], isError: true, details: { mode: "management", results: [] } };
849
+ }
850
+ async function steerNestedRun(input) {
851
+ const run = input.target.match.run;
852
+ if (run.state !== "running" && run.state !== "queued")
853
+ return { content: [{ type: "text", text: `Nested run ${run.id} is ${run.state} and cannot be steered.` }], isError: true, details: { mode: "management", results: [] } };
854
+ const direct = await directNestedAsyncSteer(input);
855
+ if (direct)
856
+ return direct;
857
+ return { content: [{ type: "text", text: `Nested run ${run.id} is not a live async Pi child session with a steering inbox. action='steer' cannot target foreground nested runs.` }], isError: true, details: { mode: "management", results: [] } };
858
+ }
859
+ async function resumeAsyncRun(input) {
860
+ const followUp = (input.params.message ?? input.params.task ?? "").trim();
861
+ const attachChain = (input.params.chain?.length ?? 0) > 0 ? input.params.chain : undefined;
862
+ if (!followUp && !attachChain) {
863
+ return {
864
+ content: [{ type: "text", text: "action='resume' requires message." }],
865
+ isError: true,
866
+ details: { mode: "management", results: [] },
867
+ };
868
+ }
869
+ const acceptanceErrors = validateExecutionAcceptance(input.params);
870
+ if (acceptanceErrors.length > 0) {
871
+ return {
872
+ content: [{ type: "text", text: `Cannot resume: ${acceptanceErrors.join(" ")}` }],
873
+ isError: true,
874
+ details: { mode: "management", results: [] },
875
+ };
876
+ }
877
+ input.deps.state.currentSessionId = resolveCurrentSessionId(input.ctx.sessionManager);
878
+ let target;
879
+ const parentSessionFile = input.ctx.sessionManager.getSessionFile() ?? null;
880
+ try {
881
+ const requestedId = input.params.id ?? input.params.runId;
882
+ let resolved;
883
+ try {
884
+ resolved = requestedId ? resolveSubagentRunId(requestedId, { state: input.deps.state, nested: nestedResolutionScopeForExecutor(input.deps) }) : undefined;
885
+ }
886
+ catch (error) {
887
+ const message = error instanceof Error ? error.message : "";
888
+ const asyncMatches = message.match(/async:/g)?.length ?? 0;
889
+ if (!isResumeAmbiguity(error) || !message.includes("foreground:") || asyncMatches !== 1)
890
+ throw error;
891
+ }
892
+ if (resolved?.kind === "nested") {
893
+ if (attachChain) {
894
+ return {
895
+ content: [{ type: "text", text: "Attaching a running subagent as a chain root is currently available for top-level async runs only." }],
896
+ isError: true,
897
+ details: { mode: "management", results: [] },
898
+ };
899
+ }
900
+ if (resolved.match.run.state === "running" || resolved.match.run.state === "queued") {
901
+ return resumeLiveNestedRun({ target: resolved, message: followUp });
902
+ }
903
+ const trustedSessionRoots = [
904
+ ...(input.deps.config.defaultSessionDir ? [path.resolve(input.deps.expandTilde(input.deps.config.defaultSessionDir))] : []),
905
+ ...(parentSessionFile ? [input.deps.getSubagentSessionRoot(parentSessionFile)] : []),
906
+ ];
907
+ target = resolveNestedResumeTarget(resolved, trustedSessionRoots);
908
+ }
909
+ else {
910
+ target = resolveResumeTarget(input.params, input.deps.state, { asyncRequireSessionFile: !attachChain });
911
+ }
912
+ }
913
+ catch (error) {
914
+ const message = error instanceof Error ? error.message : String(error);
915
+ return { content: [{ type: "text", text: message }], isError: true, details: { mode: "management", results: [] } };
916
+ }
917
+ if (target.kind === "live" && !attachChain) {
918
+ const interrupt = interruptLiveAsyncResumeTarget({
919
+ target,
920
+ state: input.deps.state,
921
+ kill: input.deps.kill,
922
+ resultsDir: RESULTS_DIR,
923
+ });
924
+ if (!interrupt.ok) {
925
+ return {
926
+ content: [{ type: "text", text: interrupt.message }],
927
+ isError: true,
928
+ details: { mode: "management", results: [] },
929
+ };
930
+ }
931
+ const delivered = await deliverSubagentIntercomMessageEvent(input.deps.pi.events, target.intercomTarget, `Follow-up for async run ${target.runId} (${target.agent}):\n\n${followUp}`, 500, { source: "async-resume", runId: target.runId, agent: target.agent, index: target.index });
932
+ if (delivered) {
933
+ return {
934
+ content: [{ type: "text", text: [`Interrupted live async child, then delivered follow-up.`, `Run: ${target.runId}`, `Intercom target: ${target.intercomTarget}`].join("\n") }],
935
+ details: { mode: "management", results: [] },
936
+ };
937
+ }
938
+ return {
939
+ content: [{ type: "text", text: [`Async child appears live but its intercom target is not registered.`, `Run: ${target.runId}`, `Intercom target: ${target.intercomTarget}`, `Wait for completion, then retry action='resume'.`].join("\n") }],
940
+ isError: true,
941
+ details: { mode: "management", results: [] },
942
+ };
943
+ }
944
+ const { blocked, depth, maxDepth } = checkSubagentDepth(input.deps.config.maxSubagentDepth);
945
+ if (blocked) {
946
+ return {
947
+ content: [{ type: "text", text: `Nested subagent resume blocked (depth=${depth}, max=${maxDepth}). Complete the follow-up directly instead.` }],
948
+ isError: true,
949
+ details: { mode: "management", results: [] },
950
+ };
951
+ }
952
+ input.deps.state.currentSessionId = resolveCurrentSessionId(input.ctx.sessionManager);
953
+ const effectiveCwd = target.cwd ?? input.requestCwd;
954
+ const modelScope = undefined;
955
+ const sessionName = resolveIntercomSessionTarget(input.deps.pi.getSessionName(), input.ctx.sessionManager.getSessionId());
956
+ const intercomBridge = resolveIntercomBridge({
957
+ config: input.deps.config.intercomBridge,
958
+ context: input.params.context,
959
+ orchestratorTarget: sessionName,
960
+ });
961
+ const recoveryDescriptor = "recoveryDescriptor" in target ? target.recoveryDescriptor : undefined;
962
+ if (attachChain) {
963
+ if (target.source !== "async") {
964
+ return {
965
+ content: [{ type: "text", text: "Attaching a running subagent as a chain root is currently available for async runs only." }],
966
+ isError: true,
967
+ details: { mode: "management", results: [] },
968
+ };
969
+ }
970
+ if (!isAsyncAvailable()) {
971
+ return {
972
+ content: [{ type: "text", text: "Async mode requires upstream jiti for TypeScript execution but it could not be found. Ensure the pi-subagents package dependencies are installed." }],
973
+ isError: true,
974
+ details: { mode: "chain", results: [] },
975
+ };
976
+ }
977
+ const runId = randomUUID().slice(0, 8);
978
+ const artifactConfig = { ...DEFAULT_ARTIFACT_CONFIG, enabled: input.params.artifacts !== false };
979
+ const availableModels = input.ctx.modelRegistry.getAvailable().map(toModelInfo);
980
+ const contextPolicy = resolveExplicitContextPolicy(input.params);
981
+ const workflowTask = (input.params.task ?? followUp) || undefined;
982
+ const goal = resolveAsyncEventGoal(workflowTask, attachChain);
983
+ const chain = wrapChainTasksForFork(attachChain, contextPolicy);
984
+ const normalized = normalizeSkillInput(input.params.skill);
985
+ const result = executeAsyncChain(runId, {
986
+ chain,
987
+ task: workflowTask,
988
+ goal,
989
+ attachRoot: {
990
+ runId: target.runId,
991
+ asyncDir: target.asyncDir ?? path.join(ASYNC_DIR, target.runId),
992
+ resultPath: resolveAsyncRootResultPath(RESULTS_DIR, target.runId),
993
+ index: target.index,
994
+ agent: target.agent,
995
+ label: `Attached ${target.runId}`,
996
+ },
997
+ ctx: {
998
+ pi: input.deps.pi,
999
+ cwd: input.requestCwd,
1000
+ currentSessionId: input.deps.state.currentSessionId,
1001
+ parentSessionId: input.ctx.sessionManager.getSessionId() ?? undefined,
1002
+ currentModelProvider: input.ctx.model?.provider,
1003
+ currentModel: input.ctx.model,
1004
+ modelScope,
1005
+ },
1006
+ availableModels,
1007
+ cwd: effectiveCwd,
1008
+ maxOutput: input.params.maxOutput,
1009
+ artifactsDir: getArtifactsDir(parentSessionFile, effectiveCwd),
1010
+ artifactConfig,
1011
+ shareEnabled: input.params.share === true,
1012
+ sessionRoot: input.deps.getSubagentSessionRoot(parentSessionFile),
1013
+ chainSkills: normalized === false ? [] : (normalized ?? []),
1014
+ dynamicFanoutMaxItems: input.deps.config.chain?.dynamicFanout?.maxItems,
1015
+ maxSubagentDepth: resolveCurrentMaxSubagentDepth(input.deps.config.maxSubagentDepth),
1016
+ waitToolEnabled: input.deps.waitToolEnabled,
1017
+ worktreeSetupHook: input.deps.config.worktreeSetupHook,
1018
+ worktreeSetupHookTimeoutMs: input.deps.config.worktreeSetupHookTimeoutMs,
1019
+ worktreeBaseDir: input.deps.config.worktreeBaseDir,
1020
+ controlConfig: resolveControlConfig(input.deps.config.control, input.params.control),
1021
+ controlIntercomTarget: intercomBridge.active ? intercomBridge.orchestratorTarget : undefined,
1022
+ childIntercomTarget: intercomBridge.active ? (agent, index) => resolveSubagentIntercomTarget(runId, agent, index) : undefined,
1023
+ globalConcurrencyLimit: input.deps.config.globalConcurrencyLimit,
1024
+ });
1025
+ if (result.isError)
1026
+ return result;
1027
+ const attachedId = result.details.asyncId ?? runId;
1028
+ const lines = [
1029
+ `Attached async subagent ${target.runId} as the first step of a new chain.`,
1030
+ `Chain run: ${attachedId}`,
1031
+ `Root: ${target.agent} (step ${target.index + 1})`,
1032
+ result.details.asyncDir ? `Async dir: ${result.details.asyncDir}` : undefined,
1033
+ `Status if needed: subagent({ action: "status", id: "${attachedId}" })`,
1034
+ ].filter((line) => Boolean(line));
1035
+ return { content: [{ type: "text", text: formatAsyncStartedMessage(lines.join("\n")) }], details: result.details };
1036
+ }
1037
+ const runId = randomUUID().slice(0, 8);
1038
+ const artifactConfig = recoveryDescriptor?.artifactConfig ?? { ...DEFAULT_ARTIFACT_CONFIG, enabled: input.params.artifacts !== false };
1039
+ const artifactsDir = recoveryDescriptor?.artifactsDir ?? getArtifactsDir(parentSessionFile, effectiveCwd);
1040
+ const availableModels = input.ctx.modelRegistry.getAvailable().map(toModelInfo);
1041
+ let recoverySpec;
1042
+ try {
1043
+ recoverySpec = normalizeChildSpec({
1044
+ task: buildRevivedAsyncTask(target, followUp),
1045
+ description: recoveryDescriptor?.description ?? target.description ?? target.agent,
1046
+ permissions: recoveryDescriptor?.permissions ?? target.permissions ?? "read-only",
1047
+ model: input.params.model ?? recoveryDescriptor?.model ?? target.model,
1048
+ skill: recoveryDescriptor?.skills,
1049
+ cwd: effectiveCwd,
1050
+ output: recoveryDescriptor?.outputPath,
1051
+ outputMode: recoveryDescriptor?.outputMode,
1052
+ acceptance: input.params.acceptance ?? recoveryDescriptor?.acceptance,
1053
+ toolBudget: recoveryDescriptor?.initialToolBudget,
1054
+ }, {
1055
+ parentMode: snapshotParentPermissionMode(input.deps.state.currentSessionId),
1056
+ runId,
1057
+ index: 0,
1058
+ childId: recoveryDescriptor?.childId ?? target.childId ?? `${runId}-0`,
1059
+ });
1060
+ }
1061
+ catch (error) {
1062
+ return { content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }], isError: true, details: { mode: "management", results: [] } };
1063
+ }
1064
+ const result = executeAsyncSingle(runId, {
1065
+ spec: recoverySpec,
1066
+ goal: followUp,
1067
+ ctx: {
1068
+ pi: input.deps.pi,
1069
+ cwd: input.requestCwd,
1070
+ currentSessionId: input.deps.state.currentSessionId,
1071
+ parentSessionId: input.ctx.sessionManager.getSessionId() ?? undefined,
1072
+ currentModelProvider: input.ctx.model?.provider,
1073
+ currentModel: input.ctx.model,
1074
+ modelScope,
1075
+ },
1076
+ cwd: effectiveCwd,
1077
+ maxOutput: input.params.maxOutput ?? recoveryDescriptor?.maxOutput,
1078
+ artifactsDir,
1079
+ artifactConfig,
1080
+ shareEnabled: recoveryDescriptor?.share ?? input.params.share === true,
1081
+ sessionRoot: input.deps.getSubagentSessionRoot(parentSessionFile),
1082
+ ...(recoveryDescriptor?.sessionDir ? { sessionDir: recoveryDescriptor.sessionDir } : {}),
1083
+ sessionFile: target.sessionFile,
1084
+ revivalLease: {
1085
+ sessionFile: target.sessionFile,
1086
+ runId,
1087
+ sourceRunId: target.runId,
1088
+ ...(input.deps.state.currentSessionId ? { parentSessionId: input.deps.state.currentSessionId } : {}),
1089
+ },
1090
+ modelOverride: input.params.model ?? recoveryDescriptor?.model ?? target.model,
1091
+ thinkingOverride: input.params.model ? undefined : recoveryDescriptor?.thinking ?? target.thinking,
1092
+ outputBaseDir: resolveSingleRunOutputBaseDir(input.deps, artifactsDir, runId),
1093
+ maxSubagentDepth: recoveryDescriptor?.maxSubagentDepth ?? resolveCurrentMaxSubagentDepth(input.deps.config.maxSubagentDepth),
1094
+ waitToolEnabled: input.deps.waitToolEnabled,
1095
+ worktreeSetupHook: input.deps.config.worktreeSetupHook,
1096
+ worktreeSetupHookTimeoutMs: input.deps.config.worktreeSetupHookTimeoutMs,
1097
+ worktreeBaseDir: input.deps.config.worktreeBaseDir,
1098
+ controlConfig: recoveryDescriptor?.controlConfig ?? resolveControlConfig(input.deps.config.control, input.params.control),
1099
+ controlIntercomTarget: intercomBridge.active ? intercomBridge.orchestratorTarget : undefined,
1100
+ childIntercomTarget: intercomBridge.active ? (agent, index) => resolveSubagentIntercomTarget(runId, agent, index) : undefined,
1101
+ availableModels,
1102
+ output: recoveryDescriptor?.outputPath,
1103
+ outputMode: recoveryDescriptor?.outputMode,
1104
+ ...(recoveryDescriptor?.skills ? { skills: [...recoveryDescriptor.skills] } : {}),
1105
+ ...(recoveryDescriptor?.acceptance !== undefined && input.params.acceptance === undefined ? { acceptance: recoveryDescriptor.acceptance } : {}),
1106
+ ...(input.params.timeoutMs !== undefined ? { timeoutMs: input.params.timeoutMs } : {}),
1107
+ ...(input.absoluteDeadlineAt !== undefined ? { absoluteDeadlineAt: input.absoluteDeadlineAt } : {}),
1108
+ ...(input.params.turnBudget !== undefined ? { turnBudget: input.params.turnBudget } : {}),
1109
+ ...(input.params.toolBudget !== undefined ? { toolBudget: input.params.toolBudget } : {}),
1110
+ });
1111
+ if (result.isError)
1112
+ return result;
1113
+ const revivedId = result.details.asyncId ?? runId;
1114
+ const revivedTarget = intercomBridge.active ? resolveSubagentIntercomTarget(revivedId, target.agent, 0) : undefined;
1115
+ const sourceLabel = target.source;
1116
+ const lines = [
1117
+ `Revived ${sourceLabel} subagent from ${target.runId}.`,
1118
+ `Revived run: ${revivedId}`,
1119
+ `Agent: ${target.agent}`,
1120
+ `Session: ${target.sessionFile}`,
1121
+ result.details.asyncDir ? `Async dir: ${result.details.asyncDir}` : undefined,
1122
+ revivedTarget ? `Intercom target: ${revivedTarget} (if registered)` : undefined,
1123
+ `Status if needed: subagent({ action: "status", id: "${revivedId}" })`,
1124
+ ].filter((line) => Boolean(line));
1125
+ return { content: [{ type: "text", text: formatAsyncStartedMessage(lines.join("\n")) }], details: result.details };
1126
+ }
1127
+ function resultSummaryForIntercom(result) {
1128
+ const output = getSingleResultOutput(result);
1129
+ if (result.exitCode !== 0 && result.error) {
1130
+ return output ? `${result.error}\n\nOutput:\n${output}` : result.error;
1131
+ }
1132
+ return output || result.error || "(no output)";
1133
+ }
1134
+ function formatFailedSingleRunOutput(result, displayOutput) {
1135
+ const error = result.error || "Failed";
1136
+ const output = displayOutput.trim();
1137
+ const lines = [error];
1138
+ if (output && output !== error.trim()) {
1139
+ lines.push("", "Output:", output);
1140
+ }
1141
+ if (result.artifactPaths?.outputPath) {
1142
+ lines.push("", `Output artifact: ${result.artifactPaths.outputPath}`);
1143
+ }
1144
+ return lines.join("\n");
1145
+ }
1146
+ function createForegroundControlNotifier(data, deps) {
1147
+ return (event) => emitControlNotification({
1148
+ pi: deps.pi,
1149
+ controlConfig: data.controlConfig,
1150
+ intercomBridge: data.intercomBridge,
1151
+ event,
1152
+ });
1153
+ }
1154
+ async function emitForegroundResultIntercom(input) {
1155
+ if (!input.intercomBridge.active || !input.intercomBridge.orchestratorTarget)
1156
+ return null;
1157
+ const children = input.results.flatMap((result, index) => result.detached ? [] : [{
1158
+ agent: result.agent,
1159
+ status: resolveSubagentResultStatus({
1160
+ exitCode: result.exitCode,
1161
+ interrupted: result.interrupted,
1162
+ detached: result.detached,
1163
+ }),
1164
+ summary: resultSummaryForIntercom(result),
1165
+ index,
1166
+ artifactPath: result.artifactPaths?.outputPath,
1167
+ sessionPath: result.sessionFile,
1168
+ intercomTarget: resolveSubagentIntercomTarget(input.runId, result.agent, index),
1169
+ }]);
1170
+ if (children.length === 0)
1171
+ return null;
1172
+ const payload = buildSubagentResultIntercomPayload({
1173
+ to: input.intercomBridge.orchestratorTarget,
1174
+ runId: input.runId,
1175
+ mode: input.mode,
1176
+ source: "foreground",
1177
+ children: attachNestedChildrenToResultChildren(input.runId, children, input.nestedChildren),
1178
+ ...(typeof input.chainSteps === "number" ? { chainSteps: input.chainSteps } : {}),
1179
+ });
1180
+ const delivered = await deliverSubagentResultIntercomEvent(input.pi.events, payload);
1181
+ if (!delivered)
1182
+ return null;
1183
+ return payload;
1184
+ }
1185
+ async function maybeBuildForegroundIntercomReceipt(input) {
1186
+ const payload = await emitForegroundResultIntercom({
1187
+ pi: input.pi,
1188
+ intercomBridge: input.intercomBridge,
1189
+ runId: input.runId,
1190
+ mode: input.mode,
1191
+ results: input.details.results,
1192
+ ...(typeof input.details.totalSteps === "number" ? { chainSteps: input.details.totalSteps } : {}),
1193
+ ...(input.nestedChildren?.length ? { nestedChildren: input.nestedChildren } : {}),
1194
+ });
1195
+ if (!payload)
1196
+ return null;
1197
+ return {
1198
+ text: formatSubagentResultReceipt({ mode: input.mode, runId: input.runId, payload }),
1199
+ details: stripDetailsOutputsForIntercomReceipt(input.details),
1200
+ };
1201
+ }
1202
+ function validateExecutionInput(params, hasChain, hasTasks, hasSingle, allowClarifyTaskPrompt) {
1203
+ if (Number(hasChain) + Number(hasTasks) + Number(hasSingle) !== 1) {
1204
+ return {
1205
+ content: [
1206
+ {
1207
+ type: "text",
1208
+ text: "Provide exactly one mode: { task, description, permissions? }, { tasks: [...] }, or { chain: [...] }.",
1209
+ },
1210
+ ],
1211
+ isError: true,
1212
+ details: { mode: "single", results: [] },
1213
+ };
1214
+ }
1215
+ const acceptanceErrors = validateExecutionAcceptance(params);
1216
+ if (acceptanceErrors.length > 0) {
1217
+ return {
1218
+ content: [{ type: "text", text: acceptanceErrors.join(" ") }],
1219
+ isError: true,
1220
+ details: { mode: getRequestedModeLabel(params), results: [] },
1221
+ };
1222
+ }
1223
+ if (hasSingle && !params.description) {
1224
+ return {
1225
+ content: [{ type: "text", text: "description is required and must be a concise single-line label (max 80 characters)." }],
1226
+ isError: true,
1227
+ details: { mode: "single", results: [] },
1228
+ };
1229
+ }
1230
+ if (hasTasks && params.tasks) {
1231
+ for (let i = 0; i < params.tasks.length; i++) {
1232
+ const task = params.tasks[i];
1233
+ if (!task.description) {
1234
+ return {
1235
+ content: [{ type: "text", text: `description is required (task ${i + 1})` }],
1236
+ isError: true,
1237
+ details: { mode: "parallel", results: [] },
1238
+ };
1239
+ }
1240
+ }
1241
+ }
1242
+ if (hasChain && params.chain) {
1243
+ if (params.chain.length === 0) {
1244
+ return {
1245
+ content: [{ type: "text", text: "Chain must have at least one step" }],
1246
+ isError: true,
1247
+ details: { mode: "chain", results: [] },
1248
+ };
1249
+ }
1250
+ const firstStep = params.chain[0];
1251
+ if (isParallelStep(firstStep)) {
1252
+ const missingTaskIndex = firstStep.parallel.findIndex((t) => !t.task);
1253
+ if (missingTaskIndex !== -1) {
1254
+ return {
1255
+ content: [{ type: "text", text: `First parallel step: task ${missingTaskIndex + 1} must have a task (no previous output to reference)` }],
1256
+ isError: true,
1257
+ details: { mode: "chain", results: [] },
1258
+ };
1259
+ }
1260
+ }
1261
+ else if (isDynamicParallelStep(firstStep)) {
1262
+ return {
1263
+ content: [{ type: "text", text: "First step in chain cannot be dynamic fanout; expand.from requires a prior structured named output" }],
1264
+ isError: true,
1265
+ details: { mode: "chain", results: [] },
1266
+ };
1267
+ }
1268
+ else if (!firstStep.task && !params.task && !allowClarifyTaskPrompt) {
1269
+ return {
1270
+ content: [{ type: "text", text: "First step in chain must have a task" }],
1271
+ isError: true,
1272
+ details: { mode: "chain", results: [] },
1273
+ };
1274
+ }
1275
+ for (let i = 0; i < params.chain.length; i++) {
1276
+ const step = params.chain[i];
1277
+ if (!isParallelStep(step) && !isDynamicParallelStep(step) && !step.description) {
1278
+ return {
1279
+ content: [{ type: "text", text: `description is required (step ${i + 1})` }],
1280
+ isError: true,
1281
+ details: { mode: "chain", results: [] },
1282
+ };
1283
+ }
1284
+ if (isParallelStep(step)) {
1285
+ const missing = step.parallel.findIndex((t) => !t.description);
1286
+ if (missing !== -1) {
1287
+ return {
1288
+ content: [{ type: "text", text: `description is required (step ${i + 1}, parallel task ${missing + 1})` }],
1289
+ isError: true,
1290
+ details: { mode: "chain", results: [] },
1291
+ };
1292
+ }
1293
+ }
1294
+ if (isParallelStep(step) && step.parallel.length === 0) {
1295
+ return {
1296
+ content: [{ type: "text", text: `Parallel step ${i + 1} must have at least one task` }],
1297
+ isError: true,
1298
+ details: { mode: "chain", results: [] },
1299
+ };
1300
+ }
1301
+ }
1302
+ }
1303
+ return null;
1304
+ }
1305
+ function validateExecutionChainBindings(params, dynamicFanoutMaxItems) {
1306
+ if ((params.chain?.length ?? 0) === 0)
1307
+ return null;
1308
+ try {
1309
+ validateChainOutputBindingsWithContext(params.chain, { maxItems: dynamicFanoutMaxItems });
1310
+ }
1311
+ catch (error) {
1312
+ if (error instanceof ChainOutputValidationError) {
1313
+ return {
1314
+ content: [{ type: "text", text: error.message }],
1315
+ isError: true,
1316
+ details: { mode: "chain", results: [] },
1317
+ };
1318
+ }
1319
+ throw error;
1320
+ }
1321
+ return null;
1322
+ }
1323
+ function getRequestedModeLabel(params) {
1324
+ if ((params.chain?.length ?? 0) > 0)
1325
+ return "chain";
1326
+ if ((params.tasks?.length ?? 0) > 0)
1327
+ return "parallel";
1328
+ if (params.task)
1329
+ return "single";
1330
+ return "single";
1331
+ }
1332
+ function resolveAgentDefaultContextPolicy(params) {
1333
+ // lunr: hide fork from the model; force every child to fresh. Fork internals stay.
1334
+ return lunrContextPolicy(params);
1335
+ }
1336
+ function resolveExplicitContextPolicy(params) {
1337
+ // lunr: `context: "fork"` from the model is coerced to fresh.
1338
+ return lunrContextPolicy(params);
1339
+ }
1340
+ function shouldForkAgent(contextPolicy, agentName) {
1341
+ return contextPolicy.contextForAgent(agentName) === "fork";
1342
+ }
1343
+ function buildRequestedModeError(params, message) {
1344
+ return withForkContext({
1345
+ content: [{ type: "text", text: message }],
1346
+ isError: true,
1347
+ details: { mode: getRequestedModeLabel(params), results: [] },
1348
+ }, params.context);
1349
+ }
1350
+ function runtimeConfigFromChildSpec(spec) {
1351
+ return {
1352
+ name: spec.childId,
1353
+ description: spec.description,
1354
+ model: spec.model,
1355
+ thinking: undefined,
1356
+ systemPromptMode: "append",
1357
+ inheritProjectContext: true,
1358
+ inheritSkills: false,
1359
+ acceptanceRole: spec.effectivePermissions === "read-only" ? "read-only" : "writer",
1360
+ systemPrompt: "",
1361
+ skills: spec.skill === false ? [] : normalizeSkillInput(spec.skill) || undefined,
1362
+ output: typeof spec.output === "string" ? spec.output : undefined,
1363
+ toolBudget: spec.toolBudget,
1364
+ };
1365
+ }
1366
+ function internalizePromptDrivenChildren(params, options) {
1367
+ const agents = [];
1368
+ let flatIndex = 0;
1369
+ const normalize = (input, defaultTask) => {
1370
+ const spec = normalizeChildSpec(input, {
1371
+ parentMode: options.parentMode,
1372
+ runId: options.runId,
1373
+ index: flatIndex,
1374
+ defaultTask,
1375
+ });
1376
+ agents.push(runtimeConfigFromChildSpec(spec));
1377
+ return { input: { ...input, agent: spec.childId }, spec };
1378
+ };
1379
+ if ((params.tasks?.length ?? 0) > 0) {
1380
+ const tasks = params.tasks.map((task) => {
1381
+ const normalized = normalize(task);
1382
+ flatIndex++;
1383
+ return normalized.input;
1384
+ });
1385
+ return { params: { ...params, tasks }, agents };
1386
+ }
1387
+ if ((params.chain?.length ?? 0) > 0) {
1388
+ const chain = params.chain.map((step) => {
1389
+ if (isParallelStep(step)) {
1390
+ const parallel = step.parallel.map((task) => {
1391
+ const normalized = normalize(task, flatIndex === 0 ? params.task : "{previous}");
1392
+ flatIndex++;
1393
+ return normalized.input;
1394
+ });
1395
+ return { ...step, parallel };
1396
+ }
1397
+ if (isDynamicParallelStep(step)) {
1398
+ const normalized = normalize(step.parallel, "{previous}");
1399
+ const reserved = step.expand.maxItems ?? options.dynamicFanoutMaxItems ?? 1;
1400
+ flatIndex += Math.max(1, reserved);
1401
+ return { ...step, parallel: normalized.input };
1402
+ }
1403
+ const normalized = normalize(step, flatIndex === 0 ? params.task : "{previous}");
1404
+ flatIndex++;
1405
+ return normalized.input;
1406
+ });
1407
+ return { params: { ...params, chain }, agents };
1408
+ }
1409
+ const normalized = normalize({
1410
+ agent: params.agent,
1411
+ task: params.task ?? "",
1412
+ description: params.description,
1413
+ permissions: params.permissions,
1414
+ cwd: params.cwd,
1415
+ model: params.model,
1416
+ tier: params.tier,
1417
+ skill: params.skill,
1418
+ output: params.output,
1419
+ outputMode: params.outputMode,
1420
+ acceptance: params.acceptance,
1421
+ toolBudget: params.toolBudget,
1422
+ });
1423
+ return {
1424
+ params: { ...params, agent: normalized.spec.childId },
1425
+ agents,
1426
+ };
1427
+ }
1428
+ function resolveForegroundTimeout(params) {
1429
+ const rawTimeout = params.timeoutMs;
1430
+ const rawMaxRuntime = params.maxRuntimeMs;
1431
+ if (rawTimeout === undefined && rawMaxRuntime === undefined)
1432
+ return {};
1433
+ for (const [name, value] of [["timeoutMs", rawTimeout], ["maxRuntimeMs", rawMaxRuntime]]) {
1434
+ if (value === undefined)
1435
+ continue;
1436
+ if (typeof value !== "number" || !Number.isInteger(value) || value <= 0) {
1437
+ return { error: `${name} must be a positive integer.` };
1438
+ }
1439
+ }
1440
+ if (rawTimeout !== undefined && rawMaxRuntime !== undefined && rawTimeout !== rawMaxRuntime) {
1441
+ return { error: "timeoutMs and maxRuntimeMs are aliases; provide only one value or use the same value for both." };
1442
+ }
1443
+ return { timeoutMs: rawTimeout ?? rawMaxRuntime };
1444
+ }
1445
+ function resolveToolBudget(raw, label = "toolBudget") {
1446
+ const resolved = validateToolBudgetConfig(raw, label);
1447
+ return { toolBudget: resolved.budget, error: resolved.error };
1448
+ }
1449
+ function resolveEffectiveToolBudget(input) {
1450
+ if (input.stepBudget !== undefined)
1451
+ return resolveToolBudget(input.stepBudget, "toolBudget");
1452
+ if (input.runBudget !== undefined)
1453
+ return { toolBudget: input.runBudget };
1454
+ if (input.agentBudget !== undefined)
1455
+ return resolveToolBudget(input.agentBudget, "agent.toolBudget");
1456
+ return resolveToolBudget(input.configBudget, "config.toolBudget");
1457
+ }
1458
+ function expandTopLevelTaskCounts(tasks) {
1459
+ const expanded = [];
1460
+ for (let taskIndex = 0; taskIndex < tasks.length; taskIndex++) {
1461
+ const task = tasks[taskIndex];
1462
+ const rawCount = task.count;
1463
+ if (rawCount !== undefined && (typeof rawCount !== "number" || !Number.isInteger(rawCount) || rawCount < 1)) {
1464
+ return { error: `tasks[${taskIndex}].count must be an integer >= 1` };
1465
+ }
1466
+ const { count, ...concreteTask } = task;
1467
+ for (let repeat = 0; repeat < (rawCount ?? 1); repeat++) {
1468
+ expanded.push({ ...concreteTask });
1469
+ }
1470
+ }
1471
+ return { tasks: expanded };
1472
+ }
1473
+ function expandChainParallelCounts(chain) {
1474
+ const expandedChain = [];
1475
+ for (let stepIndex = 0; stepIndex < chain.length; stepIndex++) {
1476
+ const step = chain[stepIndex];
1477
+ if (!isParallelStep(step)) {
1478
+ expandedChain.push(step);
1479
+ continue;
1480
+ }
1481
+ const expandedParallel = [];
1482
+ for (let taskIndex = 0; taskIndex < step.parallel.length; taskIndex++) {
1483
+ const task = step.parallel[taskIndex];
1484
+ const rawCount = task.count;
1485
+ if (rawCount !== undefined && (typeof rawCount !== "number" || !Number.isInteger(rawCount) || rawCount < 1)) {
1486
+ return { error: `chain[${stepIndex}].parallel[${taskIndex}].count must be an integer >= 1` };
1487
+ }
1488
+ const { count, ...concreteTask } = task;
1489
+ for (let repeat = 0; repeat < (rawCount ?? 1); repeat++) {
1490
+ expandedParallel.push({ ...concreteTask });
1491
+ }
1492
+ }
1493
+ expandedChain.push({ ...step, parallel: expandedParallel });
1494
+ }
1495
+ return { chain: expandedChain };
1496
+ }
1497
+ function normalizeRepeatedParallelCounts(params) {
1498
+ if (params.tasks) {
1499
+ const expandedTasks = expandTopLevelTaskCounts(params.tasks);
1500
+ if (expandedTasks.error) {
1501
+ return { error: buildRequestedModeError(params, expandedTasks.error) };
1502
+ }
1503
+ return { params: { ...params, tasks: expandedTasks.tasks } };
1504
+ }
1505
+ if (params.chain) {
1506
+ const expandedChain = expandChainParallelCounts(params.chain);
1507
+ if (expandedChain.error) {
1508
+ return { error: buildRequestedModeError(params, expandedChain.error) };
1509
+ }
1510
+ return { params: { ...params, chain: expandedChain.chain } };
1511
+ }
1512
+ return { params };
1513
+ }
1514
+ function withForkContext(result, context) {
1515
+ if (context !== "fork" || !result.details)
1516
+ return result;
1517
+ return {
1518
+ ...result,
1519
+ details: {
1520
+ ...result.details,
1521
+ context: "fork",
1522
+ },
1523
+ };
1524
+ }
1525
+ function withForkThinkingNotes(result, downgrades) {
1526
+ if (downgrades.size === 0)
1527
+ return result;
1528
+ const children = [...downgrades.entries()]
1529
+ .sort(([a], [b]) => a - b)
1530
+ .map(([index, agent]) => `${agent} (child ${index})`)
1531
+ .join(", ");
1532
+ const note = `Note: fork context forced thinking off for ${children}. The forked transcript contained signed Anthropic thinking blocks that were sanitized, and Anthropic children cannot resume such a transcript with thinking enabled. Use context: "fresh" when an Anthropic child needs thinking.`;
1533
+ return { ...result, content: [...result.content, { type: "text", text: note }] };
1534
+ }
1535
+ function toExecutionErrorResult(params, error) {
1536
+ const message = error instanceof Error ? error.message : String(error);
1537
+ return withForkContext({
1538
+ content: [{ type: "text", text: message }],
1539
+ isError: true,
1540
+ details: { mode: getRequestedModeLabel(params), results: [] },
1541
+ }, params.context);
1542
+ }
1543
+ function collectChainSessionFiles(chain, sessionFileForTask, dynamicFanoutMaxItems) {
1544
+ const sessionFiles = [];
1545
+ let flatIndex = 0;
1546
+ for (const step of chain) {
1547
+ if (isParallelStep(step)) {
1548
+ for (const task of step.parallel) {
1549
+ sessionFiles.push(sessionFileForTask(task.agent, flatIndex, task.model));
1550
+ flatIndex++;
1551
+ }
1552
+ continue;
1553
+ }
1554
+ if (isDynamicParallelStep(step)) {
1555
+ const maxItems = step.expand.maxItems ?? dynamicFanoutMaxItems ?? 0;
1556
+ for (let itemIndex = 0; itemIndex < maxItems; itemIndex++) {
1557
+ sessionFiles.push(sessionFileForTask(step.parallel.agent, flatIndex, step.parallel.model));
1558
+ flatIndex++;
1559
+ }
1560
+ continue;
1561
+ }
1562
+ const sequential = step;
1563
+ sessionFiles.push(sessionFileForTask(sequential.agent, flatIndex, sequential.model));
1564
+ flatIndex++;
1565
+ }
1566
+ return sessionFiles;
1567
+ }
1568
+ function collectChainThinkingOverrides(chain, thinkingOverrideForTask, dynamicFanoutMaxItems) {
1569
+ const thinkingOverrides = [];
1570
+ let flatIndex = 0;
1571
+ for (const step of chain) {
1572
+ if (isParallelStep(step)) {
1573
+ for (const task of step.parallel) {
1574
+ thinkingOverrides.push(thinkingOverrideForTask(task.agent, flatIndex, task.model));
1575
+ flatIndex++;
1576
+ }
1577
+ continue;
1578
+ }
1579
+ if (isDynamicParallelStep(step)) {
1580
+ const maxItems = step.expand.maxItems ?? dynamicFanoutMaxItems ?? 0;
1581
+ for (let itemIndex = 0; itemIndex < maxItems; itemIndex++) {
1582
+ thinkingOverrides.push(thinkingOverrideForTask(step.parallel.agent, flatIndex, step.parallel.model));
1583
+ flatIndex++;
1584
+ }
1585
+ continue;
1586
+ }
1587
+ const sequential = step;
1588
+ thinkingOverrides.push(thinkingOverrideForTask(sequential.agent, flatIndex, sequential.model));
1589
+ flatIndex++;
1590
+ }
1591
+ return thinkingOverrides;
1592
+ }
1593
+ function firstChainAgent(chain) {
1594
+ const first = chain[0];
1595
+ if (!first)
1596
+ return undefined;
1597
+ if (isParallelStep(first))
1598
+ return first.parallel[0]?.agent;
1599
+ if (isDynamicParallelStep(first))
1600
+ return first.parallel.agent;
1601
+ return first.agent;
1602
+ }
1603
+ function firstRawChainTask(chain) {
1604
+ const first = chain[0];
1605
+ if (!first)
1606
+ return undefined;
1607
+ if (isParallelStep(first))
1608
+ return first.parallel[0]?.task;
1609
+ if (isDynamicParallelStep(first))
1610
+ return first.parallel.task;
1611
+ return first.task;
1612
+ }
1613
+ function resolveAsyncEventGoal(workflowTask, rawChain, unwrapForkFallback = false) {
1614
+ if (workflowTask?.trim())
1615
+ return workflowTask;
1616
+ const fallback = firstRawChainTask(rawChain) || "";
1617
+ if (!unwrapForkFallback)
1618
+ return fallback;
1619
+ const forkPrefix = `${DEFAULT_FORK_PREAMBLE}\n\nTask:\n`;
1620
+ return fallback.startsWith(forkPrefix) ? fallback.slice(forkPrefix.length) : fallback;
1621
+ }
1622
+ function wrapChainTasksForFork(chain, contextPolicy) {
1623
+ return chain.map((step, stepIndex) => {
1624
+ if (isParallelStep(step)) {
1625
+ return {
1626
+ ...step,
1627
+ parallel: step.parallel.map((task) => ({
1628
+ ...task,
1629
+ task: shouldForkAgent(contextPolicy, task.agent)
1630
+ ? wrapForkTask(task.task ?? "{previous}")
1631
+ : task.task,
1632
+ })),
1633
+ };
1634
+ }
1635
+ if (isDynamicParallelStep(step)) {
1636
+ return {
1637
+ ...step,
1638
+ parallel: {
1639
+ ...step.parallel,
1640
+ task: shouldForkAgent(contextPolicy, step.parallel.agent)
1641
+ ? wrapForkTask(step.parallel.task ?? "{previous}")
1642
+ : step.parallel.task,
1643
+ },
1644
+ };
1645
+ }
1646
+ const sequential = step;
1647
+ return {
1648
+ ...sequential,
1649
+ task: shouldForkAgent(contextPolicy, sequential.agent)
1650
+ ? wrapForkTask(sequential.task ?? (stepIndex === 0 ? "{task}" : "{previous}"))
1651
+ : sequential.task,
1652
+ };
1653
+ });
1654
+ }
1655
+ function preflightForkSessionsForStaticTasks(params, contextPolicy, sessionFileForTask, dynamicFanoutMaxItems) {
1656
+ if (!contextPolicy.usesFork)
1657
+ return;
1658
+ if (params.agent) {
1659
+ if (shouldForkAgent(contextPolicy, params.agent))
1660
+ sessionFileForTask(params.agent, 0, params.model);
1661
+ return;
1662
+ }
1663
+ if (params.tasks) {
1664
+ params.tasks.forEach((task, index) => {
1665
+ if (shouldForkAgent(contextPolicy, task.agent))
1666
+ sessionFileForTask(task.agent, index, task.model);
1667
+ });
1668
+ return;
1669
+ }
1670
+ if (!params.chain?.length)
1671
+ return;
1672
+ let flatIndex = 0;
1673
+ for (const step of params.chain) {
1674
+ if (isParallelStep(step)) {
1675
+ for (const task of step.parallel) {
1676
+ if (shouldForkAgent(contextPolicy, task.agent))
1677
+ sessionFileForTask(task.agent, flatIndex, task.model);
1678
+ flatIndex++;
1679
+ }
1680
+ continue;
1681
+ }
1682
+ if (isDynamicParallelStep(step)) {
1683
+ const maxItems = step.expand.maxItems ?? dynamicFanoutMaxItems ?? 0;
1684
+ if (shouldForkAgent(contextPolicy, step.parallel.agent)) {
1685
+ for (let itemIndex = 0; itemIndex < maxItems; itemIndex++)
1686
+ sessionFileForTask(step.parallel.agent, flatIndex + itemIndex, step.parallel.model);
1687
+ }
1688
+ flatIndex += maxItems;
1689
+ continue;
1690
+ }
1691
+ const sequential = step;
1692
+ if (shouldForkAgent(contextPolicy, sequential.agent))
1693
+ sessionFileForTask(sequential.agent, flatIndex, sequential.model);
1694
+ flatIndex++;
1695
+ }
1696
+ }
1697
+ function runAsyncPath(data, deps) {
1698
+ const { params, effectiveCwd, agents, ctx, shareEnabled, sessionRoot, sessionFileForIndex, sessionFileForTask, thinkingOverrideForTask, artifactConfig, artifactsDir, effectiveAsync, controlConfig, intercomBridge, nestedRoute, contextPolicy, } = data;
1699
+ const hasChain = (params.chain?.length ?? 0) > 0;
1700
+ const hasTasks = (params.tasks?.length ?? 0) > 0;
1701
+ const hasSingle = !hasChain && !hasTasks && Boolean(params.agent);
1702
+ if (!effectiveAsync)
1703
+ return null;
1704
+ if (hasChain && params.chain) {
1705
+ const chainWorktreeTaskCwdError = buildChainWorktreeTaskCwdError(params.chain, effectiveCwd);
1706
+ if (chainWorktreeTaskCwdError) {
1707
+ return {
1708
+ content: [{ type: "text", text: chainWorktreeTaskCwdError }],
1709
+ isError: true,
1710
+ details: { mode: "chain", results: [] },
1711
+ };
1712
+ }
1713
+ }
1714
+ if (hasTasks && params.tasks) {
1715
+ const maxParallelTasks = resolveTopLevelParallelMaxTasks(deps.config.parallel?.maxTasks);
1716
+ if (params.tasks.length > maxParallelTasks) {
1717
+ return buildParallelModeError(`Max ${maxParallelTasks} tasks`);
1718
+ }
1719
+ if (params.worktree) {
1720
+ const worktreeTaskCwdError = buildParallelWorktreeTaskCwdError(params.tasks, effectiveCwd);
1721
+ if (worktreeTaskCwdError)
1722
+ return buildParallelModeError(worktreeTaskCwdError);
1723
+ }
1724
+ }
1725
+ if (!isAsyncAvailable()) {
1726
+ return {
1727
+ content: [{ type: "text", text: "Async mode requires upstream jiti for TypeScript execution but it could not be found. Ensure the pi-subagents package dependencies are installed." }],
1728
+ isError: true,
1729
+ details: { mode: "single", results: [] },
1730
+ };
1731
+ }
1732
+ const id = randomUUID();
1733
+ const asyncCtx = {
1734
+ pi: deps.pi,
1735
+ cwd: ctx.cwd,
1736
+ currentSessionId: deps.state.currentSessionId,
1737
+ parentSessionId: ctx.sessionManager.getSessionId() ?? undefined,
1738
+ currentModelProvider: ctx.model?.provider,
1739
+ currentModel: ctx.model,
1740
+ modelScope: data.modelScope,
1741
+ };
1742
+ const availableModels = ctx.modelRegistry.getAvailable().map(toModelInfo);
1743
+ const currentMaxSubagentDepth = resolveCurrentMaxSubagentDepth(deps.config.maxSubagentDepth);
1744
+ const currentProvider = ctx.model?.provider;
1745
+ const controlIntercomTarget = intercomBridge.active ? intercomBridge.orchestratorTarget : undefined;
1746
+ const childIntercomTarget = intercomBridge.active ? (agent, index) => resolveSubagentIntercomTarget(id, agent, index) : undefined;
1747
+ if (hasTasks && params.tasks) {
1748
+ const skillOverrides = params.tasks.map((task) => normalizeSkillInput(task.skill));
1749
+ const parallelTasks = params.tasks.map((task, index) => ({
1750
+ agent: task.agent,
1751
+ task: shouldForkAgent(contextPolicy, task.agent) ? wrapForkTask(task.task) : task.task,
1752
+ cwd: task.cwd,
1753
+ ...(task.model !== undefined ? { model: task.model } : {}),
1754
+ ...(skillOverrides[index] !== undefined ? { skill: skillOverrides[index] } : {}),
1755
+ ...(task.output !== undefined && task.output !== true ? { output: task.output } : {}),
1756
+ ...(task.outputMode !== undefined ? { outputMode: task.outputMode } : {}),
1757
+ ...(task.reads !== undefined && task.reads !== true ? { reads: task.reads } : {}),
1758
+ ...(task.progress !== undefined ? { progress: task.progress } : {}),
1759
+ ...(task.toolBudget !== undefined ? { toolBudget: task.toolBudget } : {}),
1760
+ ...(task.acceptance !== undefined ? { acceptance: task.acceptance } : {}),
1761
+ }));
1762
+ return executeAsyncChain(id, {
1763
+ chain: [{
1764
+ parallel: parallelTasks,
1765
+ concurrency: resolveTopLevelParallelConcurrency(params.concurrency, deps.config.parallel?.concurrency),
1766
+ worktree: params.worktree,
1767
+ }],
1768
+ resultMode: "parallel",
1769
+ goal: params.tasks[0]?.task ?? "",
1770
+ ctx: asyncCtx,
1771
+ availableModels,
1772
+ cwd: effectiveCwd,
1773
+ maxOutput: params.maxOutput,
1774
+ artifactsDir: artifactConfig.enabled ? artifactsDir : undefined,
1775
+ artifactConfig,
1776
+ shareEnabled,
1777
+ sessionRoot,
1778
+ chainSkills: [],
1779
+ sessionFilesByFlatIndex: params.tasks.map((task, index) => sessionFileForTask(task.agent, index, task.model)),
1780
+ thinkingOverridesByFlatIndex: params.tasks.map((task, index) => thinkingOverrideForTask(task.agent, index, task.model)),
1781
+ maxSubagentDepth: currentMaxSubagentDepth,
1782
+ waitToolEnabled: deps.waitToolEnabled,
1783
+ worktreeSetupHook: deps.config.worktreeSetupHook,
1784
+ worktreeSetupHookTimeoutMs: deps.config.worktreeSetupHookTimeoutMs,
1785
+ worktreeBaseDir: deps.config.worktreeBaseDir,
1786
+ controlConfig,
1787
+ controlIntercomTarget,
1788
+ childIntercomTarget,
1789
+ nestedRoute,
1790
+ timeoutMs: data.timeoutMs,
1791
+ turnBudget: data.turnBudget,
1792
+ toolBudget: data.toolBudget,
1793
+ configToolBudget: data.configToolBudget,
1794
+ globalConcurrencyLimit: deps.config.globalConcurrencyLimit,
1795
+ });
1796
+ }
1797
+ if (hasChain && params.chain) {
1798
+ const normalized = normalizeSkillInput(params.skill);
1799
+ const chainSkills = normalized === false ? [] : (normalized ?? []);
1800
+ const rawChain = params.chain;
1801
+ const chain = wrapChainTasksForFork(rawChain, contextPolicy);
1802
+ return executeAsyncChain(id, {
1803
+ chain,
1804
+ task: params.task,
1805
+ goal: resolveAsyncEventGoal(params.task, rawChain),
1806
+ ctx: asyncCtx,
1807
+ availableModels,
1808
+ cwd: effectiveCwd,
1809
+ maxOutput: params.maxOutput,
1810
+ artifactsDir: artifactConfig.enabled ? artifactsDir : undefined,
1811
+ artifactConfig,
1812
+ shareEnabled,
1813
+ sessionRoot,
1814
+ chainSkills,
1815
+ sessionFilesByFlatIndex: collectChainSessionFiles(chain, sessionFileForTask, deps.config.chain?.dynamicFanout?.maxItems),
1816
+ thinkingOverridesByFlatIndex: collectChainThinkingOverrides(chain, thinkingOverrideForTask, deps.config.chain?.dynamicFanout?.maxItems),
1817
+ dynamicFanoutMaxItems: deps.config.chain?.dynamicFanout?.maxItems,
1818
+ maxSubagentDepth: currentMaxSubagentDepth,
1819
+ waitToolEnabled: deps.waitToolEnabled,
1820
+ worktreeSetupHook: deps.config.worktreeSetupHook,
1821
+ worktreeSetupHookTimeoutMs: deps.config.worktreeSetupHookTimeoutMs,
1822
+ worktreeBaseDir: deps.config.worktreeBaseDir,
1823
+ controlConfig,
1824
+ controlIntercomTarget,
1825
+ childIntercomTarget,
1826
+ nestedRoute,
1827
+ timeoutMs: data.timeoutMs,
1828
+ turnBudget: data.turnBudget,
1829
+ toolBudget: data.toolBudget,
1830
+ configToolBudget: data.configToolBudget,
1831
+ globalConcurrencyLimit: deps.config.globalConcurrencyLimit,
1832
+ });
1833
+ }
1834
+ if (hasSingle) {
1835
+ const a = agents.find((x) => x.name === params.agent);
1836
+ if (!a) {
1837
+ return {
1838
+ content: [{ type: "text", text: `Unknown agent: ${params.agent}` }],
1839
+ isError: true,
1840
+ details: { mode: "single", results: [] },
1841
+ };
1842
+ }
1843
+ const rawOutput = params.output !== undefined ? params.output : a.output;
1844
+ const effectiveOutput = normalizeSingleOutputOverride(rawOutput, a.output);
1845
+ const effectiveOutputMode = params.outputMode ?? "inline";
1846
+ const normalizedSkills = normalizeSkillInput(params.skill);
1847
+ const skills = normalizedSkills === false ? [] : normalizedSkills;
1848
+ const maxSubagentDepth = resolveChildMaxSubagentDepth(currentMaxSubagentDepth, a.maxSubagentDepth);
1849
+ // lunr: model tiers — explicit model wins; otherwise resolve params.tier via the tier bridge.
1850
+ const modelOverride = resolveEffectiveSubagentModel(params.model ?? resolveTierModelOverride(params.tier), a.model, ctx.model, availableModels, currentProvider, { scope: data.modelScope });
1851
+ const spec = normalizeChildSpec({
1852
+ task: shouldForkAgent(contextPolicy, params.agent) ? wrapForkTask(params.task ?? "") : (params.task ?? ""),
1853
+ description: params.description,
1854
+ permissions: params.permissions,
1855
+ model: modelOverride,
1856
+ tier: params.tier,
1857
+ skill: params.skill,
1858
+ cwd: effectiveCwd,
1859
+ output: effectiveOutput,
1860
+ outputMode: effectiveOutputMode,
1861
+ acceptance: params.acceptance,
1862
+ toolBudget: params.toolBudget,
1863
+ }, {
1864
+ parentMode: snapshotParentPermissionMode(deps.state.currentSessionId),
1865
+ runId: id,
1866
+ index: 0,
1867
+ childId: params.agent,
1868
+ });
1869
+ return executeAsyncSingle(id, {
1870
+ spec,
1871
+ goal: params.task ?? "",
1872
+ ctx: asyncCtx,
1873
+ availableModels,
1874
+ cwd: effectiveCwd,
1875
+ maxOutput: params.maxOutput,
1876
+ artifactsDir: artifactConfig.enabled ? artifactsDir : undefined,
1877
+ artifactConfig,
1878
+ shareEnabled,
1879
+ sessionRoot,
1880
+ sessionFile: sessionFileForTask(params.agent, 0, modelOverride),
1881
+ skills,
1882
+ output: effectiveOutput,
1883
+ outputMode: effectiveOutputMode,
1884
+ outputBaseDir: resolveSingleRunOutputBaseDir(deps, artifactsDir, id),
1885
+ modelOverride,
1886
+ thinkingOverride: thinkingOverrideForTask(params.agent, 0, modelOverride),
1887
+ maxSubagentDepth,
1888
+ waitToolEnabled: deps.waitToolEnabled,
1889
+ worktreeSetupHook: deps.config.worktreeSetupHook,
1890
+ worktreeSetupHookTimeoutMs: deps.config.worktreeSetupHookTimeoutMs,
1891
+ worktreeBaseDir: deps.config.worktreeBaseDir,
1892
+ controlConfig,
1893
+ controlIntercomTarget,
1894
+ childIntercomTarget: childIntercomTarget ? (agent, index) => childIntercomTarget(agent, index) : undefined,
1895
+ nestedRoute,
1896
+ acceptance: params.acceptance,
1897
+ timeoutMs: data.timeoutMs,
1898
+ turnBudget: data.turnBudget,
1899
+ toolBudget: data.toolBudget,
1900
+ configToolBudget: data.configToolBudget,
1901
+ });
1902
+ }
1903
+ return null;
1904
+ }
1905
+ async function runChainPath(data, deps) {
1906
+ const { params, effectiveCwd, agents, ctx, signal, runId, shareEnabled, sessionDirForIndex, sessionFileForIndex, sessionFileForTask, thinkingOverrideForTask, artifactsDir, artifactConfig, onUpdate, sessionRoot, controlConfig, contextPolicy, } = data;
1907
+ const onControlEvent = createForegroundControlNotifier(data, deps);
1908
+ const childIntercomTarget = data.intercomBridge.active ? resolveSubagentIntercomTarget : undefined;
1909
+ const foregroundControl = deps.state.foregroundControls.get(runId);
1910
+ const normalized = normalizeSkillInput(params.skill);
1911
+ const chainSkills = normalized === false ? [] : (normalized ?? []);
1912
+ const chain = wrapChainTasksForFork(params.chain, contextPolicy);
1913
+ const currentMaxSubagentDepth = resolveCurrentMaxSubagentDepth(deps.config.maxSubagentDepth);
1914
+ const chainResult = await executeChain({
1915
+ chain,
1916
+ task: params.task,
1917
+ agents,
1918
+ ctx,
1919
+ modelScope: data.modelScope,
1920
+ intercomEvents: deps.pi.events,
1921
+ signal,
1922
+ runId,
1923
+ cwd: effectiveCwd,
1924
+ shareEnabled,
1925
+ sessionDirForIndex,
1926
+ sessionFileForIndex,
1927
+ sessionFileForTask,
1928
+ thinkingOverrideForTask,
1929
+ artifactsDir,
1930
+ artifactConfig,
1931
+ includeProgress: params.includeProgress,
1932
+ clarify: params.clarify,
1933
+ onUpdate,
1934
+ onControlEvent,
1935
+ controlConfig,
1936
+ childIntercomTarget: childIntercomTarget ? (agent, index) => childIntercomTarget(runId, agent, index) : undefined,
1937
+ orchestratorIntercomTarget: data.intercomBridge.active ? data.intercomBridge.orchestratorTarget : undefined,
1938
+ foregroundControl,
1939
+ nestedRoute: foregroundControl?.nestedRoute,
1940
+ chainSkills,
1941
+ chainDir: params.chainDir ?? getProjectChainRunsDir(effectiveCwd),
1942
+ dynamicFanoutMaxItems: deps.config.chain?.dynamicFanout?.maxItems,
1943
+ maxSubagentDepth: currentMaxSubagentDepth,
1944
+ worktreeSetupHook: deps.config.worktreeSetupHook,
1945
+ worktreeSetupHookTimeoutMs: deps.config.worktreeSetupHookTimeoutMs,
1946
+ worktreeBaseDir: deps.config.worktreeBaseDir,
1947
+ timeoutMs: data.timeoutMs,
1948
+ deadlineAt: data.deadlineAt,
1949
+ turnBudget: data.turnBudget,
1950
+ onDetachedExit: (index, result) => updateRememberedForegroundChild(deps.state, { runId, mode: "chain", cwd: effectiveCwd, sessionId: data.parentSessionId, index, result, events: deps.pi.events }),
1951
+ toolBudget: data.toolBudget,
1952
+ configToolBudget: data.configToolBudget,
1953
+ globalConcurrencyLimit: deps.config.globalConcurrencyLimit,
1954
+ });
1955
+ if (chainResult.requestedAsync) {
1956
+ if (!isAsyncAvailable()) {
1957
+ return {
1958
+ content: [{ type: "text", text: "Background mode requires upstream jiti for TypeScript execution but it could not be found. Ensure the pi-subagents package dependencies are installed." }],
1959
+ isError: true,
1960
+ details: { mode: "chain", results: [] },
1961
+ };
1962
+ }
1963
+ const id = randomUUID();
1964
+ const asyncCtx = {
1965
+ pi: deps.pi,
1966
+ cwd: ctx.cwd,
1967
+ currentSessionId: deps.state.currentSessionId,
1968
+ parentSessionId: ctx.sessionManager.getSessionId() ?? undefined,
1969
+ currentModelProvider: ctx.model?.provider,
1970
+ currentModel: ctx.model,
1971
+ modelScope: data.modelScope,
1972
+ };
1973
+ const rawAsyncChain = chainResult.requestedAsync.chain;
1974
+ const asyncChain = wrapChainTasksForFork(rawAsyncChain, contextPolicy);
1975
+ const firstAgent = firstChainAgent(rawAsyncChain);
1976
+ return executeAsyncChain(id, {
1977
+ chain: asyncChain,
1978
+ task: params.task,
1979
+ goal: resolveAsyncEventGoal(params.task, rawAsyncChain, firstAgent ? shouldForkAgent(contextPolicy, firstAgent) : false),
1980
+ ctx: asyncCtx,
1981
+ availableModels: ctx.modelRegistry.getAvailable().map(toModelInfo),
1982
+ cwd: effectiveCwd,
1983
+ maxOutput: params.maxOutput,
1984
+ artifactsDir: artifactConfig.enabled ? artifactsDir : undefined,
1985
+ artifactConfig,
1986
+ shareEnabled,
1987
+ sessionRoot,
1988
+ chainSkills: chainResult.requestedAsync.chainSkills,
1989
+ sessionFilesByFlatIndex: collectChainSessionFiles(asyncChain, sessionFileForTask, deps.config.chain?.dynamicFanout?.maxItems),
1990
+ thinkingOverridesByFlatIndex: collectChainThinkingOverrides(asyncChain, thinkingOverrideForTask, deps.config.chain?.dynamicFanout?.maxItems),
1991
+ dynamicFanoutMaxItems: deps.config.chain?.dynamicFanout?.maxItems,
1992
+ maxSubagentDepth: currentMaxSubagentDepth,
1993
+ waitToolEnabled: deps.waitToolEnabled,
1994
+ worktreeSetupHook: deps.config.worktreeSetupHook,
1995
+ worktreeSetupHookTimeoutMs: deps.config.worktreeSetupHookTimeoutMs,
1996
+ worktreeBaseDir: deps.config.worktreeBaseDir,
1997
+ controlConfig,
1998
+ controlIntercomTarget: data.intercomBridge.active ? data.intercomBridge.orchestratorTarget : undefined,
1999
+ childIntercomTarget: data.intercomBridge.active ? (agent, index) => resolveSubagentIntercomTarget(id, agent, index) : undefined,
2000
+ nestedRoute: data.nestedRoute,
2001
+ timeoutMs: data.timeoutMs,
2002
+ turnBudget: data.turnBudget,
2003
+ toolBudget: data.toolBudget,
2004
+ configToolBudget: data.configToolBudget,
2005
+ globalConcurrencyLimit: deps.config.globalConcurrencyLimit,
2006
+ });
2007
+ }
2008
+ const rawChainDetails = chainResult.details ? { ...chainResult.details, runId } : undefined;
2009
+ if (foregroundControl && rawChainDetails) {
2010
+ updateForegroundNestedProjection(foregroundControl);
2011
+ attachRootChildrenToSteps(runId, rawChainDetails.results, foregroundControl.nestedChildren);
2012
+ rawChainDetails.totalCost = sumResultsCost(rawChainDetails.results);
2013
+ }
2014
+ const chainDetails = rawChainDetails ? compactForegroundDetails(rawChainDetails) : undefined;
2015
+ if (chainDetails)
2016
+ rememberForegroundRun(deps.state, { runId, mode: "chain", cwd: effectiveCwd, sessionId: data.parentSessionId, results: chainDetails.results });
2017
+ const intercomReceipt = chainDetails && !chainDetails.results.some((result) => result.interrupted || result.detached)
2018
+ ? await maybeBuildForegroundIntercomReceipt({
2019
+ pi: deps.pi,
2020
+ intercomBridge: data.intercomBridge,
2021
+ runId,
2022
+ mode: "chain",
2023
+ details: chainDetails,
2024
+ ...(foregroundControl?.nestedChildren?.length ? { nestedChildren: foregroundControl.nestedChildren } : {}),
2025
+ })
2026
+ : null;
2027
+ if (intercomReceipt) {
2028
+ return {
2029
+ ...chainResult,
2030
+ content: [{ type: "text", text: intercomReceipt.text }],
2031
+ details: intercomReceipt.details,
2032
+ };
2033
+ }
2034
+ return chainDetails ? { ...chainResult, details: chainDetails } : chainResult;
2035
+ }
2036
+ function buildParallelModeError(message) {
2037
+ return {
2038
+ content: [{ type: "text", text: message }],
2039
+ isError: true,
2040
+ details: { mode: "parallel", results: [] },
2041
+ };
2042
+ }
2043
+ function createParallelWorktreeSetup(enabled, cwd, runId, tasks, setupHook, setupHookTimeoutMs, baseDir) {
2044
+ if (!enabled)
2045
+ return {};
2046
+ try {
2047
+ return {
2048
+ setup: createWorktrees(cwd, runId, tasks.length, {
2049
+ agents: tasks.map((task) => task.agent),
2050
+ setupHook: setupHook
2051
+ ? { hookPath: setupHook, timeoutMs: setupHookTimeoutMs }
2052
+ : undefined,
2053
+ baseDir,
2054
+ }),
2055
+ };
2056
+ }
2057
+ catch (error) {
2058
+ const message = error instanceof Error ? error.message : String(error);
2059
+ return { errorResult: buildParallelModeError(message) };
2060
+ }
2061
+ }
2062
+ function buildParallelWorktreeTaskCwdError(tasks, sharedCwd) {
2063
+ const conflict = findWorktreeTaskCwdConflict(tasks, sharedCwd);
2064
+ if (!conflict)
2065
+ return undefined;
2066
+ return formatWorktreeTaskCwdConflict(conflict, sharedCwd);
2067
+ }
2068
+ function resolveSingleRunOutputBaseDir(deps, artifactsDir, runId) {
2069
+ return deps.config.singleRunOutputBaseDir
2070
+ ? path.resolve(deps.expandTilde(deps.config.singleRunOutputBaseDir))
2071
+ : path.join(artifactsDir, "outputs", runId);
2072
+ }
2073
+ function buildChainWorktreeTaskCwdError(chain, sharedCwd) {
2074
+ for (let stepIndex = 0; stepIndex < chain.length; stepIndex++) {
2075
+ const step = chain[stepIndex];
2076
+ if (!isParallelStep(step) || !step.worktree)
2077
+ continue;
2078
+ const stepCwd = resolveChildCwd(sharedCwd, step.cwd);
2079
+ const conflict = findWorktreeTaskCwdConflict(step.parallel, stepCwd);
2080
+ if (!conflict)
2081
+ continue;
2082
+ const detail = formatWorktreeTaskCwdConflict(conflict, stepCwd);
2083
+ return `parallel chain step ${stepIndex + 1}: ${detail}`;
2084
+ }
2085
+ return undefined;
2086
+ }
2087
+ function resolveParallelTaskCwd(task, paramsCwd, worktreeSetup, index) {
2088
+ if (worktreeSetup)
2089
+ return worktreeSetup.worktrees[index].agentCwd;
2090
+ return resolveChildCwd(paramsCwd, task.cwd);
2091
+ }
2092
+ function buildParallelWorktreeSuffix(worktreeSetup, artifactsDir, tasks) {
2093
+ if (!worktreeSetup)
2094
+ return "";
2095
+ const diffsDir = path.join(artifactsDir, "worktree-diffs");
2096
+ const diffs = diffWorktrees(worktreeSetup, tasks.map((task) => task.agent), diffsDir);
2097
+ return formatWorktreeDiffSummary(diffs);
2098
+ }
2099
+ function findDuplicateParallelOutputPath(input) {
2100
+ const seen = new Map();
2101
+ for (let index = 0; index < input.tasks.length; index++) {
2102
+ const behavior = input.behaviors[index];
2103
+ if (!behavior?.output)
2104
+ continue;
2105
+ const task = input.tasks[index];
2106
+ const taskCwd = resolveParallelTaskCwd(task, input.paramsCwd, input.worktreeSetup, index);
2107
+ const outputPath = resolveSingleOutputPath(behavior.output, input.ctxCwd, taskCwd, input.outputBaseDir);
2108
+ if (!outputPath)
2109
+ continue;
2110
+ const previous = seen.get(outputPath);
2111
+ if (previous) {
2112
+ return `Parallel tasks ${previous.index + 1} (${previous.agent}) and ${index + 1} (${task.agent}) resolve output to the same path: ${outputPath}. Use distinct output paths.`;
2113
+ }
2114
+ seen.set(outputPath, { index, agent: task.agent });
2115
+ }
2116
+ return undefined;
2117
+ }
2118
+ async function runForegroundParallelTasks(input) {
2119
+ // Pre-warm fork session files sequentially before concurrent dispatch to avoid
2120
+ // races where multiple workers simultaneously try to branch the same parent session.
2121
+ for (let i = 0; i < input.tasks.length; i++) {
2122
+ input.sessionFileForTask(input.tasks[i].agent, i, input.modelOverrides[i]);
2123
+ }
2124
+ return mapConcurrent(input.tasks, input.concurrencyLimit, async (task, index) => {
2125
+ const behavior = input.behaviors[index];
2126
+ const effectiveSkills = behavior?.skills;
2127
+ const taskCwd = resolveParallelTaskCwd(task, input.paramsCwd, input.worktreeSetup, index);
2128
+ const readInstructions = behavior
2129
+ ? buildChainInstructions({ ...behavior, output: false, progress: false }, taskCwd, false)
2130
+ : { prefix: "", suffix: "" };
2131
+ const progressInstructions = behavior
2132
+ ? buildChainInstructions({ ...behavior, output: false, reads: false }, input.progressDir, index === input.firstProgressIndex)
2133
+ : { prefix: "", suffix: "" };
2134
+ const outputPath = resolveSingleOutputPath(behavior?.output, input.ctx.cwd, taskCwd, input.outputBaseDir);
2135
+ const agentConfig = input.agents.find((agent) => agent.name === task.agent);
2136
+ const taskText = injectSingleOutputInstruction(`${readInstructions.prefix}${input.taskTexts[index]}${progressInstructions.suffix}`, outputPath, agentConfig);
2137
+ const interruptController = new AbortController();
2138
+ if (input.foregroundControl) {
2139
+ input.foregroundControl.currentAgent = task.description || task.agent;
2140
+ input.foregroundControl.currentChildId = task.agent;
2141
+ input.foregroundControl.currentIndex = index;
2142
+ input.foregroundControl.currentActivityState = undefined;
2143
+ input.foregroundControl.updatedAt = Date.now();
2144
+ input.foregroundControl.interrupt = () => {
2145
+ if (interruptController.signal.aborted)
2146
+ return false;
2147
+ interruptController.abort();
2148
+ input.foregroundControl.currentActivityState = undefined;
2149
+ input.foregroundControl.updatedAt = Date.now();
2150
+ return true;
2151
+ };
2152
+ }
2153
+ return runSync(input.ctx.cwd, normalizeChildSpec({
2154
+ task: taskText,
2155
+ description: task.description,
2156
+ permissions: task.permissions,
2157
+ model: input.modelOverrides[index] ?? task.model,
2158
+ skill: task.skill,
2159
+ cwd: taskCwd,
2160
+ output: task.output,
2161
+ outputMode: task.outputMode,
2162
+ acceptance: task.acceptance,
2163
+ toolBudget: task.toolBudget,
2164
+ }, { parentMode: snapshotParentPermissionMode(input.ctx.sessionManager.getSessionId() ?? undefined), runId: input.runId, index }), {
2165
+ parentSessionId: input.ctx.sessionManager.getSessionId() ?? undefined,
2166
+ cwd: taskCwd,
2167
+ signal: input.signal,
2168
+ interruptSignal: interruptController.signal,
2169
+ allowIntercomDetach: agentConfig?.systemPrompt?.includes(INTERCOM_BRIDGE_MARKER) === true,
2170
+ intercomEvents: input.intercomEvents,
2171
+ runId: input.runId,
2172
+ index,
2173
+ sessionDir: input.sessionDirForIndex(index),
2174
+ sessionFile: input.sessionFileForTask(task.agent, index, input.modelOverrides[index]),
2175
+ share: input.shareEnabled,
2176
+ artifactsDir: input.artifactConfig.enabled ? input.artifactsDir : undefined,
2177
+ artifactConfig: input.artifactConfig,
2178
+ maxOutput: input.maxOutput,
2179
+ outputPath,
2180
+ outputMode: behavior?.outputMode,
2181
+ maxSubagentDepth: input.maxSubagentDepths[index],
2182
+ waitToolEnabled: input.waitToolEnabled,
2183
+ controlConfig: input.controlConfig,
2184
+ onControlEvent: input.onControlEvent,
2185
+ onDetachedExit: (result) => updateRememberedForegroundChild(input.state, { runId: input.runId, mode: "parallel", cwd: taskCwd, sessionId: input.parentSessionId, index, result, events: input.intercomEvents }),
2186
+ intercomSessionName: input.childIntercomTarget?.(task.agent, index),
2187
+ orchestratorIntercomTarget: input.orchestratorIntercomTarget,
2188
+ nestedRoute: input.foregroundControl?.nestedRoute,
2189
+ modelOverride: input.modelOverrides[index],
2190
+ thinkingOverride: input.thinkingOverrideForTask(task.agent, index, input.modelOverrides[index]),
2191
+ availableModels: input.availableModels,
2192
+ preferredModelProvider: input.ctx.model?.provider,
2193
+ modelScope: input.modelScope,
2194
+ skills: effectiveSkills === false ? [] : effectiveSkills,
2195
+ acceptance: task.acceptance,
2196
+ acceptanceContext: { mode: "parallel" },
2197
+ timeoutMs: input.timeoutMs,
2198
+ deadlineAt: input.deadlineAt,
2199
+ turnBudget: input.turnBudget,
2200
+ toolBudget: input.toolBudgets[index],
2201
+ onUpdate: input.onUpdate
2202
+ ? (progressUpdate) => {
2203
+ const stepResults = progressUpdate.details?.results || [];
2204
+ const stepProgress = progressUpdate.details?.progress || [];
2205
+ if (input.foregroundControl && stepProgress.length > 0) {
2206
+ const current = stepProgress[0];
2207
+ input.foregroundControl.currentAgent = task.description || task.agent;
2208
+ input.foregroundControl.currentChildId = task.agent;
2209
+ input.foregroundControl.currentIndex = index;
2210
+ input.foregroundControl.currentActivityState = current?.activityState;
2211
+ input.foregroundControl.lastActivityAt = current?.lastActivityAt;
2212
+ input.foregroundControl.currentTool = current?.currentTool;
2213
+ input.foregroundControl.currentToolStartedAt = current?.currentToolStartedAt;
2214
+ input.foregroundControl.currentPath = current?.currentPath;
2215
+ input.foregroundControl.turnCount = current?.turnCount;
2216
+ input.foregroundControl.tokens = current?.tokens;
2217
+ input.foregroundControl.toolCount = current?.toolCount;
2218
+ input.foregroundControl.updatedAt = Date.now();
2219
+ }
2220
+ if (stepResults.length > 0)
2221
+ input.liveResults[index] = stepResults[0];
2222
+ if (stepProgress.length > 0)
2223
+ input.liveProgress[index] = stepProgress[0];
2224
+ const mergedResults = input.liveResults.filter((result) => result !== undefined);
2225
+ const mergedProgress = input.liveProgress.filter((progress) => progress !== undefined);
2226
+ input.onUpdate?.({
2227
+ content: progressUpdate.content,
2228
+ details: {
2229
+ mode: "parallel",
2230
+ results: mergedResults,
2231
+ progress: mergedProgress,
2232
+ controlEvents: progressUpdate.details?.controlEvents,
2233
+ totalSteps: input.tasks.length,
2234
+ },
2235
+ });
2236
+ }
2237
+ : undefined,
2238
+ }).finally(() => {
2239
+ if (input.foregroundControl?.currentIndex === index) {
2240
+ input.foregroundControl.interrupt = undefined;
2241
+ input.foregroundControl.updatedAt = Date.now();
2242
+ }
2243
+ });
2244
+ }, input.globalSemaphore);
2245
+ }
2246
+ async function runParallelPath(data, deps) {
2247
+ const { params, effectiveCwd, agents, ctx, signal, runId, sessionDirForIndex, sessionFileForIndex, sessionFileForTask, thinkingOverrideForTask, shareEnabled, artifactConfig, artifactsDir, backgroundRequestedWhileClarifying, onUpdate, sessionRoot, controlConfig, contextPolicy, } = data;
2248
+ const onControlEvent = createForegroundControlNotifier(data, deps);
2249
+ const childIntercomTarget = data.intercomBridge.active ? resolveSubagentIntercomTarget : undefined;
2250
+ const allProgress = [];
2251
+ const allArtifactPaths = [];
2252
+ const tasks = params.tasks;
2253
+ const maxParallelTasks = resolveTopLevelParallelMaxTasks(deps.config.parallel?.maxTasks);
2254
+ const parallelConcurrency = resolveTopLevelParallelConcurrency(params.concurrency, deps.config.parallel?.concurrency);
2255
+ if (tasks.length > maxParallelTasks)
2256
+ return {
2257
+ content: [{ type: "text", text: `Max ${maxParallelTasks} tasks` }],
2258
+ isError: true,
2259
+ details: { mode: "parallel", results: [] },
2260
+ };
2261
+ const agentConfigs = [];
2262
+ for (const t of tasks) {
2263
+ const config = agents.find((a) => a.name === t.agent);
2264
+ if (!config) {
2265
+ return {
2266
+ content: [{ type: "text", text: `Unknown agent: ${t.agent}` }],
2267
+ isError: true,
2268
+ details: { mode: "parallel", results: [] },
2269
+ };
2270
+ }
2271
+ agentConfigs.push(config);
2272
+ }
2273
+ const currentMaxSubagentDepth = resolveCurrentMaxSubagentDepth(deps.config.maxSubagentDepth);
2274
+ const maxSubagentDepths = agentConfigs.map((config) => resolveChildMaxSubagentDepth(currentMaxSubagentDepth, config.maxSubagentDepth));
2275
+ const toolBudgets = [];
2276
+ for (let index = 0; index < tasks.length; index++) {
2277
+ const resolved = resolveEffectiveToolBudget({ stepBudget: tasks[index]?.toolBudget, runBudget: data.toolBudget, agentBudget: agentConfigs[index]?.toolBudget, configBudget: data.configToolBudget });
2278
+ if (resolved.error)
2279
+ return buildParallelModeError(resolved.error);
2280
+ toolBudgets.push(resolved.toolBudget);
2281
+ }
2282
+ if (params.worktree) {
2283
+ const worktreeTaskCwdError = buildParallelWorktreeTaskCwdError(tasks, effectiveCwd);
2284
+ if (worktreeTaskCwdError)
2285
+ return buildParallelModeError(worktreeTaskCwdError);
2286
+ }
2287
+ const currentProvider = ctx.model?.provider;
2288
+ const availableModels = ctx.modelRegistry.getAvailable().map(toModelInfo);
2289
+ let taskTexts = tasks.map((t) => t.task);
2290
+ const skillOverrides = tasks.map((t) => normalizeSkillInput(t.skill));
2291
+ const behaviorOverrides = tasks.map((task, index) => ({
2292
+ ...(task.output !== undefined && task.output !== true ? { output: task.output } : {}),
2293
+ ...(task.outputMode !== undefined ? { outputMode: task.outputMode } : {}),
2294
+ ...(task.reads !== undefined && task.reads !== true ? { reads: task.reads } : {}),
2295
+ ...(task.progress !== undefined ? { progress: task.progress } : {}),
2296
+ ...(skillOverrides[index] !== undefined ? { skills: skillOverrides[index] } : {}),
2297
+ ...(task.model !== undefined ? { model: task.model } : {}),
2298
+ }));
2299
+ const modelOverrides = tasks.map((task, i) =>
2300
+ // lunr: model tiers — explicit per-task model wins; otherwise resolve task.tier via the tier bridge.
2301
+ resolveEffectiveSubagentModel(behaviorOverrides[i]?.model ?? resolveTierModelOverride(task.tier), agentConfigs[i]?.model, ctx.model, availableModels, currentProvider, { scope: data.modelScope }));
2302
+ if (params.clarify === true && ctx.hasUI) {
2303
+ const behaviors = agentConfigs.map((_c, i) => resolveStepBehavior(behaviorOverrides[i]));
2304
+ const availableSkills = discoverAvailableSkills(effectiveCwd);
2305
+ const result = await ctx.ui.custom((tui, theme, _kb, done) => new ChainClarifyComponent(tui, theme, agentConfigs, taskTexts, "", undefined, behaviors, availableModels, currentProvider, availableSkills, done, "parallel"), { overlay: true, overlayOptions: { anchor: "center", width: 84, maxHeight: "80%" } });
2306
+ if (!result || !result.confirmed) {
2307
+ return { content: [{ type: "text", text: "Cancelled" }], details: { mode: "parallel", results: [] } };
2308
+ }
2309
+ taskTexts = result.templates;
2310
+ for (let i = 0; i < result.behaviorOverrides.length; i++) {
2311
+ const override = result.behaviorOverrides[i];
2312
+ if (override?.model !== undefined) {
2313
+ modelOverrides[i] = resolveEffectiveSubagentModel(override.model, agentConfigs[i]?.model, ctx.model, availableModels, currentProvider, { scope: data.modelScope });
2314
+ behaviorOverrides[i].model = override.model;
2315
+ }
2316
+ if (override?.output !== undefined)
2317
+ behaviorOverrides[i].output = override.output;
2318
+ if (override?.reads !== undefined)
2319
+ behaviorOverrides[i].reads = override.reads;
2320
+ if (override?.progress !== undefined)
2321
+ behaviorOverrides[i].progress = override.progress;
2322
+ if (override?.skills !== undefined) {
2323
+ skillOverrides[i] = override.skills;
2324
+ behaviorOverrides[i].skills = override.skills;
2325
+ }
2326
+ }
2327
+ if (result.runInBackground) {
2328
+ if (!isAsyncAvailable()) {
2329
+ return {
2330
+ content: [{ type: "text", text: "Background mode requires upstream jiti for TypeScript execution but it could not be found. Ensure the pi-subagents package dependencies are installed." }],
2331
+ isError: true,
2332
+ details: { mode: "parallel", results: [] },
2333
+ };
2334
+ }
2335
+ const id = randomUUID();
2336
+ const asyncCtx = {
2337
+ pi: deps.pi,
2338
+ cwd: ctx.cwd,
2339
+ currentSessionId: deps.state.currentSessionId,
2340
+ parentSessionId: ctx.sessionManager.getSessionId() ?? undefined,
2341
+ currentModelProvider: ctx.model?.provider,
2342
+ currentModel: ctx.model,
2343
+ modelScope: data.modelScope,
2344
+ };
2345
+ const parallelTasks = tasks.map((t, i) => {
2346
+ const taskText = shouldForkAgent(contextPolicy, t.agent) ? wrapForkTask(taskTexts[i]) : taskTexts[i];
2347
+ const progress = taskDisallowsFileUpdates(taskText) ? false : behaviorOverrides[i]?.progress;
2348
+ return {
2349
+ agent: t.agent,
2350
+ task: taskText,
2351
+ cwd: t.cwd,
2352
+ ...(behaviorOverrides[i]?.model !== undefined ? { model: behaviorOverrides[i].model } : {}),
2353
+ ...(skillOverrides[i] !== undefined ? { skill: skillOverrides[i] } : {}),
2354
+ ...(behaviorOverrides[i]?.output !== undefined ? { output: behaviorOverrides[i].output } : {}),
2355
+ ...(behaviorOverrides[i]?.outputMode !== undefined ? { outputMode: behaviorOverrides[i].outputMode } : {}),
2356
+ ...(behaviorOverrides[i]?.reads !== undefined ? { reads: behaviorOverrides[i].reads } : {}),
2357
+ ...(progress !== undefined ? { progress } : {}),
2358
+ ...(t.toolBudget !== undefined ? { toolBudget: t.toolBudget } : {}),
2359
+ ...(t.acceptance !== undefined ? { acceptance: t.acceptance } : {}),
2360
+ };
2361
+ });
2362
+ return executeAsyncChain(id, {
2363
+ chain: [{ parallel: parallelTasks, concurrency: parallelConcurrency, worktree: params.worktree }],
2364
+ resultMode: "parallel",
2365
+ goal: taskTexts[0] ?? "",
2366
+ ctx: asyncCtx,
2367
+ availableModels,
2368
+ cwd: effectiveCwd,
2369
+ maxOutput: params.maxOutput,
2370
+ artifactsDir: artifactConfig.enabled ? artifactsDir : undefined,
2371
+ artifactConfig,
2372
+ shareEnabled,
2373
+ sessionRoot,
2374
+ chainSkills: [],
2375
+ sessionFilesByFlatIndex: tasks.map((task, index) => sessionFileForTask(task.agent, index, modelOverrides[index])),
2376
+ thinkingOverridesByFlatIndex: tasks.map((task, index) => thinkingOverrideForTask(task.agent, index, modelOverrides[index])),
2377
+ maxSubagentDepth: currentMaxSubagentDepth,
2378
+ waitToolEnabled: deps.waitToolEnabled,
2379
+ worktreeSetupHook: deps.config.worktreeSetupHook,
2380
+ worktreeSetupHookTimeoutMs: deps.config.worktreeSetupHookTimeoutMs,
2381
+ worktreeBaseDir: deps.config.worktreeBaseDir,
2382
+ controlConfig,
2383
+ controlIntercomTarget: data.intercomBridge.active ? data.intercomBridge.orchestratorTarget : undefined,
2384
+ childIntercomTarget: data.intercomBridge.active ? (agent, index) => resolveSubagentIntercomTarget(id, agent, index) : undefined,
2385
+ timeoutMs: data.timeoutMs,
2386
+ turnBudget: data.turnBudget,
2387
+ globalConcurrencyLimit: deps.config.globalConcurrencyLimit,
2388
+ });
2389
+ }
2390
+ }
2391
+ const behaviors = agentConfigs.map((_config, index) => suppressProgressForReadOnlyTask(resolveStepBehavior(behaviorOverrides[index]), taskTexts[index]));
2392
+ const firstProgressIndex = behaviors.findIndex((behavior) => behavior.progress);
2393
+ const liveResults = new Array(tasks.length).fill(undefined);
2394
+ const liveProgress = new Array(tasks.length).fill(undefined);
2395
+ const foregroundControl = deps.state.foregroundControls.get(runId);
2396
+ const { setup: worktreeSetup, errorResult } = createParallelWorktreeSetup(params.worktree, effectiveCwd, runId, tasks, deps.config.worktreeSetupHook, deps.config.worktreeSetupHookTimeoutMs, deps.config.worktreeBaseDir);
2397
+ if (errorResult)
2398
+ return errorResult;
2399
+ try {
2400
+ const outputBaseDir = path.join(artifactsDir, "outputs", runId);
2401
+ const duplicateOutputError = findDuplicateParallelOutputPath({
2402
+ tasks,
2403
+ behaviors,
2404
+ paramsCwd: effectiveCwd,
2405
+ ctxCwd: ctx.cwd,
2406
+ outputBaseDir,
2407
+ worktreeSetup,
2408
+ });
2409
+ if (duplicateOutputError)
2410
+ return buildParallelModeError(duplicateOutputError);
2411
+ for (let index = 0; index < tasks.length; index++) {
2412
+ const taskCwd = resolveParallelTaskCwd(tasks[index], effectiveCwd, worktreeSetup, index);
2413
+ const outputPath = resolveSingleOutputPath(behaviors[index]?.output, ctx.cwd, taskCwd, outputBaseDir);
2414
+ const validationError = validateFileOnlyOutputMode(behaviors[index]?.outputMode, outputPath, `Parallel task ${index + 1} (${tasks[index].agent})`);
2415
+ if (validationError)
2416
+ return buildParallelModeError(validationError);
2417
+ }
2418
+ const parallelProgressPrecreated = firstProgressIndex !== -1;
2419
+ const parallelProgressDir = path.join(artifactsDir, "progress", runId);
2420
+ if (parallelProgressPrecreated)
2421
+ writeInitialProgressFile(parallelProgressDir);
2422
+ for (let i = 0; i < taskTexts.length; i++) {
2423
+ if (shouldForkAgent(contextPolicy, tasks[i].agent))
2424
+ taskTexts[i] = wrapForkTask(taskTexts[i]);
2425
+ }
2426
+ const deadlineAt = data.deadlineAt ?? (data.timeoutMs !== undefined ? Date.now() + data.timeoutMs : undefined);
2427
+ const results = await runForegroundParallelTasks({
2428
+ tasks,
2429
+ taskTexts,
2430
+ agents,
2431
+ ctx,
2432
+ state: deps.state,
2433
+ intercomEvents: deps.pi.events,
2434
+ parentSessionId: data.parentSessionId,
2435
+ signal,
2436
+ runId,
2437
+ sessionDirForIndex,
2438
+ sessionFileForIndex,
2439
+ sessionFileForTask,
2440
+ thinkingOverrideForTask,
2441
+ shareEnabled,
2442
+ artifactConfig,
2443
+ artifactsDir,
2444
+ outputBaseDir,
2445
+ maxOutput: params.maxOutput,
2446
+ paramsCwd: effectiveCwd,
2447
+ progressDir: parallelProgressDir,
2448
+ availableModels,
2449
+ modelScope: data.modelScope,
2450
+ modelOverrides,
2451
+ behaviors,
2452
+ firstProgressIndex: parallelProgressPrecreated ? -1 : firstProgressIndex,
2453
+ controlConfig,
2454
+ onControlEvent,
2455
+ childIntercomTarget: childIntercomTarget ? (agent, index) => childIntercomTarget(runId, agent, index) : undefined,
2456
+ orchestratorIntercomTarget: data.intercomBridge.active ? data.intercomBridge.orchestratorTarget : undefined,
2457
+ foregroundControl,
2458
+ concurrencyLimit: parallelConcurrency,
2459
+ globalSemaphore: new Semaphore(deps.config.globalConcurrencyLimit ?? DEFAULT_GLOBAL_CONCURRENCY_LIMIT),
2460
+ maxSubagentDepths,
2461
+ waitToolEnabled: deps.waitToolEnabled,
2462
+ liveResults,
2463
+ liveProgress,
2464
+ onUpdate,
2465
+ worktreeSetup,
2466
+ timeoutMs: data.timeoutMs,
2467
+ deadlineAt,
2468
+ turnBudget: data.turnBudget,
2469
+ toolBudgets,
2470
+ });
2471
+ for (let i = 0; i < results.length; i++) {
2472
+ const run = results[i];
2473
+ recordRun(run.agent, taskTexts[i], run.exitCode, run.progressSummary?.durationMs ?? 0);
2474
+ }
2475
+ for (const result of results) {
2476
+ if (result.progress)
2477
+ allProgress.push(result.progress);
2478
+ if (result.artifactPaths)
2479
+ allArtifactPaths.push(result.artifactPaths);
2480
+ }
2481
+ if (foregroundControl) {
2482
+ updateForegroundNestedProjection(foregroundControl);
2483
+ attachRootChildrenToSteps(runId, results, foregroundControl.nestedChildren);
2484
+ }
2485
+ const interrupted = results.find((result) => result.interrupted);
2486
+ const details = compactForegroundDetails({
2487
+ mode: "parallel",
2488
+ runId,
2489
+ results,
2490
+ progress: params.includeProgress ? allProgress : undefined,
2491
+ artifacts: allArtifactPaths.length ? { dir: artifactsDir, files: allArtifactPaths } : undefined,
2492
+ totalChildUsage: sumResultsUsage(results),
2493
+ totalCost: sumResultsCost(results),
2494
+ });
2495
+ rememberForegroundRun(deps.state, { runId, mode: "parallel", cwd: effectiveCwd, sessionId: data.parentSessionId, results: details.results });
2496
+ if (interrupted) {
2497
+ return {
2498
+ content: [{ type: "text", text: `Parallel run paused after interrupt (${interrupted.agent}). Waiting for explicit next action.` }],
2499
+ details,
2500
+ };
2501
+ }
2502
+ const detachedIndex = results.findIndex((result) => result.detached);
2503
+ const detached = detachedIndex >= 0 ? results[detachedIndex] : undefined;
2504
+ if (detached) {
2505
+ return {
2506
+ content: [{ type: "text", text: `Parallel run detached for intercom coordination (${detached.agent}). Reply to the supervisor request first, then wait with subagent_wait({ id: "${runId}" }). Use subagent({ action: "status", id: "${runId}" }) to recover the result; do not resume or launch a replacement while it remains detached.` }],
2507
+ details,
2508
+ };
2509
+ }
2510
+ if (foregroundControl)
2511
+ updateForegroundNestedProjection(foregroundControl);
2512
+ const intercomReceipt = await maybeBuildForegroundIntercomReceipt({
2513
+ pi: deps.pi,
2514
+ intercomBridge: data.intercomBridge,
2515
+ runId,
2516
+ mode: "parallel",
2517
+ details,
2518
+ ...(foregroundControl?.nestedChildren?.length ? { nestedChildren: foregroundControl.nestedChildren } : {}),
2519
+ });
2520
+ if (intercomReceipt) {
2521
+ return {
2522
+ content: [{ type: "text", text: intercomReceipt.text }],
2523
+ details: intercomReceipt.details,
2524
+ };
2525
+ }
2526
+ const worktreeSuffix = buildParallelWorktreeSuffix(worktreeSetup, artifactsDir, tasks);
2527
+ const ok = results.filter((result) => result.exitCode === 0).length;
2528
+ const downgradeNote = backgroundRequestedWhileClarifying ? " (background requested, but clarify kept this run foreground)" : "";
2529
+ const aggregatedOutput = aggregateParallelOutputs(results.map((result) => ({
2530
+ agent: result.agent,
2531
+ output: result.truncation?.text || getSingleResultOutput(result),
2532
+ exitCode: result.exitCode,
2533
+ error: result.error,
2534
+ timedOut: result.timedOut,
2535
+ })), (i, agent) => `=== Task ${i + 1}: ${agent} ===`);
2536
+ const summary = `${ok}/${results.length} succeeded${downgradeNote}`;
2537
+ const fullContent = worktreeSuffix
2538
+ ? `${summary}\n\n${aggregatedOutput}\n\n${worktreeSuffix}`
2539
+ : `${summary}\n\n${aggregatedOutput}`;
2540
+ return {
2541
+ content: [{ type: "text", text: fullContent }],
2542
+ details,
2543
+ };
2544
+ }
2545
+ finally {
2546
+ if (worktreeSetup)
2547
+ cleanupWorktrees(worktreeSetup);
2548
+ }
2549
+ }
2550
+ async function runSinglePath(data, deps) {
2551
+ const { params, effectiveCwd, agents, ctx, signal, runId, sessionDirForIndex, sessionFileForTask, thinkingOverrideForTask, shareEnabled, artifactConfig, artifactsDir, onUpdate, sessionRoot, controlConfig, contextPolicy, } = data;
2552
+ const onControlEvent = createForegroundControlNotifier(data, deps);
2553
+ let spec;
2554
+ try {
2555
+ spec = normalizeChildSpec({
2556
+ task: params.task,
2557
+ description: params.description,
2558
+ permissions: params.permissions,
2559
+ model: params.model,
2560
+ tier: params.tier,
2561
+ skill: params.skill,
2562
+ cwd: effectiveCwd,
2563
+ output: params.output,
2564
+ outputMode: params.outputMode,
2565
+ acceptance: params.acceptance,
2566
+ toolBudget: params.toolBudget,
2567
+ }, { parentMode: snapshotParentPermissionMode(deps.state.currentSessionId), runId, index: 0 });
2568
+ }
2569
+ catch (error) {
2570
+ return {
2571
+ content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
2572
+ isError: true,
2573
+ details: { mode: "single", results: [] },
2574
+ };
2575
+ }
2576
+ const childIntercomTarget = data.intercomBridge.active ? resolveSubagentIntercomTarget(runId, spec.childId, 0) : undefined;
2577
+ const allProgress = [];
2578
+ const allArtifactPaths = [];
2579
+ const agentConfig = {
2580
+ name: spec.childId,
2581
+ description: spec.description,
2582
+ model: spec.model,
2583
+ output: typeof spec.output === "string" ? spec.output : undefined,
2584
+ toolBudget: spec.toolBudget,
2585
+ skills: spec.skill === false ? [] : undefined,
2586
+ systemPrompt: "",
2587
+ systemPromptMode: "append",
2588
+ inheritProjectContext: true,
2589
+ inheritSkills: false,
2590
+ };
2591
+ const effectiveToolBudget = resolveEffectiveToolBudget({ runBudget: data.toolBudget, agentBudget: spec.toolBudget, configBudget: data.configToolBudget });
2592
+ if (effectiveToolBudget.error)
2593
+ return toExecutionErrorResult(params, new Error(effectiveToolBudget.error));
2594
+ const currentProvider = ctx.model?.provider;
2595
+ const availableModels = ctx.modelRegistry.getAvailable().map(toModelInfo);
2596
+ let task = params.task ?? "";
2597
+ // lunr: model tiers — explicit model wins; otherwise resolve params.tier via the tier bridge.
2598
+ let modelOverride = resolveEffectiveSubagentModel(params.model ?? resolveTierModelOverride(params.tier), agentConfig.model, ctx.model, availableModels, currentProvider, { scope: data.modelScope });
2599
+ let skillOverride = normalizeSkillInput(params.skill);
2600
+ const rawOutput = params.output !== undefined ? params.output : agentConfig.output;
2601
+ let effectiveOutput = normalizeSingleOutputOverride(rawOutput, agentConfig.output);
2602
+ const effectiveOutputMode = params.outputMode ?? "inline";
2603
+ const currentMaxSubagentDepth = resolveCurrentMaxSubagentDepth(deps.config.maxSubagentDepth);
2604
+ const maxSubagentDepth = resolveChildMaxSubagentDepth(currentMaxSubagentDepth, agentConfig.maxSubagentDepth);
2605
+ if (params.clarify === true && ctx.hasUI) {
2606
+ const behavior = resolveStepBehavior({ output: effectiveOutput, skills: skillOverride });
2607
+ const availableSkills = discoverAvailableSkills(effectiveCwd);
2608
+ const result = await ctx.ui.custom((tui, theme, _kb, done) => new ChainClarifyComponent(tui, theme, [agentConfig], [task], task, undefined, [behavior], availableModels, currentProvider, availableSkills, done, "single"), { overlay: true, overlayOptions: { anchor: "center", width: 84, maxHeight: "80%" } });
2609
+ if (!result || !result.confirmed) {
2610
+ return { content: [{ type: "text", text: "Cancelled" }], details: { mode: "single", results: [] } };
2611
+ }
2612
+ task = result.templates[0];
2613
+ const override = result.behaviorOverrides[0];
2614
+ if (override?.model !== undefined)
2615
+ modelOverride = resolveEffectiveSubagentModel(override.model, agentConfig.model, ctx.model, availableModels, currentProvider, { scope: data.modelScope });
2616
+ if (override?.output !== undefined)
2617
+ effectiveOutput = normalizeSingleOutputOverride(override.output, agentConfig.output);
2618
+ if (override?.skills !== undefined)
2619
+ skillOverride = override.skills;
2620
+ if (result.runInBackground) {
2621
+ if (!isAsyncAvailable()) {
2622
+ return {
2623
+ content: [{ type: "text", text: "Background mode requires upstream jiti for TypeScript execution but it could not be found. Ensure the pi-subagents package dependencies are installed." }],
2624
+ isError: true,
2625
+ details: { mode: "single", results: [] },
2626
+ };
2627
+ }
2628
+ const id = randomUUID();
2629
+ const asyncCtx = {
2630
+ pi: deps.pi,
2631
+ cwd: ctx.cwd,
2632
+ currentSessionId: deps.state.currentSessionId,
2633
+ parentSessionId: ctx.sessionManager.getSessionId() ?? undefined,
2634
+ currentModelProvider: ctx.model?.provider,
2635
+ currentModel: ctx.model,
2636
+ modelScope: data.modelScope,
2637
+ };
2638
+ return executeAsyncSingle(id, {
2639
+ spec: { ...spec, task: shouldForkAgent(contextPolicy, params.agent) ? wrapForkTask(task) : task },
2640
+ goal: task,
2641
+ ctx: asyncCtx,
2642
+ availableModels,
2643
+ cwd: effectiveCwd,
2644
+ maxOutput: params.maxOutput,
2645
+ artifactsDir: artifactConfig.enabled ? artifactsDir : undefined,
2646
+ artifactConfig,
2647
+ shareEnabled,
2648
+ sessionRoot,
2649
+ sessionFile: sessionFileForTask(spec.childId, 0, modelOverride),
2650
+ skills: skillOverride === false ? [] : skillOverride,
2651
+ output: effectiveOutput,
2652
+ outputMode: effectiveOutputMode,
2653
+ outputBaseDir: resolveSingleRunOutputBaseDir(deps, artifactsDir, id),
2654
+ modelOverride,
2655
+ thinkingOverride: thinkingOverrideForTask(params.agent, 0, modelOverride),
2656
+ maxSubagentDepth,
2657
+ waitToolEnabled: deps.waitToolEnabled,
2658
+ worktreeSetupHook: deps.config.worktreeSetupHook,
2659
+ worktreeSetupHookTimeoutMs: deps.config.worktreeSetupHookTimeoutMs,
2660
+ worktreeBaseDir: deps.config.worktreeBaseDir,
2661
+ controlConfig,
2662
+ controlIntercomTarget: data.intercomBridge.active ? data.intercomBridge.orchestratorTarget : undefined,
2663
+ childIntercomTarget: data.intercomBridge.active ? (agent, index) => resolveSubagentIntercomTarget(id, agent, index) : undefined,
2664
+ timeoutMs: data.timeoutMs,
2665
+ turnBudget: data.turnBudget,
2666
+ toolBudget: effectiveToolBudget.toolBudget,
2667
+ });
2668
+ }
2669
+ }
2670
+ if (shouldForkAgent(contextPolicy, params.agent)) {
2671
+ task = wrapForkTask(task);
2672
+ }
2673
+ const cleanTask = task;
2674
+ const outputPath = resolveSingleOutputPath(effectiveOutput, ctx.cwd, effectiveCwd, resolveSingleRunOutputBaseDir(deps, artifactsDir, runId));
2675
+ const validationError = validateFileOnlyOutputMode(effectiveOutputMode, outputPath, `Single run (${params.agent})`);
2676
+ if (validationError) {
2677
+ return { content: [{ type: "text", text: validationError }], isError: true, details: { mode: "single", results: [] } };
2678
+ }
2679
+ task = injectSingleOutputInstruction(task, outputPath, agentConfig);
2680
+ let effectiveSkills;
2681
+ if (skillOverride === false) {
2682
+ effectiveSkills = [];
2683
+ }
2684
+ else {
2685
+ effectiveSkills = skillOverride;
2686
+ }
2687
+ const interruptController = new AbortController();
2688
+ const foregroundControl = deps.state.foregroundControls.get(runId);
2689
+ if (foregroundControl) {
2690
+ foregroundControl.currentAgent = params.description || params.agent;
2691
+ foregroundControl.currentChildId = params.agent;
2692
+ foregroundControl.currentIndex = 0;
2693
+ foregroundControl.currentActivityState = undefined;
2694
+ foregroundControl.updatedAt = Date.now();
2695
+ foregroundControl.interrupt = () => {
2696
+ if (interruptController.signal.aborted)
2697
+ return false;
2698
+ interruptController.abort();
2699
+ foregroundControl.currentActivityState = undefined;
2700
+ foregroundControl.updatedAt = Date.now();
2701
+ return true;
2702
+ };
2703
+ }
2704
+ const forwardSingleUpdate = onUpdate
2705
+ ? (update) => {
2706
+ if (foregroundControl) {
2707
+ const firstProgress = update.details?.progress?.[0];
2708
+ foregroundControl.currentAgent = params.description || params.agent;
2709
+ foregroundControl.currentChildId = params.agent;
2710
+ foregroundControl.currentIndex = firstProgress?.index ?? 0;
2711
+ foregroundControl.currentActivityState = firstProgress?.activityState;
2712
+ foregroundControl.lastActivityAt = firstProgress?.lastActivityAt;
2713
+ foregroundControl.currentTool = firstProgress?.currentTool;
2714
+ foregroundControl.currentToolStartedAt = firstProgress?.currentToolStartedAt;
2715
+ foregroundControl.currentPath = firstProgress?.currentPath;
2716
+ foregroundControl.turnCount = firstProgress?.turnCount;
2717
+ foregroundControl.tokens = firstProgress?.tokens;
2718
+ foregroundControl.toolCount = firstProgress?.toolCount;
2719
+ foregroundControl.updatedAt = Date.now();
2720
+ }
2721
+ onUpdate(update);
2722
+ }
2723
+ : undefined;
2724
+ const deadlineAt = data.deadlineAt ?? (data.timeoutMs !== undefined ? Date.now() + data.timeoutMs : undefined);
2725
+ const r = await runSync(ctx.cwd, { ...spec, task }, {
2726
+ parentSessionId: ctx.sessionManager.getSessionId() ?? undefined,
2727
+ cwd: effectiveCwd,
2728
+ signal,
2729
+ interruptSignal: interruptController.signal,
2730
+ allowIntercomDetach: data.intercomBridge.active,
2731
+ intercomEvents: deps.pi.events,
2732
+ runId,
2733
+ sessionDir: sessionDirForIndex(0),
2734
+ sessionFile: sessionFileForTask(spec.childId, 0, modelOverride),
2735
+ share: shareEnabled,
2736
+ artifactsDir: artifactConfig.enabled ? artifactsDir : undefined,
2737
+ artifactConfig,
2738
+ maxOutput: params.maxOutput,
2739
+ outputPath,
2740
+ outputMode: effectiveOutputMode,
2741
+ maxSubagentDepth,
2742
+ waitToolEnabled: deps.waitToolEnabled,
2743
+ onUpdate: forwardSingleUpdate,
2744
+ controlConfig,
2745
+ onControlEvent,
2746
+ intercomSessionName: childIntercomTarget,
2747
+ orchestratorIntercomTarget: data.intercomBridge.active ? data.intercomBridge.orchestratorTarget : undefined,
2748
+ nestedRoute: foregroundControl?.nestedRoute,
2749
+ index: 0,
2750
+ modelOverride,
2751
+ thinkingOverride: thinkingOverrideForTask(params.agent, 0, modelOverride),
2752
+ availableModels,
2753
+ preferredModelProvider: currentProvider,
2754
+ modelScope: data.modelScope,
2755
+ skills: effectiveSkills,
2756
+ acceptance: params.acceptance,
2757
+ acceptanceContext: { mode: "single" },
2758
+ onDetachedExit: (result) => updateRememberedForegroundChild(deps.state, { runId, mode: "single", cwd: effectiveCwd, sessionId: data.parentSessionId, index: 0, result, events: deps.pi.events }),
2759
+ timeoutMs: data.timeoutMs,
2760
+ deadlineAt,
2761
+ turnBudget: data.turnBudget,
2762
+ toolBudget: effectiveToolBudget.toolBudget,
2763
+ });
2764
+ if (foregroundControl?.currentIndex === 0) {
2765
+ foregroundControl.interrupt = undefined;
2766
+ foregroundControl.currentActivityState = r.progress?.activityState;
2767
+ foregroundControl.lastActivityAt = r.progress?.lastActivityAt;
2768
+ foregroundControl.currentTool = r.progress?.currentTool;
2769
+ foregroundControl.currentToolStartedAt = r.progress?.currentToolStartedAt;
2770
+ foregroundControl.currentPath = r.progress?.currentPath;
2771
+ foregroundControl.turnCount = r.progress?.turnCount;
2772
+ foregroundControl.tokens = r.progress?.tokens;
2773
+ foregroundControl.toolCount = r.progress?.toolCount;
2774
+ foregroundControl.updatedAt = Date.now();
2775
+ }
2776
+ recordRun(params.agent, cleanTask, r.exitCode, r.progressSummary?.durationMs ?? 0);
2777
+ if (r.progress)
2778
+ allProgress.push(r.progress);
2779
+ if (r.artifactPaths)
2780
+ allArtifactPaths.push(r.artifactPaths);
2781
+ const fullOutput = getSingleResultOutput(r);
2782
+ const finalizedOutput = finalizeSingleOutput({
2783
+ fullOutput,
2784
+ truncatedOutput: r.truncation?.text,
2785
+ outputPath,
2786
+ outputMode: r.outputMode,
2787
+ exitCode: r.exitCode,
2788
+ savedPath: r.savedOutputPath,
2789
+ outputReference: r.outputReference,
2790
+ saveError: r.outputSaveError,
2791
+ });
2792
+ if (foregroundControl) {
2793
+ updateForegroundNestedProjection(foregroundControl);
2794
+ attachRootChildrenToSteps(runId, [r], foregroundControl.nestedChildren);
2795
+ }
2796
+ const details = compactForegroundDetails({
2797
+ mode: "single",
2798
+ runId,
2799
+ results: [r],
2800
+ ...(data.turnBudget ? { turnBudget: data.turnBudget } : {}),
2801
+ ...(effectiveToolBudget.toolBudget ? { toolBudget: effectiveToolBudget.toolBudget } : {}),
2802
+ progress: params.includeProgress ? allProgress : undefined,
2803
+ artifacts: allArtifactPaths.length ? { dir: artifactsDir, files: allArtifactPaths } : undefined,
2804
+ truncation: r.truncation,
2805
+ totalChildUsage: sumResultsUsage([r]),
2806
+ totalCost: sumResultsCost([r]),
2807
+ });
2808
+ rememberForegroundRun(deps.state, { runId, mode: "single", cwd: effectiveCwd, sessionId: data.parentSessionId, results: details.results });
2809
+ if (!r.detached && !r.interrupted) {
2810
+ if (foregroundControl)
2811
+ updateForegroundNestedProjection(foregroundControl);
2812
+ const intercomReceipt = await maybeBuildForegroundIntercomReceipt({
2813
+ pi: deps.pi,
2814
+ intercomBridge: data.intercomBridge,
2815
+ runId,
2816
+ mode: "single",
2817
+ details,
2818
+ ...(foregroundControl?.nestedChildren?.length ? { nestedChildren: foregroundControl.nestedChildren } : {}),
2819
+ });
2820
+ if (intercomReceipt) {
2821
+ return {
2822
+ content: [{ type: "text", text: intercomReceipt.text }],
2823
+ details: intercomReceipt.details,
2824
+ ...(r.exitCode !== 0 ? { isError: true } : {}),
2825
+ };
2826
+ }
2827
+ }
2828
+ if (r.detached) {
2829
+ return {
2830
+ content: [{ type: "text", text: `Detached for intercom coordination: ${params.agent}. Reply to the supervisor request first, then wait with subagent_wait({ id: "${runId}" }). Use subagent({ action: "status", id: "${runId}" }) to recover the result; do not resume or launch a replacement while it remains detached.` }],
2831
+ details,
2832
+ };
2833
+ }
2834
+ if (r.interrupted) {
2835
+ return {
2836
+ content: [{ type: "text", text: `Run paused after interrupt (${params.agent}). Waiting for explicit next action.` }],
2837
+ details,
2838
+ };
2839
+ }
2840
+ if (r.exitCode !== 0)
2841
+ return {
2842
+ content: [{ type: "text", text: formatFailedSingleRunOutput(r, finalizedOutput.displayOutput) }],
2843
+ details,
2844
+ isError: true,
2845
+ };
2846
+ return {
2847
+ content: [{ type: "text", text: finalizedOutput.displayOutput || "(no output)" }],
2848
+ details,
2849
+ };
2850
+ }
2851
+ function inferExecutionMode(params) {
2852
+ if ((params.chain?.length ?? 0) > 0)
2853
+ return "chain";
2854
+ if ((params.tasks?.length ?? 0) > 0)
2855
+ return "parallel";
2856
+ return "single";
2857
+ }
2858
+ function foregroundCapacityResult(params, inFlight, limit) {
2859
+ return {
2860
+ content: [{
2861
+ type: "text",
2862
+ text: `Foreground subagent capacity reached (${inFlight}/${limit} running). Wait for a child to finish, use ONE subagent call with tasks: [{task, description}, …], or set async: true.`,
2863
+ }],
2864
+ isError: true,
2865
+ details: { mode: inferExecutionMode(params), results: [] },
2866
+ };
2867
+ }
2868
+ function omitExecutionModeActionAlias(params) {
2869
+ const action = params.action?.toLowerCase();
2870
+ if (action === "single" && params.task !== undefined) {
2871
+ const rest = { ...params };
2872
+ delete rest.action;
2873
+ return rest;
2874
+ }
2875
+ if ((action === "parallel" || action === "tasks") && (params.tasks?.length ?? 0) > 0) {
2876
+ const rest = { ...params };
2877
+ delete rest.action;
2878
+ return rest;
2879
+ }
2880
+ return params;
2881
+ }
2882
+ export function createSubagentExecutor(deps) {
2883
+ const execute = async (_id, params, signal, onUpdate, ctx) => {
2884
+ deps.state.baseCwd = ctx.cwd;
2885
+ deps.state.foregroundRuns ??= new Map();
2886
+ deps.state.foregroundControls ??= new Map();
2887
+ deps.state.lastForegroundControlId ??= null;
2888
+ const requestParams = omitExecutionModeActionAlias(params);
2889
+ const requestCwd = resolveRequestedCwd(ctx.cwd, requestParams.cwd);
2890
+ const paramsWithResolvedCwd = requestParams.cwd === undefined ? requestParams : { ...requestParams, cwd: requestCwd };
2891
+ const action = paramsWithResolvedCwd.action;
2892
+ if (action) {
2893
+ if (WATCHDOG_TOOL_ACTIONS.includes(action)) {
2894
+ if (deps.allowMutatingManagementActions === false && MUTATING_MANAGEMENT_ACTIONS.has(action)) {
2895
+ return {
2896
+ content: [{ type: "text", text: `Action '${action}' is not available from child-safe subagent fanout mode.` }],
2897
+ isError: true,
2898
+ details: { mode: "management", results: [] },
2899
+ };
2900
+ }
2901
+ return handleWatchdogToolAction(action, paramsWithResolvedCwd, ctx, deps.watchdog);
2902
+ }
2903
+ if (action === "doctor") {
2904
+ let currentSessionFile = null;
2905
+ let currentSessionId = deps.state.currentSessionId;
2906
+ let sessionError;
2907
+ try {
2908
+ currentSessionFile = ctx.sessionManager.getSessionFile() ?? null;
2909
+ currentSessionId = ctx.sessionManager.getSessionId();
2910
+ }
2911
+ catch (error) {
2912
+ sessionError = error instanceof Error ? `${error.name}: ${error.message}` : String(error);
2913
+ }
2914
+ let orchestratorTarget;
2915
+ try {
2916
+ orchestratorTarget = resolveIntercomSessionTarget(deps.pi.getSessionName(), ctx.sessionManager.getSessionId());
2917
+ }
2918
+ catch (error) {
2919
+ if (!sessionError)
2920
+ sessionError = error instanceof Error ? `${error.name}: ${error.message}` : String(error);
2921
+ }
2922
+ return {
2923
+ content: [{
2924
+ type: "text",
2925
+ text: buildDoctorReport({
2926
+ cwd: requestCwd,
2927
+ config: deps.config,
2928
+ state: deps.state,
2929
+ context: paramsWithResolvedCwd.context,
2930
+ requestedSessionDir: paramsWithResolvedCwd.sessionDir,
2931
+ currentSessionFile,
2932
+ currentSessionId,
2933
+ orchestratorTarget,
2934
+ sessionError,
2935
+ expandTilde: deps.expandTilde,
2936
+ }),
2937
+ }],
2938
+ details: { mode: "management", results: [] },
2939
+ };
2940
+ }
2941
+ if (action === "status") {
2942
+ deps.state.currentSessionId = resolveCurrentSessionId(ctx.sessionManager);
2943
+ const targetRunId = paramsWithResolvedCwd.id ?? paramsWithResolvedCwd.runId;
2944
+ const nestedScope = nestedResolutionScopeForExecutor(deps);
2945
+ const sessionRoots = trustedSessionRootsForStatus(ctx, deps);
2946
+ if (paramsWithResolvedCwd.view === "fleet") {
2947
+ return inspectSubagentStatus(paramsWithResolvedCwd, { state: deps.state, nested: nestedScope, sessionRoots });
2948
+ }
2949
+ if (targetRunId) {
2950
+ try {
2951
+ const resolved = resolveSubagentRunId(targetRunId, { state: deps.state, nested: nestedScope });
2952
+ if (resolved?.kind === "foreground") {
2953
+ const foreground = getForegroundControl(deps.state, resolved.id);
2954
+ if (foreground) {
2955
+ if (paramsWithResolvedCwd.view === "transcript") {
2956
+ return {
2957
+ content: [{ type: "text", text: "Live foreground transcript is already visible in the expanded running subagent result. Persisted session transcript becomes inspectable after the foreground run completes when sessions are enabled." }],
2958
+ details: { mode: "management", results: [] },
2959
+ };
2960
+ }
2961
+ return foregroundStatusResult(foreground);
2962
+ }
2963
+ }
2964
+ }
2965
+ catch (error) {
2966
+ const message = error instanceof Error ? error.message : String(error);
2967
+ return { content: [{ type: "text", text: message }], isError: true, details: { mode: "management", results: [] } };
2968
+ }
2969
+ }
2970
+ else {
2971
+ const foreground = getForegroundControl(deps.state, undefined);
2972
+ if (foreground && paramsWithResolvedCwd.view !== "transcript")
2973
+ return foregroundStatusResult(foreground);
2974
+ if (foreground && paramsWithResolvedCwd.view === "transcript") {
2975
+ return {
2976
+ content: [{ type: "text", text: "Live foreground transcript is already visible in the expanded running subagent result. Pass an async run id to inspect a background transcript." }],
2977
+ details: { mode: "management", results: [] },
2978
+ };
2979
+ }
2980
+ }
2981
+ return inspectSubagentStatus(paramsWithResolvedCwd, { state: deps.state, nested: nestedScope, sessionRoots });
2982
+ }
2983
+ if (action === "resume") {
2984
+ return resumeAsyncRun({ params: paramsWithResolvedCwd, requestCwd, ctx, deps });
2985
+ }
2986
+ if (action === "steer") {
2987
+ deps.state.currentSessionId = resolveCurrentSessionId(ctx.sessionManager);
2988
+ const message = (paramsWithResolvedCwd.message ?? paramsWithResolvedCwd.task ?? "").trim();
2989
+ if (!message)
2990
+ return { content: [{ type: "text", text: "action='steer' requires message." }], isError: true, details: { mode: "management", results: [] } };
2991
+ const targetRunId = paramsWithResolvedCwd.runId ?? paramsWithResolvedCwd.id;
2992
+ if (paramsWithResolvedCwd.dir) {
2993
+ try {
2994
+ const location = resolveAsyncRunLocation(paramsWithResolvedCwd, ASYNC_DIR, RESULTS_DIR);
2995
+ const runId = location.resolvedId ?? targetRunId ?? path.basename(location.asyncDir ?? paramsWithResolvedCwd.dir);
2996
+ return steerAsyncRun({ state: deps.state, runId, message, index: paramsWithResolvedCwd.index, kill: deps.kill, location, signal, recover: ({ absoluteDeadlineAt, ...limits }) => resumeAsyncRun({ params: { ...limits, action: "resume", id: runId, message }, requestCwd, ctx, deps, absoluteDeadlineAt }) });
2997
+ }
2998
+ catch (error) {
2999
+ const text = error instanceof Error ? error.message : String(error);
3000
+ return { content: [{ type: "text", text }], isError: true, details: { mode: "management", results: [] } };
3001
+ }
3002
+ }
3003
+ if (!targetRunId)
3004
+ return { content: [{ type: "text", text: "action='steer' requires id or dir." }], isError: true, details: { mode: "management", results: [] } };
3005
+ let resolved;
3006
+ try {
3007
+ resolved = resolveSubagentRunId(targetRunId, { state: deps.state, nested: nestedResolutionScopeForExecutor(deps) });
3008
+ }
3009
+ catch (error) {
3010
+ const text = error instanceof Error ? error.message : String(error);
3011
+ return { content: [{ type: "text", text }], isError: true, details: { mode: "management", results: [] } };
3012
+ }
3013
+ if (resolved?.kind === "nested")
3014
+ return steerNestedRun({ target: resolved, message, index: paramsWithResolvedCwd.index, signal });
3015
+ if (resolved?.kind === "foreground")
3016
+ return { content: [{ type: "text", text: "action='steer' currently supports live async Pi child sessions only; use action='interrupt' or action='resume' for foreground runs." }], isError: true, details: { mode: "management", results: [] } };
3017
+ if (resolved?.kind !== "async")
3018
+ return { content: [{ type: "text", text: `No async run found for '${targetRunId}'.` }], isError: true, details: { mode: "management", results: [] } };
3019
+ return steerAsyncRun({ state: deps.state, runId: resolved.id, message, index: paramsWithResolvedCwd.index, kill: deps.kill, location: resolved.location, signal, recover: ({ absoluteDeadlineAt, ...limits }) => resumeAsyncRun({ params: { ...limits, action: "resume", id: resolved.id, message }, requestCwd, ctx, deps, absoluteDeadlineAt }) });
3020
+ }
3021
+ if (action === "append-step") {
3022
+ return appendStepToAsyncChain({ params: paramsWithResolvedCwd, requestCwd, ctx, deps });
3023
+ }
3024
+ if (action === "schedule" || action === "schedule-list" || action === "schedule-status" || action === "schedule-cancel") {
3025
+ if (!deps.handleScheduledRunAction) {
3026
+ return {
3027
+ content: [{ type: "text", text: `Action '${action}' is not available in this subagent context.` }],
3028
+ isError: true,
3029
+ details: { mode: "management", results: [] },
3030
+ };
3031
+ }
3032
+ return deps.handleScheduledRunAction(paramsWithResolvedCwd, ctx);
3033
+ }
3034
+ if (action === "stop") {
3035
+ const targetRunId = paramsWithResolvedCwd.runId ?? paramsWithResolvedCwd.id;
3036
+ let resolved;
3037
+ if (paramsWithResolvedCwd.dir) {
3038
+ try {
3039
+ const location = resolveAsyncRunLocation(paramsWithResolvedCwd, ASYNC_DIR, RESULTS_DIR);
3040
+ return stopAsyncRun(deps.state, location.resolvedId ?? targetRunId ?? path.basename(location.asyncDir ?? paramsWithResolvedCwd.dir), deps.kill, location);
3041
+ }
3042
+ catch (error) {
3043
+ const text = error instanceof Error ? error.message : String(error);
3044
+ return { content: [{ type: "text", text }], isError: true, details: { mode: "management", results: [] } };
3045
+ }
3046
+ }
3047
+ if (!targetRunId)
3048
+ return { content: [{ type: "text", text: "action='stop' requires id or dir." }], isError: true, details: { mode: "management", results: [] } };
3049
+ try {
3050
+ resolved = resolveSubagentRunId(targetRunId, { state: deps.state, nested: nestedResolutionScopeForExecutor(deps) });
3051
+ }
3052
+ catch (error) {
3053
+ const message = error instanceof Error ? error.message : String(error);
3054
+ return { content: [{ type: "text", text: message }], isError: true, details: { mode: "management", results: [] } };
3055
+ }
3056
+ if (resolved?.kind === "nested")
3057
+ return { content: [{ type: "text", text: "action='stop' supports current-session top-level async runs only." }], isError: true, details: { mode: "management", results: [] } };
3058
+ if (resolved?.kind === "foreground")
3059
+ return { content: [{ type: "text", text: "action='stop' supports async runs only. Use action='interrupt' for foreground runs." }], isError: true, details: { mode: "management", results: [] } };
3060
+ const stopResult = stopAsyncRun(deps.state, resolved?.kind === "async" ? resolved.id : targetRunId, deps.kill, resolved?.kind === "async" ? resolved.location : undefined);
3061
+ if (stopResult)
3062
+ return stopResult;
3063
+ return {
3064
+ content: [{ type: "text", text: "No stoppable async run found in this session." }],
3065
+ isError: true,
3066
+ details: { mode: "management", results: [] },
3067
+ };
3068
+ }
3069
+ if (action === "interrupt") {
3070
+ const targetRunId = paramsWithResolvedCwd.runId ?? paramsWithResolvedCwd.id;
3071
+ let resolved;
3072
+ if (targetRunId) {
3073
+ try {
3074
+ resolved = resolveSubagentRunId(targetRunId, { state: deps.state, nested: nestedResolutionScopeForExecutor(deps) });
3075
+ }
3076
+ catch (error) {
3077
+ const message = error instanceof Error ? error.message : String(error);
3078
+ return { content: [{ type: "text", text: message }], isError: true, details: { mode: "management", results: [] } };
3079
+ }
3080
+ }
3081
+ if (resolved?.kind === "nested")
3082
+ return interruptNestedRun(resolved);
3083
+ const foreground = getForegroundControl(deps.state, resolved?.kind === "foreground" ? resolved.id : targetRunId);
3084
+ if (foreground?.interrupt) {
3085
+ const interrupted = foreground.interrupt();
3086
+ if (interrupted) {
3087
+ foreground.updatedAt = Date.now();
3088
+ foreground.currentActivityState = undefined;
3089
+ return {
3090
+ content: [{ type: "text", text: `Interrupt requested for foreground run ${foreground.runId}.` }],
3091
+ details: { mode: "management", results: [] },
3092
+ };
3093
+ }
3094
+ return {
3095
+ content: [{ type: "text", text: `Foreground run ${foreground.runId} has no active child step to interrupt.` }],
3096
+ isError: true,
3097
+ details: { mode: "management", results: [] },
3098
+ };
3099
+ }
3100
+ const asyncInterruptResult = interruptAsyncRun(deps.state, resolved?.kind === "async" ? resolved.id : targetRunId, deps.kill, resolved?.kind === "async" ? resolved.location : undefined);
3101
+ if (asyncInterruptResult)
3102
+ return asyncInterruptResult;
3103
+ return {
3104
+ content: [{ type: "text", text: "No interrupt-capable run found in this session." }],
3105
+ isError: true,
3106
+ details: { mode: "management", results: [] },
3107
+ };
3108
+ }
3109
+ // Every supported control action returns above. Named-agent CRUD actions are
3110
+ // intentionally absent from SUBAGENT_ACTIONS and have no fallback handler.
3111
+ return {
3112
+ content: [{ type: "text", text: `Unknown action: ${action}. Valid: ${SUBAGENT_ACTIONS.join(", ")}` }],
3113
+ isError: true,
3114
+ details: { mode: "management", results: [] },
3115
+ };
3116
+ }
3117
+ const { blocked, depth, maxDepth } = checkSubagentDepth(deps.config.maxSubagentDepth);
3118
+ if (blocked) {
3119
+ return {
3120
+ content: [
3121
+ {
3122
+ type: "text",
3123
+ text: `Nested subagent call blocked (depth=${depth}, max=${maxDepth}). ` +
3124
+ "You are running at the maximum subagent nesting depth. " +
3125
+ "Complete your current task directly without delegating to further subagents.",
3126
+ },
3127
+ ],
3128
+ isError: true,
3129
+ details: { mode: "single", results: [] },
3130
+ };
3131
+ }
3132
+ const normalized = normalizeRepeatedParallelCounts(paramsWithResolvedCwd);
3133
+ if (normalized.error)
3134
+ return normalized.error;
3135
+ const normalizedParams = normalized.params;
3136
+ let effectiveParams = applyForceTopLevelAsyncOverride(normalizedParams, depth, deps.config.forceTopLevelAsync === true);
3137
+ const runToolBudget = resolveToolBudget(effectiveParams.toolBudget, "toolBudget");
3138
+ if (runToolBudget.error)
3139
+ return buildRequestedModeError(effectiveParams, runToolBudget.error);
3140
+ const configToolBudget = resolveToolBudget(deps.config.toolBudget, "config.toolBudget");
3141
+ if (configToolBudget.error)
3142
+ return buildRequestedModeError(effectiveParams, configToolBudget.error);
3143
+ const effectiveCwd = effectiveParams.cwd ?? ctx.cwd;
3144
+ const parentSessionFile = ctx.sessionManager.getSessionFile() ?? null;
3145
+ deps.state.currentSessionId = resolveCurrentSessionId(ctx.sessionManager);
3146
+ const runId = randomUUID().slice(0, 8);
3147
+ const parentPermissionMode = snapshotParentPermissionMode(deps.state.currentSessionId);
3148
+ let internalized;
3149
+ try {
3150
+ internalized = internalizePromptDrivenChildren(effectiveParams, {
3151
+ runId,
3152
+ parentMode: parentPermissionMode,
3153
+ dynamicFanoutMaxItems: deps.config.chain?.dynamicFanout?.maxItems,
3154
+ });
3155
+ }
3156
+ catch (error) {
3157
+ return buildRequestedModeError(effectiveParams, error instanceof Error ? error.message : String(error));
3158
+ }
3159
+ effectiveParams = internalized.params;
3160
+ const discoveredAgents = internalized.agents;
3161
+ const modelScope = undefined;
3162
+ const foregroundTimeout = resolveForegroundTimeout(effectiveParams);
3163
+ if (foregroundTimeout.error)
3164
+ return buildRequestedModeError(effectiveParams, foregroundTimeout.error);
3165
+ const turnBudget = resolveTurnBudgetConfig(effectiveParams.turnBudget ?? deps.config.turnBudget);
3166
+ if (turnBudget.error)
3167
+ return buildRequestedModeError(effectiveParams, turnBudget.error);
3168
+ const contextPolicy = resolveAgentDefaultContextPolicy(effectiveParams);
3169
+ effectiveParams = contextPolicy.params;
3170
+ const sessionName = resolveIntercomSessionTarget(deps.pi.getSessionName(), ctx.sessionManager.getSessionId());
3171
+ const intercomBridge = resolveIntercomBridge({
3172
+ config: deps.config.intercomBridge,
3173
+ context: effectiveParams.context,
3174
+ orchestratorTarget: sessionName,
3175
+ });
3176
+ const agents = intercomBridge.active
3177
+ ? discoveredAgents.map((agent) => applyIntercomBridgeToAgent(agent, intercomBridge))
3178
+ : discoveredAgents;
3179
+ const inheritedNestedRoute = resolveInheritedNestedRouteFromEnv();
3180
+ const nestedParentAddress = inheritedNestedRoute ? resolveNestedParentAddressFromEnv() : undefined;
3181
+ const nestedRoute = inheritedNestedRoute ?? createNestedRoute(runId);
3182
+ const shareEnabled = effectiveParams.share === true;
3183
+ const hasChain = (effectiveParams.chain?.length ?? 0) > 0;
3184
+ const hasTasks = (effectiveParams.tasks?.length ?? 0) > 0;
3185
+ const hasSingle = !hasChain && !hasTasks && Boolean(effectiveParams.task);
3186
+ const allowClarifyTaskPrompt = hasChain
3187
+ && effectiveParams.clarify === true
3188
+ && ctx.hasUI
3189
+ && !(effectiveParams.chain?.some(isParallelStep) ?? false);
3190
+ const validationError = validateExecutionInput(effectiveParams, hasChain, hasTasks, hasSingle, allowClarifyTaskPrompt);
3191
+ if (validationError)
3192
+ return validationError;
3193
+ let forkSessionFileForIndex = () => undefined;
3194
+ let forkThinkingOverrideForIndex = () => undefined;
3195
+ let prepareForkThinking = (_agentName, _index, _modelOverride) => { };
3196
+ const forkThinkingRequirements = new Map();
3197
+ const forkThinkingDowngrades = new Map();
3198
+ try {
3199
+ const forkAvailableModels = contextPolicy.usesFork ? ctx.modelRegistry.getAvailable().map(toModelInfo) : [];
3200
+ prepareForkThinking = (agentName, index, modelOverride) => {
3201
+ const agentConfig = agents.find((agent) => agent.name === agentName);
3202
+ const primaryModel = resolveEffectiveSubagentModel(modelOverride, agentConfig?.model, ctx.model, forkAvailableModels, ctx.model?.provider);
3203
+ const candidates = buildModelCandidates(primaryModel, agentConfig?.fallbackModels, forkAvailableModels, ctx.model?.provider);
3204
+ forkThinkingRequirements.set(index, candidates.length === 0
3205
+ || candidates.some((candidate) => forkedChildRequiresThinkingOff(candidate, forkAvailableModels, ctx.model?.provider)));
3206
+ };
3207
+ const forkContextResolver = createForkContextResolver(ctx.sessionManager, contextPolicy.usesFork ? "fork" : undefined, {
3208
+ forceThinkingOffForIndex: (index) => forkThinkingRequirements.get(index) ?? true,
3209
+ });
3210
+ forkSessionFileForIndex = forkContextResolver.sessionFileForIndex;
3211
+ forkThinkingOverrideForIndex = forkContextResolver.thinkingOverrideForIndex;
3212
+ }
3213
+ catch (error) {
3214
+ return toExecutionErrorResult(effectiveParams, error);
3215
+ }
3216
+ const requestedAsync = effectiveParams.async ?? deps.asyncByDefault;
3217
+ const backgroundRequestedWhileClarifying = (hasChain || hasTasks) && requestedAsync && effectiveParams.clarify === true;
3218
+ const effectiveAsync = requestedAsync && effectiveParams.clarify !== true;
3219
+ const controlConfig = resolveControlConfig(deps.config.control, effectiveParams.control);
3220
+ const artifactConfig = {
3221
+ ...DEFAULT_ARTIFACT_CONFIG,
3222
+ enabled: effectiveParams.artifacts !== false,
3223
+ };
3224
+ const artifactsDir = getArtifactsDir(parentSessionFile, effectiveCwd);
3225
+ let sessionRoot;
3226
+ if (effectiveParams.sessionDir) {
3227
+ sessionRoot = path.resolve(deps.expandTilde(effectiveParams.sessionDir));
3228
+ }
3229
+ else {
3230
+ const baseSessionRoot = deps.config.defaultSessionDir
3231
+ ? path.resolve(deps.expandTilde(deps.config.defaultSessionDir))
3232
+ : deps.getSubagentSessionRoot(parentSessionFile);
3233
+ sessionRoot = path.join(baseSessionRoot, runId);
3234
+ }
3235
+ try {
3236
+ fs.mkdirSync(sessionRoot, { recursive: true });
3237
+ }
3238
+ catch (error) {
3239
+ const message = error instanceof Error ? error.message : String(error);
3240
+ return toExecutionErrorResult(effectiveParams, new Error(`Failed to create session directory '${sessionRoot}': ${message}`));
3241
+ }
3242
+ const sessionDirForIndex = (idx) => path.join(sessionRoot, `run-${idx ?? 0}`);
3243
+ const forkSessionFileForTask = (agentName, idx = 0, modelOverride) => {
3244
+ if (!shouldForkAgent(contextPolicy, agentName))
3245
+ return undefined;
3246
+ prepareForkThinking(agentName, idx, modelOverride);
3247
+ return forkSessionFileForIndex(idx);
3248
+ };
3249
+ const forkThinkingOverrideForTask = (agentName, idx = 0, modelOverride) => {
3250
+ if (!shouldForkAgent(contextPolicy, agentName))
3251
+ return undefined;
3252
+ prepareForkThinking(agentName, idx, modelOverride);
3253
+ const override = forkThinkingOverrideForIndex(idx);
3254
+ if (override === "off")
3255
+ forkThinkingDowngrades.set(idx, agentName);
3256
+ return override;
3257
+ };
3258
+ const childSessionFileForTask = (agentName, idx, modelOverride) => forkSessionFileForTask(agentName, idx, modelOverride) ?? path.join(sessionDirForIndex(idx), "session.jsonl");
3259
+ const childSessionFileForIndex = (idx) => path.join(sessionDirForIndex(idx), "session.jsonl");
3260
+ try {
3261
+ if (!(effectiveParams.clarify === true && ctx.hasUI)) {
3262
+ preflightForkSessionsForStaticTasks(effectiveParams, contextPolicy, forkSessionFileForTask, deps.config.chain?.dynamicFanout?.maxItems);
3263
+ }
3264
+ }
3265
+ catch (error) {
3266
+ return toExecutionErrorResult(effectiveParams, error);
3267
+ }
3268
+ const chainBindingsError = validateExecutionChainBindings(effectiveParams, deps.config.chain?.dynamicFanout?.maxItems);
3269
+ if (chainBindingsError)
3270
+ return chainBindingsError;
3271
+ const onUpdateWithContext = onUpdate
3272
+ ? (r) => onUpdate(withForkContext(r, effectiveParams.context))
3273
+ : undefined;
3274
+ const foregroundMode = hasChain ? "chain" : hasTasks ? "parallel" : "single";
3275
+ const spawnLimitError = reserveSubagentSpawns({
3276
+ state: deps.state,
3277
+ config: deps.config,
3278
+ sessionId: deps.state.currentSessionId,
3279
+ requested: countRequestedSubagentSpawns(effectiveParams, deps.config),
3280
+ mode: foregroundMode,
3281
+ });
3282
+ if (spawnLimitError)
3283
+ return spawnLimitError;
3284
+ const execData = {
3285
+ params: effectiveParams,
3286
+ effectiveCwd,
3287
+ ctx,
3288
+ signal,
3289
+ onUpdate: onUpdateWithContext,
3290
+ agents,
3291
+ runId,
3292
+ shareEnabled,
3293
+ sessionRoot,
3294
+ sessionDirForIndex,
3295
+ sessionFileForIndex: childSessionFileForIndex,
3296
+ sessionFileForTask: childSessionFileForTask,
3297
+ thinkingOverrideForTask: forkThinkingOverrideForTask,
3298
+ artifactConfig,
3299
+ artifactsDir,
3300
+ backgroundRequestedWhileClarifying,
3301
+ effectiveAsync,
3302
+ controlConfig,
3303
+ intercomBridge,
3304
+ nestedRoute,
3305
+ timeoutMs: foregroundTimeout.timeoutMs,
3306
+ turnBudget: turnBudget.turnBudget,
3307
+ toolBudget: runToolBudget.toolBudget,
3308
+ configToolBudget: configToolBudget.toolBudget,
3309
+ contextPolicy,
3310
+ modelScope,
3311
+ parentSessionId: deps.state.currentSessionId,
3312
+ };
3313
+ const foregroundControl = effectiveAsync
3314
+ ? undefined
3315
+ : {
3316
+ runId,
3317
+ mode: foregroundMode,
3318
+ startedAt: Date.now(),
3319
+ updatedAt: Date.now(),
3320
+ currentAgent: undefined,
3321
+ currentChildId: undefined,
3322
+ currentIndex: undefined,
3323
+ currentActivityState: undefined,
3324
+ nestedRoute,
3325
+ interrupt: undefined,
3326
+ };
3327
+ if (foregroundControl) {
3328
+ deps.state.foregroundControls.set(runId, foregroundControl);
3329
+ deps.state.lastForegroundControlId = runId;
3330
+ }
3331
+ const writeNestedForegroundEvent = (type, result) => {
3332
+ if (!inheritedNestedRoute || !nestedParentAddress)
3333
+ return;
3334
+ const now = Date.now();
3335
+ const details = result?.details;
3336
+ const state = type === "subagent.nested.started"
3337
+ ? "running"
3338
+ : details?.results.some((child) => child.interrupted || child.detached)
3339
+ ? "paused"
3340
+ : result?.isError || details?.results.some((child) => child.exitCode !== 0)
3341
+ ? "failed"
3342
+ : "complete";
3343
+ const errorText = result?.isError
3344
+ ? result.content.find((item) => item.type === "text")?.text
3345
+ : undefined;
3346
+ const internalChildKeys = hasTasks && effectiveParams.tasks
3347
+ ? effectiveParams.tasks.map((task) => task.agent)
3348
+ : hasChain && effectiveParams.chain
3349
+ ? effectiveParams.chain.flatMap((step) => isParallelStep(step)
3350
+ ? step.parallel.map((task) => task.agent)
3351
+ : isDynamicParallelStep(step) ? [step.parallel.agent] : [step.agent])
3352
+ : effectiveParams.agent ? [effectiveParams.agent] : [];
3353
+ const childrenForSummary = hasTasks && effectiveParams.tasks
3354
+ ? effectiveParams.tasks.map((task) => task.description || task.agent || "child")
3355
+ : hasChain && effectiveParams.chain
3356
+ ? effectiveParams.chain.flatMap(getStepAgents)
3357
+ : [effectiveParams.description || effectiveParams.agent || "child"];
3358
+ const leafIntercomTarget = intercomBridge.active && internalChildKeys[0]
3359
+ ? resolveSubagentIntercomTarget(runId, internalChildKeys[0], 0)
3360
+ : undefined;
3361
+ try {
3362
+ writeNestedEvent(inheritedNestedRoute, {
3363
+ type,
3364
+ ts: now,
3365
+ parentRunId: nestedParentAddress.parentRunId,
3366
+ parentStepIndex: nestedParentAddress.parentStepIndex,
3367
+ child: {
3368
+ id: runId,
3369
+ parentRunId: nestedParentAddress.parentRunId,
3370
+ parentStepIndex: nestedParentAddress.parentStepIndex,
3371
+ depth: nestedParentAddress.depth,
3372
+ path: nestedParentAddress.path,
3373
+ ownerIntercomTarget: process.env.PI_SUBAGENT_INTERCOM_SESSION_NAME,
3374
+ leafIntercomTarget,
3375
+ intercomTarget: leafIntercomTarget,
3376
+ ownerState: state === "running" ? "live" : "gone",
3377
+ mode: foregroundMode,
3378
+ state,
3379
+ agent: childrenForSummary[0],
3380
+ agents: childrenForSummary,
3381
+ startedAt: foregroundControl?.startedAt ?? now,
3382
+ ...(state !== "running" ? { endedAt: now } : {}),
3383
+ lastUpdate: now,
3384
+ ...(details?.totalCost ? { totalCost: details.totalCost } : {}),
3385
+ ...(errorText ? { error: errorText } : {}),
3386
+ ...(details?.results.length ? { steps: details.results.map((child) => ({
3387
+ agent: child.agent,
3388
+ status: child.interrupted || child.detached ? "paused" : child.exitCode === 0 ? "complete" : "failed",
3389
+ ...(child.sessionFile ? { sessionFile: child.sessionFile } : {}),
3390
+ ...(child.error ? { error: child.error } : {}),
3391
+ })) } : {}),
3392
+ },
3393
+ });
3394
+ }
3395
+ catch (error) {
3396
+ console.error("Failed to emit nested foreground status event:", error);
3397
+ }
3398
+ };
3399
+ let nestedForegroundStarted = false;
3400
+ try {
3401
+ const asyncResult = runAsyncPath(execData, deps);
3402
+ if (asyncResult)
3403
+ return withForkContext(withForkThinkingNotes(asyncResult, forkThinkingDowngrades), effectiveParams.context);
3404
+ if (foregroundControl) {
3405
+ writeNestedForegroundEvent("subagent.nested.started");
3406
+ nestedForegroundStarted = true;
3407
+ }
3408
+ if (hasChain && effectiveParams.chain) {
3409
+ const result = await runChainPath(execData, deps);
3410
+ writeNestedForegroundEvent("subagent.nested.completed", result);
3411
+ return withForkContext(withForkThinkingNotes(result, forkThinkingDowngrades), effectiveParams.context);
3412
+ }
3413
+ if (hasTasks && effectiveParams.tasks) {
3414
+ const result = await runParallelPath(execData, deps);
3415
+ writeNestedForegroundEvent("subagent.nested.completed", result);
3416
+ return withForkContext(withForkThinkingNotes(result, forkThinkingDowngrades), effectiveParams.context);
3417
+ }
3418
+ if (hasSingle) {
3419
+ const result = await runSinglePath(execData, deps);
3420
+ writeNestedForegroundEvent("subagent.nested.completed", result);
3421
+ return withForkContext(withForkThinkingNotes(result, forkThinkingDowngrades), effectiveParams.context);
3422
+ }
3423
+ }
3424
+ catch (error) {
3425
+ const errorResult = withForkThinkingNotes(toExecutionErrorResult(effectiveParams, error), forkThinkingDowngrades);
3426
+ if (nestedForegroundStarted)
3427
+ writeNestedForegroundEvent("subagent.nested.completed", errorResult);
3428
+ return errorResult;
3429
+ }
3430
+ finally {
3431
+ if (foregroundControl) {
3432
+ clearPendingForegroundControlNotices(deps.state, runId);
3433
+ deps.state.foregroundControls.delete(runId);
3434
+ if (deps.state.lastForegroundControlId === runId) {
3435
+ deps.state.lastForegroundControlId = null;
3436
+ }
3437
+ }
3438
+ }
3439
+ return withForkContext({
3440
+ content: [{ type: "text", text: "Invalid params" }],
3441
+ isError: true,
3442
+ details: { mode: "single", results: [] },
3443
+ }, effectiveParams.context);
3444
+ };
3445
+ const executeWithSingleDispatchGuard = async (id, params, signal, onUpdate, ctx) => {
3446
+ const requestParams = omitExecutionModeActionAlias(params);
3447
+ if (requestParams.action)
3448
+ return execute(id, requestParams, signal, onUpdate, ctx);
3449
+ const { depth } = checkSubagentDepth(deps.config.maxSubagentDepth);
3450
+ const dispatchParams = applyForceTopLevelAsyncOverride(requestParams, depth, deps.config.forceTopLevelAsync === true);
3451
+ const runsForeground = dispatchParams.clarify === true || (dispatchParams.async ?? deps.asyncByDefault) !== true;
3452
+ if (!runsForeground)
3453
+ return execute(id, requestParams, signal, onUpdate, ctx);
3454
+ const limit = resolveTopLevelParallelConcurrency(undefined, deps.config.parallel?.concurrency);
3455
+ const inFlight = deps.state.foregroundSubagentInFlight ?? 0;
3456
+ if (inFlight >= limit)
3457
+ return foregroundCapacityResult(requestParams, inFlight, limit);
3458
+ deps.state.foregroundSubagentInFlight = inFlight + 1;
3459
+ try {
3460
+ return await execute(id, requestParams, signal, onUpdate, ctx);
3461
+ }
3462
+ finally {
3463
+ deps.state.foregroundSubagentInFlight = Math.max(0, (deps.state.foregroundSubagentInFlight ?? 1) - 1);
3464
+ }
3465
+ };
3466
+ return { execute: executeWithSingleDispatchGuard };
3467
+ }
3468
+ //# sourceMappingURL=subagent-executor.js.map