@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,16 +1,12 @@
1
1
  ---
2
2
  title: "@bastani/atomic-ai"
3
- sidebarTitle: "AI"
4
- description: "Unified LLM API: providers, models, auth, streaming, tools, images, classification and thinking."
3
+ sidebarTitle: "@bastani/atomic-ai"
4
+ description: "Unified LLM API for providers, models, auth, streaming, tool calling, images, classification, and thinking."
5
5
  ---
6
6
 
7
- `@bastani/atomic-ai` is the LLM library Atomic itself runs on. It ships in every Atomic release at Atomic's version, and you can install it on its own:
7
+ `@bastani/atomic-ai` is the LLM library Atomic runs on (requires Node.js 22.19+). It ships in every Atomic release at Atomic's version, and you can install it independently (see [Installation](#installation)).
8
8
 
9
- ```bash
10
- npm install @bastani/atomic-ai
11
- ```
12
-
13
- Inside an Atomic extension, import it without installing it because the host provides it. See [Libraries](/libraries) for how the packages fit together and for legacy package names that still resolve inside Atomic.
9
+ Inside an Atomic extension, import it without installing it because the host provides it. See [Standalone libraries](/libraries) for how the packages fit together and for legacy package names that still resolve inside Atomic.
14
10
 
15
11
  `@bastani/atomic-ai` provides one LLM API across providers with provider collections, automatic auth resolution, token and cost tracking, and JSON-serializable contexts for mid-session model handoffs.
16
12
 
@@ -18,14 +14,14 @@ Inside an Atomic extension, import it without installing it because the host pro
18
14
 
19
15
  ## Supported providers
20
16
 
21
- - **OpenAI** (API key or Sign in with ChatGPT; separate `openai-images` and `openai-decisions` providers share OpenAI API keys)
17
+ - **OpenAI** (`openai`: API key or Sign in with ChatGPT OAuth; `openai-api` via `openaiApiProvider()`: dedicated API-key-only provider so API billing stays separate from ChatGPT OAuth; separate `openai-images` and `openai-decisions` providers share OpenAI API keys)
22
18
  - **Ant Ling**
23
19
  - **Azure** (Azure OpenAI Responses and Microsoft Foundry Chat Completions)
24
20
  - **OpenAI Codex** (ChatGPT subscription via OAuth)
25
21
  - **TypeSafe** (System One classifier API)
26
22
  - **DeepSeek**
27
23
  - **NVIDIA NIM**
28
- - **Anthropic** (API key, bearer token, workload identity federation, or Claude Pro/Max OAuth)
24
+ - **Anthropic** (`anthropic`: API key, bearer token, workload identity federation, or Claude Pro/Max OAuth; `anthropic-api` via `anthropicApiProvider()`: dedicated API-key-only provider so API billing stays separate from Claude Pro/Max OAuth)
29
25
  - **Google**
30
26
  - **Vertex AI** (Gemini via Google Cloud Vertex AI)
31
27
  - **Mistral**
@@ -60,83 +56,93 @@ Inside an Atomic extension, import it without installing it because the host pro
60
56
  npm install @bastani/atomic-ai
61
57
  ```
62
58
 
63
- `@bastani/atomic-ai` re-exports TypeBox's `Type`, `Static`, and `TSchema`.
59
+ Requires Node.js 22.19 or newer.
60
+
61
+ Key root and subpath exports:
62
+
63
+ - Root `@bastani/atomic-ai`: `createModels`, `createProvider`, `Type`/`Static`/`TSchema` (re-exported from TypeBox), thinking helpers (`DEFAULT_THINKING_BUDGETS`, `fittedThinkingBudget`, `thinkingBudgetForLevel`, `getSupportedThinkingLevels`, `clampThinkingLevel`), `OAuthRefreshRejectedError`, `GitHubCopilot*Error`, `cleanupSessionResources`, and `PI_AI_VERSION`.
64
+ - Subpaths: `@bastani/atomic-ai/models`, `@bastani/atomic-ai/providers/<provider>`, `@bastani/atomic-ai/providers/all`, `@bastani/atomic-ai/api/<api-id>`, `@bastani/atomic-ai/utils/*`, `@bastani/atomic-ai/session-resources`, `@bastani/atomic-ai/bedrock-provider`, `@bastani/atomic-ai/lazy-bedrock-provider`, `@bastani/atomic-ai/oauth`, `@bastani/atomic-ai/bun-oauth`, `@bastani/atomic-ai/lazy-oauth`, and `@bastani/atomic-ai/compat`.
64
65
 
65
66
  ## Quick start
66
67
 
67
- Build a `Models` collection of providers and stream through it. The fastest start registers every built-in provider; apps optimizing bundle size register individual providers instead (see [Provider factories](#provider-factories) and [Bundling and tree shaking](#bundling-and-tree-shaking)).
68
+ Build a `Models` collection of providers and stream through it. Export `OPENAI_API_KEY` before running these examples. The fastest start registers every built-in provider; apps optimizing bundle size register individual providers instead (see [Provider factories](#provider-factories) and [Bundling and tree shaking](#bundling-and-tree-shaking)).
69
+
70
+ ### Streaming with tool calls
68
71
 
69
72
  ```typescript
70
- import { Type, type Context, type Tool } from '@bastani/atomic-ai';
71
- import { builtinModels } from '@bastani/atomic-ai/providers/all';
73
+ import { Type, type Context, type Tool } from "@bastani/atomic-ai";
74
+ import { builtinModels } from "@bastani/atomic-ai/providers/all";
72
75
 
73
76
  // A Models collection with every built-in provider registered
74
77
  const models = builtinModels();
75
78
 
76
79
  // Sync lookup against the collection
77
- const model = models.getModel('openai', 'gpt-4o-mini')!;
80
+ const model = models.getModel("openai", "gpt-4o-mini");
81
+ if (!model) throw new Error("Model not found");
78
82
 
79
83
  // Define tools with TypeBox schemas for type safety and validation
80
- const tools: Tool[] = [{
81
- name: 'get_time',
82
- description: 'Get the current time',
83
- parameters: Type.Object({
84
- timezone: Type.Optional(Type.String({ description: 'Optional timezone (e.g., America/New_York)' }))
85
- })
86
- }];
84
+ const tools: Tool[] = [
85
+ {
86
+ name: "get_time",
87
+ description: "Get the current time",
88
+ parameters: Type.Object({
89
+ timezone: Type.Optional(Type.String({ description: "Optional timezone (e.g., America/New_York)" })),
90
+ }),
91
+ },
92
+ ];
87
93
 
88
94
  // Build a conversation context (easily serializable and transferable between models)
89
95
  const context: Context = {
90
- systemPrompt: 'You are a helpful assistant.',
91
- messages: [{ role: 'user', content: 'What time is it?', timestamp: Date.now() }],
92
- tools
96
+ systemPrompt: "You are a helpful assistant.",
97
+ messages: [{ role: "user", content: "What time is it?", timestamp: Date.now() }],
98
+ tools,
93
99
  };
94
100
 
95
- // Option 1: Streaming with all event types.
96
101
  // Auth resolves through the provider (OPENAI_API_KEY from the environment here).
97
102
  const s = models.stream(model, context);
98
103
 
99
104
  for await (const event of s) {
100
105
  switch (event.type) {
101
- case 'start':
106
+ case "start":
102
107
  console.log(`Starting with ${event.partial.model}`);
103
108
  break;
104
- case 'text_start':
105
- console.log('\n[Text started]');
109
+ case "text_start":
110
+ console.log("\n[Text started]");
106
111
  break;
107
- case 'text_delta':
112
+ case "text_delta":
108
113
  process.stdout.write(event.delta);
109
114
  break;
110
- case 'text_end':
111
- console.log('\n[Text ended]');
115
+ case "text_end":
116
+ console.log("\n[Text ended]");
112
117
  break;
113
- case 'thinking_start':
114
- console.log('[Model is thinking...]');
118
+ case "thinking_start":
119
+ console.log("[Model is thinking...]");
115
120
  break;
116
- case 'thinking_delta':
121
+ case "thinking_delta":
117
122
  process.stdout.write(event.delta);
118
123
  break;
119
- case 'thinking_end':
120
- console.log('[Thinking complete]');
124
+ case "thinking_end":
125
+ console.log("[Thinking complete]");
121
126
  break;
122
- case 'toolcall_start':
127
+ case "toolcall_start":
123
128
  console.log(`\n[Tool call started: index ${event.contentIndex}]`);
124
129
  break;
125
- case 'toolcall_delta':
130
+ case "toolcall_delta": {
126
131
  // Partial tool arguments are being streamed
127
132
  const partialCall = event.partial.content[event.contentIndex];
128
- if (partialCall.type === 'toolCall') {
133
+ if (partialCall?.type === "toolCall") {
129
134
  console.log(`[Streaming args for ${partialCall.name}]`);
130
135
  }
131
136
  break;
132
- case 'toolcall_end':
137
+ }
138
+ case "toolcall_end":
133
139
  console.log(`\nTool called: ${event.toolCall.name}`);
134
140
  console.log(`Arguments: ${JSON.stringify(event.toolCall.arguments)}`);
135
141
  break;
136
- case 'done':
142
+ case "done":
137
143
  console.log(`\nFinished: ${event.reason}`);
138
144
  break;
139
- case 'error':
145
+ case "error":
140
146
  console.error(`Error: ${event.error.errorMessage}`);
141
147
  break;
142
148
  }
@@ -147,24 +153,26 @@ const finalMessage = await s.result();
147
153
  context.messages.push(finalMessage);
148
154
 
149
155
  // Handle tool calls if any
150
- const toolCalls = finalMessage.content.filter(b => b.type === 'toolCall');
156
+ const toolCalls = finalMessage.content.filter((block) => block.type === "toolCall");
151
157
  for (const call of toolCalls) {
152
- const result = call.name === 'get_time'
153
- ? new Date().toLocaleString('en-US', {
154
- timeZone: call.arguments.timezone || 'UTC',
155
- dateStyle: 'full',
156
- timeStyle: 'long'
157
- })
158
- : 'Unknown tool';
158
+ const timeZone = typeof call.arguments.timezone === "string" ? call.arguments.timezone : "UTC";
159
+ const result =
160
+ call.name === "get_time"
161
+ ? new Date().toLocaleString("en-US", {
162
+ timeZone,
163
+ dateStyle: "full",
164
+ timeStyle: "long",
165
+ })
166
+ : "Unknown tool";
159
167
 
160
168
  // Add tool result to context (supports text and images)
161
169
  context.messages.push({
162
- role: 'toolResult',
170
+ role: "toolResult",
163
171
  toolCallId: call.id,
164
172
  toolName: call.name,
165
- content: [{ type: 'text', text: result }],
173
+ content: [{ type: "text", text: result }],
166
174
  isError: false,
167
- timestamp: Date.now()
175
+ timestamp: Date.now(),
168
176
  });
169
177
  }
170
178
 
@@ -172,19 +180,34 @@ for (const call of toolCalls) {
172
180
  if (toolCalls.length > 0) {
173
181
  const continuation = await models.complete(model, context);
174
182
  context.messages.push(continuation);
175
- console.log('After tool execution:', continuation.content);
183
+ console.log("After tool execution:", continuation.content);
176
184
  }
177
185
 
178
186
  console.log(`Total tokens: ${finalMessage.usage.input} in, ${finalMessage.usage.output} out`);
179
187
  console.log(`Cost: $${finalMessage.usage.cost.total.toFixed(4)}`);
188
+ ```
189
+
190
+ ### Non-streaming completion
191
+
192
+ ```typescript
193
+ import { type Context } from "@bastani/atomic-ai";
194
+ import { builtinModels } from "@bastani/atomic-ai/providers/all";
195
+
196
+ const models = builtinModels();
197
+ const model = models.getModel("openai", "gpt-4o-mini");
198
+ if (!model) throw new Error("Model not found");
199
+
200
+ const context: Context = {
201
+ systemPrompt: "You are a concise assistant.",
202
+ messages: [{ role: "user", content: "Summarize HTTP 429 in one sentence.", timestamp: Date.now() }],
203
+ };
180
204
 
181
- // Option 2: Get complete response without streaming
182
205
  const response = await models.complete(model, context);
183
206
 
184
207
  for (const block of response.content) {
185
- if (block.type === 'text') {
208
+ if (block.type === "text") {
186
209
  console.log(block.text);
187
- } else if (block.type === 'toolCall') {
210
+ } else if (block.type === "toolCall") {
188
211
  console.log(`Tool: ${block.name}(${JSON.stringify(block.arguments)})`);
189
212
  }
190
213
  }
@@ -1774,6 +1797,8 @@ Rules:
1774
1797
 
1775
1798
  Avoid `@bastani/atomic-ai/compat` in new bundled apps because it preserves the legacy global API and pulls in the full built-in catalog.
1776
1799
 
1800
+ ### Bundler troubleshooting
1801
+
1777
1802
  For single-file Node ESM bundles, some SDK dependencies may still use dynamic CommonJS `require()` internally. If you see errors such as `Dynamic require of "child_process" is not supported`, add a Node `require` shim to the bundle. With esbuild:
1778
1803
 
1779
1804
  ```bash
@@ -1913,15 +1938,17 @@ Official docs: [Application Default Credentials](https://cloud.google.com/docs/a
1913
1938
 
1914
1939
  ### CLI login
1915
1940
 
1916
- The quickest way to authenticate:
1941
+ `@bastani/atomic-ai` ships the `atomic-ai` binary (with `pi-ai` kept as a legacy alias) to log into built-in **OAuth** providers:
1917
1942
 
1918
1943
  ```bash
1919
- npx @bastani/atomic-ai login # interactive provider selection
1920
- npx @bastani/atomic-ai login anthropic # login to specific provider
1921
- npx @bastani/atomic-ai list # list available providers
1944
+ npx @bastani/atomic-ai login # interactive OAuth provider selection
1945
+ npx @bastani/atomic-ai login anthropic # log into a specific OAuth provider
1946
+ npx @bastani/atomic-ai list # list OAuth-enabled providers
1947
+ # Or when installed locally/globally:
1948
+ atomic-ai login anthropic
1922
1949
  ```
1923
1950
 
1924
- Credentials are saved to `auth.json` in the current directory.
1951
+ The CLI lists only providers that support OAuth (`provider.auth.oauth`), and writes credentials to `auth.json` in the current working directory with owner-only permissions (`0600`).
1925
1952
 
1926
1953
  ### Programmatic OAuth
1927
1954
 
@@ -1,10 +1,26 @@
1
1
  ---
2
2
  title: "@bastani/atomic-codemode"
3
- sidebarTitle: "Codemode"
4
- description: "Sandboxed JavaScript execution where the only capability is calling injected tools."
3
+ sidebarTitle: "@bastani/atomic-codemode"
4
+ description: "Run model-written JavaScript in a QuickJS WebAssembly sandbox whose only capability is calling injected tools."
5
5
  ---
6
6
 
7
- Runs model-written JavaScript in a QuickJS VM (compiled to WebAssembly) where the only capability is calling injected tools. Nested tool calls never enter the LLM context; only the script's output and return value do.
7
+ Runs model-written JavaScript in a QuickJS VM (compiled to WebAssembly) where the only capability is calling injected tools. Nested tool calls never enter the LLM context; only the script's output and return value do. See [Standalone libraries](/libraries) for all standalone packages.
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ npm install @bastani/atomic-codemode
13
+ ```
14
+
15
+ Requires Node.js 22.19+ (or Bun / Cloudflare Workers via the portable subpaths). Available package entry points:
16
+
17
+ - `@bastani/atomic-codemode`: `CodemodeSandbox`, `loadQuickJSWasm`, `parseCodemodeSource`, `renderDeclarations`, and worker runtime for Node and Bun.
18
+ - `@bastani/atomic-codemode/portable`: `RemoteCodemodeSandbox` and `InlineCodemodeSandbox` with zero Node.js imports.
19
+ - `@bastani/atomic-codemode/cloudflare`: `CodemodeSandboxDurableObject` and `createInlineCodemodeSandbox` for Cloudflare Workers.
20
+ - `@bastani/atomic-codemode/declarations`: lightweight `renderDeclarations()` without worker or WebAssembly dependencies.
21
+ - `@bastani/atomic-codemode/source`: lightweight `parseCodemodeSource()`, `CodemodeSourceError`, and `CODEMODE_SOURCE_GRAMMAR`.
22
+ - `@bastani/atomic-codemode/node-options`: Node worker option helpers.
23
+ - `@bastani/atomic-codemode/worker`: worker entrypoint for bundled hosts.
8
24
 
9
25
  Scripts use `tools`, `ALL_TOOLS`, `text`, `image`, `exit`, `store`, and `load`, and may start with a `// @options:` line. Atomic uses it for its built-in [`codemode` tool](/codemode). It has no dependency on the other Atomic packages and can be used on its own to expose any functions (remote APIs, MCP servers, application services) to model-written scripts.
10
26
 
@@ -20,6 +36,7 @@ See [Usage on Node and Bun](#usage-on-node-and-bun) and [Usage on Cloudflare Wor
20
36
  ## Usage on Node and Bun
21
37
 
22
38
  ```ts
39
+ import { readFile } from "node:fs/promises";
23
40
  import { CodemodeSandbox } from "@bastani/atomic-codemode";
24
41
 
25
42
  const sandbox = new CodemodeSandbox({
@@ -29,7 +46,7 @@ const sandbox = new CodemodeSandbox({
29
46
  name: "read",
30
47
  execute: async (args, { signal }) => {
31
48
  const { path } = args as { path: string };
32
- return await readFile(path, "utf8");
49
+ return await readFile(path, { encoding: "utf8", signal });
33
50
  },
34
51
  },
35
52
  ],
@@ -50,16 +67,17 @@ await sandbox.close();
50
67
 
51
68
  `code` is the body of an async function, so `return` and top-level `await` work. Inside the script, every sandbox provides:
52
69
 
53
- - `tools.<name>(args)` returns a promise. Arguments and results go through a JSON round trip, and a tool that throws rejects with an `Error` carrying the same message. Tool names are also exposed as identifiers with invalid characters replaced by `_` via `toCodemodeIdentifier`, so `my-tool` is available as both `tools.my_tool` and `tools["my-tool"]`.
70
+ - `tools.<name>(args)` returns a promise. Arguments and results go through a JSON round trip. When a tool rejects with an `Error`, the script catches an `Error` with the same message plus any extra JSON-serializable own properties from that error (such as `code`, excluding `name`, `message`, and `stack`). Tool names are also exposed as identifiers with invalid characters replaced by `_` via `toCodemodeIdentifier`, so `my-tool` is available as both `tools.my_tool` and `tools["my-tool"]`.
54
71
  - `ALL_TOOLS` lists `{ name, description }` for every tool, using the identifier form for `name`.
55
72
  - `text(value)` appends a text item to `result.output`, JSON-stringifying non-string values. `console.log`, `info`, `warn`, `error`, and `debug` append text items with `console: true`.
56
73
  - `image(urlOrItem)` appends an image item. It accepts a base64 `data:` URL, `{ image_url }`, or an image block (`{ type: "image", data, mimeType }`, as MCP tools and `@bastani/atomic-ai` produce). Remote URLs are rejected.
57
74
  - `exit()` ends the script immediately with a successful result, keeping its output and store writes.
58
- - `globals` passed to the sandbox are callable as top-level functions, such as a host helper `image(ref)`. They behave like tools but are not recorded in `result.calls`. A dotted name like `models.classify` places the function on a frozen `models` object. With `spread: true`, `execute` receives all call arguments as an array instead of only the first argument, and `signature` replaces the declaration generated from the schemas.
75
+ - `globals` passed to the sandbox are callable as top-level functions, such as a host helper `image(ref)`. They behave like tools but are not recorded in `result.calls`. Global names must be valid JavaScript identifiers (or dotted `namespace.member` forms, placing the function on a frozen namespace object) and cannot collide with reserved names: `tools`, `ALL_TOOLS`, `console`, `text`, `image`, `exit`, `globalThis`, `store`, or `load`. With `spread: true`, `execute` receives all call arguments as an array instead of only the first argument, and `signature` replaces the declaration generated from the schemas.
59
76
  - `store(key, value)` and `load(key)` read and write JSON values synchronously. See [Store](#store).
77
+ - **Frozen built-in prototypes:** Before running scripts, the VM freezes built-in prototypes (`Object.prototype`, `Array.prototype`, and others, while still allowing instance overrides of `constructor`, `name`, `message`, `toString`, `toLocaleString`, `valueOf`, and `toJSON`). Scripts that attempt to monkey-patch built-in prototypes throw a `TypeError`.
60
78
  - Nothing else is available. There are no timers, `fetch`, `process`, `require`, modules, or `WebAssembly`. `eval` and `Function` work, but they only evaluate code inside the same VM.
61
79
 
62
- Setting `timeoutMs: Infinity` disables the deadline so the script runs until it settles or `signal` aborts it. A script that awaits a promise nothing can settle (with no tool call pending and no timers or I/O in the VM) fails immediately instead of hanging.
80
+ When `timeoutMs` is omitted, `CodemodeSandbox` uses `DEFAULT_TIMEOUT_MS` (`300_000` ms, or 5 minutes). Setting `timeoutMs: Infinity` disables the deadline so the script runs until it settles or `signal` aborts it. A script that awaits a promise nothing can settle (with no tool call pending and no timers or I/O in the VM) fails immediately instead of hanging.
63
81
 
64
82
  `memoryLimitBytes` caps the VM heap. Allocations beyond that limit fail inside the script with `InternalError: out of memory`.
65
83
 
@@ -107,7 +125,12 @@ const source = await tools.read({ path: "package.json" });
107
125
  text(JSON.parse(source).name);
108
126
  ```
109
127
 
110
- Supported fields are `max_output_tokens` (an output token budget) and `timeout_ms` (a hard deadline). The sandbox does not enforce them; the caller decides how to apply them. The options line is replaced by an empty line so line numbers in stack traces still match the input.
128
+ Supported JSON fields on the `// @options:` header line are snake_case:
129
+
130
+ - `max_output_tokens`: non-negative safe integer (`>= 0`; `0` is valid), returned as `options.maxOutputTokens`.
131
+ - `timeout_ms`: positive safe integer from `1` to `2,147,483,647`, returned as `options.timeoutMs`.
132
+
133
+ `parseCodemodeSource()` returns `{ code, options: { maxOutputTokens?, timeoutMs? } }`. The sandbox does not enforce these limits itself; the caller decides how to apply them. The options line is replaced by a blank line so line numbers in stack traces still match the input.
111
134
 
112
135
  Empty input, invalid JSON, unknown fields, an options line without code, or an options line after line 1 throw `CodemodeSourceError`. `CODEMODE_SOURCE_GRAMMAR` is a Lark grammar for providers that support grammar-constrained tool input. Both exports are also available from the lightweight `@bastani/atomic-codemode/source` entry.
113
136
 
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  title: "@bastani/atomic-schema"
3
- sidebarTitle: "Schema"
4
- description: "JSON Schema builders and validation without eval, for drafts 2020-12 and 7."
3
+ sidebarTitle: "@bastani/atomic-schema"
4
+ description: "Build and validate JSON Schema drafts 2020-12 and 7 without eval, with zero runtime dependencies and optional coercion."
5
5
  ---
6
6
 
7
7
  JSON Schema builders and validation without `eval`. Each schema compiles once into plain closures, so validation runs without code generation, works under a strict Content Security Policy, and needs no runtime dependencies.
@@ -12,7 +12,7 @@ JSON Schema builders and validation without `eval`. Each schema compiles once in
12
12
  - Schemas are never mutated, so frozen schemas work.
13
13
  - Format checks live in an optional subpath import.
14
14
 
15
- Atomic validates tool arguments with `@bastani/atomic-schema`. See [Tool parameter schemas](/extensions#tool-parameter-schemas). Extensions can import `@bastani/atomic-schema` from the host without installing it.
15
+ Atomic validates tool arguments with `@bastani/atomic-schema`. See [Tool parameter schemas](/extensions#tool-parameter-schemas) and [Standalone libraries](/libraries). Extensions can import `@bastani/atomic-schema` from the host without installing it.
16
16
 
17
17
  ## Installation
18
18
 
@@ -33,7 +33,10 @@ const Read = obj({
33
33
  type Read = Static<typeof Read>; // { path: string; mode: "text" | "binary"; offset?: number }
34
34
 
35
35
  const read = compile(Read);
36
- if (read.check(value)) value.path; // value: Read
36
+ const value: unknown = { path: "README.md", mode: "text" };
37
+ if (read.check(value)) {
38
+ console.log(value.path); // value is narrowed to Read
39
+ }
37
40
 
38
41
  read.errors({ offset: 0, extra: true });
39
42
  // [
@@ -48,7 +51,7 @@ read.errors({ offset: 0, extra: true });
48
51
 
49
52
  `check(value)` is the fast boolean path. It is a standalone function you can pass around, and it avoids allocations for most schemas.
50
53
 
51
- `errors(value)` explains failures and returns `[]` for valid values. The error explainer is built on the first failure and reused, so schemas whose inputs always pass never pay for it. `validate(value)` runs both without modifying the input and returns `{ ok: true, value }` or `{ ok: false, errors }`.
54
+ `errors(value)` explains failures and returns `ValidationError[]` (`{ path: string; keyword: string; message: string }`), or `[]` for valid values. The error explainer is built on the first failure and reused, so schemas whose inputs always pass never pay for it. `validate(value)` runs both without modifying the input and returns `ParseResult<T>` (`{ ok: true; value: T } | { ok: false; errors: ValidationError[] }`).
52
55
 
53
56
  ### Builders
54
57
 
@@ -59,7 +62,7 @@ read.errors({ offset: 0, extra: true });
59
62
  | `bool()`, `nul()`, `unknown()` | `{ type: "boolean" }`, `{ type: "null" }`, `{}` | `boolean`, `null`, `unknown` |
60
63
  | `lit(value)` | `{ const: value }` | the literal |
61
64
  | `oneOf(["a", "b"])` | `{ enum: [...] }` | `"a" \| "b"` |
62
- | `obj({ a: str(), b: opt(num()) }, { open })` | closed object; `open: true` allows other properties | `{ a: string; b?: number }` |
65
+ | `obj({ a: str(), b: opt(num()) }, { open })` | closed object (`additionalProperties: false`); `open: true` omits `additionalProperties` | `{ a: string; b?: number }` |
63
66
  | `arr(items, { minItems, maxItems, uniqueItems })` | `{ type: "array", items }` | `T[]` |
64
67
  | `tuple([str(), num()])` | `prefixItems`, no additional items | `[string, number]` |
65
68
  | `map(value)` | `{ type: "object", additionalProperties: value }` | `Record<string, T>` |
@@ -105,16 +108,16 @@ const validator = compile(schema, {
105
108
  });
106
109
  ```
107
110
 
108
- `formats` includes every format defined in JSON Schema 2020-12 (`date-time`, `email`, `uri`, `uuid`, `ipv6`, and the rest), plus `url` and `json-pointer-uri-fragment`. Pass your own record to check a subset of formats or add custom checks.
111
+ `formats` includes all 21 supported format keys: `date`, `date-time`, `duration`, `email`, `hostname`, `idn-email`, `idn-hostname`, `ipv4`, `ipv6`, `iri`, `iri-reference`, `json-pointer`, `json-pointer-uri-fragment`, `regex`, `relative-json-pointer`, `time`, `uri`, `uri-reference`, `uri-template`, `url`, and `uuid`. Pass your own record to check a subset of formats or add custom checks.
109
112
 
110
113
  By default, an unresolved `$ref` (a missing definition or a document not in `schemas`) throws during `compile()`. With `unresolvedRefs: "reject"`, that reference compiles as `false` instead. Only values at that position fail, with the error `unresolved reference <ref>`, while the rest of the schema continues to validate. Use this option for external schemas such as MCP tool schemas whose references may dangle.
111
114
 
112
115
  ### TypeBox schemas
113
116
 
114
- TypeBox 1.x schemas are JSON Schema objects, so they compile directly:
117
+ TypeBox 1.x schemas are JSON Schema objects, so they compile directly. Inside Atomic extensions and SDK apps, import `Type` from `@bastani/atomic/typebox`; in standalone apps using `@bastani/atomic-schema` alone, import from `typebox` directly:
115
118
 
116
119
  ```typescript
117
- import Type from "typebox";
120
+ import Type from "typebox"; // standalone app; inside Atomic use: import { Type } from "@bastani/atomic/typebox"
118
121
 
119
122
  const user = compile(Type.Object({ name: Type.String(), tags: Type.Array(Type.String()) }));
120
123
  ```
@@ -0,0 +1,92 @@
1
+ ---
2
+ title: "@bastani/atomic-storage-libsql"
3
+ sidebarTitle: "@bastani/atomic-storage-libsql"
4
+ description: "libSQL and Turso storage adapter for Atomic sessions and Intercom multi-node routing, usable from the CLI or TypeScript SDK."
5
+ ---
6
+
7
+ `@bastani/atomic-storage-libsql` is Atomic's standalone libSQL and [Turso](https://turso.tech) storage adapter. It stores sessions and Intercom multi-node routing in a shared Turso database, self-hosted `sqld` server, or local libSQL file with one URL and one auth token. Unlike the six core libraries in [Standalone libraries](/libraries), this package is not bundled inside `@bastani/atomic`; install it only when you use libSQL or Turso.
8
+
9
+ - **Plain ESM with types:** Ships plain JavaScript ESM and TypeScript declarations (`libsql.d.ts`), requiring Node.js 22.19+ with no TypeScript loader.
10
+ - **Batched writes:** Sends statement batches to remote libSQL servers in a single request and redacts auth tokens and custom headers from error diagnostics.
11
+
12
+ For operator setup, see [Turso and libSQL](/storage#turso-and-libsql). For sharing Intercom across a team while keeping personal sessions local, see [Team and CI setup](/guides/team-setup). For all five SDK storage backends and `createAgentSessionRuntime()`, see [SDK storage backends](/sdk/storage).
13
+
14
+ ## Installation
15
+
16
+ Install according to how you use Atomic:
17
+
18
+ ```bash
19
+ # CLI (install in user scope without -l; Atomic searches user-scope packages for adapters)
20
+ atomic install npm:@bastani/atomic-storage-libsql
21
+
22
+ # TypeScript SDK application
23
+ npm install @bastani/atomic-storage-libsql @bastani/atomic
24
+ ```
25
+
26
+ ## SDK quick start
27
+
28
+ ```typescript
29
+ import { createAgentSession } from "@bastani/atomic";
30
+ import { openLibsqlDatabase } from "@bastani/atomic-storage-libsql";
31
+
32
+ const database = await openLibsqlDatabase({
33
+ url: "libsql://<db>.turso.io",
34
+ authToken: process.env.TURSO_AUTH_TOKEN,
35
+ });
36
+
37
+ try {
38
+ const { session } = await createAgentSession({
39
+ sessionStore: { kind: "database", database, prefix: "app_" },
40
+ });
41
+ try {
42
+ await session.prompt("Summarize the failing tests in this repository");
43
+ } finally {
44
+ await session.dispose();
45
+ }
46
+ } finally {
47
+ await database.close();
48
+ }
49
+ ```
50
+
51
+ Pass the returned `SqliteDatabase` to `createAgentSession({ sessionStore: { kind: "database", database, prefix? } })` or `SqlSessionStore.open(database, { prefix? })`. Atomic leaves caller-owned database handles open on `session.dispose()`, so always close `database` in your outer `finally`.
52
+
53
+ ## `LibsqlDatabaseOptions`
54
+
55
+ | Option | Type | Required | Description |
56
+ | --- | --- | --- | --- |
57
+ | `url` | `string` | Yes | A `libsql://`, `https://`, `http://`, `wss://`, `ws://`, or `file:` URL. (`atomic storage join` and `atomic team join` accept `libsql://`, `https://`, `http://`, `wss://`, `ws://`, or an absolute `file:` URL without embedded credentials.) |
58
+ | `authToken` | `string` | For remote databases | Database auth token. In CLI settings, pass through `secrets` (`{ "file": ... }` or `{ "env": ... }`) so it never lands in `settings.json`. |
59
+ | `namespace` | `string` | No | Self-hosted `sqld` namespace (`sqld --enable-namespaces`), sent as the `x-namespace` header. Requires a `libsql:`, `https:`, or `http:` URL. |
60
+ | `headers` | `Readonly<Record<string, string>>` | No | Extra request headers sent on every HTTP/libSQL request and redacted from diagnostics. Requires a `libsql:`, `https:`, or `http:` URL. |
61
+
62
+ ## Exported API
63
+
64
+ - `openLibsqlDatabase(options: LibsqlDatabaseOptions): Promise<SqliteDatabase>` — opens a libSQL/Turso-backed `SqliteDatabase`.
65
+ - Type: `LibsqlDatabaseOptions`.
66
+ - Default export: `StorageAdapterModule` (`{ atomicStorageAdapter: 1, openDatabase }`) used by `atomic` CLI settings, `{ kind: "adapter" }` selections, and `teamProfileSelection()`.
67
+
68
+ ## Concurrency, WAL, and `sqld` retries
69
+
70
+ - **Local `file:` databases:** On first open, the adapter enables write-ahead logging (WAL, creating `-wal` and `-shm` sidecar files) with a 5-second busy timeout matching Atomic's built-in SQLite stores. Single statements, single-statement `exec`, batches, and transaction starts retry when another connection commits while waiting; multi-statement `exec` calls are not retried. Open a local file through only one SQLite library at a time so concurrent readers do not see stale WAL state.
71
+ - **Remote `sqld` servers:** When `sqld` hits a WAL checkpoint, it returns `SQLITE_BUSY` immediately without running the write. The adapter retries single statements, single-statement `exec`, batches, and transaction starts with jittered exponential backoff for up to 5 seconds within a 10-second wall-clock ceiling (one 5-second lock timeout plus one 5-second checkpoint window). For self-hosted `sqld`, start with `--checkpoint-interval-s 60` (or `SQLD_CHECKPOINT_INTERVAL_S=60`).
72
+
73
+ ## CLI configuration
74
+
75
+ Join a shared database for both sessions and Intercom:
76
+
77
+ ```bash
78
+ turso db tokens create <db> > ~/turso-token
79
+ chmod 600 ~/turso-token
80
+ atomic storage join libsql://<db>.turso.io --token-file ~/turso-token
81
+ atomic intercom restart
82
+ atomic storage status
83
+ ```
84
+
85
+ To share Intercom across machines while keeping personal sessions in local SQLite, run `atomic team join <url> --token-file ~/turso-token` instead (see [Team and CI setup](/guides/team-setup)). Run `atomic storage migrate` when upgrading schemas on a shared database.
86
+
87
+ ## Related docs
88
+
89
+ - [Turso and libSQL operator guide](/storage#turso-and-libsql): CLI setup, manual `settings.json`, size limits, and storage errors.
90
+ - [Team and CI setup](/guides/team-setup): shared team Intercom, CI runner profiles, and `teamProfileSelection()`.
91
+ - [SDK storage backends](/sdk/storage): complete `createAgentSession()`, `createAgentSessionRuntime()`, and error-handling recipes.
92
+ - [Standalone libraries](/libraries): all published `@bastani/atomic-*` packages.