@bastani/atomic 0.9.14 → 0.9.15-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (525) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +1 -1
  3. package/dist/builtin/intercom/package.json +2 -2
  4. package/dist/builtin/mcp/CHANGELOG.md +6 -0
  5. package/dist/builtin/mcp/package.json +4 -4
  6. package/dist/builtin/mcp/sampling-handler.ts +2 -2
  7. package/dist/builtin/mcp/types.ts +1 -1
  8. package/dist/builtin/subagents/CHANGELOG.md +21 -0
  9. package/dist/builtin/subagents/README.md +5 -22
  10. package/dist/builtin/subagents/agents/code-simplifier.md +2 -2
  11. package/dist/builtin/subagents/agents/codebase-analyzer.md +2 -2
  12. package/dist/builtin/subagents/agents/codebase-locator.md +2 -2
  13. package/dist/builtin/subagents/agents/codebase-online-researcher.md +2 -2
  14. package/dist/builtin/subagents/agents/codebase-pattern-finder.md +2 -2
  15. package/dist/builtin/subagents/agents/codebase-research-analyzer.md +2 -2
  16. package/dist/builtin/subagents/agents/codebase-research-locator.md +2 -2
  17. package/dist/builtin/subagents/agents/worker.md +2 -2
  18. package/dist/builtin/subagents/package.json +4 -4
  19. package/dist/builtin/subagents/skills/subagent/SKILL.md +6 -6
  20. package/dist/builtin/subagents/src/agents/agent-loaders.ts +0 -4
  21. package/dist/builtin/subagents/src/agents/agent-management-helpers.ts +1 -12
  22. package/dist/builtin/subagents/src/agents/agent-management.ts +0 -1
  23. package/dist/builtin/subagents/src/agents/agent-serializer.ts +7 -6
  24. package/dist/builtin/subagents/src/agents/agent-types.ts +0 -1
  25. package/dist/builtin/subagents/src/extension/schemas.ts +2 -2
  26. package/dist/builtin/subagents/src/extension/startup-maintenance.ts +2 -2
  27. package/dist/builtin/subagents/src/intercom/result-intercom.ts +0 -127
  28. package/dist/builtin/subagents/src/runs/foreground/inprocess-run-sync.ts +1 -3
  29. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-context.ts +15 -106
  30. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel-task.ts +0 -3
  31. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel.ts +2 -13
  32. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-single.ts +2 -12
  33. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-status.ts +1 -20
  34. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-types.ts +0 -6
  35. package/dist/builtin/subagents/src/runs/foreground/subagent-executor.ts +10 -21
  36. package/dist/builtin/subagents/src/runs/inprocess/attempt-handles.ts +104 -0
  37. package/dist/builtin/subagents/src/runs/inprocess/index.ts +10 -21
  38. package/dist/builtin/subagents/src/runs/inprocess/prompt-behavior.ts +2 -3
  39. package/dist/builtin/subagents/src/runs/inprocess/runner.ts +11 -32
  40. package/dist/builtin/subagents/src/runs/inprocess/runtime-support/temp-cleanup.ts +69 -0
  41. package/dist/builtin/subagents/src/shared/model-resolution.ts +1 -1
  42. package/dist/builtin/subagents/src/shared/types-config.ts +0 -4
  43. package/dist/builtin/subagents/src/shared/types-depth.ts +15 -103
  44. package/dist/builtin/subagents/src/shared/types-foreground-state.ts +56 -0
  45. package/dist/builtin/subagents/src/shared/types-results.ts +1 -59
  46. package/dist/builtin/subagents/src/shared/types-runtime.ts +0 -2
  47. package/dist/builtin/subagents/src/shared/types.ts +1 -1
  48. package/dist/builtin/subagents/src/shared/utils.ts +1 -1
  49. package/dist/builtin/subagents/src/slash/slash-live-state.ts +1 -1
  50. package/dist/builtin/web-access/package.json +2 -2
  51. package/dist/builtin/web-access/summary-review.ts +2 -2
  52. package/dist/builtin/web-access/web-search-summary.ts +2 -2
  53. package/dist/builtin/workflows/CHANGELOG.md +14 -0
  54. package/dist/builtin/workflows/README.md +2 -2
  55. package/dist/builtin/workflows/package.json +2 -2
  56. package/dist/builtin/workflows/src/extension/index.bundle.mjs +60473 -401
  57. package/dist/builtin/workflows/src/extension/public-types.ts +1 -1
  58. package/dist/builtin/workflows/src/extension/wiring.ts +1 -1
  59. package/dist/builtin/workflows/src/extension/workflow-heartbeat-delivery.ts +48 -4
  60. package/dist/builtin/workflows/src/extension/workflow-tool.ts +1 -1
  61. package/dist/builtin/workflows/src/runs/foreground/executor-stage-factory.ts +5 -0
  62. package/dist/builtin/workflows/src/runs/foreground/stage-runner-controller.ts +35 -2
  63. package/dist/builtin/workflows/src/runs/foreground/stage-runner-options.ts +1 -1
  64. package/dist/builtin/workflows/src/runs/foreground/stage-runner-pause.ts +6 -0
  65. package/dist/builtin/workflows/src/tui/chat-surface-message.ts +15 -13
  66. package/dist/builtin/workflows/src/tui/store-widget-installer.ts +25 -2
  67. package/dist/bun/cli.js +1 -1
  68. package/dist/bun/cli.js.map +1 -1
  69. package/dist/bun/register-bedrock.js +2 -2
  70. package/dist/bun/register-bedrock.js.map +1 -1
  71. package/dist/cli/auth-check.d.ts +1 -1
  72. package/dist/cli/auth-check.d.ts.map +1 -1
  73. package/dist/cli/auth-check.js +1 -1
  74. package/dist/cli/auth-check.js.map +1 -1
  75. package/dist/cli/credential-print.d.ts +1 -1
  76. package/dist/cli/credential-print.d.ts.map +1 -1
  77. package/dist/cli/credential-print.js +2 -2
  78. package/dist/cli/credential-print.js.map +1 -1
  79. package/dist/cli/file-processor.d.ts +1 -1
  80. package/dist/cli/file-processor.d.ts.map +1 -1
  81. package/dist/cli/file-processor.js.map +1 -1
  82. package/dist/cli/initial-message.d.ts +1 -1
  83. package/dist/cli/initial-message.d.ts.map +1 -1
  84. package/dist/cli/initial-message.js.map +1 -1
  85. package/dist/cli/list-models.js.map +1 -1
  86. package/dist/core/agent-session-auto-compaction.d.ts +1 -1
  87. package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
  88. package/dist/core/agent-session-auto-compaction.js +1 -1
  89. package/dist/core/agent-session-auto-compaction.js.map +1 -1
  90. package/dist/core/agent-session-events.d.ts +1 -1
  91. package/dist/core/agent-session-events.d.ts.map +1 -1
  92. package/dist/core/agent-session-events.js +1 -1
  93. package/dist/core/agent-session-events.js.map +1 -1
  94. package/dist/core/agent-session-export.js.map +1 -1
  95. package/dist/core/agent-session-extension-bindings.js +1 -1
  96. package/dist/core/agent-session-extension-bindings.js.map +1 -1
  97. package/dist/core/agent-session-message-queue.d.ts +1 -1
  98. package/dist/core/agent-session-message-queue.d.ts.map +1 -1
  99. package/dist/core/agent-session-message-queue.js.map +1 -1
  100. package/dist/core/agent-session-methods.d.ts +2 -2
  101. package/dist/core/agent-session-methods.d.ts.map +1 -1
  102. package/dist/core/agent-session-methods.js.map +1 -1
  103. package/dist/core/agent-session-models.d.ts +2 -2
  104. package/dist/core/agent-session-models.d.ts.map +1 -1
  105. package/dist/core/agent-session-models.js +2 -2
  106. package/dist/core/agent-session-models.js.map +1 -1
  107. package/dist/core/agent-session-prompt.d.ts +1 -1
  108. package/dist/core/agent-session-prompt.d.ts.map +1 -1
  109. package/dist/core/agent-session-prompt.js.map +1 -1
  110. package/dist/core/agent-session-retry.d.ts +1 -1
  111. package/dist/core/agent-session-retry.d.ts.map +1 -1
  112. package/dist/core/agent-session-retry.js +1 -1
  113. package/dist/core/agent-session-retry.js.map +1 -1
  114. package/dist/core/agent-session-runtime-auth.js +1 -1
  115. package/dist/core/agent-session-runtime-auth.js.map +1 -1
  116. package/dist/core/agent-session-runtime.d.ts +1 -1
  117. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  118. package/dist/core/agent-session-runtime.js +1 -1
  119. package/dist/core/agent-session-runtime.js.map +1 -1
  120. package/dist/core/agent-session-services.d.ts +1 -1
  121. package/dist/core/agent-session-services.d.ts.map +1 -1
  122. package/dist/core/agent-session-services.js.map +1 -1
  123. package/dist/core/agent-session-state.d.ts +1 -1
  124. package/dist/core/agent-session-state.d.ts.map +1 -1
  125. package/dist/core/agent-session-state.js.map +1 -1
  126. package/dist/core/agent-session-tree.js.map +1 -1
  127. package/dist/core/agent-session-types.d.ts +1 -1
  128. package/dist/core/agent-session-types.d.ts.map +1 -1
  129. package/dist/core/agent-session-types.js.map +1 -1
  130. package/dist/core/agent-session.d.ts +1 -1
  131. package/dist/core/agent-session.d.ts.map +1 -1
  132. package/dist/core/agent-session.js.map +1 -1
  133. package/dist/core/anthropic-thinking-guard.d.ts +1 -1
  134. package/dist/core/anthropic-thinking-guard.d.ts.map +1 -1
  135. package/dist/core/anthropic-thinking-guard.js +1 -1
  136. package/dist/core/anthropic-thinking-guard.js.map +1 -1
  137. package/dist/core/auth-storage.d.ts +1 -1
  138. package/dist/core/auth-storage.d.ts.map +1 -1
  139. package/dist/core/auth-storage.js.map +1 -1
  140. package/dist/core/cache-stats.d.ts +1 -1
  141. package/dist/core/cache-stats.d.ts.map +1 -1
  142. package/dist/core/cache-stats.js.map +1 -1
  143. package/dist/core/cloudflare-gateway-binding.d.ts +1 -1
  144. package/dist/core/cloudflare-gateway-binding.d.ts.map +1 -1
  145. package/dist/core/cloudflare-gateway-binding.js +1 -1
  146. package/dist/core/cloudflare-gateway-binding.js.map +1 -1
  147. package/dist/core/codex-fast-mode.d.ts +2 -2
  148. package/dist/core/codex-fast-mode.d.ts.map +1 -1
  149. package/dist/core/codex-fast-mode.js +3 -2
  150. package/dist/core/codex-fast-mode.js.map +1 -1
  151. package/dist/core/compaction/branch-summarization.d.ts +2 -2
  152. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  153. package/dist/core/compaction/branch-summarization.js +2 -2
  154. package/dist/core/compaction/branch-summarization.js.map +1 -1
  155. package/dist/core/compaction/compaction-runner.d.ts +2 -2
  156. package/dist/core/compaction/compaction-runner.d.ts.map +1 -1
  157. package/dist/core/compaction/compaction-runner.js.map +1 -1
  158. package/dist/core/compaction/compaction-types.d.ts +2 -2
  159. package/dist/core/compaction/compaction-types.d.ts.map +1 -1
  160. package/dist/core/compaction/compaction-types.js.map +1 -1
  161. package/dist/core/compaction/compaction.d.ts +1 -1
  162. package/dist/core/compaction/compaction.d.ts.map +1 -1
  163. package/dist/core/compaction/compaction.js.map +1 -1
  164. package/dist/core/compaction/fallback-planner.d.ts +1 -1
  165. package/dist/core/compaction/fallback-planner.d.ts.map +1 -1
  166. package/dist/core/compaction/fallback-planner.js.map +1 -1
  167. package/dist/core/compaction/planner-outcome.d.ts +1 -1
  168. package/dist/core/compaction/planner-outcome.d.ts.map +1 -1
  169. package/dist/core/compaction/planner-outcome.js +1 -1
  170. package/dist/core/compaction/planner-outcome.js.map +1 -1
  171. package/dist/core/compaction/range-planner-diagnostics.d.ts +1 -1
  172. package/dist/core/compaction/range-planner-diagnostics.d.ts.map +1 -1
  173. package/dist/core/compaction/range-planner-diagnostics.js +1 -1
  174. package/dist/core/compaction/range-planner-diagnostics.js.map +1 -1
  175. package/dist/core/compaction/range-planner.d.ts +2 -2
  176. package/dist/core/compaction/range-planner.d.ts.map +1 -1
  177. package/dist/core/compaction/range-planner.js +2 -2
  178. package/dist/core/compaction/range-planner.js.map +1 -1
  179. package/dist/core/compaction/session-summarization.d.ts +2 -2
  180. package/dist/core/compaction/session-summarization.d.ts.map +1 -1
  181. package/dist/core/compaction/session-summarization.js +2 -2
  182. package/dist/core/compaction/session-summarization.js.map +1 -1
  183. package/dist/core/compaction/transcript-serialization.d.ts +1 -1
  184. package/dist/core/compaction/transcript-serialization.d.ts.map +1 -1
  185. package/dist/core/compaction/transcript-serialization.js.map +1 -1
  186. package/dist/core/compaction/utils.d.ts +1 -1
  187. package/dist/core/compaction/utils.d.ts.map +1 -1
  188. package/dist/core/compaction/utils.js.map +1 -1
  189. package/dist/core/experimental.d.ts +1 -1
  190. package/dist/core/experimental.d.ts.map +1 -1
  191. package/dist/core/experimental.js.map +1 -1
  192. package/dist/core/export-html/tool-renderer.js.map +1 -1
  193. package/dist/core/extensions/agent-events.d.ts +2 -2
  194. package/dist/core/extensions/agent-events.d.ts.map +1 -1
  195. package/dist/core/extensions/agent-events.js.map +1 -1
  196. package/dist/core/extensions/api-types.d.ts +2 -2
  197. package/dist/core/extensions/api-types.d.ts.map +1 -1
  198. package/dist/core/extensions/api-types.js.map +1 -1
  199. package/dist/core/extensions/context-types.d.ts +1 -7
  200. package/dist/core/extensions/context-types.d.ts.map +1 -1
  201. package/dist/core/extensions/context-types.js.map +1 -1
  202. package/dist/core/extensions/event-results.d.ts +1 -1
  203. package/dist/core/extensions/event-results.d.ts.map +1 -1
  204. package/dist/core/extensions/event-results.js.map +1 -1
  205. package/dist/core/extensions/index.d.ts +1 -1
  206. package/dist/core/extensions/index.d.ts.map +1 -1
  207. package/dist/core/extensions/index.js.map +1 -1
  208. package/dist/core/extensions/loader-api.js.map +1 -1
  209. package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
  210. package/dist/core/extensions/loader-virtual-modules.js +21 -9
  211. package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
  212. package/dist/core/extensions/provider-types.d.ts +2 -2
  213. package/dist/core/extensions/provider-types.d.ts.map +1 -1
  214. package/dist/core/extensions/provider-types.js.map +1 -1
  215. package/dist/core/extensions/reactive-widget.d.ts +6 -0
  216. package/dist/core/extensions/reactive-widget.d.ts.map +1 -1
  217. package/dist/core/extensions/reactive-widget.js +62 -6
  218. package/dist/core/extensions/reactive-widget.js.map +1 -1
  219. package/dist/core/extensions/runner-context.d.ts +1 -1
  220. package/dist/core/extensions/runner-context.d.ts.map +1 -1
  221. package/dist/core/extensions/runner-context.js.map +1 -1
  222. package/dist/core/extensions/runner-events.d.ts +1 -1
  223. package/dist/core/extensions/runner-events.d.ts.map +1 -1
  224. package/dist/core/extensions/runner-events.js.map +1 -1
  225. package/dist/core/extensions/runner.d.ts +2 -2
  226. package/dist/core/extensions/runner.d.ts.map +1 -1
  227. package/dist/core/extensions/runner.js.map +1 -1
  228. package/dist/core/extensions/runtime-types.d.ts +2 -2
  229. package/dist/core/extensions/runtime-types.d.ts.map +1 -1
  230. package/dist/core/extensions/runtime-types.js.map +1 -1
  231. package/dist/core/extensions/tool-events.d.ts +1 -1
  232. package/dist/core/extensions/tool-events.d.ts.map +1 -1
  233. package/dist/core/extensions/tool-events.js.map +1 -1
  234. package/dist/core/extensions/tool-types.d.ts +2 -2
  235. package/dist/core/extensions/tool-types.d.ts.map +1 -1
  236. package/dist/core/extensions/tool-types.js.map +1 -1
  237. package/dist/core/extensions/ui-types.d.ts +2 -0
  238. package/dist/core/extensions/ui-types.d.ts.map +1 -1
  239. package/dist/core/extensions/ui-types.js.map +1 -1
  240. package/dist/core/fallback-models.d.ts +1 -1
  241. package/dist/core/fallback-models.d.ts.map +1 -1
  242. package/dist/core/fallback-models.js.map +1 -1
  243. package/dist/core/http-dispatcher.d.ts.map +1 -1
  244. package/dist/core/http-dispatcher.js +14 -0
  245. package/dist/core/http-dispatcher.js.map +1 -1
  246. package/dist/core/messages.d.ts +1 -1
  247. package/dist/core/messages.d.ts.map +1 -1
  248. package/dist/core/messages.js.map +1 -1
  249. package/dist/core/model-capabilities.d.ts +1 -1
  250. package/dist/core/model-capabilities.d.ts.map +1 -1
  251. package/dist/core/model-capabilities.js.map +1 -1
  252. package/dist/core/model-fallback-failures.d.ts.map +1 -1
  253. package/dist/core/model-fallback-failures.js +18 -1
  254. package/dist/core/model-fallback-failures.js.map +1 -1
  255. package/dist/core/model-registry.d.ts +1 -1
  256. package/dist/core/model-registry.d.ts.map +1 -1
  257. package/dist/core/model-registry.js.map +1 -1
  258. package/dist/core/model-resolver-cli.js.map +1 -1
  259. package/dist/core/model-resolver-defaults.d.ts +1 -1
  260. package/dist/core/model-resolver-defaults.d.ts.map +1 -1
  261. package/dist/core/model-resolver-defaults.js +1 -1
  262. package/dist/core/model-resolver-defaults.js.map +1 -1
  263. package/dist/core/model-resolver-initial.d.ts +1 -1
  264. package/dist/core/model-resolver-initial.d.ts.map +1 -1
  265. package/dist/core/model-resolver-initial.js.map +1 -1
  266. package/dist/core/model-resolver-patterns.d.ts +1 -1
  267. package/dist/core/model-resolver-patterns.d.ts.map +1 -1
  268. package/dist/core/model-resolver-patterns.js.map +1 -1
  269. package/dist/core/model-resolver-scope.d.ts +1 -1
  270. package/dist/core/model-resolver-scope.d.ts.map +1 -1
  271. package/dist/core/model-resolver-scope.js +1 -1
  272. package/dist/core/model-resolver-scope.js.map +1 -1
  273. package/dist/core/model-resolver-types.d.ts +1 -1
  274. package/dist/core/model-resolver-types.d.ts.map +1 -1
  275. package/dist/core/model-resolver-types.js.map +1 -1
  276. package/dist/core/model-runtime-auth.d.ts +1 -1
  277. package/dist/core/model-runtime-auth.d.ts.map +1 -1
  278. package/dist/core/model-runtime-auth.js.map +1 -1
  279. package/dist/core/model-runtime-providers.d.ts +2 -2
  280. package/dist/core/model-runtime-providers.d.ts.map +1 -1
  281. package/dist/core/model-runtime-providers.js +2 -2
  282. package/dist/core/model-runtime-providers.js.map +1 -1
  283. package/dist/core/model-runtime-restoration.d.ts +1 -1
  284. package/dist/core/model-runtime-restoration.d.ts.map +1 -1
  285. package/dist/core/model-runtime-restoration.js.map +1 -1
  286. package/dist/core/model-runtime-snapshot.d.ts +1 -1
  287. package/dist/core/model-runtime-snapshot.d.ts.map +1 -1
  288. package/dist/core/model-runtime-snapshot.js.map +1 -1
  289. package/dist/core/model-runtime-streaming.d.ts +1 -1
  290. package/dist/core/model-runtime-streaming.d.ts.map +1 -1
  291. package/dist/core/model-runtime-streaming.js +1 -1
  292. package/dist/core/model-runtime-streaming.js.map +1 -1
  293. package/dist/core/model-runtime-types.d.ts +1 -1
  294. package/dist/core/model-runtime-types.d.ts.map +1 -1
  295. package/dist/core/model-runtime-types.js.map +1 -1
  296. package/dist/core/model-runtime.d.ts +8 -1
  297. package/dist/core/model-runtime.d.ts.map +1 -1
  298. package/dist/core/model-runtime.js +15 -3
  299. package/dist/core/model-runtime.js.map +1 -1
  300. package/dist/core/models-store.d.ts +1 -1
  301. package/dist/core/models-store.d.ts.map +1 -1
  302. package/dist/core/models-store.js.map +1 -1
  303. package/dist/core/oauth-login.d.ts +1 -1
  304. package/dist/core/oauth-login.d.ts.map +1 -1
  305. package/dist/core/oauth-login.js.map +1 -1
  306. package/dist/core/oauth-provider-metadata.d.ts +1 -1
  307. package/dist/core/oauth-provider-metadata.d.ts.map +1 -1
  308. package/dist/core/oauth-provider-metadata.js.map +1 -1
  309. package/dist/core/openai-responses-payload-sanitizer.d.ts +1 -1
  310. package/dist/core/openai-responses-payload-sanitizer.d.ts.map +1 -1
  311. package/dist/core/openai-responses-payload-sanitizer.js.map +1 -1
  312. package/dist/core/provider-attribution.d.ts +1 -1
  313. package/dist/core/provider-attribution.d.ts.map +1 -1
  314. package/dist/core/provider-attribution.js.map +1 -1
  315. package/dist/core/provider-composer-internal.d.ts +1 -1
  316. package/dist/core/provider-composer-internal.d.ts.map +1 -1
  317. package/dist/core/provider-composer-internal.js.map +1 -1
  318. package/dist/core/provider-composer.d.ts +1 -1
  319. package/dist/core/provider-composer.d.ts.map +1 -1
  320. package/dist/core/provider-composer.js +2 -2
  321. package/dist/core/provider-composer.js.map +1 -1
  322. package/dist/core/provider-context-usage.d.ts.map +1 -1
  323. package/dist/core/provider-context-usage.js.map +1 -1
  324. package/dist/core/remote-catalog-provider.d.ts +1 -1
  325. package/dist/core/remote-catalog-provider.d.ts.map +1 -1
  326. package/dist/core/remote-catalog-provider.js.map +1 -1
  327. package/dist/core/runtime-credentials.d.ts +1 -1
  328. package/dist/core/runtime-credentials.d.ts.map +1 -1
  329. package/dist/core/runtime-credentials.js.map +1 -1
  330. package/dist/core/sdk-types.d.ts +1 -1
  331. package/dist/core/sdk-types.d.ts.map +1 -1
  332. package/dist/core/sdk-types.js.map +1 -1
  333. package/dist/core/sdk.d.ts +1 -1
  334. package/dist/core/sdk.d.ts.map +1 -1
  335. package/dist/core/sdk.js +30 -6
  336. package/dist/core/sdk.js.map +1 -1
  337. package/dist/core/session-manager-core.d.ts +2 -2
  338. package/dist/core/session-manager-core.d.ts.map +1 -1
  339. package/dist/core/session-manager-core.js.map +1 -1
  340. package/dist/core/session-manager-entries.d.ts +1 -1
  341. package/dist/core/session-manager-entries.d.ts.map +1 -1
  342. package/dist/core/session-manager-entries.js.map +1 -1
  343. package/dist/core/session-manager-list.js.map +1 -1
  344. package/dist/core/session-manager-types.d.ts +1 -1
  345. package/dist/core/session-manager-types.d.ts.map +1 -1
  346. package/dist/core/session-manager-types.js.map +1 -1
  347. package/dist/core/session-manager-validation.js +1 -1
  348. package/dist/core/session-manager-validation.js.map +1 -1
  349. package/dist/core/settings-manager-basic-accessors.d.ts +1 -0
  350. package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
  351. package/dist/core/settings-manager-basic-accessors.js +11 -0
  352. package/dist/core/settings-manager-basic-accessors.js.map +1 -1
  353. package/dist/core/settings-types.d.ts +2 -1
  354. package/dist/core/settings-types.d.ts.map +1 -1
  355. package/dist/core/settings-types.js.map +1 -1
  356. package/dist/core/summarization-retry.d.ts +1 -1
  357. package/dist/core/summarization-retry.d.ts.map +1 -1
  358. package/dist/core/summarization-retry.js.map +1 -1
  359. package/dist/core/tools/bash-session-environment.d.ts +1 -1
  360. package/dist/core/tools/bash-session-environment.d.ts.map +1 -1
  361. package/dist/core/tools/bash-session-environment.js.map +1 -1
  362. package/dist/core/tools/oversized-tool-result.d.ts +1 -1
  363. package/dist/core/tools/oversized-tool-result.d.ts.map +1 -1
  364. package/dist/core/tools/oversized-tool-result.js.map +1 -1
  365. package/dist/core/tools/read-url.d.ts +1 -1
  366. package/dist/core/tools/read-url.d.ts.map +1 -1
  367. package/dist/core/tools/read-url.js.map +1 -1
  368. package/dist/core/tools/read.d.ts.map +1 -1
  369. package/dist/core/tools/read.js.map +1 -1
  370. package/dist/core/tools/render-utils.d.ts +1 -1
  371. package/dist/core/tools/render-utils.d.ts.map +1 -1
  372. package/dist/core/tools/render-utils.js.map +1 -1
  373. package/dist/core/tools/resource-selectors.d.ts +1 -1
  374. package/dist/core/tools/resource-selectors.d.ts.map +1 -1
  375. package/dist/core/tools/resource-selectors.js +2 -7
  376. package/dist/core/tools/resource-selectors.js.map +1 -1
  377. package/dist/core/typebox-compat.js +1 -1
  378. package/dist/core/typebox-compat.js.map +1 -1
  379. package/dist/core/usage-totals.d.ts +1 -1
  380. package/dist/core/usage-totals.d.ts.map +1 -1
  381. package/dist/core/usage-totals.js.map +1 -1
  382. package/dist/extensions/llama/provider.d.ts +1 -1
  383. package/dist/extensions/llama/provider.d.ts.map +1 -1
  384. package/dist/extensions/llama/provider.js +1 -1
  385. package/dist/extensions/llama/provider.js.map +1 -1
  386. package/dist/main-app-mode.d.ts +1 -1
  387. package/dist/main-app-mode.d.ts.map +1 -1
  388. package/dist/main-app-mode.js.map +1 -1
  389. package/dist/main-session-options.js +1 -1
  390. package/dist/main-session-options.js.map +1 -1
  391. package/dist/modes/interactive/components/assistant-message.d.ts +1 -1
  392. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  393. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  394. package/dist/modes/interactive/components/chat-message-renderer.d.ts +1 -1
  395. package/dist/modes/interactive/components/chat-message-renderer.d.ts.map +1 -1
  396. package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
  397. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  398. package/dist/modes/interactive/components/login-dialog.d.ts +1 -1
  399. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  400. package/dist/modes/interactive/components/login-dialog.js.map +1 -1
  401. package/dist/modes/interactive/components/model-selector.d.ts +1 -1
  402. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  403. package/dist/modes/interactive/components/model-selector.js +1 -1
  404. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  405. package/dist/modes/interactive/components/scoped-models-selector.d.ts +1 -1
  406. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
  407. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
  408. package/dist/modes/interactive/components/settings-selector-handlers.js.map +1 -1
  409. package/dist/modes/interactive/components/settings-selector-types.d.ts +1 -1
  410. package/dist/modes/interactive/components/settings-selector-types.d.ts.map +1 -1
  411. package/dist/modes/interactive/components/settings-selector-types.js.map +1 -1
  412. package/dist/modes/interactive/interactive-auth-routing.js +1 -1
  413. package/dist/modes/interactive/interactive-auth-routing.js.map +1 -1
  414. package/dist/modes/interactive/interactive-deferred-startup.js +1 -1
  415. package/dist/modes/interactive/interactive-deferred-startup.js.map +1 -1
  416. package/dist/modes/interactive/interactive-extension-context.js +26 -0
  417. package/dist/modes/interactive/interactive-extension-context.js.map +1 -1
  418. package/dist/modes/interactive/interactive-extension-runtime.js +7 -2
  419. package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
  420. package/dist/modes/interactive/interactive-mode-base.d.ts +1 -0
  421. package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
  422. package/dist/modes/interactive/interactive-mode-base.js +1 -0
  423. package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
  424. package/dist/modes/interactive/interactive-mode-deps.d.ts +1 -1
  425. package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
  426. package/dist/modes/interactive/interactive-mode-deps.js +1 -1
  427. package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
  428. package/dist/modes/interactive/interactive-mode-helpers.js +1 -1
  429. package/dist/modes/interactive/interactive-mode-helpers.js.map +1 -1
  430. package/dist/modes/interactive/interactive-mode-surface.d.ts +2 -0
  431. package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
  432. package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
  433. package/dist/modes/interactive/model-catalog-refresh.d.ts +1 -1
  434. package/dist/modes/interactive/model-catalog-refresh.d.ts.map +1 -1
  435. package/dist/modes/interactive/model-catalog-refresh.js.map +1 -1
  436. package/dist/modes/interactive/streaming-assistant-message.d.ts +1 -1
  437. package/dist/modes/interactive/streaming-assistant-message.d.ts.map +1 -1
  438. package/dist/modes/interactive/streaming-assistant-message.js.map +1 -1
  439. package/dist/modes/interactive-engine/engine-custom-ui.d.ts +3 -0
  440. package/dist/modes/interactive-engine/engine-custom-ui.d.ts.map +1 -1
  441. package/dist/modes/interactive-engine/engine-custom-ui.js +26 -3
  442. package/dist/modes/interactive-engine/engine-custom-ui.js.map +1 -1
  443. package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
  444. package/dist/modes/interactive-engine/remote-component.d.ts +2 -1
  445. package/dist/modes/interactive-engine/remote-component.d.ts.map +1 -1
  446. package/dist/modes/interactive-engine/remote-component.js +14 -0
  447. package/dist/modes/interactive-engine/remote-component.js.map +1 -1
  448. package/dist/modes/interactive-engine/remote-model-catalog.js.map +1 -1
  449. package/dist/modes/json-event.d.ts +1 -1
  450. package/dist/modes/json-event.d.ts.map +1 -1
  451. package/dist/modes/json-event.js.map +1 -1
  452. package/dist/modes/print-mode.d.ts +1 -1
  453. package/dist/modes/print-mode.d.ts.map +1 -1
  454. package/dist/modes/print-mode.js.map +1 -1
  455. package/dist/modes/rpc/rpc-client-api.d.ts +2 -2
  456. package/dist/modes/rpc/rpc-client-api.d.ts.map +1 -1
  457. package/dist/modes/rpc/rpc-client-api.js.map +1 -1
  458. package/dist/modes/rpc/rpc-client.d.ts +1 -1
  459. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  460. package/dist/modes/rpc/rpc-client.js.map +1 -1
  461. package/dist/modes/rpc/rpc-extension-ui.d.ts.map +1 -1
  462. package/dist/modes/rpc/rpc-extension-ui.js +4 -1
  463. package/dist/modes/rpc/rpc-extension-ui.js.map +1 -1
  464. package/dist/modes/rpc/rpc-provider-auth.d.ts +1 -1
  465. package/dist/modes/rpc/rpc-provider-auth.d.ts.map +1 -1
  466. package/dist/modes/rpc/rpc-provider-auth.js.map +1 -1
  467. package/dist/modes/rpc/rpc-types.d.ts +2 -2
  468. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  469. package/dist/modes/rpc/rpc-types.js.map +1 -1
  470. package/dist/utils/tool-result-images.d.ts +1 -1
  471. package/dist/utils/tool-result-images.d.ts.map +1 -1
  472. package/dist/utils/tool-result-images.js.map +1 -1
  473. package/docs/custom-provider.md +11 -8
  474. package/docs/development.md +0 -2
  475. package/docs/extensions.md +2 -2
  476. package/docs/json.md +1 -1
  477. package/docs/models/artificial-analysis-index.md +2 -2
  478. package/docs/models/model-selection.md +8 -8
  479. package/docs/models/pareto-efficiency.md +10 -10
  480. package/docs/models.md +9 -3
  481. package/docs/packages.md +1 -1
  482. package/docs/providers.md +5 -3
  483. package/docs/quickstart.md +1 -1
  484. package/docs/rpc.md +1 -1
  485. package/docs/sdk.md +2 -2
  486. package/docs/session-format.md +2 -2
  487. package/docs/settings.md +2 -1
  488. package/docs/subagents.md +5 -6
  489. package/docs/tui.md +3 -0
  490. package/docs/workflows.md +3 -1
  491. package/examples/extensions/README.md +1 -1
  492. package/examples/extensions/custom-footer.ts +1 -1
  493. package/examples/extensions/custom-provider-anthropic/index.ts +1 -1
  494. package/examples/extensions/custom-provider-gitlab-duo/index.ts +1 -1
  495. package/examples/extensions/custom-provider-gitlab-duo/test.ts +1 -1
  496. package/examples/extensions/handoff.ts +2 -2
  497. package/examples/extensions/hello.ts +1 -1
  498. package/examples/extensions/plan-mode/index.ts +1 -1
  499. package/examples/extensions/preset.ts +1 -1
  500. package/examples/extensions/qna.ts +1 -1
  501. package/examples/extensions/subagent/display.ts +1 -1
  502. package/examples/extensions/subagent/runner.ts +1 -1
  503. package/examples/extensions/subagent/types.ts +1 -1
  504. package/examples/extensions/summarize.ts +2 -2
  505. package/examples/extensions/tool-override.ts +1 -1
  506. package/examples/sdk/02-custom-model.ts +1 -1
  507. package/examples/sdk/12-full-control.ts +1 -1
  508. package/examples/sdk/README.md +1 -1
  509. package/npm-shrinkwrap.json +54 -31
  510. package/package.json +3 -3
  511. package/dist/builtin/subagents/src/extension/fanout-child.ts +0 -259
  512. package/dist/builtin/subagents/src/runs/inprocess/nested-routing.ts +0 -218
  513. package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-api.ts +0 -55
  514. package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-control.ts +0 -178
  515. package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-core.ts +0 -187
  516. package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-paths.ts +0 -57
  517. package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-projection.ts +0 -42
  518. package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-registry.ts +0 -352
  519. package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-rendering.ts +0 -136
  520. package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-sanitize.ts +0 -252
  521. package/dist/builtin/subagents/src/shared/types-nested.ts +0 -127
  522. package/dist/core/copilot-env-routing.d.ts +0 -36
  523. package/dist/core/copilot-env-routing.d.ts.map +0 -1
  524. package/dist/core/copilot-env-routing.js +0 -94
  525. package/dist/core/copilot-env-routing.js.map +0 -1
@@ -24,8 +24,6 @@ import {
24
24
  DEFAULT_ARTIFACT_CONFIG,
25
25
  getCurrentSubagentDepth,
26
26
  isWorkflowStageOrchestrationContext,
27
- resolveChildMaxSubagentDepth,
28
- resolveWorkflowStageMaxSubagentDepth,
29
27
  type SingleResult,
30
28
  SUBAGENT_ACTIONS,
31
29
  type SubagentToolResult,
@@ -39,7 +37,7 @@ import {
39
37
  import { inheritedIntercomGroup } from "../shared/intercom-group.js";
40
38
  import { currentModelFullId } from "../shared/model-fallback.js";
41
39
  import { resolveControlConfig } from "../shared/subagent-control.js";
42
- import { checkDepthForExecution, prepareExecutionContext } from "./subagent-executor-context.js";
40
+ import { prepareExecutionContext, refuseSubagentChildDelegation } from "./subagent-executor-context.js";
43
41
  import { toExecutionErrorResult, withForkContext } from "./subagent-executor-input.js";
44
42
  import { runParallelPath } from "./subagent-executor-parallel.js";
45
43
  import { resolveRequestedCwd } from "./subagent-executor-resume.js";
@@ -132,12 +130,6 @@ async function resumeRetainedForegroundChild(
132
130
  artifactsDir: artifactConfig.enabled ? artifactsDir : undefined,
133
131
  artifactConfig,
134
132
  maxOutput: params.maxOutput,
135
- maxSubagentDepth:
136
- child.maxSubagentDepth ??
137
- resolveChildMaxSubagentDepth(
138
- resolveWorkflowStageMaxSubagentDepth(ctx, deps.config.maxSubagentDepth),
139
- agentConfig.maxSubagentDepth,
140
- ),
141
133
  parentDepth: getCurrentSubagentDepth(ctx),
142
134
  workflowStageSubagentGuard: isWorkflowStageOrchestrationContext(ctx),
143
135
  workflowSessionMetadata: workflowSessionMetadataFromContext(ctx),
@@ -234,6 +226,12 @@ async function handleManagementRequest(input: {
234
226
  details: { mode: "management" as const, results: [] },
235
227
  };
236
228
  }
229
+ // Delegation is one level deep: a session admitted as a subagent child may
230
+ // never start or continue another agent, whatever else it is authorized for.
231
+ if (!READ_ONLY_MANAGEMENT_ACTIONS.has(action)) {
232
+ const childRefusal = refuseSubagentChildDelegation(ctx, "management");
233
+ if (childRefusal) return childRefusal;
234
+ }
237
235
  if (action === "doctor") {
238
236
  let currentSessionFile: string | null = null;
239
237
  let currentSessionId = deps.state.currentSessionId;
@@ -388,32 +386,23 @@ export function createSubagentExecutor(rawDeps: ExecutorDeps): {
388
386
  };
389
387
  }
390
388
 
391
- const depthError = checkDepthForExecution(ctx, deps);
392
- if (depthError) return depthError;
389
+ const childRefusal = refuseSubagentChildDelegation(ctx, inferExecutionMode(params));
390
+ if (childRefusal) return childRefusal;
393
391
 
394
392
  const built = prepareExecutionContext({ params: paramsWithResolvedCwd, ctx, signal, onUpdate, deps });
395
393
  if (built.error) return built.error;
396
394
  const prepared = built.prepared!;
397
- let nestedForegroundStarted = false;
398
395
  try {
399
- if (prepared.foregroundControl) {
400
- prepared.writeNestedForegroundEvent("subagent.nested.started");
401
- nestedForegroundStarted = true;
402
- }
403
396
  if (prepared.hasTasks && prepared.effectiveParams.tasks) {
404
397
  const result = await runParallelPath(prepared.execData, deps);
405
- prepared.writeNestedForegroundEvent("subagent.nested.completed", result);
406
398
  return withForkContext(result, prepared.effectiveParams.context);
407
399
  }
408
400
  if (prepared.hasSingle) {
409
401
  const result = await runSinglePath(prepared.execData, deps);
410
- prepared.writeNestedForegroundEvent("subagent.nested.completed", result);
411
402
  return withForkContext(result, prepared.effectiveParams.context);
412
403
  }
413
404
  } catch (error) {
414
- const errorResult = toExecutionErrorResult(prepared.effectiveParams, error);
415
- if (nestedForegroundStarted) prepared.writeNestedForegroundEvent("subagent.nested.completed", errorResult);
416
- return errorResult;
405
+ return toExecutionErrorResult(prepared.effectiveParams, error);
417
406
  } finally {
418
407
  if (prepared.foregroundControl) {
419
408
  clearPendingForegroundControlNotices(deps.state, prepared.runId);
@@ -0,0 +1,104 @@
1
+ /**
2
+ * In-process attempt handles for a top-level session's direct children.
3
+ *
4
+ * Delegation is one level deep, so this registry only ever holds a parent's own
5
+ * children. A live child is addressed by its run id or canonical task path, and
6
+ * interrupt/resume reach it through the handle registered when its attempt
7
+ * started — never through a request file, a capability token, or a poller.
8
+ */
9
+
10
+ export interface InProcessAttemptResumeOutcome {
11
+ readonly status: "ok" | "error" | "interrupted" | "continued";
12
+ readonly path: string;
13
+ readonly sessionFile?: string;
14
+ readonly envelope?: string;
15
+ }
16
+
17
+ export interface InProcessAttemptHandle {
18
+ readonly runId: string;
19
+ readonly path: string;
20
+ readonly status: () => string;
21
+ readonly interrupt: () => Promise<void>;
22
+ readonly resume: (message: string) => Promise<InProcessAttemptResumeOutcome>;
23
+ }
24
+
25
+ export interface InProcessAttemptControlResult {
26
+ readonly ok: boolean;
27
+ readonly message: string;
28
+ readonly outcome?: InProcessAttemptResumeOutcome;
29
+ }
30
+
31
+ const attemptHandles = new Map<string, Map<string, InProcessAttemptHandle>>();
32
+
33
+ function attemptKey(id: string): string {
34
+ return id.trim();
35
+ }
36
+
37
+ export function registerInProcessAttempt(handle: InProcessAttemptHandle): () => void {
38
+ const key = attemptKey(handle.runId);
39
+ let handles = attemptHandles.get(key);
40
+ if (!handles) {
41
+ handles = new Map();
42
+ attemptHandles.set(key, handles);
43
+ }
44
+ handles.set(handle.path, handle);
45
+ const pathKey = attemptKey(handle.path);
46
+ if (pathKey !== key) {
47
+ let byPath = attemptHandles.get(pathKey);
48
+ if (!byPath) {
49
+ byPath = new Map();
50
+ attemptHandles.set(pathKey, byPath);
51
+ }
52
+ byPath.set(handle.path, handle);
53
+ }
54
+ return () => {
55
+ for (const lookupKey of [key, pathKey]) {
56
+ const current = attemptHandles.get(lookupKey);
57
+ if (!current || current.get(handle.path) !== handle) continue;
58
+ current.delete(handle.path);
59
+ if (current.size === 0) attemptHandles.delete(lookupKey);
60
+ }
61
+ };
62
+ }
63
+
64
+ function handlesFor(id: string): InProcessAttemptHandle[] {
65
+ return [...(attemptHandles.get(attemptKey(id))?.values() ?? [])];
66
+ }
67
+
68
+ export async function interruptInProcessAttempt(targetId: string): Promise<InProcessAttemptControlResult | undefined> {
69
+ const handles = handlesFor(targetId);
70
+ if (handles.length === 0) return undefined;
71
+ const active = handles.filter((handle) => handle.status() === "running" || handle.status() === "continued");
72
+ if (active.length === 0) {
73
+ return { ok: false, message: `Run ${targetId} has no active child attempt to interrupt.` };
74
+ }
75
+ await Promise.all(active.map((handle) => handle.interrupt()));
76
+ return { ok: true, message: `Interrupt requested for run ${targetId}.` };
77
+ }
78
+
79
+ export async function resumeInProcessAttempt(
80
+ targetId: string,
81
+ message: string,
82
+ ): Promise<InProcessAttemptControlResult | undefined> {
83
+ const handles = handlesFor(targetId);
84
+ if (handles.length === 0) return undefined;
85
+ const handle =
86
+ handles.find((candidate) => candidate.status() === "interrupted" || candidate.status() === "error") ?? handles[0];
87
+ if (!handle) return undefined;
88
+ if (handle.status() === "running" || handle.status() === "continued") {
89
+ return { ok: false, message: `Run ${targetId} is still running; resume is not required.` };
90
+ }
91
+ const outcome = await handle.resume(message);
92
+ return {
93
+ ok: outcome.status === "ok" || outcome.status === "continued",
94
+ message:
95
+ outcome.status === "ok"
96
+ ? `Reloaded run ${targetId} through the in-process control plane.`
97
+ : `Run ${targetId} resume ended with status '${outcome.status}'.`,
98
+ outcome,
99
+ };
100
+ }
101
+
102
+ export function clearInProcessAttemptHandles(): void {
103
+ attemptHandles.clear();
104
+ }
@@ -1,20 +1,14 @@
1
+ export type {
2
+ InProcessAttemptControlResult,
3
+ InProcessAttemptHandle,
4
+ InProcessAttemptResumeOutcome,
5
+ } from "./attempt-handles.js";
1
6
  export {
2
- appendInProcessControlRequest,
3
- appendInProcessControlResult,
4
- appendInProcessNestedEvent,
5
- clearInProcessNestedRouting,
6
- hasInProcessNestedRoute,
7
- interruptInProcessNestedAttempt,
8
- readInProcessControlRequests,
9
- readInProcessControlResults,
10
- readInProcessNestedEvents,
11
- registerInProcessNestedAttempt,
12
- registerInProcessNestedRoute,
13
- removeInProcessControlRequest,
14
- resumeInProcessNestedAttempt,
15
- subscribeInProcessControlRequests,
16
- unregisterInProcessNestedRoute,
17
- } from "./nested-routing.js";
7
+ clearInProcessAttemptHandles,
8
+ interruptInProcessAttempt,
9
+ registerInProcessAttempt,
10
+ resumeInProcessAttempt,
11
+ } from "./attempt-handles.js";
18
12
  export type {
19
13
  AdmissionRefusal,
20
14
  AdmittedResult,
@@ -25,11 +19,6 @@ export type {
25
19
  ChildSpec,
26
20
  ChildStatus,
27
21
  ContinuationReason,
28
- InProcessControlRequest,
29
- InProcessControlResult,
30
- InProcessNestedAttemptHandle,
31
- InProcessNestedResumeOutcome,
32
- InProcessNestedRouteKey,
33
22
  ModelCandidate,
34
23
  ParentContext,
35
24
  ResultEnvelope,
@@ -11,9 +11,8 @@ export const CHILD_SUBAGENT_BOUNDARY_INSTRUCTIONS = [
11
11
  export const CHILD_FANOUT_BOUNDARY_INSTRUCTIONS = [
12
12
  "You are a child subagent with explicit fanout responsibility for this assigned task.",
13
13
  "The parent session owns final orchestration, completion decisions, and follow-up implementation launches.",
14
- "You may use the `subagent` tool only for the fanout work explicitly requested in this task.",
15
- "Do not broaden yourself into general parent orchestration. Do not launch follow-up workers unless the task explicitly asks for that.",
16
- "The maxSubagentDepth cap still applies and may block further fanout.",
14
+ "Delegation is one level deep: the `subagent` tool refuses every launch, resume, and interrupt from inside a subagent.",
15
+ "Do the assigned fanout work yourself and report what you found; do not plan around delegating it.",
17
16
  "If you need to edit files, call the actual edit/write tools. Do not print tool-call syntax, patches, or pseudo-tool calls as text.",
18
17
  ].join("\n");
19
18
 
@@ -23,7 +23,7 @@ import {
23
23
  type TerminationCause as NativeTerminationCause,
24
24
  SubagentControl,
25
25
  } from "@bastani/atomic-natives";
26
- import type { Api, Model } from "@earendil-works/pi-ai/compat";
26
+ import type { Api, Model } from "@bastani/pi-ai/compat";
27
27
  import type { AgentConfig } from "../../agents/agent-types.js";
28
28
  import {
29
29
  buildSkillInjection,
@@ -43,11 +43,10 @@ import {
43
43
  type ArtifactPaths,
44
44
  DEFAULT_MAX_OUTPUT,
45
45
  type MaxOutputConfig,
46
- normalizeMaxSubagentDepth,
47
46
  truncateOutput,
48
47
  } from "../../shared/types.js";
48
+ import { type InProcessAttemptResumeOutcome, registerInProcessAttempt } from "./attempt-handles.js";
49
49
  import { type ChildModePolicy, resolveChildModePolicy } from "./child-policy.js";
50
- import { type InProcessNestedResumeOutcome, registerInProcessNestedAttempt } from "./nested-routing.js";
51
50
  import { createInProcessChildPromptBehavior, createInProcessChildSystemPromptTransform } from "./prompt-behavior.js";
52
51
 
53
52
  export type ChildStatus = NativeAgentStatus;
@@ -99,12 +98,6 @@ export interface ChildSpec {
99
98
  /** Typed identity/capability resolved by the parent before admission. */
100
99
  readonly intercom?: SubagentIntercomIdentity;
101
100
  readonly sessionFile?: string;
102
- /**
103
- * Effective delegation limit for this child, already narrowed by the parent's
104
- * limit and the child agent's own `maxSubagentDepth`. Retained on the spec so
105
- * a cold reload reissues the same limit.
106
- */
107
- readonly maxSubagentDepth?: number;
108
101
  readonly testSession?: boolean | TestSessionOptions;
109
102
  readonly artifactJsonlPath?: string;
110
103
  /**
@@ -316,16 +309,6 @@ function workflowMetadataFromContext(
316
309
  };
317
310
  }
318
311
 
319
- /**
320
- * Effective delegation limit for an admitted child. A caller that already
321
- * narrowed the parent's limit against the agent definition puts the result on
322
- * the spec; a caller admitting a child directly still gets the agent's own
323
- * declared limit rather than an unbounded policy.
324
- */
325
- export function effectiveChildMaxSubagentDepth(spec: ChildSpec): number | undefined {
326
- return spec.maxSubagentDepth ?? normalizeMaxSubagentDepth(spec.agent.maxSubagentDepth);
327
- }
328
-
329
312
  /**
330
313
  * In-process children must load the same bundled extensions as the host.
331
314
  * Workflow extensions are disabled inside workflow-owned sessions because their
@@ -618,8 +601,9 @@ function writeEvent(pathValue: string | undefined, event: AgentSessionEvent): vo
618
601
 
619
602
  /**
620
603
  * A child identity whose constructor is private. Depth and path validation happen
621
- * at the Rust admission door, so callers cannot manufacture an admitted depth-6
622
- * child or bypass canonical identity allocation.
604
+ * at the Rust admission door, so callers cannot manufacture an admitted child
605
+ * below the single permitted delegation level or bypass canonical identity
606
+ * allocation.
623
607
  */
624
608
  interface AdmittedChildInput {
625
609
  readonly identity: ChildIdentity;
@@ -655,7 +639,7 @@ export class AdmittedChild {
655
639
  }
656
640
 
657
641
  static create(input: AdmittedChildInput): AdmittedChild {
658
- if (input.identity.depth > 5) throw new Error("child depth exceeds maximum 5");
642
+ if (input.identity.depth > 1) throw new Error("child depth exceeds maximum 1");
659
643
  validatePath(input.identity.path);
660
644
  return new AdmittedChild(input);
661
645
  }
@@ -747,9 +731,6 @@ export class SubagentControlRuntime {
747
731
  intercomGroup: parent.intercomGroup,
748
732
  intercom: spec.intercom,
749
733
  depth: identity.depth,
750
- ...(effectiveChildMaxSubagentDepth(spec) === undefined
751
- ? {}
752
- : { maxSubagentDepth: effectiveChildMaxSubagentDepth(spec) }),
753
734
  },
754
735
  sessionDir,
755
736
  sessionFile: spec.sessionFile,
@@ -1228,16 +1209,17 @@ export class SubagentControlRuntime {
1228
1209
  };
1229
1210
  }
1230
1211
 
1231
- registerNestedAttempt(runId: string, running: RunningAttempt, candidate: ModelCandidate): void {
1232
- registerInProcessNestedAttempt({
1212
+ /** Expose a direct child's live attempt so `interrupt`/`resume` can reach it by run id or path. */
1213
+ registerAttempt(runId: string, running: RunningAttempt, candidate: ModelCandidate): void {
1214
+ registerInProcessAttempt({
1233
1215
  runId,
1234
1216
  path: running.child.identity.path,
1235
1217
  status: () => running.status,
1236
1218
  interrupt: () => this.terminateChildAttempt(running, "interrupt"),
1237
- resume: async (message): Promise<InProcessNestedResumeOutcome> => {
1219
+ resume: async (message): Promise<InProcessAttemptResumeOutcome> => {
1238
1220
  const admission = this.reloadColdChild(running.child.identity.path, message);
1239
1221
  if (!admission.admitted) {
1240
- throw new Error(admission.refusal?.reason ?? "nested child cold reload was refused");
1222
+ throw new Error(admission.refusal?.reason ?? "child cold reload was refused");
1241
1223
  }
1242
1224
  const neverAbort = new AbortController().signal;
1243
1225
  const resumed = this.startAttempt(admission.admitted, candidate, {
@@ -1344,9 +1326,6 @@ export class SubagentControlRuntime {
1344
1326
  thinkingLevel: spec.thinkingLevel ?? (spec.agent.thinking as ChildPolicy["thinkingLevel"]),
1345
1327
  intercomGroup: spec.parent?.intercomGroup,
1346
1328
  depth,
1347
- ...(effectiveChildMaxSubagentDepth(spec) === undefined
1348
- ? {}
1349
- : { maxSubagentDepth: effectiveChildMaxSubagentDepth(spec) }),
1350
1329
  };
1351
1330
  }
1352
1331
 
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Startup housekeeping for the subagent runtime temp root.
3
+ *
4
+ * The multi-level route/event pipeline that once wrote into this directory is
5
+ * gone, so nothing creates entries here any more. The scanner stays because
6
+ * users' machines still hold directories written by earlier versions, and
7
+ * nothing else would ever reap them.
8
+ */
9
+
10
+ import * as fs from "node:fs";
11
+ import * as path from "node:path";
12
+ import { TEMP_ROOT_DIR } from "../../../shared/types.js";
13
+
14
+ /**
15
+ * Historical directory name. It must keep matching what earlier versions wrote,
16
+ * or their leftovers become unreachable garbage.
17
+ */
18
+ export const SUBAGENT_RUNTIME_TEMP_DIR = path.join(TEMP_ROOT_DIR, "nested-subagent-events");
19
+
20
+ /** Whether any entry in the tree rooted at filePath has an mtime at or after cutoff, stopping at the first hit. */
21
+ export function hasEntryNewerThan(filePath: string, cutoff: number): boolean {
22
+ const stat = fs.statSync(filePath);
23
+ if (stat.mtimeMs >= cutoff) return true;
24
+ if (!stat.isDirectory()) return false;
25
+ return directoryHasEntryNewerThan(filePath, cutoff);
26
+ }
27
+
28
+ function directoryHasEntryNewerThan(dirPath: string, cutoff: number): boolean {
29
+ let entries: string[];
30
+ try {
31
+ entries = fs.readdirSync(dirPath);
32
+ } catch {
33
+ return false;
34
+ }
35
+ for (const entry of entries) {
36
+ const childPath = path.join(dirPath, entry);
37
+ try {
38
+ const stat = fs.statSync(childPath);
39
+ if (stat.mtimeMs >= cutoff) return true;
40
+ if (stat.isDirectory() && directoryHasEntryNewerThan(childPath, cutoff)) return true;
41
+ } catch {
42
+ // Runtime cleanup is best-effort housekeeping.
43
+ }
44
+ }
45
+ return false;
46
+ }
47
+
48
+ function cleanupOldSubdirectories(root: string, maxAgeDays: number): void {
49
+ let entries: string[];
50
+ try {
51
+ entries = fs.readdirSync(root);
52
+ } catch (error) {
53
+ if ((error as NodeJS.ErrnoException).code === "ENOENT") return;
54
+ throw error;
55
+ }
56
+ const cutoff = Date.now() - maxAgeDays * 24 * 60 * 60 * 1000;
57
+ for (const entry of entries) {
58
+ const entryPath = path.join(root, entry);
59
+ try {
60
+ if (!hasEntryNewerThan(entryPath, cutoff)) fs.rmSync(entryPath, { recursive: true, force: true });
61
+ } catch {
62
+ // Keep startup resilient if a child process removes or rewrites an entry while scanning.
63
+ }
64
+ }
65
+ }
66
+
67
+ export function cleanupOldSubagentRuntimeDirs(maxAgeDays: number): void {
68
+ cleanupOldSubdirectories(SUBAGENT_RUNTIME_TEMP_DIR, maxAgeDays);
69
+ }
@@ -15,7 +15,7 @@
15
15
  * string means.
16
16
  */
17
17
 
18
- import type { Api, Model } from "@earendil-works/pi-ai/compat";
18
+ import type { Api, Model } from "@bastani/pi-ai/compat";
19
19
  import { splitKnownThinkingSuffix, THINKING_LEVELS, type ThinkingLevel } from "./model-info.js";
20
20
 
21
21
  /** Registry surface needed to resolve a candidate; satisfied by `ctx.modelRegistry`. */
@@ -5,7 +5,6 @@
5
5
  import type { AgentSessionEvent, SessionWorkflowMetadata } from "@bastani/atomic";
6
6
  import type { AgentToolResult } from "@earendil-works/pi-agent-core";
7
7
  import type { CandidateModelResolver } from "./model-resolution.js";
8
- import type { NestedRouteInfo } from "./types-nested.js";
9
8
  import type {
10
9
  ArtifactConfig,
11
10
  ControlConfig,
@@ -88,12 +87,10 @@ export interface RunSyncOptions {
88
87
  share?: boolean;
89
88
  outputPath?: string;
90
89
  outputMode?: OutputMode;
91
- maxSubagentDepth?: number;
92
90
  /** Current session depth passed to the in-process admission door. */
93
91
  parentDepth?: number;
94
92
  workflowStageSubagentGuard?: boolean;
95
93
  workflowSessionMetadata?: SessionWorkflowMetadata;
96
- nestedRoute?: NestedRouteInfo;
97
94
  /** Override the agent's default model (format: "provider/id" or just "id") */
98
95
  modelOverride?: string;
99
96
  /** Registry models available for heuristic bare-model resolution */
@@ -160,7 +157,6 @@ interface TopLevelParallelConfig {
160
157
 
161
158
  export interface ExtensionConfig {
162
159
  defaultSessionDir?: string;
163
- maxSubagentDepth?: number;
164
160
  control?: ControlConfig;
165
161
  parallel?: TopLevelParallelConfig;
166
162
  worktreeSetupHook?: string;
@@ -1,42 +1,15 @@
1
1
  /**
2
- * Recursion-depth guard helpers for nested subagent execution.
2
+ * Delegation boundary helpers.
3
+ *
4
+ * Delegation is exactly one level deep and is not configurable: a top-level
5
+ * session (main chat or a workflow stage) may call the `subagent` tool, and the
6
+ * children it admits may not.
3
7
  */
4
8
 
5
9
  import type { ExtensionContext, SessionWorkflowMetadata } from "@bastani/atomic";
6
- import { DEFAULT_SUBAGENT_MAX_DEPTH, MAX_SUBAGENT_NESTING_DEPTH } from "./types-runtime.js";
7
10
 
8
11
  // Depth is admission state carried in the typed child policy, not process environment.
9
12
 
10
- // ============================================================================
11
- export function normalizeMaxSubagentDepth(value: unknown): number | undefined {
12
- const parsed = typeof value === "number" ? value : typeof value === "string" ? Number(value) : NaN;
13
- if (!Number.isInteger(parsed) || parsed < 0) return undefined;
14
- return Math.min(parsed, MAX_SUBAGENT_NESTING_DEPTH);
15
- }
16
-
17
- /**
18
- * The effective limit is the stricter of the local configuration and any limit
19
- * inherited through the child policy, both clamped by the global ceiling.
20
- */
21
- export function resolveCurrentMaxSubagentDepth(configMaxDepth?: number, inheritedMaxDepth?: number): number {
22
- const local = normalizeMaxSubagentDepth(configMaxDepth) ?? DEFAULT_SUBAGENT_MAX_DEPTH;
23
- const inherited = normalizeMaxSubagentDepth(inheritedMaxDepth);
24
- return inherited === undefined ? local : Math.min(local, inherited);
25
- }
26
-
27
- /** Read the delegation limit a parent admission issued to this child session. */
28
- export function getInheritedMaxSubagentDepth(
29
- ctx: Partial<Pick<ExtensionContext, "subagentPolicy">>,
30
- ): number | undefined {
31
- return ctx.subagentPolicy?.maxSubagentDepth;
32
- }
33
-
34
- export function resolveChildMaxSubagentDepth(parentMaxDepth: number, agentMaxDepth?: number): number {
35
- const normalizedParent = normalizeMaxSubagentDepth(parentMaxDepth) ?? DEFAULT_SUBAGENT_MAX_DEPTH;
36
- const normalizedAgent = normalizeMaxSubagentDepth(agentMaxDepth);
37
- return normalizedAgent === undefined ? normalizedParent : Math.min(normalizedParent, normalizedAgent);
38
- }
39
-
40
13
  export function isWorkflowStageOrchestrationContext(ctx: Pick<ExtensionContext, "orchestrationContext">): boolean {
41
14
  return ctx.orchestrationContext?.kind === "workflow-stage";
42
15
  }
@@ -53,82 +26,21 @@ export function workflowSessionMetadataFromContext(
53
26
  };
54
27
  }
55
28
 
56
- export function resolveWorkflowStageMaxSubagentDepth(
57
- ctx: Pick<ExtensionContext, "orchestrationContext"> & Partial<Pick<ExtensionContext, "subagentPolicy">>,
58
- configMaxDepth?: number,
59
- ): number {
60
- const maxDepth = resolveCurrentMaxSubagentDepth(configMaxDepth, getInheritedMaxSubagentDepth(ctx));
61
- return isWorkflowStageOrchestrationContext(ctx)
62
- ? // Workflow stages receive an explicit host constraint, clamped by the
63
- // inherited/global nesting ceiling. A 0-depth workflow constraint still
64
- // preserves one child-subagent hop so configured stages can delegate once.
65
- Math.min(maxDepth, Math.max(1, ctx.orchestrationContext?.constraints.maxSubagentDepth ?? 1))
66
- : maxDepth;
67
- }
68
-
69
- export interface SubagentDepthPolicy {
70
- maxSubagentDepth: number;
71
- workflowStageSubagentGuard: boolean;
72
- }
73
-
74
- export function resolveSubagentDepthPolicy(
75
- ctx: Pick<ExtensionContext, "orchestrationContext"> & Partial<Pick<ExtensionContext, "subagentPolicy">>,
76
- configMaxDepth?: number,
77
- ): SubagentDepthPolicy {
78
- return {
79
- maxSubagentDepth: resolveWorkflowStageMaxSubagentDepth(ctx, configMaxDepth),
80
- workflowStageSubagentGuard: isWorkflowStageOrchestrationContext(ctx),
81
- };
82
- }
83
-
84
- function workflowStageSubagentDepthMessage(
85
- depth: number,
86
- maxDepth: number,
87
- action: "call" | "resume" = "call",
88
- ): string {
89
- return `Nested subagent ${action} blocked (depth=${depth}, max=${maxDepth}). Sub-agents inside workflow stages are running at the maximum nesting depth.`;
90
- }
91
-
92
- export function subagentDepthBlockedMessage(
93
- depth: number,
94
- maxDepth: number,
95
- options?: { action?: "call" | "resume"; workflowStageGuard?: boolean },
96
- ): string {
97
- const action = options?.action ?? "call";
98
- if (options?.workflowStageGuard) {
99
- return workflowStageSubagentDepthMessage(depth, maxDepth, action);
100
- }
101
- if (action === "resume") {
102
- return `Nested subagent resume blocked (depth=${depth}, max=${maxDepth}). Complete the follow-up directly instead.`;
103
- }
104
- return (
105
- `Nested subagent call blocked (depth=${depth}, max=${maxDepth}). ` +
106
- "You are running at the maximum subagent nesting depth. " +
107
- "Complete your current task directly without delegating to further subagents."
108
- );
109
- }
110
-
111
- export interface SubagentDepthCheck {
112
- blocked: boolean;
113
- depth: number;
114
- maxDepth: number;
115
- }
116
-
117
29
  /** Read the admitted depth carried by an in-process child session. */
118
30
  export function getCurrentSubagentDepth(ctx: Pick<ExtensionContext, "subagentPolicy">): number {
119
31
  const depth = ctx.subagentPolicy?.depth;
120
32
  return typeof depth === "number" && Number.isInteger(depth) && depth >= 0 ? depth : 0;
121
33
  }
122
34
 
123
- export function checkSubagentDepth(
124
- ctx: Pick<ExtensionContext, "subagentPolicy">,
125
- configMaxDepth?: number,
126
- ): SubagentDepthCheck {
127
- const depth = getCurrentSubagentDepth(ctx);
128
- const maxDepth = resolveCurrentMaxSubagentDepth(configMaxDepth, getInheritedMaxSubagentDepth(ctx));
129
- return { blocked: Number.isFinite(depth) && depth >= maxDepth, depth, maxDepth };
35
+ /**
36
+ * True when this session was itself admitted as a subagent child. Such a session
37
+ * may never delegate further, regardless of any other capability it carries.
38
+ */
39
+ export function isSubagentChildSession(ctx: Pick<ExtensionContext, "subagentPolicy">): boolean {
40
+ return getCurrentSubagentDepth(ctx) >= 1;
130
41
  }
131
42
 
132
- // ============================================================================
133
- // Utility Functions
134
- // ============================================================================
43
+ export const SUBAGENT_CHILD_DELEGATION_BLOCKED_MESSAGE =
44
+ "Subagent delegation is not available inside a subagent. " +
45
+ "Only a top-level session (main chat or a workflow stage) can call the subagent tool. " +
46
+ "Complete your assigned task directly.";
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Foreground run and extension state public types.
3
+ *
4
+ * Delegation is one level deep, so a parent tracks only its own direct children.
5
+ * The multi-level run address, route, and recursive summary types this file once
6
+ * carried are gone with the pipeline that produced them.
7
+ */
8
+
9
+ import type { ExtensionContext } from "@bastani/atomic";
10
+ import type { ActivityState, SingleResult, SubagentResultStatus, SubagentRunMode } from "./types-results.js";
11
+
12
+ export interface ForegroundResumeChild {
13
+ agent: string;
14
+ index: number;
15
+ sessionFile?: string;
16
+ status: SubagentResultStatus;
17
+ result?: SingleResult;
18
+ }
19
+
20
+ export interface ForegroundResumeRun {
21
+ runId: string;
22
+ mode: SubagentRunMode;
23
+ cwd: string;
24
+ updatedAt: number;
25
+ children: ForegroundResumeChild[];
26
+ }
27
+
28
+ export interface SubagentState {
29
+ baseCwd: string;
30
+ currentSessionId: string | null;
31
+ subagentInProgress?: boolean;
32
+ foregroundRuns?: Map<string, ForegroundResumeRun>;
33
+ foregroundControls: Map<
34
+ string,
35
+ {
36
+ runId: string;
37
+ mode: SubagentRunMode;
38
+ startedAt: number;
39
+ updatedAt: number;
40
+ currentAgent?: string;
41
+ currentIndex?: number;
42
+ currentActivityState?: ActivityState;
43
+ lastActivityAt?: number;
44
+ currentTool?: string;
45
+ currentToolStartedAt?: number;
46
+ currentPath?: string;
47
+ turnCount?: number;
48
+ tokens?: number;
49
+ toolCount?: number;
50
+ interrupt?: () => boolean;
51
+ }
52
+ >;
53
+ lastForegroundControlId: string | null;
54
+ pendingForegroundControlNotices?: Map<string, ReturnType<typeof setTimeout>>;
55
+ lastUiContext: ExtensionContext | null;
56
+ }