@ashx-j/lunr 0.2.11 → 0.2.13

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 (342) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +211 -236
  3. package/dist/builtin-extensions/ashxj-tui.d.ts +3 -0
  4. package/dist/builtin-extensions/ashxj-tui.d.ts.map +1 -1
  5. package/dist/builtin-extensions/ashxj-tui.js +28 -11
  6. package/dist/builtin-extensions/ashxj-tui.js.map +1 -1
  7. package/dist/builtin-extensions/index.d.ts.map +1 -1
  8. package/dist/builtin-extensions/index.js +0 -2
  9. package/dist/builtin-extensions/index.js.map +1 -1
  10. package/dist/builtin-extensions/lunr-cron.d.ts +1 -1
  11. package/dist/builtin-extensions/lunr-cron.d.ts.map +1 -1
  12. package/dist/builtin-extensions/lunr-cron.js +1 -1
  13. package/dist/builtin-extensions/lunr-cron.js.map +1 -1
  14. package/dist/builtin-extensions/pi-subagents/src/extension/chain-validation.d.ts.map +1 -1
  15. package/dist/builtin-extensions/pi-subagents/src/extension/chain-validation.js +3 -3
  16. package/dist/builtin-extensions/pi-subagents/src/extension/chain-validation.js.map +1 -1
  17. package/dist/builtin-extensions/pi-subagents/src/extension/doctor.d.ts +0 -2
  18. package/dist/builtin-extensions/pi-subagents/src/extension/doctor.d.ts.map +1 -1
  19. package/dist/builtin-extensions/pi-subagents/src/extension/doctor.js +1 -23
  20. package/dist/builtin-extensions/pi-subagents/src/extension/doctor.js.map +1 -1
  21. package/dist/builtin-extensions/pi-subagents/src/extension/fanout-child.d.ts.map +1 -1
  22. package/dist/builtin-extensions/pi-subagents/src/extension/fanout-child.js +6 -7
  23. package/dist/builtin-extensions/pi-subagents/src/extension/fanout-child.js.map +1 -1
  24. package/dist/builtin-extensions/pi-subagents/src/extension/index.d.ts +1 -1
  25. package/dist/builtin-extensions/pi-subagents/src/extension/index.d.ts.map +1 -1
  26. package/dist/builtin-extensions/pi-subagents/src/extension/index.js +7 -14
  27. package/dist/builtin-extensions/pi-subagents/src/extension/index.js.map +1 -1
  28. package/dist/builtin-extensions/pi-subagents/src/extension/schemas.d.ts +12 -9
  29. package/dist/builtin-extensions/pi-subagents/src/extension/schemas.d.ts.map +1 -1
  30. package/dist/builtin-extensions/pi-subagents/src/extension/schemas.js +38 -34
  31. package/dist/builtin-extensions/pi-subagents/src/extension/schemas.js.map +1 -1
  32. package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.d.ts +3 -3
  33. package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.d.ts.map +1 -1
  34. package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.js +32 -47
  35. package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.js.map +1 -1
  36. package/dist/builtin-extensions/pi-subagents/src/intercom/intercom-bridge.d.ts +2 -2
  37. package/dist/builtin-extensions/pi-subagents/src/intercom/intercom-bridge.d.ts.map +1 -1
  38. package/dist/builtin-extensions/pi-subagents/src/intercom/intercom-bridge.js.map +1 -1
  39. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.d.ts +7 -10
  40. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.d.ts.map +1 -1
  41. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.js +90 -109
  42. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.js.map +1 -1
  43. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-resume.d.ts +3 -2
  44. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-resume.d.ts.map +1 -1
  45. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-resume.js +37 -50
  46. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-resume.js.map +1 -1
  47. package/dist/builtin-extensions/pi-subagents/src/runs/background/run-status.d.ts.map +1 -1
  48. package/dist/builtin-extensions/pi-subagents/src/runs/background/run-status.js +1 -1
  49. package/dist/builtin-extensions/pi-subagents/src/runs/background/run-status.js.map +1 -1
  50. package/dist/builtin-extensions/pi-subagents/src/runs/background/scheduled-runs.d.ts +4 -0
  51. package/dist/builtin-extensions/pi-subagents/src/runs/background/scheduled-runs.d.ts.map +1 -1
  52. package/dist/builtin-extensions/pi-subagents/src/runs/background/scheduled-runs.js +5 -5
  53. package/dist/builtin-extensions/pi-subagents/src/runs/background/scheduled-runs.js.map +1 -1
  54. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.d.ts.map +1 -1
  55. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.js +31 -13
  56. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.js.map +1 -1
  57. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-clarify.d.ts +2 -2
  58. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-clarify.d.ts.map +1 -1
  59. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-clarify.js.map +1 -1
  60. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.d.ts +4 -3
  61. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.d.ts.map +1 -1
  62. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.js +48 -20
  63. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.js.map +1 -1
  64. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.d.ts +2 -2
  65. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.d.ts.map +1 -1
  66. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.js +90 -64
  67. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.js.map +1 -1
  68. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.d.ts +6 -8
  69. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.d.ts.map +1 -1
  70. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js +262 -161
  71. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js.map +1 -1
  72. package/dist/builtin-extensions/pi-subagents/src/runs/shared/acceptance.d.ts +2 -1
  73. package/dist/builtin-extensions/pi-subagents/src/runs/shared/acceptance.d.ts.map +1 -1
  74. package/dist/builtin-extensions/pi-subagents/src/runs/shared/acceptance.js +24 -33
  75. package/dist/builtin-extensions/pi-subagents/src/runs/shared/acceptance.js.map +1 -1
  76. package/dist/builtin-extensions/pi-subagents/src/runs/shared/child-tools.d.ts +25 -0
  77. package/dist/builtin-extensions/pi-subagents/src/runs/shared/child-tools.d.ts.map +1 -0
  78. package/dist/builtin-extensions/pi-subagents/src/runs/shared/child-tools.js +51 -0
  79. package/dist/builtin-extensions/pi-subagents/src/runs/shared/child-tools.js.map +1 -0
  80. package/dist/builtin-extensions/pi-subagents/src/runs/shared/dynamic-fanout.d.ts.map +1 -1
  81. package/dist/builtin-extensions/pi-subagents/src/runs/shared/dynamic-fanout.js +20 -3
  82. package/dist/builtin-extensions/pi-subagents/src/runs/shared/dynamic-fanout.js.map +1 -1
  83. package/dist/builtin-extensions/pi-subagents/src/runs/shared/parallel-utils.d.ts +4 -1
  84. package/dist/builtin-extensions/pi-subagents/src/runs/shared/parallel-utils.d.ts.map +1 -1
  85. package/dist/builtin-extensions/pi-subagents/src/runs/shared/parallel-utils.js.map +1 -1
  86. package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.d.ts +5 -0
  87. package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.d.ts.map +1 -1
  88. package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.js +9 -3
  89. package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.js.map +1 -1
  90. package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.d.ts.map +1 -1
  91. package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.js +2 -2
  92. package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.js.map +1 -1
  93. package/dist/builtin-extensions/pi-subagents/src/runs/shared/task-intent.d.ts +2 -2
  94. package/dist/builtin-extensions/pi-subagents/src/runs/shared/task-intent.d.ts.map +1 -1
  95. package/dist/builtin-extensions/pi-subagents/src/runs/shared/task-intent.js +20 -17
  96. package/dist/builtin-extensions/pi-subagents/src/runs/shared/task-intent.js.map +1 -1
  97. package/dist/builtin-extensions/pi-subagents/src/shared/child-spec.d.ts +70 -0
  98. package/dist/builtin-extensions/pi-subagents/src/shared/child-spec.d.ts.map +1 -0
  99. package/dist/builtin-extensions/pi-subagents/src/shared/child-spec.js +153 -0
  100. package/dist/builtin-extensions/pi-subagents/src/shared/child-spec.js.map +1 -0
  101. package/dist/builtin-extensions/pi-subagents/src/shared/settings.d.ts +13 -8
  102. package/dist/builtin-extensions/pi-subagents/src/shared/settings.d.ts.map +1 -1
  103. package/dist/builtin-extensions/pi-subagents/src/shared/settings.js +20 -51
  104. package/dist/builtin-extensions/pi-subagents/src/shared/settings.js.map +1 -1
  105. package/dist/builtin-extensions/pi-subagents/src/shared/types.d.ts +80 -20
  106. package/dist/builtin-extensions/pi-subagents/src/shared/types.d.ts.map +1 -1
  107. package/dist/builtin-extensions/pi-subagents/src/shared/types.js +10 -2
  108. package/dist/builtin-extensions/pi-subagents/src/shared/types.js.map +1 -1
  109. package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.d.ts +2 -2
  110. package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.d.ts.map +1 -1
  111. package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.js +20 -32
  112. package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.js.map +1 -1
  113. package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.d.ts +2 -1
  114. package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.d.ts.map +1 -1
  115. package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.js +23 -449
  116. package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.js.map +1 -1
  117. package/dist/builtin-extensions/pi-subagents/src/tui/render.d.ts +2 -1
  118. package/dist/builtin-extensions/pi-subagents/src/tui/render.d.ts.map +1 -1
  119. package/dist/builtin-extensions/pi-subagents/src/tui/render.js +13 -11
  120. package/dist/builtin-extensions/pi-subagents/src/tui/render.js.map +1 -1
  121. package/dist/builtin-extensions/pi-subagents/src/watchdog/runtime.d.ts +2 -1
  122. package/dist/builtin-extensions/pi-subagents/src/watchdog/runtime.d.ts.map +1 -1
  123. package/dist/builtin-extensions/pi-subagents/src/watchdog/runtime.js +18 -17
  124. package/dist/builtin-extensions/pi-subagents/src/watchdog/runtime.js.map +1 -1
  125. package/dist/builtin-extensions/simple-pi-memory.d.ts +2 -2
  126. package/dist/builtin-extensions/simple-pi-memory.d.ts.map +1 -1
  127. package/dist/builtin-extensions/simple-pi-memory.js +41 -17
  128. package/dist/builtin-extensions/simple-pi-memory.js.map +1 -1
  129. package/dist/catalog/models.json +1 -1
  130. package/dist/catalog/providers/amazon-bedrock.json +1 -1
  131. package/dist/catalog/providers/azure-openai-responses.json +1 -1
  132. package/dist/catalog/providers/cloudflare-ai-gateway.json +1 -1
  133. package/dist/catalog/providers/cloudflare-workers-ai.json +1 -1
  134. package/dist/catalog/providers/fireworks.json +1 -1
  135. package/dist/catalog/providers/github-copilot.json +1 -1
  136. package/dist/catalog/providers/huggingface.json +1 -1
  137. package/dist/catalog/providers/minimax-cn.json +1 -1
  138. package/dist/catalog/providers/minimax.json +1 -1
  139. package/dist/catalog/providers/mistral.json +1 -1
  140. package/dist/catalog/providers/nvidia.json +1 -1
  141. package/dist/catalog/providers/openai.json +1 -1
  142. package/dist/catalog/providers/opencode-go.json +1 -1
  143. package/dist/catalog/providers/opencode.json +1 -1
  144. package/dist/catalog/providers/openrouter.json +1 -1
  145. package/dist/catalog/providers/qwen-cloud-cn.json +1 -1
  146. package/dist/catalog/providers/qwen-cloud.json +1 -1
  147. package/dist/catalog/providers/qwen-token-plan-cn.json +1 -1
  148. package/dist/catalog/providers/qwen-token-plan.json +1 -1
  149. package/dist/catalog/providers/together.json +1 -1
  150. package/dist/catalog/providers/vercel-ai-gateway.json +1 -1
  151. package/dist/catalog/providers/zai-coding-cn.json +1 -1
  152. package/dist/catalog/providers/zai.json +1 -1
  153. package/dist/catalog/publication.json +3 -3
  154. package/dist/core/agent-session.d.ts +7 -1
  155. package/dist/core/agent-session.d.ts.map +1 -1
  156. package/dist/core/agent-session.js +34 -4
  157. package/dist/core/agent-session.js.map +1 -1
  158. package/dist/core/context-breakdown.d.ts +3 -1
  159. package/dist/core/context-breakdown.d.ts.map +1 -1
  160. package/dist/core/context-breakdown.js +5 -2
  161. package/dist/core/context-breakdown.js.map +1 -1
  162. package/dist/core/customize.d.ts +2 -0
  163. package/dist/core/customize.d.ts.map +1 -1
  164. package/dist/core/customize.js +6 -0
  165. package/dist/core/customize.js.map +1 -1
  166. package/dist/core/memory-cap.d.ts +4 -8
  167. package/dist/core/memory-cap.d.ts.map +1 -1
  168. package/dist/core/memory-cap.js +8 -8
  169. package/dist/core/memory-cap.js.map +1 -1
  170. package/dist/core/permissions.d.ts +2 -0
  171. package/dist/core/permissions.d.ts.map +1 -1
  172. package/dist/core/permissions.js +30 -14
  173. package/dist/core/permissions.js.map +1 -1
  174. package/dist/core/plan-mode.d.ts.map +1 -1
  175. package/dist/core/plan-mode.js +1 -9
  176. package/dist/core/plan-mode.js.map +1 -1
  177. package/dist/core/rollback.d.ts.map +1 -1
  178. package/dist/core/rollback.js +1 -1
  179. package/dist/core/rollback.js.map +1 -1
  180. package/dist/core/settings-manager.d.ts +16 -5
  181. package/dist/core/settings-manager.d.ts.map +1 -1
  182. package/dist/core/settings-manager.js +37 -10
  183. package/dist/core/settings-manager.js.map +1 -1
  184. package/dist/core/slash-commands.d.ts.map +1 -1
  185. package/dist/core/slash-commands.js +1 -5
  186. package/dist/core/slash-commands.js.map +1 -1
  187. package/dist/core/subagent-permission-inherit.d.ts +34 -22
  188. package/dist/core/subagent-permission-inherit.d.ts.map +1 -1
  189. package/dist/core/subagent-permission-inherit.js +37 -80
  190. package/dist/core/subagent-permission-inherit.js.map +1 -1
  191. package/dist/core/swarm.d.ts.map +1 -1
  192. package/dist/core/swarm.js +13 -7
  193. package/dist/core/swarm.js.map +1 -1
  194. package/dist/core/system-prompt.d.ts +6 -4
  195. package/dist/core/system-prompt.d.ts.map +1 -1
  196. package/dist/core/system-prompt.js +38 -48
  197. package/dist/core/system-prompt.js.map +1 -1
  198. package/dist/core/usage-adapters/openai-codex.d.ts +1 -1
  199. package/dist/core/usage-adapters/openai-codex.d.ts.map +1 -1
  200. package/dist/core/usage-adapters/openai-codex.js +22 -17
  201. package/dist/core/usage-adapters/openai-codex.js.map +1 -1
  202. package/dist/core/usage-service.d.ts +10 -1
  203. package/dist/core/usage-service.d.ts.map +1 -1
  204. package/dist/core/usage-service.js +17 -6
  205. package/dist/core/usage-service.js.map +1 -1
  206. package/dist/gateway/agent-bridge.d.ts.map +1 -1
  207. package/dist/gateway/agent-bridge.js +1 -4
  208. package/dist/gateway/agent-bridge.js.map +1 -1
  209. package/dist/gateway/cron.d.ts.map +1 -1
  210. package/dist/gateway/cron.js +1 -4
  211. package/dist/gateway/cron.js.map +1 -1
  212. package/dist/index.d.ts +1 -1
  213. package/dist/index.d.ts.map +1 -1
  214. package/dist/index.js.map +1 -1
  215. package/dist/main.d.ts.map +1 -1
  216. package/dist/main.js +0 -5
  217. package/dist/main.js.map +1 -1
  218. package/dist/migrations.d.ts +2 -0
  219. package/dist/migrations.d.ts.map +1 -1
  220. package/dist/migrations.js +21 -0
  221. package/dist/migrations.js.map +1 -1
  222. package/dist/modes/interactive/components/settings-selector.d.ts +7 -4
  223. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  224. package/dist/modes/interactive/components/settings-selector.js +122 -162
  225. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  226. package/dist/modes/interactive/components/usage-view.d.ts +1 -1
  227. package/dist/modes/interactive/components/usage-view.d.ts.map +1 -1
  228. package/dist/modes/interactive/components/usage-view.js +7 -4
  229. package/dist/modes/interactive/components/usage-view.js.map +1 -1
  230. package/dist/modes/interactive/interactive-mode.d.ts +1 -2
  231. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  232. package/dist/modes/interactive/interactive-mode.js +55 -96
  233. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  234. package/dist/modes/interactive/skill-tag-autocomplete.d.ts +13 -0
  235. package/dist/modes/interactive/skill-tag-autocomplete.d.ts.map +1 -0
  236. package/dist/modes/interactive/skill-tag-autocomplete.js +72 -0
  237. package/dist/modes/interactive/skill-tag-autocomplete.js.map +1 -0
  238. package/docs/compaction.md +23 -23
  239. package/docs/containerization.md +24 -24
  240. package/docs/custom-provider.md +18 -18
  241. package/docs/development.md +16 -15
  242. package/docs/docs.json +6 -2
  243. package/docs/extensions.md +82 -80
  244. package/docs/features.md +102 -0
  245. package/docs/index.md +25 -19
  246. package/docs/json.md +7 -7
  247. package/docs/keybindings.md +4 -4
  248. package/docs/models.md +2 -2
  249. package/docs/packages.md +38 -42
  250. package/docs/prompt-templates.md +4 -4
  251. package/docs/providers.md +22 -10
  252. package/docs/quickstart.md +81 -46
  253. package/docs/rpc.md +7 -13
  254. package/docs/sdk.md +43 -41
  255. package/docs/security.md +18 -18
  256. package/docs/session-format.md +9 -9
  257. package/docs/sessions.md +13 -12
  258. package/docs/settings.md +63 -24
  259. package/docs/shell-aliases.md +2 -2
  260. package/docs/skills.md +21 -11
  261. package/docs/terminal-setup.md +5 -5
  262. package/docs/termux.md +7 -7
  263. package/docs/themes.md +12 -14
  264. package/docs/tmux.md +4 -4
  265. package/docs/tui.md +23 -23
  266. package/docs/usage.md +112 -87
  267. package/docs/windows.md +10 -2
  268. package/examples/README.md +3 -1
  269. package/examples/extensions/README.md +6 -6
  270. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  271. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  272. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  273. package/examples/extensions/doom-overlay/README.md +2 -2
  274. package/examples/extensions/gondolin/package-lock.json +2 -2
  275. package/examples/extensions/gondolin/package.json +1 -1
  276. package/examples/extensions/plan-mode/README.md +3 -1
  277. package/examples/extensions/sandbox/package-lock.json +2 -2
  278. package/examples/extensions/sandbox/package.json +1 -1
  279. package/examples/extensions/subagent/README.md +13 -11
  280. package/examples/extensions/todo.ts +2 -1
  281. package/examples/extensions/with-deps/package-lock.json +2 -2
  282. package/examples/extensions/with-deps/package.json +1 -1
  283. package/examples/sdk/README.md +9 -5
  284. package/package.json +6 -7
  285. package/dist/builtin-extensions/lunr-behavior.d.ts +0 -44
  286. package/dist/builtin-extensions/lunr-behavior.d.ts.map +0 -1
  287. package/dist/builtin-extensions/lunr-behavior.js +0 -213
  288. package/dist/builtin-extensions/lunr-behavior.js.map +0 -1
  289. package/dist/builtin-extensions/pi-subagents/agents/context-builder.md +0 -46
  290. package/dist/builtin-extensions/pi-subagents/agents/deep-researcher.md +0 -36
  291. package/dist/builtin-extensions/pi-subagents/agents/delegate.md +0 -12
  292. package/dist/builtin-extensions/pi-subagents/agents/oracle.md +0 -73
  293. package/dist/builtin-extensions/pi-subagents/agents/planner.md +0 -55
  294. package/dist/builtin-extensions/pi-subagents/agents/research-writer.md +0 -37
  295. package/dist/builtin-extensions/pi-subagents/agents/researcher.md +0 -52
  296. package/dist/builtin-extensions/pi-subagents/agents/reviewer.md +0 -79
  297. package/dist/builtin-extensions/pi-subagents/agents/scout.md +0 -50
  298. package/dist/builtin-extensions/pi-subagents/agents/worker.md +0 -55
  299. package/dist/builtin-extensions/pi-subagents/src/agents/agent-management.d.ts +0 -20
  300. package/dist/builtin-extensions/pi-subagents/src/agents/agent-management.d.ts.map +0 -1
  301. package/dist/builtin-extensions/pi-subagents/src/agents/agent-management.js +0 -1273
  302. package/dist/builtin-extensions/pi-subagents/src/agents/agent-management.js.map +0 -1
  303. package/dist/builtin-extensions/pi-subagents/src/agents/agent-memory.d.ts +0 -49
  304. package/dist/builtin-extensions/pi-subagents/src/agents/agent-memory.d.ts.map +0 -1
  305. package/dist/builtin-extensions/pi-subagents/src/agents/agent-memory.js +0 -252
  306. package/dist/builtin-extensions/pi-subagents/src/agents/agent-memory.js.map +0 -1
  307. package/dist/builtin-extensions/pi-subagents/src/agents/agent-scope.d.ts +0 -3
  308. package/dist/builtin-extensions/pi-subagents/src/agents/agent-scope.d.ts.map +0 -1
  309. package/dist/builtin-extensions/pi-subagents/src/agents/agent-scope.js +0 -6
  310. package/dist/builtin-extensions/pi-subagents/src/agents/agent-scope.js.map +0 -1
  311. package/dist/builtin-extensions/pi-subagents/src/agents/agent-selection.d.ts +0 -3
  312. package/dist/builtin-extensions/pi-subagents/src/agents/agent-selection.d.ts.map +0 -1
  313. package/dist/builtin-extensions/pi-subagents/src/agents/agent-selection.js +0 -23
  314. package/dist/builtin-extensions/pi-subagents/src/agents/agent-selection.js.map +0 -1
  315. package/dist/builtin-extensions/pi-subagents/src/agents/agent-serializer.d.ts +0 -8
  316. package/dist/builtin-extensions/pi-subagents/src/agents/agent-serializer.d.ts.map +0 -1
  317. package/dist/builtin-extensions/pi-subagents/src/agents/agent-serializer.js +0 -143
  318. package/dist/builtin-extensions/pi-subagents/src/agents/agent-serializer.js.map +0 -1
  319. package/dist/builtin-extensions/pi-subagents/src/agents/agents.d.ts +0 -176
  320. package/dist/builtin-extensions/pi-subagents/src/agents/agents.d.ts.map +0 -1
  321. package/dist/builtin-extensions/pi-subagents/src/agents/agents.js +0 -1326
  322. package/dist/builtin-extensions/pi-subagents/src/agents/agents.js.map +0 -1
  323. package/dist/builtin-extensions/pi-subagents/src/agents/chain-serializer.d.ts +0 -7
  324. package/dist/builtin-extensions/pi-subagents/src/agents/chain-serializer.d.ts.map +0 -1
  325. package/dist/builtin-extensions/pi-subagents/src/agents/chain-serializer.js +0 -307
  326. package/dist/builtin-extensions/pi-subagents/src/agents/chain-serializer.js.map +0 -1
  327. package/dist/builtin-extensions/pi-subagents/src/agents/identity.d.ts +0 -8
  328. package/dist/builtin-extensions/pi-subagents/src/agents/identity.d.ts.map +0 -1
  329. package/dist/builtin-extensions/pi-subagents/src/agents/identity.js +0 -30
  330. package/dist/builtin-extensions/pi-subagents/src/agents/identity.js.map +0 -1
  331. package/dist/builtin-extensions/pi-subagents/src/agents/proactive-skills.d.ts +0 -35
  332. package/dist/builtin-extensions/pi-subagents/src/agents/proactive-skills.d.ts.map +0 -1
  333. package/dist/builtin-extensions/pi-subagents/src/agents/proactive-skills.js +0 -151
  334. package/dist/builtin-extensions/pi-subagents/src/agents/proactive-skills.js.map +0 -1
  335. package/dist/builtin-extensions/pi-subagents/src/profiles/profiles.d.ts +0 -131
  336. package/dist/builtin-extensions/pi-subagents/src/profiles/profiles.d.ts.map +0 -1
  337. package/dist/builtin-extensions/pi-subagents/src/profiles/profiles.js +0 -491
  338. package/dist/builtin-extensions/pi-subagents/src/profiles/profiles.js.map +0 -1
  339. package/dist/core/behavior-preset.d.ts +0 -60
  340. package/dist/core/behavior-preset.d.ts.map +0 -1
  341. package/dist/core/behavior-preset.js +0 -257
  342. package/dist/core/behavior-preset.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/builtin-extensions/pi-subagents/src/shared/types.ts"],"names":[],"mappings":"AAAA,cAAc;AACd;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAkNlC,MAAM,CAAC,MAAM,mCAAmC,GAAG,CAAC,CAAC;AAo0BrD,MAAM,CAAC,MAAM,6BAA6B,GAAG,4BAA4B,CAAC;AAC1E,MAAM,CAAC,MAAM,8BAA8B,GAAG,6BAA6B,CAAC;AAC5E,MAAM,CAAC,MAAM,4BAA4B,GAAG,wBAAwB,CAAC;AACrE,MAAM,CAAC,MAAM,6BAA6B,GAAG,yBAAyB,CAAC;AACvE,MAAM,CAAC,MAAM,kCAAkC,GAAG,8BAA8B,CAAC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node:os\";\nimport * as path from \"node:path\";\nimport type { Message } from \"@ashx-j/lunr-ai\";\nimport type { FSWatcher } from \"node:fs\";\nimport type { ExtensionContext } from \"@ashx-j/lunr\";\nimport type { ModelScopeConfig } from \"../runs/shared/model-scope.ts\";\n\n// ============================================================================\n// Basic Types\n// ============================================================================\n\nexport interface MaxOutputConfig {\n\tbytes?: number;\n\tlines?: number;\n}\n\nexport type OutputMode = \"inline\" | \"file-only\";\n\nexport type AcceptanceRole = \"read-only\" | \"writer\";\n\nexport type JsonSchemaObject = Record<string, unknown>;\n\nexport interface ChainOutputMapEntry {\n\ttext: string;\n\tstructured?: unknown;\n\tagent: string;\n\tstepIndex: number;\n}\n\nexport type ChainOutputMap = Record<string, ChainOutputMapEntry>;\n\nexport type WorkflowNodeStatus = \"pending\" | \"running\" | \"completed\" | \"failed\" | \"paused\" | \"stopped\" | \"detached\";\n\nexport interface WorkflowGraphNode {\n\tid: string;\n\tkind: \"step\" | \"parallel-group\" | \"dynamic-parallel-group\" | \"agent\";\n\tagent?: string;\n\tphase?: string;\n\tlabel: string;\n\tstatus: WorkflowNodeStatus;\n\tflatIndex?: number;\n\tstepIndex?: number;\n\tchildren?: WorkflowGraphNode[];\n\tdynamic?: {\n\t\tsourceOutput: string;\n\t\tsourcePath: string;\n\t\titemName: string;\n\t\tmaxItems?: number;\n\t\tcollectAs?: string;\n\t};\n\titemKey?: string;\n\toutputName?: string;\n\tstructured?: boolean;\n\tacceptanceStatus?: AcceptanceLedgerStatus;\n\terror?: string;\n}\n\nexport interface WorkflowGraphSnapshot {\n\trunId: string;\n\tmode: \"chain\" | \"parallel\" | \"single\";\n\tphases: Array<{ title: string; nodeIds: string[] }>;\n\tnodes: WorkflowGraphNode[];\n\tcurrentNodeId?: string;\n}\n\nexport interface SavedOutputReference {\n\tpath: string;\n\tbytes: number;\n\tlines: number;\n\tmessage: string;\n}\n\ninterface TruncationResult {\n\ttext: string;\n\ttruncated: boolean;\n\toriginalBytes?: number;\n\toriginalLines?: number;\n\tartifactPath?: string;\n}\n\nexport interface Usage {\n\tinput: number;\n\toutput: number;\n\tcacheRead: number;\n\tcacheWrite: number;\n\tcost: number;\n\tturns: number;\n}\n\nexport interface TurnBudgetConfig {\n\tmaxTurns: number;\n\tgraceTurns?: number;\n}\n\nexport interface ResolvedTurnBudget {\n\tmaxTurns: number;\n\tgraceTurns: number;\n}\n\nexport interface ToolBudgetConfig {\n\tsoft?: number;\n\thard: number;\n\tblock?: string[] | \"*\";\n}\n\nexport interface ResolvedToolBudget {\n\tsoft?: number;\n\thard: number;\n\tblock: string[] | \"*\";\n}\n\nexport type ToolBudgetOutcome = \"within-budget\" | \"soft-reached\" | \"hard-blocked\";\n\nexport interface ToolBudgetState extends ResolvedToolBudget {\n\toutcome: ToolBudgetOutcome;\n\ttoolCount: number;\n\tsoftReachedAt?: number;\n\thardReachedAt?: number;\n\tblockedTool?: string;\n}\n\nexport type TurnBudgetOutcome = \"within-budget\" | \"wrap-up-requested\" | \"exceeded\";\n\nexport interface TurnBudgetState extends ResolvedTurnBudget {\n\toutcome: TurnBudgetOutcome;\n\tturnCount: number;\n\twrapUpRequestedAtTurn?: number;\n\texceededAtTurn?: number;\n}\n\nexport interface TokenUsage {\n\tinput: number;\n\toutput: number;\n\ttotal: number;\n}\n\nexport type ActivityState = \"active_long_running\" | \"needs_attention\";\nexport type ControlEventType = \"active_long_running\" | \"needs_attention\";\nexport type ControlNotificationChannel = \"event\" | \"async\" | \"intercom\";\n\nexport interface ControlConfig {\n\tenabled?: boolean;\n\tneedsAttentionAfterMs?: number;\n\tactiveNoticeAfterMs?: number;\n\tactiveNoticeAfterTurns?: number;\n\tactiveNoticeAfterTokens?: number;\n\tfailedToolAttemptsBeforeAttention?: number;\n\tnotifyOn?: ControlEventType[];\n\tnotifyChannels?: ControlNotificationChannel[];\n}\n\nexport interface ResolvedControlConfig {\n\tenabled: boolean;\n\tneedsAttentionAfterMs: number;\n\tactiveNoticeAfterMs: number;\n\tactiveNoticeAfterTurns?: number;\n\tactiveNoticeAfterTokens?: number;\n\tfailedToolAttemptsBeforeAttention: number;\n\tnotifyOn: ControlEventType[];\n\tnotifyChannels: ControlNotificationChannel[];\n}\n\n/**\n * Smart completion batching for async-completion notifications. Successful\n * sibling completions are held briefly so they arrive as one grouped message;\n * failure and attention signals bypass grouping and always fire immediately.\n */\nexport interface CompletionBatchConfig {\n\tenabled?: boolean;\n\t/** Idle window after each arrival; resets on every new item. */\n\tdebounceMs?: number;\n\t/** Hard cap measured from the first item in a group. */\n\tmaxWaitMs?: number;\n\t/** Shorter idle window for straggler groups. */\n\tstragglerDebounceMs?: number;\n\t/** Shorter hard cap for straggler groups. */\n\tstragglerMaxWaitMs?: number;\n\t/** Arrivals within this window after an emit join a straggler group. */\n\tstragglerWindowMs?: number;\n}\n\nexport interface WaitToolConfigObject {\n\tenabled?: boolean;\n}\n\nexport type WaitToolConfig = boolean | WaitToolConfigObject;\n\nexport interface ControlEvent {\n\ttype: ControlEventType;\n\tfrom?: ActivityState;\n\tto: ActivityState;\n\tts: number;\n\tagent: string;\n\tindex?: number;\n\trunId: string;\n\tnestedRunId?: string;\n\tnestingPath?: NestedRunAddress[\"path\"];\n\tmessage: string;\n\treason?: \"idle\" | \"completion_guard\" | \"active_long_running\" | \"tool_failures\" | \"time_threshold\" | \"turn_threshold\" | \"token_threshold\";\n\tturns?: number;\n\ttokens?: number;\n\ttoolCount?: number;\n\tcurrentTool?: string;\n\tcurrentToolDurationMs?: number;\n\tcurrentPath?: string;\n\telapsedMs?: number;\n\trecentFailureSummary?: string;\n}\n\nexport type SubagentResultStatus = \"completed\" | \"failed\" | \"paused\" | \"stopped\" | \"detached\";\nexport type SubagentRunMode = \"single\" | \"parallel\" | \"chain\";\nexport const SUBAGENT_LIFECYCLE_ARTIFACT_VERSION = 2;\nexport type SubagentLifecycleArtifactVersion = typeof SUBAGENT_LIFECYCLE_ARTIFACT_VERSION;\n\nexport type SteeringActionState = \"delivered\" | \"scheduled\" | \"pending\" | \"partial\" | \"recovered\" | \"failed\";\nexport type SteeringTargetState = \"scheduled\" | \"routed\" | \"delivered\" | \"late\" | \"failed\" | \"recovered\";\n\nexport interface SteeringTargetStatus {\n\tindex: number;\n\tstate: SteeringTargetState;\n\troutedAt?: number;\n\tdeliveredAt?: number;\n\tlateDeliveredAt?: number;\n\tfailedAt?: number;\n\trecoveredAt?: number;\n\treason?: string;\n\treplacementRunId?: string;\n}\n\nexport interface SteeringRequestStatus {\n\tid: string;\n\trequestedAt: number;\n\tsource?: string;\n\tmessagePreview: string;\n\ttargets: SteeringTargetStatus[];\n}\n\nexport interface SteeringStatus {\n\trequested: number;\n\tscheduled: number;\n\tpending: number;\n\tdelivered: number;\n\tfailed: number;\n\trecovered: number;\n\tlastRequestedAt?: number;\n\tlastDeliveredAt?: number;\n\trecent: SteeringRequestStatus[];\n}\n\nexport interface SteerActionTarget {\n\tindex: number;\n\tstate: SteeringTargetState;\n\tdeliveredAt?: number;\n\tlateDeliveredAt?: number;\n\treason?: string;\n\treplacementRunId?: string;\n}\n\nexport interface SteerActionResult {\n\trequestId: string;\n\tstate: SteeringActionState;\n\tsourceRunId: string;\n\treplacementRunId?: string;\n\ttargets: SteerActionTarget[];\n}\n\nexport interface SteeringNotice {\n\ttype: \"subagent.steering.notice\";\n\tts: number;\n\trunId: string;\n\trequestId: string;\n\tstate: \"failed\" | \"partial\" | \"recovered\";\n\tmessage: string;\n\tcurrentSessionId?: string;\n}\n\nexport interface SteeringRecoveryDescriptor {\n\tversion: 1;\n\tsourceRunId: string;\n\tagent: string;\n\tsessionFile?: string;\n\tcwd: string;\n\tmodel?: string;\n\tfallbackModels?: string[];\n\tthinking?: string;\n\ttools?: string[];\n\textensions?: string[];\n\tsubagentOnlyExtensions?: string[];\n\tmcpDirectTools?: string[];\n\tsystemPrompt?: string;\n\tsystemPromptMode: \"append\" | \"replace\";\n\tinheritProjectContext: boolean;\n\tinheritSkills: boolean;\n\tskills?: string[];\n\tskillPath?: string[];\n\tagentFilePath?: string;\n\tcompletionGuard?: boolean;\n\tmemory?: { scope: \"project\" | \"user\"; path: string };\n\toutputPath?: string;\n\toutputMode: \"inline\" | \"file-only\";\n\tacceptance?: AcceptanceInput;\n\tcontrolConfig?: ResolvedControlConfig;\n\tabsoluteDeadlineAt?: number;\n\tinitialTurnBudget?: ResolvedTurnBudget;\n\tinitialToolBudget?: ResolvedToolBudget;\n\tmaxSubagentDepth: number;\n\tmaxOutput?: MaxOutputConfig;\n\tshare: boolean;\n\tsessionDir?: string;\n\tartifactsDir?: string;\n\tartifactConfig?: ArtifactConfig;\n}\n\nexport type PublicNestedStepSummary = Pick<\n\tNestedStepSummary,\n\t\"agent\" | \"status\" | \"sessionFile\" | \"transcriptPath\" | \"transcriptError\" | \"activityState\" | \"lastActivityAt\" | \"currentTool\" | \"currentToolStartedAt\" | \"currentPath\" | \"turnCount\" | \"toolCount\" | \"toolBudget\" | \"toolBudgetBlocked\" | \"startedAt\" | \"endedAt\" | \"error\" | \"timedOut\" | \"stopped\"\n> & {\n\tchildren?: PublicNestedRunSummary[];\n};\n\nexport type CostSummary = {\n\tinputTokens: number;\n\toutputTokens: number;\n\tcostUsd: number;\n};\n\nexport type PublicNestedRunSummary = Pick<\n\tNestedRunSummary,\n\t\"id\" | \"parentRunId\" | \"parentStepIndex\" | \"parentAgent\" | \"depth\" | \"path\" | \"asyncDir\" | \"sessionId\" | \"sessionFile\" | \"intercomTarget\" | \"ownerIntercomTarget\" | \"leafIntercomTarget\" | \"ownerState\" | \"mode\" | \"state\" | \"agent\" | \"agents\" | \"currentStep\" | \"chainStepCount\" | \"parallelGroups\" | \"activityState\" | \"lastActivityAt\" | \"currentTool\" | \"currentToolStartedAt\" | \"currentPath\" | \"turnCount\" | \"toolCount\" | \"toolBudget\" | \"toolBudgetBlocked\" | \"totalTokens\" | \"totalCost\" | \"startedAt\" | \"endedAt\" | \"lastUpdate\" | \"error\" | \"timeoutMs\" | \"deadlineAt\" | \"timedOut\" | \"stopped\" | \"turnBudget\" | \"turnBudgetExceeded\" | \"wrapUpRequested\"\n> & {\n\tsteps?: PublicNestedStepSummary[];\n\tchildren?: PublicNestedRunSummary[];\n};\n\nexport interface SubagentResultIntercomChild {\n\tagent: string;\n\tstatus: SubagentResultStatus;\n\tsummary: string;\n\tindex?: number;\n\tartifactPath?: string;\n\tsessionPath?: string;\n\tintercomTarget?: string;\n\tchildren?: PublicNestedRunSummary[];\n}\n\nexport interface SubagentResultIntercomPayload {\n\tto: string;\n\tmessage: string;\n\trequestId?: string;\n\trunId: string;\n\tmode: SubagentRunMode;\n\tstatus: SubagentResultStatus;\n\tsummary: string;\n\tsource: \"foreground\" | \"async\";\n\tchildren: SubagentResultIntercomChild[];\n\tasyncId?: string;\n\tasyncDir?: string;\n\tchainSteps?: number;\n\tagent?: string;\n\tindex?: number;\n\tartifactPath?: string;\n\tsessionPath?: string;\n}\n\n// ============================================================================\n// Progress Tracking\n// ============================================================================\n\nexport interface ChildWatchdogProgress {\n\tphase: \"idle\" | \"reviewing\" | \"autofollow\" | \"settling\" | \"stale\" | \"failed\";\n\tseq: number;\n\tlastUpdate: number;\n\tfollowUpPending: boolean;\n\treason?: string;\n\ttimedOut?: boolean;\n}\n\nexport interface AgentProgress {\n\tindex: number;\n\tagent: string;\n\tstatus: \"pending\" | \"running\" | \"completed\" | \"failed\" | \"detached\";\n\tactivityState?: ActivityState;\n\ttask: string;\n\tskills?: string[];\n\tlastActivityAt?: number;\n\tcurrentTool?: string;\n\tcurrentToolArgs?: string;\n\tcurrentToolStartedAt?: number;\n\tcurrentPath?: string;\n\tmodel?: string;\n\tthinking?: string;\n\tthinkingText?: string;\n\trecentTools: Array<{ tool: string; args: string; endMs: number }>;\n\trecentOutput: string[];\n\ttoolCount: number;\n\tturnCount?: number;\n\ttokens: number;\n\tdurationMs: number;\n\terror?: string;\n\tfailedTool?: string;\n\twatchdog?: ChildWatchdogProgress;\n}\n\nexport interface ToolCallSummary {\n\ttext: string;\n\texpandedText: string;\n}\n\ninterface ProgressSummary {\n\ttoolCount: number;\n\ttokens: number;\n\tdurationMs: number;\n}\n\n// ============================================================================\n// Results\n// ============================================================================\n\nexport interface ModelAttempt {\n\tmodel: string;\n\tsuccess: boolean;\n\texitCode?: number | null;\n\terror?: string;\n\tusage?: Usage;\n}\n\nexport type AcceptanceLevel = \"auto\" | \"none\" | \"attested\" | \"checked\" | \"verified\" | \"reviewed\";\n\nexport type AcceptanceEvidenceKind =\n\t| \"changed-files\"\n\t| \"tests-added\"\n\t| \"commands-run\"\n\t| \"validation-output\"\n\t| \"residual-risks\"\n\t| \"no-staged-files\"\n\t| \"diff-summary\"\n\t| \"review-findings\"\n\t| \"manual-notes\";\n\nexport interface AcceptanceGate {\n\tid: string;\n\tmust: string;\n\tevidence?: AcceptanceEvidenceKind[];\n\tseverity?: \"required\" | \"recommended\";\n}\n\nexport interface AcceptanceVerifyCommand {\n\tid: string;\n\tcommand: string;\n\ttimeoutMs?: number;\n\tcwd?: string;\n\tenv?: Record<string, string>;\n\tallowFailure?: boolean;\n}\n\nexport interface AcceptanceReviewGate {\n\tagent?: string;\n\tfocus?: string;\n\trequired?: boolean;\n}\n\nexport interface AcceptanceConfig {\n\tlevel?: AcceptanceLevel;\n\tcriteria?: Array<string | AcceptanceGate>;\n\tevidence?: AcceptanceEvidenceKind[];\n\tverify?: AcceptanceVerifyCommand[];\n\treview?: AcceptanceReviewGate | false;\n\tstopRules?: string[];\n\treason?: string;\n}\n\n/** Bare \"none\" is not accepted: use { level: \"none\", reason: \"...\" }; false remains a deprecated shorthand. */\nexport type AcceptanceInput = Exclude<AcceptanceLevel, \"none\"> | false | AcceptanceConfig;\n\nexport interface ResolvedAcceptanceGate extends AcceptanceGate {\n\tid: string;\n\tmust: string;\n\tevidence: AcceptanceEvidenceKind[];\n\tseverity: \"required\" | \"recommended\";\n}\n\nexport interface ResolvedAcceptanceConfig {\n\tlevel: Exclude<AcceptanceLevel, \"auto\">;\n\texplicit: boolean;\n\tinferredReason: string[];\n\tcriteria: ResolvedAcceptanceGate[];\n\tevidence: AcceptanceEvidenceKind[];\n\tverify: AcceptanceVerifyCommand[];\n\treview?: AcceptanceReviewGate | false;\n\tstopRules: string[];\n\treason?: string;\n}\n\nexport interface AcceptanceReport {\n\tcriteriaSatisfied?: Array<{\n\t\tid?: string;\n\t\tstatus: \"satisfied\" | \"not-satisfied\" | \"not-applicable\";\n\t\tevidence: string;\n\t}>;\n\tchangedFiles?: string[];\n\ttestsAddedOrUpdated?: string[];\n\tcommandsRun?: Array<{\n\t\tcommand: string;\n\t\tresult: \"passed\" | \"failed\" | \"not-run\";\n\t\tsummary: string;\n\t}>;\n\tvalidationOutput?: string[];\n\tresidualRisks?: string[];\n\tnoStagedFiles?: boolean;\n\tdiffSummary?: string;\n\treviewFindings?: string[];\n\tmanualNotes?: string;\n\tnotes?: string;\n}\n\nexport type AcceptanceRuntimeCheckStatus = \"passed\" | \"failed\" | \"not-applicable\";\n\nexport interface AcceptanceRuntimeCheck {\n\tid: string;\n\tstatus: AcceptanceRuntimeCheckStatus;\n\tmessage: string;\n}\n\nexport interface AcceptanceVerifyResult {\n\tid: string;\n\tcommand: string;\n\tcwd?: string;\n\texitCode: number | null;\n\tstatus: \"passed\" | \"failed\" | \"timed-out\" | \"allowed-failure\";\n\tstdout?: string;\n\tstderr?: string;\n\tdurationMs: number;\n}\n\nexport interface AcceptanceReviewResult {\n\tstatus: \"no-blockers\" | \"blockers\" | \"needs-parent-decision\";\n\tfindings: Array<{\n\t\tseverity: \"blocker\" | \"non-blocking\";\n\t\tfile?: string;\n\t\tissue: string;\n\t\trationale: string;\n\t}>;\n}\n\nexport type AcceptanceLedgerStatus =\n\t| \"pending\"\n\t| \"not-required\"\n\t| \"claimed\"\n\t| \"attested\"\n\t| \"checked\"\n\t| \"verified\"\n\t| \"reviewed\"\n\t| \"accepted\"\n\t| \"rejected\";\n\nexport interface AcceptanceLedger {\n\tstatus: AcceptanceLedgerStatus;\n\texplicit: boolean;\n\teffectiveAcceptance: ResolvedAcceptanceConfig;\n\tinferredReason: string[];\n\tcriteria: ResolvedAcceptanceGate[];\n\tchildReport?: AcceptanceReport;\n\tchildReportParseError?: string;\n\truntimeChecks: AcceptanceRuntimeCheck[];\n\tverifyRuns: AcceptanceVerifyResult[];\n\treviewResult?: AcceptanceReviewResult;\n\tparentDecision?: {\n\t\tstatus: \"accepted\" | \"rejected\";\n\t\tat: string;\n\t\treason?: string;\n\t};\n}\n\nexport interface ProtocolOutputLimit {\n\tcode: \"protocol_output_limit\";\n\tstream: \"stdout\" | \"stderr\";\n\tlimitBytes: number;\n\tobservedBytes: number;\n\tdiagnosticPrefix: string;\n\tdiagnosticTail: string;\n}\n\nexport interface SingleResult {\n\tagent: string;\n\ttask: string;\n\texitCode: number;\n\tdetached?: boolean;\n\tdetachedReason?: string;\n\tinterrupted?: boolean;\n\ttimedOut?: boolean;\n\tstopped?: boolean;\n\tturnBudget?: TurnBudgetState;\n\tturnBudgetExceeded?: boolean;\n\twrapUpRequested?: boolean;\n\ttoolBudget?: ToolBudgetState;\n\ttoolBudgetBlocked?: boolean;\n\tmessages?: Message[];\n\tusage: Usage;\n\tmodel?: string;\n\tthinking?: string;\n\tattemptedModels?: string[];\n\tmodelAttempts?: ModelAttempt[];\n\tcontrolEvents?: ControlEvent[];\n\terror?: string;\n\tprotocolError?: ProtocolOutputLimit;\n\tsessionFile?: string;\n\tskills?: string[];\n\tskillsWarning?: string;\n\tprogress?: AgentProgress;\n\tprogressSummary?: ProgressSummary;\n\ttoolCalls?: ToolCallSummary[];\n\tartifactPaths?: ArtifactPaths;\n\ttruncation?: TruncationResult;\n\tfinalOutput?: string;\n\toutputMode?: OutputMode;\n\tsavedOutputPath?: string;\n\toutputReference?: SavedOutputReference;\n\toutputSaveError?: string;\n\tstructuredOutput?: unknown;\n\tstructuredOutputPath?: string;\n\tstructuredOutputSchemaPath?: string;\n\tacceptance?: AcceptanceLedger;\n\ttranscriptPath?: string;\n\ttranscriptError?: string;\n\tchildren?: NestedRunSummary[];\n\twatchdog?: ChildWatchdogProgress;\n}\n\nexport interface Details {\n\tmode: SubagentRunMode | \"management\";\n\trunId?: string;\n\tcontext?: \"fresh\" | \"fork\";\n\tresults: SingleResult[];\n\tcontrolEvents?: ControlEvent[];\n\tsteering?: SteerActionResult;\n\tasyncId?: string;\n\tasyncDir?: string;\n\ttimeoutMs?: number;\n\tdeadlineAt?: number;\n\ttimedOut?: boolean;\n\tstopped?: boolean;\n\tturnBudget?: ResolvedTurnBudget;\n\ttoolBudget?: ResolvedToolBudget;\n\tprogress?: AgentProgress[];\n\tprogressSummary?: ProgressSummary;\n\tartifacts?: {\n\t\tdir: string;\n\t\tfiles: ArtifactPaths[];\n\t};\n\ttruncation?: {\n\t\ttruncated: boolean;\n\t\toriginalBytes?: number;\n\t\toriginalLines?: number;\n\t\tartifactPath?: string;\n\t};\n\t// Chain metadata for observability\n\tchainAgents?: string[]; // Agent names in order, e.g., [\"scout\", \"planner\"]\n\ttotalSteps?: number; // Total steps in chain\n\tcurrentStepIndex?: number; // 0-indexed current step (for running chains)\n\tworkflowGraph?: WorkflowGraphSnapshot;\n\toutputs?: ChainOutputMap;\n\t// Aggregated child usage across all agents in the run\n\ttotalChildUsage?: Usage;\n\t// Aggregated cost across all agents in the run\n\ttotalCost?: CostSummary;\n}\n\n// ============================================================================\n// Artifacts\n// ============================================================================\n\nexport interface ArtifactPaths {\n\tinputPath: string;\n\toutputPath: string;\n\tjsonlPath: string;\n\ttranscriptPath: string;\n\tmetadataPath: string;\n}\n\nexport interface ArtifactConfig {\n\tenabled: boolean;\n\tincludeInput: boolean;\n\tincludeOutput: boolean;\n\tincludeJsonl: boolean;\n\tincludeTranscript?: boolean;\n\tincludeMetadata: boolean;\n\tcleanupDays: number;\n}\n\n// ============================================================================\n// Async Execution\n// ============================================================================\n\nexport interface AsyncParallelGroupStatus {\n\tstart: number;\n\tcount: number;\n\tstepIndex: number;\n}\n\nexport type NestedRunState = \"queued\" | \"running\" | \"complete\" | \"failed\" | \"paused\" | \"stopped\";\nexport type NestedOwnerState = \"live\" | \"gone\" | \"unknown\";\n\nexport interface NestedRunAddress {\n\tid: string;\n\tparentRunId: string;\n\tparentStepIndex?: number;\n\tparentAgent?: string;\n\tdepth: number;\n\tpath: Array<{ runId: string; stepIndex?: number; agent?: string }>;\n}\n\nexport interface NestedStepSummary {\n\tagent: string;\n\tstatus: \"pending\" | \"running\" | \"complete\" | \"completed\" | \"failed\" | \"paused\" | \"stopped\";\n\tsessionFile?: string;\n\ttranscriptPath?: string;\n\ttranscriptError?: string;\n\tactivityState?: ActivityState;\n\tlastActivityAt?: number;\n\tcurrentTool?: string;\n\tcurrentToolStartedAt?: number;\n\tcurrentPath?: string;\n\tturnCount?: number;\n\ttoolCount?: number;\n\tstartedAt?: number;\n\tendedAt?: number;\n\terror?: string;\n\twatchdog?: ChildWatchdogProgress;\n\ttimedOut?: boolean;\n\tstopped?: boolean;\n\tturnBudget?: TurnBudgetState;\n\tturnBudgetExceeded?: boolean;\n\twrapUpRequested?: boolean;\n\ttoolBudget?: ToolBudgetState;\n\ttoolBudgetBlocked?: boolean;\n\tchildren?: NestedRunSummary[];\n}\n\nexport interface NestedRunSummary extends NestedRunAddress {\n\tasyncDir?: string;\n\tpid?: number;\n\tsessionId?: string;\n\tsessionFile?: string;\n\tintercomTarget?: string;\n\townerIntercomTarget?: string;\n\tleafIntercomTarget?: string;\n\townerState?: NestedOwnerState;\n\tcontrolInbox?: string;\n\tcapabilityToken?: string;\n\tmode?: SubagentRunMode;\n\tstate: NestedRunState;\n\tagent?: string;\n\tagents?: string[];\n\tcurrentStep?: number;\n\tchainStepCount?: number;\n\tparallelGroups?: AsyncParallelGroupStatus[];\n\tsteps?: NestedStepSummary[];\n\tchildren?: NestedRunSummary[];\n\tactivityState?: ActivityState;\n\tlastActivityAt?: number;\n\tcurrentTool?: string;\n\tcurrentToolStartedAt?: number;\n\tcurrentPath?: string;\n\tturnCount?: number;\n\ttoolCount?: number;\n\ttotalTokens?: TokenUsage;\n\ttotalCost?: CostSummary;\n\tstartedAt?: number;\n\tendedAt?: number;\n\tlastUpdate?: number;\n\ttimeoutMs?: number;\n\tdeadlineAt?: number;\n\ttimedOut?: boolean;\n\tstopped?: boolean;\n\tturnBudget?: TurnBudgetState;\n\tturnBudgetExceeded?: boolean;\n\twrapUpRequested?: boolean;\n\ttoolBudget?: ToolBudgetState;\n\ttoolBudgetBlocked?: boolean;\n\terror?: string;\n}\n\nexport interface NestedRouteInfo {\n\trootRunId: string;\n\teventSink: string;\n\tcontrolInbox: string;\n\tcapabilityToken: string;\n}\n\nexport interface AsyncStartedEvent {\n\tlifecycleArtifactVersion?: SubagentLifecycleArtifactVersion;\n\tid?: string;\n\tasyncDir?: string;\n\tpid?: number;\n\tsessionId?: string;\n\tmode?: SubagentRunMode;\n\tagent?: string;\n\tagents?: string[];\n\t/** Truncated first child task retained for backwards compatibility. */\n\ttask?: string;\n\t/** Workflow-level caller task, falling back to the first child task. */\n\tgoal?: string;\n\tchain?: string[];\n\tchainStepCount?: number;\n\tparallelGroups?: AsyncParallelGroupStatus[];\n\tworkflowGraph?: WorkflowGraphSnapshot;\n\ttimeoutMs?: number;\n\tdeadlineAt?: number;\n\tturnBudget?: TurnBudgetState;\n\tnestedRoute?: NestedRouteInfo;\n}\n\nexport interface AsyncStatus {\n\tlifecycleArtifactVersion?: SubagentLifecycleArtifactVersion;\n\trunId: string;\n\tsessionId?: string;\n\tmode: SubagentRunMode;\n\tisNested?: boolean;\n\tstate: \"queued\" | \"running\" | \"complete\" | \"failed\" | \"paused\" | \"stopped\";\n\terror?: string;\n\tactivityState?: ActivityState;\n\tlastActivityAt?: number;\n\tcurrentTool?: string;\n\tcurrentToolStartedAt?: number;\n\tcurrentPath?: string;\n\tturnCount?: number;\n\ttoolCount?: number;\n\tsteering?: SteeringStatus;\n\tstartedAt: number;\n\tendedAt?: number;\n\tlastUpdate?: number;\n\ttimeoutMs?: number;\n\tdeadlineAt?: number;\n\ttimedOut?: boolean;\n\tstopped?: boolean;\n\tturnBudget?: TurnBudgetState;\n\tturnBudgetExceeded?: boolean;\n\twrapUpRequested?: boolean;\n\ttoolBudget?: ToolBudgetState;\n\ttoolBudgetBlocked?: boolean;\n\tpid?: number;\n\tcwd?: string;\n\tcurrentStep?: number;\n\tchainStepCount?: number;\n\tpendingAppends?: number;\n\tparallelGroups?: AsyncParallelGroupStatus[];\n\tworkflowGraph?: WorkflowGraphSnapshot;\n\tsteps?: Array<{\n\t\tagent: string;\n\t\tphase?: string;\n\t\tlabel?: string;\n\t\toutputName?: string;\n\t\tstructured?: boolean;\n\t\tstatus: \"pending\" | \"running\" | \"complete\" | \"completed\" | \"failed\" | \"paused\" | \"stopped\";\n\t\tchildren?: NestedRunSummary[];\n\t\tsessionFile?: string;\n\t\ttranscriptPath?: string;\n\t\ttranscriptError?: string;\n\t\tactivityState?: ActivityState;\n\t\tlastActivityAt?: number;\n\t\tcurrentTool?: string;\n\t\tcurrentToolArgs?: string;\n\t\tcurrentToolStartedAt?: number;\n\t\tcurrentPath?: string;\n\t\trecentTools?: Array<{ tool: string; args: string; endMs: number }>;\n\t\trecentOutput?: string[];\n\t\tturnCount?: number;\n\t\ttoolCount?: number;\n\t\tstartedAt?: number;\n\t\tendedAt?: number;\n\t\tdurationMs?: number;\n\t\texitCode?: number | null;\n\t\ttimedOut?: boolean;\n\t\tstopped?: boolean;\n\t\tturnBudget?: TurnBudgetState;\n\t\tturnBudgetExceeded?: boolean;\n\t\twrapUpRequested?: boolean;\n\t\ttoolBudget?: ToolBudgetState;\n\t\ttoolBudgetBlocked?: boolean;\n\t\ttokens?: TokenUsage;\n\t\tskills?: string[];\n\t\tmodel?: string;\n\t\tthinking?: string;\n\t\tattemptedModels?: string[];\n\t\tmodelAttempts?: ModelAttempt[];\n\t\ttotalCost?: CostSummary;\n\t\tsteering?: SteeringStatus;\n\t\terror?: string;\n\t\tstructuredOutput?: unknown;\n\t\tstructuredOutputPath?: string;\n\t\tstructuredOutputSchemaPath?: string;\n\t\tacceptance?: AcceptanceLedger;\n\t\twatchdog?: ChildWatchdogProgress;\n\t}>;\n\tsessionDir?: string;\n\toutputFile?: string;\n\ttotalTokens?: TokenUsage;\n\ttotalCost?: CostSummary;\n\tsessionFile?: string;\n\toutputs?: ChainOutputMap;\n}\n\nexport type AsyncJobStep = NonNullable<AsyncStatus[\"steps\"]>[number] & {\n\tindex?: number;\n};\n\nexport interface AsyncJobState {\n\tasyncId: string;\n\tasyncDir: string;\n\tstatus: \"queued\" | \"running\" | \"complete\" | \"failed\" | \"paused\" | \"stopped\";\n\tpid?: number;\n\tsessionId?: string;\n\tactivityState?: ActivityState;\n\tlastActivityAt?: number;\n\tcurrentTool?: string;\n\tcurrentToolStartedAt?: number;\n\tcurrentPath?: string;\n\tturnCount?: number;\n\ttoolCount?: number;\n\tsteering?: SteeringStatus;\n\tmode?: SubagentRunMode;\n\tagents?: string[];\n\tcurrentStep?: number;\n\tchainStepCount?: number;\n\tparallelGroups?: AsyncParallelGroupStatus[];\n\tsteps?: AsyncJobStep[];\n\tstepsTotal?: number;\n\trunningSteps?: number;\n\tcompletedSteps?: number;\n\thasParallelGroups?: boolean;\n\tactiveParallelGroup?: boolean;\n\tstartedAt?: number;\n\tupdatedAt?: number;\n\ttimeoutMs?: number;\n\tdeadlineAt?: number;\n\ttimedOut?: boolean;\n\tstopped?: boolean;\n\tturnBudget?: TurnBudgetState;\n\tturnBudgetExceeded?: boolean;\n\twrapUpRequested?: boolean;\n\ttoolBudget?: ToolBudgetState;\n\ttoolBudgetBlocked?: boolean;\n\tsessionDir?: string;\n\toutputFile?: string;\n\ttotalTokens?: TokenUsage;\n\tsessionFile?: string;\n\tcontrolEventCursor?: number;\n\tnestedRoute?: NestedRouteInfo;\n\tnestedChildren?: NestedRunSummary[];\n}\n\nexport interface ForegroundResumeChild {\n\tagent: string;\n\tindex: number;\n\tsessionFile?: string;\n\tstatus: SubagentResultStatus;\n\texitCode?: number;\n\terror?: string;\n\tfinalOutput?: string;\n\toutputMode?: OutputMode;\n\tsavedOutputPath?: string;\n\toutputSaveError?: string;\n\tartifactPaths?: ArtifactPaths;\n\ttranscriptPath?: string;\n\ttranscriptError?: string;\n\tdetachedReason?: string;\n\tacceptance?: AcceptanceLedger;\n\tupdatedAt?: number;\n}\n\nexport interface ForegroundResumeRun {\n\trunId: string;\n\tmode: SubagentRunMode;\n\tcwd: string;\n\t/** Originating parent session. Detached exits can outlive the active session. */\n\tsessionId?: string;\n\tupdatedAt: number;\n\tchildren: ForegroundResumeChild[];\n}\n\nexport interface SubagentState {\n\tbaseCwd: string;\n\tcurrentSessionId: string | null;\n\t/** Live foreground `subagent` tool calls. Caps same-turn overlap. */\n\tforegroundSubagentInFlight?: number;\n\tsubagentSpawns?: { sessionId: string | null; count: number };\n\tasyncJobs: Map<string, AsyncJobState>;\n\t/** Current-session active and recent async runs for the native fleet inspector. */\n\tfleetJobs?: Map<string, AsyncJobState>;\n\tforegroundRuns?: Map<string, ForegroundResumeRun>;\n\tforegroundControls: Map<string, {\n\t\trunId: string;\n\t\tmode: SubagentRunMode;\n\t\tstartedAt: number;\n\t\tupdatedAt: number;\n\t\tcurrentAgent?: string;\n\t\tcurrentIndex?: number;\n\t\tcurrentActivityState?: ActivityState;\n\t\tlastActivityAt?: number;\n\t\tcurrentTool?: string;\n\t\tcurrentToolStartedAt?: number;\n\t\tcurrentPath?: string;\n\t\tturnCount?: number;\n\t\ttokens?: number;\n\t\ttoolCount?: number;\n\t\tnestedRoute?: NestedRouteInfo;\n\t\tnestedChildren?: NestedRunSummary[];\n\t\tinterrupt?: () => boolean;\n\t}>;\n\tlastForegroundControlId: string | null;\n\tpendingForegroundControlNotices?: Map<string, ReturnType<typeof setTimeout>>;\n\tcleanupTimers: Map<string, ReturnType<typeof setTimeout>>;\n\tlastUiContext: ExtensionContext | null;\n\tpoller: NodeJS.Timeout | null;\n\tcompletionSeen: Map<string, number>;\n\twatcher: FSWatcher | null;\n\twatcherRestartTimer: ReturnType<typeof setTimeout> | null;\n\tresultFileCoalescer: {\n\t\tschedule(file: string, delayMs?: number): boolean;\n\t\tclear(): void;\n\t};\n}\n\n// ============================================================================\n// Display\n// ============================================================================\n\nexport type DisplayItem = \n\t| { type: \"text\"; text: string } \n\t| { type: \"tool\"; name: string; args: Record<string, unknown> };\n\n// ============================================================================\n// Error Handling\n// ============================================================================\n\nexport interface ErrorInfo {\n\thasError: boolean;\n\texitCode?: number;\n\terrorType?: string;\n\tdetails?: string;\n}\n\nexport interface IntercomEventBus {\n\ton(channel: string, handler: (data: unknown) => void): () => void;\n\temit(channel: string, data: unknown): void;\n}\n\nexport const INTERCOM_DETACH_REQUEST_EVENT = \"pi-intercom:detach-request\";\nexport const INTERCOM_DETACH_RESPONSE_EVENT = \"pi-intercom:detach-response\";\nexport const SUBAGENT_ASYNC_STARTED_EVENT = \"subagent:async-started\";\nexport const SUBAGENT_ASYNC_COMPLETE_EVENT = \"subagent:async-complete\";\nexport const SUBAGENT_FOREGROUND_COMPLETE_EVENT = \"subagent:foreground-complete\";\nexport const SUBAGENT_CONTROL_EVENT = \"subagent:control-event\";\nexport const SUBAGENT_CONTROL_INTERCOM_EVENT = \"subagent:control-intercom\";\nexport const SUBAGENT_STEERING_NOTICE_EVENT = \"subagent:steering-notice\";\nexport const SUBAGENT_RESULT_INTERCOM_EVENT = \"subagent:result-intercom\";\nexport const SUBAGENT_RESULT_INTERCOM_DELIVERY_EVENT = \"subagent:result-intercom-delivery\";\n\n// ============================================================================\n// Execution Options\n// ============================================================================\n\nexport interface RunSyncOptions {\n\t/** Session id of the direct parent session for permission-system ask forwarding. */\n\tparentSessionId?: string;\n\tcwd?: string;\n\tsignal?: AbortSignal;\n\tinterruptSignal?: AbortSignal;\n\ttimeoutMs?: number;\n\tdeadlineAt?: number;\n\tturnBudget?: ResolvedTurnBudget;\n\ttoolBudget?: ResolvedToolBudget;\n\tallowIntercomDetach?: boolean;\n\tintercomEvents?: IntercomEventBus;\n\tonUpdate?: (r: import(\"@ashx-j/lunr-agent\").AgentToolResult<Details>) => void;\n\tonControlEvent?: (event: ControlEvent) => void;\n\tonDetachedExit?: (result: SingleResult) => void;\n\tcontrolConfig?: ResolvedControlConfig;\n\tintercomSessionName?: string;\n\torchestratorIntercomTarget?: string;\n\tmaxOutput?: MaxOutputConfig;\n\tartifactsDir?: string;\n\tartifactConfig?: ArtifactConfig;\n\trunId: string;\n\tindex?: number;\n\tsessionDir?: string;\n\tsessionFile?: string;\n\tshare?: boolean;\n\toutputPath?: string;\n\toutputMode?: OutputMode;\n\tmaxSubagentDepth?: number;\n\t/** Effective parent wait-tool setting propagated to the child runtime. */\n\twaitToolEnabled?: boolean;\n\tnestedRoute?: NestedRouteInfo;\n\t/** Override the agent's default model (format: \"provider/id\" or just \"id\") */\n\tmodelOverride?: string;\n\t/** Override the agent's default thinking level for this run */\n\tthinkingOverride?: AgentConfig[\"thinking\"];\n\t/** Registry models available for heuristic bare-model resolution */\n\tavailableModels?: Array<{ provider: string; id: string; fullId: string }>;\n\t/** Current parent-session provider to prefer for ambiguous bare model ids */\n\tpreferredModelProvider?: string;\n\t/** Optional subagent model-scope enforcement for fallback candidates */\n\tmodelScope?: ModelScopeConfig;\n\t/** Skills to make available (overrides agent default if provided) */\n\tskills?: string[];\n\tstructuredOutput?: {\n\t\tschema: JsonSchemaObject;\n\t\tschemaPath: string;\n\t\toutputPath: string;\n\t};\n\tacceptance?: AcceptanceInput;\n\tacceptanceContext?: {\n\t\tmode?: SubagentRunMode;\n\t\tasync?: boolean;\n\t\tdynamic?: boolean;\n\t\tdynamicGroup?: boolean;\n\t};\n}\n\nexport type IntercomBridgeMode = \"off\" | \"fork-only\" | \"always\";\n\nexport interface IntercomBridgeConfig {\n\tmode?: IntercomBridgeMode;\n\tinstructionFile?: string;\n}\n\ninterface TopLevelParallelConfig {\n\tmaxTasks?: number;\n\tconcurrency?: number;\n}\n\ninterface ExtensionChainConfig {\n\tdynamicFanout?: {\n\t\tmaxItems?: number;\n\t};\n}\n\nexport interface ProactiveSkillSubagentsConfig {\n\tenabled?: boolean;\n\tminReferences?: number;\n\tmaxRecommendations?: number;\n\tpreferredAgent?: string;\n}\n\nexport type ToolDescriptionMode = \"full\" | \"compact\" | \"custom\";\n\nexport interface ScheduledRunsConfig {\n\tenabled?: boolean;\n\tmaxLatenessMs?: number;\n\tmaxPending?: number;\n}\n\nexport interface ExtensionConfig {\n\tasyncByDefault?: boolean;\n\t/** Show the above-editor async runs widget. Defaults to true. */\n\tasyncWidget?: boolean;\n\t/** Tool description variant registered for the parent-facing subagent tool. Defaults to full. */\n\ttoolDescriptionMode?: ToolDescriptionMode;\n\tforceTopLevelAsync?: boolean;\n\twaitTool?: WaitToolConfig;\n\tdefaultSessionDir?: string;\n\tsingleRunOutputBaseDir?: string;\n\tmaxSubagentDepth?: number;\n\t/** Optional cumulative session cap. Unset or 0 means unlimited. */\n\tmaxSubagentSpawnsPerSession?: number;\n\t/** Global cap on simultaneously-running subagent tasks within a single run. Unset means unlimited. */\n\tglobalConcurrencyLimit?: number;\n\tcontrol?: ControlConfig;\n\tcompletionBatch?: CompletionBatchConfig;\n\tturnBudget?: TurnBudgetConfig;\n\ttoolBudget?: ToolBudgetConfig;\n\tparallel?: TopLevelParallelConfig;\n\tchain?: ExtensionChainConfig;\n\tworktreeSetupHook?: string;\n\tworktreeSetupHookTimeoutMs?: number;\n\tworktreeBaseDir?: string;\n\tintercomBridge?: IntercomBridgeConfig;\n\tproactiveSkillSubagents?: ProactiveSkillSubagentsConfig | false;\n\tscheduledRuns?: ScheduledRunsConfig;\n}\n\n// ============================================================================\n// Constants\n// ============================================================================\n\nexport const DEFAULT_MAX_OUTPUT: Required<MaxOutputConfig> = {\n\tbytes: 200 * 1024,\n\tlines: 5000,\n};\n\nexport const DEFAULT_ARTIFACT_CONFIG: ArtifactConfig = {\n\tenabled: true,\n\tincludeInput: true,\n\tincludeOutput: true,\n\tincludeJsonl: false,\n\tincludeTranscript: true,\n\tincludeMetadata: true,\n\tcleanupDays: 7,\n};\n\nfunction sanitizeTempScopeSegment(value: string): string {\n\tconst sanitized = value\n\t\t.trim()\n\t\t.replace(/[^A-Za-z0-9._-]+/g, \"-\")\n\t\t.replace(/^-+|-+$/g, \"\");\n\treturn sanitized || \"unknown\";\n}\n\nexport function resolveTempScopeId(options?: {\n\tenv?: NodeJS.ProcessEnv;\n\tgetuid?: (() => number) | undefined;\n\tuserInfo?: (() => { username?: string | null }) | undefined;\n\thomedir?: (() => string) | undefined;\n}): string {\n\tconst env = options?.env ?? process.env;\n\tconst getuid = options && Object.hasOwn(options, \"getuid\")\n\t\t? options.getuid\n\t\t: process.getuid?.bind(process);\n\tif (typeof getuid === \"function\") {\n\t\treturn `uid-${getuid()}`;\n\t}\n\n\tfor (const key of [\"USERNAME\", \"USER\", \"LOGNAME\"] as const) {\n\t\tconst value = env[key];\n\t\tif (value) return `user-${sanitizeTempScopeSegment(value)}`;\n\t}\n\n\tconst userInfo = options && Object.hasOwn(options, \"userInfo\")\n\t\t? options.userInfo\n\t\t: os.userInfo;\n\ttry {\n\t\tconst username = userInfo?.().username;\n\t\tif (username) return `user-${sanitizeTempScopeSegment(username)}`;\n\t} catch {\n\t\t// Fall through to home-directory-based scoping.\n\t}\n\n\tconst homedir = env.USERPROFILE ?? env.HOME;\n\tif (homedir) return `home-${sanitizeTempScopeSegment(homedir)}`;\n\n\tconst resolveHomedir = options && Object.hasOwn(options, \"homedir\")\n\t\t? options.homedir\n\t\t: os.homedir;\n\ttry {\n\t\tconst fallbackHomedir = resolveHomedir?.();\n\t\tif (fallbackHomedir) return `home-${sanitizeTempScopeSegment(fallbackHomedir)}`;\n\t} catch {\n\t\t// Fall through to the last-resort shared scope.\n\t}\n\n\treturn \"shared\";\n}\n\nconst MAX_PARALLEL = Number.MAX_SAFE_INTEGER;\nexport const MAX_CONCURRENCY = Number.MAX_SAFE_INTEGER;\nexport const TEMP_ROOT_DIR = path.join(os.tmpdir(), `pi-subagents-${resolveTempScopeId()}`);\nexport const RESULTS_DIR = path.join(TEMP_ROOT_DIR, \"async-subagent-results\");\nexport const ASYNC_DIR = path.join(TEMP_ROOT_DIR, \"async-subagent-runs\");\nexport const CHAIN_RUNS_DIR = path.join(TEMP_ROOT_DIR, \"chain-runs\");\nexport const TEMP_ARTIFACTS_DIR = path.join(TEMP_ROOT_DIR, \"artifacts\");\nexport const WIDGET_KEY = \"subagent-async\";\nexport const SLASH_RESULT_TYPE = \"subagent-slash-result\";\nexport const SLASH_TEXT_RESULT_TYPE = \"subagent-slash-text-result\";\nexport const SLASH_SUBAGENT_REQUEST_EVENT = \"subagent:slash:request\";\nexport const SLASH_SUBAGENT_STARTED_EVENT = \"subagent:slash:started\";\nexport const SLASH_SUBAGENT_RESPONSE_EVENT = \"subagent:slash:response\";\nexport const SLASH_SUBAGENT_UPDATE_EVENT = \"subagent:slash:update\";\nexport const SLASH_SUBAGENT_CANCEL_EVENT = \"subagent:slash:cancel\";\nexport const POLL_INTERVAL_MS = 250;\nexport const MAX_WIDGET_JOBS = 4;\nexport const DEFAULT_SUBAGENT_MAX_DEPTH = 2;\nexport const SUBAGENT_ACTIONS = [\"list\", \"get\", \"models\", \"create\", \"update\", \"delete\", \"eject\", \"disable\", \"enable\", \"reset\", \"status\", \"interrupt\", \"resume\", \"steer\", \"stop\", \"append-step\", \"doctor\", \"watchdog.status\", \"watchdog.check\", \"watchdog.configure\", \"watchdog.recommend-model\", \"schedule\", \"schedule-list\", \"schedule-status\", \"schedule-cancel\"] as const;\n\nexport const DEFAULT_FORK_PREAMBLE =\n\t\"You are a delegated subagent running from a fork of the parent session. \" +\n\t\"Treat the inherited conversation as reference-only context, not a live thread to continue. \" +\n\t\"Do not continue or answer prior messages as if they are waiting for a reply. \" +\n\t\"Your sole job is to execute the task below and return a focused result for that task using your tools.\";\n\nfunction normalizeTopLevelParallelValue(value: unknown): number | undefined {\n\tconst parsed = typeof value === \"number\" ? value : typeof value === \"string\" ? Number(value) : NaN;\n\tif (!Number.isInteger(parsed) || parsed < 1) return undefined;\n\treturn parsed;\n}\n\nexport function resolveTopLevelParallelMaxTasks(value: unknown): number {\n\treturn normalizeTopLevelParallelValue(value) ?? MAX_PARALLEL;\n}\n\nexport function resolveTopLevelParallelConcurrency(\n\toverride: unknown,\n\tconfigValue: unknown,\n): number {\n\treturn normalizeTopLevelParallelValue(override)\n\t\t?? normalizeTopLevelParallelValue(configValue)\n\t\t?? MAX_CONCURRENCY;\n}\n\nexport function getAsyncConfigPath(suffix: string): string {\n\treturn path.join(TEMP_ROOT_DIR, `async-cfg-${suffix}.json`);\n}\n\nexport function wrapForkTask(task: string, preamble?: string | false): string {\n\tif (preamble === false) return task;\n\tconst effectivePreamble = preamble ?? DEFAULT_FORK_PREAMBLE;\n\tconst wrappedPrefix = `${effectivePreamble}\\n\\nTask:\\n`;\n\tif (task.startsWith(wrappedPrefix)) return task;\n\treturn `${wrappedPrefix}${task}`;\n}\n\n// ============================================================================\n// Recursion Depth Guard\n// ============================================================================\n\nfunction normalizeNonNegativeInteger(value: unknown): number | undefined {\n\tconst parsed = typeof value === \"number\" ? value : typeof value === \"string\" ? Number(value) : NaN;\n\tif (!Number.isInteger(parsed) || parsed < 0) return undefined;\n\treturn parsed;\n}\n\nexport function normalizeMaxSubagentDepth(value: unknown): number | undefined {\n\treturn normalizeNonNegativeInteger(value);\n}\n\nexport function resolveCurrentMaxSubagentDepth(configMaxDepth?: number): number {\n\treturn normalizeMaxSubagentDepth(process.env.PI_SUBAGENT_MAX_DEPTH)\n\t\t?? normalizeMaxSubagentDepth(configMaxDepth)\n\t\t?? DEFAULT_SUBAGENT_MAX_DEPTH;\n}\n\nexport function resolveChildMaxSubagentDepth(parentMaxDepth: number, agentMaxDepth?: number): number {\n\tconst normalizedParent = normalizeMaxSubagentDepth(parentMaxDepth) ?? DEFAULT_SUBAGENT_MAX_DEPTH;\n\tconst normalizedAgent = normalizeMaxSubagentDepth(agentMaxDepth);\n\treturn normalizedAgent === undefined ? normalizedParent : Math.min(normalizedParent, normalizedAgent);\n}\n\nexport function checkSubagentDepth(configMaxDepth?: number): { blocked: boolean; depth: number; maxDepth: number } {\n\tconst depth = Number(process.env.PI_SUBAGENT_DEPTH ?? \"0\");\n\tconst maxDepth = resolveCurrentMaxSubagentDepth(configMaxDepth);\n\tconst blocked = Number.isFinite(depth) && depth >= maxDepth;\n\treturn { blocked, depth, maxDepth };\n}\n\nexport function getSubagentDepthEnv(maxDepth?: number): Record<string, string> {\n\tconst parentDepth = Number(process.env.PI_SUBAGENT_DEPTH ?? \"0\");\n\tconst nextDepth = Number.isFinite(parentDepth) ? parentDepth + 1 : 1;\n\treturn {\n\t\tPI_SUBAGENT_DEPTH: String(nextDepth),\n\t\tPI_SUBAGENT_MAX_DEPTH: String(normalizeMaxSubagentDepth(maxDepth) ?? resolveCurrentMaxSubagentDepth()),\n\t};\n}\n\nexport function normalizeMaxSubagentSpawnsPerSession(value: unknown): number | undefined {\n\treturn normalizeNonNegativeInteger(value);\n}\n\nexport function resolveMaxSubagentSpawnsPerSession(configMaxSpawns?: number): number | undefined {\n\tconst envMaxSpawns = normalizeMaxSubagentSpawnsPerSession(process.env.PI_SUBAGENT_MAX_SPAWNS_PER_SESSION);\n\tif (envMaxSpawns !== undefined) return envMaxSpawns === 0 ? undefined : envMaxSpawns;\n\tconst configuredMaxSpawns = normalizeMaxSubagentSpawnsPerSession(configMaxSpawns);\n\treturn configuredMaxSpawns === 0 ? undefined : configuredMaxSpawns;\n}\n\n// ============================================================================\n// Utility Functions\n// ============================================================================\n\nfunction formatBytes(bytes: number): string {\n\tif (bytes < 1024) return `${bytes}B`;\n\tif (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)}KB`;\n\treturn `${(bytes / (1024 * 1024)).toFixed(1)}MB`;\n}\n\nexport function truncateOutput(\n\toutput: string,\n\tconfig: Required<MaxOutputConfig>,\n\tartifactPath?: string,\n): TruncationResult {\n\tconst lines = output.split(\"\\n\");\n\tconst bytes = Buffer.byteLength(output, \"utf-8\");\n\n\tif (bytes <= config.bytes && lines.length <= config.lines) {\n\t\treturn { text: output, truncated: false };\n\t}\n\n\tlet truncatedLines = lines;\n\tif (lines.length > config.lines) {\n\t\ttruncatedLines = lines.slice(0, config.lines);\n\t}\n\n\tlet result = truncatedLines.join(\"\\n\");\n\tif (Buffer.byteLength(result, \"utf-8\") > config.bytes) {\n\t\tlet low = 0;\n\t\tlet high = result.length;\n\t\twhile (low < high) {\n\t\t\tconst mid = Math.floor((low + high + 1) / 2);\n\t\t\tif (Buffer.byteLength(result.slice(0, mid), \"utf-8\") <= config.bytes) {\n\t\t\t\tlow = mid;\n\t\t\t} else {\n\t\t\t\thigh = mid - 1;\n\t\t\t}\n\t\t}\n\t\tresult = result.slice(0, low);\n\t}\n\n\tconst keptLines = result.split(\"\\n\").length;\n\tconst marker = `[TRUNCATED: showing first ${keptLines} of ${lines.length} lines, ${formatBytes(Buffer.byteLength(result))} of ${formatBytes(bytes)}${artifactPath ? ` - full output at ${artifactPath}` : \"\"}]\\n`;\n\n\treturn {\n\t\ttext: marker + result,\n\t\ttruncated: true,\n\t\toriginalBytes: bytes,\n\t\toriginalLines: lines.length,\n\t\tartifactPath,\n\t};\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/builtin-extensions/pi-subagents/src/shared/types.ts"],"names":[],"mappings":"AAAA,cAAc;AACd;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAoElC,MAAM,UAAU,aAAa,CAAC,KAK7B,EAAU;IACV,OAAO,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,KAAK,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,KAAK,CAAC,OAAO,IAAI,OAAO,CAAC;AAAA,CAC3G;AAmMD,MAAM,CAAC,MAAM,mCAAmC,GAAG,CAAC,CAAC;AAErD,MAAM,CAAC,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,MAAM,GAAG,6BAA6B,SAAS,OAAO,KAAK,CAAC,MAAM,WAAW,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,OAAO,WAAW,CAAC,KAAK,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,qBAAqB,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC;IAElN,OAAO;QACN,IAAI,EAAE,MAAM,GAAG,MAAM;QACrB,SAAS,EAAE,IAAI;QACf,aAAa,EAAE,KAAK;QACpB,aAAa,EAAE,KAAK,CAAC,MAAM;QAC3B,YAAY;KACZ,CAAC;AAAA,CACF","sourcesContent":["// @ts-nocheck\n/**\n * Type definitions for the subagent extension\n */\n\nimport * as os from \"node:os\";\nimport * as path from \"node:path\";\nimport type { Message } from \"@ashx-j/lunr-ai\";\nimport type { FSWatcher } from \"node:fs\";\nimport type { ExtensionContext } from \"@ashx-j/lunr\";\nimport type { ModelScopeConfig } from \"../runs/shared/model-scope.ts\";\n\n// ============================================================================\n// Basic Types\n// ============================================================================\n\nexport interface MaxOutputConfig {\n\tbytes?: number;\n\tlines?: number;\n}\n\nexport type OutputMode = \"inline\" | \"file-only\";\n\nexport type ChildPermission = \"full\" | \"read-only\";\nexport type ChildTier = \"light\" | \"standard\" | \"heavy\";\n\nexport interface ChildSpec {\n\tchildId: string;\n\ttask: string;\n\tdescription: string;\n\trequestedPermissions: ChildPermission;\n\teffectivePermissions: ChildPermission;\n\tmodel?: string;\n\ttier?: ChildTier;\n\tskill?: string | string[] | false;\n\tcwd?: string;\n\toutput?: string | false;\n\toutputMode?: OutputMode;\n\tacceptance?: AcceptanceInput;\n\ttoolBudget?: ToolBudgetConfig;\n\tcount?: number;\n\treads?: string[] | false;\n\tprogress?: boolean;\n\tlabel?: string;\n\tphase?: string;\n\tas?: string;\n\toutputSchema?: JsonSchemaObject;\n\tfanoutAuthorized?: boolean;\n}\n\n/** Internal execution compatibility shape. It is built from ChildSpec and is never user-discovered. */\nexport interface ChildRuntimeConfig {\n\tname: string;\n\tdescription: string;\n\ttools?: string[];\n\tmcpDirectTools?: string[];\n\tmodel?: string;\n\tfallbackModels?: string[];\n\tthinking?: string | false;\n\tsystemPromptMode: \"append\" | \"replace\";\n\tinheritProjectContext: boolean;\n\tinheritSkills: boolean;\n\tacceptanceRole?: AcceptanceRole;\n\tsystemPrompt: string;\n\tskills?: string[];\n\tskillPath?: string[];\n\textensions?: string[];\n\tsubagentOnlyExtensions?: string[];\n\toutput?: string;\n\tmaxSubagentDepth?: number;\n\tcompletionGuard?: boolean;\n\ttoolBudget?: ToolBudgetConfig;\n}\n\nexport function childRowLabel(entry: {\n\tdescription?: string;\n\tlabel?: string;\n\tagent?: string;\n\tchildId?: string;\n}): string {\n\treturn entry.label?.trim() || entry.description?.trim() || entry.agent?.trim() || entry.childId || \"child\";\n}\n\nexport type AcceptanceRole = \"read-only\" | \"writer\";\n\nexport type JsonSchemaObject = Record<string, unknown>;\n\nexport interface ChainOutputMapEntry {\n\ttext: string;\n\tstructured?: unknown;\n\tagent: string;\n\tstepIndex: number;\n}\n\nexport type ChainOutputMap = Record<string, ChainOutputMapEntry>;\n\nexport type WorkflowNodeStatus = \"pending\" | \"running\" | \"completed\" | \"failed\" | \"paused\" | \"stopped\" | \"detached\";\n\nexport interface WorkflowGraphNode {\n\tid: string;\n\tkind: \"step\" | \"parallel-group\" | \"dynamic-parallel-group\" | \"agent\";\n\tagent?: string;\n\tphase?: string;\n\tlabel: string;\n\tstatus: WorkflowNodeStatus;\n\tflatIndex?: number;\n\tstepIndex?: number;\n\tchildren?: WorkflowGraphNode[];\n\tdynamic?: {\n\t\tsourceOutput: string;\n\t\tsourcePath: string;\n\t\titemName: string;\n\t\tmaxItems?: number;\n\t\tcollectAs?: string;\n\t};\n\titemKey?: string;\n\toutputName?: string;\n\tstructured?: boolean;\n\tacceptanceStatus?: AcceptanceLedgerStatus;\n\terror?: string;\n}\n\nexport interface WorkflowGraphSnapshot {\n\trunId: string;\n\tmode: \"chain\" | \"parallel\" | \"single\";\n\tphases: Array<{ title: string; nodeIds: string[] }>;\n\tnodes: WorkflowGraphNode[];\n\tcurrentNodeId?: string;\n}\n\nexport interface SavedOutputReference {\n\tpath: string;\n\tbytes: number;\n\tlines: number;\n\tmessage: string;\n}\n\ninterface TruncationResult {\n\ttext: string;\n\ttruncated: boolean;\n\toriginalBytes?: number;\n\toriginalLines?: number;\n\tartifactPath?: string;\n}\n\nexport interface Usage {\n\tinput: number;\n\toutput: number;\n\tcacheRead: number;\n\tcacheWrite: number;\n\tcost: number;\n\tturns: number;\n}\n\nexport interface TurnBudgetConfig {\n\tmaxTurns: number;\n\tgraceTurns?: number;\n}\n\nexport interface ResolvedTurnBudget {\n\tmaxTurns: number;\n\tgraceTurns: number;\n}\n\nexport interface ToolBudgetConfig {\n\tsoft?: number;\n\thard: number;\n\tblock?: string[] | \"*\";\n}\n\nexport interface ResolvedToolBudget {\n\tsoft?: number;\n\thard: number;\n\tblock: string[] | \"*\";\n}\n\nexport type ToolBudgetOutcome = \"within-budget\" | \"soft-reached\" | \"hard-blocked\";\n\nexport interface ToolBudgetState extends ResolvedToolBudget {\n\toutcome: ToolBudgetOutcome;\n\ttoolCount: number;\n\tsoftReachedAt?: number;\n\thardReachedAt?: number;\n\tblockedTool?: string;\n}\n\nexport type TurnBudgetOutcome = \"within-budget\" | \"wrap-up-requested\" | \"exceeded\";\n\nexport interface TurnBudgetState extends ResolvedTurnBudget {\n\toutcome: TurnBudgetOutcome;\n\tturnCount: number;\n\twrapUpRequestedAtTurn?: number;\n\texceededAtTurn?: number;\n}\n\nexport interface TokenUsage {\n\tinput: number;\n\toutput: number;\n\ttotal: number;\n}\n\nexport type ActivityState = \"active_long_running\" | \"needs_attention\";\nexport type ControlEventType = \"active_long_running\" | \"needs_attention\";\nexport type ControlNotificationChannel = \"event\" | \"async\" | \"intercom\";\n\nexport interface ControlConfig {\n\tenabled?: boolean;\n\tneedsAttentionAfterMs?: number;\n\tactiveNoticeAfterMs?: number;\n\tactiveNoticeAfterTurns?: number;\n\tactiveNoticeAfterTokens?: number;\n\tfailedToolAttemptsBeforeAttention?: number;\n\tnotifyOn?: ControlEventType[];\n\tnotifyChannels?: ControlNotificationChannel[];\n}\n\nexport interface ResolvedControlConfig {\n\tenabled: boolean;\n\tneedsAttentionAfterMs: number;\n\tactiveNoticeAfterMs: number;\n\tactiveNoticeAfterTurns?: number;\n\tactiveNoticeAfterTokens?: number;\n\tfailedToolAttemptsBeforeAttention: number;\n\tnotifyOn: ControlEventType[];\n\tnotifyChannels: ControlNotificationChannel[];\n}\n\n/**\n * Smart completion batching for async-completion notifications. Successful\n * sibling completions are held briefly so they arrive as one grouped message;\n * failure and attention signals bypass grouping and always fire immediately.\n */\nexport interface CompletionBatchConfig {\n\tenabled?: boolean;\n\t/** Idle window after each arrival; resets on every new item. */\n\tdebounceMs?: number;\n\t/** Hard cap measured from the first item in a group. */\n\tmaxWaitMs?: number;\n\t/** Shorter idle window for straggler groups. */\n\tstragglerDebounceMs?: number;\n\t/** Shorter hard cap for straggler groups. */\n\tstragglerMaxWaitMs?: number;\n\t/** Arrivals within this window after an emit join a straggler group. */\n\tstragglerWindowMs?: number;\n}\n\nexport interface WaitToolConfigObject {\n\tenabled?: boolean;\n}\n\nexport type WaitToolConfig = boolean | WaitToolConfigObject;\n\nexport interface ControlEvent {\n\ttype: ControlEventType;\n\tfrom?: ActivityState;\n\tto: ActivityState;\n\tts: number;\n\tagent: string;\n\tindex?: number;\n\trunId: string;\n\tnestedRunId?: string;\n\tnestingPath?: NestedRunAddress[\"path\"];\n\tmessage: string;\n\treason?: \"idle\" | \"completion_guard\" | \"active_long_running\" | \"tool_failures\" | \"time_threshold\" | \"turn_threshold\" | \"token_threshold\";\n\tturns?: number;\n\ttokens?: number;\n\ttoolCount?: number;\n\tcurrentTool?: string;\n\tcurrentToolDurationMs?: number;\n\tcurrentPath?: string;\n\telapsedMs?: number;\n\trecentFailureSummary?: string;\n}\n\nexport type SubagentResultStatus = \"completed\" | \"failed\" | \"paused\" | \"stopped\" | \"detached\";\nexport type SubagentRunMode = \"single\" | \"parallel\" | \"chain\";\nexport const SUBAGENT_LIFECYCLE_ARTIFACT_VERSION = 3;\nexport type SubagentLifecycleArtifactVersion = typeof SUBAGENT_LIFECYCLE_ARTIFACT_VERSION;\nexport const UNSUPPORTED_SUBAGENT_LIFECYCLE_MESSAGE =\n\t\"This subagent run uses an unsupported lifecycle format. Named agent types cannot be resumed. Launch a new prompt-driven child instead.\";\n\nexport function isSupportedSubagentLifecycleVersion(version: unknown): boolean {\n\treturn version === SUBAGENT_LIFECYCLE_ARTIFACT_VERSION;\n}\n\nexport type SteeringActionState = \"delivered\" | \"scheduled\" | \"pending\" | \"partial\" | \"recovered\" | \"failed\";\nexport type SteeringTargetState = \"scheduled\" | \"routed\" | \"delivered\" | \"late\" | \"failed\" | \"recovered\";\n\nexport interface SteeringTargetStatus {\n\tindex: number;\n\tstate: SteeringTargetState;\n\troutedAt?: number;\n\tdeliveredAt?: number;\n\tlateDeliveredAt?: number;\n\tfailedAt?: number;\n\trecoveredAt?: number;\n\treason?: string;\n\treplacementRunId?: string;\n}\n\nexport interface SteeringRequestStatus {\n\tid: string;\n\trequestedAt: number;\n\tsource?: string;\n\tmessagePreview: string;\n\ttargets: SteeringTargetStatus[];\n}\n\nexport interface SteeringStatus {\n\trequested: number;\n\tscheduled: number;\n\tpending: number;\n\tdelivered: number;\n\tfailed: number;\n\trecovered: number;\n\tlastRequestedAt?: number;\n\tlastDeliveredAt?: number;\n\trecent: SteeringRequestStatus[];\n}\n\nexport interface SteerActionTarget {\n\tindex: number;\n\tstate: SteeringTargetState;\n\tdeliveredAt?: number;\n\tlateDeliveredAt?: number;\n\treason?: string;\n\treplacementRunId?: string;\n}\n\nexport interface SteerActionResult {\n\trequestId: string;\n\tstate: SteeringActionState;\n\tsourceRunId: string;\n\treplacementRunId?: string;\n\ttargets: SteerActionTarget[];\n}\n\nexport interface SteeringNotice {\n\ttype: \"subagent.steering.notice\";\n\tts: number;\n\trunId: string;\n\trequestId: string;\n\tstate: \"failed\" | \"partial\" | \"recovered\";\n\tmessage: string;\n\tcurrentSessionId?: string;\n}\n\nexport interface SteeringRecoveryDescriptor {\n\tversion: 3;\n\tlifecycleArtifactVersion?: SubagentLifecycleArtifactVersion;\n\tsourceRunId: string;\n\tchildId: string;\n\tdescription: string;\n\tpermissions: ChildPermission;\n\tagent: string;\n\tsessionFile?: string;\n\tcwd: string;\n\tmodel?: string;\n\tthinking?: string;\n\tskills?: string[];\n\toutputPath?: string;\n\toutputMode: \"inline\" | \"file-only\";\n\tacceptance?: AcceptanceInput;\n\tcontrolConfig?: ResolvedControlConfig;\n\tabsoluteDeadlineAt?: number;\n\tinitialTurnBudget?: ResolvedTurnBudget;\n\tinitialToolBudget?: ResolvedToolBudget;\n\tmaxSubagentDepth: number;\n\tmaxOutput?: MaxOutputConfig;\n\tshare: boolean;\n\tsessionDir?: string;\n\tartifactsDir?: string;\n\tartifactConfig?: ArtifactConfig;\n}\n\nexport type PublicNestedStepSummary = Pick<\n\tNestedStepSummary,\n\t\"agent\" | \"status\" | \"sessionFile\" | \"transcriptPath\" | \"transcriptError\" | \"activityState\" | \"lastActivityAt\" | \"currentTool\" | \"currentToolStartedAt\" | \"currentPath\" | \"turnCount\" | \"toolCount\" | \"toolBudget\" | \"toolBudgetBlocked\" | \"startedAt\" | \"endedAt\" | \"error\" | \"timedOut\" | \"stopped\"\n> & {\n\tchildren?: PublicNestedRunSummary[];\n};\n\nexport type CostSummary = {\n\tinputTokens: number;\n\toutputTokens: number;\n\tcostUsd: number;\n};\n\nexport type PublicNestedRunSummary = Pick<\n\tNestedRunSummary,\n\t\"id\" | \"parentRunId\" | \"parentStepIndex\" | \"parentAgent\" | \"depth\" | \"path\" | \"asyncDir\" | \"sessionId\" | \"sessionFile\" | \"intercomTarget\" | \"ownerIntercomTarget\" | \"leafIntercomTarget\" | \"ownerState\" | \"mode\" | \"state\" | \"agent\" | \"agents\" | \"currentStep\" | \"chainStepCount\" | \"parallelGroups\" | \"activityState\" | \"lastActivityAt\" | \"currentTool\" | \"currentToolStartedAt\" | \"currentPath\" | \"turnCount\" | \"toolCount\" | \"toolBudget\" | \"toolBudgetBlocked\" | \"totalTokens\" | \"totalCost\" | \"startedAt\" | \"endedAt\" | \"lastUpdate\" | \"error\" | \"timeoutMs\" | \"deadlineAt\" | \"timedOut\" | \"stopped\" | \"turnBudget\" | \"turnBudgetExceeded\" | \"wrapUpRequested\"\n> & {\n\tsteps?: PublicNestedStepSummary[];\n\tchildren?: PublicNestedRunSummary[];\n};\n\nexport interface SubagentResultIntercomChild {\n\tagent: string;\n\tstatus: SubagentResultStatus;\n\tsummary: string;\n\tindex?: number;\n\tartifactPath?: string;\n\tsessionPath?: string;\n\tintercomTarget?: string;\n\tchildren?: PublicNestedRunSummary[];\n}\n\nexport interface SubagentResultIntercomPayload {\n\tto: string;\n\tmessage: string;\n\trequestId?: string;\n\trunId: string;\n\tmode: SubagentRunMode;\n\tstatus: SubagentResultStatus;\n\tsummary: string;\n\tsource: \"foreground\" | \"async\";\n\tchildren: SubagentResultIntercomChild[];\n\tasyncId?: string;\n\tasyncDir?: string;\n\tchainSteps?: number;\n\tagent?: string;\n\tindex?: number;\n\tartifactPath?: string;\n\tsessionPath?: string;\n}\n\n// ============================================================================\n// Progress Tracking\n// ============================================================================\n\nexport interface ChildWatchdogProgress {\n\tphase: \"idle\" | \"reviewing\" | \"autofollow\" | \"settling\" | \"stale\" | \"failed\";\n\tseq: number;\n\tlastUpdate: number;\n\tfollowUpPending: boolean;\n\treason?: string;\n\ttimedOut?: boolean;\n}\n\nexport interface AgentProgress {\n\tindex: number;\n\tchildId?: string;\n\tdescription?: string;\n\tpermissions?: ChildPermission;\n\tagent: string;\n\tstatus: \"pending\" | \"running\" | \"completed\" | \"failed\" | \"detached\";\n\tactivityState?: ActivityState;\n\ttask: string;\n\tskills?: string[];\n\tlastActivityAt?: number;\n\tcurrentTool?: string;\n\tcurrentToolArgs?: string;\n\tcurrentToolStartedAt?: number;\n\tcurrentPath?: string;\n\tmodel?: string;\n\tthinking?: string;\n\tthinkingText?: string;\n\trecentTools: Array<{ tool: string; args: string; endMs: number }>;\n\trecentOutput: string[];\n\ttoolCount: number;\n\tturnCount?: number;\n\ttokens: number;\n\tdurationMs: number;\n\terror?: string;\n\tfailedTool?: string;\n\twatchdog?: ChildWatchdogProgress;\n}\n\nexport interface ToolCallSummary {\n\ttext: string;\n\texpandedText: string;\n}\n\ninterface ProgressSummary {\n\ttoolCount: number;\n\ttokens: number;\n\tdurationMs: number;\n}\n\n// ============================================================================\n// Results\n// ============================================================================\n\nexport interface ModelAttempt {\n\tmodel: string;\n\tsuccess: boolean;\n\texitCode?: number | null;\n\terror?: string;\n\tusage?: Usage;\n}\n\nexport type AcceptanceLevel = \"auto\" | \"none\" | \"attested\" | \"checked\" | \"verified\" | \"reviewed\";\n\nexport type AcceptanceEvidenceKind =\n\t| \"changed-files\"\n\t| \"tests-added\"\n\t| \"commands-run\"\n\t| \"validation-output\"\n\t| \"residual-risks\"\n\t| \"no-staged-files\"\n\t| \"diff-summary\"\n\t| \"review-findings\"\n\t| \"manual-notes\";\n\nexport interface AcceptanceGate {\n\tid: string;\n\tmust: string;\n\tevidence?: AcceptanceEvidenceKind[];\n\tseverity?: \"required\" | \"recommended\";\n}\n\nexport interface AcceptanceVerifyCommand {\n\tid: string;\n\tcommand: string;\n\ttimeoutMs?: number;\n\tcwd?: string;\n\tenv?: Record<string, string>;\n\tallowFailure?: boolean;\n}\n\nexport interface AcceptanceReviewGate {\n\tagent?: string;\n\tfocus?: string;\n\trequired?: boolean;\n}\n\nexport interface AcceptanceConfig {\n\tlevel?: AcceptanceLevel;\n\tcriteria?: Array<string | AcceptanceGate>;\n\tevidence?: AcceptanceEvidenceKind[];\n\tverify?: AcceptanceVerifyCommand[];\n\treview?: AcceptanceReviewGate | false;\n\tstopRules?: string[];\n\treason?: string;\n}\n\n/** Bare \"none\" is not accepted: use { level: \"none\", reason: \"...\" }; false remains a deprecated shorthand. */\nexport type AcceptanceInput = Exclude<AcceptanceLevel, \"none\"> | false | AcceptanceConfig;\n\nexport interface ResolvedAcceptanceGate extends AcceptanceGate {\n\tid: string;\n\tmust: string;\n\tevidence: AcceptanceEvidenceKind[];\n\tseverity: \"required\" | \"recommended\";\n}\n\nexport interface ResolvedAcceptanceConfig {\n\tlevel: Exclude<AcceptanceLevel, \"auto\">;\n\texplicit: boolean;\n\tinferredReason: string[];\n\tcriteria: ResolvedAcceptanceGate[];\n\tevidence: AcceptanceEvidenceKind[];\n\tverify: AcceptanceVerifyCommand[];\n\treview?: AcceptanceReviewGate | false;\n\tstopRules: string[];\n\treason?: string;\n}\n\nexport interface AcceptanceReport {\n\tcriteriaSatisfied?: Array<{\n\t\tid?: string;\n\t\tstatus: \"satisfied\" | \"not-satisfied\" | \"not-applicable\";\n\t\tevidence: string;\n\t}>;\n\tchangedFiles?: string[];\n\ttestsAddedOrUpdated?: string[];\n\tcommandsRun?: Array<{\n\t\tcommand: string;\n\t\tresult: \"passed\" | \"failed\" | \"not-run\";\n\t\tsummary: string;\n\t}>;\n\tvalidationOutput?: string[];\n\tresidualRisks?: string[];\n\tnoStagedFiles?: boolean;\n\tdiffSummary?: string;\n\treviewFindings?: string[];\n\tmanualNotes?: string;\n\tnotes?: string;\n}\n\nexport type AcceptanceRuntimeCheckStatus = \"passed\" | \"failed\" | \"not-applicable\";\n\nexport interface AcceptanceRuntimeCheck {\n\tid: string;\n\tstatus: AcceptanceRuntimeCheckStatus;\n\tmessage: string;\n}\n\nexport interface AcceptanceVerifyResult {\n\tid: string;\n\tcommand: string;\n\tcwd?: string;\n\texitCode: number | null;\n\tstatus: \"passed\" | \"failed\" | \"timed-out\" | \"allowed-failure\";\n\tstdout?: string;\n\tstderr?: string;\n\tdurationMs: number;\n}\n\nexport interface AcceptanceReviewResult {\n\tstatus: \"no-blockers\" | \"blockers\" | \"needs-parent-decision\";\n\tfindings: Array<{\n\t\tseverity: \"blocker\" | \"non-blocking\";\n\t\tfile?: string;\n\t\tissue: string;\n\t\trationale: string;\n\t}>;\n}\n\nexport type AcceptanceLedgerStatus =\n\t| \"pending\"\n\t| \"not-required\"\n\t| \"claimed\"\n\t| \"attested\"\n\t| \"checked\"\n\t| \"verified\"\n\t| \"reviewed\"\n\t| \"accepted\"\n\t| \"rejected\";\n\nexport interface AcceptanceLedger {\n\tstatus: AcceptanceLedgerStatus;\n\texplicit: boolean;\n\teffectiveAcceptance: ResolvedAcceptanceConfig;\n\tinferredReason: string[];\n\tcriteria: ResolvedAcceptanceGate[];\n\tchildReport?: AcceptanceReport;\n\tchildReportParseError?: string;\n\truntimeChecks: AcceptanceRuntimeCheck[];\n\tverifyRuns: AcceptanceVerifyResult[];\n\treviewResult?: AcceptanceReviewResult;\n\tparentDecision?: {\n\t\tstatus: \"accepted\" | \"rejected\";\n\t\tat: string;\n\t\treason?: string;\n\t};\n}\n\nexport interface ProtocolOutputLimit {\n\tcode: \"protocol_output_limit\";\n\tstream: \"stdout\" | \"stderr\";\n\tlimitBytes: number;\n\tobservedBytes: number;\n\tdiagnosticPrefix: string;\n\tdiagnosticTail: string;\n}\n\nexport interface SingleResult {\n\tchildId?: string;\n\tdescription?: string;\n\tpermissions?: ChildPermission;\n\tagent: string;\n\ttask: string;\n\texitCode: number;\n\tdetached?: boolean;\n\tdetachedReason?: string;\n\tinterrupted?: boolean;\n\ttimedOut?: boolean;\n\tstopped?: boolean;\n\tturnBudget?: TurnBudgetState;\n\tturnBudgetExceeded?: boolean;\n\twrapUpRequested?: boolean;\n\ttoolBudget?: ToolBudgetState;\n\ttoolBudgetBlocked?: boolean;\n\tmessages?: Message[];\n\tusage: Usage;\n\tmodel?: string;\n\tthinking?: string;\n\tattemptedModels?: string[];\n\tmodelAttempts?: ModelAttempt[];\n\tcontrolEvents?: ControlEvent[];\n\terror?: string;\n\tprotocolError?: ProtocolOutputLimit;\n\tsessionFile?: string;\n\tskills?: string[];\n\tskillsWarning?: string;\n\tprogress?: AgentProgress;\n\tprogressSummary?: ProgressSummary;\n\ttoolCalls?: ToolCallSummary[];\n\tartifactPaths?: ArtifactPaths;\n\ttruncation?: TruncationResult;\n\tfinalOutput?: string;\n\toutputMode?: OutputMode;\n\tsavedOutputPath?: string;\n\toutputReference?: SavedOutputReference;\n\toutputSaveError?: string;\n\tstructuredOutput?: unknown;\n\tstructuredOutputPath?: string;\n\tstructuredOutputSchemaPath?: string;\n\tacceptance?: AcceptanceLedger;\n\ttranscriptPath?: string;\n\ttranscriptError?: string;\n\tchildren?: NestedRunSummary[];\n\twatchdog?: ChildWatchdogProgress;\n}\n\nexport interface Details {\n\tmode: SubagentRunMode | \"management\";\n\trunId?: string;\n\tcontext?: \"fresh\" | \"fork\";\n\tresults: SingleResult[];\n\tcontrolEvents?: ControlEvent[];\n\tsteering?: SteerActionResult;\n\tasyncId?: string;\n\tasyncDir?: string;\n\ttimeoutMs?: number;\n\tdeadlineAt?: number;\n\ttimedOut?: boolean;\n\tstopped?: boolean;\n\tturnBudget?: ResolvedTurnBudget;\n\ttoolBudget?: ResolvedToolBudget;\n\tprogress?: AgentProgress[];\n\tprogressSummary?: ProgressSummary;\n\tartifacts?: {\n\t\tdir: string;\n\t\tfiles: ArtifactPaths[];\n\t};\n\ttruncation?: {\n\t\ttruncated: boolean;\n\t\toriginalBytes?: number;\n\t\toriginalLines?: number;\n\t\tartifactPath?: string;\n\t};\n\t// Chain metadata for observability\n\tchainAgents?: string[]; // deprecated: child descriptions in order\n\tchainChildren?: Array<{ childId: string; description: string; permissions: ChildPermission }>;\n\ttotalSteps?: number; // Total steps in chain\n\tcurrentStepIndex?: number; // 0-indexed current step (for running chains)\n\tworkflowGraph?: WorkflowGraphSnapshot;\n\toutputs?: ChainOutputMap;\n\t// Aggregated child usage across all agents in the run\n\ttotalChildUsage?: Usage;\n\t// Aggregated cost across all agents in the run\n\ttotalCost?: CostSummary;\n}\n\n// ============================================================================\n// Artifacts\n// ============================================================================\n\nexport interface ArtifactPaths {\n\tinputPath: string;\n\toutputPath: string;\n\tjsonlPath: string;\n\ttranscriptPath: string;\n\tmetadataPath: string;\n}\n\nexport interface ArtifactConfig {\n\tenabled: boolean;\n\tincludeInput: boolean;\n\tincludeOutput: boolean;\n\tincludeJsonl: boolean;\n\tincludeTranscript?: boolean;\n\tincludeMetadata: boolean;\n\tcleanupDays: number;\n}\n\n// ============================================================================\n// Async Execution\n// ============================================================================\n\nexport interface AsyncParallelGroupStatus {\n\tstart: number;\n\tcount: number;\n\tstepIndex: number;\n}\n\nexport type NestedRunState = \"queued\" | \"running\" | \"complete\" | \"failed\" | \"paused\" | \"stopped\";\nexport type NestedOwnerState = \"live\" | \"gone\" | \"unknown\";\n\nexport interface NestedRunAddress {\n\tid: string;\n\tparentRunId: string;\n\tparentStepIndex?: number;\n\tparentAgent?: string;\n\tdepth: number;\n\tpath: Array<{ runId: string; stepIndex?: number; agent?: string }>;\n}\n\nexport interface NestedStepSummary {\n\tagent: string;\n\tstatus: \"pending\" | \"running\" | \"complete\" | \"completed\" | \"failed\" | \"paused\" | \"stopped\";\n\tsessionFile?: string;\n\ttranscriptPath?: string;\n\ttranscriptError?: string;\n\tactivityState?: ActivityState;\n\tlastActivityAt?: number;\n\tcurrentTool?: string;\n\tcurrentToolStartedAt?: number;\n\tcurrentPath?: string;\n\tturnCount?: number;\n\ttoolCount?: number;\n\tstartedAt?: number;\n\tendedAt?: number;\n\terror?: string;\n\twatchdog?: ChildWatchdogProgress;\n\ttimedOut?: boolean;\n\tstopped?: boolean;\n\tturnBudget?: TurnBudgetState;\n\tturnBudgetExceeded?: boolean;\n\twrapUpRequested?: boolean;\n\ttoolBudget?: ToolBudgetState;\n\ttoolBudgetBlocked?: boolean;\n\tchildren?: NestedRunSummary[];\n}\n\nexport interface NestedRunSummary extends NestedRunAddress {\n\tasyncDir?: string;\n\tpid?: number;\n\tsessionId?: string;\n\tsessionFile?: string;\n\tintercomTarget?: string;\n\townerIntercomTarget?: string;\n\tleafIntercomTarget?: string;\n\townerState?: NestedOwnerState;\n\tcontrolInbox?: string;\n\tcapabilityToken?: string;\n\tmode?: SubagentRunMode;\n\tstate: NestedRunState;\n\tagent?: string;\n\tagents?: string[];\n\tcurrentStep?: number;\n\tchainStepCount?: number;\n\tparallelGroups?: AsyncParallelGroupStatus[];\n\tsteps?: NestedStepSummary[];\n\tchildren?: NestedRunSummary[];\n\tactivityState?: ActivityState;\n\tlastActivityAt?: number;\n\tcurrentTool?: string;\n\tcurrentToolStartedAt?: number;\n\tcurrentPath?: string;\n\tturnCount?: number;\n\ttoolCount?: number;\n\ttotalTokens?: TokenUsage;\n\ttotalCost?: CostSummary;\n\tstartedAt?: number;\n\tendedAt?: number;\n\tlastUpdate?: number;\n\ttimeoutMs?: number;\n\tdeadlineAt?: number;\n\ttimedOut?: boolean;\n\tstopped?: boolean;\n\tturnBudget?: TurnBudgetState;\n\tturnBudgetExceeded?: boolean;\n\twrapUpRequested?: boolean;\n\ttoolBudget?: ToolBudgetState;\n\ttoolBudgetBlocked?: boolean;\n\terror?: string;\n}\n\nexport interface NestedRouteInfo {\n\trootRunId: string;\n\teventSink: string;\n\tcontrolInbox: string;\n\tcapabilityToken: string;\n}\n\nexport interface AsyncStartedEvent {\n\tlifecycleArtifactVersion?: SubagentLifecycleArtifactVersion;\n\tid?: string;\n\tasyncDir?: string;\n\tpid?: number;\n\tsessionId?: string;\n\tmode?: SubagentRunMode;\n\tagent?: string;\n\tagents?: string[];\n\t/** Truncated first child task retained for backwards compatibility. */\n\ttask?: string;\n\t/** Workflow-level caller task, falling back to the first child task. */\n\tgoal?: string;\n\tchain?: string[];\n\tchainStepCount?: number;\n\tparallelGroups?: AsyncParallelGroupStatus[];\n\tworkflowGraph?: WorkflowGraphSnapshot;\n\ttimeoutMs?: number;\n\tdeadlineAt?: number;\n\tturnBudget?: TurnBudgetState;\n\tnestedRoute?: NestedRouteInfo;\n}\n\nexport interface AsyncStatus {\n\tlifecycleArtifactVersion?: SubagentLifecycleArtifactVersion;\n\trunId: string;\n\tsessionId?: string;\n\tmode: SubagentRunMode;\n\tisNested?: boolean;\n\tstate: \"queued\" | \"running\" | \"complete\" | \"failed\" | \"paused\" | \"stopped\";\n\terror?: string;\n\tactivityState?: ActivityState;\n\tlastActivityAt?: number;\n\tcurrentTool?: string;\n\tcurrentToolStartedAt?: number;\n\tcurrentPath?: string;\n\tturnCount?: number;\n\ttoolCount?: number;\n\tsteering?: SteeringStatus;\n\tstartedAt: number;\n\tendedAt?: number;\n\tlastUpdate?: number;\n\ttimeoutMs?: number;\n\tdeadlineAt?: number;\n\ttimedOut?: boolean;\n\tstopped?: boolean;\n\tturnBudget?: TurnBudgetState;\n\tturnBudgetExceeded?: boolean;\n\twrapUpRequested?: boolean;\n\ttoolBudget?: ToolBudgetState;\n\ttoolBudgetBlocked?: boolean;\n\tpid?: number;\n\tcwd?: string;\n\tcurrentStep?: number;\n\tchainStepCount?: number;\n\tpendingAppends?: number;\n\tparallelGroups?: AsyncParallelGroupStatus[];\n\tworkflowGraph?: WorkflowGraphSnapshot;\n\tsteps?: Array<{\n\t\tchildId?: string;\n\t\tdescription?: string;\n\t\tpermissions?: ChildPermission;\n\t\tagent: string;\n\t\tphase?: string;\n\t\tlabel?: string;\n\t\toutputName?: string;\n\t\tstructured?: boolean;\n\t\tstatus: \"pending\" | \"running\" | \"complete\" | \"completed\" | \"failed\" | \"paused\" | \"stopped\";\n\t\tchildren?: NestedRunSummary[];\n\t\tsessionFile?: string;\n\t\ttranscriptPath?: string;\n\t\ttranscriptError?: string;\n\t\tactivityState?: ActivityState;\n\t\tlastActivityAt?: number;\n\t\tcurrentTool?: string;\n\t\tcurrentToolArgs?: string;\n\t\tcurrentToolStartedAt?: number;\n\t\tcurrentPath?: string;\n\t\trecentTools?: Array<{ tool: string; args: string; endMs: number }>;\n\t\trecentOutput?: string[];\n\t\tturnCount?: number;\n\t\ttoolCount?: number;\n\t\tstartedAt?: number;\n\t\tendedAt?: number;\n\t\tdurationMs?: number;\n\t\texitCode?: number | null;\n\t\ttimedOut?: boolean;\n\t\tstopped?: boolean;\n\t\tturnBudget?: TurnBudgetState;\n\t\tturnBudgetExceeded?: boolean;\n\t\twrapUpRequested?: boolean;\n\t\ttoolBudget?: ToolBudgetState;\n\t\ttoolBudgetBlocked?: boolean;\n\t\ttokens?: TokenUsage;\n\t\tskills?: string[];\n\t\tmodel?: string;\n\t\tthinking?: string;\n\t\tattemptedModels?: string[];\n\t\tmodelAttempts?: ModelAttempt[];\n\t\ttotalCost?: CostSummary;\n\t\tsteering?: SteeringStatus;\n\t\terror?: string;\n\t\tstructuredOutput?: unknown;\n\t\tstructuredOutputPath?: string;\n\t\tstructuredOutputSchemaPath?: string;\n\t\tacceptance?: AcceptanceLedger;\n\t\twatchdog?: ChildWatchdogProgress;\n\t}>;\n\tsessionDir?: string;\n\toutputFile?: string;\n\ttotalTokens?: TokenUsage;\n\ttotalCost?: CostSummary;\n\tsessionFile?: string;\n\toutputs?: ChainOutputMap;\n}\n\nexport type AsyncJobStep = NonNullable<AsyncStatus[\"steps\"]>[number] & {\n\tindex?: number;\n};\n\nexport interface AsyncJobState {\n\tasyncId: string;\n\tasyncDir: string;\n\tstatus: \"queued\" | \"running\" | \"complete\" | \"failed\" | \"paused\" | \"stopped\";\n\tpid?: number;\n\tsessionId?: string;\n\tactivityState?: ActivityState;\n\tlastActivityAt?: number;\n\tcurrentTool?: string;\n\tcurrentToolStartedAt?: number;\n\tcurrentPath?: string;\n\tturnCount?: number;\n\ttoolCount?: number;\n\tsteering?: SteeringStatus;\n\tmode?: SubagentRunMode;\n\tagents?: string[];\n\tcurrentStep?: number;\n\tchainStepCount?: number;\n\tparallelGroups?: AsyncParallelGroupStatus[];\n\tsteps?: AsyncJobStep[];\n\tstepsTotal?: number;\n\trunningSteps?: number;\n\tcompletedSteps?: number;\n\thasParallelGroups?: boolean;\n\tactiveParallelGroup?: boolean;\n\tstartedAt?: number;\n\tupdatedAt?: number;\n\ttimeoutMs?: number;\n\tdeadlineAt?: number;\n\ttimedOut?: boolean;\n\tstopped?: boolean;\n\tturnBudget?: TurnBudgetState;\n\tturnBudgetExceeded?: boolean;\n\twrapUpRequested?: boolean;\n\ttoolBudget?: ToolBudgetState;\n\ttoolBudgetBlocked?: boolean;\n\tsessionDir?: string;\n\toutputFile?: string;\n\ttotalTokens?: TokenUsage;\n\tsessionFile?: string;\n\tcontrolEventCursor?: number;\n\tnestedRoute?: NestedRouteInfo;\n\tnestedChildren?: NestedRunSummary[];\n}\n\nexport interface ForegroundResumeChild {\n\tagent: string;\n\tindex: number;\n\tsessionFile?: string;\n\tstatus: SubagentResultStatus;\n\texitCode?: number;\n\terror?: string;\n\tfinalOutput?: string;\n\toutputMode?: OutputMode;\n\tsavedOutputPath?: string;\n\toutputSaveError?: string;\n\tartifactPaths?: ArtifactPaths;\n\ttranscriptPath?: string;\n\ttranscriptError?: string;\n\tdetachedReason?: string;\n\tacceptance?: AcceptanceLedger;\n\tupdatedAt?: number;\n}\n\nexport interface ForegroundResumeRun {\n\trunId: string;\n\tmode: SubagentRunMode;\n\tcwd: string;\n\t/** Originating parent session. Detached exits can outlive the active session. */\n\tsessionId?: string;\n\tupdatedAt: number;\n\tchildren: ForegroundResumeChild[];\n}\n\nexport interface SubagentState {\n\tbaseCwd: string;\n\tcurrentSessionId: string | null;\n\t/** Live foreground `subagent` tool calls. Caps same-turn overlap. */\n\tforegroundSubagentInFlight?: number;\n\tsubagentSpawns?: { sessionId: string | null; count: number };\n\tasyncJobs: Map<string, AsyncJobState>;\n\t/** Current-session active and recent async runs for the native fleet inspector. */\n\tfleetJobs?: Map<string, AsyncJobState>;\n\tforegroundRuns?: Map<string, ForegroundResumeRun>;\n\tforegroundControls: Map<string, {\n\t\trunId: string;\n\t\tmode: SubagentRunMode;\n\t\tstartedAt: number;\n\t\tupdatedAt: number;\n\t\tcurrentAgent?: string;\n\t\tcurrentChildId?: string;\n\t\tcurrentIndex?: number;\n\t\tcurrentActivityState?: ActivityState;\n\t\tlastActivityAt?: number;\n\t\tcurrentTool?: string;\n\t\tcurrentToolStartedAt?: number;\n\t\tcurrentPath?: string;\n\t\tturnCount?: number;\n\t\ttokens?: number;\n\t\ttoolCount?: number;\n\t\tnestedRoute?: NestedRouteInfo;\n\t\tnestedChildren?: NestedRunSummary[];\n\t\tinterrupt?: () => boolean;\n\t}>;\n\tlastForegroundControlId: string | null;\n\tpendingForegroundControlNotices?: Map<string, ReturnType<typeof setTimeout>>;\n\tcleanupTimers: Map<string, ReturnType<typeof setTimeout>>;\n\tlastUiContext: ExtensionContext | null;\n\tpoller: NodeJS.Timeout | null;\n\tcompletionSeen: Map<string, number>;\n\twatcher: FSWatcher | null;\n\twatcherRestartTimer: ReturnType<typeof setTimeout> | null;\n\tresultFileCoalescer: {\n\t\tschedule(file: string, delayMs?: number): boolean;\n\t\tclear(): void;\n\t};\n}\n\n// ============================================================================\n// Display\n// ============================================================================\n\nexport type DisplayItem = \n\t| { type: \"text\"; text: string } \n\t| { type: \"tool\"; name: string; args: Record<string, unknown> };\n\n// ============================================================================\n// Error Handling\n// ============================================================================\n\nexport interface ErrorInfo {\n\thasError: boolean;\n\texitCode?: number;\n\terrorType?: string;\n\tdetails?: string;\n}\n\nexport interface IntercomEventBus {\n\ton(channel: string, handler: (data: unknown) => void): () => void;\n\temit(channel: string, data: unknown): void;\n}\n\nexport const INTERCOM_DETACH_REQUEST_EVENT = \"pi-intercom:detach-request\";\nexport const INTERCOM_DETACH_RESPONSE_EVENT = \"pi-intercom:detach-response\";\nexport const SUBAGENT_ASYNC_STARTED_EVENT = \"subagent:async-started\";\nexport const SUBAGENT_ASYNC_COMPLETE_EVENT = \"subagent:async-complete\";\nexport const SUBAGENT_FOREGROUND_COMPLETE_EVENT = \"subagent:foreground-complete\";\nexport const SUBAGENT_CONTROL_EVENT = \"subagent:control-event\";\nexport const SUBAGENT_CONTROL_INTERCOM_EVENT = \"subagent:control-intercom\";\nexport const SUBAGENT_STEERING_NOTICE_EVENT = \"subagent:steering-notice\";\nexport const SUBAGENT_RESULT_INTERCOM_EVENT = \"subagent:result-intercom\";\nexport const SUBAGENT_RESULT_INTERCOM_DELIVERY_EVENT = \"subagent:result-intercom-delivery\";\n\n// ============================================================================\n// Execution Options\n// ============================================================================\n\nexport interface RunSyncOptions {\n\t/** Session id of the direct parent session for permission-system ask forwarding. */\n\tparentSessionId?: string;\n\tcwd?: string;\n\tsignal?: AbortSignal;\n\tinterruptSignal?: AbortSignal;\n\ttimeoutMs?: number;\n\tdeadlineAt?: number;\n\tturnBudget?: ResolvedTurnBudget;\n\ttoolBudget?: ResolvedToolBudget;\n\tallowIntercomDetach?: boolean;\n\tintercomEvents?: IntercomEventBus;\n\tonUpdate?: (r: import(\"@ashx-j/lunr-agent\").AgentToolResult<Details>) => void;\n\tonControlEvent?: (event: ControlEvent) => void;\n\tonDetachedExit?: (result: SingleResult) => void;\n\tcontrolConfig?: ResolvedControlConfig;\n\tintercomSessionName?: string;\n\torchestratorIntercomTarget?: string;\n\tmaxOutput?: MaxOutputConfig;\n\tartifactsDir?: string;\n\tartifactConfig?: ArtifactConfig;\n\trunId: string;\n\tindex?: number;\n\tsessionDir?: string;\n\tsessionFile?: string;\n\tshare?: boolean;\n\toutputPath?: string;\n\toutputMode?: OutputMode;\n\tmaxSubagentDepth?: number;\n\t/** Effective parent wait-tool setting propagated to the child runtime. */\n\twaitToolEnabled?: boolean;\n\tnestedRoute?: NestedRouteInfo;\n\t/** Override the agent's default model (format: \"provider/id\" or just \"id\") */\n\tmodelOverride?: string;\n\t/** Override the agent's default thinking level for this run */\n\tthinkingOverride?: string | false;\n\t/** Registry models available for heuristic bare-model resolution */\n\tavailableModels?: Array<{ provider: string; id: string; fullId: string }>;\n\t/** Current parent-session provider to prefer for ambiguous bare model ids */\n\tpreferredModelProvider?: string;\n\t/** Optional subagent model-scope enforcement for fallback candidates */\n\tmodelScope?: ModelScopeConfig;\n\t/** Skills to make available (overrides agent default if provided) */\n\tskills?: string[];\n\tstructuredOutput?: {\n\t\tschema: JsonSchemaObject;\n\t\tschemaPath: string;\n\t\toutputPath: string;\n\t};\n\tacceptance?: AcceptanceInput;\n\tacceptanceContext?: {\n\t\tmode?: SubagentRunMode;\n\t\tasync?: boolean;\n\t\tdynamic?: boolean;\n\t\tdynamicGroup?: boolean;\n\t};\n}\n\nexport type IntercomBridgeMode = \"off\" | \"fork-only\" | \"always\";\n\nexport interface IntercomBridgeConfig {\n\tmode?: IntercomBridgeMode;\n\tinstructionFile?: string;\n}\n\ninterface TopLevelParallelConfig {\n\tmaxTasks?: number;\n\tconcurrency?: number;\n}\n\ninterface ExtensionChainConfig {\n\tdynamicFanout?: {\n\t\tmaxItems?: number;\n\t};\n}\n\nexport interface ProactiveSkillSubagentsConfig {\n\tenabled?: boolean;\n\tminReferences?: number;\n\tmaxRecommendations?: number;\n\tpreferredAgent?: string;\n}\n\nexport type ToolDescriptionMode = \"full\" | \"compact\" | \"custom\";\n\nexport interface ScheduledRunsConfig {\n\tenabled?: boolean;\n\tmaxLatenessMs?: number;\n\tmaxPending?: number;\n}\n\nexport interface ExtensionConfig {\n\tasyncByDefault?: boolean;\n\t/** Show the above-editor async runs widget. Defaults to true. */\n\tasyncWidget?: boolean;\n\t/** Tool description variant registered for the parent-facing subagent tool. Defaults to full. */\n\ttoolDescriptionMode?: ToolDescriptionMode;\n\tforceTopLevelAsync?: boolean;\n\twaitTool?: WaitToolConfig;\n\tdefaultSessionDir?: string;\n\tsingleRunOutputBaseDir?: string;\n\tmaxSubagentDepth?: number;\n\t/** Optional cumulative session cap. Unset or 0 means unlimited. */\n\tmaxSubagentSpawnsPerSession?: number;\n\t/** Global cap on simultaneously-running subagent tasks within a single run. Unset means unlimited. */\n\tglobalConcurrencyLimit?: number;\n\tcontrol?: ControlConfig;\n\tcompletionBatch?: CompletionBatchConfig;\n\tturnBudget?: TurnBudgetConfig;\n\ttoolBudget?: ToolBudgetConfig;\n\tparallel?: TopLevelParallelConfig;\n\tchain?: ExtensionChainConfig;\n\tworktreeSetupHook?: string;\n\tworktreeSetupHookTimeoutMs?: number;\n\tworktreeBaseDir?: string;\n\tintercomBridge?: IntercomBridgeConfig;\n\tproactiveSkillSubagents?: ProactiveSkillSubagentsConfig | false;\n\tscheduledRuns?: ScheduledRunsConfig;\n}\n\n// ============================================================================\n// Constants\n// ============================================================================\n\nexport const DEFAULT_MAX_OUTPUT: Required<MaxOutputConfig> = {\n\tbytes: 200 * 1024,\n\tlines: 5000,\n};\n\nexport const DEFAULT_ARTIFACT_CONFIG: ArtifactConfig = {\n\tenabled: true,\n\tincludeInput: true,\n\tincludeOutput: true,\n\tincludeJsonl: false,\n\tincludeTranscript: true,\n\tincludeMetadata: true,\n\tcleanupDays: 7,\n};\n\nfunction sanitizeTempScopeSegment(value: string): string {\n\tconst sanitized = value\n\t\t.trim()\n\t\t.replace(/[^A-Za-z0-9._-]+/g, \"-\")\n\t\t.replace(/^-+|-+$/g, \"\");\n\treturn sanitized || \"unknown\";\n}\n\nexport function resolveTempScopeId(options?: {\n\tenv?: NodeJS.ProcessEnv;\n\tgetuid?: (() => number) | undefined;\n\tuserInfo?: (() => { username?: string | null }) | undefined;\n\thomedir?: (() => string) | undefined;\n}): string {\n\tconst env = options?.env ?? process.env;\n\tconst getuid = options && Object.hasOwn(options, \"getuid\")\n\t\t? options.getuid\n\t\t: process.getuid?.bind(process);\n\tif (typeof getuid === \"function\") {\n\t\treturn `uid-${getuid()}`;\n\t}\n\n\tfor (const key of [\"USERNAME\", \"USER\", \"LOGNAME\"] as const) {\n\t\tconst value = env[key];\n\t\tif (value) return `user-${sanitizeTempScopeSegment(value)}`;\n\t}\n\n\tconst userInfo = options && Object.hasOwn(options, \"userInfo\")\n\t\t? options.userInfo\n\t\t: os.userInfo;\n\ttry {\n\t\tconst username = userInfo?.().username;\n\t\tif (username) return `user-${sanitizeTempScopeSegment(username)}`;\n\t} catch {\n\t\t// Fall through to home-directory-based scoping.\n\t}\n\n\tconst homedir = env.USERPROFILE ?? env.HOME;\n\tif (homedir) return `home-${sanitizeTempScopeSegment(homedir)}`;\n\n\tconst resolveHomedir = options && Object.hasOwn(options, \"homedir\")\n\t\t? options.homedir\n\t\t: os.homedir;\n\ttry {\n\t\tconst fallbackHomedir = resolveHomedir?.();\n\t\tif (fallbackHomedir) return `home-${sanitizeTempScopeSegment(fallbackHomedir)}`;\n\t} catch {\n\t\t// Fall through to the last-resort shared scope.\n\t}\n\n\treturn \"shared\";\n}\n\nconst MAX_PARALLEL = Number.MAX_SAFE_INTEGER;\nexport const MAX_CONCURRENCY = Number.MAX_SAFE_INTEGER;\nexport const TEMP_ROOT_DIR = path.join(os.tmpdir(), `pi-subagents-${resolveTempScopeId()}`);\nexport const RESULTS_DIR = path.join(TEMP_ROOT_DIR, \"async-subagent-results\");\nexport const ASYNC_DIR = path.join(TEMP_ROOT_DIR, \"async-subagent-runs\");\nexport const CHAIN_RUNS_DIR = path.join(TEMP_ROOT_DIR, \"chain-runs\");\nexport const TEMP_ARTIFACTS_DIR = path.join(TEMP_ROOT_DIR, \"artifacts\");\nexport const WIDGET_KEY = \"subagent-async\";\nexport const SLASH_RESULT_TYPE = \"subagent-slash-result\";\nexport const SLASH_TEXT_RESULT_TYPE = \"subagent-slash-text-result\";\nexport const SLASH_SUBAGENT_REQUEST_EVENT = \"subagent:slash:request\";\nexport const SLASH_SUBAGENT_STARTED_EVENT = \"subagent:slash:started\";\nexport const SLASH_SUBAGENT_RESPONSE_EVENT = \"subagent:slash:response\";\nexport const SLASH_SUBAGENT_UPDATE_EVENT = \"subagent:slash:update\";\nexport const SLASH_SUBAGENT_CANCEL_EVENT = \"subagent:slash:cancel\";\nexport const POLL_INTERVAL_MS = 250;\nexport const MAX_WIDGET_JOBS = 4;\nexport const DEFAULT_SUBAGENT_MAX_DEPTH = 2;\nexport const SUBAGENT_ACTIONS = [\"status\", \"interrupt\", \"resume\", \"steer\", \"stop\", \"append-step\", \"doctor\", \"watchdog.status\", \"watchdog.check\", \"watchdog.configure\", \"watchdog.recommend-model\", \"schedule\", \"schedule-list\", \"schedule-status\", \"schedule-cancel\"] as const;\nexport const REMOVED_SUBAGENT_ACTIONS = [\"list\", \"get\", \"models\", \"create\", \"update\", \"delete\", \"eject\", \"disable\", \"enable\", \"reset\"] as const;\n\nexport const DEFAULT_FORK_PREAMBLE =\n\t\"You are a delegated subagent running from a fork of the parent session. \" +\n\t\"Treat the inherited conversation as reference-only context, not a live thread to continue. \" +\n\t\"Do not continue or answer prior messages as if they are waiting for a reply. \" +\n\t\"Your sole job is to execute the task below and return a focused result for that task using your tools.\";\n\nfunction normalizeTopLevelParallelValue(value: unknown): number | undefined {\n\tconst parsed = typeof value === \"number\" ? value : typeof value === \"string\" ? Number(value) : NaN;\n\tif (!Number.isInteger(parsed) || parsed < 1) return undefined;\n\treturn parsed;\n}\n\nexport function resolveTopLevelParallelMaxTasks(value: unknown): number {\n\treturn normalizeTopLevelParallelValue(value) ?? MAX_PARALLEL;\n}\n\nexport function resolveTopLevelParallelConcurrency(\n\toverride: unknown,\n\tconfigValue: unknown,\n): number {\n\treturn normalizeTopLevelParallelValue(override)\n\t\t?? normalizeTopLevelParallelValue(configValue)\n\t\t?? MAX_CONCURRENCY;\n}\n\nexport function getAsyncConfigPath(suffix: string): string {\n\treturn path.join(TEMP_ROOT_DIR, `async-cfg-${suffix}.json`);\n}\n\nexport function wrapForkTask(task: string, preamble?: string | false): string {\n\tif (preamble === false) return task;\n\tconst effectivePreamble = preamble ?? DEFAULT_FORK_PREAMBLE;\n\tconst wrappedPrefix = `${effectivePreamble}\\n\\nTask:\\n`;\n\tif (task.startsWith(wrappedPrefix)) return task;\n\treturn `${wrappedPrefix}${task}`;\n}\n\n// ============================================================================\n// Recursion Depth Guard\n// ============================================================================\n\nfunction normalizeNonNegativeInteger(value: unknown): number | undefined {\n\tconst parsed = typeof value === \"number\" ? value : typeof value === \"string\" ? Number(value) : NaN;\n\tif (!Number.isInteger(parsed) || parsed < 0) return undefined;\n\treturn parsed;\n}\n\nexport function normalizeMaxSubagentDepth(value: unknown): number | undefined {\n\treturn normalizeNonNegativeInteger(value);\n}\n\nexport function resolveCurrentMaxSubagentDepth(configMaxDepth?: number): number {\n\treturn normalizeMaxSubagentDepth(process.env.PI_SUBAGENT_MAX_DEPTH)\n\t\t?? normalizeMaxSubagentDepth(configMaxDepth)\n\t\t?? DEFAULT_SUBAGENT_MAX_DEPTH;\n}\n\nexport function resolveChildMaxSubagentDepth(parentMaxDepth: number, agentMaxDepth?: number): number {\n\tconst normalizedParent = normalizeMaxSubagentDepth(parentMaxDepth) ?? DEFAULT_SUBAGENT_MAX_DEPTH;\n\tconst normalizedAgent = normalizeMaxSubagentDepth(agentMaxDepth);\n\treturn normalizedAgent === undefined ? normalizedParent : Math.min(normalizedParent, normalizedAgent);\n}\n\nexport function checkSubagentDepth(configMaxDepth?: number): { blocked: boolean; depth: number; maxDepth: number } {\n\tconst depth = Number(process.env.PI_SUBAGENT_DEPTH ?? \"0\");\n\tconst maxDepth = resolveCurrentMaxSubagentDepth(configMaxDepth);\n\tconst blocked = Number.isFinite(depth) && depth >= maxDepth;\n\treturn { blocked, depth, maxDepth };\n}\n\nexport function getSubagentDepthEnv(maxDepth?: number): Record<string, string> {\n\tconst parentDepth = Number(process.env.PI_SUBAGENT_DEPTH ?? \"0\");\n\tconst nextDepth = Number.isFinite(parentDepth) ? parentDepth + 1 : 1;\n\treturn {\n\t\tPI_SUBAGENT_DEPTH: String(nextDepth),\n\t\tPI_SUBAGENT_MAX_DEPTH: String(normalizeMaxSubagentDepth(maxDepth) ?? resolveCurrentMaxSubagentDepth()),\n\t};\n}\n\nexport function normalizeMaxSubagentSpawnsPerSession(value: unknown): number | undefined {\n\treturn normalizeNonNegativeInteger(value);\n}\n\nexport function resolveMaxSubagentSpawnsPerSession(configMaxSpawns?: number): number | undefined {\n\tconst envMaxSpawns = normalizeMaxSubagentSpawnsPerSession(process.env.PI_SUBAGENT_MAX_SPAWNS_PER_SESSION);\n\tif (envMaxSpawns !== undefined) return envMaxSpawns === 0 ? undefined : envMaxSpawns;\n\tconst configuredMaxSpawns = normalizeMaxSubagentSpawnsPerSession(configMaxSpawns);\n\treturn configuredMaxSpawns === 0 ? undefined : configuredMaxSpawns;\n}\n\n// ============================================================================\n// Utility Functions\n// ============================================================================\n\nfunction formatBytes(bytes: number): string {\n\tif (bytes < 1024) return `${bytes}B`;\n\tif (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)}KB`;\n\treturn `${(bytes / (1024 * 1024)).toFixed(1)}MB`;\n}\n\nexport function truncateOutput(\n\toutput: string,\n\tconfig: Required<MaxOutputConfig>,\n\tartifactPath?: string,\n): TruncationResult {\n\tconst lines = output.split(\"\\n\");\n\tconst bytes = Buffer.byteLength(output, \"utf-8\");\n\n\tif (bytes <= config.bytes && lines.length <= config.lines) {\n\t\treturn { text: output, truncated: false };\n\t}\n\n\tlet truncatedLines = lines;\n\tif (lines.length > config.lines) {\n\t\ttruncatedLines = lines.slice(0, config.lines);\n\t}\n\n\tlet result = truncatedLines.join(\"\\n\");\n\tif (Buffer.byteLength(result, \"utf-8\") > config.bytes) {\n\t\tlet low = 0;\n\t\tlet high = result.length;\n\t\twhile (low < high) {\n\t\t\tconst mid = Math.floor((low + high + 1) / 2);\n\t\t\tif (Buffer.byteLength(result.slice(0, mid), \"utf-8\") <= config.bytes) {\n\t\t\t\tlow = mid;\n\t\t\t} else {\n\t\t\t\thigh = mid - 1;\n\t\t\t}\n\t\t}\n\t\tresult = result.slice(0, low);\n\t}\n\n\tconst keptLines = result.split(\"\\n\").length;\n\tconst marker = `[TRUNCATED: showing first ${keptLines} of ${lines.length} lines, ${formatBytes(Buffer.byteLength(result))} of ${formatBytes(bytes)}${artifactPath ? ` - full output at ${artifactPath}` : \"\"}]\\n`;\n\n\treturn {\n\t\ttext: marker + result,\n\t\ttruncated: true,\n\t\toriginalBytes: bytes,\n\t\toriginalLines: lines.length,\n\t\tartifactPath,\n\t};\n}\n"]}
@@ -5,8 +5,8 @@ interface PromptWorkflow {
5
5
  description: string;
6
6
  body: string;
7
7
  filePath: string;
8
- agent: string;
9
- context?: "fresh" | "fork";
8
+ childDescription: string;
9
+ permissions: "full" | "read-only";
10
10
  model?: string;
11
11
  skill?: string | string[] | false;
12
12
  cwd?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"prompt-workflows.d.ts","sourceRoot":"","sources":["../../../../../src/builtin-extensions/pi-subagents/src/slash/prompt-workflows.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAEtF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAIlF,UAAU,cAAc;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,KAAK,CAAC;IAClC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAED,KAAK,oBAAoB,GAAG,CAAC,MAAM,EAAE,kBAAkB,EAAE,GAAG,EAAE,gBAAgB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AA+FjG,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,EAAE,CAOrE;AA0ID,wBAAgB,8BAA8B,CAAC,KAAK,EAAE;IACrD,EAAE,EAAE,YAAY,CAAC;IACjB,GAAG,EAAE,oBAAoB,CAAC;CAC1B,GAAG,IAAI,CAgEP","sourcesContent":["// @ts-nocheck\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport type { ExtensionAPI, ExtensionContext } from \"@ashx-j/lunr\";\nimport { parseFrontmatter } from \"../agents/frontmatter.ts\";\nimport type { SubagentParamsLike } from \"../runs/foreground/subagent-executor.ts\";\nimport type { ChainStep } from \"../shared/settings.ts\";\nimport { getAgentDir, getProjectConfigDir } from \"../shared/utils.ts\";\n\ninterface PromptWorkflow {\n\tname: string;\n\tdescription: string;\n\tbody: string;\n\tfilePath: string;\n\tagent: string;\n\tcontext?: \"fresh\" | \"fork\";\n\tmodel?: string;\n\tskill?: string | string[] | false;\n\tcwd?: string;\n\tworktree?: boolean;\n\tchain?: string;\n}\n\ntype PromptWorkflowRunner = (params: SubagentParamsLike, ctx: ExtensionContext) => Promise<void>;\n\nconst RESERVED_COMMAND_NAMES = new Set([\n\t\"chain-prompts\",\n\t\"prompt-workflow\",\n\t\"run\",\n\t\"chain\",\n\t\"parallel\",\n\t\"run-chain\",\n\t\"subagents-doctor\",\n\t\"subagents-models\",\n]);\n\nfunction packagePromptsDir(): string {\n\treturn path.resolve(path.dirname(fileURLToPath(import.meta.url)), \"..\", \"..\", \"prompts\");\n}\n\nfunction promptDirs(cwd: string): string[] {\n\treturn [\n\t\tpackagePromptsDir(),\n\t\tpath.join(getAgentDir(), \"prompts\"),\n\t\tpath.join(getProjectConfigDir(cwd), \"prompts\"),\n\t];\n}\n\nfunction readPromptFiles(cwd: string): string[] {\n\tconst files: string[] = [];\n\tfor (const dir of promptDirs(cwd)) {\n\t\tlet entries: fs.Dirent[];\n\t\ttry {\n\t\t\tentries = fs.readdirSync(dir, { withFileTypes: true });\n\t\t} catch {\n\t\t\tcontinue;\n\t\t}\n\t\tfor (const entry of entries) {\n\t\t\tif (entry.isFile() && entry.name.endsWith(\".md\")) files.push(path.join(dir, entry.name));\n\t\t}\n\t}\n\treturn files;\n}\n\nfunction firstNonEmptyLine(value: string): string {\n\treturn value.split(/\\r?\\n/).map((line) => line.trim()).find(Boolean) ?? \"Prompt workflow\";\n}\n\nfunction stringField(frontmatter: Record<string, string>, key: string): string | undefined {\n\tconst value = frontmatter[key]?.trim();\n\treturn value ? value : undefined;\n}\n\nfunction booleanField(frontmatter: Record<string, string>, key: string): boolean | undefined {\n\tconst value = frontmatter[key]?.trim().toLowerCase();\n\tif (value === \"true\" || value === \"yes\" || value === \"1\") return true;\n\tif (value === \"false\" || value === \"no\" || value === \"0\") return false;\n\treturn undefined;\n}\n\nfunction parseSkill(value: string | undefined): string | string[] | false | undefined {\n\tif (!value) return undefined;\n\tif (value === \"false\") return false;\n\tconst parts = value.split(\",\").map((part) => part.trim()).filter(Boolean);\n\treturn parts.length > 1 ? parts : parts[0];\n}\n\nfunction parseAgent(frontmatter: Record<string, string>): string {\n\tconst subagent = stringField(frontmatter, \"subagent\");\n\tif (!subagent || subagent === \"true\") return \"delegate\";\n\treturn subagent;\n}\n\nfunction loadPromptWorkflow(filePath: string): PromptWorkflow | undefined {\n\tconst content = fs.readFileSync(filePath, \"utf-8\");\n\tconst { frontmatter, body } = parseFrontmatter(content);\n\tconst name = path.basename(filePath, \".md\");\n\tif (!name || RESERVED_COMMAND_NAMES.has(name)) return undefined;\n\tconst model = stringField(frontmatter, \"model\");\n\tconst skill = parseSkill(stringField(frontmatter, \"skill\"));\n\tconst cwd = stringField(frontmatter, \"cwd\");\n\tconst chain = stringField(frontmatter, \"chain\");\n\treturn {\n\t\tname,\n\t\tdescription: stringField(frontmatter, \"description\") ?? firstNonEmptyLine(body),\n\t\tbody,\n\t\tfilePath,\n\t\tagent: parseAgent(frontmatter),\n\t\t...(booleanField(frontmatter, \"inheritContext\") === true || booleanField(frontmatter, \"fork\") === true ? { context: \"fork\" as const } : {}),\n\t\t...(booleanField(frontmatter, \"fresh\") === true ? { context: \"fresh\" as const } : {}),\n\t\t...(model ? { model } : {}),\n\t\t...(skill !== undefined ? { skill } : {}),\n\t\t...(cwd ? { cwd } : {}),\n\t\t...(booleanField(frontmatter, \"worktree\") === true ? { worktree: true } : {}),\n\t\t...(chain ? { chain } : {}),\n\t};\n}\n\nexport function discoverPromptWorkflows(cwd: string): PromptWorkflow[] {\n\tconst workflows = new Map<string, PromptWorkflow>();\n\tfor (const file of readPromptFiles(cwd)) {\n\t\tconst workflow = loadPromptWorkflow(file);\n\t\tif (workflow) workflows.set(workflow.name, workflow);\n\t}\n\treturn [...workflows.values()].sort((a, b) => a.name.localeCompare(b.name));\n}\n\nfunction shellWords(input: string): string[] {\n\tconst words: string[] = [];\n\tlet current = \"\";\n\tlet quote: \"'\" | '\"' | undefined;\n\tlet escaped = false;\n\tfor (const ch of input) {\n\t\tif (escaped) {\n\t\t\tcurrent += ch;\n\t\t\tescaped = false;\n\t\t\tcontinue;\n\t\t}\n\t\tif (ch === \"\\\\\") {\n\t\t\tescaped = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (quote) {\n\t\t\tif (ch === quote) quote = undefined;\n\t\t\telse current += ch;\n\t\t\tcontinue;\n\t\t}\n\t\tif (ch === \"'\" || ch === '\"') {\n\t\t\tquote = ch;\n\t\t\tcontinue;\n\t\t}\n\t\tif (/\\s/.test(ch)) {\n\t\t\tif (current) {\n\t\t\t\twords.push(current);\n\t\t\t\tcurrent = \"\";\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tcurrent += ch;\n\t}\n\tif (current) words.push(current);\n\treturn words;\n}\n\nfunction substituteArgs(template: string, args: string[]): string {\n\tconst all = args.join(\" \");\n\treturn template\n\t\t.replace(/\\$ARGUMENTS/g, all)\n\t\t.replace(/\\$@/g, all)\n\t\t.replace(/\\$\\{(\\d+):-([^}]*)\\}/g, (_match, index: string, fallback: string) => args[Number(index) - 1] || fallback)\n\t\t.replace(/\\$(\\d+)/g, (_match, index: string) => args[Number(index) - 1] ?? \"\");\n}\n\nfunction parseRuntimeOptions(words: string[]): { args: string[]; agentOverride?: string; fork?: boolean; fresh?: boolean; worktree?: boolean; bg?: boolean } {\n\tconst args: string[] = [];\n\tlet agentOverride: string | undefined;\n\tlet fork = false;\n\tlet fresh = false;\n\tlet worktree = false;\n\tlet bg = false;\n\tfor (let i = 0; i < words.length; i++) {\n\t\tconst word = words[i]!;\n\t\tif (word === \"--fork\") {\n\t\t\tfork = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (word === \"--fresh\") {\n\t\t\tfresh = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (word === \"--worktree\") {\n\t\t\tworktree = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (word === \"--bg\" || word === \"--async\") {\n\t\t\tbg = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (word === \"--subagent\") {\n\t\t\tagentOverride = words[++i];\n\t\t\tcontinue;\n\t\t}\n\t\tconst eq = word.match(/^--subagent(?:=|:)(.+)$/);\n\t\tif (eq) {\n\t\t\tagentOverride = eq[1];\n\t\t\tcontinue;\n\t\t}\n\t\targs.push(word);\n\t}\n\treturn { args, agentOverride, fork, fresh, worktree, bg };\n}\n\nfunction splitChainDeclaration(input: string): { declaration: string; argsText: string } {\n\tconst delimiter = input.indexOf(\" -- \");\n\tif (delimiter === -1) return { declaration: input.trim(), argsText: \"\" };\n\treturn { declaration: input.slice(0, delimiter).trim(), argsText: input.slice(delimiter + 4).trim() };\n}\n\nfunction splitPromptChain(input: string): string[] {\n\treturn input.split(\" -> \").map((part) => part.trim()).filter(Boolean);\n}\n\nfunction workflowParams(workflow: PromptWorkflow, args: string[], runtime: ReturnType<typeof parseRuntimeOptions>): SubagentParamsLike {\n\tconst task = substituteArgs(workflow.body, args).trim();\n\t// lunr: --fork is parsed so it is not a task word; children always start fresh.\n\tconst context = \"fresh\";\n\treturn {\n\t\tagent: runtime.agentOverride ?? workflow.agent,\n\t\ttask,\n\t\tclarify: false,\n\t\tagentScope: \"both\",\n\t\t...(context ? { context } : {}),\n\t\t...(workflow.model ? { model: workflow.model } : {}),\n\t\t...(workflow.skill !== undefined ? { skill: workflow.skill } : {}),\n\t\t...(workflow.cwd ? { cwd: workflow.cwd } : {}),\n\t\t...(runtime.worktree || workflow.worktree ? { worktree: true } : {}),\n\t\t...(runtime.bg ? { async: true } : {}),\n\t};\n}\n\nfunction workflowChainStep(workflow: PromptWorkflow, args: string[], runtime: ReturnType<typeof parseRuntimeOptions>): ChainStep {\n\tconst params = workflowParams(workflow, args, runtime);\n\treturn {\n\t\tagent: params.agent ?? \"delegate\",\n\t\ttask: params.task,\n\t\t...(params.model ? { model: params.model } : {}),\n\t\t...(params.skill !== undefined ? { skill: params.skill } : {}),\n\t\t...(params.cwd ? { cwd: params.cwd } : {}),\n\t};\n}\n\nfunction findWorkflow(workflows: PromptWorkflow[], name: string): PromptWorkflow | undefined {\n\treturn workflows.find((workflow) => workflow.name === name);\n}\n\nfunction formatWorkflowList(workflows: PromptWorkflow[]): string {\n\tif (workflows.length === 0) return \"No prompt workflows found in package, user, or project prompts.\";\n\treturn [\n\t\t\"Prompt workflows:\",\n\t\t...workflows.map((workflow) => `- ${workflow.name}: ${workflow.description} (${workflow.filePath})`),\n\t].join(\"\\n\");\n}\n\nexport function registerPromptWorkflowCommands(input: {\n\tpi: ExtensionAPI;\n\trun: PromptWorkflowRunner;\n}): void {\n\tconst { pi, run } = input;\n\n\tpi.registerCommand(\"prompt-workflow\", {\n\t\tdescription: \"Run a prompt template through native pi-subagents: /prompt-workflow <name> [args]\",\n\t\thandler: async (rawArgs, ctx) => {\n\t\t\tconst words = shellWords(rawArgs);\n\t\t\tconst name = words.shift();\n\t\t\tconst workflows = discoverPromptWorkflows(ctx.cwd);\n\t\t\tif (!name || name === \"list\") {\n\t\t\t\tpi.sendMessage({ content: formatWorkflowList(workflows), display: true });\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst workflow = findWorkflow(workflows, name);\n\t\t\tif (!workflow) {\n\t\t\t\tctx.ui.notify(`Unknown prompt workflow: ${name}`, \"error\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst runtime = parseRuntimeOptions(words);\n\t\t\ttry {\n\t\t\t\tif (workflow.chain) {\n\t\t\t\t\tconst chainNames = splitPromptChain(workflow.chain);\n\t\t\t\t\tconst chain = chainNames.map((stepName) => {\n\t\t\t\t\t\tconst step = findWorkflow(workflows, stepName);\n\t\t\t\t\t\tif (!step) throw new Error(`Unknown prompt workflow in chain '${workflow.name}': ${stepName}`);\n\t\t\t\t\t\treturn workflowChainStep(step, runtime.args, runtime);\n\t\t\t\t\t});\n\t\t\t\t\tawait run({ chain, task: runtime.args.join(\" \"), clarify: false, agentScope: \"both\", ...(runtime.bg ? { async: true } : {}) }, ctx);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tawait run(workflowParams(workflow, runtime.args, runtime), ctx);\n\t\t\t} catch (error) {\n\t\t\t\tctx.ui.notify(error instanceof Error ? error.message : String(error), \"error\");\n\t\t\t}\n\t\t},\n\t});\n\n\tpi.registerCommand(\"chain-prompts\", {\n\t\tdescription: \"Run prompt templates as a native subagent chain: /chain-prompts analyze -> fix -- args\",\n\t\thandler: async (rawArgs, ctx) => {\n\t\t\tconst { declaration, argsText } = splitChainDeclaration(rawArgs);\n\t\t\tconst workflows = discoverPromptWorkflows(ctx.cwd);\n\t\t\tif (!declaration || declaration === \"list\") {\n\t\t\t\tpi.sendMessage({ content: formatWorkflowList(workflows), display: true });\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst runtime = parseRuntimeOptions(shellWords(argsText));\n\t\t\tconst names = splitPromptChain(declaration);\n\t\t\tif (names.length === 0) {\n\t\t\t\tctx.ui.notify(\"Usage: /chain-prompts prompt-a -> prompt-b -- args\", \"error\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tconst chain = names.map((name) => {\n\t\t\t\t\tconst workflow = findWorkflow(workflows, name);\n\t\t\t\t\tif (!workflow) throw new Error(`Unknown prompt workflow: ${name}`);\n\t\t\t\t\treturn workflowChainStep(workflow, runtime.args, runtime);\n\t\t\t\t});\n\t\t\t\tawait run({ chain, task: runtime.args.join(\" \"), clarify: false, agentScope: \"both\", ...(runtime.bg ? { async: true } : {}) }, ctx);\n\t\t\t} catch (error) {\n\t\t\t\tctx.ui.notify(error instanceof Error ? error.message : String(error), \"error\");\n\t\t\t}\n\t\t},\n\t});\n}\n"]}
1
+ {"version":3,"file":"prompt-workflows.d.ts","sourceRoot":"","sources":["../../../../../src/builtin-extensions/pi-subagents/src/slash/prompt-workflows.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAEtF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAIlF,UAAU,cAAc;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,MAAM,GAAG,WAAW,CAAC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,KAAK,CAAC;IAClC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAED,KAAK,oBAAoB,GAAG,CAAC,MAAM,EAAE,kBAAkB,EAAE,GAAG,EAAE,gBAAgB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAsFjG,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,EAAE,CAOrE;AAuID,wBAAgB,8BAA8B,CAAC,KAAK,EAAE;IACrD,EAAE,EAAE,YAAY,CAAC;IACjB,GAAG,EAAE,oBAAoB,CAAC;CAC1B,GAAG,IAAI,CAgEP","sourcesContent":["// @ts-nocheck\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport type { ExtensionAPI, ExtensionContext } from \"@ashx-j/lunr\";\nimport { parseFrontmatter } from \"../agents/frontmatter.ts\";\nimport type { SubagentParamsLike } from \"../runs/foreground/subagent-executor.ts\";\nimport type { ChainStep } from \"../shared/settings.ts\";\nimport { getAgentDir, getProjectConfigDir } from \"../shared/utils.ts\";\n\ninterface PromptWorkflow {\n\tname: string;\n\tdescription: string;\n\tbody: string;\n\tfilePath: string;\n\tchildDescription: string;\n\tpermissions: \"full\" | \"read-only\";\n\tmodel?: string;\n\tskill?: string | string[] | false;\n\tcwd?: string;\n\tworktree?: boolean;\n\tchain?: string;\n}\n\ntype PromptWorkflowRunner = (params: SubagentParamsLike, ctx: ExtensionContext) => Promise<void>;\n\nconst RESERVED_COMMAND_NAMES = new Set([\n\t\"chain-prompts\",\n\t\"prompt-workflow\",\n\t\"run\",\n\t\"chain\",\n\t\"parallel\",\n\t\"subagents-doctor\",\n]);\n\nfunction packagePromptsDir(): string {\n\treturn path.resolve(path.dirname(fileURLToPath(import.meta.url)), \"..\", \"..\", \"prompts\");\n}\n\nfunction promptDirs(cwd: string): string[] {\n\treturn [\n\t\tpackagePromptsDir(),\n\t\tpath.join(getAgentDir(), \"prompts\"),\n\t\tpath.join(getProjectConfigDir(cwd), \"prompts\"),\n\t];\n}\n\nfunction readPromptFiles(cwd: string): string[] {\n\tconst files: string[] = [];\n\tfor (const dir of promptDirs(cwd)) {\n\t\tlet entries: fs.Dirent[];\n\t\ttry {\n\t\t\tentries = fs.readdirSync(dir, { withFileTypes: true });\n\t\t} catch {\n\t\t\tcontinue;\n\t\t}\n\t\tfor (const entry of entries) {\n\t\t\tif (entry.isFile() && entry.name.endsWith(\".md\")) files.push(path.join(dir, entry.name));\n\t\t}\n\t}\n\treturn files;\n}\n\nfunction firstNonEmptyLine(value: string): string {\n\treturn value.split(/\\r?\\n/).map((line) => line.trim()).find(Boolean) ?? \"Prompt workflow\";\n}\n\nfunction stringField(frontmatter: Record<string, string>, key: string): string | undefined {\n\tconst value = frontmatter[key]?.trim();\n\treturn value ? value : undefined;\n}\n\nfunction booleanField(frontmatter: Record<string, string>, key: string): boolean | undefined {\n\tconst value = frontmatter[key]?.trim().toLowerCase();\n\tif (value === \"true\" || value === \"yes\" || value === \"1\") return true;\n\tif (value === \"false\" || value === \"no\" || value === \"0\") return false;\n\treturn undefined;\n}\n\nfunction parseSkill(value: string | undefined): string | string[] | false | undefined {\n\tif (!value) return undefined;\n\tif (value === \"false\") return false;\n\tconst parts = value.split(\",\").map((part) => part.trim()).filter(Boolean);\n\treturn parts.length > 1 ? parts : parts[0];\n}\n\nfunction loadPromptWorkflow(filePath: string): PromptWorkflow | undefined {\n\tconst content = fs.readFileSync(filePath, \"utf-8\");\n\tconst { frontmatter, body } = parseFrontmatter(content);\n\tconst name = path.basename(filePath, \".md\");\n\tif (!name || RESERVED_COMMAND_NAMES.has(name)) return undefined;\n\tconst model = stringField(frontmatter, \"model\");\n\tconst skill = parseSkill(stringField(frontmatter, \"skill\"));\n\tconst cwd = stringField(frontmatter, \"cwd\");\n\tconst chain = stringField(frontmatter, \"chain\");\n\treturn {\n\t\tname,\n\t\tdescription: stringField(frontmatter, \"description\") ?? firstNonEmptyLine(body),\n\t\tbody,\n\t\tfilePath,\n\t\tchildDescription: stringField(frontmatter, \"child-description\") ?? name,\n\t\tpermissions: stringField(frontmatter, \"permissions\") === \"read-only\" ? \"read-only\" : \"full\",\n\t\t...(model ? { model } : {}),\n\t\t...(skill !== undefined ? { skill } : {}),\n\t\t...(cwd ? { cwd } : {}),\n\t\t...(booleanField(frontmatter, \"worktree\") === true ? { worktree: true } : {}),\n\t\t...(chain ? { chain } : {}),\n\t};\n}\n\nexport function discoverPromptWorkflows(cwd: string): PromptWorkflow[] {\n\tconst workflows = new Map<string, PromptWorkflow>();\n\tfor (const file of readPromptFiles(cwd)) {\n\t\tconst workflow = loadPromptWorkflow(file);\n\t\tif (workflow) workflows.set(workflow.name, workflow);\n\t}\n\treturn [...workflows.values()].sort((a, b) => a.name.localeCompare(b.name));\n}\n\nfunction shellWords(input: string): string[] {\n\tconst words: string[] = [];\n\tlet current = \"\";\n\tlet quote: \"'\" | '\"' | undefined;\n\tlet escaped = false;\n\tfor (const ch of input) {\n\t\tif (escaped) {\n\t\t\tcurrent += ch;\n\t\t\tescaped = false;\n\t\t\tcontinue;\n\t\t}\n\t\tif (ch === \"\\\\\") {\n\t\t\tescaped = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (quote) {\n\t\t\tif (ch === quote) quote = undefined;\n\t\t\telse current += ch;\n\t\t\tcontinue;\n\t\t}\n\t\tif (ch === \"'\" || ch === '\"') {\n\t\t\tquote = ch;\n\t\t\tcontinue;\n\t\t}\n\t\tif (/\\s/.test(ch)) {\n\t\t\tif (current) {\n\t\t\t\twords.push(current);\n\t\t\t\tcurrent = \"\";\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tcurrent += ch;\n\t}\n\tif (current) words.push(current);\n\treturn words;\n}\n\nfunction substituteArgs(template: string, args: string[]): string {\n\tconst all = args.join(\" \");\n\treturn template\n\t\t.replace(/\\$ARGUMENTS/g, all)\n\t\t.replace(/\\$@/g, all)\n\t\t.replace(/\\$\\{(\\d+):-([^}]*)\\}/g, (_match, index: string, fallback: string) => args[Number(index) - 1] || fallback)\n\t\t.replace(/\\$(\\d+)/g, (_match, index: string) => args[Number(index) - 1] ?? \"\");\n}\n\nfunction parseRuntimeOptions(words: string[]): { args: string[]; descriptionOverride?: string; permissions?: \"full\" | \"read-only\"; worktree?: boolean; bg?: boolean } {\n\tconst args: string[] = [];\n\tlet descriptionOverride: string | undefined;\n\tlet permissions: \"full\" | \"read-only\" | undefined;\n\tlet worktree = false;\n\tlet bg = false;\n\tfor (let i = 0; i < words.length; i++) {\n\t\tconst word = words[i]!;\n\t\tif (word === \"--read-only\") {\n\t\t\tpermissions = \"read-only\";\n\t\t\tcontinue;\n\t\t}\n\t\tif (word === \"--full\") {\n\t\t\tpermissions = \"full\";\n\t\t\tcontinue;\n\t\t}\n\t\tif (word === \"--worktree\") {\n\t\t\tworktree = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (word === \"--bg\" || word === \"--async\") {\n\t\t\tbg = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (word === \"--description\") {\n\t\t\tdescriptionOverride = words[++i];\n\t\t\tcontinue;\n\t\t}\n\t\tconst eq = word.match(/^--description(?:=|:)(.+)$/);\n\t\tif (eq) {\n\t\t\tdescriptionOverride = eq[1];\n\t\t\tcontinue;\n\t\t}\n\t\targs.push(word);\n\t}\n\treturn { args, descriptionOverride, permissions, worktree, bg };\n}\n\nfunction splitChainDeclaration(input: string): { declaration: string; argsText: string } {\n\tconst delimiter = input.indexOf(\" -- \");\n\tif (delimiter === -1) return { declaration: input.trim(), argsText: \"\" };\n\treturn { declaration: input.slice(0, delimiter).trim(), argsText: input.slice(delimiter + 4).trim() };\n}\n\nfunction splitPromptChain(input: string): string[] {\n\treturn input.split(\" -> \").map((part) => part.trim()).filter(Boolean);\n}\n\nfunction workflowParams(workflow: PromptWorkflow, args: string[], runtime: ReturnType<typeof parseRuntimeOptions>): SubagentParamsLike {\n\tconst task = substituteArgs(workflow.body, args).trim();\n\treturn {\n\t\ttask,\n\t\tdescription: runtime.descriptionOverride ?? workflow.childDescription,\n\t\tpermissions: runtime.permissions ?? workflow.permissions,\n\t\tclarify: false,\n\t\t...(workflow.model ? { model: workflow.model } : {}),\n\t\t...(workflow.skill !== undefined ? { skill: workflow.skill } : {}),\n\t\t...(workflow.cwd ? { cwd: workflow.cwd } : {}),\n\t\t...(runtime.worktree || workflow.worktree ? { worktree: true } : {}),\n\t\t...(runtime.bg ? { async: true } : {}),\n\t};\n}\n\nfunction workflowChainStep(workflow: PromptWorkflow, args: string[], runtime: ReturnType<typeof parseRuntimeOptions>): ChainStep {\n\tconst params = workflowParams(workflow, args, runtime);\n\treturn {\n\t\tdescription: params.description ?? workflow.childDescription,\n\t\tpermissions: params.permissions ?? workflow.permissions,\n\t\ttask: params.task,\n\t\t...(params.model ? { model: params.model } : {}),\n\t\t...(params.skill !== undefined ? { skill: params.skill } : {}),\n\t\t...(params.cwd ? { cwd: params.cwd } : {}),\n\t};\n}\n\nfunction findWorkflow(workflows: PromptWorkflow[], name: string): PromptWorkflow | undefined {\n\treturn workflows.find((workflow) => workflow.name === name);\n}\n\nfunction formatWorkflowList(workflows: PromptWorkflow[]): string {\n\tif (workflows.length === 0) return \"No prompt workflows found in package, user, or project prompts.\";\n\treturn [\n\t\t\"Prompt workflows:\",\n\t\t...workflows.map((workflow) => `- ${workflow.name}: ${workflow.description} (${workflow.filePath})`),\n\t].join(\"\\n\");\n}\n\nexport function registerPromptWorkflowCommands(input: {\n\tpi: ExtensionAPI;\n\trun: PromptWorkflowRunner;\n}): void {\n\tconst { pi, run } = input;\n\n\tpi.registerCommand(\"prompt-workflow\", {\n\t\tdescription: \"Run a prompt template through lunR subagents: /prompt-workflow <name> [args]\",\n\t\thandler: async (rawArgs, ctx) => {\n\t\t\tconst words = shellWords(rawArgs);\n\t\t\tconst name = words.shift();\n\t\t\tconst workflows = discoverPromptWorkflows(ctx.cwd);\n\t\t\tif (!name || name === \"list\") {\n\t\t\t\tpi.sendMessage({ content: formatWorkflowList(workflows), display: true });\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst workflow = findWorkflow(workflows, name);\n\t\t\tif (!workflow) {\n\t\t\t\tctx.ui.notify(`Unknown prompt workflow: ${name}`, \"error\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst runtime = parseRuntimeOptions(words);\n\t\t\ttry {\n\t\t\t\tif (workflow.chain) {\n\t\t\t\t\tconst chainNames = splitPromptChain(workflow.chain);\n\t\t\t\t\tconst chain = chainNames.map((stepName) => {\n\t\t\t\t\t\tconst step = findWorkflow(workflows, stepName);\n\t\t\t\t\t\tif (!step) throw new Error(`Unknown prompt workflow in chain '${workflow.name}': ${stepName}`);\n\t\t\t\t\t\treturn workflowChainStep(step, runtime.args, runtime);\n\t\t\t\t\t});\n\t\t\t\t\tawait run({ chain, task: runtime.args.join(\" \"), clarify: false, ...(runtime.bg ? { async: true } : {}) }, ctx);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tawait run(workflowParams(workflow, runtime.args, runtime), ctx);\n\t\t\t} catch (error) {\n\t\t\t\tctx.ui.notify(error instanceof Error ? error.message : String(error), \"error\");\n\t\t\t}\n\t\t},\n\t});\n\n\tpi.registerCommand(\"chain-prompts\", {\n\t\tdescription: \"Run prompt templates as a native subagent chain: /chain-prompts analyze -> fix -- args\",\n\t\thandler: async (rawArgs, ctx) => {\n\t\t\tconst { declaration, argsText } = splitChainDeclaration(rawArgs);\n\t\t\tconst workflows = discoverPromptWorkflows(ctx.cwd);\n\t\t\tif (!declaration || declaration === \"list\") {\n\t\t\t\tpi.sendMessage({ content: formatWorkflowList(workflows), display: true });\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst runtime = parseRuntimeOptions(shellWords(argsText));\n\t\t\tconst names = splitPromptChain(declaration);\n\t\t\tif (names.length === 0) {\n\t\t\t\tctx.ui.notify(\"Usage: /chain-prompts prompt-a -> prompt-b -- args\", \"error\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tconst chain = names.map((name) => {\n\t\t\t\t\tconst workflow = findWorkflow(workflows, name);\n\t\t\t\t\tif (!workflow) throw new Error(`Unknown prompt workflow: ${name}`);\n\t\t\t\t\treturn workflowChainStep(workflow, runtime.args, runtime);\n\t\t\t\t});\n\t\t\t\tawait run({ chain, task: runtime.args.join(\" \"), clarify: false, ...(runtime.bg ? { async: true } : {}) }, ctx);\n\t\t\t} catch (error) {\n\t\t\t\tctx.ui.notify(error instanceof Error ? error.message : String(error), \"error\");\n\t\t\t}\n\t\t},\n\t});\n}\n"]}
@@ -10,9 +10,7 @@ const RESERVED_COMMAND_NAMES = new Set([
10
10
  "run",
11
11
  "chain",
12
12
  "parallel",
13
- "run-chain",
14
13
  "subagents-doctor",
15
- "subagents-models",
16
14
  ]);
17
15
  function packagePromptsDir() {
18
16
  return path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "..", "prompts");
@@ -64,12 +62,6 @@ function parseSkill(value) {
64
62
  const parts = value.split(",").map((part) => part.trim()).filter(Boolean);
65
63
  return parts.length > 1 ? parts : parts[0];
66
64
  }
67
- function parseAgent(frontmatter) {
68
- const subagent = stringField(frontmatter, "subagent");
69
- if (!subagent || subagent === "true")
70
- return "delegate";
71
- return subagent;
72
- }
73
65
  function loadPromptWorkflow(filePath) {
74
66
  const content = fs.readFileSync(filePath, "utf-8");
75
67
  const { frontmatter, body } = parseFrontmatter(content);
@@ -85,9 +77,8 @@ function loadPromptWorkflow(filePath) {
85
77
  description: stringField(frontmatter, "description") ?? firstNonEmptyLine(body),
86
78
  body,
87
79
  filePath,
88
- agent: parseAgent(frontmatter),
89
- ...(booleanField(frontmatter, "inheritContext") === true || booleanField(frontmatter, "fork") === true ? { context: "fork" } : {}),
90
- ...(booleanField(frontmatter, "fresh") === true ? { context: "fresh" } : {}),
80
+ childDescription: stringField(frontmatter, "child-description") ?? name,
81
+ permissions: stringField(frontmatter, "permissions") === "read-only" ? "read-only" : "full",
91
82
  ...(model ? { model } : {}),
92
83
  ...(skill !== undefined ? { skill } : {}),
93
84
  ...(cwd ? { cwd } : {}),
@@ -153,19 +144,18 @@ function substituteArgs(template, args) {
153
144
  }
154
145
  function parseRuntimeOptions(words) {
155
146
  const args = [];
156
- let agentOverride;
157
- let fork = false;
158
- let fresh = false;
147
+ let descriptionOverride;
148
+ let permissions;
159
149
  let worktree = false;
160
150
  let bg = false;
161
151
  for (let i = 0; i < words.length; i++) {
162
152
  const word = words[i];
163
- if (word === "--fork") {
164
- fork = true;
153
+ if (word === "--read-only") {
154
+ permissions = "read-only";
165
155
  continue;
166
156
  }
167
- if (word === "--fresh") {
168
- fresh = true;
157
+ if (word === "--full") {
158
+ permissions = "full";
169
159
  continue;
170
160
  }
171
161
  if (word === "--worktree") {
@@ -176,18 +166,18 @@ function parseRuntimeOptions(words) {
176
166
  bg = true;
177
167
  continue;
178
168
  }
179
- if (word === "--subagent") {
180
- agentOverride = words[++i];
169
+ if (word === "--description") {
170
+ descriptionOverride = words[++i];
181
171
  continue;
182
172
  }
183
- const eq = word.match(/^--subagent(?:=|:)(.+)$/);
173
+ const eq = word.match(/^--description(?:=|:)(.+)$/);
184
174
  if (eq) {
185
- agentOverride = eq[1];
175
+ descriptionOverride = eq[1];
186
176
  continue;
187
177
  }
188
178
  args.push(word);
189
179
  }
190
- return { args, agentOverride, fork, fresh, worktree, bg };
180
+ return { args, descriptionOverride, permissions, worktree, bg };
191
181
  }
192
182
  function splitChainDeclaration(input) {
193
183
  const delimiter = input.indexOf(" -- ");
@@ -200,14 +190,11 @@ function splitPromptChain(input) {
200
190
  }
201
191
  function workflowParams(workflow, args, runtime) {
202
192
  const task = substituteArgs(workflow.body, args).trim();
203
- // lunr: --fork is parsed so it is not a task word; children always start fresh.
204
- const context = "fresh";
205
193
  return {
206
- agent: runtime.agentOverride ?? workflow.agent,
207
194
  task,
195
+ description: runtime.descriptionOverride ?? workflow.childDescription,
196
+ permissions: runtime.permissions ?? workflow.permissions,
208
197
  clarify: false,
209
- agentScope: "both",
210
- ...(context ? { context } : {}),
211
198
  ...(workflow.model ? { model: workflow.model } : {}),
212
199
  ...(workflow.skill !== undefined ? { skill: workflow.skill } : {}),
213
200
  ...(workflow.cwd ? { cwd: workflow.cwd } : {}),
@@ -218,7 +205,8 @@ function workflowParams(workflow, args, runtime) {
218
205
  function workflowChainStep(workflow, args, runtime) {
219
206
  const params = workflowParams(workflow, args, runtime);
220
207
  return {
221
- agent: params.agent ?? "delegate",
208
+ description: params.description ?? workflow.childDescription,
209
+ permissions: params.permissions ?? workflow.permissions,
222
210
  task: params.task,
223
211
  ...(params.model ? { model: params.model } : {}),
224
212
  ...(params.skill !== undefined ? { skill: params.skill } : {}),
@@ -239,7 +227,7 @@ function formatWorkflowList(workflows) {
239
227
  export function registerPromptWorkflowCommands(input) {
240
228
  const { pi, run } = input;
241
229
  pi.registerCommand("prompt-workflow", {
242
- description: "Run a prompt template through native pi-subagents: /prompt-workflow <name> [args]",
230
+ description: "Run a prompt template through lunR subagents: /prompt-workflow <name> [args]",
243
231
  handler: async (rawArgs, ctx) => {
244
232
  const words = shellWords(rawArgs);
245
233
  const name = words.shift();
@@ -263,7 +251,7 @@ export function registerPromptWorkflowCommands(input) {
263
251
  throw new Error(`Unknown prompt workflow in chain '${workflow.name}': ${stepName}`);
264
252
  return workflowChainStep(step, runtime.args, runtime);
265
253
  });
266
- await run({ chain, task: runtime.args.join(" "), clarify: false, agentScope: "both", ...(runtime.bg ? { async: true } : {}) }, ctx);
254
+ await run({ chain, task: runtime.args.join(" "), clarify: false, ...(runtime.bg ? { async: true } : {}) }, ctx);
267
255
  return;
268
256
  }
269
257
  await run(workflowParams(workflow, runtime.args, runtime), ctx);
@@ -295,7 +283,7 @@ export function registerPromptWorkflowCommands(input) {
295
283
  throw new Error(`Unknown prompt workflow: ${name}`);
296
284
  return workflowChainStep(workflow, runtime.args, runtime);
297
285
  });
298
- await run({ chain, task: runtime.args.join(" "), clarify: false, agentScope: "both", ...(runtime.bg ? { async: true } : {}) }, ctx);
286
+ await run({ chain, task: runtime.args.join(" "), clarify: false, ...(runtime.bg ? { async: true } : {}) }, ctx);
299
287
  }
300
288
  catch (error) {
301
289
  ctx.ui.notify(error instanceof Error ? error.message : String(error), "error");