@bastani/atomic 0.10.14-alpha.1 → 0.10.15-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (341) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/dist/_shared/dist-KOELCESV.js +2 -2
  3. package/dist/_shared/fork-row-index-UAUAQRD5.js +2 -2
  4. package/dist/_shared/lib-4PES5P4V.js +2 -2
  5. package/dist/_shared/mode-interactive-sdk-7KXUFI2F.js +3 -3
  6. package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +3 -3
  7. package/dist/_shared/mode-shared-2QJSCUM6.js +3 -3
  8. package/dist/_shared/p1a-prewarm-XIU57JHF.js +3 -3
  9. package/dist/_shared/runtime-O4KCSG4C.js +2 -2
  10. package/dist/_shared/{sdk-B5LEWGGI.js → sdk-OHKMDJ74.js} +27 -5
  11. package/dist/_shared/{sdk-B5LEWGGI.js.map → sdk-OHKMDJ74.js.map} +1 -1
  12. package/dist/_shared/session-data-AHTU7IS6.js +2 -2
  13. package/dist/_shared/startup-0-0-Q3MWKUK4.js +2 -2
  14. package/dist/_shared/startup-0-1-M6OWAYHH.js +2 -2
  15. package/dist/_shared/{startup-0-2-5QHPCEON.js → startup-0-2-2HUMCPKX.js} +14 -16
  16. package/dist/_shared/startup-0-2-2HUMCPKX.js.map +1 -0
  17. package/dist/_shared/startup-0-3-4ZYBYQNM.js +3 -3
  18. package/dist/_shared/startup-0-4-ZMJV547D.js +3 -3
  19. package/dist/_shared/startup-0-5-YDW47QX6.js +3 -3
  20. package/dist/_shared/startup-10-0-TDQNBDDL.js +3 -3
  21. package/dist/_shared/startup-14-0-MLX36RBG.js +1 -1
  22. package/dist/_shared/startup-15-0-YUKGAC63.js +1 -1
  23. package/dist/_shared/startup-15-1-4S7FLMNG.js +6 -30
  24. package/dist/_shared/startup-15-1-4S7FLMNG.js.map +1 -1
  25. package/dist/_shared/startup-8-0-34CBHPZH.js +3 -3
  26. package/dist/_shared/startup-8-1-LZFXSD3Z.js +3 -3
  27. package/dist/_shared/storage-command-7MGXLJGZ.js +2 -2
  28. package/dist/_shared/storage-status-K7PX2RXA.js +3 -3
  29. package/dist/_shared/task-unsaved-answer-VJ2KTB4V.js +2 -2
  30. package/dist/_shared/tree-outline-MUEPK5B7.js +2 -2
  31. package/dist/builtin/intercom/index.bundle.mjs +1 -1
  32. package/dist/builtin/intercom/package.json +1 -1
  33. package/dist/builtin/mcp/index.bundle.mjs +1 -1
  34. package/dist/builtin/mcp/package.json +1 -1
  35. package/dist/builtin/subagents/package.json +1 -1
  36. package/dist/builtin/subagents/src/extension/index.bundle.mjs +1 -1
  37. package/dist/builtin/web-access/index.bundle.mjs +1 -1
  38. package/dist/builtin/web-access/package.json +1 -1
  39. package/dist/cli/auth-cli.code.js +1 -1
  40. package/dist/cli/auth-cli.impl.js +3 -3
  41. package/dist/cli/auth-cli.js +3 -3
  42. package/dist/cli/blueprint-command.impl.js +3 -3
  43. package/dist/cli/blueprint-command.js +3 -3
  44. package/dist/cli/intercom-command.code.js +3 -3
  45. package/dist/cli/intercom-command.impl.js +3 -3
  46. package/dist/cli/intercom-command.js +3 -3
  47. package/dist/cli/list-models.impl.js +3 -3
  48. package/dist/cli/list-models.js +3 -3
  49. package/dist/cli/session-picker.code.js +1 -1
  50. package/dist/cli/session-picker.impl.js +3 -3
  51. package/dist/cli/session-picker.js +3 -3
  52. package/dist/cli/startup-ui.code.js +1 -1
  53. package/dist/cli/startup-ui.impl.js +3 -3
  54. package/dist/cli/startup-ui.js +3 -3
  55. package/dist/cli/storage-command.impl.js +3 -3
  56. package/dist/cli/storage-command.js +3 -3
  57. package/dist/cli/storage-search-session.code.js +1 -1
  58. package/dist/cli/storage-search-session.impl.js +3 -3
  59. package/dist/cli/storage-search-session.js +3 -3
  60. package/dist/cli/team-command.code.js +1 -1
  61. package/dist/cli/team-command.impl.js +3 -3
  62. package/dist/cli/team-command.js +3 -3
  63. package/dist/cli.js +2 -2
  64. package/dist/core/compaction/compactor.d.ts +0 -8
  65. package/dist/core/debug.impl.js +3 -3
  66. package/dist/core/debug.js +3 -3
  67. package/dist/core/export-html/card-projection.impl.js +3 -3
  68. package/dist/core/export-html/card-projection.js +3 -3
  69. package/dist/core/export-html/index.code.js +2 -2
  70. package/dist/core/export-html/index.impl.js +3 -3
  71. package/dist/core/export-html/index.js +3 -3
  72. package/dist/core/export-html/json-spans.impl.js +3 -3
  73. package/dist/core/export-html/json-spans.js +3 -3
  74. package/dist/core/export-html/oversized-render-inputs.impl.js +3 -3
  75. package/dist/core/export-html/oversized-render-inputs.js +3 -3
  76. package/dist/core/export-html/tool-renderer.impl.js +3 -3
  77. package/dist/core/export-html/tool-renderer.js +3 -3
  78. package/dist/core/extensions/jiti-loader.impl.js +3 -3
  79. package/dist/core/extensions/jiti-loader.js +3 -3
  80. package/dist/core/extensions/jiti-static-loader.impl.js +3 -3
  81. package/dist/core/extensions/jiti-static-loader.js +3 -3
  82. package/dist/core/extensions/loader-host-modules.impl.js +3 -3
  83. package/dist/core/extensions/loader-host-modules.js +3 -3
  84. package/dist/core/intercom-broker-control-host.code.js +1 -1
  85. package/dist/core/intercom-broker-control-host.impl.js +3 -3
  86. package/dist/core/intercom-broker-control-host.js +3 -3
  87. package/dist/core/intercom-broker-control.code.js +2 -2
  88. package/dist/core/intercom-broker-control.impl.js +3 -3
  89. package/dist/core/intercom-broker-control.js +3 -3
  90. package/dist/core/package-manager-storage-adapters.impl.js +3 -3
  91. package/dist/core/package-manager-storage-adapters.js +3 -3
  92. package/dist/core/sdk.code.js +1 -1
  93. package/dist/core/sdk.impl.js +3 -3
  94. package/dist/core/sdk.js +3 -3
  95. package/dist/core/session-manager-core.js +3 -3
  96. package/dist/core/session-manager-list.impl.js +3 -3
  97. package/dist/core/session-manager-list.js +3 -3
  98. package/dist/core/session-manager.impl.js +3 -3
  99. package/dist/core/session-manager.js +3 -3
  100. package/dist/core/session-storage.impl.js +3 -3
  101. package/dist/core/session-storage.js +3 -3
  102. package/dist/core/storage/index.js +2 -2
  103. package/dist/core/storage/node-sqlite-thread.js +2 -2
  104. package/dist/core/storage/node-sqlite.js +2 -2
  105. package/dist/core/storage/offline-snapshot-file.impl.js +3 -3
  106. package/dist/core/storage/offline-snapshot-file.js +3 -3
  107. package/dist/core/storage/provider.js +2 -2
  108. package/dist/core/storage/selection.js +2 -2
  109. package/dist/core/storage/session/branch-fork-source.code.js +2 -2
  110. package/dist/core/storage/session/branch-fork-source.impl.js +3 -3
  111. package/dist/core/storage/session/branch-fork-source.js +3 -3
  112. package/dist/core/storage/session/card-view.impl.js +3 -3
  113. package/dist/core/storage/session/card-view.js +3 -3
  114. package/dist/core/storage/session/child-reader.code.js +2 -2
  115. package/dist/core/storage/session/child-reader.impl.js +3 -3
  116. package/dist/core/storage/session/child-reader.js +3 -3
  117. package/dist/core/storage/session/chunked-resume-projection.impl.js +3 -3
  118. package/dist/core/storage/session/chunked-resume-projection.js +3 -3
  119. package/dist/core/storage/session/expanded-child-details.code.js +2 -2
  120. package/dist/core/storage/session/expanded-child-details.impl.js +3 -3
  121. package/dist/core/storage/session/expanded-child-details.js +3 -3
  122. package/dist/core/storage/session/fork-row-bytes.impl.js +3 -3
  123. package/dist/core/storage/session/fork-row-bytes.js +3 -3
  124. package/dist/core/storage/session/fork-row-index.impl.js +3 -3
  125. package/dist/core/storage/session/fork-row-index.js +3 -3
  126. package/dist/core/storage/session/fork-staging.code.js +1 -1
  127. package/dist/core/storage/session/fork-staging.impl.js +3 -3
  128. package/dist/core/storage/session/fork-staging.js +3 -3
  129. package/dist/core/storage/session/fork-window.code.js +2 -2
  130. package/dist/core/storage/session/fork-window.impl.js +3 -3
  131. package/dist/core/storage/session/fork-window.js +3 -3
  132. package/dist/core/storage/session/history-pages.impl.js +3 -3
  133. package/dist/core/storage/session/history-pages.js +3 -3
  134. package/dist/core/storage/session/jsonl-entry-projection.impl.js +3 -3
  135. package/dist/core/storage/session/jsonl-entry-projection.js +3 -3
  136. package/dist/core/storage/session/jsonl-session-store.impl.js +3 -3
  137. package/dist/core/storage/session/jsonl-session-store.js +3 -3
  138. package/dist/core/storage/session/memory-session-store.impl.js +3 -3
  139. package/dist/core/storage/session/memory-session-store.js +3 -3
  140. package/dist/core/storage/session/pinned-branch-resume.code.js +2 -2
  141. package/dist/core/storage/session/pinned-branch-resume.impl.js +3 -3
  142. package/dist/core/storage/session/pinned-branch-resume.js +3 -3
  143. package/dist/core/storage/session/released-history-files.code.js +1 -1
  144. package/dist/core/storage/session/released-history-files.impl.js +3 -3
  145. package/dist/core/storage/session/released-history-files.js +3 -3
  146. package/dist/core/storage/session/resident-fork-rows.impl.js +3 -3
  147. package/dist/core/storage/session/resident-fork-rows.js +3 -3
  148. package/dist/core/storage/session/session-resume.impl.js +3 -3
  149. package/dist/core/storage/session/session-resume.js +3 -3
  150. package/dist/core/storage/session/snapshot-cut.impl.js +3 -3
  151. package/dist/core/storage/session/snapshot-cut.js +3 -3
  152. package/dist/core/storage/session/snapshot-history.code.js +2 -2
  153. package/dist/core/storage/session/snapshot-history.impl.js +3 -3
  154. package/dist/core/storage/session/snapshot-history.js +3 -3
  155. package/dist/core/storage/session/sql-session-store.code.js +1 -1
  156. package/dist/core/storage/session/sql-session-store.impl.js +3 -3
  157. package/dist/core/storage/session/sql-session-store.js +3 -3
  158. package/dist/core/storage/session/tree-outline.impl.js +3 -3
  159. package/dist/core/storage/session/tree-outline.js +3 -3
  160. package/dist/core/storage/session/tree-presentation.impl.js +3 -3
  161. package/dist/core/storage/session/tree-presentation.js +3 -3
  162. package/dist/core/storage/storage-status.impl.js +3 -3
  163. package/dist/core/storage/storage-status.js +3 -3
  164. package/dist/core/storage/team.impl.js +3 -3
  165. package/dist/core/storage/team.js +3 -3
  166. package/dist/core/structured-output/index.code.js +1 -1
  167. package/dist/core/structured-output/index.impl.js +3 -3
  168. package/dist/core/structured-output/index.js +3 -3
  169. package/dist/core/tasks/task-completion-entry.impl.js +3 -3
  170. package/dist/core/tasks/task-completion-entry.js +3 -3
  171. package/dist/core/tasks/task-file-history.code.js +2 -2
  172. package/dist/core/tasks/task-file-history.impl.js +3 -3
  173. package/dist/core/tasks/task-file-history.js +3 -3
  174. package/dist/core/tasks/task-reference-archive.code.js +2 -2
  175. package/dist/core/tasks/task-reference-archive.js +3 -3
  176. package/dist/core/tasks/task-reference-identity.js +3 -3
  177. package/dist/core/tasks/task-reference-stream.impl.js +3 -3
  178. package/dist/core/tasks/task-reference-stream.js +3 -3
  179. package/dist/core/tasks/task-unsaved-answer.impl.js +3 -3
  180. package/dist/core/tasks/task-unsaved-answer.js +3 -3
  181. package/dist/core/tasks/task-view-source.impl.js +3 -3
  182. package/dist/core/tasks/task-view-source.js +3 -3
  183. package/dist/core/tools/read-url.impl.js +3 -3
  184. package/dist/core/tools/read-url.js +3 -3
  185. package/dist/core/worktree-snapshot/blob-store.js +2 -2
  186. package/dist/core/worktree-snapshot/errors.code.js +1 -1
  187. package/dist/core/worktree-snapshot/errors.impl.js +3 -3
  188. package/dist/core/worktree-snapshot/errors.js +3 -3
  189. package/dist/core/worktree-snapshot/session-index-reset.impl.js +3 -3
  190. package/dist/core/worktree-snapshot/session-index-reset.js +3 -3
  191. package/dist/extensions/codemode/execute.impl.js +3 -3
  192. package/dist/extensions/codemode/execute.js +3 -3
  193. package/dist/extensions/codemode/renderer.impl.js +3 -3
  194. package/dist/extensions/codemode/renderer.js +3 -3
  195. package/dist/extensions/mcp/cli.code.js +1 -1
  196. package/dist/extensions/mcp/cli.impl.js +3 -3
  197. package/dist/extensions/mcp/cli.js +3 -3
  198. package/dist/extensions/mcp/cli.lazy.code.js +2 -2
  199. package/dist/extensions/mcp/cli.lazy.impl.js +3 -3
  200. package/dist/extensions/mcp/cli.lazy.js +3 -3
  201. package/dist/extensions/mcp/runtime.code.js +1 -1
  202. package/dist/extensions/mcp/runtime.impl.js +3 -3
  203. package/dist/extensions/mcp/runtime.js +3 -3
  204. package/dist/index.d.ts +21 -1
  205. package/dist/index.js +2 -2
  206. package/dist/main-first-time-setup.code.js +1 -1
  207. package/dist/main-first-time-setup.impl.js +3 -3
  208. package/dist/main-first-time-setup.js +3 -3
  209. package/dist/modes/interactive/components/stored-tree-view.code.js +2 -2
  210. package/dist/modes/interactive/components/stored-tree-view.impl.js +3 -3
  211. package/dist/modes/interactive/components/stored-tree-view.js +3 -3
  212. package/dist/modes/interactive/components/user-message-selector-archive.impl.js +3 -3
  213. package/dist/modes/interactive/components/user-message-selector-archive.js +3 -3
  214. package/dist/modes/print-mode.js +1 -1
  215. package/dist/package-manager-cli.code.js +2 -2
  216. package/dist/package-manager-cli.impl.js +3 -3
  217. package/dist/package-manager-cli.js +3 -3
  218. package/dist/startup-files.json +1 -1
  219. package/dist/startup-stages/6.js +1 -1
  220. package/dist/utils/startup-database-spare.code.js +1 -1
  221. package/dist/utils/startup-database-spare.impl.js +3 -3
  222. package/dist/utils/startup-database-spare.js +3 -3
  223. package/dist/utils/tools-manager.impl.js +3 -3
  224. package/dist/utils/tools-manager.js +3 -3
  225. package/docs/background-tasks/reference.md +182 -0
  226. package/docs/background-tasks.md +98 -405
  227. package/docs/build.md +67 -27
  228. package/docs/changelog.mdx +9 -0
  229. package/docs/codemode.md +108 -39
  230. package/docs/compaction/branch-summaries.md +54 -0
  231. package/docs/compaction/custom-compactors.md +161 -0
  232. package/docs/compaction/memory-compaction.md +77 -0
  233. package/docs/compaction/reference.md +86 -38
  234. package/docs/compaction.md +51 -252
  235. package/docs/computer-use.md +169 -321
  236. package/docs/containerization.md +71 -57
  237. package/docs/custom-provider/api-reference.md +119 -25
  238. package/docs/custom-provider/oauth.md +114 -132
  239. package/docs/custom-provider/override.md +37 -27
  240. package/docs/custom-provider/registration.md +107 -83
  241. package/docs/custom-provider/streaming.md +85 -71
  242. package/docs/custom-provider.md +85 -52
  243. package/docs/development.md +39 -29
  244. package/docs/docs.json +76 -63
  245. package/docs/environment-variables.md +94 -44
  246. package/docs/extensions/api-reference.md +86 -43
  247. package/docs/extensions/authoring.md +162 -154
  248. package/docs/extensions/events.md +80 -25
  249. package/docs/extensions/examples.md +90 -85
  250. package/docs/extensions/ui.md +206 -82
  251. package/docs/extensions.md +79 -108
  252. package/docs/getting-started/authentication.md +67 -36
  253. package/docs/getting-started/first-session.md +53 -43
  254. package/docs/getting-started/installation.md +116 -89
  255. package/docs/getting-started/project-instructions.md +48 -34
  256. package/docs/guides/configuration.md +82 -20
  257. package/docs/guides/non-interactive.md +66 -24
  258. package/docs/guides/resume-on-any-machine.md +135 -82
  259. package/docs/guides/team-setup.md +114 -105
  260. package/docs/guides.md +76 -32
  261. package/docs/herdr.md +15 -16
  262. package/docs/how-atomic-works.md +140 -0
  263. package/docs/index.md +58 -44
  264. package/docs/intercom/operations.md +141 -151
  265. package/docs/intercom/reference.md +85 -108
  266. package/docs/intercom.md +84 -145
  267. package/docs/json.md +120 -67
  268. package/docs/keybindings.md +85 -49
  269. package/docs/libraries/agent-core.md +137 -275
  270. package/docs/libraries/ai.md +100 -84
  271. package/docs/libraries/codemode.md +210 -300
  272. package/docs/libraries/schema.md +59 -53
  273. package/docs/libraries/storage-postgres.md +49 -35
  274. package/docs/libraries/telemetry.md +153 -354
  275. package/docs/libraries/tui.md +265 -393
  276. package/docs/libraries.md +42 -26
  277. package/docs/llama-cpp.md +171 -161
  278. package/docs/mcp-servers.md +90 -51
  279. package/docs/models/choose-a-model.md +188 -0
  280. package/docs/models/reference.md +74 -30
  281. package/docs/models.md +153 -88
  282. package/docs/orchestration/migrating-workflows.md +23 -16
  283. package/docs/orchestration/patterns.md +39 -44
  284. package/docs/orchestration.md +65 -26
  285. package/docs/packages/authoring.md +51 -29
  286. package/docs/packages/reference.md +42 -21
  287. package/docs/packages.md +69 -58
  288. package/docs/programmatic.md +118 -24
  289. package/docs/prompt-templates.md +84 -83
  290. package/docs/providers/reference.md +43 -48
  291. package/docs/providers.md +219 -451
  292. package/docs/quickstart.md +140 -120
  293. package/docs/reference/cli.md +135 -97
  294. package/docs/reference.md +20 -18
  295. package/docs/rpc/examples.md +76 -20
  296. package/docs/rpc/extension-ui.md +64 -38
  297. package/docs/rpc/protocol.md +361 -110
  298. package/docs/rpc.md +57 -17
  299. package/docs/sdk/reference.md +409 -534
  300. package/docs/sdk/storage.md +53 -13
  301. package/docs/sdk/structured-decisions.md +82 -56
  302. package/docs/sdk/web-server.md +57 -43
  303. package/docs/sdk.md +106 -84
  304. package/docs/security.md +42 -64
  305. package/docs/session-format.md +62 -38
  306. package/docs/sessions.md +99 -214
  307. package/docs/settings.md +165 -195
  308. package/docs/shell-aliases.md +9 -6
  309. package/docs/skills/authoring.md +69 -48
  310. package/docs/skills/reference.md +51 -20
  311. package/docs/skills.md +99 -148
  312. package/docs/slash-commands.md +129 -0
  313. package/docs/storage/custom-adapters.md +160 -85
  314. package/docs/storage/jsonl.md +81 -66
  315. package/docs/storage/postgres/pgbouncer.md +120 -126
  316. package/docs/storage/postgres/tuning.md +120 -143
  317. package/docs/storage/postgres.md +314 -330
  318. package/docs/storage/sqlite.md +71 -42
  319. package/docs/storage.md +298 -302
  320. package/docs/subagents/authoring.md +55 -38
  321. package/docs/subagents/reference.md +73 -33
  322. package/docs/subagents.md +119 -187
  323. package/docs/terminal-setup.md +50 -38
  324. package/docs/termux.md +67 -41
  325. package/docs/themes/reference.md +23 -19
  326. package/docs/themes.md +142 -127
  327. package/docs/tmux.md +47 -55
  328. package/docs/tools.md +147 -109
  329. package/docs/tui/reference.md +166 -214
  330. package/docs/tui.md +196 -341
  331. package/docs/usage.md +118 -138
  332. package/docs/verification.md +79 -51
  333. package/docs/web-access.md +121 -101
  334. package/docs/windows.md +26 -27
  335. package/docs/worktree-snapshots/reference.md +245 -0
  336. package/docs/worktree-snapshots.md +71 -259
  337. package/package.json +8 -8
  338. package/dist/_shared/startup-0-2-5QHPCEON.js.map +0 -1
  339. package/docs/guides/intercom.md +0 -32
  340. package/docs/guides/orchestration.md +0 -28
  341. package/docs/guides/subagents.md +0 -37
package/docs/sdk.md CHANGED
@@ -1,53 +1,68 @@
1
1
  ---
2
- title: "TypeScript SDK"
3
- sidebarTitle: "SDK"
4
- description: "Embed Atomic agent sessions in Node.js applications with programmatic control over models, tools, storage, and human input."
2
+ title: "Use the TypeScript SDK"
3
+ sidebarTitle: "Use the SDK"
4
+ description: "Embed Atomic agent sessions in Node.js 24.20+ applications with programmatic control over models, tools, storage, workspaces, and human input."
5
5
  ---
6
6
 
7
7
  Embed Atomic in Node.js applications (Node.js 24.20 or newer) to build custom UIs, power backend services, or drive automated workflows directly inside your Node.js process. Working examples live in [examples/sdk/](https://github.com/bastani-inc/atomic/tree/main/packages/coding-agent/examples/sdk).
8
8
 
9
- - **Full options and exports:** [SDK API reference](/sdk/reference) (includes [Owner-bound task supervisor](/sdk/reference#owner-bound-task-supervisor), [Supervised command SDK](/sdk/reference#supervised-command-sdk), and [Task transcript references](/sdk/reference#task-transcript-references)).
10
- - **Typed decisions:** [Structured decisions API](/sdk/structured-decisions).
11
- - **Session storage:** [SDK storage guide](/sdk/storage) and [Storage](/storage).
12
- - **HTTP streaming servers:** [Embed Atomic in a web server](/sdk/web-server) (Next.js App Router guide).
13
- - **Compare modes:** [Programmatic integration](/programmatic).
9
+ <Columns cols={2}>
10
+ <Card title="SDK API reference" href="/sdk/reference">
11
+ Full options, `AgentSession` and `AgentSessionRuntime` methods, loaders, run modes, task supervision, error classes, and exports.
12
+ </Card>
13
+ <Card title="Configure session storage" href="/sdk/storage">
14
+ Recipes for SQLite, JSONL, in-memory, and PostgreSQL storage, `StorageProvider`, ownership rules, and `StorageError` handling.
15
+ </Card>
16
+ <Card title="Make structured decisions" href="/sdk/structured-decisions">
17
+ Run typed classifier or chat decisions with `decide()`, `generateStructuredOutput()`, and `structured_output`.
18
+ </Card>
19
+ <Card title="Stream from a web server" href="/sdk/web-server">
20
+ Build a streaming NDJSON HTTP endpoint with Next.js App Router and `createAgentSession()`.
21
+ </Card>
22
+ </Columns>
23
+
24
+ Need to compare Print mode, JSON event streams, RPC mode, and the SDK? See [Choose an integration mode](/programmatic).
14
25
 
15
26
  ## Quick start
16
27
 
17
- Install `@bastani/atomic` (the SDK ships in the main package; install scripts are not required):
18
-
19
- ```bash
20
- npm install @bastani/atomic
21
- # or: pnpm add @bastani/atomic
22
- # or: bun add @bastani/atomic
23
- ```
24
-
25
- For TypeScript ESM projects, set `"type": "module"` in `package.json` and `"module": "NodeNext"`, `"moduleResolution": "NodeNext"`, `"strict": true` in `tsconfig.json`.
26
-
27
- Create a session, stream text deltas, and dispose cleanly in `finally`:
28
-
29
- ```typescript
30
- import { createAgentSession, ModelRuntime, SessionManager } from "@bastani/atomic";
31
-
32
- const modelRuntime = await ModelRuntime.create();
33
-
34
- const { session } = await createAgentSession({
35
- sessionManager: SessionManager.inMemory(),
36
- modelRuntime,
37
- });
38
-
39
- session.subscribe((event) => {
40
- if (event.type === "message_update" && event.assistantMessageEvent.type === "text_delta") {
41
- process.stdout.write(event.assistantMessageEvent.delta);
42
- }
43
- });
44
-
45
- try {
46
- await session.prompt("What files are in the current directory?");
47
- } finally {
48
- await session.dispose();
49
- }
50
- ```
28
+ <Steps>
29
+ <Step title="Install @bastani/atomic">
30
+ The SDK ships in the main package; dependency install scripts are not required.
31
+
32
+ ```bash
33
+ npm install @bastani/atomic
34
+ # or: pnpm add @bastani/atomic
35
+ # or: bun add @bastani/atomic
36
+ ```
37
+ </Step>
38
+ <Step title="Configure TypeScript ESM">
39
+ Set `"type": "module"` in `package.json` and `"module": "NodeNext"`, `"moduleResolution": "NodeNext"`, `"strict": true` in `tsconfig.json`.
40
+ </Step>
41
+ <Step title="Create a session, stream deltas, and dispose cleanly">
42
+ ```typescript
43
+ import { createAgentSession, ModelRuntime, SessionManager } from "@bastani/atomic";
44
+
45
+ const modelRuntime = await ModelRuntime.create();
46
+
47
+ const { session } = await createAgentSession({
48
+ sessionManager: SessionManager.inMemory(),
49
+ modelRuntime,
50
+ });
51
+
52
+ session.subscribe((event) => {
53
+ if (event.type === "message_update" && event.assistantMessageEvent.type === "text_delta") {
54
+ process.stdout.write(event.assistantMessageEvent.delta);
55
+ }
56
+ });
57
+
58
+ try {
59
+ await session.prompt("What files are in the current directory?");
60
+ } finally {
61
+ await session.dispose();
62
+ }
63
+ ```
64
+ </Step>
65
+ </Steps>
51
66
 
52
67
  - **`ModelRuntime`:** Async runtime for credentials, native providers, and dynamic catalogs. Accepts `authPath`, `modelsPath`, `credentials`, runtime auth overrides, and catalog options (`allowModelNetwork`, `modelRefreshTimeoutMs`, `modelsStorePath`, `modelsStore`; see [Model catalog persistence and refresh](/sdk/reference#model-catalog-persistence-and-refresh)). Legacy synchronous facades `ModelRegistry` and `AuthStorage` remain available, and `readStoredCredential(provider, authPath?)` reads one stored credential.
53
68
  - **Exact model restoration:** Call `await resolveRestoredModelReference(provider, modelId, modelRuntime)` to resolve an authenticated saved model (including custom or dynamic IDs) or receive `undefined` without falling back to a default.
@@ -93,7 +108,7 @@ const { session: custom } = await createAgentSession({
93
108
  - **Startup hooks and rebinding:** `createAgentSession()` runs extension `session_start` hooks before resolving. Pass `extensionBindings` here if startup hooks need them; later `session.bindExtensions(...)` calls update bindings without replaying `session_start`.
94
109
  - **Explicit recovery:** Opening a session never recovers interrupted work automatically. Call `await session.startPendingRecovery("resume")` once ready to display output; it returns `{ replayed, dropped, completions, notices }`.
95
110
 
96
- ### Workspaces
111
+ ### Workspaces {#workspaces}
97
112
 
98
113
  Bind a session to a Git repository, branch, and worktree with `workspace({ ... })` (requires Git 2.33+):
99
114
 
@@ -107,9 +122,13 @@ const reviewer = await createAgentSession({ workspace: api.readOnly() });
107
122
  ```
108
123
 
109
124
  - **Resolution:** Local `repo` must point to a repository root. Remote repositories clone once under `<storageHome>/repos/` ([storage home](/storage#storage-home)) and create worktrees after fetching. Missing branches start from `base`; existing worktrees must match repository and branch (interrupted checkouts re-create automatically). Explicit `cwd` must stay inside the worktree, and an explicit `sessionManager` must already point inside it (`WorkspaceConfigError` otherwise).
110
- - **Read-only (`api.readOnly()`):** Removes and blocks `write`, `edit`, and `todo` even if listed in `tools`. Shell tools still run because read-only workspaces are not an OS sandbox. Child sessions stay read-only even with their own workspace.
125
+ - **Read-only (`api.readOnly()`):** Removes and blocks `write`, `edit`, and `todo` even if listed in `tools`. Child sessions stay read-only even with their own workspace.
111
126
  - **Persistence and PRs:** Bindings persist as a `workspace_binding` entry and restore on reopen (call `bindSessionWorkspace(workspace, sessionManager, signal?)` beforehand if you need the resolved path early). Inspect commits with `workspaceChangeSet(binding)` and open pull requests via `publishPullRequest(changeSet, { draft: true })`.
112
- - **Errors:** Invalid options throw `WorkspaceConfigError`. Binding failures throw `WorkspaceBindingError` with one of these `code` values: `wrong-repository`, `wrong-branch`, `conflicting-worktree-input`, `invalid-repository`, `unknown-base`, `cwd-outside-worktree`, `git-unavailable`, `git-failed`, `filesystem-failed`, `drift`, `writer-conflict`, or `incomplete-worktree`.
127
+ - **Errors:** Invalid options throw `WorkspaceConfigError`. Binding failures throw `WorkspaceBindingError` with `code` set to `wrong-repository`, `wrong-branch`, `conflicting-worktree-input`, `invalid-repository`, `unknown-base`, `cwd-outside-worktree`, `git-unavailable`, `git-failed`, `filesystem-failed`, `drift`, `writer-conflict`, or `incomplete-worktree`. See [Workspace](/sdk/reference#workspace) for the full helper and error-class list.
128
+
129
+ <Warning>
130
+ Read-only workspaces are **not** an OS sandbox. Shell tools (`bash`, `powershell`) can still run and modify files unless you disable them via `tools`/`excludedTools` or isolate the process in a container or VM.
131
+ </Warning>
113
132
 
114
133
  ### Shared resource admission
115
134
 
@@ -139,7 +158,7 @@ const { session } = await createAgentSession({ resourceAdmission });
139
158
 
140
159
  ### Session storage
141
160
 
142
- Sessions default to local SQLite at `~/.atomic/workflows/journal.sqlite` with the `session_` table prefix. Override storage per session with `sessionStore`, `storage`, or an explicit `sessionManager`. Read the **[SDK storage guide](/sdk/storage)** for complete recipes across all five backends, `createAgentSessionRuntime()` wiring, `SessionManager` CRUD, `JsonlSessionStore` `exactDirectory` behavior, `npm install` vs `atomic install` adapter resolution, ownership and close rules, and `StorageError` handling.
161
+ Sessions default to local SQLite at `~/.atomic/workflows/journal.sqlite` with the `session_` table prefix. Override storage per session with `sessionStore`, `storage`, or an explicit `sessionManager`. Read [Configure session storage](/sdk/storage) for complete recipes across all four backends, `createAgentSessionRuntime()` wiring, `SessionManager` CRUD, `JsonlSessionStore` `exactDirectory` behavior, adapter resolution, ownership rules, and `StorageError` handling.
143
162
 
144
163
  | Backend | Package | How to pass it to `createAgentSession()` |
145
164
  | --- | --- | --- |
@@ -148,7 +167,7 @@ Sessions default to local SQLite at `~/.atomic/workflows/journal.sqlite` with th
148
167
  | In-memory | Built into `@bastani/atomic` | `new MemorySessionStore()` (caller-owned) or `{ kind: "memory" }` (discarded on `dispose()`) |
149
168
  | PostgreSQL (16+ for sessions) | [`@bastani/atomic-storage-postgres`](/libraries/storage-postgres) | `{ kind: "adapter", module: POSTGRES_ADAPTER_PACKAGE, ... }` or caller-owned `openPostgresDatabase()` |
150
169
 
151
- Quick local SQLite session. Atomic opens the store and closes it in `dispose()`:
170
+ Quick local SQLite session (Atomic opens the store and closes it in `dispose()`):
152
171
 
153
172
  ```typescript
154
173
  import { createAgentSession } from "@bastani/atomic";
@@ -193,7 +212,7 @@ try {
193
212
  - **Precedence:** Atomic resolves storage in order from `sessionManager`, `sessionStore`, `storage`, process flags and variables (`ATOMIC_SESSIONS_STORAGE` and `ATOMIC_STORAGE`), settings (`sessions.storage` before `storage`), and default SQLite. Memory is never an automatic fallback.
194
213
  - **Ownership and mutations:** Atomic closes stores it opened from selection objects during `dispose()`, while leaving caller-owned `SessionStore`, `SessionManager`, and `database` instances open. Await every `SessionManager` write and every `atomic.appendEntry`, `setSessionName`, `setLabel`, `setThinkingLevel`, and `cycleThinkingLevel` call; there is no `flush()` method. `ExtensionContext.sessionSignal` aborts when reload or shutdown starts so extensions can cancel waits while finishing in-flight writes.
195
214
 
196
- See the **[SDK storage guide](/sdk/storage)** for all five backends, `createAgentSessionRuntime()` wiring, `SessionManager` CRUD, `JsonlSessionStore` `exactDirectory` behavior, `npm install` vs `atomic install` adapter resolution, ownership and close rules, and `StorageError` handling. For CLI session commands, the full `SessionManager` method list, operator setup, and cross-machine resume, see [Sessions](/sessions), [SessionManager API](/session-format#sessionmanager-api), [Storage](/storage), and [Resume on any machine](/guides/resume-on-any-machine).
215
+ For CLI session commands, the full `SessionManager` method list, operator setup, and cross-machine resume, see [Sessions](/sessions), [SessionManager API](/session-format#sessionmanager-api), [Storage](/storage), and [Resume on any machine](/guides/resume-on-any-machine).
197
216
 
198
217
  ### Human input without a terminal
199
218
 
@@ -228,7 +247,7 @@ async function attachApplication(humanInput: HostInput) {
228
247
 
229
248
  Read `session.sessionSummary` (`summary` and `summarizedThroughId`) or inspect `SessionManager.list()` / `listAll()`. Stored summaries remain readable when `sessionSummary.enabled` is `false`; `SessionManager.inMemory()` never generates summaries.
230
249
 
231
- ### Worktree snapshots
250
+ ### Worktree snapshots {#worktree-snapshots}
232
251
 
233
252
  SQLite and adapter-backed sessions capture checkout state automatically. Passing a reopened `sessionManager` to `createAgentSession({ sessionManager })` (or `runtime.rehydrate()`) restores missing or drifted checkouts into fresh worktrees while leaving matching local checkouts untouched. If a checkout cannot be rebuilt or Git is unavailable, resume continues with a warning notice instead of failing fast:
234
253
 
@@ -240,9 +259,9 @@ const { session } = await createAgentSession({ sessionManager });
240
259
  ```
241
260
 
242
261
  - By default in the SDK (`resume.waitForBlueprint: "tools"`), `createAgentSession()` returns immediately while blueprint setup runs in the background and gates tool calls. Call `await blueprintBuildSettled(sessionId)` to wait explicitly, register `onBlueprintBuildFinished(listener)` for warnings, or set `resume.waitForBlueprint: "prompt"` to block startup (see [Start the first turn while the build runs](/guides/resume-on-any-machine#start-the-first-turn-while-the-build-runs)).
243
- - Override per-session snapshot settings with `createAgentSession({ snapshots: { enabled: false } })`. Exported helpers include `captureWorktreeSnapshot()`, `restoreWorktreeSnapshot()`, `verifyWorktree()`, `session.sessionManager.getWorktreeRootMappings()`, `latestResumeTimings()`, `formatResumeTimings()`, and `session.exportToJsonl()`. See [Worktree snapshots](/worktree-snapshots).
262
+ - Override per-session snapshot settings with `createAgentSession({ snapshots: { enabled: false } })`. Exported helpers include `captureWorktreeSnapshot()`, `restoreWorktreeSnapshot()`, `verifyWorktree()`, `session.sessionManager.getWorktreeRootMappings()`, `latestResumeTimings()`, `formatResumeTimings()`, and `session.exportToJsonl()`. See [Worktree snapshots](/worktree-snapshots) and [Worktree snapshots reference](/worktree-snapshots/reference).
244
263
 
245
- ### Intercom group and reach
264
+ ### Intercom group and reach {#intercom-group-and-reach}
246
265
 
247
266
  Isolate multi-session hosts in one process with broker-enforced `intercom` policies (also accepted by `createAgentSessionFromServices()`):
248
267
 
@@ -258,7 +277,7 @@ await session.intercom.setReachable(["doc-1907", "doc-2011"]);
258
277
  - Group names are trimmed of surrounding whitespace, cannot be empty, cannot exceed 1,024 characters, and cannot be the reserved names `"auto"` or `"true"` (case-insensitively). Duplicates and self-references in `reachable` are removed automatically.
259
278
  - `setReachable()` updates live policy on the broker and leaves newly unreachable groups. Calling it on a session created without `intercom`, or passing an invalid group name or more than 1,000 reachable groups, throws `IntercomPolicyError` (which extends `TypeError`).
260
279
 
261
- ### Subagent children
280
+ ### Subagent children {#subagent-children}
262
281
 
263
282
  Children inherit the parent's `ModelRuntime`, settings, `agentDir`, `scopedModels`, `fallbackModels`, `customTools`, `resourceAdmission`, `humanInput`, and diagnostics. Working directory resolves in order: child `workspace`, child `cwd`, child `sessionManager.getCwd()`, then parent `cwd` or worktree.
264
283
 
@@ -267,7 +286,7 @@ Children inherit the parent's `ModelRuntime`, settings, `agentDir`, `scopedModel
267
286
 
268
287
  ### Driving a session
269
288
 
270
- `AgentSession` is the handle for prompting, queueing, model switching, events, compaction, and disposal:
289
+ `AgentSession` is the primary handle for prompting, queueing, model switching, events, compaction, and disposal:
271
290
 
272
291
  ```typescript
273
292
  interface AgentSession {
@@ -317,6 +336,8 @@ interface AgentSession {
317
336
  }
318
337
  ```
319
338
 
339
+ `AgentSession` also exposes `stopTurns()`, `sendUserMessage()`, `sendCustomMessage()`, `executeBash()` / `abortBash()`, `exportToJsonl()` / `exportToHtml()`, `getSessionStats()`, `getContextUsage()`, `setActiveToolsByName()`, `setScopedModels()`, `reload()`, and cache-warming controls (`cacheWarmingStatus`, `setCacheWarmingMode()`). See [AgentSession and AgentSessionRuntime](/sdk/reference#agentsession-and-agentsessionruntime) for every method.
340
+
320
341
  **Clean stop and disposal:** Always `await session.dispose()` in `finally` (60 s drain limit). If any cleanup step fails or stalls, `dispose()` rejects with an `AggregateError` tagged with `code: "ShutdownFailed"` (inspect `error.errors` for the individual causes). Pass `{ pauseQueuedMessages: true }` when aborting before disposal so arriving background notices do not launch another turn:
321
342
 
322
343
  ```typescript
@@ -329,7 +350,7 @@ try {
329
350
  ```
330
351
 
331
352
  - `setModel(model, { thinkingLevel: "high", persist: true })` clamps unsupported thinking levels and optionally writes global defaults (project overrides still win at startup).
332
- - `setCompactionModel(model, scope?, options?)` and `setDecisionModel(model, scope?, options?)` update the active session's compaction or decision model immediately without restarting or reloading. They save to `"global"` (default) or `"project"` settings unless `{ persist: false }` is passed. Pass `""` or `"auto"` for automatic selection, or an exact `provider/model` ID. Invalid values throw `CompactionConfigError` or `DecisionConfigError` synchronously. See [Compaction](/compaction) and [Structured decisions API](/sdk/structured-decisions).
353
+ - `setCompactionModel(model, scope?, options?)` and `setDecisionModel(model, scope?, options?)` update the active session's compaction or decision model immediately without restarting or reloading. They save to `"global"` (default) or `"project"` settings unless `{ persist: false }` is passed. Pass `""` or `"auto"` for automatic selection, or an exact `provider/model` ID. Invalid values throw `CompactionConfigError` or `DecisionConfigError` synchronously. See [Compaction](/compaction) and [Make structured decisions](/sdk/structured-decisions).
333
354
  - Extension APIs reject new actions with an `Error` tagged with `code: "SessionClosed"` once close or reload starts. Give `atomic.exec()` calls timeouts or abort signals. Custom messages with `persistWhenStreaming: true` survive reload.
334
355
 
335
356
  #### Event subscriptions
@@ -359,9 +380,9 @@ Disposal and reload drain admitted callbacks, model refreshes, and `atomic.exec(
359
380
 
360
381
  - `await runtime.dispose()` rejects new replacements, drains pending work, waits up to 3 s for in-flight OAuth token refreshes, and stops Intercom broker startup. Pass `{ fromSignal: true }` on `SIGTERM` or `SIGHUP` so `session_shutdown` handlers receive the signal flag.
361
382
  - Unrecovered `persist: true` settings write failures cause `dispose()` to reject with `AggregateError` (`code: "ShutdownFailed"`). `executeBash()` IDs are correlation IDs: `abortBash(id)` cancels all active calls sharing that ID.
362
- - For transactional reload lifecycle effects (`publishExtensionContextEffect`, `registerExtensionContextRetirementEffect`), see [Reload lifecycle and resource ownership](/sdk/reference#reload-lifecycle-and-resource-ownership).
383
+ - For reload lifecycle effects (`publishExtensionContextEffect`, `registerExtensionContextRetirementEffect`), see [Reload lifecycle and resource ownership](/sdk/reference#reload-lifecycle-and-resource-ownership).
363
384
 
364
- #### Compaction and tree navigation
385
+ #### Compaction and tree navigation {#compaction-and-tree-navigation}
365
386
 
366
387
  `session.compact({ query?, compactionModel? })` stops active runs, clears context or replaces it with output from a configured compactor model such as `morph/morph-compactor`, appends a `verbatim-lines` `compaction` entry, and returns `VerbatimCompactionResult` (`form: "cleared" | "compacted"`). It rejects with `CompactionStateError` (`code: "nothing-to-compact"`) when nothing new has entered context since the last boundary; concurrent calls coalesce. Call `session.setCompactionModel(model, scope?, options?)` to change the configured compactor live. A chat, classifier, or unknown `compactionModel` ID clears the context with a notice instead of failing. See [Compaction errors](/compaction/reference#compaction-errors), [Compaction](/compaction), and [Session format](/session-format#compactionentry).
367
388
 
@@ -402,9 +423,9 @@ const runtime = await createAgentSessionRuntime(createRuntime, {
402
423
  });
403
424
  ```
404
425
 
405
- After any replacement, `runtime.session` points to the new session. Re-subscribe to events, call `bindExtensions()` again, and call `startPendingRecovery("resume")` after `switchSession()`.
426
+ After any replacement, `runtime.session` points to the new session. Re-subscribe to events, call `bindExtensions()` again, call `runtime.takeResumeNotices()` to display any resume warnings, and call `startPendingRecovery("resume")` after `switchSession()`. Pass `interactive: true` to `createAgentSessionRuntime()` only when attaching an interactive UI (by default `false`, so resumed worktree blueprint builds run behind the first turn unless `resume.waitForBlueprint` is set).
406
427
 
407
- ### Releasing idle sessions
428
+ ### Releasing idle sessions {#releasing-idle-sessions}
408
429
 
409
430
  Free in-memory resources (agent loop, extensions, tools, timers, MCP and Intercom connections) for idle conversations with `session.release()`, and restore them on demand with `runtime.rehydrate(sessionId)`:
410
431
 
@@ -415,7 +436,7 @@ await live.prompt("Here is the CI result you were waiting for.");
415
436
  await live.release();
416
437
  ```
417
438
 
418
- - **Auto-release:** Pass `releaseWhenIdle: { afterMs }` (`0` to `2,147,483,647` ms; invalid values throw `AgentReleaseConfigError`) to `createAgentSession()` or `createAgentSessionFromServices()`. If the session is still busy when the timer fires, Atomic reschedules for another `afterMs` instead of failing. Managed by the process-wide `agentWakeDispatcher()` (`handle`, `deliver`, `onUnobservedFailure`, `whenIdle`, `stats()`).
439
+ - **Auto-release:** Pass `releaseWhenIdle: { afterMs }` (`0` to `2,147,483,647` ms; invalid values throw `AgentReleaseConfigError`) to `createAgentSession()` or `createAgentSessionFromServices()`. Combining `releaseWhenIdle` with `SessionManager.inMemory()` rejects immediately in `createAgentSession()` with `AgentRehydrateError` (`code: "not-reopenable"`) before constructing the session. If the session is still busy when the timer fires, Atomic reschedules for another `afterMs` instead of failing. Managed by the process-wide `agentWakeDispatcher()` (`handle`, `deliver`, `onUnobservedFailure`, `whenIdle`, `stats()`).
419
440
  - **Lifecycle:** Emits `session_released` before closing. Rejects with retryable `session-busy` if streaming, compacting, running shells or background tasks, or holding queued messages. `rehydrate()` opens at the current context window (`readHistory()` and `readEntry()` fetch older entries), shares matching-cwd `services`, runs alongside `runtime.session` without replacing it, deduplicates concurrent calls, and closes on `runtime.dispose()`.
420
441
  - **In-memory store spilling:** A directly constructed `new MemorySessionStore()` has no spill directory and keeps released session history in RAM. Opening a memory store through `resolveSessionStore(cwd, { agentDir, sessionStore: { kind: "memory" } })` enables disk spilling to private owner-only files (`0700`/`0600`) under `<agentDir>/released-history/` with integrity verification (`SessionSpillError` on missing or corrupt files; see [Storage errors](/storage#storage-errors)). Spill files clean up on exit and sweep on restart after crashes; worker-only hosts must close stores before `worker.terminate()`. Custom stores can implement `releaseSession(id)`, `readEntryRange(id, query)`, and `readForkWindow(id, entryId)`.
421
442
 
@@ -459,7 +480,7 @@ Access the underlying [`@bastani/atomic-agent-core`](/libraries/agent-core) `Age
459
480
 
460
481
  ### Events and transcript collection
461
482
 
462
- Subscribe with `session.subscribe((event) => ...)` for `message_start`/`message_update`/`message_end`, `tool_execution_start`/`update`/`end`, `agent_start`/`end`/`settled`, `turn_start`/`end`, `queue_update`, `compaction_start`/`end`, and retry events. Never mutate `message_start`'s live partial object (seed mid-turn subscribers from `session.agent.state.streamingMessage`).
483
+ Subscribe with `session.subscribe((event) => ...)` for `message_start`/`message_update`/`message_end`, `tool_execution_start`/`update`/`end`, `agent_start`/`end`/`settled`, `turn_start`/`end`, `queue_update`, `compaction_start`/`end`, `session_storage_reconnect` (emitted when ordered PostgreSQL session writes wait for reconnection or recover), and retry/fallback events. Never mutate `message_start`'s live partial object (seed mid-turn subscribers from `session.agent.state.streamingMessage`).
463
484
 
464
485
  Use `createTranscript()` to collect ordered JSON-serializable parts (`text`, `thinking`, and `toolCall` with `result`). Pass `toolResult: (name) => "details" | "content"` to prefer structured details over text; redacted thinking is omitted, and nested tool events (`parentToolCallId`) are ignored.
465
486
 
@@ -478,7 +499,6 @@ console.log(JSON.stringify(transcript.parts()));
478
499
  ## Complete example
479
500
 
480
501
  ```typescript
481
- import { getModel } from "@bastani/atomic-ai/compat";
482
502
  import { Type } from "@bastani/atomic/typebox";
483
503
  import {
484
504
  AuthStorage,
@@ -511,7 +531,7 @@ const statusTool = defineTool({
511
531
  }),
512
532
  });
513
533
 
514
- const model = getModel("anthropic", "claude-opus-4-5");
534
+ const model = modelRuntime.getModel("anthropic", "claude-opus-4-5");
515
535
  if (!model) throw new Error("Model not found");
516
536
 
517
537
  const settingsManager = SettingsManager.inMemory({
@@ -557,8 +577,9 @@ try {
557
577
 
558
578
  ### Error classes vs. `.code`-tagged errors
559
579
 
560
- - **`NativeModuleUnavailableError` is exported from `@bastani/atomic`** (`code: "NativeModuleUnavailable"`). `createAgentSession()` throws it when `@bastani/atomic-natives` cannot load or came from a different Atomic release.
561
- - **`ShutdownFailed`, `HumanInputUnavailable`, `InvalidHostInput`, `BuiltinUnavailable`, and `SessionClosed` are NOT exported classes.** They are standard `Error` (or `AggregateError` for `ShutdownFailed`) instances tagged with string `.code` properties. Check `(error as { code?: string }).code === "HumanInputUnavailable"` (and `error instanceof AggregateError` for `ShutdownFailed`) rather than `instanceof`.
580
+ <Note>
581
+ `NativeModuleUnavailableError` is an exported class (`code: "NativeModuleUnavailable"`). By contrast, `ShutdownFailed`, `HumanInputUnavailable`, `InvalidHostInput`, `BuiltinUnavailable`, and `SessionClosed` are **not** exported classes — they are standard `Error` (or `AggregateError` for `ShutdownFailed`) instances tagged with string `.code` properties. Branch on `(error as { code?: string }).code` rather than `instanceof`.
582
+ </Note>
562
583
 
563
584
  ### Updating Atomic while your program runs
564
585
 
@@ -571,26 +592,27 @@ When `npm install`, `pnpm add`, or `bun add` replaces `@bastani/atomic` while a
571
592
 
572
593
  Also restart after an in-place update if your process launched on an older Atomic release or before importing `@bastani/atomic/rpc-entry`.
573
594
 
574
- ### Node 22 hosts
575
-
576
- Atomic no longer runs on Node.js 22. It needs Node.js 24.20.0 or newer. To move a host off Node 22:
577
-
578
- 1. Run `node --version` to see which version you have.
579
- 2. Install the current Node.js 24 LTS release from [nodejs.org](https://nodejs.org/en/download), or with `nvm install 24`, `fnm install 24` or `mise use -g node@24`.
580
- 3. Reinstall your project's dependencies with the new Node.js, for example with `npm install`.
581
- 4. If you started your host with `node --experimental-async-context-frame` to make Node 22 faster, remove the flag. Node 24 doesn't need it and refuses to start with it.
582
-
583
- See [Node.js version](/getting-started/installation#nodejs-version) for more on choosing a version.
584
-
585
- ### Migrating an existing Node host
586
-
587
- - **Builtins load automatically:** Remove manual registration of shipped builtin extensions; disable selectively with `builtins` and restrict tools with `tools` / `excludedTools` (`tools: []` excludes Intercom too).
588
- - **Host input:** Supply all five `HostInput` methods (`confirm`, `select`, `input`, `editor`, `questionnaire`) on `extensionBindings.humanInput`, honoring abort signals and returning literal `true` only on explicit approval (omission rejects with `code: "HumanInputUnavailable"`).
589
- - **Removed `workflows` builtin:** Remove `workflows` from `builtins`; workflow SDK exports were removed. Convert older workflow files into skills ([Migrating workflows](/orchestration/migrating-workflows)).
590
- - **Always `await session.dispose()` in `finally`:** Disposal is async and may reject with `AggregateError` (`code: "ShutdownFailed"`) after attempting all cleanup; do not swallow it or call `process.exit()`.
591
- - **Diagnostics and packaging:** Capture operational events via `extensionBindings.onDiagnostic`. If creation fails with `code: "BuiltinUnavailable"`, reinstall the full package rather than copying only `dist/index.js`.
592
- - **Removed experimental client:** `@bastani/atomic/client` was removed; embed `createAgentSession()` directly or drive [RPC mode](/rpc) (`--mode rpc` / `@bastani/atomic/rpc-entry`).
595
+ <AccordionGroup>
596
+ <Accordion title="Upgrading from Node.js 22 hosts">
597
+ Atomic requires Node.js 24.20.0 or newer and no longer runs on Node.js 22:
598
+
599
+ 1. Run `node --version` to verify your installed runtime.
600
+ 2. Install the current Node.js 24 LTS release from [nodejs.org](https://nodejs.org/en/download), or with `nvm install 24`, `fnm install 24`, or `mise use -g node@24`.
601
+ 3. Reinstall project dependencies with `npm install`.
602
+ 4. Remove `--experimental-async-context-frame` from your startup command if you used it on Node 22 (Node 24 refuses to start with that flag).
603
+
604
+ See [Node.js version](/getting-started/installation#nodejs-version) for details.
605
+ </Accordion>
606
+ <Accordion title="Migrating an existing Node host from earlier releases">
607
+ - **Builtins load automatically:** Remove manual registration of shipped builtin extensions; disable selectively with `builtins` and restrict tools with `tools` / `excludedTools` (`tools: []` excludes Intercom too).
608
+ - **Host input:** Supply all five `HostInput` methods (`confirm`, `select`, `input`, `editor`, `questionnaire`) on `extensionBindings.humanInput`, honoring abort signals and returning literal `true` only on explicit approval (omission rejects with `code: "HumanInputUnavailable"`).
609
+ - **Removed `workflows` builtin:** Remove `workflows` from `builtins`; workflow SDK exports were removed. Convert older workflow files into skills ([Migrating workflows](/orchestration/migrating-workflows)).
610
+ - **Always `await session.dispose()` in `finally`:** Disposal is async and may reject with `AggregateError` (`code: "ShutdownFailed"`) after attempting all cleanup; do not swallow it or call `process.exit()`.
611
+ - **Diagnostics and packaging:** Capture operational events via `extensionBindings.onDiagnostic`. If creation fails with `code: "BuiltinUnavailable"`, reinstall the full package rather than copying only `dist/index.js`.
612
+ - **Removed experimental client:** `@bastani/atomic/client` was removed; embed `createAgentSession()` directly or drive [RPC mode](/rpc) (`--mode rpc` / `@bastani/atomic/rpc-entry`).
613
+ </Accordion>
614
+ </AccordionGroup>
593
615
 
594
616
  ## API reference
595
617
 
596
- All factory options, resource loaders, return types, run modes (`InteractiveMode`, `runPrintMode`, `runRpcMode`), exports, and supervised-task APIs are documented in the [SDK API reference](/sdk/reference).
618
+ All factory options, `AgentSession` and `AgentSessionRuntime` methods, resource loaders, run modes (`InteractiveMode`, `runPrintMode`, `runRpcMode`), error families, task supervision, and exports are documented in the [SDK API reference](/sdk/reference).
package/docs/security.md CHANGED
@@ -1,14 +1,14 @@
1
1
  ---
2
- title: "Security and project trust"
3
- sidebarTitle: "Security"
2
+ title: "Manage security and project trust"
3
+ sidebarTitle: "Security & Project Trust"
4
4
  description: "Configure project trust, restrict tools, understand local security boundaries, and safely export credentials."
5
5
  ---
6
6
 
7
- Atomic is a local coding agent. It runs with the permissions of the user account that starts it and treats files writable by that user as inside the same local trust boundary.
7
+ Atomic is a local coding agent. It runs with the permissions of the OS user account that starts it and treats files writable by that user as inside the same local trust boundary.
8
8
 
9
9
  ## Project trust
10
10
 
11
- Project trust controls whether Atomic loads project-local settings, instructions, resources, packages, and extensions. It is not a sandbox and does not restrict what tools can do once a session starts.
11
+ Project trust controls whether Atomic loads project-local settings, instructions, resources, packages, and extensions before work begins. It is not a sandbox and does not limit what tools can do once a session starts.
12
12
 
13
13
  Atomic treats a folder as having trust-gated inputs when it finds any of these from the current working directory:
14
14
 
@@ -17,11 +17,13 @@ Atomic treats a folder as having trust-gated inputs when it finds any of these f
17
17
  - `.agents/skills` in the current directory or an ancestor directory. `~/.agents/skills` in your home directory is always treated as a trusted user resource and never triggers project trust.
18
18
  - At the nearest ancestor project root (any ancestor containing `.atomic/`, `.pi/`, or `.agents/`), any `.agents/` directory, `.atomic/agents`, `.pi/agents`, `.atomic/settings.json`, or `.pi/settings.json`. Your home directory is never treated as an ancestor project root for these checks.
19
19
 
20
+ ### How decisions are stored and prompted
21
+
20
22
  Saved decisions live in `~/.atomic/agent/trust.json`, keyed by canonical directory path mapped to `true` or `false`. Atomic checks `trust.json` from the current directory upward and applies the closest saved decision ahead of global defaults. A saved `false` entry for the current folder or an ancestor still marks the folder untrusted even when no trust-gated files are present right now.
21
23
 
22
- On Windows, saved paths match case-insensitively and saving removes duplicate entries with different casing. Atomic writes `trust.json` atomically through a temporary file while holding `trust.json.lock` (waiting up to 5 seconds, or taking over stale locks older than 10 seconds) and follows symlinks to update the target file. If `trust.json` contains malformed JSON or invalid values, Atomic warns once and treats it as empty until the next save. If the file cannot be read because of permissions, saving fails instead of overwriting it.
24
+ Atomic saves `trust.json` safely across concurrent sessions and follows symlinks. On Windows, saved paths match case-insensitively and saving removes duplicate entries with different casing. If `trust.json` contains malformed JSON or invalid values, Atomic warns once and treats it as empty until the next save; if permissions prevent reading the file, saving fails instead of overwriting it.
23
25
 
24
- When no saved decision matches and the folder has trust-gated inputs, Atomic checks global `defaultProjectTrust` in `~/.atomic/agent/settings.json` (`"ask"`, `"always"`, or `"never"`; default `"ask"`). `defaultProjectTrust` is global-only: Atomic ignores it in project `.atomic/settings.json` and falls back to `"ask"` if the global value is invalid or unreadable (printing a warning on read failure).
26
+ When no saved decision matches and the folder has trust-gated inputs, Atomic checks global `defaultProjectTrust` in `~/.atomic/agent/settings.json` (`"ask"`, `"always"`, or `"never"`; default `"ask"`). `defaultProjectTrust` is global-only: Atomic ignores it in project `.atomic/settings.json` and falls back to `"ask"` if the global value is invalid or unreadable.
25
27
 
26
28
  In an interactive session with `defaultProjectTrust: "ask"`, Atomic opens a trust prompt with five options (four at the filesystem root):
27
29
 
@@ -33,9 +35,11 @@ In an interactive session with `defaultProjectTrust: "ask"`, Atomic opens a trus
33
35
 
34
36
  Choosing **Trust parent folder** saves `true` for the parent directory and removes any saved entry for the current directory so it inherits from the parent. Pressing `Escape` cancels the prompt and leaves the folder untrusted for this session only without writing to `trust.json`.
35
37
 
36
- Use the `Up` and `Down` arrow keys to pick an option, then press `Enter`. If you typed or pasted text before or while the prompt opened, `Enter` is disarmed so pressing `Enter` adds a newline to your draft instead of confirming trust by accident. Press `Up` or `Down` once to arm `Enter`, then confirm. Your draft stays in the editor afterward so you can review and send it.
38
+ <Note>
39
+ Use `Up`/`Down` and `Enter` to confirm. If you typed or pasted text before or while the prompt opened, `Enter` is disarmed so it adds a newline to your draft instead of confirming trust by accident — press `Up` or `Down` once to arm `Enter`.
37
40
 
38
- Run `/trust` at any time to save a persistent choice (**Trust**, **Trust parent folder**, or **Do not trust**). Restart Atomic after saving in `/trust` for the new choice to take effect; `/reload` does not re-evaluate a newly saved `/trust` decision. To clear a saved decision completely, remove its path entry from `~/.atomic/agent/trust.json` (or choose **Trust parent folder** to clear a child override).
41
+ Run `/trust` at any time to save a persistent choice, then **restart Atomic** for the new choice to take effect (`/reload` does not re-evaluate a newly saved `/trust` decision). To clear a saved entry completely, remove its path from `~/.atomic/agent/trust.json`.
42
+ </Note>
39
43
 
40
44
  If you start an interactive session in a clean folder (no trust-gated inputs at startup and neither `--approve` nor `--no-approve`) and create trust-gated files such as `.atomic/settings.json` or `.atomic/extensions` during that session, running `/reload` automatically saves `true` for that folder in `trust.json` when no decision is saved yet.
41
45
 
@@ -48,26 +52,26 @@ Trusting a project lets Atomic load:
48
52
  - Project-local `AGENTS.override.md`, `AGENTS.md`, `AGENTS.MD`, `CLAUDE.md`, and `CLAUDE.MD`, plus project `.agents/skills`
49
53
  - Project subagent definitions and agent overrides (`.atomic/agents`, `.pi/agents`, and `.agents`)
50
54
  - Earlier workflow files for on-demand [conversion to skills](/orchestration/migrating-workflows) (read as text only, never executed, modified, or deleted)
51
- - Project MCP server config ([`.atomic/mcp.json`](/mcp-servers); `auth.provider` is forbidden in project configs and package manifests, and `!command` values run shell commands) and blueprint builds ([`.atomic/blueprint.yaml`](/guides/resume-on-any-machine#set-the-environment-up-with-a-blueprint))
55
+ - Project MCP server config ([`.atomic/mcp.json`](/mcp-servers); reusing Atomic's saved provider credentials via `auth.provider` is forbidden in project configs and package manifests, while `!command` values run shell commands) and blueprint builds ([`.atomic/blueprint.yaml`](/guides/resume-on-any-machine#set-the-environment-up-with-a-blueprint))
52
56
  - Project-configured [packages](/packages) (`atomic install -l` requires project trust or `--approve`), automatic installation of missing project packages, and package-managed extensions
53
57
 
54
- Declining trust skips all of these project inputs. Global instructions, global skills, global settings, and explicit CLI resources remain available. Interactive sessions in an untrusted project display a warning; run `/trust` to save a decision, then restart Atomic.
58
+ Declining trust skips all of these project inputs while keeping global instructions, global skills, global settings, and explicit CLI resources available. Interactive sessions in an untrusted project display a warning; run `/trust` and restart Atomic to enable project inputs.
55
59
 
56
60
  ### Folders, worktrees, non-interactive runs, and extension hooks
57
61
 
58
- - **Per-folder trust:** Trust belongs to the folder a session works in, not the directory you started Atomic from. Resuming a session (`--resume`, `--continue`, `--session`, or `/resume`) applies that folder's trust decision and prompts if none is saved. Session-only choices last until Atomic exits and are never written to `trust.json`.
59
- - **Git worktrees:** A worktree outside its main repository folder has its own trust decision because it can check out different `.atomic` content. Choose **Trust parent folder** (at the prompt or in `/trust`) to trust sibling worktrees under one parent directory.
60
- - **Extension `project_trust` hooks:** Global extensions and explicit CLI `-e` extensions can handle the [`project_trust`](/extensions/events#project_trust) event ahead of `trust.json` and `defaultProjectTrust` (see `project-trust.ts` in [Extension examples](/extensions/examples#events-and-gates)). When such extensions are installed, Atomic waits for them before applying project settings, resources, or a project-configured session store. Handlers run in extension load order: returning `{ trusted: "undecided" }` passes to the next handler, and the first `{ trusted: "yes" }` or `{ trusted: "no" }` wins (and writes to `trust.json` when `remember: true`). If a handler throws an error, Atomic logs a warning and continues to the next handler, or falls back to `trust.json`, `defaultProjectTrust`, and the prompt. Hooks do not run when a folder has no trust-gated inputs or when `--approve` or `--no-approve` overrides trust. Switching to a resumed session in another folder shuts down the previous folder's extensions (waiting up to 5 seconds before continuing) before loading the resumed folder's extensions.
61
- - **Borrowed `-e` sources:** If `-e <dir>` discovers resources from that directory's `.atomic`, legacy `.pi`, or `.agents/skills`, Atomic checks `trust.json` under that source's canonical path (cached for the session) before loading them, because borrowed extensions run with your user permissions. Passing `--approve` (`-a`) or `--no-approve` (`-na`) also overrides trust for borrowed `-e` sources.
62
- - **Non-interactive runs:** Print mode (`-p`), `--mode json`, and `--mode rpc` never open a trust prompt. Without a saved decision, `defaultProjectTrust: "ask"` and `"never"` leave the project untrusted and skip project resources, while `"always"` trusts the project. Pass `--approve` (`-a`) or `--no-approve` (`-na`) to override trust for one run.
62
+ - **Per-folder trust.** Trust belongs to the folder a session works in, not the directory you launched Atomic from. Resuming a session (`--resume`, `--continue`, `--session`, or `/resume`) applies that folder's trust decision and prompts if none is saved. Session-only choices last until Atomic exits and never write to `trust.json`.
63
+ - **Git worktrees.** A worktree outside its main repository folder has its own trust decision because it can check out different `.atomic` content. Choose **Trust parent folder** (at the prompt or in `/trust`) to trust sibling worktrees under one parent directory.
64
+ - **Extension `project_trust` hooks.** Global and explicit CLI `-e` extensions can decide project trust through the [`project_trust`](/extensions/events#project_trust) hook before Atomic checks `trust.json` or prompts you. The first handler returning `{ trusted: "yes" }` or `{ trusted: "no" }` wins (and saves to `trust.json` when `remember: true`), while `{ trusted: "undecided" }` passes to later handlers and built-in trust rules; hooks do not run when `--approve` or `--no-approve` overrides trust. See `project-trust.ts` in [Extension examples](/extensions/examples#events-and-gates).
65
+ - **External `-e` directories.** If a directory passed to `-e <dir>` contains resources under its own `.atomic`, legacy `.pi`, or `.agents/skills`, Atomic checks `trust.json` for that directory's canonical path before loading them, because those extensions run with your user permissions. Passing `--approve` (`-a`) or `--no-approve` (`-na`) also overrides trust for those directories.
66
+ - **Non-interactive runs.** Print mode (`-p`), `--mode json`, and `--mode rpc` never open a trust prompt. Without a saved decision, `defaultProjectTrust: "ask"` and `"never"` leave the project untrusted and skip project resources, while `"always"` trusts the project. Pass `--approve` (`-a`) or `--no-approve` (`-na`) to override trust for one run.
63
67
 
64
68
  ## No built-in sandbox
65
69
 
66
- Atomic does not include a built-in sandbox. Built-in tools read, write, and edit files and run shell commands with the permissions of the Atomic process. Extensions run as TypeScript modules with the same permissions.
67
-
68
- Use OS isolation, a container, or a VM when you need a security boundary.
70
+ <Warning>
71
+ Atomic does **not** include a built-in sandbox. Built-in tools read, write, and edit files and execute shell commands with the permissions of the OS user running Atomic, and extensions execute as TypeScript modules with the same permissions. Use OS isolation, a container, or a VM whenever you need a security boundary.
72
+ </Warning>
69
73
 
70
- Project trust only guards project input loading so a repository cannot change settings or run extensions before you approve it. It does not make untrusted code, prompts, or model output safe. Prompt injection from repository files, comments, docs, context files, or command output is an inherent risk for any local coding agent.
74
+ Project trust only prevents an untrusted repository from changing settings or running extensions before you approve it. It does not make untrusted code, prompts, or model output safe. Prompt injection from repository files, comments, docs, context files, or command output is an inherent risk for any local coding agent.
71
75
 
72
76
  When shell tools are enabled, model-supplied commands run through the configured shell with your user permissions, and Atomic provides no command-level allowlist or denylist. Be careful with shells, interpreters, package managers, `curl`, `git`, `sudo`, `env`, `xargs`, and any other program that can run arbitrary commands.
73
77
 
@@ -77,7 +81,7 @@ You can narrow which tools a session exposes:
77
81
  - **Settings:** Configure `defaultTools` in [Settings](/settings#tools) globally or in a trusted project.
78
82
  - **SDK:** Pass `tools`, `excludedTools`, or `noTools` when creating a session ([SDK tools reference](/sdk/reference#tools)).
79
83
 
80
- On native Windows, Atomic enables the [`powershell` tool](/windows#powershell-tool) alongside `bash` whenever PowerShell is installed. Excluding `bash` alone still leaves `powershell` enabled. Exclude both when you want no shell execution:
84
+ On native Windows, Atomic enables the [`powershell` tool](/windows#powershell-tool) alongside `bash` whenever PowerShell is installed. Excluding `bash` alone leaves `powershell` enabled; exclude both to disable all shell execution:
81
85
 
82
86
  ```bash
83
87
  atomic --exclude-tools bash,powershell
@@ -89,11 +93,11 @@ Use a container, VM, remote sandbox, restricted OS account, or custom extension
89
93
 
90
94
  Atomic enforces several local guardrails by default:
91
95
 
92
- - **SSRF blocking on URL reads.** `read` blocks `localhost`, `.localhost`, private IP ranges, cloud metadata endpoints, and redirects to them ([Documents and URLs](/tools#documents-and-urls)). Set `ATOMIC_ALLOW_PRIVATE_URL_READS=1` only when a workflow must read private URLs ([Environment variables](/environment-variables)). Bundled `@bastani/web-access` also keeps local or intranet hosts and credentialed URLs out of remote fallbacks ([Web access](/web-access)).
96
+ - **Private-network blocking on URL reads (SSRF protection).** `read` blocks `localhost`, `.localhost`, private IP ranges, cloud metadata endpoints, and redirects to them ([Documents and URLs](/tools#documents-and-urls)). Set `ATOMIC_ALLOW_PRIVATE_URL_READS=1` only when a workflow must read private URLs ([Environment variables](/environment-variables)). Bundled `@bastani/web-access` also keeps local or intranet hosts and credentialed URLs out of remote fallbacks ([Web access](/web-access)).
93
97
  - **Opt-in browser cookies.** Gemini Web cookie lookup is disabled by default and activates only when you set `allowBrowserCookies: true` in `~/.atomic/web-search.json` or `ATOMIC_ALLOW_BROWSER_COOKIES=1` ([Web access](/web-access)).
94
98
  - **Worktree snapshot secret deny list.** [Worktree snapshots](/worktree-snapshots) exclude `.env*`, `*.pem`, `*.key`, `*.p12`, `*.pfx`, `credentials`, `credentials.json`, `.netrc`, `_netrc`, `.git-credentials`, `.pgpass`, and private SSH key files before `.atomic/snapshot-ignore` or Git staging. This deny list cannot be overridden ([What is left out](/worktree-snapshots#what-is-left-out)).
95
99
  - **Storage credentials and process overrides.** Shared storage rejects credentials embedded in URLs and saves static tokens in mode-`600` files. Process-level storage overrides (`--storage`, `--storage-file`, `ATOMIC_STORAGE`, `ATOMIC_SESSIONS_STORAGE`) come from the launching host and bypass project trust ([Selecting storage per process](/storage#selecting-storage-per-process)).
96
- - **Session sharing and debug snapshots.** `/share` uploads a private GitHub gist and strips worktree snapshots and large tool-output blobs, while keeping the rest of the transcript ([Exporting and sharing sessions](/usage#exporting-and-sharing-sessions)). `/debug` writes all current session messages unredacted to `~/.atomic/agent/atomic-debug.log` ([Diagnostics and debugging](/development#debugging)).
100
+ - **Session sharing and debug snapshots.** `/share` uploads a private GitHub gist and strips worktree snapshots and large tool-output blobs while keeping the rest of the transcript ([Exporting and sharing sessions](/usage#exporting-and-sharing-sessions)). `/debug` writes all current session messages unredacted to `~/.atomic/agent/atomic-debug.log` ([Diagnostics and debugging](/development#debugging)).
97
101
 
98
102
  ## Running untrusted or unattended work
99
103
 
@@ -103,59 +107,33 @@ See [Run Atomic in containers](/containerization) for common setups:
103
107
 
104
108
  - Run the whole `atomic` process inside Docker or NVIDIA OpenShell.
105
109
  - Run Atomic on the host while routing built-in file and shell tools into a Gondolin micro-VM.
106
- - Mount only the workspace paths the agent needs.
107
- - Avoid mounting host `~/.atomic` or `~/.atomic/agent` unless the container should access host sessions, settings, and credentials.
108
- - Pass only the minimum required API keys or short-lived tokens.
109
- - Restrict outbound network access when the task does not need it.
110
+ - Mount only the workspace paths the agent needs, and avoid mounting host `~/.atomic` or `~/.atomic/agent` unless the container should access host sessions, settings, and credentials.
111
+ - Pass only the minimum required API keys or short-lived tokens, and restrict outbound network access when the task does not need it.
110
112
  - Review diffs and outputs before copying files back to trusted systems.
111
113
 
112
114
  If you bind-mount a host directory read/write, writes inside the container or VM modify host files directly. Use read-only mounts or copy files in and out when you need to protect host checkouts from unintended writes.
113
115
 
114
116
  ## Credential export
115
117
 
116
- `atomic auth print-api-key`, `atomic auth print-bearer-token`, and `atomic auth check --credentials` export a resolved credential to stdout so external clients can reuse your Atomic authentication without reading `auth.json`. `atomic auth check` without `--credentials` stays status-only and never prints a secret. See [CLI credential commands](/reference/cli#credential-commands) and [Providers](/providers) for full command flags and provider auth setup.
118
+ `atomic auth print-api-key`, `atomic auth print-bearer-token`, and `atomic auth check --credentials` export a resolved credential to stdout so external clients can reuse your Atomic authentication without reading `auth.json`. Plain `atomic auth check` (without `--credentials`) stays status-only and never prints a secret.
117
119
 
118
120
  ```bash
119
- TOKEN=$(atomic auth print-bearer-token --provider openai-codex --model gpt-5.4 --min-expiry 45m)
121
+ TOKEN=$(atomic auth print-bearer-token --provider openai-codex --model gpt-6.2-sol --min-expiry 45m)
120
122
  KEY=$(atomic auth check --provider openai --credentials)
121
123
  ```
122
124
 
123
- Credential-export guarantees and exact flag rules:
124
-
125
- - **Stdout carries credentials only on explicit export.** Warnings, provider selection, refresh notices, and `atomic auth --help` go to stderr. Failed exports leave stdout empty (except partial write exit code `9`) and report status on stderr, or emit status-only JSON under `auth check --json --credentials`.
126
- - **Explicit targets and matching rules.** `print-api-key` and `print-bearer-token` always require `--model` (never an unnamed session model). Without `--provider`, both print subcommands use fuzzy model matching to infer the provider. If `--model` matches multiple configured providers, Atomic queries each candidate before exiting with code `3`, which can refresh and persist an expiring OAuth token on a candidate provider before reporting ambiguity. Pass `--provider` to avoid ambiguity and extra token checks. `auth check --credentials` requires `--provider` or an exact `--model` (never fuzzy matching).
127
- - **Flag scope and OAuth lifetime.** `print-bearer-token` and `auth check --credentials` require at least 30 minutes of remaining OAuth lifetime by default and refresh expiring tokens automatically. `--min-expiry <duration>` accepts `<integer><ms|s|m|h>` (case-insensitive, default `30m`), works only on `print-bearer-token`, and is rejected on `print-api-key` (even after `--`) and `auth check`. `--no-refresh` works only on `auth check` (rejected with exit code `1` on `print-bearer-token`) and refuses short-lived tokens without modifying `auth.json`.
128
- - **No file or clipboard sink.** There is no `--output` flag or clipboard option; redirect stdout yourself if you choose to save the output.
129
- - **JSON output on `auth check --json --credentials`.** A ready check emits `{"status":"ready","provider":"...","authType":"...","credentials":"..."}`. A non-ready check emits the status JSON object without a `credentials` field.
130
- - **Stream failure handling.** If a stream error occurs after the complete credential is written, Atomic reports the error on stderr and exits `0`. If writing fails partway through, Atomic exits with code `9` so callers discard the partial stdout bytes.
131
- - **No log leakage.** Atomic never writes exported credentials to debug logs, session transcripts, error messages, or RPC responses.
132
-
133
- ### Exit codes for `print-api-key` and `print-bearer-token`
134
-
135
- | Exit code | Meaning |
136
- | --- | --- |
137
- | `0` | Credential written to stdout |
138
- | `1` | Usage error (invalid flag or missing `--model`) |
139
- | `2` | No credential configured for the resolved provider |
140
- | `3` | Provider ambiguous (multiple configured providers matched `--model`) |
141
- | `4` | Wrong credential kind (provider uses OAuth when API key was requested, or vice versa) |
142
- | `5` | OAuth refresh failed (stored credential left untouched) |
143
- | `6` | Refreshed token still expires sooner than `--min-expiry` |
144
- | `7` | OAuth credential derivation failed (a refresh may already have persisted) |
145
- | `8` | Output write failed before any bytes were emitted |
146
- | `9` | Partial write to stdout; discard the received bytes |
147
-
148
- ### Exit codes for `auth check`
149
-
150
- | Exit code | Meaning |
151
- | --- | --- |
152
- | `0` | Provider is ready |
153
- | `1` | Provider is not ready |
154
- | `2` | Auth state or command is invalid |
155
- | `8` | With `--credentials`, output write failed before any bytes were emitted |
156
- | `9` | With `--credentials`, partial write to stdout; discard the received bytes |
157
-
158
- Once a credential reaches stdout, it is ordinary text in your shell or pipeline. Prefer `print-bearer-token`, which emits an expiring token, over a long-lived API key, and never call credential export inside a script that logs its own stdout.
125
+ <Warning>
126
+ Once a credential reaches stdout, it is ordinary text in your shell or pipeline. Prefer `print-bearer-token` (which emits a short-lived OAuth token) over a long-lived API key, never run credential export inside a script that logs stdout, and discard received bytes whenever the command exits with code `9` (partial write).
127
+ </Warning>
128
+
129
+ Security guarantees to keep in mind when wiring credential export into automation:
130
+
131
+ - **Stdout carries secrets only on explicit export.** Warnings, refresh notices, and help text go to stderr. Failed raw exports leave stdout empty (except exit code `9` for a partial stream write).
132
+ - **Specify `--provider` to avoid ambiguity.** `print-api-key` and `print-bearer-token` require `--model`; omitting `--provider` falls back to fuzzy matching and can inspect (and refresh an expiring OAuth token on) multiple configured candidates before failing as ambiguous. `auth check --credentials` requires `--provider` or an exact `--model`.
133
+ - **No file sinks or log leakage.** There is no `--output` or clipboard flag, and Atomic never writes exported credentials to debug logs, session transcripts, error messages, or RPC responses.
134
+ - **Read-only probes.** Pass `--no-refresh` to `atomic auth check` when you want a read-only check that never modifies `auth.json`.
135
+
136
+ See [CLI credential commands](/reference/cli#credential-commands) for all flag rules (`--min-expiry`, `--no-refresh`, `--json`) and the complete exit-code tables (`0`–`9`).
159
137
 
160
138
  ## Reporting security issues
161
139