@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
@@ -0,0 +1,119 @@
1
+ ---
2
+ title: "@bastani/atomic-storage-postgres"
3
+ sidebarTitle: "@bastani/atomic-storage-postgres"
4
+ description: "PostgreSQL storage adapter for Atomic sessions and Intercom multi-node routing, usable from the CLI or TypeScript SDK."
5
+ ---
6
+
7
+ `@bastani/atomic-storage-postgres` is Atomic's standalone [PostgreSQL](https://www.postgresql.org) storage adapter. It stores sessions and Intercom multi-node routing in one shared PostgreSQL database so multiple machines or SDK hosts can share state. Unlike the six core libraries in [Standalone libraries](/libraries), this package is not bundled inside `@bastani/atomic`; install it only when you use PostgreSQL.
8
+
9
+ - **PostgreSQL version requirement:** Atomic sessions require **PostgreSQL 16 or later** (for session JSON query functions). The adapter accepts **PostgreSQL 14 or later** on connect for non-session tables and rejects servers older than PostgreSQL 14.
10
+ - **Plain ESM with types:** Ships plain JavaScript ESM and TypeScript declarations (`postgres.d.ts`), requiring Node.js 22.19+ with no TypeScript loader.
11
+
12
+ For operator setup, role creation SQL, migrations, and troubleshooting, see [PostgreSQL setup](/storage#postgresql). 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-postgres
21
+
22
+ # TypeScript SDK application
23
+ npm install @bastani/atomic-storage-postgres @bastani/atomic
24
+ ```
25
+
26
+ If you use [cloud IAM authentication](#cloud-iam-authentication), also install the matching optional peer dependency for your cloud provider (`@azure/identity`, `@aws-sdk/rds-signer`, or `google-auth-library`).
27
+
28
+ ## SDK quick start
29
+
30
+ Create your database roles and run `atomic storage migrate` as the owner role first (see [Set up the database](/storage#set-up-the-database)), then connect from your Node.js application with `openPostgresDatabase()`:
31
+
32
+ ```typescript
33
+ import { readFile } from "node:fs/promises";
34
+ import { createAgentSession } from "@bastani/atomic";
35
+ import { openPostgresDatabase } from "@bastani/atomic-storage-postgres";
36
+
37
+ const database = await openPostgresDatabase({
38
+ url: "postgresql://atomic_runtime@db.example.com:5432/atomic",
39
+ // Accepts a string or an async callback invoked for every new connection (supports rotation).
40
+ password: async () => (await readFile("/run/secrets/postgres-password", "utf8")).trim(),
41
+ });
42
+
43
+ try {
44
+ const { session } = await createAgentSession({
45
+ // PostgreSQL prefixes must be lowercase and at most 24 characters.
46
+ sessionStore: { kind: "database", database, prefix: "app_" },
47
+ });
48
+ try {
49
+ await session.prompt("Summarize the open tasks in this repository");
50
+ } finally {
51
+ await session.dispose();
52
+ }
53
+ } finally {
54
+ await database.close();
55
+ }
56
+ ```
57
+
58
+ 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`.
59
+
60
+ ## `PostgresDatabaseOptions`
61
+
62
+ | Option | Type | Default | Description |
63
+ | --- | --- | --- | --- |
64
+ | `url` | `string` *(required)* | — | A `postgres://` or `postgresql://` URL with a username and no embedded password. Any password in the URL or a `password=` query parameter is rejected with `credential-in-url`. |
65
+ | `password` | `string \| (() => Promise<string>)` | — | Password string or async callback invoked for each new connection. Omit when using cloud `auth`; combining cloud `auth` with `password` throws `conflicting-token`. |
66
+ | `auth` | `"password" \| "azure-entra" \| "aws-iam" \| "gcp-iam"` | `"password"` | Credential strategy. Cloud modes request short-lived tokens per new connection via the provider's SDK. |
67
+ | `maxConnections` | `number` | `8` (`DEFAULT_MAX_CONNECTIONS`) | Maximum pooled connections kept open per process. |
68
+ | `statementTimeoutMs` | `number` | `30000` (`DEFAULT_STATEMENT_TIMEOUT_MS`) | Server-side per-statement timeout in milliseconds before cancellation. |
69
+ | `listenUrl` | `string` | `url` | Direct session-mode endpoint for `LISTEN`/`NOTIFY` wake-ups when `url` goes through a transaction pooler. |
70
+ | `schema` | `string` | `"atomic"` (`DEFAULT_SCHEMA`) | Lowercase schema holding Atomic's tables. Existing databases with tables in `public` and no `atomic` schema keep using `public` until `atomic storage migrate` moves them. Every transaction sets `SET LOCAL search_path`. |
71
+ | `sdkSearchPaths` | `readonly string[]` | — | Extra npm prefix directories to search when loading a cloud IAM SDK not found beside the adapter. CLI adapter loading passes `<agentDir>/npm`. |
72
+ | `proxy` | `string` | Environment proxy | An `http://` or `https://` proxy URL for `CONNECT` tunneling (credentials sent in `Proxy-Authorization` and redacted), or `"none"` to connect directly. Overrides environment proxy variables for TCP hosts. |
73
+ | `socket` | `PostgresSocketFactory` | — | Custom transport callback `(target: ProxyTarget) => Duplex \| Promise<Duplex>` carrying the PostgreSQL protocol (`target` has `{ host, port }` from `url` or `PGHOST`/`PGPORT`). Atomic negotiates TLS over it as over a normal socket. Cannot be combined with `proxy` (`conflicting-transport`). Socket directories always connect directly. |
74
+
75
+ ## Exported API
76
+
77
+ - `openPostgresDatabase(options: PostgresDatabaseOptions): Promise<SqliteDatabase>` — opens a pooled PostgreSQL-backed `SqliteDatabase`.
78
+ - `DEFAULT_MAX_CONNECTIONS` (`8`), `DEFAULT_STATEMENT_TIMEOUT_MS` (`30000`), `DEFAULT_SCHEMA` (`"atomic"`).
79
+ - `numberPlaceholders(sql: string): string` — rewrites positional `?` parameters outside string literals, quoted identifiers, and comments to `$1`, `$2`, ....
80
+ - `physicalIdentifiers(sql: string): string` — replaces unquoted identifiers longer than 63 bytes with their deterministic PostgreSQL physical identifier.
81
+ - Types: `PostgresDatabaseOptions`, `PostgresSocketFactory`, `ProxyTarget`.
82
+ - Default export: `StorageAdapterModule` (`{ atomicStorageAdapter: 1, liveSecrets, openDatabase }`) used by `atomic` CLI settings and `{ kind: "adapter" }` selections.
83
+
84
+ ## Cloud IAM authentication
85
+
86
+ On Azure, AWS, and Google Cloud, set `auth` and omit `password` / `secrets.password`. Only the selected provider's SDK is loaded on first connection. Tokens stay in memory, never appear in settings or errors, time out after 8 seconds, and clear and retry once on rejection (`28P01`, or Azure `28000`). Missing SDKs or token failures throw `StorageConfigError` (`reason: "auth-unavailable"`). Cloud tokens require TLS (`sslmode=verify-full` or `require`).
87
+
88
+ | `auth` | Optional peer SDK | CLI user-scope install | Credential source |
89
+ | --- | --- | --- | --- |
90
+ | `azure-entra` | `@azure/identity` | `atomic install npm:@azure/identity@4.14.1` | `DefaultAzureCredential` for `https://ossrdbms-aad.database.windows.net/.default` (reused until 5 minutes before expiry) |
91
+ | `aws-iam` | `@aws-sdk/rds-signer` | `atomic install npm:@aws-sdk/rds-signer@3.1169.0` | RDS `Signer` using the AWS default credential chain (`AWS_*`, profiles, IRSA, instance profile) |
92
+ | `gcp-iam` | `google-auth-library` | `atomic install npm:google-auth-library@11.3.4` | `GoogleAuth` for `https://www.googleapis.com/auth/sqlservice.login` (ADC, GKE/GCE/Cloud Run metadata) |
93
+
94
+ For Azure Database for PostgreSQL Flexible Server (PostgreSQL 16+), Azure HorizonDB (PostgreSQL 17, read/write endpoint), Amazon RDS/Aurora, and Google Cloud SQL role-grant SQL, see [PostgreSQL setup](/storage#azure) and [Cloud identities](/storage#cloud-identities).
95
+
96
+ ## TLS, HTTP proxies, and connection poolers
97
+
98
+ - **TLS defaults:** When `url` omits `sslmode`, Atomic applies `sslmode=verify-full` for remote hosts (checking `PGHOST` if omitted from the URL). Add `sslrootcert=/path/to/ca.pem` for private CAs. Without `sslrootcert`, `require` verifies both certificate and hostname like `verify-full` (stricter than libpq). TLS parameter names are case-sensitive; unknown `sslmode` values are rejected.
99
+ - **HTTP `CONNECT` proxies:** Without `options.proxy`, remote TCP hosts check `HTTPS_PROXY` (`https_proxy`), then `ALL_PROXY` (when HTTP/HTTPS), then `HTTP_PROXY`, respecting `NO_PROXY`. Loopback hosts and Unix socket directories connect directly. Keep `sslmode=verify-full` (or `verify-ca` with a private CA) so TLS runs end to end through the tunnel.
100
+ - **Connection poolers and wake-ups:** Works with transaction-mode poolers (PgBouncer, Azure port `6432`, Supabase Supavisor, Neon `-pooler`) with no session-level state or named prepared statements. Each process opens one extra `LISTEN` connection outside the pool for instant Intercom wake-ups; when `url` uses a transaction pooler, set `listenUrl` to a direct endpoint or Atomic falls back to polling automatically.
101
+ - **Retries and errors:** Connection drops, lock conflicts (`40001`, `40P01`, `55P03`), and canceled statements (`57014`) throw `StorageTransientError` (read-only and unwritten calls retry automatically). Invalid credentials (`28P01`), missing databases (`3D000`), and certificate errors fail immediately. Missing privileges (`42501`) fail immediately with `StorageConfigError` (`reason: "missing-privilege"`) naming the exact `GRANT` or migration command.
102
+
103
+ ## CLI configuration
104
+
105
+ Join a machine with the CLI after installing in user scope and running `atomic storage migrate`:
106
+
107
+ ```bash
108
+ printf '%s' "$PASSWORD" > ~/atomic-db-password
109
+ chmod 600 ~/atomic-db-password
110
+ atomic storage join 'postgresql://atomic_runtime@db.example.com:5432/atomic' --password-file ~/atomic-db-password
111
+ atomic intercom restart
112
+ atomic storage status
113
+ ```
114
+
115
+ ## Related docs
116
+
117
+ - [PostgreSQL operator guide](/storage#postgresql): role creation SQL, migrations, Azure/RDS/Cloud SQL setup, and troubleshooting.
118
+ - [SDK storage backends](/sdk/storage): complete `createAgentSession()`, `createAgentSessionRuntime()`, and error-handling recipes.
119
+ - [Standalone libraries](/libraries): all published `@bastani/atomic-*` packages.
@@ -1,10 +1,10 @@
1
1
  ---
2
2
  title: "@bastani/atomic-telemetry"
3
- sidebarTitle: "Telemetry"
4
- description: "Vendor-neutral telemetry contracts, a no-op and an in-memory context, metrics and typed schemas."
3
+ sidebarTitle: "@bastani/atomic-telemetry"
4
+ description: "Vendor-neutral telemetry contracts, no-op and in-memory contexts, metrics, trace rendering, and typed telemetry schemas."
5
5
  ---
6
6
 
7
- Vendor-neutral telemetry contracts and typed schema utilities for Atomic's libraries. This package contains no exporter and sends nothing on its own; you supply the adapter.
7
+ Vendor-neutral telemetry contracts and typed schema utilities for Atomic's libraries. This package contains no exporter and sends nothing on its own; you supply the adapter. See [Standalone libraries](/libraries) for all standalone packages.
8
8
 
9
9
  This package provides:
10
10
 
@@ -24,6 +24,39 @@ Applications can use the in-memory reference or supply an adapter for OpenTeleme
24
24
  npm install @bastani/atomic-telemetry
25
25
  ```
26
26
 
27
+ ## Quick start
28
+
29
+ ```typescript
30
+ import {
31
+ InMemoryTelemetryContext,
32
+ NOOP_TELEMETRY_CONTEXT,
33
+ type TelemetryContext,
34
+ } from "@bastani/atomic-telemetry";
35
+ import { renderTrace } from "@bastani/atomic-telemetry/render";
36
+
37
+ const accounts = new Map<string, { id: string; plan: string }>([["acct-1", { id: "acct-1", plan: "pro" }]]);
38
+
39
+ async function loadAccount(accountId: string, telemetry: TelemetryContext = NOOP_TELEMETRY_CONTEXT) {
40
+ return telemetry.startSpan(
41
+ {
42
+ name: "example.account.load",
43
+ attributes: { "example.account.id": accountId },
44
+ },
45
+ async (span) => {
46
+ const account = accounts.get(accountId);
47
+ span.setAttributes({ "example.account.found": account !== undefined });
48
+ return account;
49
+ },
50
+ );
51
+ }
52
+
53
+ const recorder = new InMemoryTelemetryContext();
54
+ await loadAccount("acct-1", recorder);
55
+
56
+ const { traces } = await recorder.findTraces();
57
+ if (traces[0]) console.log(renderTrace(traces[0].spans));
58
+ ```
59
+
27
60
  ## Telemetry concepts
28
61
 
29
62
  Telemetry describes what a program did while running using spans, attributes, events, statuses, and explicit context:
@@ -273,13 +306,13 @@ Storage in `InMemoryTelemetryContext` is unbounded and process-local. Create a f
273
306
 
274
307
  `TelemetryStore` separates querying from recording. `InMemoryTelemetryContext` implements it, and persistent adapters can implement it too:
275
308
 
276
- - `findTraces(query?)` returns locally stored traces, newest trace start first. Filters include the earliest stored span's `name`, inclusive `startMin` and `startMax`, `errors: true`, and scalar `attributes` (all requested attributes must match one span anywhere in the trace). Pages default to 20 traces; pass the returned opaque `cursor` with the same filters to continue. Equal start times order by trace ID.
277
- - `getTrace(traceId)` returns a trace or `undefined`.
278
- - `findMetrics({ name, startMin?, startMax?, attributes? })` returns metric rows with count, sum, minimum, and maximum. Time bounds are inclusive interval-start times. `InMemoryTelemetryContext` maps each raw measurement to a count-one row in its 10-second interval, while persistent stores can aggregate measurements per series and interval.
309
+ - `findTraces(query?)` returns `Promise<{ traces: readonly StoredTrace[]; cursor?: string }>`, newest trace start first, where each `StoredTrace` is `{ traceId, spans }`. `TraceQuery` filters include the earliest stored span's `name`, inclusive `startMin` and `startMax`, `errors: true`, `attributes` (scalar equalities that must all match one span anywhere in the trace), `limit` (default `20`), and opaque `cursor` (pass with the same filters to fetch the next page). Equal start times order by `traceId`.
310
+ - `getTrace(traceId)` returns `Promise<StoredTrace | undefined>`.
311
+ - `findMetrics({ name, startMin?, startMax?, attributes? })` returns `Promise<readonly StoredMetric[]>`, where each `StoredMetric` has `{ intervalMs, name, kind, unit?, attributes, count, sum, min, max }`. Time bounds are inclusive interval-start times. `InMemoryTelemetryContext` maps each raw measurement to a count-one row in its 10-second interval, while persistent stores can aggregate measurements per series and interval.
279
312
 
280
313
  Only settled spans are returned. A trace ID propagates from the root span with the parent identity. Stores return the spans available locally, so remote or expired parents may be absent and a child can appear before its parent settles. Pagination is not a frozen snapshot across requests because late settlements and retention can change a trace's earliest stored span.
281
314
 
282
- `StoredSpan` includes epoch-millisecond `startedMs` and `endedMs`, event offsets in `timeMs`, and links carrying both target `traceId` and `spanId`. Durations use a monotonic clock because wall clocks across processes may disagree. Merge spans from multiple stores by trace ID; parent relationships, not timestamp containment, define the tree.
315
+ `StoredSpan` has `{ id, traceId, parentId?, name, startedMs, endedMs, attributes, events: [{ name, timeMs, attributes }], links: [{ traceId, spanId, attributes? }], status }`. `startedMs` and `endedMs` are epoch milliseconds (`telemetryNow()`), and event `timeMs` values are offsets relative to span start. Durations use a monotonic clock because wall clocks across processes may disagree. Merge spans from multiple stores by `traceId`; parent relationships, not timestamp containment, define the tree.
283
316
 
284
317
  Trace formatting lives in `@bastani/atomic-telemetry/render`:
285
318
 
@@ -383,7 +416,7 @@ const startSpan = createTypedSpanStarter(
383
416
  );
384
417
  ```
385
418
 
386
- The starter exposes one overload per span and checks names and attributes at compile time. Union-valued names must be narrowed before a call, preserving the relationship between each runtime name and its attribute schema. Its callback receives a child starter over the same schemas, already bound to the callback span:
419
+ The starter exposes one overload per span and checks names and attributes at compile time. Union-valued names must be narrowed before a call, preserving the relationship between each runtime name and its attribute schema. Always pass the second `attributes` argument (pass `{}` when a span declares `startAttributes: {}`), unlike `span.addEvent()` where `attributes` is optional when no attributes are required. Its callback receives a child starter over the same schemas, already bound to the callback span:
387
420
 
388
421
  ```typescript
389
422
  await startSpan(
@@ -481,7 +514,7 @@ Adapters do not need to understand schema objects. Instrumentation helpers and t
481
514
 
482
515
  ## Using with `@bastani/atomic-ai`
483
516
 
484
- Pass a parent `TelemetryContext` to `@bastani/atomic-ai` through `telemetryContext` in request options:
517
+ Pass a parent `TelemetryContext` to [`@bastani/atomic-ai`](/libraries/ai) through `telemetryContext` in request options:
485
518
 
486
519
  ```typescript
487
520
  import { InMemoryTelemetryContext } from '@bastani/atomic-telemetry';
@@ -1,10 +1,16 @@
1
1
  ---
2
2
  title: "@bastani/atomic-tui"
3
- sidebarTitle: "TUI"
4
- description: "Terminal UI framework with differential rendering, components, overlays, key handling and images."
3
+ sidebarTitle: "@bastani/atomic-tui"
4
+ description: "Terminal UI framework with differential rendering, alternate-screen viewports, components, overlays, key handling, and images."
5
5
  ---
6
6
 
7
- Minimal terminal UI framework with differential rendering and synchronized output for flicker-free interactive CLI applications.
7
+ Minimal terminal UI framework with differential rendering and synchronized output for flicker-free interactive CLI applications (requires Node.js 22.19+).
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ npm install @bastani/atomic-tui
13
+ ```
8
14
 
9
15
  ## Features
10
16
 
@@ -13,9 +19,9 @@ Minimal terminal UI framework with differential rendering and synchronized outpu
13
19
  - **Application-owned scrolling.** Alternate-screen viewport supports mouse, trackpad, and keyboard navigation.
14
20
  - **Synchronized output.** Uses CSI 2026 for atomic, flicker-free screen updates.
15
21
  - **Bracketed paste mode.** Handles large pastes with compact markers for pastes over 10 lines.
16
- - **Component-based.** Simple `Component` interface with a `render(width)` method.
22
+ - **Component-based.** Simple `Component` interface with `render(width)` and optional `renderSized(width, height)`.
17
23
  - **Theme support.** Components accept theme interfaces for styling.
18
- - **Built-in components.** `Text`, `TruncatedText`, `Input`, `Editor`, `Markdown`, `Loader`, `CancellableLoader`, `SelectList`, `SettingsList`, `MouseRegion`, `Spacer`, `Image`, `Box`, `Container`, `VStack`, `HStack`, and `ScrollView`.
24
+ - **Built-in components.** `Text`, `TruncatedText`, `Input`, `Editor`, `Markdown`, `Loader`, `CancellableLoader`, `SelectList`, `SettingsList`, `MouseRegion`, `Spacer`, `Image`, `Box`, `Container`, `WindowedContainer`, `VStack`, `HStack`, and `ScrollView`.
19
25
  - **Inline images.** Renders images in terminals supporting Kitty or iTerm2 graphics protocols.
20
26
  - **Autocomplete support.** File paths and slash commands.
21
27
 
@@ -187,6 +193,21 @@ Press `Ctrl+Shift+F` to open or close the primary scroll view's bordered search
187
193
 
188
194
  `TuiAltScreenOptions.scrollToEndIndicator` renders a clickable label centered on the last row of a `follow: "end"` primary scroll view while scrolled away from the end. Clicking it resumes end-following.
189
195
 
196
+ **`TuiAltScreenOptions` summary:**
197
+
198
+ | Option | Type | Description |
199
+ | --- | --- | --- |
200
+ | `wheelScrollLines` | `number \| "auto"` | Logical lines moved per wheel event (default `1`; `"auto"` accelerates fast spins; Alt+wheel moves 5x). |
201
+ | `mouse` | `boolean` | Capture mouse events for scrolling and application-owned text selection. |
202
+ | `copyOnSelect` | `boolean` | Automatically copy dragged selections on mouse release (default `true`). |
203
+ | `copySelection` | `(text: string) => Promise<boolean \| string>` | Custom system clipboard writer; falls back to OSC 52 when omitted. |
204
+ | `openUrl` | `(url: string) => void` | Handler invoked when clicking an OSC 8 hyperlink. |
205
+ | `onRightClickPaste` | `() => void` | Secondary-button paste handler (currently Windows only). |
206
+ | `searchMatchStyle` / `searchCurrentMatchStyle` | `(text: string) => string` | Highlighters for transcript search matches and the active match. |
207
+ | `searchNavigationButtonStyle` | `(text: string, hovered: boolean) => string` | Styling callback for the search panel's previous/next buttons. |
208
+ | `scrollToEndIndicator` | `() => string` | Clickable jump-to-end indicator shown when scrolled away from the bottom. |
209
+ | `scrollPinnedPrompt` | `{ isPrompt, render }` | Pins matching prompt rows at the top of the scroll viewport. |
210
+
190
211
  Layout geometry is rebuilt for each requested frame. Stateful components are retained, and their existing rendered-line caches remain effective. Calling `render(width)` directly on these layout components produces an unbounded document, which is also used when alt mode restores the main screen.
191
212
 
192
213
  ### Overlays
@@ -275,21 +296,29 @@ All components implement:
275
296
  ```typescript
276
297
  interface Component {
277
298
  render(width: number): string[];
299
+ renderSized?(width: number, height: number): string[];
278
300
  handleInput?(data: string): void;
279
301
  handleMouse?(event: TuiMouseEvent): TuiMouseEventResult | undefined;
280
- capturesViewportInput?: boolean;
302
+ paintedRowKey?(row: number): string | undefined;
281
303
  readonly selectionTextMayChangeOnReplay?: boolean;
304
+ readonly historyReplayable?: boolean;
305
+ wantsKeyRelease?: boolean;
306
+ capturesViewportInput?: boolean;
282
307
  invalidate(): void;
283
308
  }
284
309
  ```
285
310
 
286
- | Method | Description |
287
- |--------|-------------|
311
+ | Member | Description |
312
+ | --- | --- |
288
313
  | `render(width)` | Returns an array of strings, one per line. Each line **must not exceed `width`** or the TUI throws an error. Use `truncateToWidth()` or manual wrapping. |
314
+ | `renderSized?(width, height)` | Optional sized renderer invoked instead of `render()` when a layout slot allocates a fixed row height. |
289
315
  | `handleInput?(data)` | Called when the component has focus and receives keyboard input. The `data` string contains raw terminal input, which may include ANSI escape sequences. |
290
316
  | `handleMouse?(event)` | Called by `TuiAltScreen` for normalized pointer input targeted at the component. |
291
- | `capturesViewportInput?` | When `true` on the focused component, `TuiAltScreen` forwards viewport scrolling and prompt-jump keys (`tui.altScreen.*` except search) to the component instead of scrolling the viewport, matching focused overlays. `SelectList`, `SettingsList`, and `Editor` (while autocomplete is open) set this so PageUp and PageDown move selection. Only the focused component is checked, so a wrapper forwarding input to a list must mirror this flag. Use `getSelectPageIndex(keybindings, data, selectedIndex, itemCount, pageSize)` to compute page movement. |
292
- | `selectionTextMayChangeOnReplay` | Set to `true` on a `WindowedContainer` component whose text cannot be recreated from saved input. Fullscreen selection then keeps the selected fragments in memory until dismissed or replaced. While the component remains on screen, copying uses its latest painted text; if evicted and recreated, repeated copies keep the original selection. Leave unset for deterministic rows. |
317
+ | `paintedRowKey?(row)` | Optional stable identity for what the last render drew on `row`, so press and release become a click only when both target the same item across repaints. |
318
+ | `selectionTextMayChangeOnReplay` | Set to `true` on a `WindowedContainer` component whose text cannot be recreated from saved input. Fullscreen selection then keeps the selected fragments in memory until dismissed or replaced. Leave unset for deterministic rows. |
319
+ | `historyReplayable` | Set to `true` on a chat-rendered component that can be discarded offscreen and recreated from saved input without losing state. |
320
+ | `wantsKeyRelease` | When `true`, receives Kitty key release events in `handleInput()`. Default: `false`. |
321
+ | `capturesViewportInput` | When `true` on the focused component, `TuiAltScreen` forwards viewport scrolling and prompt-jump keys (`tui.altScreen.*` except search) to the component instead of scrolling the viewport, matching focused overlays. `SelectList`, `SettingsList`, and `Editor` (while autocomplete is open) set this so PageUp and PageDown move selection. Use `getSelectPageIndex(keybindings, data, selectedIndex, itemCount, pageSize)` to compute page movement. |
293
322
  | `invalidate()` | Required. Clears cached render state so the next `render()` rebuilds from scratch. Stateless components can leave the body empty. |
294
323
 
295
324
  The TUI appends a full SGR reset and OSC 8 reset at the end of each rendered line, so styles do not carry across lines. Reapply styles per line or use `wrapTextWithAnsi()` to preserve styling across wrapped lines.
@@ -403,7 +432,7 @@ Without this propagation, typing with an IME (Chinese, Japanese, Korean, etc.) w
403
432
 
404
433
  ### Container
405
434
 
406
- Groups child components.
435
+ Groups child components vertically.
407
436
 
408
437
  ```typescript
409
438
  const container = new Container();
@@ -411,6 +440,10 @@ container.addChild(component);
411
440
  container.removeChild(component);
412
441
  ```
413
442
 
443
+ ### WindowedContainer
444
+
445
+ Virtualized vertical container for large transcripts inside `ScrollView`. Keeps only visible children mounted in memory and materializes or evicts off-screen rows on demand (respecting `historyReplayable` and `selectionTextMayChangeOnReplay` for fullscreen text selection).
446
+
414
447
  ### Box
415
448
 
416
449
  Container that applies padding and background color to all children.
@@ -824,8 +857,13 @@ The TUI works with any object implementing the `Terminal` interface:
824
857
  interface Terminal {
825
858
  start(onInput: (data: string) => void, onResize: () => void): void;
826
859
  stop(): void;
860
+ handOff?(held?: readonly string[]): void;
861
+ readonly continuedFromHandOff?: boolean;
862
+ restoreOnExit?(before: string, after: string): void;
827
863
  drainInput(maxMs?: number, idleMs?: number): Promise<void>;
828
864
  write(data: string): void;
865
+ flush?(): Promise<void>;
866
+ readonly colorDepth?: number;
829
867
  get columns(): number;
830
868
  get rows(): number;
831
869
  get kittyProtocolActive(): boolean;
@@ -851,7 +889,7 @@ import { visibleWidth, truncateToWidth, wrapTextWithAnsi } from "@bastani/atomic
851
889
  // Get visible width of string (ignoring ANSI codes)
852
890
  const width = visibleWidth("\x1b[31mHello\x1b[0m"); // 5
853
891
 
854
- // Truncate string to width (preserving ANSI codes, adds ellipsis)
892
+ // Truncate string to width (preserving ANSI codes and closing active styles)
855
893
  const truncated = truncateToWidth("Hello World", 8); // "Hello..."
856
894
 
857
895
  // Truncate without ellipsis
@@ -862,30 +900,42 @@ const lines = wrapTextWithAnsi("This is a long line that needs wrapping", 20);
862
900
  // ["This is a long line", "that needs wrapping"]
863
901
  ```
864
902
 
865
- ## Creating custom components
903
+ Additional exported helpers:
866
904
 
867
- When creating custom components, **each line returned by `render()` must not exceed the `width` parameter**. The TUI throws an error if any line is wider than the terminal.
905
+ | Export | Purpose |
906
+ | --- | --- |
907
+ | `fuzzyFilter` / `fuzzyMatch` | Fuzzy matching and ranked filtering for pickers and search inputs. |
908
+ | `KeybindingsManager` / `TUI_KEYBINDINGS` | Configurable TUI keybinding definitions and lookup. |
909
+ | `decodePrintableKey` | Decode printable Kitty CSI-u and `modifyOtherKeys` sequences. |
910
+ | `normalizePastedText` | Normalize bracketed paste text (CRLF/CR, tmux control bytes, tabs, C0 control filtering). |
911
+ | `stripTerminalSequences` / `sliceByColumn` | Strip ANSI/OSC sequences or slice styled strings by display column range. |
912
+ | `hyperlink` / `clickableHint` | Format OSC 8 clickable terminal links and clickable hint badges. |
913
+ | `renderLatex` | Render inline or block LaTeX math into Unicode text for terminals. |
914
+ | `formatProgramStatus` | Encode OSC 7501 program-status escape sequences. |
915
+ | `getNativeClipboard` | Access the native clipboard integration when available. |
868
916
 
869
- ### Handling input
917
+ ## Creating custom components
870
918
 
871
- Use `matchesKey()` with the `Key` helper for keyboard input:
919
+ When building a custom `Component`, keep every line returned by `render(width)` within `width` columns using `truncateToWidth()`, `wrapTextWithAnsi()`, or `visibleWidth()`, handle keys via `matchesKey()` (see [Key detection](#key-detection)), and cache rendered output by width until `invalidate()` runs:
872
920
 
873
921
  ```typescript
874
- import { matchesKey, Key, truncateToWidth } from "@bastani/atomic-tui";
875
- import type { Component } from "@bastani/atomic-tui";
922
+ import { Key, matchesKey, truncateToWidth, type Component } from "@bastani/atomic-tui";
876
923
 
877
- class MyInteractiveComponent implements Component {
924
+ class CachedList implements Component {
878
925
  private selectedIndex = 0;
879
926
  private items = ["Option 1", "Option 2", "Option 3"];
880
-
927
+ private cachedWidth?: number;
928
+ private cachedLines?: string[];
881
929
  public onSelect?: (index: number) => void;
882
930
  public onCancel?: () => void;
883
931
 
884
932
  handleInput(data: string): void {
885
933
  if (matchesKey(data, Key.up)) {
886
934
  this.selectedIndex = Math.max(0, this.selectedIndex - 1);
935
+ this.invalidate();
887
936
  } else if (matchesKey(data, Key.down)) {
888
937
  this.selectedIndex = Math.min(this.items.length - 1, this.selectedIndex + 1);
938
+ this.invalidate();
889
939
  } else if (matchesKey(data, Key.enter)) {
890
940
  this.onSelect?.(this.selectedIndex);
891
941
  } else if (matchesKey(data, Key.escape) || matchesKey(data, Key.ctrl("c"))) {
@@ -893,85 +943,15 @@ class MyInteractiveComponent implements Component {
893
943
  }
894
944
  }
895
945
 
896
- render(width: number): string[] {
897
- return this.items.map((item, i) => {
898
- const prefix = i === this.selectedIndex ? "> " : " ";
899
- return truncateToWidth(prefix + item, width);
900
- });
901
- }
902
-
903
- invalidate(): void {}
904
- }
905
- ```
906
-
907
- ### Handling line width
908
-
909
- Use the provided utilities so lines stay within `width`:
910
-
911
- ```typescript
912
- import { visibleWidth, truncateToWidth } from "@bastani/atomic-tui";
913
- import type { Component } from "@bastani/atomic-tui";
914
-
915
- class MyComponent implements Component {
916
- private text: string;
917
-
918
- constructor(text: string) {
919
- this.text = text;
920
- }
921
-
922
- render(width: number): string[] {
923
- // Option 1: Truncate long lines
924
- return [truncateToWidth(this.text, width)];
925
-
926
- // Option 2: Check and pad to exact width
927
- const line = this.text;
928
- const visible = visibleWidth(line);
929
- if (visible > width) {
930
- return [truncateToWidth(line, width)];
931
- }
932
- // Pad to exact width (optional, for backgrounds)
933
- return [line + " ".repeat(width - visible)];
934
- }
935
-
936
- invalidate(): void {}
937
- }
938
- ```
939
-
940
- ### ANSI code considerations
941
-
942
- Both `visibleWidth()` and `truncateToWidth()` handle ANSI escape codes:
943
-
944
- - `visibleWidth()` ignores ANSI codes when calculating display width.
945
- - `truncateToWidth()` preserves ANSI codes and closes active styles when truncating.
946
-
947
- ```typescript
948
- import chalk from "chalk";
949
-
950
- const styled = chalk.red("Hello") + " " + chalk.blue("World");
951
- const width = visibleWidth(styled); // 11 (not counting ANSI codes)
952
- const truncated = truncateToWidth(styled, 8); // Red "Hello" + " W..." with proper reset
953
- ```
954
-
955
- ### Caching
956
-
957
- Cache rendered lines and rebuild only when `width` changes or `invalidate()` runs:
958
-
959
- ```typescript
960
- class CachedComponent implements Component {
961
- private text: string;
962
- private cachedWidth?: number;
963
- private cachedLines?: string[];
964
-
965
946
  render(width: number): string[] {
966
947
  if (this.cachedLines && this.cachedWidth === width) {
967
948
  return this.cachedLines;
968
949
  }
969
-
970
- const lines = [truncateToWidth(this.text, width)];
971
-
972
950
  this.cachedWidth = width;
973
- this.cachedLines = lines;
974
- return lines;
951
+ this.cachedLines = this.items.map((item, i) =>
952
+ truncateToWidth(`${i === this.selectedIndex ? "> " : " "}${item}`, width),
953
+ );
954
+ return this.cachedLines;
975
955
  }
976
956
 
977
957
  invalidate(): void {
package/docs/libraries.md CHANGED
@@ -1,10 +1,14 @@
1
1
  ---
2
- title: "Libraries"
3
- sidebarTitle: "Libraries"
4
- description: "The TypeScript libraries Atomic is built on, published as @bastani/atomic-* packages you can use in extensions, SDK apps, or on their own."
2
+ title: "Standalone libraries"
3
+ sidebarTitle: "All libraries"
4
+ description: "Explore Atomic's six core @bastani/atomic-* TypeScript libraries and two optional storage adapter packages for extensions, SDK apps, and standalone Node.js 22.19+ projects."
5
5
  ---
6
6
 
7
- Atomic is built on six TypeScript libraries. Each one is published on npm at Atomic's version with every release, and each works on its own outside Atomic.
7
+ Atomic publishes six core TypeScript libraries and two optional storage adapter packages (all requiring Node.js 22.19 or newer). Each package publishes on npm at Atomic's version with every release and works independently outside Atomic.
8
+
9
+ ## Core libraries
10
+
11
+ The six core libraries are bundled inside `@bastani/atomic` and provided to extensions automatically:
8
12
 
9
13
  | Package | What it does |
10
14
  | --- | --- |
@@ -15,20 +19,33 @@ Atomic is built on six TypeScript libraries. Each one is published on npm at Ato
15
19
  | [`@bastani/atomic-schema`](/libraries/schema) | JSON Schema builders and validation without `eval` |
16
20
  | [`@bastani/atomic-telemetry`](/libraries/telemetry) | Vendor-neutral telemetry contracts and reference contexts that send nothing on their own |
17
21
 
22
+ ## Storage adapter packages
23
+
24
+ Remote SQL storage adapters are **not** bundled into `@bastani/atomic` and must be installed separately when you use PostgreSQL or libSQL/Turso:
25
+
26
+ | Package | What it does |
27
+ | --- | --- |
28
+ | [`@bastani/atomic-storage-postgres`](/libraries/storage-postgres) | PostgreSQL 16+ storage adapter (`openPostgresDatabase()`, cloud IAM, proxies, poolers) for shared sessions and Intercom |
29
+ | [`@bastani/atomic-storage-libsql`](/libraries/storage-libsql) | libSQL and Turso storage adapter (`openLibsqlDatabase()`, namespaces, WAL/sqld retries) for shared sessions and Intercom |
30
+
31
+ For CLI usage, install storage adapters in user scope with `atomic install npm:@bastani/atomic-storage-postgres` or `atomic install npm:@bastani/atomic-storage-libsql`. For TypeScript SDK applications, install them with `npm install` alongside `@bastani/atomic` (see [SDK storage backends](/sdk/storage)).
32
+
33
+ > **Native bindings:** `@bastani/atomic-natives` is an internal N-API native module installed automatically as a runtime dependency of `@bastani/atomic` (with per-platform binary packages in its `optionalDependencies`) and is not intended as a standalone user library.
34
+
18
35
  ## Install
19
36
 
20
- Install a library on its own with npm:
37
+ Install a core library on its own with npm:
21
38
 
22
39
  ```bash
23
40
  npm install @bastani/atomic-ai
24
41
  ```
25
42
 
26
- Inside an Atomic [extension](/extensions), import the libraries without installing them. The running Atomic process provides them, so your extension shares its instances. If you publish an [Atomic package](/packages/authoring) that imports them, list them in `peerDependencies` with a `"*"` range.
43
+ Inside an Atomic [extension](/extensions), import the six core libraries without installing them. The running Atomic process provides them, so your extension shares its instances. If you publish an [Atomic package](/packages/authoring) that imports them, list them in `peerDependencies` with a `"*"` range.
27
44
 
28
- To build on Atomic's sessions, tools, and extensions rather than the bare libraries, use the [SDK](/sdk) instead. For custom extension UI, start with [TUI components](/tui).
45
+ To build on Atomic's sessions, tools, and extensions rather than the bare libraries, use the [SDK](/sdk) and [SDK storage backends](/sdk/storage). For custom extension UI, start with [TUI components](/tui).
29
46
 
30
47
  ## Older package names
31
48
 
32
- These libraries began as forks of pi's packages. Extensions written for pi still work inside Atomic. Imports of `@earendil-works/pi-ai`, `@earendil-works/pi-tui`, `@earendil-works/pi-agent-core`, `@earendil-works/pi-codemode`, `@earendil-works/pi-schema`, `@earendil-works/pi-telemetry`, their `@mariozechner/pi-*` equivalents, and `@bastani/pi-ai`, along with their subpaths, resolve to the matching `@bastani/atomic-*` package.
49
+ These libraries began as forks of pi's packages. Extensions written for pi still work inside Atomic: imports of `@earendil-works/pi-coding-agent` and `@mariozechner/pi-coding-agent` map to `@bastani/atomic`, while `@earendil-works/pi-ai`, `@earendil-works/pi-tui`, `@earendil-works/pi-agent-core`, `@earendil-works/pi-codemode`, `@earendil-works/pi-schema`, `@earendil-works/pi-telemetry`, their `@mariozechner/pi-*` equivalents, and `@bastani/pi-ai` (plus subpaths) map to the matching `@bastani/atomic-*` package.
33
50
 
34
51
  Use the `@bastani/atomic-*` names in new code. The older names resolve only inside Atomic. Outside Atomic, install the `@bastani/atomic-*` packages.