@bastani/atomic 0.9.20-alpha.5 → 0.9.20-alpha.7

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 (374) hide show
  1. package/CHANGELOG.md +73 -0
  2. package/README.md +37 -0
  3. package/dist/builtin/intercom/CHANGELOG.md +10 -0
  4. package/dist/builtin/intercom/broker/broker.ts +110 -39
  5. package/dist/builtin/intercom/broker/client.ts +8 -1
  6. package/dist/builtin/intercom/index.bundle.mjs +61 -2
  7. package/dist/builtin/intercom/live-route-refusal.ts +69 -0
  8. package/dist/builtin/intercom/package.json +2 -2
  9. package/dist/builtin/intercom/recoverable-disconnect.ts +16 -4
  10. package/dist/builtin/intercom/skills/intercom/SKILL.md +11 -11
  11. package/dist/builtin/intercom/types.ts +3 -1
  12. package/dist/builtin/mcp/package.json +2 -2
  13. package/dist/builtin/subagents/CHANGELOG.md +12 -0
  14. package/dist/builtin/subagents/package.json +3 -3
  15. package/dist/builtin/subagents/skills/cua-driver/BROWSER.md +494 -0
  16. package/dist/builtin/subagents/skills/cua-driver/EMBEDDING.md +578 -0
  17. package/dist/builtin/subagents/skills/cua-driver/LINUX.md +364 -0
  18. package/dist/builtin/subagents/skills/cua-driver/MACOS.md +509 -0
  19. package/dist/builtin/subagents/skills/cua-driver/README.md +113 -0
  20. package/dist/builtin/subagents/skills/cua-driver/RECORDING.md +162 -0
  21. package/dist/builtin/subagents/skills/cua-driver/SKILL.md +1105 -0
  22. package/dist/builtin/subagents/skills/cua-driver/WINDOWS.md +866 -0
  23. package/dist/builtin/subagents/src/extension/index.bundle.mjs +18 -8
  24. package/dist/builtin/web-access/package.json +2 -2
  25. package/dist/builtin/workflows/CHANGELOG.md +34 -0
  26. package/dist/builtin/workflows/README.md +5 -19
  27. package/dist/builtin/workflows/builtin/adversarial-verification.js +3 -3
  28. package/dist/builtin/workflows/builtin/{chunk-7f381xnq.js → chunk-2hzrv5y8.js} +140 -21
  29. package/dist/builtin/workflows/builtin/{chunk-e83tc6nr.js → chunk-3tx8ry44.js} +3 -2
  30. package/dist/builtin/workflows/builtin/{chunk-00ywx588.js → chunk-5724b0cf.js} +1 -1
  31. package/dist/builtin/workflows/builtin/{chunk-zj5162bh.js → chunk-7bzcersz.js} +33 -22
  32. package/dist/builtin/workflows/builtin/{chunk-ne6vh5ct.js → chunk-7n51c5gh.js} +1 -1
  33. package/dist/builtin/workflows/builtin/{chunk-x2nftpgj.js → chunk-9z3ztr2a.js} +1 -1
  34. package/dist/builtin/workflows/builtin/{chunk-7h7s5xdj.js → chunk-dxjxtgmp.js} +1 -1
  35. package/dist/builtin/workflows/builtin/{chunk-tvcydq13.js → chunk-ffdrv23t.js} +1 -1
  36. package/dist/builtin/workflows/builtin/{chunk-pfm1kgqz.js → chunk-hmt5w62g.js} +12 -4
  37. package/dist/builtin/workflows/builtin/{chunk-tdqvdrg1.js → chunk-jngsbbpm.js} +3 -3
  38. package/dist/builtin/workflows/builtin/{chunk-55p5dxjk.js → chunk-njmf5ze7.js} +1 -1
  39. package/dist/builtin/workflows/builtin/{chunk-evfb0312.js → chunk-vn0wb31x.js} +1 -1
  40. package/dist/builtin/workflows/builtin/classify-and-act.js +3 -3
  41. package/dist/builtin/workflows/builtin/fan-out-and-synthesize.js +3 -3
  42. package/dist/builtin/workflows/builtin/generate-and-filter.js +3 -3
  43. package/dist/builtin/workflows/builtin/goal.js +4 -4
  44. package/dist/builtin/workflows/builtin/index.js +12 -12
  45. package/dist/builtin/workflows/builtin/loop-until-done.js +3 -3
  46. package/dist/builtin/workflows/builtin/open-claude-design.js +3 -3
  47. package/dist/builtin/workflows/builtin/ralph.js +4 -4
  48. package/dist/builtin/workflows/builtin/steering-context.js +1 -1
  49. package/dist/builtin/workflows/builtin/tournament.js +3 -3
  50. package/dist/builtin/workflows/package.json +2 -2
  51. package/dist/builtin/workflows/skills/prompt-engineer/SKILL.md +10 -9
  52. package/dist/builtin/workflows/skills/prompt-engineer/references/advanced_patterns.md +4 -4
  53. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_fable_5.md +96 -23
  54. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_fable_5_1.md +75 -27
  55. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_opus_4_8.md +72 -26
  56. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_opus_5.md +58 -22
  57. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_opus_5_5.md +118 -0
  58. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_sonnet_5.md +70 -29
  59. package/dist/builtin/workflows/skills/prompt-engineer/references/core_prompting.md +1 -1
  60. package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_5_5.md +95 -32
  61. package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_5_6.md +79 -30
  62. package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6.md +139 -0
  63. package/dist/builtin/workflows/skills/prompt-engineer/references/quality_improvement.md +4 -4
  64. package/dist/builtin/workflows/src/extension/index.bundle.mjs +446 -639
  65. package/dist/builtin/workflows/src/index.js +1434 -1277
  66. package/dist/cli/args.d.ts.map +1 -1
  67. package/dist/cli/args.js +15 -4
  68. package/dist/cli/args.js.map +1 -1
  69. package/dist/cli/file-processor.d.ts +1 -1
  70. package/dist/cli/file-processor.d.ts.map +1 -1
  71. package/dist/cli/file-processor.js.map +1 -1
  72. package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
  73. package/dist/core/agent-session-auto-compaction.js +40 -12
  74. package/dist/core/agent-session-auto-compaction.js.map +1 -1
  75. package/dist/core/agent-session-bash.d.ts.map +1 -1
  76. package/dist/core/agent-session-bash.js +9 -8
  77. package/dist/core/agent-session-bash.js.map +1 -1
  78. package/dist/core/agent-session-boundaries.d.ts +68 -0
  79. package/dist/core/agent-session-boundaries.d.ts.map +1 -0
  80. package/dist/core/agent-session-boundaries.js +334 -0
  81. package/dist/core/agent-session-boundaries.js.map +1 -0
  82. package/dist/core/agent-session-compaction.js +1 -1
  83. package/dist/core/agent-session-compaction.js.map +1 -1
  84. package/dist/core/agent-session-events.d.ts.map +1 -1
  85. package/dist/core/agent-session-events.js +27 -13
  86. package/dist/core/agent-session-events.js.map +1 -1
  87. package/dist/core/agent-session-export.d.ts.map +1 -1
  88. package/dist/core/agent-session-export.js +16 -20
  89. package/dist/core/agent-session-export.js.map +1 -1
  90. package/dist/core/agent-session-message-queue.d.ts.map +1 -1
  91. package/dist/core/agent-session-message-queue.js +6 -3
  92. package/dist/core/agent-session-message-queue.js.map +1 -1
  93. package/dist/core/agent-session-methods.d.ts +33 -4
  94. package/dist/core/agent-session-methods.d.ts.map +1 -1
  95. package/dist/core/agent-session-methods.js.map +1 -1
  96. package/dist/core/agent-session-persistent-custom-messages.d.ts.map +1 -1
  97. package/dist/core/agent-session-persistent-custom-messages.js +2 -1
  98. package/dist/core/agent-session-persistent-custom-messages.js.map +1 -1
  99. package/dist/core/agent-session-prompt.d.ts.map +1 -1
  100. package/dist/core/agent-session-prompt.js +93 -25
  101. package/dist/core/agent-session-prompt.js.map +1 -1
  102. package/dist/core/agent-session-retry.d.ts.map +1 -1
  103. package/dist/core/agent-session-retry.js +4 -9
  104. package/dist/core/agent-session-retry.js.map +1 -1
  105. package/dist/core/agent-session-runtime.d.ts +4 -0
  106. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  107. package/dist/core/agent-session-runtime.js +7 -1
  108. package/dist/core/agent-session-runtime.js.map +1 -1
  109. package/dist/core/agent-session-tasks.d.ts +9 -0
  110. package/dist/core/agent-session-tasks.d.ts.map +1 -1
  111. package/dist/core/agent-session-tasks.js +68 -16
  112. package/dist/core/agent-session-tasks.js.map +1 -1
  113. package/dist/core/agent-session-tool-hooks.d.ts.map +1 -1
  114. package/dist/core/agent-session-tool-hooks.js +15 -5
  115. package/dist/core/agent-session-tool-hooks.js.map +1 -1
  116. package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
  117. package/dist/core/agent-session-tool-registry.js +9 -21
  118. package/dist/core/agent-session-tool-registry.js.map +1 -1
  119. package/dist/core/agent-session-tree.d.ts.map +1 -1
  120. package/dist/core/agent-session-tree.js +2 -3
  121. package/dist/core/agent-session-tree.js.map +1 -1
  122. package/dist/core/agent-session-types.d.ts +8 -0
  123. package/dist/core/agent-session-types.d.ts.map +1 -1
  124. package/dist/core/agent-session-types.js.map +1 -1
  125. package/dist/core/agent-session.d.ts +18 -2
  126. package/dist/core/agent-session.d.ts.map +1 -1
  127. package/dist/core/agent-session.js +22 -3
  128. package/dist/core/agent-session.js.map +1 -1
  129. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  130. package/dist/core/compaction/branch-summarization.js +1 -0
  131. package/dist/core/compaction/branch-summarization.js.map +1 -1
  132. package/dist/core/compaction/compaction-boundary.d.ts.map +1 -1
  133. package/dist/core/compaction/compaction-boundary.js +11 -6
  134. package/dist/core/compaction/compaction-boundary.js.map +1 -1
  135. package/dist/core/compaction/compaction.d.ts +3 -1
  136. package/dist/core/compaction/compaction.d.ts.map +1 -1
  137. package/dist/core/compaction/compaction.js +37 -0
  138. package/dist/core/compaction/compaction.js.map +1 -1
  139. package/dist/core/crash-log.d.ts +6 -0
  140. package/dist/core/crash-log.d.ts.map +1 -0
  141. package/dist/core/crash-log.js +69 -0
  142. package/dist/core/crash-log.js.map +1 -0
  143. package/dist/core/execution-model-router.d.ts +15 -0
  144. package/dist/core/execution-model-router.d.ts.map +1 -1
  145. package/dist/core/execution-model-router.js +82 -33
  146. package/dist/core/execution-model-router.js.map +1 -1
  147. package/dist/core/export-html/template-js/tree-filter-render.js +6 -1
  148. package/dist/core/export-html/template.js +6 -1
  149. package/dist/core/extensions/agent-events.d.ts +69 -3
  150. package/dist/core/extensions/agent-events.d.ts.map +1 -1
  151. package/dist/core/extensions/agent-events.js.map +1 -1
  152. package/dist/core/extensions/api-types.d.ts +5 -3
  153. package/dist/core/extensions/api-types.d.ts.map +1 -1
  154. package/dist/core/extensions/api-types.js.map +1 -1
  155. package/dist/core/extensions/event-results.d.ts +3 -0
  156. package/dist/core/extensions/event-results.d.ts.map +1 -1
  157. package/dist/core/extensions/event-results.js.map +1 -1
  158. package/dist/core/extensions/event-types.d.ts +2 -2
  159. package/dist/core/extensions/event-types.d.ts.map +1 -1
  160. package/dist/core/extensions/event-types.js.map +1 -1
  161. package/dist/core/extensions/index.d.ts +1 -1
  162. package/dist/core/extensions/index.d.ts.map +1 -1
  163. package/dist/core/extensions/index.js.map +1 -1
  164. package/dist/core/extensions/provider-types.d.ts +2 -0
  165. package/dist/core/extensions/provider-types.d.ts.map +1 -1
  166. package/dist/core/extensions/provider-types.js.map +1 -1
  167. package/dist/core/extensions/runner-events.d.ts +16 -2
  168. package/dist/core/extensions/runner-events.d.ts.map +1 -1
  169. package/dist/core/extensions/runner-events.js +98 -5
  170. package/dist/core/extensions/runner-events.js.map +1 -1
  171. package/dist/core/extensions/runner.d.ts +3 -2
  172. package/dist/core/extensions/runner.d.ts.map +1 -1
  173. package/dist/core/extensions/runner.js +4 -1
  174. package/dist/core/extensions/runner.js.map +1 -1
  175. package/dist/core/fast-model-variants.d.ts +16 -0
  176. package/dist/core/fast-model-variants.d.ts.map +1 -1
  177. package/dist/core/fast-model-variants.js +27 -0
  178. package/dist/core/fast-model-variants.js.map +1 -1
  179. package/dist/core/index.d.ts +1 -1
  180. package/dist/core/index.d.ts.map +1 -1
  181. package/dist/core/index.js.map +1 -1
  182. package/dist/core/messages.d.ts +10 -0
  183. package/dist/core/messages.d.ts.map +1 -1
  184. package/dist/core/messages.js +57 -0
  185. package/dist/core/messages.js.map +1 -1
  186. package/dist/core/model-config.d.ts +52 -0
  187. package/dist/core/model-config.d.ts.map +1 -1
  188. package/dist/core/model-config.js +16 -0
  189. package/dist/core/model-config.js.map +1 -1
  190. package/dist/core/model-resolver-defaults.d.ts.map +1 -1
  191. package/dist/core/model-resolver-defaults.js +2 -1
  192. package/dist/core/model-resolver-defaults.js.map +1 -1
  193. package/dist/core/model-runtime.d.ts +13 -1
  194. package/dist/core/model-runtime.d.ts.map +1 -1
  195. package/dist/core/model-runtime.js +16 -1
  196. package/dist/core/model-runtime.js.map +1 -1
  197. package/dist/core/prompt-templates-async.d.ts +2 -2
  198. package/dist/core/prompt-templates-async.d.ts.map +1 -1
  199. package/dist/core/prompt-templates-async.js +57 -29
  200. package/dist/core/prompt-templates-async.js.map +1 -1
  201. package/dist/core/prompt-templates.d.ts +6 -1
  202. package/dist/core/prompt-templates.d.ts.map +1 -1
  203. package/dist/core/prompt-templates.js +61 -35
  204. package/dist/core/prompt-templates.js.map +1 -1
  205. package/dist/core/provider-composer-internal.d.ts +1 -0
  206. package/dist/core/provider-composer-internal.d.ts.map +1 -1
  207. package/dist/core/provider-composer-internal.js +19 -0
  208. package/dist/core/provider-composer-internal.js.map +1 -1
  209. package/dist/core/resource-loader-assets.d.ts.map +1 -1
  210. package/dist/core/resource-loader-assets.js +6 -6
  211. package/dist/core/resource-loader-assets.js.map +1 -1
  212. package/dist/core/sdk-types.d.ts +5 -0
  213. package/dist/core/sdk-types.d.ts.map +1 -1
  214. package/dist/core/sdk-types.js.map +1 -1
  215. package/dist/core/sdk.d.ts.map +1 -1
  216. package/dist/core/sdk.js +7 -2
  217. package/dist/core/sdk.js.map +1 -1
  218. package/dist/core/session-manager-core.d.ts +10 -3
  219. package/dist/core/session-manager-core.d.ts.map +1 -1
  220. package/dist/core/session-manager-core.js +65 -7
  221. package/dist/core/session-manager-core.js.map +1 -1
  222. package/dist/core/session-manager-entries.d.ts +4 -1
  223. package/dist/core/session-manager-entries.d.ts.map +1 -1
  224. package/dist/core/session-manager-entries.js +8 -0
  225. package/dist/core/session-manager-entries.js.map +1 -1
  226. package/dist/core/session-manager-history.d.ts +16 -1
  227. package/dist/core/session-manager-history.d.ts.map +1 -1
  228. package/dist/core/session-manager-history.js +105 -42
  229. package/dist/core/session-manager-history.js.map +1 -1
  230. package/dist/core/session-manager-types.d.ts +30 -3
  231. package/dist/core/session-manager-types.d.ts.map +1 -1
  232. package/dist/core/session-manager-types.js.map +1 -1
  233. package/dist/core/session-manager.d.ts +2 -2
  234. package/dist/core/session-manager.d.ts.map +1 -1
  235. package/dist/core/session-manager.js +1 -1
  236. package/dist/core/session-manager.js.map +1 -1
  237. package/dist/core/settings-types.js.map +1 -1
  238. package/dist/core/structured-output/index.d.ts +1 -1
  239. package/dist/core/structured-output/index.d.ts.map +1 -1
  240. package/dist/core/structured-output/index.js +37 -41
  241. package/dist/core/structured-output/index.js.map +1 -1
  242. package/dist/core/structured-output/jev-client.d.ts +13 -8
  243. package/dist/core/structured-output/jev-client.d.ts.map +1 -1
  244. package/dist/core/structured-output/jev-client.js +90 -32
  245. package/dist/core/structured-output/jev-client.js.map +1 -1
  246. package/dist/core/structured-output/jev.d.ts.map +1 -1
  247. package/dist/core/structured-output/jev.js +38 -64
  248. package/dist/core/structured-output/jev.js.map +1 -1
  249. package/dist/core/structured-output/resolver.d.ts +32 -24
  250. package/dist/core/structured-output/resolver.d.ts.map +1 -1
  251. package/dist/core/structured-output/resolver.js +57 -9
  252. package/dist/core/structured-output/resolver.js.map +1 -1
  253. package/dist/core/structured-output/types.d.ts +8 -6
  254. package/dist/core/structured-output/types.d.ts.map +1 -1
  255. package/dist/core/structured-output/types.js.map +1 -1
  256. package/dist/core/system-prompt.js +1 -1
  257. package/dist/core/system-prompt.js.map +1 -1
  258. package/dist/core/tasks/child-command-owner.d.ts +34 -0
  259. package/dist/core/tasks/child-command-owner.d.ts.map +1 -0
  260. package/dist/core/tasks/child-command-owner.js +70 -0
  261. package/dist/core/tasks/child-command-owner.js.map +1 -0
  262. package/dist/core/tools/bash-pty-native.d.ts +5 -1
  263. package/dist/core/tools/bash-pty-native.d.ts.map +1 -1
  264. package/dist/core/tools/bash-pty-native.js +15 -7
  265. package/dist/core/tools/bash-pty-native.js.map +1 -1
  266. package/dist/core/tools/kill.d.ts +2 -2
  267. package/dist/core/tools/kill.d.ts.map +1 -1
  268. package/dist/core/tools/kill.js +3 -4
  269. package/dist/core/tools/kill.js.map +1 -1
  270. package/dist/core/tools/read.d.ts +4 -0
  271. package/dist/core/tools/read.d.ts.map +1 -1
  272. package/dist/core/tools/read.js +5 -1
  273. package/dist/core/tools/read.js.map +1 -1
  274. package/dist/index-extensions.d.ts +1 -1
  275. package/dist/index-extensions.d.ts.map +1 -1
  276. package/dist/index-extensions.js.map +1 -1
  277. package/dist/index.d.ts +4 -4
  278. package/dist/index.d.ts.map +1 -1
  279. package/dist/index.js +4 -4
  280. package/dist/index.js.map +1 -1
  281. package/dist/main-app-mode.d.ts +1 -1
  282. package/dist/main-app-mode.d.ts.map +1 -1
  283. package/dist/main-app-mode.js +3 -2
  284. package/dist/main-app-mode.js.map +1 -1
  285. package/dist/main.d.ts.map +1 -1
  286. package/dist/main.js +1 -1
  287. package/dist/main.js.map +1 -1
  288. package/dist/modes/interactive/components/tree-selector-content.d.ts.map +1 -1
  289. package/dist/modes/interactive/components/tree-selector-content.js +6 -0
  290. package/dist/modes/interactive/components/tree-selector-content.js.map +1 -1
  291. package/dist/modes/interactive/components/tree-selector-model.d.ts.map +1 -1
  292. package/dist/modes/interactive/components/tree-selector-model.js +1 -0
  293. package/dist/modes/interactive/components/tree-selector-model.js.map +1 -1
  294. package/dist/modes/interactive/interactive-agent-events.js +17 -1
  295. package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
  296. package/dist/modes/interactive/interactive-auth-login.js +2 -4
  297. package/dist/modes/interactive/interactive-auth-login.js.map +1 -1
  298. package/dist/modes/interactive/interactive-mode-helpers.d.ts +1 -0
  299. package/dist/modes/interactive/interactive-mode-helpers.d.ts.map +1 -1
  300. package/dist/modes/interactive/interactive-mode-helpers.js +16 -0
  301. package/dist/modes/interactive/interactive-mode-helpers.js.map +1 -1
  302. package/dist/modes/interactive/interactive-mode-surface.d.ts +1 -0
  303. package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
  304. package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
  305. package/dist/modes/interactive/interactive-process-lifecycle.js +13 -1
  306. package/dist/modes/interactive/interactive-process-lifecycle.js.map +1 -1
  307. package/dist/modes/interactive/interactive-session-runtime.js +5 -1
  308. package/dist/modes/interactive/interactive-session-runtime.js.map +1 -1
  309. package/dist/modes/interactive-engine/isolated-auth.d.ts +16 -0
  310. package/dist/modes/interactive-engine/isolated-auth.d.ts.map +1 -1
  311. package/dist/modes/interactive-engine/isolated-auth.js +27 -0
  312. package/dist/modes/interactive-engine/isolated-auth.js.map +1 -1
  313. package/dist/modes/interactive-engine/isolated-runtime.d.ts +4 -0
  314. package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
  315. package/dist/modes/interactive-engine/isolated-runtime.js +4 -1
  316. package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
  317. package/dist/modes/rpc/rpc-client-api.d.ts +2 -1
  318. package/dist/modes/rpc/rpc-client-api.d.ts.map +1 -1
  319. package/dist/modes/rpc/rpc-client-api.js +7 -2
  320. package/dist/modes/rpc/rpc-client-api.js.map +1 -1
  321. package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
  322. package/dist/modes/rpc/rpc-command-handler.js +3 -1
  323. package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
  324. package/dist/modes/rpc/rpc-provider-auth.d.ts +2 -1
  325. package/dist/modes/rpc/rpc-provider-auth.d.ts.map +1 -1
  326. package/dist/modes/rpc/rpc-provider-auth.js +2 -2
  327. package/dist/modes/rpc/rpc-provider-auth.js.map +1 -1
  328. package/dist/modes/rpc/rpc-types.d.ts +2 -0
  329. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  330. package/dist/modes/rpc/rpc-types.js.map +1 -1
  331. package/dist/utils/mime.js +1 -1
  332. package/dist/utils/mime.js.map +1 -1
  333. package/dist/utils/tool-result-images.d.ts +3 -1
  334. package/dist/utils/tool-result-images.d.ts.map +1 -1
  335. package/dist/utils/tool-result-images.js +4 -1
  336. package/dist/utils/tool-result-images.js.map +1 -1
  337. package/docs/background-tasks.md +11 -2
  338. package/docs/compaction.md +5 -1
  339. package/docs/computer-use.md +105 -56
  340. package/docs/environment-variables.md +1 -1
  341. package/docs/extensions/events.md +75 -7
  342. package/docs/extensions.md +6 -2
  343. package/docs/getting-started/first-session.md +3 -2
  344. package/docs/intercom/operations.md +13 -1
  345. package/docs/intercom.md +1 -1
  346. package/docs/llama-cpp.md +2 -2
  347. package/docs/models/evals.md +108 -118
  348. package/docs/models/reference.md +31 -3
  349. package/docs/packages.md +2 -0
  350. package/docs/prompt-templates.md +1 -0
  351. package/docs/providers.md +19 -6
  352. package/docs/reference/cli.md +2 -2
  353. package/docs/rpc/examples.md +2 -0
  354. package/docs/sdk/reference.md +2 -3
  355. package/docs/sdk/structured-decisions.md +25 -18
  356. package/docs/sdk.md +13 -2
  357. package/docs/session-format.md +17 -2
  358. package/docs/settings.md +8 -8
  359. package/docs/skills.md +8 -2
  360. package/docs/subagents/reference.md +4 -4
  361. package/docs/subagents.md +2 -2
  362. package/docs/workflows/api-reference.md +7 -34
  363. package/docs/workflows/authoring.md +191 -0
  364. package/docs/workflows/builtins.md +1 -1
  365. package/docs/workflows/operations.md +18 -78
  366. package/docs/workflows/reliable-design.md +14 -29
  367. package/docs/workflows/verification.md +21 -8
  368. package/docs/workflows.md +8 -7
  369. package/examples/rpc-client.ts +38 -0
  370. package/examples/rpc-extension-ui.ts +19 -5
  371. package/examples/sdk/README.md +1 -1
  372. package/npm-shrinkwrap.json +69 -69
  373. package/package.json +8 -8
  374. package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6_astra.md +0 -58
@@ -1,19 +1,19 @@
1
1
  ---
2
2
  title: Structured decisions
3
- description: Make a bounded structured decision without starting an agent session.
3
+ description: Make a schema-validated structured decision without starting an agent session.
4
4
  ---
5
5
 
6
6
  # Structured decisions
7
7
 
8
8
  Use `inferStructuredOutput()` from `@bastani/atomic` when an SDK integration needs one semantic decision before it performs an action. It returns a schema-validated value, the requested and responding model identities, and input/output token counts. It does not execute tools, start a session, or authorize an action.
9
9
 
10
- `inferStructuredOutput()` takes an explicit inference model and never reads `routerModel`. The `structured_output` tool continues to use its session's model. Neither API changes the selected chat model. [Model-invoked workflow launches](/workflows/operations#model-invoked-launch-routing) and [subagent `model: "auto"`](/subagents/reference#automatic-model-selection) use the shared router entrypoint below.
10
+ `inferStructuredOutput()` takes an explicit inference model and never reads `routerModel`. The `structured_output` tool continues to use its session's model. Neither API changes the selected chat model. [Workflow-stage](/workflows/operations#automatic-stage-models) and [subagent `model: "auto"`](/subagents/reference#automatic-model-selection) selection use the shared router entrypoint below.
11
11
 
12
12
  ## Select the inference model
13
13
 
14
- For a general structured-output call, pass `model: { kind: "chat", fullId, model }` with a concrete model from the current registry, or `model: { kind: "jev", fullId: "typesafe-ai/jev-latest" }`. For OpenRouter Jev, use `model: { kind: "jev", fullId: "openrouter/~typesafe/jev-latest" }`. Setting `routerModel` or exporting a TypeSafe key does not change this explicit selection.
14
+ For a general structured-output call, pass `model: { kind: "chat", fullId, model }` with a concrete model from the current registry, or `model: { kind: "jev", fullId: "typesafe-ai/jev-latest" }`. For Jev through a gateway, use any `fullId` from `getStructuredOutputProviders()`: `openrouter/~typesafe/jev-latest`, `vercel-ai-gateway/typesafe-ai/jev`, `opencode/jev-1.13`, or `opencode/jev-1.13-free`. Setting `routerModel` or exporting a TypeSafe key does not change this explicit selection.
15
15
 
16
- `inferRouterDecision()` is the shared entrypoint for prerequisite workflow selection and automatic subagent/workflow-stage model selection. Only this entrypoint consults `routerModel` in [settings.json](/settings#routermodel). It takes `settings`, `modelRegistry` and the invocation-time `currentModel` instead of an explicit inference `model`. Resolution is:
16
+ `inferRouterDecision()` is the shared entrypoint for automatic subagent/workflow-stage model selection. Only this entrypoint consults `routerModel` in [settings.json](/settings#routermodel). It takes `settings`, `modelRegistry` and the invocation-time `currentModel` instead of an explicit inference `model`. Resolution is:
17
17
 
18
18
  1. A nonempty explicit, exact `routerModel` value.
19
19
  2. Otherwise `typesafe-ai/jev-latest` when Jev credentials are configured through `/login typesafe-ai` or `TYPESAFE_API_KEY`.
@@ -27,13 +27,19 @@ Pass the full `ModelRegistry` to use saved Jev credentials with either decision
27
27
 
28
28
  OpenRouter Jev reuses the registry's existing OpenRouter sign-in or saved API key and normal `OPENROUTER_API_KEY` fallback. It never uses TypeSafe credentials. Minimal adapters use `OPENROUTER_API_KEY` for this selection. The Atomic ID includes `openrouter/`; the wire model is only `~typesafe/jev-latest`, sent to `https://openrouter.ai/api/alpha/decisions`. Both Jev selections accept the same Choice questions and return the same structured result. OpenRouter is explicit-only and does not change automatic selection precedence.
29
29
 
30
+ Vercel AI Gateway (`https://ai-gateway.vercel.sh/typesafe/v1/systemone`, wire model `typesafe-ai/jev`) and OpenCode Zen (`https://opencode.ai/zen/v1/systemone`, wire models `jev-1.13` and `jev-1.13-free`) follow the same rule with `AI_GATEWAY_API_KEY` and `OPENCODE_API_KEY` or that provider's `/login`. Their model IDs, `contextWindow`, and `cost` fields are read from the models.dev decision catalog bundled with `@bastani/pi-ai` (`getDecisionModels()`), so a gateway that drops or renames its Jev listing disappears from `getStructuredOutputProviders()` at the next catalog regeneration. Gateway Jev is explicit-only.
31
+
30
32
  ### Router repair attempts
31
33
 
32
- By default, `inferRouterDecision()` gives each provider an initial attempt plus **up to three corrective retries** when an answer is malformed or fails the decision schema. This applies independently to Jev and the current-chat fallback: at most four attempts each, sharing one deadline of 30 seconds by default. A valid answer stops retries immediately; a valid `none` is not retried. Repairs may increase latency and provider usage, but never start a workflow or child before final validation.
34
+ By default, `inferRouterDecision()` gives each provider an initial attempt plus **up to three corrective retries** when an answer is malformed or fails the decision schema. When a chat fallback exists, a failed Jev attempt switches to chat immediately instead of repairing on Jev; the chat fallback then gets at most four attempts, without a structured-decision time limit. A valid answer stops retries immediately; a valid `none` is not retried. Repairs may increase latency and provider usage, but never start a workflow or child before final validation.
35
+
36
+ Separately from output repairs, transient provider failures — connection errors and HTTP 408, 429 and 5xx — are retried up to three times with exponential backoff for both Jev and chat decision requests. Every request honors cancellation; an aborted request is never retried. Both decision APIs accept a `retry` policy (`{ enabled, maxRetries, baseDelayMs }`) to change this; `inferRouterDecision()` also reads `settings.retry` when available.
33
37
 
34
- Input/configuration errors, cancellation, timeout, and stale-catalog rejection are not repaired. Generic `inferStructuredOutput()` remains one-shot; it does not gain router repairs or provider fallback.
38
+ Input/configuration errors, cancellation, and stale-catalog rejection are not repaired. Generic `inferStructuredOutput()` gains the same transient-failure retries but no output repairs or provider fallback.
35
39
 
36
- When `routerModel` is empty, automatically selected Jev switches to the current chat model after exhausting its output repairs, encountering an HTTP or connection error, or exceeding the local context budget. Context-budget failures switch before sending an oversized request; HTTP errors such as `max_tokens_exceeded` switch without repeating an unchanged request. A warning reports the safe failure reason and fallback model. The fallback gets its own initial attempt plus three corrective retries, using the original state, schema and constraints within the remaining deadline. The result includes `fallback: { from, to, reason }` and identifies the chat model in `model`. This can send routing context to your chat provider and incur its normal charges. An explicit `routerModel` disables provider fallback. Missing credentials, response-size violations, cancellation and timeout do not trigger fallback.
40
+ Any Jev failure switches to the current chat model when the invocation has a concrete current chat model — exhausted output repairs, HTTP and connection errors after their transient retries, missing or unresolvable credentials, response-size violations, and local context-budget rejection. This applies to explicit Jev `routerModel` selections as well as automatic ones. Context-budget failures switch before sending an oversized request; HTTP errors such as `max_tokens_exceeded` switch without repeating an unchanged request. A warning reports the safe failure reason and fallback model. The fallback gets its own initial attempt plus three corrective retries, using the original state, schema and constraints. The result includes `fallback: { from, to, reason }` and identifies the chat model in `model`. This can send routing context to your chat provider and incur its normal charges. Cancellation never triggers fallback.
41
+
42
+ For [workflow-stage](/workflows/operations#automatic-stage-models) and [subagent](/subagents/reference#automatic-model-selection) `model: "auto"`, a complete routing-inference failure — Jev and the chat structured-output fallback both — runs the stage or child on the current chat model with a recorded warning instead of failing, provided that model is available and satisfies every routing constraint. If ranking a fallback model fails after the primary was chosen, the primary is kept. Validation, eligibility, credential-screening failures and cancellation still fail as before.
37
43
 
38
44
  ## Prepare a decision
39
45
 
@@ -68,7 +74,7 @@ const result = await inferStructuredOutput({
68
74
  schema,
69
75
  instructions: "Classify whether the task asks a question. Use none for other tasks.",
70
76
  state: {
71
- task: "What does the timeout setting mean?",
77
+ task: "What does the router setting mean?",
72
78
  constraints: { permittedAction: "classify only" },
73
79
  reference: { text: "A question requests an explanation or information." },
74
80
  candidates: ["question", "none"],
@@ -87,7 +93,6 @@ const result = await inferStructuredOutput({
87
93
  category: choices.category === "question" ? "question" : "none",
88
94
  } as const),
89
95
  },
90
- timeoutMs: 30_000,
91
96
  maxTokens: 4096,
92
97
  });
93
98
  console.log(result.value.category);
@@ -101,9 +106,9 @@ For runtime catalogs, build schema, state and Choice candidates from the same sn
101
106
 
102
107
  Ordinary models receive one `structured_output` result tool with the supplied schema. Atomic uses provider-aware serialization, requests strict sampling where supported, and validates the returned arguments without coercing values or removing extra fields. Use `additionalProperties: false` for closed objects. Providers without strict sampling must still return valid arguments. `toolChoice: "auto"` also supports models that reject forced tool use. A prose-only response, extra tool call, truncated response or invalid result fails a generic `inferStructuredOutput()` call without a repair prompt; router calls can use the bounded repairs described above.
103
108
 
104
- Ordinary requests set `maxRetries: 0`, use HTTP/SSE rather than WebSocket transport fallback, and disable configured Anthropic server-side fallbacks for this request only. Custom provider implementations must honor these options and must not introduce their own inference retries or fallback requests.
109
+ Ordinary requests use HTTP/SSE rather than WebSocket transport fallback, and disable configured Anthropic server-side fallbacks for this request only. Transient-failure retries are owned by the decision layer: each provider request sets `maxRetries: 0`, and custom provider implementations must honor these options and must not introduce their own inference retries or fallback requests.
105
110
 
106
- [TypeSafe Jev](/providers#typesafe-jev) accepts shared state and typed questions instead of JSON-schema generation. Atomic packs independent questions together. Generic `inferStructuredOutput()` calls have no automatic retries; router calls can repair malformed or schema-invalid answers within their shared deadline. Question IDs are correlation keys, not instructions seen by Jev, so put complete semantics in each question's `instructions`. Describe the speculative premise of a conditional question and consume its answer only when that premise applies.
111
+ [TypeSafe Jev](/providers#typesafe-jev) accepts shared state and typed questions instead of JSON-schema generation. Atomic packs independent questions together. Both decision APIs retry transient provider failures up to three times; router calls can additionally repair malformed or schema-invalid answers within their attempt allowance. Question IDs are correlation keys, not instructions seen by Jev, so put complete semantics in each question's `instructions`. Describe the speculative premise of a conditional question and consume its answer only when that premise applies.
107
112
 
108
113
  Choices with up to 255 options keep a single comparison when they fit the context budget. Larger or more verbose choices use a bounded tournament: every original option participates in stable batches of at most 255; each batch retains its top three by validated probabilities, with ties resolved by original order. Further shrinking rounds precede a final shared comparison. Probabilities are never compared across batches. Multiple named questions can mix small choices and tournaments; `decode` receives original option keys only after all judgments succeed. Empty choices fail; singletons still go to the provider when they fit.
109
114
 
@@ -113,20 +118,22 @@ Overflow requires multiple HTTP requests and can increase latency and billed inp
113
118
 
114
119
  Jev documents limits of 32k tokens for state plus the longest question, and 64k for state plus all questions. Without an exact Jev tokenizer, Atomic uses conservative UTF-8 byte budgets of 24,000 and 48,000 respectively, reserving further framing headroom when packing. These checks include compiled instructions and criteria, apply even below 255 options, and may reject inputs the provider would accept.
115
120
 
116
- The structured-decision transport never trims supplied state or sends an indivisible comparison that exceeds its local budget. Default routing can use that state with the current chat model; explicitly pinned Jev and general structured-output calls fail. A provider `max_tokens_exceeded` response still uses the same routing fallback policy without repeating the rejected request. Supply concise context or select a chat model with enough capacity when needed.
121
+ The structured-decision transport never trims supplied state or sends an indivisible comparison that exceeds its local budget. Router calls use that state with the current chat model, including for pinned Jev; general structured-output calls fail. A provider `max_tokens_exceeded` response still uses the same routing fallback policy without repeating the rejected request. Supply concise context or select a chat model with enough capacity when needed.
117
122
 
118
- Automatic subagent and workflow-stage model selection prepares a [bounded task excerpt](/subagents/reference#automatic-model-selection) before calling this API. That excerpt preserves protected spans and does not replace the execution prompt. Workflow-launch routing and direct SDK decision calls do not apply this task-excerpt policy.
123
+ Automatic subagent and workflow-stage model selection prepares a [bounded task excerpt](/subagents/reference#automatic-model-selection) before calling this API. That excerpt preserves protected spans and does not replace the execution prompt. Direct SDK decision calls do not apply this task-excerpt policy.
119
124
 
120
- Jev response bodies are limited to 1 MiB per request. Atomic validates answer types, choices, probability distributions and usage without imposing a confidence threshold.
125
+ Jev response bodies are limited to 1 MiB per request. Atomic validates that every question receives a known Choice option; reported model, usage, probabilities and confidence are advisory and never reject an otherwise valid decision.
121
126
 
122
127
  ## Cancellation and failures
123
128
 
124
- The default deadline is 30 seconds for the entire decision, including all router repair attempts, any chat fallback, tournament rounds, authentication, transport and response reading. `timeoutMs` must be a positive integer no greater than 2147483647; zero does not disable it. Ordinary output is bounded by `maxTokens`, default 4096. Pass an `AbortSignal` to cancel. Cancellation or timeout rejects the whole call immediately; a failed batch yields no partial decision, and late responses cannot invoke the Jev mapper.
129
+ Structured decisions have no built-in wall-clock timeout. Slow authentication, inference, repairs, chat fallback and tournament rounds can finish without the former 30-second cutoff. Pass an `AbortSignal` to cancel; SDK callers that need their own deadline can supply `signal: AbortSignal.timeout(milliseconds)`. Cancellation rejects the whole call immediately, even if a provider ignores its signal. A failed batch yields no partial decision, and late responses cannot invoke the Jev mapper. Ordinary output is still bounded by `maxTokens`, default 4096.
130
+
131
+ The `timeoutMs` request option and `DEFAULT_STRUCTURED_OUTPUT_TIMEOUT_MS` export have been removed. Remove these from existing integrations and use `signal` for caller-owned cancellation. Provider transport, credential-preparation and enclosing tool-request limits remain independent; removing the decision timeout does not disable them.
125
132
 
126
133
  No result is returned for missing state, invalid configuration, unrepaired malformed output or an unrecovered provider failure. Keep action admission after the awaited result and check cancellation again at that boundary. Neither API runs recursive agents or provider probes.
127
134
 
128
- Jev errors report the SDK error class, HTTP status, recognized machine error codes such as `max_tokens_exceeded`, and a validated TypeSafe request ID when available. Raw error bodies, arbitrary messages and credentials are not exposed. SDK transport retries and body logging are disabled, including when `TYPESAFE_LOG_LEVEL` is set. Cancellation and timeout remain distinct failures.
135
+ Jev errors report the SDK error class, HTTP status, recognized machine error codes such as `max_tokens_exceeded`, and a validated TypeSafe request ID when available. Raw error bodies, arbitrary messages and credentials are not exposed. Transient HTTP failures are retried up to three times before an error is reported; there is no body logging, including when `TYPESAFE_LOG_LEVEL` is set.
129
136
 
130
- For direct Jev, HTTP 401 means check `/login typesafe-ai` or `TYPESAFE_API_KEY`; for OpenRouter Jev, check `/login openrouter` or `OPENROUTER_API_KEY`. HTTP 400 or 422 means check the state/question contract or reported context limit; 403 means access denied, 404 means check the endpoint/model, and 429 or 529 means wait before an explicit retry.
137
+ For direct Jev, HTTP 401 means check `/login typesafe-ai` or `TYPESAFE_API_KEY`; for OpenRouter Jev, check `/login openrouter` or `OPENROUTER_API_KEY`. HTTP 400 or 422 means check the state/question contract or reported context limit; 403 means access denied, 404 means check the endpoint/model, and a reported 429 or 529 means the provider stayed rate limited or overloaded through the automatic retries.
131
138
 
132
- Malformed Jev response errors include a static diagnostic code, without response values or routing context. For example, `probability_mass` means the returned probabilities failed the sum-to-one tolerance, `probability_keys` means the options did not match, and `choice_not_highest` means the selected option was not highest-probability. Include the code when reporting a failure. Router calls may repair these errors before returning a final failure; generic calls fail immediately. No invalid decision is accepted.
139
+ Malformed Jev response errors include a static diagnostic code, without response values or routing context: `choice_key` means an answer named no known Choice option (or was missing), and a non-JSON body reports malformed JSON. Include the code when reporting a failure. Router calls may repair these errors before returning a final failure; generic calls fail immediately. No decision naming an unknown option is accepted.
package/docs/sdk.md CHANGED
@@ -283,6 +283,8 @@ interface AgentSession {
283
283
 
284
284
  // State access
285
285
  agent: Agent;
286
+ sessionManager: SessionManager;
287
+ refreshContext(): void;
286
288
  model: Model | undefined;
287
289
  thinkingLevel: ThinkingLevel;
288
290
  messages: AgentMessage[];
@@ -493,8 +495,8 @@ const state = session.agent.state;
493
495
  // state.streamingMessage?: AgentMessage - current partial assistant message
494
496
  // state.errorMessage?: string - latest assistant error
495
497
 
496
- // Replace messages (useful for branching or restoration)
497
- session.agent.state.messages = messages; // copies the top-level array
498
+ // Model-visible messages are projected from session.sessionManager.
499
+ // agent.state.messages is a refreshed inspection cache; do not assign it for restoration.
498
500
 
499
501
  // Replace tools
500
502
  session.agent.state.tools = tools; // copies the top-level array
@@ -503,6 +505,15 @@ session.agent.state.tools = tools; // copies the top-level array
503
505
  await session.agent.waitForIdle();
504
506
  ```
505
507
 
508
+ Provider requests use `session.sessionManager` as the canonical finalized context. Assigning `session.agent.state.messages` does not replace persisted context and may be overwritten at the next request boundary. Restore externally stored history when constructing the session instead:
509
+
510
+ ```typescript
511
+ const restoredManager = SessionManager.inMemory(process.cwd(), { id: sessionId }, entries);
512
+ const { session } = await createAgentSession({ sessionManager: restoredManager });
513
+ ```
514
+
515
+ For an existing session, use `session.navigateTree(entryId)` to move its active branch. Use `session.sessionManager.appendMessage(...)` plus `session.refreshContext()` only when intentionally appending externally managed entries. A caller-supplied `prepareNextTurnWithContext` replacement context is still honored for exactly the request it prepared.
516
+
506
517
  ### Events
507
518
 
508
519
  Subscribe to events to receive streaming output and lifecycle notifications.
@@ -267,6 +267,18 @@ Older Atomic versions stored logical entry/content-block deletions in `type:"con
267
267
 
268
268
  These records are archival and never produced or applied by current Atomic. When an old session resumes, previously hidden content may re-enter context until verbatim-line compaction creates an active boundary.
269
269
 
270
+ ### ContextEditEntry
271
+
272
+ Append-only edit of one earlier context-producing entry. It changes only future model context; the target entry and its metadata remain unchanged in raw history, UI, exports, and session accounting.
273
+
274
+ ```json
275
+ {"type":"context_edit","id":"g6h7i8j9","parentId":"f6g7h8i9","timestamp":"2024-12-03T14:11:00.000Z","targetId":"c3d4e5f6","replacement":null}
276
+ ```
277
+
278
+ Targets may be user, assistant, tool-result, or custom-message entries. `replacement: null` omits the target from model context. A non-null `replacement` replaces only the target message content. String replacements for assistant and tool-result entries are normalized to one text block because those roles require content arrays. If several edits target the same entry, the latest edit on the active branch wins. Edits are branch-relative: navigating to a point before the edit reveals the target's original contribution again.
279
+
280
+ Atomic writes these entries itself when it durably omits a failed attempt from model context (an automatic retry after a provider error, a model fallback, an overflow or length recovery, or an interrupted empty reply that resumes an admitted queued message). Extensions append them through the `turn_end` and `agent_before_settle` boundaries.
281
+
270
282
  ### BranchSummaryEntry
271
283
 
272
284
  Created when switching branches via `/tree` with an LLM generated summary of the left branch up to the common ancestor. Captures context from the abandoned path.
@@ -354,10 +366,10 @@ Entries form a tree:
354
366
 
355
367
  ## Context Building
356
368
 
357
- `buildSessionContext()` walks the active branch from root to leaf and replays model, thinking-level, and context-window changes. It selects the latest `compaction` entry whose `details.strategy` is `"verbatim-lines"`.
369
+ `buildSessionProjection()` walks the active branch from root to leaf and replays model, thinking-level, and context-window changes. It selects the latest `compaction` entry whose `details.strategy` is `"verbatim-lines"`, then applies the latest `context_edit` for each selected target. It returns the model-visible messages together with their source entries (`entries[].sourceEntry` and `entries[].messages`); omitted targets produce no message, replacements retain the source entry's role and metadata while changing only content, and the raw selected entries are not modified. `buildSessionContext()` returns just the messages, thinking level, and model from that projection. Provider requests are built from this projection.
358
370
 
359
371
  - With no active boundary, normal message, custom-message, and branch-summary entries are emitted verbatim.
360
- - With a boundary whose `firstKeptEntryId` is a string, Atomic emits a single custom-role `customType:"compaction"` message whose text is the durable string plus the losslessly serialized kept tail (the entries from that ID up to the boundary, with retained images kept as image blocks on that message), then the messages appended after the boundary.
372
+ - With a boundary whose `firstKeptEntryId` is a string, Atomic emits a single custom-role `customType:"compaction"` message whose text is the durable string plus the losslessly serialized kept tail (the entries from that ID up to the boundary, with context edits applied and retained images kept as image blocks on that message), then the messages appended after the boundary. Kept-tail entries project no standalone messages of their own.
361
373
  - With `firstKeptEntryId: null`, Atomic emits the boundary and post-boundary messages but no pre-boundary ordinary message.
362
374
  - If a corrupt/foreign boundary's non-null `firstKeptEntryId` is absent, Atomic emits the boundary followed by post-boundary messages rather than resurrecting all older content.
363
375
  - Legacy `context_compaction` entries and non-verbatim `compaction` entries are skipped as inert archival records.
@@ -468,7 +480,10 @@ for (const stage of stages.filter((session) => session.internal)) {
468
480
  - `branchWithSummary(entryId, summary, details?, fromHook?)` - Branch with context summary
469
481
 
470
482
  ### Instance Methods - Context & Info
483
+ - `buildSessionProjection()` - Get the context-edited projection: source entries with their model-visible messages, plus thinkingLevel and model
471
484
  - `buildSessionContext()` - Get messages, thinkingLevel, and model for LLM
485
+ - `buildContextEntries()` - Active branch entries after the latest compaction boundary
486
+ - `appendContextEdit(targetId, replacement)` - Append a branch-local context edit (`null` omits the target; `{ content }` replaces only its content)
472
487
  - `getEntries()` - All entries (excluding header)
473
488
  - `getHeader()` - Session header metadata
474
489
  - `getSessionName()` - Get display name from latest session_info entry (`undefined` when cleared or never named)
package/docs/settings.md CHANGED
@@ -55,7 +55,7 @@ See [Herdr](/herdr) for state aggregation, reporter conflicts, privacy, and Herd
55
55
  |---------|------|---------|-------------|
56
56
  | `defaultProvider` | string | - | Startup provider, saved automatically when you switch models interactively |
57
57
  | `defaultModel` | string | - | Startup model ID, saved automatically when you switch models interactively |
58
- | `routerModel` | string | `""` | Inference model for prerequisite workflow and subagent-auto routing only. Exact `provider/model`; empty selects Jev when its credentials are configured through `/login` or `TYPESAFE_API_KEY`, otherwise the current chat model. Does not change chat or `structured_output` tool inference. |
58
+ | `routerModel` | string | `""` | Inference model for workflow-stage and subagent `model: "auto"` selection only. Exact `provider/model`; empty selects Jev when its credentials are configured through `/login` or `TYPESAFE_API_KEY`, otherwise the current chat model. Does not change chat or `structured_output` tool inference. |
59
59
  | `defaultThinkingLevel` | string | - | Startup thinking level, saved automatically on interactive model/thinking changes: `"off"`, `"minimal"`, `"low"`, `"medium"`, `"high"`, `"xhigh"`, `"max"`; clamped to the active model's supported levels |
60
60
  | `modelThinkingLevels` | object | - | Per-model startup thinking levels keyed by `"provider/modelId"`; updated automatically on interactive model/thinking changes, or configured from `/settings` → Default thinking level per model |
61
61
  | `hideThinkingBlock` | boolean | `false` | Hide thinking blocks in output |
@@ -79,17 +79,17 @@ Normal automatic selection of an available authenticated model remains enabled i
79
79
  { "routerModel": "" }
80
80
  ```
81
81
 
82
- Use `/settings` → **Router model** to change the effective selection. If the project already defines `routerModel`, the picker edits that project override; otherwise it saves the global default in `~/.atomic/agent/settings.json`. The picker identifies which scope it will save. Choose **Automatic** to save `""` in that scope, **typesafe-ai/jev-latest** for direct Jev, **openrouter/~typesafe/jev-latest** for Jev using your existing OpenRouter login or `OPENROUTER_API_KEY`, or search available chat models by provider/model ID. Both Jev options are offered here without appearing in `/model`. Run `/reload` or restart Atomic to apply the saved choice to an already-running isolated engine.
82
+ Use `/settings` → **Router model** to change the effective selection. If the project already defines `routerModel`, the picker edits that project override; otherwise it saves the global default in `~/.atomic/agent/settings.json`. The picker identifies which scope it will save. Choose **Automatic** to save `""` in that scope, **typesafe-ai/jev-latest** for direct Jev, **openrouter/~typesafe/jev-latest** for Jev using your existing OpenRouter login or `OPENROUTER_API_KEY`, a Vercel AI Gateway or OpenCode Zen Jev ID (`vercel-ai-gateway/typesafe-ai/jev`, `opencode/jev-1.13`, `opencode/jev-1.13-free`) using that provider's credentials, or search available chat models by provider/model ID. The Jev options are offered here without appearing in `/model`. Run `/reload` or restart Atomic to apply the saved choice to an already-running isolated engine.
83
83
 
84
- A nonempty explicit model takes precedence over automatic Jev selection. Use an exact catalog ID without a reasoning suffix, or the decision-only ID `typesafe-ai/jev-latest` or `openrouter/~typesafe/jev-latest`. Replace old `typesafe-ai/jev` settings with `typesafe-ai/jev-latest`. An invalid explicit ID, `auto`, non-string value or surrounding whitespace fails the decision instead of silently changing providers. An explicit empty project value overrides a global selection and restores the configured-direct-Jev/current-chat precedence. OpenRouter credentials alone do not select Jev automatically.
84
+ A nonempty explicit model takes precedence over automatic Jev selection. Use an exact catalog ID without a reasoning suffix, or a decision-only ID returned by `getStructuredOutputProviders()`, such as `typesafe-ai/jev-latest`, `openrouter/~typesafe/jev-latest`, `vercel-ai-gateway/typesafe-ai/jev`, or `opencode/jev-1.13`. Replace old `typesafe-ai/jev` settings with `typesafe-ai/jev-latest`. An invalid explicit ID, `auto`, non-string value or surrounding whitespace fails the decision instead of silently changing providers. An explicit empty project value overrides a global selection and restores the configured-direct-Jev/current-chat precedence. OpenRouter, Vercel AI Gateway, and OpenCode Zen credentials alone do not select Jev automatically.
85
85
 
86
- With **Automatic**, a Jev HTTP or connection failure, or exhaustion of its structured-output repairs, switches routing to your current chat model. By default, each provider gets an initial attempt plus three corrective retries for invalid output, using the same context and shared deadline. Atomic reports the fallback; it can incur chat-provider charges. An explicit router selection disables provider fallback. Cancellation, timeout and local input-validation failures do not trigger fallback.
86
+ Any Jev failure — HTTP or connection errors, missing credentials, context-budget rejection, or exhausted structured-output repairs — switches routing to your current chat model, whether Jev was selected automatically or pinned explicitly. Transient failures (connection errors, HTTP 408, 429 and 5xx) are first retried up to three times with backoff, and each provider gets an initial attempt plus three corrective retries for invalid output, using the same context. Routing has no built-in wall-clock deadline; cancel the request to stop waiting. Independent provider, credential-preparation and enclosing tool-request limits still apply. Atomic reports the fallback; it can incur chat-provider charges. Cancellation and local input-validation failures do not trigger fallback.
87
87
 
88
- Automatic subagent and workflow-stage model selection uses a bounded excerpt for long tasks, keeping the beginning, end, and `<keepContext>...</keepContext>` spans. Only the router's copy is shortened; execution receives the full task and hard model constraints stay enforced. Put essential model-selection requirements in protected spans. Unprotected middle text may be omitted, so excerpts can affect model choice. This does not truncate workflow-launch state or general structured decisions.
88
+ Automatic subagent and workflow-stage model selection uses a bounded excerpt for long tasks, keeping the beginning, end, and `<keepContext>...</keepContext>` spans. Only the router's copy is shortened; execution receives the full task and hard model constraints stay enforced. Put essential model-selection requirements in protected spans. Unprotected middle text may be omitted, so excerpts can affect model choice. This does not truncate general structured decisions.
89
89
 
90
- If protected content or the remaining request still exceeds Jev's conservative context budget, Automatic switches to the current chat model. Pinned Jev instead reports a context-budget error; supply concise relevant excerpts or choose a chat router with enough capacity. Large candidate sets are split into bounded comparisons without dropping candidates before evaluation.
90
+ If protected content or the remaining request still exceeds Jev's conservative context budget, routing switches to the current chat model, including for a pinned Jev selection. Large candidate sets are split into bounded comparisons without dropping candidates before evaluation.
91
91
 
92
- This setting selects prerequisite inference for [model-invoked workflow launches](/workflows/operations#model-invoked-launch-routing), [workflow-stage `model: "auto"`](/workflows/authoring#automatic-stage-model-selection), and [subagent `model: "auto"`](/subagents/reference#automatic-model-selection). It does not directly select the child execution model or change the selected chat model, `structured_output` tool, or general structured-output inference. The selected router provider receives the routing context, so choose a provider permitted to process that data. Authenticate direct Jev with `/login typesafe-ai` or `TYPESAFE_API_KEY`, and OpenRouter Jev with existing OpenRouter credentials. See [Structured decisions](/sdk/structured-decisions) and [TypeSafe Jev](/providers#typesafe-jev).
92
+ This setting selects inference for [workflow-stage `model: "auto"`](/workflows/authoring#automatic-stage-model-selection) and [subagent `model: "auto"`](/subagents/reference#automatic-model-selection). It does not directly select the child execution model or change the selected chat model, `structured_output` tool, or general structured-output inference. The selected router provider receives the routing context, so choose a provider permitted to process that data. Authenticate direct Jev with `/login typesafe-ai` or `TYPESAFE_API_KEY`, and gateway Jev (OpenRouter, Vercel AI Gateway, OpenCode Zen) with that gateway's existing credentials. See [Structured decisions](/sdk/structured-decisions) and [TypeSafe Jev](/providers#typesafe-jev).
93
93
 
94
94
  Remove secrets from routing tasks, inputs, and workflow descriptions/contracts before calling the tool. A routing-context credential error stops before inference or launch. Known configured credentials are screened even when they belong to a provider other than the router. Remove the credential from the supplied context or registered definition, reload a changed definition, then retry explicitly. The guard does not detect every possible secret.
95
95
 
@@ -208,7 +208,7 @@ Atomic stores only UTC date, version, and an aggregate count, retained as aggreg
208
208
 
209
209
  Opt out by setting `enableInstallTelemetry` to `false` in `settings.json`, or by setting `ATOMIC_TELEMETRY=0` (`PI_TELEMETRY=0` remains a legacy alias). `ATOMIC_TELEMETRY=1`/`true`/`yes` forces the ping on even when the setting is false. `ATOMIC_TELEMETRY` wins when both it and `PI_TELEMETRY` are set.
210
210
 
211
- Set `ATOMIC_SKIP_VERSION_CHECK=1` to disable the Atomic version update check. Use `--offline` or `ATOMIC_OFFLINE=1` to disable all startup network operations described here, including update checks, package update checks, and install/update telemetry. Legacy `PI_*` aliases are also supported for app-specific environment variables.
211
+ Set `ATOMIC_SKIP_VERSION_CHECK=1` to disable the Atomic version update check. Use `--offline` or `ATOMIC_OFFLINE=1` to disable all startup network operations described here, including update checks, package update checks, install/update telemetry, and model catalog refreshes. Legacy `PI_*` aliases are also supported for app-specific environment variables.
212
212
 
213
213
  On a genuine first run, Atomic previews available themes and asks whether to opt into analytics. The choice and locally generated identifier are stored as `enableAnalytics` and `trackingId`; analytics remains off unless explicitly enabled.
214
214
 
package/docs/skills.md CHANGED
@@ -82,10 +82,14 @@ This is progressive disclosure: only descriptions are always in context, full in
82
82
 
83
83
  ### Built-in prompt engineering guidance
84
84
 
85
- The bundled `/skill:prompt-engineer` creates, optimizes, evaluates, and troubleshoots prompts for GPT and Claude models. Its small routing file points to separate, source-attributed guides for GPT-6 Astra, GPT-5.6, GPT-5.5, Claude Fable 5.1, Claude Fable 5, Claude Opus 5, Claude Opus 4.8, and Claude Sonnet 5. Read the target model's page, or both relevant pages for a migration, without loading every guide. Shared references cover prompt structure, tools, evaluation, and instruction audits; model defaults, effort, verification, and API compatibility stay in their own pages.
85
+ The bundled `/skill:prompt-engineer` creates, optimizes, evaluates, and troubleshoots prompts for GPT and Claude models. Its small routing file points to separate, source-attributed guides for GPT-6 Astra, GPT-5.6, GPT-5.5, Claude Fable 5.1, Claude Fable 5, Claude Opus 5.5, Claude Opus 5, Claude Opus 4.8, and Claude Sonnet 5. Read the target model's page, or both relevant pages for a migration, without loading every guide. Shared references cover prompt structure, tools, evaluation, and instruction audits; model defaults, effort, verification, and API compatibility stay in their own pages.
86
+
87
+ Each model guide pairs an observed behavior with a prompt adjustment, example wording, and caveats. Choose the patterns that address your task instead of copying the whole guide; compatibility notes explain when a prompt also needs provider or application support.
86
88
 
87
89
  Astra guidance distills [OpenAI's model guide](https://developers.openai.com/api/docs/guides/latest-model?model=gpt-6-astra) into completion and permission rules, proportionate verification, useful parallel delegation, concise writing, and API migration checks. An instruction audit based on [Eric Provencher's advice](https://x.com/pvncher/status/2095991462416490862) explains how to shorten skill descriptions, use small routing files with optional references, remove obsolete recipes, and define safe local work and stopping points. It preserves binding repository requirements and separates API features from capabilities actually exposed by the host.
88
90
 
91
+ Opus 5.5 guidance covers its always-on thinking and medium-effort API default, progress updates returned in thinking blocks, bounded continuations for unattended work, and pasted-content boundaries. Use it when migrating Opus 5 prompts or troubleshooting silent or prematurely stopped tool loops; verify provider and host support before applying API-specific controls.
92
+
89
93
  The skill no longer recommends response prefilling, which returns an error on Claude 4.6 and later, or visible chain-of-thought as a primary technique. Use explicit output instructions, schemas, tools, or post-processing instead of prefilling. Request conclusions, citations, commands, and observed results rather than reconstructed private reasoning; such requests can trigger Claude Fable 5's `reasoning_extraction` safeguard and force a model fallback.
90
94
 
91
95
  ### Built-in visual explanation guidance
@@ -109,7 +113,9 @@ Offline, `qlty metrics` and `qlty smells` still work through built-in static ana
109
113
 
110
114
  ### Built-in computer-use and automation guidance
111
115
 
112
- For desktop computer use, or CUA, use PyAutoGUI for mouse, keyboard and screenshots. For browser automation, load `/skill:agent-browser`. For terminal automation/testing, prefer `/skill:herdr` on macOS, Linux and Windows. Install Herdr if missing when network access and permissions permit; fall back to `/skill:tmux` or native Windows psmux when installation or use is not possible. Preserve the upstream skill's explicit-request and managed-pane requirements. These are separate interfaces, not interchangeable command names. See [verification and desktop safety](/workflows/verification) for installation, permissions, dedicated sessions and input cleanup.
116
+ For desktop, simulator, and emulator computer use, or CUA, load `/skill:cua-driver` and drive the exact window with one-shot `cua-driver call <tool>` commands; when a custom workflow's TypeScript owns the scenario, use the `@trycua/cua-driver` SDK inside `ctx.tool` instead. See [Computer use](/computer-use#desktop-automation-with-cua-driver) for installing the executable, turning telemetry off, readiness, and permissions. For browser automation, load `/skill:agent-browser`. For terminal automation/testing, prefer `/skill:herdr` on macOS, Linux and Windows. Install Herdr if missing when network access and permissions permit; fall back to `/skill:tmux` or native Windows psmux when installation or use is not possible. Preserve the upstream skill's explicit-request and managed-pane requirements. These are separate interfaces, not interchangeable command names. See [verification and desktop safety](/workflows/verification) for installation, permissions, dedicated sessions and evidence.
117
+
118
+ The bundled [Cua Driver skill](https://github.com/trycua/cua/tree/cua-driver-rs-v0.28.2/libs/cua-driver/rust/Skills/cua-driver) is upstream's `libs/cua-driver/rust/Skills/cua-driver` at tag `cua-driver-rs-v0.28.2`, vendored verbatim with all three platform guides (`MACOS.md`, `WINDOWS.md`, `LINUX.md`) plus `BROWSER.md`, `RECORDING.md`, and `EMBEDDING.md`; only the `SKILL.md` frontmatter is Atomic-owned. MIT licensed, © 2025 Cua AI, Inc. It teaches the snapshot → act → fresh snapshot → verify loop for the `cua-driver` CLI; it does not install the `cua-driver` executable, grant permissions, or turn telemetry off, and Atomic never runs `cua-driver skills install`. Browsers stay with `agent-browser` even though the vendored `BROWSER.md` describes upstream's browser route.
113
119
 
114
120
  The bundled [Herdr skill](https://github.com/herdrdev/herdr/blob/v0.9.0/skills/herdr/SKILL.md) requires an explicit Herdr mention or request and `HERDR_ENV=1`; it stops outside a Herdr-managed pane. It does not install Herdr or authorize control of unrelated panes. Use returned pane IDs, and check completion separately from command submission.
115
121
 
@@ -35,15 +35,15 @@ The shared [`routerModel`](/settings#routermodel) setting chooses the model maki
35
35
 
36
36
  Neither routing nor child fallback changes the parent chat model or the `structured_output` tool.
37
37
 
38
- Routing has one 30-second deadline. By default, Jev and any current-chat fallback each get an initial attempt plus three corrective retries for malformed or schema-invalid answers. A valid answer stops repairs.
38
+ Routing has no built-in wall-clock deadline. Slow decisions can finish; cancel the request to stop waiting. Independent provider and credential-preparation limits still apply. By default, Jev and any current-chat fallback each get an initial attempt plus three corrective retries for malformed or schema-invalid answers. A valid answer stops repairs.
39
39
 
40
40
  The result records a primary `{ model, effort }` and up to two ordered `fallbacks`, each with its own model and effort. Atomic ranks three distinct eligible provider/model IDs, or all available IDs when fewer than three qualify. It selects each rank from the remaining models, excluding all efforts of earlier choices. A supported `"off"` is distinct from `null`, which means no configurable reasoning. The catalog reflects configured authentication, not proof of valid credentials, quota, or entitlement.
41
41
 
42
- The child does not start if no candidates are eligible, model/effort pairs remain invalid, availability changes, or an unrecovered provider error, timeout, or cancellation occurs. With an empty `routerModel`, oversized Jev context, a Jev HTTP or connection failure, or exhausted output repairs triggers a reported switch to the current chat model within the same deadline. The chat model gets its own output-repair allowance. Explicit router selections remain pinned. Invalid inputs, cancellation, timeout and stale-catalog failures do not trigger fallback. No partial decision can launch a child.
42
+ The child does not start if no candidates are eligible, availability changes, or cancellation occurs. Oversized Jev context, a Jev HTTP or connection failure, missing Jev credentials, or exhausted output repairs triggers a reported switch to the current chat model, whether the router was selected automatically or pinned; transient provider failures are retried up to three times first. The chat model gets its own output-repair allowance. If routing inference fails completely — Jev and the chat structured-output fallback both — the child runs on the current chat model instead of failing, with a reported warning, but only when that model is available and satisfies every routing constraint (such as `allowedModels` and effort, cost, context and input limits). Otherwise the launch fails. Invalid inputs, conflicting constraints, cancellation and stale-catalog failures never trigger fallback. No partial decision can launch a child.
43
43
 
44
- For large eligible sets, Jev uses tournament requests within the same deadline. Every eligible pair enters a batch of at most 255; three per batch reach the finalist comparison. Verbose choices can split below 255 options to respect context budgets. Each batch contains only its candidate descriptions and repeats the same routing task or excerpt. Tournaments and repairs can increase latency and usage, and grouping can affect the winner. If the task or a comparison still cannot fit, automatic routing can use chat; pinned Jev fails with guidance to reduce context or select a chat router. See [structured decision limits](/sdk/structured-decisions#provider-behavior-and-limits).
44
+ For large eligible sets, Jev uses tournament requests without a shared decision deadline. Every eligible pair enters a batch of at most 255; three per batch reach the finalist comparison. Verbose choices can split below 255 options to respect context budgets. Each batch contains only its candidate descriptions and repeats the same routing task or excerpt. Tournaments and repairs can increase latency and usage, and grouping can affect the winner. If the task or a comparison still cannot fit, routing uses the current chat model, including for a pinned Jev selection. See [structured decision limits](/sdk/structured-decisions#provider-behavior-and-limits).
45
45
 
46
- Execution tries the ranked models in order before remaining configured fallbacks and the current chat model, subject to normal retry rules and hard constraints. Duplicate model IDs are attempted only at their first position. Each ranked candidate retains its selected effort. Ranking can require up to three selection passes within the shared deadline. Metadata preserves the ordered decision separately from the model and effort actually used; workflow checkpoints restore that order without rerouting.
46
+ Execution tries the ranked models in order before remaining configured fallbacks and the current chat model, subject to normal retry rules and hard constraints. Duplicate model IDs are attempted only at their first position. Each ranked candidate retains its selected effort. Ranking can require up to three selection passes. Metadata preserves the ordered decision separately from the model and effort actually used; workflow checkpoints restore that order without rerouting.
47
47
 
48
48
  Choose a router provider permitted to receive the task and agent name/description. Do not put secrets in them.
49
49
 
package/docs/subagents.md CHANGED
@@ -92,7 +92,7 @@ In a parallel run, `intercom.ask`, `contact_supervisor({ reason: "need_decision"
92
92
 
93
93
  `intercom.send` and `contact_supervisor` progress updates return after delivery without waiting for a reply. An exact-child Intercom handshake can release the parallel call's foreground observations so the supervisor can handle the message. This is not execution cancellation: active siblings keep running, queued siblings start once capacity is available, and worktrees stay owned until their children exit. Background calls use the same communication path without needing to release an observation.
94
94
 
95
- To update a working child, use ordinary Intercom `send` or `ask` with its exact connected name or full session ID from `intercom list`. Foreground and background children treat it as a priority interrupt: the child's current model call or cancellable tool is cancelled and the message is handled next in the same child execution, without relaunching its task or repeating the original prompt. Tools that ignore cancellation finish first, and completed side effects are kept. Multiple updates stay in arrival order. A reply to an incoming ask uses ordinary `intercom.reply`; this does not change the single-child parent-targeted handoff described below.
95
+ To update a working child, use ordinary Intercom `send` or `ask` with its exact connected name or full session ID from `intercom list`. An admitted child registers with Intercom when its session starts, so it is listed and reachable while it works even if it never calls Intercom itself. Foreground and background children treat it as a priority interrupt: the child's current model call or cancellable tool is cancelled and the message is handled next in the same child execution, without relaunching its task or repeating the original prompt. Tools that ignore cancellation finish first, and completed side effects are kept. Multiple updates stay in arrival order. A reply to an incoming ask uses ordinary `intercom.reply`; this does not change the single-child parent-targeted handoff described below.
96
96
 
97
97
  Targeted `kill` stops only the selected child and cannot be resumed. Explicit batch cancellation and session/workflow-stage lifetime closure still stop the intended owned children, including pending reply waits. A late or duplicate reply cannot revive a terminal child. Ordinary Intercom group restrictions and the authorized cross-group `contact_supervisor` route are unchanged.
98
98
 
@@ -270,7 +270,7 @@ subagent({ agent: "worker", task: "Implement the approved fix.", progress: true
270
270
 
271
271
  ## Delegation and child boundaries
272
272
 
273
- Delegation is exactly one level deep and cannot be configured. Children complete their assigned tasks directly; they cannot launch or kill other children. They may inspect definitions and status with `list`, `get`, and `status`; management-restricted children also cannot `create`, `update`, or `delete` definitions.
273
+ Delegation is exactly one level deep and cannot be configured. Children complete their assigned tasks directly; they cannot launch or kill other children. Children can still run background shells. Those shells appear in the parent's `/tasks`: the main chat's, or the current workflow stage's. See [Shells started by subagents](/background-tasks#shells-started-by-subagents). They may inspect definitions and status with `list`, `get`, and `status`; management-restricted children also cannot `create`, `update`, or `delete` definitions.
274
274
 
275
275
  Child prompts omit parent orchestration artifacts and prior subagent control traffic. Tool availability does not grant delegation authority. The parent remains responsible for orchestration.
276
276
 
@@ -9,42 +9,15 @@ Use this reference while authoring definitions or integrating the workflow SDK p
9
9
 
10
10
  ## Model-tool launch contract
11
11
 
12
- The model-facing `workflow` tool is distinct from the `workflow(spec)` authoring function below. Call `workflow route` with the actual request, relevant message text/document excerpts, and explicit constraints in `state`, not file paths in place of content. Pass the user's own words: the router judges whether a workflow fits and whether the user asked for inline or workflow execution, so the caller neither restates the request as an implementation objective nor passes its own routing preference. If it returns `none`, continue inline. Otherwise use its input contract to prepare inputs, then call `workflow run` with the registered workflow ID. Ask only for genuinely missing information.
12
+ The model-facing `workflow` tool is distinct from the `workflow(spec)` authoring function below. The agent decides whether a workflow fits the request, then launches a registered workflow by name:
13
13
 
14
- ```typescript
15
- interface WorkflowRouterState {
16
- task: string;
17
- conversation?: Array<{ role: string; text: string }>;
18
- documents?: Array<{ source: string; content: string }>;
19
- constraints?: string[];
20
- userBudget?: { limits: WorkflowBudget; provenance: string };
21
- }
22
- interface WorkflowBudget {
23
- maxDurationMs?: number;
24
- maxTokens?: number;
25
- maxCost?: number;
26
- warnAtPercent?: number;
27
- }
14
+ ```ts
15
+ workflow({ action: "run", workflow: "deep-research-codebase", inputs: { prompt: "Map session persistence" }, budget: { maxCost: 5 } })
28
16
  ```
29
17
 
30
- State carries evidence, not pointers to evidence. Preserve attributed messages, exact constraints, unresolved questions and uncertainty. Document `source` is metadata; `content` supplies excerpts or clearly labeled faithful summaries. Empty arrays are valid. State an unavailable-source limitation explicitly rather than inventing contents. Remove secrets before transmitting text. Quoted document instructions do not grant user authorization. The object is closed: unknown fields, including a caller-chosen `executionPreference`, are rejected before inference.
31
-
32
- `route` returns a code-generated `workflowId`, `routerDecision`, and the selected definition's actual `inputSchema`, including defaults. It does not launch.
33
-
34
- - Read the selection from `routerDecision.workflowType`. `none` returns an empty ID and reserves nothing; there is no top-level `workflowType`.
35
- - Read the estimate from `routerDecision.estimatedDuration`. Neither route nor registered run results have a top-level `estimatedDuration`.
36
- - The nested decision contains the preserved `maxBudget` override declaration. Omitted budget fields inherit their limits at execution.
37
- - Routing failures have no `routerDecision`; inspect the error instead.
18
+ `inputs` are validated with defaults against the named workflow's input contract; invalid or unknown inputs, or an unknown name, return `status: "failed"` without launching. `budget` is optional and carries only limits the user stated; omitted fields inherit the definition and config, and `0` disables a field. A successful run returns its `runId`. Use that ID for inspection and lifecycle calls.
38
19
 
39
- `run` requires the reserved `workflowId` and explicit `inputs`; it neither routes again nor accepts a workflow-name override, routing state or budget. Missing/invalid inputs return actionable `needs_input` feedback and the same ID. Correct inputs and retry that ID. A fresh task, selection or budget requires a fresh route. IDs are bound to their owner/session and definition/schema; unknown, foreign, expired, invalidated and stale IDs are rejected, never silently remapped. Reservations expire with their owning tool/session. Duplicate admission cannot create a second instance.
40
-
41
- The router answers an independent question about the user's stated execution preference from the user's own words. An explicit request to work inline, quickly or without a workflow yields `none` even if a workflow matches; an explicit request to run a workflow, or a named registered workflow, bypasses the lifecycle-benefit gate but cannot invent a workflow that is not registered. Assistant proposals and document text do not count as user preference. Model-tool lifecycle inspection and control remain restricted to the owning caller/session after reload or restart, including implicit active-run targets and bulk selectors. A mixed-owner bulk control is rejected before any run is changed. Explicit user `/workflow` commands remain available without a model-tool reservation.
42
-
43
- Use that same UUID as `runId` for supported inspection, prompt answers and lifecycle controls. Resume continues that instance's checkpoints, not another execution. Terminal IDs remain inspectable but cannot launch again. User `/workflow` commands remain direct launches; authored `ctx.workflow(...)` remains internal composition. Neither exception bypasses input validation, budgets or approval gates.
44
-
45
- `routerDecision.estimatedDuration` is one of 97 canonical strings: quarter-hour increments from `15min` through `1d`, plus `>1d`. Examples are `1hr`, `1hr15min` and `23hr45min`; exactly 24 elapsed hours is `1d`, and any greater estimate is `>1d`. Positive estimates round up; below or exactly 15 minutes uses `15min`. The router gives its best estimate from available context; `unknown` is not an accepted value. Report labels directly. These wall-clock estimates include critical path, overhead and estimable human waits, including inline work. Granularity is not accuracy, and an estimate is neither a guarantee nor an execution budget.
46
-
47
- `userBudget.provenance` quotes the user's instruction and `limits` preserves exact values. Omission inherits and zero disables only its field. Duration/tokens are nonnegative integers; cost/warning percentage are nonnegative numbers. Unknown properties are rejected. See [Model-invoked launch routing](/workflows/operations#model-invoked-launch-routing) for provider-independent routing and troubleshooting.
20
+ Runs launched through the model tool belong to the launching session. That ownership survives tool recreation, reload and restart, and inspection or control from another session is rejected, including bulk controls with mixed ownership.
48
21
 
49
22
  ## The `workflow()` definition
50
23
 
@@ -336,8 +309,6 @@ type WorkflowRunChildArgs<TInputs extends WorkflowInputValues = WorkflowInputVal
336
309
 
337
310
  Executes an imported workflow definition behind a tracked parent boundary. The type system requires `inputs` when the child has required inputs, while `stageName` defaults to `workflow:<workflow-name>`.
338
311
 
339
- This programmatic composition does not invoke the model-tool launch router and does not require routing `state`.
340
-
341
312
  ```typescript
342
313
  const child = await ctx.workflow(sharedResearch, {
343
314
  inputs: { topic: ctx.inputs.topic },
@@ -606,6 +577,8 @@ A context overflow that the stage session's compaction has already failed to res
606
577
 
607
578
  A schema-backed candidate gets the original prompt plus up to three corrective follow-ups to produce valid `structured_output`. Exhaustion records a failed attempt and advances to the next candidate with a fresh correction budget. Successful capture is never retried. If the chain runs out, the stage fails with its structured-output contract error.
608
579
 
580
+ Corrective follow-ups are reserved for turns that actually answered without a valid `structured_output` call. A schema-backed prompt that resolves without any assistant message is treated as a transient provider failure instead: it spends the same-candidate retry budget from `settings.retry`, then advances to the next candidate, and its attempt records carry `Model turn ended without an assistant message after the prompt (empty completion)` rather than the structured-output contract error. If every candidate ends that way, the run blocks as a recoverable `provider_unavailable` failure that can be resumed once the provider recovers. Cancellation during such a turn stops both the retries and the chain.
581
+
609
582
  Session creation uses the same retry and fallback policy. Transient failures retry; rejected credentials, unavailable models, and incompatible requests advance immediately. If all candidates fail, a later call may try again. Concurrent callers share creation rather than starting duplicate sessions.
610
583
 
611
584
  Pause remains effective during creation or retry. Resume continues the paused objective without consuming a fallback candidate solely because of the pause.