@bastani/atomic 0.9.14-alpha.6 → 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 (526) hide show
  1. package/CHANGELOG.md +90 -0
  2. package/README.md +1 -1
  3. package/dist/builtin/intercom/package.json +2 -2
  4. package/dist/builtin/mcp/CHANGELOG.md +14 -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 +42 -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/CHANGELOG.md +16 -0
  51. package/dist/builtin/web-access/package.json +2 -2
  52. package/dist/builtin/web-access/summary-review.ts +2 -2
  53. package/dist/builtin/web-access/web-search-summary.ts +2 -2
  54. package/dist/builtin/workflows/CHANGELOG.md +84 -0
  55. package/dist/builtin/workflows/README.md +2 -2
  56. package/dist/builtin/workflows/package.json +2 -2
  57. package/dist/builtin/workflows/src/extension/index.bundle.mjs +60473 -401
  58. package/dist/builtin/workflows/src/extension/public-types.ts +1 -1
  59. package/dist/builtin/workflows/src/extension/wiring.ts +1 -1
  60. package/dist/builtin/workflows/src/extension/workflow-heartbeat-delivery.ts +48 -4
  61. package/dist/builtin/workflows/src/extension/workflow-tool.ts +1 -1
  62. package/dist/builtin/workflows/src/runs/foreground/executor-stage-factory.ts +5 -0
  63. package/dist/builtin/workflows/src/runs/foreground/stage-runner-controller.ts +35 -2
  64. package/dist/builtin/workflows/src/runs/foreground/stage-runner-options.ts +1 -1
  65. package/dist/builtin/workflows/src/runs/foreground/stage-runner-pause.ts +6 -0
  66. package/dist/builtin/workflows/src/tui/chat-surface-message.ts +15 -13
  67. package/dist/builtin/workflows/src/tui/store-widget-installer.ts +25 -2
  68. package/dist/bun/cli.js +1 -1
  69. package/dist/bun/cli.js.map +1 -1
  70. package/dist/bun/register-bedrock.js +2 -2
  71. package/dist/bun/register-bedrock.js.map +1 -1
  72. package/dist/cli/auth-check.d.ts +1 -1
  73. package/dist/cli/auth-check.d.ts.map +1 -1
  74. package/dist/cli/auth-check.js +1 -1
  75. package/dist/cli/auth-check.js.map +1 -1
  76. package/dist/cli/credential-print.d.ts +1 -1
  77. package/dist/cli/credential-print.d.ts.map +1 -1
  78. package/dist/cli/credential-print.js +2 -2
  79. package/dist/cli/credential-print.js.map +1 -1
  80. package/dist/cli/file-processor.d.ts +1 -1
  81. package/dist/cli/file-processor.d.ts.map +1 -1
  82. package/dist/cli/file-processor.js.map +1 -1
  83. package/dist/cli/initial-message.d.ts +1 -1
  84. package/dist/cli/initial-message.d.ts.map +1 -1
  85. package/dist/cli/initial-message.js.map +1 -1
  86. package/dist/cli/list-models.js.map +1 -1
  87. package/dist/core/agent-session-auto-compaction.d.ts +1 -1
  88. package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
  89. package/dist/core/agent-session-auto-compaction.js +1 -1
  90. package/dist/core/agent-session-auto-compaction.js.map +1 -1
  91. package/dist/core/agent-session-events.d.ts +1 -1
  92. package/dist/core/agent-session-events.d.ts.map +1 -1
  93. package/dist/core/agent-session-events.js +1 -1
  94. package/dist/core/agent-session-events.js.map +1 -1
  95. package/dist/core/agent-session-export.js.map +1 -1
  96. package/dist/core/agent-session-extension-bindings.js +1 -1
  97. package/dist/core/agent-session-extension-bindings.js.map +1 -1
  98. package/dist/core/agent-session-message-queue.d.ts +1 -1
  99. package/dist/core/agent-session-message-queue.d.ts.map +1 -1
  100. package/dist/core/agent-session-message-queue.js.map +1 -1
  101. package/dist/core/agent-session-methods.d.ts +2 -2
  102. package/dist/core/agent-session-methods.d.ts.map +1 -1
  103. package/dist/core/agent-session-methods.js.map +1 -1
  104. package/dist/core/agent-session-models.d.ts +2 -2
  105. package/dist/core/agent-session-models.d.ts.map +1 -1
  106. package/dist/core/agent-session-models.js +2 -2
  107. package/dist/core/agent-session-models.js.map +1 -1
  108. package/dist/core/agent-session-prompt.d.ts +1 -1
  109. package/dist/core/agent-session-prompt.d.ts.map +1 -1
  110. package/dist/core/agent-session-prompt.js.map +1 -1
  111. package/dist/core/agent-session-retry.d.ts +1 -1
  112. package/dist/core/agent-session-retry.d.ts.map +1 -1
  113. package/dist/core/agent-session-retry.js +1 -1
  114. package/dist/core/agent-session-retry.js.map +1 -1
  115. package/dist/core/agent-session-runtime-auth.js +1 -1
  116. package/dist/core/agent-session-runtime-auth.js.map +1 -1
  117. package/dist/core/agent-session-runtime.d.ts +1 -1
  118. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  119. package/dist/core/agent-session-runtime.js +1 -1
  120. package/dist/core/agent-session-runtime.js.map +1 -1
  121. package/dist/core/agent-session-services.d.ts +1 -1
  122. package/dist/core/agent-session-services.d.ts.map +1 -1
  123. package/dist/core/agent-session-services.js.map +1 -1
  124. package/dist/core/agent-session-state.d.ts +1 -1
  125. package/dist/core/agent-session-state.d.ts.map +1 -1
  126. package/dist/core/agent-session-state.js.map +1 -1
  127. package/dist/core/agent-session-tree.js.map +1 -1
  128. package/dist/core/agent-session-types.d.ts +1 -1
  129. package/dist/core/agent-session-types.d.ts.map +1 -1
  130. package/dist/core/agent-session-types.js.map +1 -1
  131. package/dist/core/agent-session.d.ts +1 -1
  132. package/dist/core/agent-session.d.ts.map +1 -1
  133. package/dist/core/agent-session.js.map +1 -1
  134. package/dist/core/anthropic-thinking-guard.d.ts +1 -1
  135. package/dist/core/anthropic-thinking-guard.d.ts.map +1 -1
  136. package/dist/core/anthropic-thinking-guard.js +1 -1
  137. package/dist/core/anthropic-thinking-guard.js.map +1 -1
  138. package/dist/core/auth-storage.d.ts +1 -1
  139. package/dist/core/auth-storage.d.ts.map +1 -1
  140. package/dist/core/auth-storage.js.map +1 -1
  141. package/dist/core/cache-stats.d.ts +1 -1
  142. package/dist/core/cache-stats.d.ts.map +1 -1
  143. package/dist/core/cache-stats.js.map +1 -1
  144. package/dist/core/cloudflare-gateway-binding.d.ts +1 -1
  145. package/dist/core/cloudflare-gateway-binding.d.ts.map +1 -1
  146. package/dist/core/cloudflare-gateway-binding.js +1 -1
  147. package/dist/core/cloudflare-gateway-binding.js.map +1 -1
  148. package/dist/core/codex-fast-mode.d.ts +2 -2
  149. package/dist/core/codex-fast-mode.d.ts.map +1 -1
  150. package/dist/core/codex-fast-mode.js +3 -2
  151. package/dist/core/codex-fast-mode.js.map +1 -1
  152. package/dist/core/compaction/branch-summarization.d.ts +2 -2
  153. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  154. package/dist/core/compaction/branch-summarization.js +2 -2
  155. package/dist/core/compaction/branch-summarization.js.map +1 -1
  156. package/dist/core/compaction/compaction-runner.d.ts +2 -2
  157. package/dist/core/compaction/compaction-runner.d.ts.map +1 -1
  158. package/dist/core/compaction/compaction-runner.js.map +1 -1
  159. package/dist/core/compaction/compaction-types.d.ts +2 -2
  160. package/dist/core/compaction/compaction-types.d.ts.map +1 -1
  161. package/dist/core/compaction/compaction-types.js.map +1 -1
  162. package/dist/core/compaction/compaction.d.ts +1 -1
  163. package/dist/core/compaction/compaction.d.ts.map +1 -1
  164. package/dist/core/compaction/compaction.js.map +1 -1
  165. package/dist/core/compaction/fallback-planner.d.ts +1 -1
  166. package/dist/core/compaction/fallback-planner.d.ts.map +1 -1
  167. package/dist/core/compaction/fallback-planner.js.map +1 -1
  168. package/dist/core/compaction/planner-outcome.d.ts +1 -1
  169. package/dist/core/compaction/planner-outcome.d.ts.map +1 -1
  170. package/dist/core/compaction/planner-outcome.js +1 -1
  171. package/dist/core/compaction/planner-outcome.js.map +1 -1
  172. package/dist/core/compaction/range-planner-diagnostics.d.ts +1 -1
  173. package/dist/core/compaction/range-planner-diagnostics.d.ts.map +1 -1
  174. package/dist/core/compaction/range-planner-diagnostics.js +1 -1
  175. package/dist/core/compaction/range-planner-diagnostics.js.map +1 -1
  176. package/dist/core/compaction/range-planner.d.ts +2 -2
  177. package/dist/core/compaction/range-planner.d.ts.map +1 -1
  178. package/dist/core/compaction/range-planner.js +2 -2
  179. package/dist/core/compaction/range-planner.js.map +1 -1
  180. package/dist/core/compaction/session-summarization.d.ts +2 -2
  181. package/dist/core/compaction/session-summarization.d.ts.map +1 -1
  182. package/dist/core/compaction/session-summarization.js +2 -2
  183. package/dist/core/compaction/session-summarization.js.map +1 -1
  184. package/dist/core/compaction/transcript-serialization.d.ts +1 -1
  185. package/dist/core/compaction/transcript-serialization.d.ts.map +1 -1
  186. package/dist/core/compaction/transcript-serialization.js.map +1 -1
  187. package/dist/core/compaction/utils.d.ts +1 -1
  188. package/dist/core/compaction/utils.d.ts.map +1 -1
  189. package/dist/core/compaction/utils.js.map +1 -1
  190. package/dist/core/experimental.d.ts +1 -1
  191. package/dist/core/experimental.d.ts.map +1 -1
  192. package/dist/core/experimental.js.map +1 -1
  193. package/dist/core/export-html/tool-renderer.js.map +1 -1
  194. package/dist/core/extensions/agent-events.d.ts +2 -2
  195. package/dist/core/extensions/agent-events.d.ts.map +1 -1
  196. package/dist/core/extensions/agent-events.js.map +1 -1
  197. package/dist/core/extensions/api-types.d.ts +2 -2
  198. package/dist/core/extensions/api-types.d.ts.map +1 -1
  199. package/dist/core/extensions/api-types.js.map +1 -1
  200. package/dist/core/extensions/context-types.d.ts +1 -7
  201. package/dist/core/extensions/context-types.d.ts.map +1 -1
  202. package/dist/core/extensions/context-types.js.map +1 -1
  203. package/dist/core/extensions/event-results.d.ts +1 -1
  204. package/dist/core/extensions/event-results.d.ts.map +1 -1
  205. package/dist/core/extensions/event-results.js.map +1 -1
  206. package/dist/core/extensions/index.d.ts +1 -1
  207. package/dist/core/extensions/index.d.ts.map +1 -1
  208. package/dist/core/extensions/index.js.map +1 -1
  209. package/dist/core/extensions/loader-api.js.map +1 -1
  210. package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
  211. package/dist/core/extensions/loader-virtual-modules.js +21 -9
  212. package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
  213. package/dist/core/extensions/provider-types.d.ts +2 -2
  214. package/dist/core/extensions/provider-types.d.ts.map +1 -1
  215. package/dist/core/extensions/provider-types.js.map +1 -1
  216. package/dist/core/extensions/reactive-widget.d.ts +6 -0
  217. package/dist/core/extensions/reactive-widget.d.ts.map +1 -1
  218. package/dist/core/extensions/reactive-widget.js +62 -6
  219. package/dist/core/extensions/reactive-widget.js.map +1 -1
  220. package/dist/core/extensions/runner-context.d.ts +1 -1
  221. package/dist/core/extensions/runner-context.d.ts.map +1 -1
  222. package/dist/core/extensions/runner-context.js.map +1 -1
  223. package/dist/core/extensions/runner-events.d.ts +1 -1
  224. package/dist/core/extensions/runner-events.d.ts.map +1 -1
  225. package/dist/core/extensions/runner-events.js.map +1 -1
  226. package/dist/core/extensions/runner.d.ts +2 -2
  227. package/dist/core/extensions/runner.d.ts.map +1 -1
  228. package/dist/core/extensions/runner.js.map +1 -1
  229. package/dist/core/extensions/runtime-types.d.ts +2 -2
  230. package/dist/core/extensions/runtime-types.d.ts.map +1 -1
  231. package/dist/core/extensions/runtime-types.js.map +1 -1
  232. package/dist/core/extensions/tool-events.d.ts +1 -1
  233. package/dist/core/extensions/tool-events.d.ts.map +1 -1
  234. package/dist/core/extensions/tool-events.js.map +1 -1
  235. package/dist/core/extensions/tool-types.d.ts +2 -2
  236. package/dist/core/extensions/tool-types.d.ts.map +1 -1
  237. package/dist/core/extensions/tool-types.js.map +1 -1
  238. package/dist/core/extensions/ui-types.d.ts +2 -0
  239. package/dist/core/extensions/ui-types.d.ts.map +1 -1
  240. package/dist/core/extensions/ui-types.js.map +1 -1
  241. package/dist/core/fallback-models.d.ts +1 -1
  242. package/dist/core/fallback-models.d.ts.map +1 -1
  243. package/dist/core/fallback-models.js.map +1 -1
  244. package/dist/core/http-dispatcher.d.ts.map +1 -1
  245. package/dist/core/http-dispatcher.js +14 -0
  246. package/dist/core/http-dispatcher.js.map +1 -1
  247. package/dist/core/messages.d.ts +1 -1
  248. package/dist/core/messages.d.ts.map +1 -1
  249. package/dist/core/messages.js.map +1 -1
  250. package/dist/core/model-capabilities.d.ts +1 -1
  251. package/dist/core/model-capabilities.d.ts.map +1 -1
  252. package/dist/core/model-capabilities.js.map +1 -1
  253. package/dist/core/model-fallback-failures.d.ts.map +1 -1
  254. package/dist/core/model-fallback-failures.js +18 -1
  255. package/dist/core/model-fallback-failures.js.map +1 -1
  256. package/dist/core/model-registry.d.ts +1 -1
  257. package/dist/core/model-registry.d.ts.map +1 -1
  258. package/dist/core/model-registry.js.map +1 -1
  259. package/dist/core/model-resolver-cli.js.map +1 -1
  260. package/dist/core/model-resolver-defaults.d.ts +1 -1
  261. package/dist/core/model-resolver-defaults.d.ts.map +1 -1
  262. package/dist/core/model-resolver-defaults.js +1 -1
  263. package/dist/core/model-resolver-defaults.js.map +1 -1
  264. package/dist/core/model-resolver-initial.d.ts +1 -1
  265. package/dist/core/model-resolver-initial.d.ts.map +1 -1
  266. package/dist/core/model-resolver-initial.js.map +1 -1
  267. package/dist/core/model-resolver-patterns.d.ts +1 -1
  268. package/dist/core/model-resolver-patterns.d.ts.map +1 -1
  269. package/dist/core/model-resolver-patterns.js.map +1 -1
  270. package/dist/core/model-resolver-scope.d.ts +1 -1
  271. package/dist/core/model-resolver-scope.d.ts.map +1 -1
  272. package/dist/core/model-resolver-scope.js +1 -1
  273. package/dist/core/model-resolver-scope.js.map +1 -1
  274. package/dist/core/model-resolver-types.d.ts +1 -1
  275. package/dist/core/model-resolver-types.d.ts.map +1 -1
  276. package/dist/core/model-resolver-types.js.map +1 -1
  277. package/dist/core/model-runtime-auth.d.ts +1 -1
  278. package/dist/core/model-runtime-auth.d.ts.map +1 -1
  279. package/dist/core/model-runtime-auth.js.map +1 -1
  280. package/dist/core/model-runtime-providers.d.ts +2 -2
  281. package/dist/core/model-runtime-providers.d.ts.map +1 -1
  282. package/dist/core/model-runtime-providers.js +2 -2
  283. package/dist/core/model-runtime-providers.js.map +1 -1
  284. package/dist/core/model-runtime-restoration.d.ts +1 -1
  285. package/dist/core/model-runtime-restoration.d.ts.map +1 -1
  286. package/dist/core/model-runtime-restoration.js.map +1 -1
  287. package/dist/core/model-runtime-snapshot.d.ts +1 -1
  288. package/dist/core/model-runtime-snapshot.d.ts.map +1 -1
  289. package/dist/core/model-runtime-snapshot.js.map +1 -1
  290. package/dist/core/model-runtime-streaming.d.ts +1 -1
  291. package/dist/core/model-runtime-streaming.d.ts.map +1 -1
  292. package/dist/core/model-runtime-streaming.js +1 -1
  293. package/dist/core/model-runtime-streaming.js.map +1 -1
  294. package/dist/core/model-runtime-types.d.ts +1 -1
  295. package/dist/core/model-runtime-types.d.ts.map +1 -1
  296. package/dist/core/model-runtime-types.js.map +1 -1
  297. package/dist/core/model-runtime.d.ts +8 -1
  298. package/dist/core/model-runtime.d.ts.map +1 -1
  299. package/dist/core/model-runtime.js +15 -3
  300. package/dist/core/model-runtime.js.map +1 -1
  301. package/dist/core/models-store.d.ts +1 -1
  302. package/dist/core/models-store.d.ts.map +1 -1
  303. package/dist/core/models-store.js.map +1 -1
  304. package/dist/core/oauth-login.d.ts +1 -1
  305. package/dist/core/oauth-login.d.ts.map +1 -1
  306. package/dist/core/oauth-login.js.map +1 -1
  307. package/dist/core/oauth-provider-metadata.d.ts +1 -1
  308. package/dist/core/oauth-provider-metadata.d.ts.map +1 -1
  309. package/dist/core/oauth-provider-metadata.js.map +1 -1
  310. package/dist/core/openai-responses-payload-sanitizer.d.ts +1 -1
  311. package/dist/core/openai-responses-payload-sanitizer.d.ts.map +1 -1
  312. package/dist/core/openai-responses-payload-sanitizer.js.map +1 -1
  313. package/dist/core/provider-attribution.d.ts +1 -1
  314. package/dist/core/provider-attribution.d.ts.map +1 -1
  315. package/dist/core/provider-attribution.js.map +1 -1
  316. package/dist/core/provider-composer-internal.d.ts +1 -1
  317. package/dist/core/provider-composer-internal.d.ts.map +1 -1
  318. package/dist/core/provider-composer-internal.js.map +1 -1
  319. package/dist/core/provider-composer.d.ts +1 -1
  320. package/dist/core/provider-composer.d.ts.map +1 -1
  321. package/dist/core/provider-composer.js +2 -2
  322. package/dist/core/provider-composer.js.map +1 -1
  323. package/dist/core/provider-context-usage.d.ts.map +1 -1
  324. package/dist/core/provider-context-usage.js.map +1 -1
  325. package/dist/core/remote-catalog-provider.d.ts +1 -1
  326. package/dist/core/remote-catalog-provider.d.ts.map +1 -1
  327. package/dist/core/remote-catalog-provider.js.map +1 -1
  328. package/dist/core/runtime-credentials.d.ts +1 -1
  329. package/dist/core/runtime-credentials.d.ts.map +1 -1
  330. package/dist/core/runtime-credentials.js.map +1 -1
  331. package/dist/core/sdk-types.d.ts +1 -1
  332. package/dist/core/sdk-types.d.ts.map +1 -1
  333. package/dist/core/sdk-types.js.map +1 -1
  334. package/dist/core/sdk.d.ts +1 -1
  335. package/dist/core/sdk.d.ts.map +1 -1
  336. package/dist/core/sdk.js +30 -6
  337. package/dist/core/sdk.js.map +1 -1
  338. package/dist/core/session-manager-core.d.ts +2 -2
  339. package/dist/core/session-manager-core.d.ts.map +1 -1
  340. package/dist/core/session-manager-core.js.map +1 -1
  341. package/dist/core/session-manager-entries.d.ts +1 -1
  342. package/dist/core/session-manager-entries.d.ts.map +1 -1
  343. package/dist/core/session-manager-entries.js.map +1 -1
  344. package/dist/core/session-manager-list.js.map +1 -1
  345. package/dist/core/session-manager-types.d.ts +1 -1
  346. package/dist/core/session-manager-types.d.ts.map +1 -1
  347. package/dist/core/session-manager-types.js.map +1 -1
  348. package/dist/core/session-manager-validation.js +1 -1
  349. package/dist/core/session-manager-validation.js.map +1 -1
  350. package/dist/core/settings-manager-basic-accessors.d.ts +1 -0
  351. package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
  352. package/dist/core/settings-manager-basic-accessors.js +11 -0
  353. package/dist/core/settings-manager-basic-accessors.js.map +1 -1
  354. package/dist/core/settings-types.d.ts +2 -1
  355. package/dist/core/settings-types.d.ts.map +1 -1
  356. package/dist/core/settings-types.js.map +1 -1
  357. package/dist/core/summarization-retry.d.ts +1 -1
  358. package/dist/core/summarization-retry.d.ts.map +1 -1
  359. package/dist/core/summarization-retry.js.map +1 -1
  360. package/dist/core/tools/bash-session-environment.d.ts +1 -1
  361. package/dist/core/tools/bash-session-environment.d.ts.map +1 -1
  362. package/dist/core/tools/bash-session-environment.js.map +1 -1
  363. package/dist/core/tools/oversized-tool-result.d.ts +1 -1
  364. package/dist/core/tools/oversized-tool-result.d.ts.map +1 -1
  365. package/dist/core/tools/oversized-tool-result.js.map +1 -1
  366. package/dist/core/tools/read-url.d.ts +1 -1
  367. package/dist/core/tools/read-url.d.ts.map +1 -1
  368. package/dist/core/tools/read-url.js.map +1 -1
  369. package/dist/core/tools/read.d.ts.map +1 -1
  370. package/dist/core/tools/read.js.map +1 -1
  371. package/dist/core/tools/render-utils.d.ts +1 -1
  372. package/dist/core/tools/render-utils.d.ts.map +1 -1
  373. package/dist/core/tools/render-utils.js.map +1 -1
  374. package/dist/core/tools/resource-selectors.d.ts +1 -1
  375. package/dist/core/tools/resource-selectors.d.ts.map +1 -1
  376. package/dist/core/tools/resource-selectors.js +2 -7
  377. package/dist/core/tools/resource-selectors.js.map +1 -1
  378. package/dist/core/typebox-compat.js +1 -1
  379. package/dist/core/typebox-compat.js.map +1 -1
  380. package/dist/core/usage-totals.d.ts +1 -1
  381. package/dist/core/usage-totals.d.ts.map +1 -1
  382. package/dist/core/usage-totals.js.map +1 -1
  383. package/dist/extensions/llama/provider.d.ts +1 -1
  384. package/dist/extensions/llama/provider.d.ts.map +1 -1
  385. package/dist/extensions/llama/provider.js +1 -1
  386. package/dist/extensions/llama/provider.js.map +1 -1
  387. package/dist/main-app-mode.d.ts +1 -1
  388. package/dist/main-app-mode.d.ts.map +1 -1
  389. package/dist/main-app-mode.js.map +1 -1
  390. package/dist/main-session-options.js +1 -1
  391. package/dist/main-session-options.js.map +1 -1
  392. package/dist/modes/interactive/components/assistant-message.d.ts +1 -1
  393. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  394. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  395. package/dist/modes/interactive/components/chat-message-renderer.d.ts +1 -1
  396. package/dist/modes/interactive/components/chat-message-renderer.d.ts.map +1 -1
  397. package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
  398. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  399. package/dist/modes/interactive/components/login-dialog.d.ts +1 -1
  400. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  401. package/dist/modes/interactive/components/login-dialog.js.map +1 -1
  402. package/dist/modes/interactive/components/model-selector.d.ts +1 -1
  403. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  404. package/dist/modes/interactive/components/model-selector.js +1 -1
  405. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  406. package/dist/modes/interactive/components/scoped-models-selector.d.ts +1 -1
  407. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
  408. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
  409. package/dist/modes/interactive/components/settings-selector-handlers.js.map +1 -1
  410. package/dist/modes/interactive/components/settings-selector-types.d.ts +1 -1
  411. package/dist/modes/interactive/components/settings-selector-types.d.ts.map +1 -1
  412. package/dist/modes/interactive/components/settings-selector-types.js.map +1 -1
  413. package/dist/modes/interactive/interactive-auth-routing.js +1 -1
  414. package/dist/modes/interactive/interactive-auth-routing.js.map +1 -1
  415. package/dist/modes/interactive/interactive-deferred-startup.js +1 -1
  416. package/dist/modes/interactive/interactive-deferred-startup.js.map +1 -1
  417. package/dist/modes/interactive/interactive-extension-context.js +26 -0
  418. package/dist/modes/interactive/interactive-extension-context.js.map +1 -1
  419. package/dist/modes/interactive/interactive-extension-runtime.js +7 -2
  420. package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
  421. package/dist/modes/interactive/interactive-mode-base.d.ts +1 -0
  422. package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
  423. package/dist/modes/interactive/interactive-mode-base.js +1 -0
  424. package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
  425. package/dist/modes/interactive/interactive-mode-deps.d.ts +1 -1
  426. package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
  427. package/dist/modes/interactive/interactive-mode-deps.js +1 -1
  428. package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
  429. package/dist/modes/interactive/interactive-mode-helpers.js +1 -1
  430. package/dist/modes/interactive/interactive-mode-helpers.js.map +1 -1
  431. package/dist/modes/interactive/interactive-mode-surface.d.ts +2 -0
  432. package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
  433. package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
  434. package/dist/modes/interactive/model-catalog-refresh.d.ts +1 -1
  435. package/dist/modes/interactive/model-catalog-refresh.d.ts.map +1 -1
  436. package/dist/modes/interactive/model-catalog-refresh.js.map +1 -1
  437. package/dist/modes/interactive/streaming-assistant-message.d.ts +1 -1
  438. package/dist/modes/interactive/streaming-assistant-message.d.ts.map +1 -1
  439. package/dist/modes/interactive/streaming-assistant-message.js.map +1 -1
  440. package/dist/modes/interactive-engine/engine-custom-ui.d.ts +3 -0
  441. package/dist/modes/interactive-engine/engine-custom-ui.d.ts.map +1 -1
  442. package/dist/modes/interactive-engine/engine-custom-ui.js +26 -3
  443. package/dist/modes/interactive-engine/engine-custom-ui.js.map +1 -1
  444. package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
  445. package/dist/modes/interactive-engine/remote-component.d.ts +2 -1
  446. package/dist/modes/interactive-engine/remote-component.d.ts.map +1 -1
  447. package/dist/modes/interactive-engine/remote-component.js +14 -0
  448. package/dist/modes/interactive-engine/remote-component.js.map +1 -1
  449. package/dist/modes/interactive-engine/remote-model-catalog.js.map +1 -1
  450. package/dist/modes/json-event.d.ts +1 -1
  451. package/dist/modes/json-event.d.ts.map +1 -1
  452. package/dist/modes/json-event.js.map +1 -1
  453. package/dist/modes/print-mode.d.ts +1 -1
  454. package/dist/modes/print-mode.d.ts.map +1 -1
  455. package/dist/modes/print-mode.js.map +1 -1
  456. package/dist/modes/rpc/rpc-client-api.d.ts +2 -2
  457. package/dist/modes/rpc/rpc-client-api.d.ts.map +1 -1
  458. package/dist/modes/rpc/rpc-client-api.js.map +1 -1
  459. package/dist/modes/rpc/rpc-client.d.ts +1 -1
  460. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  461. package/dist/modes/rpc/rpc-client.js.map +1 -1
  462. package/dist/modes/rpc/rpc-extension-ui.d.ts.map +1 -1
  463. package/dist/modes/rpc/rpc-extension-ui.js +4 -1
  464. package/dist/modes/rpc/rpc-extension-ui.js.map +1 -1
  465. package/dist/modes/rpc/rpc-provider-auth.d.ts +1 -1
  466. package/dist/modes/rpc/rpc-provider-auth.d.ts.map +1 -1
  467. package/dist/modes/rpc/rpc-provider-auth.js.map +1 -1
  468. package/dist/modes/rpc/rpc-types.d.ts +2 -2
  469. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  470. package/dist/modes/rpc/rpc-types.js.map +1 -1
  471. package/dist/utils/tool-result-images.d.ts +1 -1
  472. package/dist/utils/tool-result-images.d.ts.map +1 -1
  473. package/dist/utils/tool-result-images.js.map +1 -1
  474. package/docs/custom-provider.md +11 -8
  475. package/docs/development.md +0 -2
  476. package/docs/extensions.md +2 -2
  477. package/docs/json.md +1 -1
  478. package/docs/models/artificial-analysis-index.md +2 -2
  479. package/docs/models/model-selection.md +8 -8
  480. package/docs/models/pareto-efficiency.md +10 -10
  481. package/docs/models.md +9 -3
  482. package/docs/packages.md +1 -1
  483. package/docs/providers.md +5 -3
  484. package/docs/quickstart.md +1 -1
  485. package/docs/rpc.md +1 -1
  486. package/docs/sdk.md +2 -2
  487. package/docs/session-format.md +2 -2
  488. package/docs/settings.md +2 -1
  489. package/docs/subagents.md +5 -6
  490. package/docs/tui.md +3 -0
  491. package/docs/workflows.md +3 -1
  492. package/examples/extensions/README.md +1 -1
  493. package/examples/extensions/custom-footer.ts +1 -1
  494. package/examples/extensions/custom-provider-anthropic/index.ts +1 -1
  495. package/examples/extensions/custom-provider-gitlab-duo/index.ts +1 -1
  496. package/examples/extensions/custom-provider-gitlab-duo/test.ts +1 -1
  497. package/examples/extensions/handoff.ts +2 -2
  498. package/examples/extensions/hello.ts +1 -1
  499. package/examples/extensions/plan-mode/index.ts +1 -1
  500. package/examples/extensions/preset.ts +1 -1
  501. package/examples/extensions/qna.ts +1 -1
  502. package/examples/extensions/subagent/display.ts +1 -1
  503. package/examples/extensions/subagent/runner.ts +1 -1
  504. package/examples/extensions/subagent/types.ts +1 -1
  505. package/examples/extensions/summarize.ts +2 -2
  506. package/examples/extensions/tool-override.ts +1 -1
  507. package/examples/sdk/02-custom-model.ts +1 -1
  508. package/examples/sdk/12-full-control.ts +1 -1
  509. package/examples/sdk/README.md +1 -1
  510. package/npm-shrinkwrap.json +54 -31
  511. package/package.json +3 -3
  512. package/dist/builtin/subagents/src/extension/fanout-child.ts +0 -259
  513. package/dist/builtin/subagents/src/runs/inprocess/nested-routing.ts +0 -218
  514. package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-api.ts +0 -55
  515. package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-control.ts +0 -178
  516. package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-core.ts +0 -187
  517. package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-paths.ts +0 -57
  518. package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-projection.ts +0 -42
  519. package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-registry.ts +0 -352
  520. package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-rendering.ts +0 -136
  521. package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-sanitize.ts +0 -252
  522. package/dist/builtin/subagents/src/shared/types-nested.ts +0 -127
  523. package/dist/core/copilot-env-routing.d.ts +0 -36
  524. package/dist/core/copilot-env-routing.d.ts.map +0 -1
  525. package/dist/core/copilot-env-routing.js +0 -94
  526. package/dist/core/copilot-env-routing.js.map +0 -1
@@ -1,7 +1,6 @@
1
1
  import { type ExtensionAPI, isStaleExtensionContextError } from "@bastani/atomic";
2
2
  import { type IntercomBridgeState, resolveSubagentIntercomTarget } from "../../intercom/intercom-bridge.js";
3
3
  import {
4
- attachNestedChildrenToResultChildren,
5
4
  buildSubagentResultIntercomPayload,
6
5
  deliverSubagentResultIntercomEvent,
7
6
  formatSubagentResultReceipt,
@@ -11,7 +10,6 @@ import {
11
10
  import {
12
11
  type ControlEvent,
13
12
  type Details,
14
- type NestedRunSummary,
15
13
  type SingleResult,
16
14
  SUBAGENT_CONTROL_EVENT,
17
15
  SUBAGENT_CONTROL_INTERCOM_EVENT,
@@ -20,8 +18,6 @@ import {
20
18
  type SubagentToolResult,
21
19
  } from "../../shared/types.js";
22
20
  import { compactForegroundDetails, compactForegroundResult, getSingleResultOutput } from "../../shared/utils.js";
23
- import { updateForegroundNestedProjection } from "../inprocess/runtime-support/nested-api.js";
24
- import { formatNestedRunStatusLines } from "../inprocess/runtime-support/nested-rendering.js";
25
21
  import {
26
22
  formatControlIntercomMessage,
27
23
  formatControlNoticeMessage,
@@ -68,12 +64,6 @@ function formatForegroundActivity(control: ForegroundControl): string | undefine
68
64
  }
69
65
 
70
66
  export function foregroundStatusResult(control: ForegroundControl): SubagentToolResult {
71
- let nestedWarning: string | undefined;
72
- try {
73
- updateForegroundNestedProjection(control);
74
- } catch (error) {
75
- nestedWarning = `Nested status unavailable: ${error instanceof Error ? error.message : String(error)}`;
76
- }
77
67
  const activity = formatForegroundActivity(control);
78
68
  const lines = [
79
69
  `Run: ${control.runId}`,
@@ -84,8 +74,6 @@ export function foregroundStatusResult(control: ForegroundControl): SubagentTool
84
74
  : undefined,
85
75
  activity ? `Activity: ${activity}` : undefined,
86
76
  ].filter((line): line is string => Boolean(line));
87
- lines.push(...formatNestedRunStatusLines(control.nestedChildren, { indent: "", commandHints: true, maxLines: 20 }));
88
- if (nestedWarning) lines.push(`Warning: ${nestedWarning}`);
89
77
  return { content: [{ type: "text", text: lines.join("\n") }], details: { mode: "management", results: [] } };
90
78
  }
91
79
 
@@ -132,8 +120,6 @@ export function rememberForegroundRun(
132
120
  mode: "single" | "parallel";
133
121
  cwd: string;
134
122
  results: SingleResult[];
135
- /** Effective delegation limit per child, aligned with `results` by index. */
136
- maxSubagentDepths?: readonly (number | undefined)[];
137
123
  },
138
124
  ): void {
139
125
  state.foregroundRuns ??= new Map();
@@ -144,7 +130,6 @@ export function rememberForegroundRun(
144
130
  updatedAt: Date.now(),
145
131
  children: input.results.map((originalResult, index) => {
146
132
  const result = takeEarlyDetachedResult(state, input.runId, index) ?? originalResult;
147
- const maxSubagentDepth = input.maxSubagentDepths?.[index];
148
133
  return {
149
134
  agent: result.agent,
150
135
  index,
@@ -154,7 +139,6 @@ export function rememberForegroundRun(
154
139
  detached: result.detached,
155
140
  }),
156
141
  ...(result.sessionFile ? { sessionFile: result.sessionFile } : {}),
157
- ...(maxSubagentDepth === undefined ? {} : { maxSubagentDepth }),
158
142
  result,
159
143
  };
160
144
  }),
@@ -323,7 +307,6 @@ async function emitForegroundResultIntercom(input: {
323
307
  runId: string;
324
308
  mode: SubagentRunMode;
325
309
  results: SingleResult[];
326
- nestedChildren?: NestedRunSummary[];
327
310
  }): Promise<ReturnType<typeof buildSubagentResultIntercomPayload> | null> {
328
311
  if (!input.intercomBridge.active || !input.intercomBridge.orchestratorTarget) return null;
329
312
  const children = input.results.flatMap((result, index) =>
@@ -350,7 +333,7 @@ async function emitForegroundResultIntercom(input: {
350
333
  to: input.intercomBridge.orchestratorTarget,
351
334
  runId: input.runId,
352
335
  mode: input.mode,
353
- children: attachNestedChildrenToResultChildren(input.runId, children, input.nestedChildren),
336
+ children,
354
337
  });
355
338
  const delivered = await deliverSubagentResultIntercomEvent(input.pi.events, payload);
356
339
  if (!delivered) return null;
@@ -363,7 +346,6 @@ export async function maybeBuildForegroundIntercomReceipt(input: {
363
346
  runId: string;
364
347
  mode: SubagentRunMode;
365
348
  details: Details;
366
- nestedChildren?: NestedRunSummary[];
367
349
  }): Promise<{ text: string; details: Details } | null> {
368
350
  const payload = await emitForegroundResultIntercom({
369
351
  pi: input.pi,
@@ -371,7 +353,6 @@ export async function maybeBuildForegroundIntercomReceipt(input: {
371
353
  runId: input.runId,
372
354
  mode: input.mode,
373
355
  results: input.details.results,
374
- ...(input.nestedChildren?.length ? { nestedChildren: input.nestedChildren } : {}),
375
356
  });
376
357
  if (!payload) return null;
377
358
  return {
@@ -6,7 +6,6 @@ import type {
6
6
  ArtifactConfig,
7
7
  ControlConfig,
8
8
  MaxOutputConfig,
9
- NestedRouteInfo,
10
9
  ResolvedControlConfig,
11
10
  SUBAGENT_ACTIONS,
12
11
  SubagentState,
@@ -105,7 +104,6 @@ export interface ExecutionContextData {
105
104
  parentDepth?: number;
106
105
  controlConfig: ResolvedControlConfig;
107
106
  intercomBridge: IntercomBridgeState;
108
- nestedRoute?: NestedRouteInfo;
109
107
  }
110
108
 
111
109
  export interface PreparedExecutionContext {
@@ -117,10 +115,6 @@ export interface PreparedExecutionContext {
117
115
  foregroundMode: "single" | "parallel";
118
116
  execData: ExecutionContextData;
119
117
  foregroundControl?: SubagentState["foregroundControls"] extends Map<string, infer T> ? T : never;
120
- writeNestedForegroundEvent: (
121
- type: "subagent.nested.started" | "subagent.nested.completed",
122
- result?: SubagentToolResult,
123
- ) => void;
124
118
  }
125
119
 
126
120
  export interface ExecutionContextBuildResult {
@@ -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;