@bastani/atomic 0.10.9 → 0.10.10-alpha.2

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 (406) hide show
  1. package/CHANGELOG.md +83 -0
  2. package/README.md +226 -163
  3. package/dist/_shared/dist-KOELCESV.js +2 -2
  4. package/dist/_shared/fork-row-index-UAUAQRD5.js +2 -2
  5. package/dist/_shared/lib-4PES5P4V.js +2 -2
  6. package/dist/_shared/mode-interactive-sdk-7KXUFI2F.js +27 -12
  7. package/dist/_shared/mode-interactive-sdk-7KXUFI2F.js.map +1 -1
  8. package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +47 -7
  9. package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js.map +1 -1
  10. package/dist/_shared/mode-shared-2QJSCUM6.js +48 -19
  11. package/dist/_shared/mode-shared-2QJSCUM6.js.map +1 -1
  12. package/dist/_shared/{p1a-prewarm-UQY3X2UK.js → p1a-prewarm-XIU57JHF.js} +5 -5
  13. package/dist/_shared/{p1a-prewarm-UQY3X2UK.js.map → p1a-prewarm-XIU57JHF.js.map} +1 -1
  14. package/dist/_shared/p2-shell-main-B2WIALFD.js +30 -25
  15. package/dist/_shared/p2-shell-main-B2WIALFD.js.map +1 -1
  16. package/dist/_shared/runtime-O4KCSG4C.js +5 -5
  17. package/dist/_shared/{sdk-OSBEPR3Q.js → sdk-RRLVN7ER.js} +15 -9
  18. package/dist/_shared/sdk-RRLVN7ER.js.map +1 -0
  19. package/dist/_shared/session-data-AHTU7IS6.js +2 -2
  20. package/dist/_shared/session-manager-list-2BLEEZVG.js +1 -1
  21. package/dist/_shared/settings-startup-8-DNZ2RIHM.js +4 -1
  22. package/dist/_shared/settings-startup-8-DNZ2RIHM.js.map +1 -1
  23. package/dist/_shared/{startup-0-0-TYUFUOJZ.js → startup-0-0-4VG2G44V.js} +427 -33
  24. package/dist/_shared/startup-0-0-4VG2G44V.js.map +1 -0
  25. package/dist/_shared/{startup-0-1-W2G2UY7R.js → startup-0-1-XTIL65D4.js} +18 -11
  26. package/dist/_shared/startup-0-1-XTIL65D4.js.map +1 -0
  27. package/dist/_shared/{startup-0-2-UXBUEOXW.js → startup-0-2-27OWFHV6.js} +150 -62
  28. package/dist/_shared/startup-0-2-27OWFHV6.js.map +1 -0
  29. package/dist/_shared/startup-0-3-T4DVFYWX.js +15 -25
  30. package/dist/_shared/startup-0-3-T4DVFYWX.js.map +1 -1
  31. package/dist/_shared/{startup-0-4-HN5EB4K7.js → startup-0-4-ZMJV547D.js} +81 -12
  32. package/dist/_shared/startup-0-4-ZMJV547D.js.map +1 -0
  33. package/dist/_shared/startup-0-5-FD2P735I.js +90 -50
  34. package/dist/_shared/startup-0-5-FD2P735I.js.map +1 -1
  35. package/dist/_shared/startup-10-0-TDQNBDDL.js +5 -5
  36. package/dist/_shared/startup-12-0-55AAXBJZ.js +13 -7
  37. package/dist/_shared/startup-12-0-55AAXBJZ.js.map +1 -1
  38. package/dist/_shared/startup-14-0-MLX36RBG.js +4 -4
  39. package/dist/_shared/startup-15-0-YUKGAC63.js +4 -4
  40. package/dist/_shared/startup-15-1-4S7FLMNG.js +88 -28
  41. package/dist/_shared/startup-15-1-4S7FLMNG.js.map +1 -1
  42. package/dist/_shared/startup-8-0-34CBHPZH.js +5 -5
  43. package/dist/_shared/startup-8-1-4KANEHRA.js +61 -17
  44. package/dist/_shared/startup-8-1-4KANEHRA.js.map +1 -1
  45. package/dist/_shared/storage-command-7MGXLJGZ.js +4 -4
  46. package/dist/_shared/task-unsaved-answer-VJ2KTB4V.js +2 -2
  47. package/dist/_shared/tree-outline-MUEPK5B7.js +2 -2
  48. package/dist/builtin/intercom/CHANGELOG.md +6 -0
  49. package/dist/builtin/intercom/README.md +87 -116
  50. package/dist/builtin/intercom/broker/broker.bundle.mjs +3 -3
  51. package/dist/builtin/intercom/broker/presence-handler.ts +1 -1
  52. package/dist/builtin/intercom/group.ts +7 -3
  53. package/dist/builtin/intercom/index.bundle.mjs +1 -1
  54. package/dist/builtin/intercom/package.json +1 -1
  55. package/dist/builtin/mcp/README.md +61 -27
  56. package/dist/builtin/mcp/index.bundle.mjs +1 -1
  57. package/dist/builtin/mcp/package.json +1 -1
  58. package/dist/builtin/subagents/CHANGELOG.md +8 -0
  59. package/dist/builtin/subagents/README.md +74 -141
  60. package/dist/builtin/subagents/package.json +1 -1
  61. package/dist/builtin/subagents/src/extension/index.bundle.mjs +213 -74
  62. package/dist/builtin/web-access/CHANGELOG.md +9 -0
  63. package/dist/builtin/web-access/README.md +61 -88
  64. package/dist/builtin/web-access/index.bundle.mjs +387 -351
  65. package/dist/builtin/web-access/package.json +1 -1
  66. package/dist/cli/args.js +2 -2
  67. package/dist/cli/auth-cli.code.js +4 -4
  68. package/dist/cli/auth-cli.impl.js +3 -3
  69. package/dist/cli/auth-cli.js +3 -3
  70. package/dist/cli/blueprint-command.code.js +2 -2
  71. package/dist/cli/blueprint-command.impl.js +3 -3
  72. package/dist/cli/blueprint-command.js +3 -3
  73. package/dist/cli/intercom-command.code.js +3 -3
  74. package/dist/cli/intercom-command.impl.js +3 -3
  75. package/dist/cli/intercom-command.js +3 -3
  76. package/dist/cli/list-models.code.js +3 -3
  77. package/dist/cli/list-models.impl.js +3 -3
  78. package/dist/cli/list-models.js +3 -3
  79. package/dist/cli/session-picker.code.js +2 -2
  80. package/dist/cli/session-picker.impl.js +3 -3
  81. package/dist/cli/session-picker.js +3 -3
  82. package/dist/cli/startup-ui.code.js +2 -2
  83. package/dist/cli/startup-ui.impl.js +3 -3
  84. package/dist/cli/startup-ui.js +3 -3
  85. package/dist/cli/storage-command.impl.js +3 -3
  86. package/dist/cli/storage-command.js +3 -3
  87. package/dist/cli/storage-search-session.code.js +2 -2
  88. package/dist/cli/storage-search-session.impl.js +3 -3
  89. package/dist/cli/storage-search-session.js +3 -3
  90. package/dist/cli/team-command.code.js +2 -2
  91. package/dist/cli/team-command.impl.js +3 -3
  92. package/dist/cli/team-command.js +3 -3
  93. package/dist/cli.js +2 -2
  94. package/dist/core/agent-session-methods.d.ts +4 -1
  95. package/dist/core/agent-session-methods.js.map +1 -1
  96. package/dist/core/agent-session.d.ts +3 -0
  97. package/dist/core/compaction/compactor.d.ts +20 -14
  98. package/dist/core/compaction/errors.d.ts +120 -0
  99. package/dist/core/compaction/index.d.ts +1 -0
  100. package/dist/core/compaction/model-resolver.d.ts +2 -2
  101. package/dist/core/debug.impl.js +3 -3
  102. package/dist/core/debug.js +3 -3
  103. package/dist/core/export-html/card-projection.impl.js +3 -3
  104. package/dist/core/export-html/card-projection.js +3 -3
  105. package/dist/core/export-html/index.code.js +2 -2
  106. package/dist/core/export-html/index.impl.js +3 -3
  107. package/dist/core/export-html/index.js +3 -3
  108. package/dist/core/export-html/json-spans.impl.js +3 -3
  109. package/dist/core/export-html/json-spans.js +3 -3
  110. package/dist/core/export-html/oversized-render-inputs.impl.js +3 -3
  111. package/dist/core/export-html/oversized-render-inputs.js +3 -3
  112. package/dist/core/export-html/tool-renderer.code.js +1 -1
  113. package/dist/core/export-html/tool-renderer.impl.js +3 -3
  114. package/dist/core/export-html/tool-renderer.js +3 -3
  115. package/dist/core/extensions/api-types.d.ts +1 -1
  116. package/dist/core/extensions/api-types.js.map +1 -1
  117. package/dist/core/extensions/index.d.ts +1 -1
  118. package/dist/core/extensions/jiti-loader.impl.js +3 -3
  119. package/dist/core/extensions/jiti-loader.js +3 -3
  120. package/dist/core/extensions/jiti-static-loader.impl.js +3 -3
  121. package/dist/core/extensions/jiti-static-loader.js +3 -3
  122. package/dist/core/extensions/loader-host-modules.code.js +1 -1
  123. package/dist/core/extensions/loader-host-modules.impl.js +3 -3
  124. package/dist/core/extensions/loader-host-modules.js +3 -3
  125. package/dist/core/extensions/loader-virtual-modules.js +1 -1
  126. package/dist/core/extensions/provider-types.d.ts +18 -6
  127. package/dist/core/extensions/provider-types.js.map +1 -1
  128. package/dist/core/extensions/runner-context.js +1 -1
  129. package/dist/core/intercom-broker-control-host.code.js +1 -1
  130. package/dist/core/intercom-broker-control-host.impl.js +3 -3
  131. package/dist/core/intercom-broker-control-host.js +3 -3
  132. package/dist/core/intercom-broker-control.code.js +3 -3
  133. package/dist/core/intercom-broker-control.impl.js +3 -3
  134. package/dist/core/intercom-broker-control.js +3 -3
  135. package/dist/core/model-config.d.ts +40 -0
  136. package/dist/core/model-registry.js +1 -1
  137. package/dist/core/model-resolver-scope.d.ts +4 -4
  138. package/dist/core/model-runtime.d.ts +1 -1
  139. package/dist/core/package-manager-storage-adapters.impl.js +3 -3
  140. package/dist/core/package-manager-storage-adapters.js +3 -3
  141. package/dist/core/provider-composer-internal.d.ts +11 -2
  142. package/dist/core/sdk.code.js +3 -3
  143. package/dist/core/sdk.impl.js +3 -3
  144. package/dist/core/sdk.js +3 -3
  145. package/dist/core/session-manager-core.js +5 -5
  146. package/dist/core/session-manager-list.impl.js +3 -3
  147. package/dist/core/session-manager-list.js +3 -3
  148. package/dist/core/session-manager.code.js +1 -1
  149. package/dist/core/session-manager.impl.js +3 -3
  150. package/dist/core/session-manager.js +3 -3
  151. package/dist/core/session-storage.impl.js +3 -3
  152. package/dist/core/session-storage.js +3 -3
  153. package/dist/core/settings-manager-basic-accessors.d.ts +6 -2
  154. package/dist/core/storage/index.js +2 -2
  155. package/dist/core/storage/node-sqlite-thread.js +2 -2
  156. package/dist/core/storage/node-sqlite.js +2 -2
  157. package/dist/core/storage/offline-snapshot-file.impl.js +3 -3
  158. package/dist/core/storage/offline-snapshot-file.js +3 -3
  159. package/dist/core/storage/provider.js +2 -2
  160. package/dist/core/storage/selection.js +2 -2
  161. package/dist/core/storage/session/branch-fork-source.code.js +2 -2
  162. package/dist/core/storage/session/branch-fork-source.impl.js +3 -3
  163. package/dist/core/storage/session/branch-fork-source.js +3 -3
  164. package/dist/core/storage/session/card-view.impl.js +3 -3
  165. package/dist/core/storage/session/card-view.js +3 -3
  166. package/dist/core/storage/session/child-reader.code.js +3 -3
  167. package/dist/core/storage/session/child-reader.impl.js +3 -3
  168. package/dist/core/storage/session/child-reader.js +3 -3
  169. package/dist/core/storage/session/chunked-resume-projection.impl.js +3 -3
  170. package/dist/core/storage/session/chunked-resume-projection.js +3 -3
  171. package/dist/core/storage/session/expanded-child-details.code.js +2 -2
  172. package/dist/core/storage/session/expanded-child-details.impl.js +3 -3
  173. package/dist/core/storage/session/expanded-child-details.js +3 -3
  174. package/dist/core/storage/session/fork-row-bytes.impl.js +3 -3
  175. package/dist/core/storage/session/fork-row-bytes.js +3 -3
  176. package/dist/core/storage/session/fork-row-index.impl.js +3 -3
  177. package/dist/core/storage/session/fork-row-index.js +3 -3
  178. package/dist/core/storage/session/fork-staging.code.js +2 -2
  179. package/dist/core/storage/session/fork-staging.impl.js +3 -3
  180. package/dist/core/storage/session/fork-staging.js +3 -3
  181. package/dist/core/storage/session/fork-window.code.js +3 -3
  182. package/dist/core/storage/session/fork-window.impl.js +3 -3
  183. package/dist/core/storage/session/fork-window.js +3 -3
  184. package/dist/core/storage/session/history-pages.impl.js +3 -3
  185. package/dist/core/storage/session/history-pages.js +3 -3
  186. package/dist/core/storage/session/jsonl-entry-projection.impl.js +3 -3
  187. package/dist/core/storage/session/jsonl-entry-projection.js +3 -3
  188. package/dist/core/storage/session/jsonl-session-store.impl.js +3 -3
  189. package/dist/core/storage/session/jsonl-session-store.js +3 -3
  190. package/dist/core/storage/session/memory-session-store.impl.js +3 -3
  191. package/dist/core/storage/session/memory-session-store.js +3 -3
  192. package/dist/core/storage/session/pinned-branch-resume.code.js +3 -3
  193. package/dist/core/storage/session/pinned-branch-resume.impl.js +3 -3
  194. package/dist/core/storage/session/pinned-branch-resume.js +3 -3
  195. package/dist/core/storage/session/released-history-files.code.js +3 -3
  196. package/dist/core/storage/session/released-history-files.impl.js +3 -3
  197. package/dist/core/storage/session/released-history-files.js +3 -3
  198. package/dist/core/storage/session/resident-fork-rows.impl.js +3 -3
  199. package/dist/core/storage/session/resident-fork-rows.js +3 -3
  200. package/dist/core/storage/session/session-resume.impl.js +3 -3
  201. package/dist/core/storage/session/session-resume.js +3 -3
  202. package/dist/core/storage/session/snapshot-cut.impl.js +3 -3
  203. package/dist/core/storage/session/snapshot-cut.js +3 -3
  204. package/dist/core/storage/session/snapshot-history.code.js +3 -3
  205. package/dist/core/storage/session/snapshot-history.impl.js +3 -3
  206. package/dist/core/storage/session/snapshot-history.js +3 -3
  207. package/dist/core/storage/session/sql-session-store.code.js +1 -1
  208. package/dist/core/storage/session/sql-session-store.impl.js +3 -3
  209. package/dist/core/storage/session/sql-session-store.js +3 -3
  210. package/dist/core/storage/session/tree-outline.impl.js +3 -3
  211. package/dist/core/storage/session/tree-outline.js +3 -3
  212. package/dist/core/storage/session/tree-presentation.impl.js +3 -3
  213. package/dist/core/storage/session/tree-presentation.js +3 -3
  214. package/dist/core/storage/storage-status.impl.js +3 -3
  215. package/dist/core/storage/storage-status.js +3 -3
  216. package/dist/core/storage/team.impl.js +3 -3
  217. package/dist/core/storage/team.js +3 -3
  218. package/dist/core/structured-output/index.code.js +1 -1
  219. package/dist/core/structured-output/index.impl.js +3 -3
  220. package/dist/core/structured-output/index.js +3 -3
  221. package/dist/core/tasks/task-completion-entry.impl.js +3 -3
  222. package/dist/core/tasks/task-completion-entry.js +3 -3
  223. package/dist/core/tasks/task-file-history.code.js +3 -3
  224. package/dist/core/tasks/task-file-history.impl.js +3 -3
  225. package/dist/core/tasks/task-file-history.js +3 -3
  226. package/dist/core/tasks/task-reference-archive.code.js +4 -4
  227. package/dist/core/tasks/task-reference-archive.js +3 -3
  228. package/dist/core/tasks/task-reference-identity.code.js +1 -1
  229. package/dist/core/tasks/task-reference-identity.js +3 -3
  230. package/dist/core/tasks/task-reference-stream.impl.js +3 -3
  231. package/dist/core/tasks/task-reference-stream.js +3 -3
  232. package/dist/core/tasks/task-unsaved-answer.impl.js +3 -3
  233. package/dist/core/tasks/task-unsaved-answer.js +3 -3
  234. package/dist/core/tasks/task-view-source.impl.js +3 -3
  235. package/dist/core/tasks/task-view-source.js +3 -3
  236. package/dist/core/tools/read-url.code.js +2 -2
  237. package/dist/core/tools/read-url.impl.js +3 -3
  238. package/dist/core/tools/read-url.js +3 -3
  239. package/dist/core/worktree-snapshot/blob-store.js +2 -2
  240. package/dist/core/worktree-snapshot/errors.code.js +3 -3
  241. package/dist/core/worktree-snapshot/errors.impl.js +3 -3
  242. package/dist/core/worktree-snapshot/errors.js +3 -3
  243. package/dist/core/worktree-snapshot/session-index-reset.impl.js +3 -3
  244. package/dist/core/worktree-snapshot/session-index-reset.js +3 -3
  245. package/dist/extensions/codemode/execute.code.js +1 -1
  246. package/dist/extensions/codemode/execute.impl.js +3 -3
  247. package/dist/extensions/codemode/execute.js +3 -3
  248. package/dist/extensions/codemode/renderer.code.js +2 -2
  249. package/dist/extensions/codemode/renderer.impl.js +3 -3
  250. package/dist/extensions/codemode/renderer.js +3 -3
  251. package/dist/extensions/mcp/cli.code.js +2 -2
  252. package/dist/extensions/mcp/cli.impl.js +3 -3
  253. package/dist/extensions/mcp/cli.js +3 -3
  254. package/dist/extensions/mcp/cli.lazy.code.js +2 -2
  255. package/dist/extensions/mcp/cli.lazy.impl.js +3 -3
  256. package/dist/extensions/mcp/cli.lazy.js +3 -3
  257. package/dist/extensions/mcp/runtime.code.js +1 -1
  258. package/dist/extensions/mcp/runtime.impl.js +3 -3
  259. package/dist/extensions/mcp/runtime.js +3 -3
  260. package/dist/index-extensions.d.ts +1 -1
  261. package/dist/index.d.ts +8 -1
  262. package/dist/index.js +7 -7
  263. package/dist/main-first-time-setup.code.js +2 -2
  264. package/dist/main-first-time-setup.impl.js +3 -3
  265. package/dist/main-first-time-setup.js +3 -3
  266. package/dist/modes/interactive/components/settings-selector-types.d.ts +1 -0
  267. package/dist/modes/interactive/components/settings-selector-types.js.map +1 -1
  268. package/dist/modes/interactive/components/stored-tree-view.code.js +2 -2
  269. package/dist/modes/interactive/components/stored-tree-view.impl.js +3 -3
  270. package/dist/modes/interactive/components/stored-tree-view.js +3 -3
  271. package/dist/modes/interactive/components/user-message-selector-archive.impl.js +3 -3
  272. package/dist/modes/interactive/components/user-message-selector-archive.js +3 -3
  273. package/dist/modes/interactive/theme/color-utils.d.ts +5 -5
  274. package/dist/modes/interactive/theme/theme-loading.d.ts +1 -0
  275. package/dist/modes/interactive-engine/engine-prewarm.js +1 -1
  276. package/dist/modes/interactive-engine/remote-model-catalog.d.ts +1 -0
  277. package/dist/modes/print-mode.js +1 -1
  278. package/dist/modes/rpc/rpc-client-api.d.ts +6 -0
  279. package/dist/modes/rpc/rpc-types.d.ts +29 -2
  280. package/dist/package-manager-cli.code.js +5 -5
  281. package/dist/package-manager-cli.impl.js +3 -3
  282. package/dist/package-manager-cli.js +3 -3
  283. package/dist/rpc-entry.js +1 -1
  284. package/dist/startup-files.json +1 -1
  285. package/dist/startup-stages/5.js +1 -1
  286. package/dist/startup-stages/7.js +1 -1
  287. package/dist/startup-stages/8.js +1 -2
  288. package/dist/startup-stages/9.js +2 -1
  289. package/dist/utils/native-module.d.ts +44 -0
  290. package/dist/utils/startup-database-spare.code.js +3 -3
  291. package/dist/utils/startup-database-spare.impl.js +3 -3
  292. package/dist/utils/startup-database-spare.js +3 -3
  293. package/dist/utils/tools-manager.code.js +1 -1
  294. package/dist/utils/tools-manager.impl.js +3 -3
  295. package/dist/utils/tools-manager.js +3 -3
  296. package/docs/background-tasks.md +238 -243
  297. package/docs/build.md +21 -15
  298. package/docs/changelog.mdx +1 -1
  299. package/docs/codemode.md +68 -51
  300. package/docs/compaction/reference.md +65 -26
  301. package/docs/compaction.md +118 -66
  302. package/docs/computer-use.md +179 -146
  303. package/docs/containerization.md +87 -33
  304. package/docs/custom-provider/api-reference.md +152 -13
  305. package/docs/custom-provider/oauth.md +45 -28
  306. package/docs/custom-provider/override.md +14 -7
  307. package/docs/custom-provider/registration.md +77 -67
  308. package/docs/custom-provider/streaming.md +42 -19
  309. package/docs/custom-provider.md +26 -62
  310. package/docs/development.md +81 -42
  311. package/docs/docs.json +54 -38
  312. package/docs/environment-variables.md +92 -64
  313. package/docs/extensions/api-reference.md +326 -735
  314. package/docs/extensions/authoring.md +186 -269
  315. package/docs/extensions/events.md +308 -375
  316. package/docs/extensions/examples.md +122 -74
  317. package/docs/extensions/ui.md +217 -197
  318. package/docs/extensions.md +189 -259
  319. package/docs/getting-started/authentication.md +27 -14
  320. package/docs/getting-started/first-session.md +25 -26
  321. package/docs/getting-started/installation.md +62 -84
  322. package/docs/getting-started/project-instructions.md +39 -14
  323. package/docs/guides/configuration.md +62 -20
  324. package/docs/guides/intercom.md +20 -12
  325. package/docs/guides/non-interactive.md +31 -16
  326. package/docs/guides/orchestration.md +17 -9
  327. package/docs/guides/resume-on-any-machine.md +63 -52
  328. package/docs/guides/subagents.md +26 -14
  329. package/docs/guides/team-setup.md +49 -27
  330. package/docs/guides.md +30 -23
  331. package/docs/herdr.md +22 -17
  332. package/docs/index.md +24 -17
  333. package/docs/intercom/operations.md +90 -66
  334. package/docs/intercom/reference.md +219 -192
  335. package/docs/intercom.md +111 -92
  336. package/docs/json.md +73 -71
  337. package/docs/keybindings.md +74 -48
  338. package/docs/libraries/agent-core.md +52 -9
  339. package/docs/libraries/ai.md +90 -63
  340. package/docs/libraries/codemode.md +31 -8
  341. package/docs/libraries/schema.md +12 -9
  342. package/docs/libraries/storage-libsql.md +92 -0
  343. package/docs/libraries/storage-postgres.md +119 -0
  344. package/docs/libraries/telemetry.md +42 -9
  345. package/docs/libraries/tui.md +74 -94
  346. package/docs/libraries.md +25 -8
  347. package/docs/llama-cpp.md +38 -33
  348. package/docs/mcp-servers.md +140 -88
  349. package/docs/models/reference.md +53 -36
  350. package/docs/models-configuration.md +19 -13
  351. package/docs/models.md +102 -87
  352. package/docs/orchestration/migrating-workflows.md +22 -20
  353. package/docs/orchestration/patterns.md +36 -21
  354. package/docs/orchestration.md +24 -21
  355. package/docs/packages/authoring.md +29 -18
  356. package/docs/packages/reference.md +77 -16
  357. package/docs/packages.md +34 -34
  358. package/docs/programmatic.md +28 -21
  359. package/docs/prompt-templates.md +65 -41
  360. package/docs/providers/reference.md +36 -20
  361. package/docs/providers.md +78 -76
  362. package/docs/quickstart.md +42 -54
  363. package/docs/reference/cli.md +256 -254
  364. package/docs/reference.md +30 -23
  365. package/docs/rpc/examples.md +121 -17
  366. package/docs/rpc/extension-ui.md +86 -63
  367. package/docs/rpc/protocol.md +817 -358
  368. package/docs/rpc.md +78 -152
  369. package/docs/sdk/reference.md +309 -73
  370. package/docs/sdk/storage.md +614 -0
  371. package/docs/sdk/structured-decisions.md +168 -65
  372. package/docs/sdk/web-server.md +80 -46
  373. package/docs/sdk.md +168 -215
  374. package/docs/security.md +117 -44
  375. package/docs/session-format.md +127 -76
  376. package/docs/sessions.md +155 -113
  377. package/docs/settings.md +293 -205
  378. package/docs/shell-aliases.md +15 -6
  379. package/docs/skills/authoring.md +17 -9
  380. package/docs/skills/reference.md +23 -21
  381. package/docs/skills.md +148 -97
  382. package/docs/storage.md +172 -260
  383. package/docs/subagents/authoring.md +148 -15
  384. package/docs/subagents/reference.md +105 -29
  385. package/docs/subagents.md +247 -250
  386. package/docs/terminal-setup.md +97 -69
  387. package/docs/termux.md +51 -85
  388. package/docs/themes/reference.md +51 -37
  389. package/docs/themes.md +52 -55
  390. package/docs/tmux.md +38 -21
  391. package/docs/tools.md +209 -147
  392. package/docs/tui/reference.md +64 -32
  393. package/docs/tui.md +38 -66
  394. package/docs/usage.md +94 -86
  395. package/docs/verification.md +25 -25
  396. package/docs/web-access.md +106 -54
  397. package/docs/windows.md +55 -57
  398. package/docs/worktree-snapshots.md +82 -74
  399. package/examples/sdk/11-sessions.ts +4 -4
  400. package/package.json +8 -8
  401. package/schemas/models.schema.json +58 -7
  402. package/dist/_shared/sdk-OSBEPR3Q.js.map +0 -1
  403. package/dist/_shared/startup-0-0-TYUFUOJZ.js.map +0 -1
  404. package/dist/_shared/startup-0-1-W2G2UY7R.js.map +0 -1
  405. package/dist/_shared/startup-0-2-UXBUEOXW.js.map +0 -1
  406. package/dist/_shared/startup-0-4-HN5EB4K7.js.map +0 -1
@@ -1,33 +1,41 @@
1
1
  ---
2
- title: Structured decisions
3
- description: Make a schema-validated structured decision without starting an agent session.
2
+ title: "Structured decisions API"
3
+ sidebarTitle: "Structured decisions"
4
+ description: "Make typed, schema-validated classifier or chat model decisions with decide() and generateStructuredOutput() without starting an agent session."
4
5
  ---
5
6
 
6
- # Structured decisions
7
+ Atomic provides one decision service across three entry points:
7
8
 
8
- Atomic provides one decision service. [`decide()`](#decide) asks the configured [`decisionModel`](/settings#decisionmodel) typed questions and returns typed answers with optional probabilities. The `structured_output` tool uses the same decision model and raises `DecisionError` subclasses on failure. `generateStructuredOutput()` from `@bastani/atomic` makes one schema-validated decision on the models you name through the same engine.
9
+ - [`decide()`](#decide) asks the configured [`decisionModel`](/settings#decisionmodel) typed `choice`, `bool`, and `score` questions and returns typed answers with optional probabilities.
10
+ - The `structured_output` tool uses the same decision model and raises `DecisionError` subclasses on failure.
11
+ - `generateStructuredOutput()` from `@bastani/atomic` makes one schema-validated decision on the models you pass through the same runtime.
9
12
 
10
- None of these APIs starts a child agent, executes other tools, authorizes an action, or changes the selected chat model.
13
+ None of these APIs starts a child agent, invokes other tools, authorizes an action, or changes the selected chat model.
11
14
 
12
- ## decide
15
+ ## Make typed decisions with `decide()` {#decide}
13
16
 
14
- `decide({ state, questions, deadline })` asks independent questions about one state in one request:
17
+ `decide({ state, questions, settings, modelRegistry, currentModel, ... })` evaluates one or more independent named questions against one `state` object in a single request:
15
18
 
16
- - `choice`: pick one option. `criteria` maps each option to its meaning.
17
- - `bool`: a yes/no question (a Noul). `criteria` defines what `true` and `false` mean.
18
- - `score`: grade on ordered levels. `criteria` lists at least two levels, lowest first.
19
+ - `choice`: pick one option. `criteria` maps each option name to its meaning.
20
+ - `bool`: a yes/no question. `criteria` defines what `true` and `false` mean.
21
+ - `score`: grade on ordered levels. `criteria` lists at least two level descriptions, lowest first.
19
22
 
20
- `decide()` resolves `decisionModel` once. When a classifier answers, it returns each Choice option's probability and confidence, the probability of `true` for a `bool`, and the score's confidence for a `score`.
23
+ `decide()` resolves `decisionModel` once. When a classifier answers, `source` is `"classifier"` and answers include probabilities and confidence scores. If the classifier fails, the current chat model answers without probabilities, sets `source: "chat"`, and populates `result.fallback`. An empty or `"auto"` `decisionModel` uses `currentModel` directly. Pass `requireProbabilities: true` to restrict answers to classifiers so chat models or classifier failures reject instead of falling back.
21
24
 
22
- If the classifier fails, the current chat model answers without probabilities, sets `source: "chat"`, and includes a `fallback` object. An empty or `"auto"` `decisionModel` uses the current chat model directly. Pass `requireProbabilities: true` when your code requires probabilities: only a classifier may answer, and a chat decision model or classifier failure rejects instead of falling back.
25
+ Standalone SDK usage with `ModelRuntime`, `ModelRegistry`, and `SettingsManager`:
23
26
 
24
27
  ```typescript
25
- import { decide, isDecisionError } from "@bastani/atomic";
28
+ import { decide, ModelRegistry, ModelRuntime, SettingsManager } from "@bastani/atomic";
29
+
30
+ const modelRuntime = await ModelRuntime.create();
31
+ const modelRegistry = new ModelRegistry(modelRuntime);
32
+ const settings = await SettingsManager.createAsync(process.cwd());
33
+ const currentModel = modelRegistry.getAvailable()[0];
26
34
 
27
35
  const result = await decide({
28
- settings: { getDecisionModel: () => ctx.getDecisionModel() },
29
- modelRegistry: ctx.modelRegistry,
30
- currentModel: ctx.model,
36
+ settings,
37
+ modelRegistry,
38
+ currentModel,
31
39
  state: { message: "Ship it once the tests pass." },
32
40
  questions: {
33
41
  intent: {
@@ -44,63 +52,160 @@ const result = await decide({
44
52
  deadline: 30_000,
45
53
  requireProbabilities: true,
46
54
  });
55
+
47
56
  const approve = result.answers.intent.probabilities?.approve ?? 0;
48
57
  if (approve >= 0.9 && (result.answers.complete.probability ?? 0) >= 0.8) {
49
- // Code decides what to do at each threshold.
58
+ // Application code decides what to do at each threshold.
50
59
  }
51
60
  ```
52
61
 
53
- Keep control in application code. Compare each option's probability against a threshold per action, require a higher bar for irreversible actions, and route low-confidence cases to a person or a slower step. A `choice` question always selects one option even when none fits, so pair it with a `bool` question that checks applicability.
62
+ Inside an extension handler, pass `settings: { getDecisionModel: () => ctx.getDecisionModel() }`, `modelRegistry: ctx.modelRegistry`, and `currentModel: ctx.model`. To override `decisionModel` without reading settings files, pass `SettingsManager.inMemory({ decisionModel: "typesafe/jev-latest" })` or pass `model: "typesafe/jev-latest"` directly on the request.
54
63
 
55
- `decide()` never caches; cache results in your code when needed. Extensions read the setting with `ctx.getDecisionModel()`. Import `decide` from `@bastani/atomic`.
64
+ ### Request options
56
65
 
57
- - `deadline`: wall-clock limit in milliseconds for the entire decision, including credential screening, requests, retries, repairs, and fallbacks. Defaults to [`httpIdleTimeoutMs`](/settings#http).
58
- - `signal`: cancels the decision and rejects with the signal's reason.
59
- - `model`: names an exact `provider/model` ID to use instead of `decisionModel`.
60
- - Credential screening: Atomic refuses `state` containing an environment credential, key-shaped text, or a saved credential known to `modelRegistry` before sending any model request. Atomic copies `state` before asynchronous screening, so mutating the caller's object later does not alter an in-flight decision.
66
+ - `state`: non-empty plain JSON object containing the facts to evaluate.
67
+ - `questions`: non-empty record mapping caller-chosen IDs to `choice`, `bool`, or `score` question definitions.
68
+ - `instructions`: optional top-level context shared across all questions. Defaults to ``"Answer each question about `state`."`` and must be non-blank if supplied.
69
+ - `deadline`: optional positive integer wall-clock limit in milliseconds covering credential screening, requests, retries, repairs, and fallbacks. Defaults to [`httpIdleTimeoutMs`](/settings#http).
70
+ - `retry`: optional `RetryPolicy` overriding default chat retries (`{ enabled: true, maxRetries: 3, baseDelayMs: 2000 }`).
71
+ - `signal`: optional `AbortSignal`; cancellation rejects immediately with the signal's reason.
72
+ - `model`: optional exact `provider/model` ID to use instead of `decisionModel`.
73
+ - `requireProbabilities`: when `true`, only a classifier may answer.
61
74
 
62
- ### Errors
75
+ ### Return value (`DecisionResult`)
76
+
77
+ `decide()` resolves with:
63
78
 
64
- Every failure rejects with a `DecisionError`. Branch on the error class or `code`, never on the message text.
79
+ ```typescript
80
+ interface DecisionResult<Q> {
81
+ answers: Record<keyof Q, DecisionAnswer>;
82
+ source: "classifier" | "chat";
83
+ model: string;
84
+ responseModel: string;
85
+ usage: { inputTokens: number; outputTokens: number };
86
+ fallback?: { from: string; to: string; reason: string };
87
+ }
88
+ ```
89
+
90
+ Each entry in `result.answers.<id>` matches its question type:
91
+
92
+ - **`choice`:** `{ type: "choice", choice: string, probabilities?: Record<string, number>, confidence?: number }`.
93
+ - **`bool`:** `{ type: "bool", value: boolean, probability?: number }`. When a classifier answers, `value` is `probability >= 0.5`.
94
+ - **`score`:** `{ type: "score", score: number, confidence?: number }`. Levels are 0-indexed from `0` to `criteria.length - 1`: chat models return an integer index, while classifiers return a numeric score (rounded during validation).
65
95
 
66
- Each error carries `hint`, `retryable`, and the underlying `cause`. `isDecisionError(error)` and the per-class guards also recognize errors that crossed a process boundary. Use `serializeDecisionError()` and `rehydrateDecisionError()` to transport errors across boundaries, and `findDecisionError(error)` or `isRetryableDecisionError(error)` to search a cause chain.
96
+ Keep action logic in application code. Compare probabilities against per-action thresholds, require stricter thresholds for irreversible actions, and pair `choice` questions with a `bool` applicability check (because `choice` always picks one option). `decide()` never caches results; cache them yourself if needed.
67
97
 
68
- For untrusted error data from another process, validate with `parseSerializedDecisionError()` before calling `rehydrateDecisionError()`. It returns `undefined` when a known error's code or fields are malformed.
98
+ ### Credential screening boundary
69
99
 
70
- Legacy `routerModel` settings migrate to `decisionModel` automatically without raising a configuration error. An existing `decisionModel` takes precedence, and invalid legacy values are ignored with a one-time warning. See [decisionModel](/settings#decisionmodel).
100
+ `decide()` actively screens `state` before sending any request. It snapshots `state` (so later caller mutations cannot alter an in-flight call) and rejects with `DecisionRequestError` (`reason: "credential-in-state"`) if `state` contains:
101
+
102
+ - any known environment credential,
103
+ - `Bearer` tokens, PEM private keys, or `sk-`, `ghp_`, or `github_pat_` key patterns, or
104
+ - a credential configured in `modelRegistry`.
105
+
106
+ `generateStructuredOutput()` does **not** run automatic credential screening. Always strip secrets from `state` and `instructions` yourself before calling `generateStructuredOutput()`.
107
+
108
+ ### Errors
71
109
 
72
- | Class | Code | When | Fields | What to do |
110
+ Every failure from `decide()` rejects with a `DecisionError`. Branch on the error class or `code`, never on message text.
111
+
112
+ Each error includes `hint`, `retryable`, and `cause`. `isDecisionError(error)` and the per-class guards recognize errors across process boundaries. Use `serializeDecisionError()` and `rehydrateDecisionError()` to transport errors between processes, and `findDecisionError(error)` or `isRetryableDecisionError(error)` to walk a `cause` chain. Validate untrusted serialized payloads with `parseSerializedDecisionError()` before calling `rehydrateDecisionError()` (returns `undefined` when malformed).
113
+
114
+ Legacy `routerModel` settings migrate to `decisionModel` automatically. An existing `decisionModel` takes precedence, and invalid legacy values are ignored with a one-time warning. See [decisionModel](/settings#decisionmodel).
115
+
116
+ | Class | `code` | When | Fields | What to do |
73
117
  | --- | --- | --- | --- | --- |
74
- | `DecisionConfigError` | `invalid-setting` | `decisionModel` is not a string or has surrounding whitespace | `source`, `field` | Set an exact `provider/model`, `auto` or `""`. |
75
- | `DecisionRequestError` | `invalid-request` | Empty or non-JSON `state`, credential in `state`, no questions, a malformed question, blank `instructions`, a bad `deadline` or `model` | `field`, `reason` | Fix the request; nothing was sent. |
76
- | `DecisionModelUnavailableError` | `model-unavailable` | `decisionModel` is not a registered chat or classifier model (`not-in-catalog`), no chat model is selected (`no-chat-model`), probabilities are required from a chat model (`no-probabilities`), or the extension host provides no decision model or model registry (`host-unsupported`) | `reason`, `model` | Choose another decision model or select a chat model; for `host-unsupported`, run in an Atomic session. |
77
- | `DecisionTimeoutError` | `timeout` | The deadline passed | `timeoutMs`, `elapsedMs`, `phase`, `attempts` | Retry, or allow a longer deadline. Retryable. |
78
- | `DecisionOutputError` | `invalid-output` | The model answered, but no answer satisfied the questions after repairs | `model`, `detail` | Make the questions unambiguous or choose another model. |
79
- | `DecisionProviderError` | `provider-failure` | The model's request failed | `model`, `providerStatus`, `providerCode`, `retryAfterMs`, `detail` | Retryable for a rate limit or exhausted quota (`providerCode`); otherwise check the provider. |
118
+ | `DecisionConfigError` | `invalid-setting` (or legacy decode-only `renamed-setting`) | `decisionModel` is not a string or has surrounding whitespace | `source`, `field`, optional `scope` (`"global" \| "project"`) | Set an exact `provider/model`, `"auto"`, or `""`. |
119
+ | `DecisionRequestError` | `invalid-request` | Empty or non-JSON `state`, credential in `state`, no questions, malformed question, blank `instructions`, invalid `deadline`, or invalid `model` | `field`, `reason` | Fix the request; nothing was sent. |
120
+ | `DecisionModelUnavailableError` | `model-unavailable` | `decisionModel` is not a registered chat or classifier model (`not-in-catalog`), no chat model is selected (`no-chat-model`), probabilities are required from a chat model (`no-probabilities`), or the host provides no decision model or registry (`host-unsupported`) | `reason`, `model` | Choose another decision model or select a chat model. |
121
+ | `DecisionTimeoutError` | `timeout` | The wall-clock deadline expired | `timeoutMs`, `elapsedMs`, `phase`, `attempts` | Retry, or raise `deadline` / `timeoutMs`. Retryable. |
122
+ | `DecisionOutputError` | `invalid-output` | The model responded, but output failed schema validation after repairs | `model`, `detail` | Clarify questions or pick another model. |
123
+ | `DecisionProviderError` | `provider-failure` | The provider request failed | `model`, `providerStatus`, `providerCode`, `retryAfterMs`, `detail` | Retryable on rate limits or quota exhaustion (`providerCode`); otherwise check provider status and auth. |
124
+
125
+ ```typescript
126
+ import { decide, isDecisionError, isDecisionProviderError, isDecisionTimeoutError } from "@bastani/atomic";
127
+
128
+ try {
129
+ const result = await decide({
130
+ settings,
131
+ modelRegistry,
132
+ currentModel,
133
+ state: { message: "Ship it once the tests pass." },
134
+ questions: {
135
+ ready: {
136
+ type: "bool",
137
+ instructions: "Is this an explicit approval to ship?",
138
+ criteria: { true: "Explicit approval to proceed.", false: "Not an approval or requests changes." },
139
+ },
140
+ },
141
+ deadline: 30_000,
142
+ });
143
+ console.log(result.answers.ready.value, result.source);
144
+ } catch (error) {
145
+ if (!isDecisionError(error)) throw error;
146
+
147
+ switch (error.code) {
148
+ case "timeout":
149
+ if (isDecisionTimeoutError(error)) {
150
+ console.error(`Timed out after ${error.elapsedMs}ms in ${error.phase}. ${error.hint}`);
151
+ }
152
+ break;
153
+ case "provider-failure":
154
+ if (isDecisionProviderError(error) && error.retryable) {
155
+ console.error(`Retryable provider error (${error.providerCode ?? "transient"}); wait ${error.retryAfterMs ?? 0}ms.`);
156
+ } else {
157
+ console.error(error.hint);
158
+ }
159
+ break;
160
+ case "model-unavailable":
161
+ case "invalid-setting":
162
+ case "invalid-request":
163
+ case "invalid-output":
164
+ case "renamed-setting":
165
+ console.error(`${error.code}: ${error.hint}`);
166
+ break;
167
+ }
168
+ }
169
+ ```
170
+
171
+ ## How `decisionModel` applies across APIs
80
172
 
81
- ## Where the decision model decides
173
+ - **The `structured_output` tool** (when called without its own `model`) starts on `decisionModel`. A classifier answers when the schema is a finite Choice; otherwise Atomic tries `fallbackModels` and then `currentModel`. Failures always reject with a `DecisionError`.
174
+ - **`generateStructuredOutput()`** uses only the models you pass (`model`, `fallbackModels`, `currentModel`) unless you pass `settings`, in which case omitting `model` starts on `decisionModel` like the tool. Note: calling `generateStructuredOutput()` **without `settings`** throws plain `Error` instances rather than `DecisionError` subclasses; `DecisionError` wrapping applies whenever `settings` is passed or when calling `decide()` or `structured_output`.
82
175
 
83
- - **The `structured_output` tool** (when called without its own `model`) starts on `decisionModel`, resolved the same way as `decide()`. A classifier answers when the result schema is a finite Choice; otherwise the call tries `fallbackModels` and then the current chat model. An unregistered or invalid `decisionModel` rejects with `DecisionModelUnavailableError` or `DecisionConfigError`, and an unanswered call rejects with `DecisionOutputError` or `DecisionProviderError`.
84
- - **`generateStructuredOutput()`** uses only the models you pass and the current chat model. Pass `settings` to start on `decisionModel` as the tool does.
176
+ ### Switch `decisionModel` on a live session
177
+
178
+ Call `session.setDecisionModel(model, scope?, options?)` on an `AgentSession` to update `decisionModel` immediately without restarting or reloading:
179
+
180
+ ```typescript
181
+ // Persist to global settings (default scope: "global")
182
+ session.setDecisionModel("typesafe/jev-latest", "global");
183
+
184
+ // Update only in-memory state for the current session without writing settings.json
185
+ session.setDecisionModel("auto", "project", { persist: false });
186
+ ```
187
+
188
+ - Pass `""` or `"auto"` to use the active chat model, or an exact registered classifier or chat `provider/model` ID.
189
+ - `scope` accepts `"global"` (default) or `"project"`. Pass `{ persist: false }` to update only the in-memory settings layer.
190
+ - Passing a non-string value or a string with leading or trailing whitespace throws `DecisionConfigError` (`code: "invalid-setting"`) synchronously.
191
+ - RPC clients can call `set_decision_model` (`client.setDecisionModel(model, scope?, options?)`); see [RPC protocol](/rpc/protocol#set_decision_model).
85
192
 
86
193
  ## Select the inference model
87
194
 
88
- Pass an optional exact `provider/model` string, not a model object and not `"auto"`:
195
+ Pass an optional exact `provider/model` string (not a `Model` object and not `"auto"`):
89
196
 
90
- - `model` is the primary candidate. It may be a chat language model or a classifier registered in `modelRegistry`. `typesafe/jev-latest` is one example classifier, not a separate request type.
91
- - `fallbackModels` is an ordered list of exact `provider/model` IDs.
92
- - Omit `model` to start on `decisionModel` when `settings` is passed (the `structured_output` tool always passes `settings`), or on the current chat model otherwise.
197
+ - `model`: primary candidate (chat model or registered classifier such as `typesafe/jev-latest`).
198
+ - `fallbackModels`: ordered list of exact `provider/model` IDs.
199
+ - Omit `model` to start on `decisionModel` when `settings` is passed, or on `currentModel` otherwise.
93
200
  - After `model` and `fallbackModels`, Atomic tries `currentModel` if it has not already been tried.
94
201
 
95
- Image-generation models, model patterns, reasoning suffixes, surrounding whitespace, and unregistered IDs cannot be used. Atomic skips those IDs, records each error in `modelAttempts`, and continues through the remaining candidates including `currentModel`. The call fails with the first ID's error only when no candidate resolves.
96
-
97
- A catalog entry does not guarantee that the provider can classify, that credentials work, or that quota remains. When `model` is omitted and `settings` is passed, `decisionModel` is never skipped: an unregistered or invalid `decisionModel` fails immediately with a [`DecisionError`](#errors).
202
+ Image-generation models, wildcard patterns, reasoning suffixes, surrounding whitespace, and unregistered IDs are invalid. Atomic skips invalid `model`/`fallbackModels` entries, records each error in `modelAttempts`, and advances to the remaining candidates including `currentModel` (failing with the first error only when no candidate resolves). When `model` is omitted and `settings` is provided, an invalid or unregistered `decisionModel` fails immediately with a [`DecisionError`](#errors) instead of skipping.
98
203
 
99
204
  ### Choice-compatible schemas
100
205
 
101
- A classifier can answer a finite Choice: literal unions, enums, booleans, and flat objects whose required fields all use those types. Free-form text, unconstrained numbers, arrays, optional fields, and nested objects are not Choice-compatible. Atomic compiles compatible schemas into choice questions and skips incompatible classifiers, recording each skip in `modelAttempts`. A request whose entire candidate chain is incompatible fails without inventing a decoder.
206
+ Classifiers answer finite Choice schemas: literal unions, enums, booleans, and flat closed objects (`additionalProperties: false`) whose required fields all use those types. Free-form text, unconstrained numbers, arrays, optional fields, and nested objects are incompatible; Atomic skips classifier candidates for those schemas, records each skip in `modelAttempts`, and advances to chat fallbacks.
102
207
 
103
- Pass the session `modelRegistry`. Classifier credentials come from that registry's provider login, such as `/login typesafe` or `TYPESAFE_API_KEY` for TypeSafe Jev. Never copy a resolved key into `state`.
208
+ Pass the session `modelRegistry` so classifier credentials resolve from its login store (such as `/login typesafe` or `TYPESAFE_API_KEY`). Never copy API keys into `state`.
104
209
 
105
210
  ```typescript
106
211
  import { Type } from "@bastani/atomic/typebox";
@@ -127,42 +232,40 @@ const result = await generateStructuredOutput({
127
232
  console.log(result.value.category, result.model);
128
233
  ```
129
234
 
130
- `result.value` holds the schema-validated decision, and `result.model` names the candidate that produced it. `result.modelAttempts` records skipped and failed candidates when a fallback chain ran.
235
+ `result.value` holds the schema-validated result, `result.model` identifies the candidate that answered, and `result.modelAttempts` records skipped and failed candidates when a fallback chain ran.
131
236
 
132
- This API reports chat token usage when a chat candidate produces the accepted result. Classifier-produced `usage` is not a classifier bill; the lower-level classifier operation may report usage and cost separately. A valid schema shape does not prove the judgment is correct, so re-check policy before taking action.
237
+ `result.usage` reports chat token usage when a chat candidate produced the result (classifier billing is reported separately by the classifier operation). A schema-valid result does not guarantee policy compliance, so validate invariants before acting.
133
238
 
134
- The `structured_output` tool accepts required `instructions`, nonempty named `state`, and optional `model` and `fallbackModels` from the calling model. `createStructuredOutputTool({ schema })` fixes the schema. Omitting `model` starts on the session's `decisionModel`, which defaults to the current chat model. The calling model cannot set a deadline; configure it with the tool's [`timeoutMs`](#cancellation-and-failures) option. See [Structured output final results](/sdk/reference#structured-output-final-results).
239
+ The `structured_output` tool accepts required `instructions`, non-empty named `state`, and optional `model` and `fallbackModels` from the calling model. `createStructuredOutputTool({ schema })` fixes the output schema. The calling model cannot override the deadline; set it with `timeoutMs`. See [Structured output final results](/sdk/reference#structured-output-final-results).
135
240
 
136
241
  ## Prepare a decision
137
242
 
138
- `instructions` describes the judgment. Named `state` fields hold the task, relevant conversation, explicit constraints, and reference text. Paths and URLs can identify a source, but do not replace its content. Exclude secrets from both `state` and `instructions`.
243
+ Put the task criteria in `instructions` and all relevant facts, constraints, and text snippets in named `state` fields. File paths and URLs identify sources, but do not substitute for their contents. Exclude secrets from both `state` and `instructions`.
139
244
 
140
- For `generateStructuredOutput()`, supply `instructions`, `state`, and `schema`. Atomic derives choice questions from a compatible schema and skips classifiers for other schemas. Keep numeric thresholds in code, and include an explicit no-match option in the schema when abstention is valid.
245
+ For `generateStructuredOutput()`, supply `instructions`, `state`, and `schema` (prefer `{ additionalProperties: false }` on object schemas). Keep numeric thresholds in application code, and add an explicit abstention option when no choice may fit.
141
246
 
142
247
  ## Provider behavior and limits
143
248
 
144
- Chat candidates receive one internal result tool whose parameters match `schema`. Atomic serializes schemas per provider, requests strict sampling where supported, and validates returned arguments without coercing values or stripping extra fields. Set `additionalProperties: false` on closed objects. A prose-only response, extra tool call, truncated response, or invalid payload fails that candidate and advances the chain.
145
-
146
- The public `structured_output` tool is separate: its parameters are `instructions`, `state`, and optional model selectors, and its result is the inferred value.
249
+ Chat candidates receive one internal result tool matching `schema`. Atomic serializes schemas per provider, enables strict sampling where supported, and validates returned arguments without type coercion or stripping extra keys. Always set `additionalProperties: false` on closed objects. Prose-only replies, extra tool calls, truncated output, or invalid payloads trigger up to 3 repair attempts (1 initial attempt plus 3 repairs) before advancing to the next fallback candidate.
147
250
 
148
- Use `Type.Optional(...)` for fields that may be omitted. When a strict provider encodes an omitted optional property as `null`, Atomic strips that placeholder if the property schema rejects `null`, including inside nested objects and array items. If `null` is a valid answer, allow it explicitly in the schema so Atomic preserves it. Required properties and undeclared fields always follow the original schema.
251
+ Use `Type.Optional(...)` for fields that may be omitted. When a strict provider encodes an omitted optional field as `null`, Atomic strips that `null` placeholder if the property schema rejects `null` (including inside nested objects and array items). Allow `null` explicitly in the schema if `null` is a valid answer.
149
252
 
150
- Chat decisions use HTTP/SSE rather than WebSocket transport fallback and disable configured Anthropic server-side fallbacks for that request. Transient chat failures follow the request's retry settings. Classifier calls invoke the registered provider's `classify` operation with the retry limit and cancellation signal; provider implementations own transport retries.
253
+ Chat decisions use HTTP/SSE transport (not WebSocket fallback) and disable configured Anthropic server-side fallbacks. Transient chat transport errors follow `retry` (default `{ enabled: true, maxRetries: 3, baseDelayMs: 2000 }`). Classifier calls invoke the provider's `classify` method with the retry limit and abort signal; provider implementations own transport retries.
151
254
 
152
- A registered classifier, such as [TypeSafe Jev](/providers#typesafe-jev), receives shared `state` and choice questions in one `classify` request. Atomic never trims `state`. If a classifier rejects the request size or context, or is incompatible with the schema, that candidate fails or is skipped and the chain advances to the next fallback without retrying the rejected request. Supply concise context or select a chat model with enough capacity.
255
+ Registered classifiers (such as [TypeSafe Jev](/providers#typesafe-jev)) receive `state` and derived choice questions in one `classify` call without trimming `state`. If a classifier rejects the size or context, or cannot represent the schema, Atomic skips or advances to the next candidate without retrying the rejected request.
153
256
 
154
- Atomic validates that every classifier answer selects a known option. Reported model names, probabilities, and confidence values are advisory and never reject an otherwise valid decision.
257
+ Atomic verifies that every classifier answer chooses a valid option. Reported model names, probabilities, and confidence values are advisory and never reject an otherwise valid answer.
155
258
 
156
259
  ## Cancellation and failures
157
260
 
158
- One wall-clock deadline covers the entire call: every repair attempt, transport retry, and fallback candidate together. Set it with `timeoutMs` as a positive integer in milliseconds. `generateStructuredOutput()` and `structured_output` check this deadline before dispatching retries so an overdue backoff never starts another provider request.
261
+ One wall-clock deadline covers the entire call: every repair attempt, transport retry, and fallback candidate combined. Configure it with `timeoutMs` (or `deadline` in `decide()`) as a positive safe integer in milliseconds. Atomic checks the deadline before every retry so overdue backoffs never start another request.
159
262
 
160
- When `timeoutMs` is omitted, `structured_output` uses the session's [`httpIdleTimeoutMs`](/settings#http) setting and other calls use the 10-minute default. Disabling the idle timeout (`0` or `"disabled"`) leaves only the maximum JavaScript timer delay, about 24.8 days. Raise the deadline for slow reasoning models or large `state`.
263
+ When omitted, `structured_output` uses the session's [`httpIdleTimeoutMs`](/settings#http) setting and standalone calls default to 10 minutes. Disabling the idle timeout (`0` or `"disabled"`) leaves only the JavaScript timer limit (~24.8 days). Increase the deadline for slow reasoning models or large `state` payloads.
161
264
 
162
- When the deadline expires, Atomic stops the in-flight generation (even if the provider ignores its abort signal) and rejects with `DecisionTimeoutError`. The error message names the deadline, phase, hint, and per-attempt timing (for example, `Attempts: 1) stopReason=stop 25m02s; 2) still generating 4m58s.`). Timeout failures are final and do not trigger more repairs or fallback candidates. Errors for exhausted repairs include the same attempt summary. Provider transport, credential preparation, and enclosing tool-request limits remain independent of this deadline.
265
+ When the deadline expires, Atomic aborts the in-flight request (even if the provider ignores abort signals) and rejects with `DecisionTimeoutError`, including the deadline, phase, hint, and per-attempt timings (for example, `Attempts: 1) stopReason=stop 25m02s; 2) still generating 4m58s.`). Timeouts are final and do not trigger further repairs or fallbacks.
163
266
 
164
- Pass an `AbortSignal` (such as `AbortSignal.timeout(milliseconds)`) to cancel sooner. Cancellation rejects immediately, even if a provider ignores its signal, and stops the fallback chain. Output has no fixed token cap; pass a positive integer `maxTokens` only to cap output below the model's limit.
267
+ Pass an `AbortSignal` (such as `AbortSignal.timeout(ms)`) to cancel sooner; cancellation rejects immediately and halts the fallback chain.
165
268
 
166
- Missing state, invalid configuration, unrepaired invalid output, or unrecovered provider failures return no result. Calls started on `decisionModel` reject with a [`DecisionError`](#errors) naming that model. Re-check cancellation and admission rules after awaiting the decision.
269
+ `generateStructuredOutput()` sets no default output token cap; pass optional `maxTokens` as a positive safe integer up to `2,147,483,647` to cap output below the model's limit.
167
270
 
168
- Provider errors report static reasons without raw response bodies or credentials. Classifier failures (including refusals or unrecognized or missing options) and chat provider errors advance to the next candidate. Ordinary text without a valid tool call gets up to three repairs before advancing; Atomic does not inspect text wording to guess whether it is a refusal.
271
+ Provider errors report static reasons without raw response bodies or credentials. Classifier failures and chat provider errors advance to the next fallback candidate; ordinary chat text without a valid tool call gets up to 3 repair attempts before advancing.
@@ -1,16 +1,12 @@
1
1
  ---
2
- title: "Embedding Atomic in a web server"
3
- sidebarTitle: "Web server"
4
- description: "Run Atomic sessions behind a Next.js App Router route and stream their output to a browser."
2
+ title: "Embed Atomic in a web server"
3
+ sidebarTitle: "Web server guide"
4
+ description: "Run Atomic sessions behind a Next.js App Router endpoint and stream newline-delimited JSON output to a browser."
5
5
  ---
6
6
 
7
- # Embedding Atomic in a web server
7
+ This guide puts an Atomic agent behind an HTTP endpoint using Next.js App Router. The same pattern works in any long-running Node.js server: keep one session per conversation, start a prompt per request, and stream session events back as newline-delimited JSON (NDJSON).
8
8
 
9
- This guide puts an Atomic agent behind an HTTP endpoint, using a Next.js App Router project as the example. The same pattern works in any long-running Node.js server: keep one session per conversation, start a prompt per request, and stream the session's events back as newline-delimited JSON (NDJSON).
10
-
11
- Read the [SDK](/sdk) page first for `createAgentSession()`, `AgentSession`, `AgentSessionRuntime`, and session events.
12
-
13
- The examples below use `createAgentSession()`, `ModelRuntime`, `SessionManager`, and `createTranscript()` from `@bastani/atomic`. For servers that release idle sessions and rehydrate them on later requests, wrap sessions with `createAgentSessionRuntime()` instead (see [Releasing idle sessions](/sdk#releasing-idle-sessions)).
9
+ Read [TypeScript SDK](/sdk) first for `createAgentSession()`, `AgentSession`, `AgentSessionRuntime`, and session events. For servers that release idle sessions and rehydrate them on later requests, wrap sessions with `createAgentSessionRuntime()` instead (see [Releasing idle sessions](/sdk#releasing-idle-sessions)).
14
10
 
15
11
  ## Install
16
12
 
@@ -18,13 +14,15 @@ The examples below use `createAgentSession()`, `ModelRuntime`, `SessionManager`,
18
14
  npm install @bastani/atomic
19
15
  ```
20
16
 
21
- Atomic requires Node.js 22.19 or newer. Dependency install scripts are not required; if your package manager reports blocked scripts, leave them disabled.
17
+ Atomic requires Node.js 22.19 or newer. Dependency install scripts are not required; if your package manager blocks install scripts, leave them disabled.
18
+
19
+ On Node 22, pass `--experimental-async-context-frame` on the server's `node` command line (not in `NODE_OPTIONS`) to avoid `AsyncLocalStorage` promise-hook overhead across concurrent HTTP requests; see [Node 22 hosts](/sdk#node-22-hosts).
22
20
 
23
21
  ## Keep Atomic out of the server bundle
24
22
 
25
- Atomic finds its bundled resources and native modules relative to its installed package, so it must load from `node_modules` rather than from Next.js's server bundle. List it in `serverExternalPackages` (Next.js 15 and later):
23
+ Atomic resolves its bundled resources and native modules relative to `node_modules`, so keep it outside Next.js's server bundle using `serverExternalPackages` (Next.js 15 and later):
26
24
 
27
- ```ts
25
+ ```typescript
28
26
  // next.config.ts
29
27
  import type { NextConfig } from "next";
30
28
 
@@ -35,23 +33,23 @@ const nextConfig: NextConfig = {
35
33
  export default nextConfig;
36
34
  ```
37
35
 
38
- Atomic's own dependencies load from `node_modules` once `@bastani/atomic` is external. The other entries cover packages your app may import directly. Add any other Atomic dependency you import yourself.
36
+ Once `@bastani/atomic` is external, its dependencies load from `node_modules`. List any other Atomic packages your application imports directly, including [`@bastani/atomic-storage-postgres`](/libraries/storage-postgres) or [`@bastani/atomic-storage-libsql`](/libraries/storage-libsql) when using remote SQL storage (see [SDK storage guide](/sdk/storage)).
39
37
 
40
- Import TypeBox for tool schemas from `@bastani/atomic/typebox` (and `@bastani/atomic/typebox/value`, `/compile`, `/format` and TypeBox's other subpaths) rather than from `typebox`. Atomic ships its own copy of TypeBox, and formats, settings or a locale your app registers reach Atomic's validation only through that copy.
38
+ Import TypeBox for custom tool schemas from `@bastani/atomic/typebox` (and its subpaths such as `/value`, `/compile`, and `/format`) rather than `typebox` directly so custom formats and settings share Atomic's TypeBox registry.
41
39
 
42
- Every route that imports Atomic must use the Node.js runtime:
40
+ Every route that imports Atomic must run on the Node.js runtime:
43
41
 
44
- ```ts
42
+ ```typescript
45
43
  export const runtime = "nodejs";
46
44
  ```
47
45
 
48
- Import Atomic only from server code. Client components may use `import type` from `@bastani/atomic`, which adds nothing to the browser bundle.
46
+ Import Atomic only from server code. Client components may use `import type` from `@bastani/atomic`, which adds zero bytes to the browser bundle.
49
47
 
50
48
  ## Keep one session per conversation
51
49
 
52
- An `AgentSession` holds the conversation's history, so create one per conversation and reuse it across requests. Keep sessions on `globalThis`: in `next dev`, module-level variables reset on every hot reload, but `globalThis` survives, so open conversations don't vanish and old sessions aren't leaked. Restart the dev server after changing session options; existing sessions keep the options they were created with.
50
+ An `AgentSession` owns the conversation history, so create one per conversation and reuse it across requests. Store shared state on `globalThis` so `next dev` hot reloads preserve active sessions without leaking them. Restart the dev server after changing session options because existing sessions keep their creation options.
53
51
 
54
- ```ts
52
+ ```typescript
55
53
  // lib/atomic.ts
56
54
  import "server-only";
57
55
  import { type AgentSession, createAgentSession, ModelRuntime, SessionManager } from "@bastani/atomic";
@@ -64,20 +62,31 @@ export interface Conversation {
64
62
  }
65
63
 
66
64
  interface AtomicState {
67
- modelRuntime: Promise<ModelRuntime>;
65
+ modelRuntime?: Promise<ModelRuntime>;
68
66
  conversations: Map<string, Promise<Conversation>>;
67
+ shutdownRegistered?: boolean;
69
68
  }
70
69
 
71
70
  const shared = globalThis as typeof globalThis & { atomicState?: AtomicState };
72
71
  const state = (shared.atomicState ??= {
73
- modelRuntime: ModelRuntime.create(),
74
72
  conversations: new Map(),
75
73
  });
76
74
 
75
+ function getModelRuntime(): Promise<ModelRuntime> {
76
+ if (!state.modelRuntime) {
77
+ // Clear cached promise on startup failure so a later request can retry.
78
+ state.modelRuntime = ModelRuntime.create().catch((error) => {
79
+ state.modelRuntime = undefined;
80
+ throw error;
81
+ });
82
+ }
83
+ return state.modelRuntime;
84
+ }
85
+
77
86
  export function getConversation(id: string): Promise<Conversation> {
78
87
  let conversation = state.conversations.get(id);
79
88
  if (!conversation) {
80
- conversation = state.modelRuntime.then(async (modelRuntime) => {
89
+ conversation = getModelRuntime().then(async (modelRuntime) => {
81
90
  const { session } = await createAgentSession({
82
91
  cwd: WORKSPACE,
83
92
  sessionManager: SessionManager.inMemory(WORKSPACE),
@@ -94,21 +103,40 @@ export function getConversation(id: string): Promise<Conversation> {
94
103
  }
95
104
 
96
105
  export async function closeConversation(id: string): Promise<void> {
97
- const conversation = state.conversations.get(id);
106
+ const pending = state.conversations.get(id);
98
107
  state.conversations.delete(id);
99
- if (conversation) await (await conversation).session.dispose();
108
+ if (!pending) return;
109
+ const conversation = await pending.catch(() => undefined);
110
+ if (!conversation) return;
111
+ // Abort active work with pauseQueuedMessages so dispose() does not wait for a running turn.
112
+ await conversation.session.abort({ pauseQueuedMessages: true });
113
+ await conversation.session.dispose();
114
+ }
115
+
116
+ export async function closeAllConversations(): Promise<void> {
117
+ const ids = [...state.conversations.keys()];
118
+ await Promise.allSettled(ids.map((id) => closeConversation(id)));
119
+ }
120
+
121
+ if (!state.shutdownRegistered) {
122
+ state.shutdownRegistered = true;
123
+ for (const signal of ["SIGTERM", "SIGINT"] as const) {
124
+ process.once(signal, () => {
125
+ void closeAllConversations().finally(() => process.exit(0));
126
+ });
127
+ }
100
128
  }
101
129
  ```
102
130
 
103
- `SessionManager.inMemory()` keeps history in process memory. To keep conversations across restarts, pass a file-backed `SessionManager` instead; see [Sessions](/sessions). Call `closeConversation()` when a conversation ends or has been idle for a while, because each open session holds resources until it is disposed.
131
+ `SessionManager.inMemory()` keeps history in process memory. To persist conversations across restarts, pass a SQLite, JSONL, libSQL, or PostgreSQL `SessionManager` or `sessionStore` (see [SDK storage guide](/sdk/storage)). Call `closeConversation()` when a conversation finishes or goes idle, and run `closeAllConversations()` on `SIGTERM`/`SIGINT` so session stores and child processes close cleanly.
104
132
 
105
- Sessions on `globalThis` live in one server process. Run this on a long-lived Node.js server, and route each conversation to the same instance if you run several. Short-lived serverless functions lose the session between requests.
133
+ Sessions on `globalThis` live in one server process. Run this on a long-lived Node.js server with sticky routing per conversation if you scale to multiple instances; short-lived serverless functions discard process memory between requests.
106
134
 
107
135
  ## Stream a prompt
108
136
 
109
- The route below starts one prompt and streams the assistant's output as NDJSON. `createTranscript()` turns session events into ordered, JSON-serializable parts (text, thinking, and tool calls joined to their results), so each line carries the complete output so far and the client simply replaces what it shows.
137
+ This route starts one prompt and streams the assistant's output as NDJSON. `createTranscript()` converts session events into ordered JSON-serializable parts (`text`, `thinking`, and `toolCall` paired with its `result`). Tool calls appear in `message_end` before execution begins and gain their `result` as `tool_execution_update` and `tool_execution_end` arrive, so each line carries the full output so far and the browser replaces its rendered list.
110
138
 
111
- ```ts
139
+ ```typescript
112
140
  // app/api/chat/route.ts
113
141
  import { createTranscript, type TranscriptPart } from "@bastani/atomic";
114
142
  import { getConversation } from "@/lib/atomic";
@@ -161,7 +189,11 @@ export async function POST(request: Request): Promise<Response> {
161
189
  session
162
190
  .prompt(message)
163
191
  .then(() => send({ type: "done" }))
164
- .catch((error: Error) => send({ type: "error", message: error.message }))
192
+ .catch((error: unknown) => {
193
+ console.error("Prompt failed:", error);
194
+ // Sanitize errors in production instead of exposing internal paths or stack details.
195
+ send({ type: "error", message: "The request could not be completed." });
196
+ })
165
197
  .finally(() => {
166
198
  unsubscribe();
167
199
  request.signal.removeEventListener("abort", stop);
@@ -184,13 +216,14 @@ export async function POST(request: Request): Promise<Response> {
184
216
  }
185
217
  ```
186
218
 
187
- A few details matter here:
219
+ Key behaviors:
188
220
 
189
- - **One prompt at a time.** `session.prompt()` rejects while the session is already streaming. The route answers `409` instead. `busy` is set synchronously, so two requests that arrive together can't both start a prompt. To queue a message instead of rejecting it, call `session.prompt(message, { streamingBehavior: "followUp" })`.
190
- - **Stop on disconnect.** When the browser disconnects or aborts its `fetch`, `request.signal` aborts and the stream is cancelled. Both call `session.abort()`, which stops the current turn and its tools but keeps the session usable.
191
- - **Payload size.** Each line repeats the whole output so far. For long answers, send lines on a timer instead of on every event, or send only the parts that changed.
221
+ - **One prompt at a time:** `session.prompt()` rejects while streaming, so the route returns `409` and flips `busy` synchronously to prevent races. To queue prompts instead of rejecting, call `session.prompt(message, { streamingBehavior: "followUp" })`.
222
+ - **Stop on disconnect:** When the browser disconnects or aborts `fetch`, `request.signal` and `cancel()` call `session.abort()`, stopping the current turn and tools while keeping the session reusable.
223
+ - **Payload throttling:** Each line emits the complete transcript so far. For long responses, throttle updates on a short timer or send incremental diffs.
224
+ - **Error sanitization:** Log raw errors server-side and send sanitized user-safe error messages to the browser.
192
225
 
193
- `createTranscript()` reports a tool result's text by default. To send a tool's structured `details` instead, pass `createTranscript({ toolResult: (toolName) => (toolName === "todo" ? "details" : "content") })`.
226
+ `createTranscript()` returns a tool result's text by default. To send structured `details` for specific tools instead, pass `createTranscript({ toolResult: (toolName) => (toolName === "todo" ? "details" : "content") })`.
194
227
 
195
228
  ## Read the stream in the browser
196
229
 
@@ -231,22 +264,23 @@ export async function sendMessage(
231
264
  }
232
265
  ```
233
266
 
234
- Render each part by `type`: `text` and `thinking` are strings, and a `toolCall` part has `name`, `arguments`, and, once the tool reports progress or finishes, a `result` with `content`, `isError`, and `isPartial`. Pass an `AbortController`'s signal to stop the agent from the page.
267
+ Render each part by `type`: `text` and `thinking` hold strings, and a `toolCall` part has `name`, `arguments`, and (once progress or completion arrives) `result` (`content`, `isError`, `isPartial`). Pass an `AbortController` signal to cancel from the UI.
235
268
 
236
269
  ## Secure the endpoint
237
270
 
238
- A route that drives an agent session lets whoever calls it run tools on your server with the server process's permissions. Atomic has [no built-in sandbox](/security#no-built-in-sandbox).
271
+ Any route driving an agent session lets callers run tools with the server process's OS permissions. Atomic has [no built-in sandbox](/security#no-built-in-sandbox).
239
272
 
240
- - **Require authentication** on every route that creates sessions or sends prompts, and scope conversation ids to the authenticated user, as `getConversation()` does above.
241
- - **Allow only the tools you need.** `tools` is an allowlist; the examples allow only the read-only `read`, `find`, and `search`. Leave out `bash`, `edit`, and `write` unless the agent must change files or run commands. `excludedTools` removes tools, and `noTools: "all"` exposes none. `ask_user_question` needs a person to answer, so leave it out of headless sessions. See [Tools](/sdk/reference#tools).
242
- - **Disable builtins you don't use.** `builtins` turns off the shipped subagents, MCP, web access, and Intercom packages, along with their tools.
243
- - **Choose the working directory deliberately.** `cwd` sets the starting directory for tool paths and controls which project settings, context files, and extensions Atomic discovers. It does not restrict file access: tools can use absolute paths and paths outside `cwd`. Point it at a directory you control, never at an upload or a user-supplied path.
244
- - **Isolate the process** in a container, VM, or restricted OS account when callers must not access other server files, even with read-only tools, or when the agent can write files or run commands. See [Containerization](/containerization).
245
- - **Keep credentials on the server.** Provider keys come from the server's `ModelRuntime`. Never send them to the browser or accept them from requests.
273
+ - **Require authentication** on every route that creates sessions or sends prompts, and scope conversation IDs to the authenticated user.
274
+ - **Allow only needed tools.** `tools` is an allowlist; the example enables only read-only `read`, `find`, and `search`. Omit `bash`, `edit`, and `write` unless the agent must mutate files or run commands. `excludedTools` removes tools, and `noTools: "all"` exposes none. Omit `ask_user_question` in headless sessions. See [Tools](/sdk/reference#tools).
275
+ - **Disable unused builtins.** Turn off `subagents`, `mcp`, `web-access`, and `intercom` via `builtins` when not required.
276
+ - **Choose `cwd` deliberately.** `cwd` sets the starting directory for relative tool paths and project discovery, but does not jail file access (tools can read absolute paths outside `cwd`). Point `cwd` at a controlled directory, never user input.
277
+ - **Isolate the process** in a container, VM, or restricted OS account whenever callers must not reach other server files or when write/shell tools are enabled. See [Containerization](/containerization).
278
+ - **Keep credentials server-side.** Provider keys live in the server's `ModelRuntime`. Never forward them to browsers or accept raw keys from untrusted clients.
246
279
 
247
280
  ## Next steps
248
281
 
249
- - [SDK](/sdk) for sessions, prompting, and events.
250
- - [SDK API reference](/sdk/reference) for every `createAgentSession()` option.
251
- - [Orchestration](/orchestration) for running multi-step tasks with codemode and subagents.
252
- - [Migrating workflows](/orchestration/migrating-workflows) for replacing earlier workflow definitions.
282
+ - [TypeScript SDK](/sdk): sessions, prompting, storage, and events.
283
+ - [SDK storage guide](/sdk/storage): persist server sessions in SQLite, JSONL, libSQL, or PostgreSQL and wire `createAgentSessionRuntime()`.
284
+ - [SDK API reference](/sdk/reference): every `createAgentSession()` option and export.
285
+ - [Orchestration](/orchestration): multi-step workflows with codemode and subagents.
286
+ - [Migrating workflows](/orchestration/migrating-workflows): replacing older workflow definitions.