@bastani/atomic 0.10.10 → 0.10.11-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (380) hide show
  1. package/CHANGELOG.md +83 -0
  2. package/README.md +1 -1
  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 +8 -10
  7. package/dist/_shared/mode-interactive-sdk-7KXUFI2F.js.map +1 -1
  8. package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +6 -6
  9. package/dist/_shared/mode-shared-2QJSCUM6.js +52 -15
  10. package/dist/_shared/mode-shared-2QJSCUM6.js.map +1 -1
  11. package/dist/_shared/p1a-prewarm-XIU57JHF.js +3 -3
  12. package/dist/_shared/runtime-O4KCSG4C.js +3 -3
  13. package/dist/_shared/{sdk-RRLVN7ER.js → sdk-AVFII7NK.js} +757 -233
  14. package/dist/_shared/sdk-AVFII7NK.js.map +1 -0
  15. package/dist/_shared/session-data-AHTU7IS6.js +3 -3
  16. package/dist/_shared/session-manager-list-2BLEEZVG.js +1 -1
  17. package/dist/_shared/{startup-0-0-4VG2G44V.js → startup-0-0-57KF6LZH.js} +94 -42
  18. package/dist/_shared/startup-0-0-57KF6LZH.js.map +1 -0
  19. package/dist/_shared/{startup-0-1-XTIL65D4.js → startup-0-1-GIY75K46.js} +75 -13
  20. package/dist/_shared/startup-0-1-GIY75K46.js.map +1 -0
  21. package/dist/_shared/startup-0-2-27OWFHV6.js +72 -7
  22. package/dist/_shared/startup-0-2-27OWFHV6.js.map +1 -1
  23. package/dist/_shared/startup-0-3-T4DVFYWX.js +4 -4
  24. package/dist/_shared/startup-0-4-ZMJV547D.js +4 -4
  25. package/dist/_shared/{startup-0-5-FD2P735I.js → startup-0-5-YDW47QX6.js} +27 -69
  26. package/dist/_shared/startup-0-5-YDW47QX6.js.map +1 -0
  27. package/dist/_shared/startup-10-0-TDQNBDDL.js +6 -6
  28. package/dist/_shared/startup-12-0-55AAXBJZ.js +3 -3
  29. package/dist/_shared/startup-14-0-MLX36RBG.js +4 -4
  30. package/dist/_shared/startup-15-0-YUKGAC63.js +31 -7
  31. package/dist/_shared/startup-15-0-YUKGAC63.js.map +1 -1
  32. package/dist/_shared/startup-15-1-4S7FLMNG.js +7 -6
  33. package/dist/_shared/startup-15-1-4S7FLMNG.js.map +1 -1
  34. package/dist/_shared/startup-8-0-34CBHPZH.js +4 -4
  35. package/dist/_shared/{startup-8-1-4KANEHRA.js → startup-8-1-X32CYSXB.js} +1219 -714
  36. package/dist/_shared/startup-8-1-X32CYSXB.js.map +1 -0
  37. package/dist/_shared/storage-command-7MGXLJGZ.js +14 -8
  38. package/dist/_shared/storage-command-7MGXLJGZ.js.map +1 -1
  39. package/dist/_shared/task-reference-stream-JWMUZSJX.js +1 -1
  40. package/dist/_shared/task-unsaved-answer-VJ2KTB4V.js +2 -2
  41. package/dist/_shared/tree-outline-MUEPK5B7.js +2 -2
  42. package/dist/builtin/intercom/CHANGELOG.md +18 -0
  43. package/dist/builtin/intercom/broker/broker.bundle.mjs +993 -362
  44. package/dist/builtin/intercom/broker/database-wake-up-bus.ts +103 -24
  45. package/dist/builtin/intercom/broker/multinode-router.ts +42 -21
  46. package/dist/builtin/intercom/broker/multinode-state-store.ts +22 -1
  47. package/dist/builtin/intercom/broker/open-broker-state.ts +82 -31
  48. package/dist/builtin/intercom/broker/paths.ts +8 -4
  49. package/dist/builtin/intercom/broker/released-asker-remote-replies.ts +18 -6
  50. package/dist/builtin/intercom/broker/sql-add-column.ts +4 -1
  51. package/dist/builtin/intercom/broker/sql-ended-child-queue-store.ts +65 -44
  52. package/dist/builtin/intercom/broker/sql-held-send-store.ts +11 -3
  53. package/dist/builtin/intercom/broker/sql-known-session-store.ts +24 -12
  54. package/dist/builtin/intercom/broker/sql-lease-store.ts +375 -65
  55. package/dist/builtin/intercom/broker/sql-outbox-store.ts +270 -101
  56. package/dist/builtin/intercom/broker/sql-pending-ask-store.ts +20 -9
  57. package/dist/builtin/intercom/broker/sql-released-ask-store.ts +14 -6
  58. package/dist/builtin/intercom/broker/sql-restoring-reservation-store.ts +27 -11
  59. package/dist/builtin/intercom/broker/sql-schema.ts +139 -1
  60. package/dist/builtin/intercom/broker/sql-sent-message-authority.ts +97 -34
  61. package/dist/builtin/intercom/index.bundle.mjs +11 -8
  62. package/dist/builtin/intercom/package.json +1 -1
  63. package/dist/builtin/mcp/index.bundle.mjs +1 -1
  64. package/dist/builtin/mcp/package.json +1 -1
  65. package/dist/builtin/subagents/CHANGELOG.md +12 -0
  66. package/dist/builtin/subagents/package.json +1 -1
  67. package/dist/builtin/subagents/skills/skill-creator/SKILL.md +1 -1
  68. package/dist/builtin/subagents/src/extension/index.bundle.mjs +62 -23
  69. package/dist/builtin/web-access/index.bundle.mjs +1 -1
  70. package/dist/builtin/web-access/package.json +1 -1
  71. package/dist/cli/args.js +2 -2
  72. package/dist/cli/auth-cli.code.js +4 -4
  73. package/dist/cli/auth-cli.impl.js +3 -3
  74. package/dist/cli/auth-cli.js +3 -3
  75. package/dist/cli/blueprint-command.code.js +3 -3
  76. package/dist/cli/blueprint-command.impl.js +3 -3
  77. package/dist/cli/blueprint-command.js +3 -3
  78. package/dist/cli/intercom-command.code.js +2 -2
  79. package/dist/cli/intercom-command.impl.js +3 -3
  80. package/dist/cli/intercom-command.js +3 -3
  81. package/dist/cli/list-models.code.js +2 -2
  82. package/dist/cli/list-models.impl.js +3 -3
  83. package/dist/cli/list-models.js +3 -3
  84. package/dist/cli/session-picker.code.js +1 -1
  85. package/dist/cli/session-picker.impl.js +3 -3
  86. package/dist/cli/session-picker.js +3 -3
  87. package/dist/cli/startup-ui.code.js +1 -1
  88. package/dist/cli/startup-ui.impl.js +3 -3
  89. package/dist/cli/startup-ui.js +3 -3
  90. package/dist/cli/storage-command.impl.js +3 -3
  91. package/dist/cli/storage-command.js +3 -3
  92. package/dist/cli/storage-search-session.code.js +3 -3
  93. package/dist/cli/storage-search-session.impl.js +3 -3
  94. package/dist/cli/storage-search-session.js +3 -3
  95. package/dist/cli/team-command.code.js +2 -2
  96. package/dist/cli/team-command.impl.js +3 -3
  97. package/dist/cli/team-command.js +3 -3
  98. package/dist/cli.js +2 -2
  99. package/dist/core/agent-session-methods.d.ts +3 -0
  100. package/dist/core/agent-session-methods.js.map +1 -1
  101. package/dist/core/agent-session.d.ts +1 -0
  102. package/dist/core/compaction/compactor.d.ts +2 -0
  103. package/dist/core/debug.impl.js +3 -3
  104. package/dist/core/debug.js +3 -3
  105. package/dist/core/export-html/card-projection.code.js +1 -1
  106. package/dist/core/export-html/card-projection.impl.js +3 -3
  107. package/dist/core/export-html/card-projection.js +3 -3
  108. package/dist/core/export-html/index.code.js +2 -2
  109. package/dist/core/export-html/index.impl.js +3 -3
  110. package/dist/core/export-html/index.js +3 -3
  111. package/dist/core/export-html/json-spans.impl.js +3 -3
  112. package/dist/core/export-html/json-spans.js +3 -3
  113. package/dist/core/export-html/oversized-render-inputs.code.js +1 -1
  114. package/dist/core/export-html/oversized-render-inputs.impl.js +3 -3
  115. package/dist/core/export-html/oversized-render-inputs.js +3 -3
  116. package/dist/core/export-html/tool-renderer.impl.js +3 -3
  117. package/dist/core/export-html/tool-renderer.js +3 -3
  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 +2 -2
  126. package/dist/core/extensions/runner-context.js +3 -3
  127. package/dist/core/extensions/runner-context.js.map +1 -1
  128. package/dist/core/intercom-broker-control-host.code.js +1 -1
  129. package/dist/core/intercom-broker-control-host.impl.js +3 -3
  130. package/dist/core/intercom-broker-control-host.js +3 -3
  131. package/dist/core/intercom-broker-control.code.js +3 -3
  132. package/dist/core/intercom-broker-control.impl.js +3 -3
  133. package/dist/core/intercom-broker-control.js +3 -3
  134. package/dist/core/model-registry.js +1 -1
  135. package/dist/core/model-resolver-defaults.d.ts +3 -2
  136. package/dist/core/package-manager-storage-adapters.code.js +1 -1
  137. package/dist/core/package-manager-storage-adapters.impl.js +3 -3
  138. package/dist/core/package-manager-storage-adapters.js +3 -3
  139. package/dist/core/sdk.code.js +3 -4
  140. package/dist/core/sdk.impl.js +3 -3
  141. package/dist/core/sdk.js +3 -3
  142. package/dist/core/session-manager-core.d.ts +5 -2
  143. package/dist/core/session-manager-core.js +17 -13
  144. package/dist/core/session-manager-core.js.map +1 -1
  145. package/dist/core/session-manager-list.impl.js +3 -3
  146. package/dist/core/session-manager-list.js +3 -3
  147. package/dist/core/session-manager.code.js +1 -1
  148. package/dist/core/session-manager.impl.js +3 -3
  149. package/dist/core/session-manager.js +3 -3
  150. package/dist/core/session-storage.code.js +1 -1
  151. package/dist/core/session-storage.impl.js +3 -3
  152. package/dist/core/session-storage.js +3 -3
  153. package/dist/core/storage/added-exports.d.ts +6 -0
  154. package/dist/core/storage/added-exports.js +16 -0
  155. package/dist/core/storage/added-exports.js.map +1 -0
  156. package/dist/core/storage/database.d.ts +16 -0
  157. package/dist/core/storage/database.js.map +1 -1
  158. package/dist/core/storage/fenced-paths.d.ts +47 -0
  159. package/dist/core/storage/fenced-paths.js +53 -0
  160. package/dist/core/storage/fenced-paths.js.map +1 -1
  161. package/dist/core/storage/file-identity.js +31 -2
  162. package/dist/core/storage/file-identity.js.map +1 -1
  163. package/dist/core/storage/index.d.ts +3 -0
  164. package/dist/core/storage/index.js +5 -2
  165. package/dist/core/storage/index.js.map +1 -1
  166. package/dist/core/storage/migrations.d.ts +22 -0
  167. package/dist/core/storage/migrations.js +55 -0
  168. package/dist/core/storage/migrations.js.map +1 -1
  169. package/dist/core/storage/node-sqlite-thread.js +19 -6
  170. package/dist/core/storage/node-sqlite-thread.js.map +1 -1
  171. package/dist/core/storage/node-sqlite.js +53 -4
  172. package/dist/core/storage/node-sqlite.js.map +1 -1
  173. package/dist/core/storage/offline-snapshot-file.impl.js +3 -3
  174. package/dist/core/storage/offline-snapshot-file.js +3 -3
  175. package/dist/core/storage/prefix.d.ts +3 -2
  176. package/dist/core/storage/prefix.js +18 -2
  177. package/dist/core/storage/prefix.js.map +1 -1
  178. package/dist/core/storage/provider.js +2 -2
  179. package/dist/core/storage/schema-catalog.d.ts +42 -0
  180. package/dist/core/storage/schema-catalog.js +141 -0
  181. package/dist/core/storage/schema-catalog.js.map +1 -0
  182. package/dist/core/storage/selection.js +2 -2
  183. package/dist/core/storage/session/branch-fork-source.code.js +41 -20
  184. package/dist/core/storage/session/branch-fork-source.code.js.map +1 -1
  185. package/dist/core/storage/session/branch-fork-source.impl.js +3 -3
  186. package/dist/core/storage/session/branch-fork-source.js +3 -3
  187. package/dist/core/storage/session/card-view.impl.js +3 -3
  188. package/dist/core/storage/session/card-view.js +3 -3
  189. package/dist/core/storage/session/child-reader.code.js +3 -3
  190. package/dist/core/storage/session/child-reader.impl.js +3 -3
  191. package/dist/core/storage/session/child-reader.js +3 -3
  192. package/dist/core/storage/session/chunked-resume-projection.code.js +1 -1
  193. package/dist/core/storage/session/chunked-resume-projection.impl.js +3 -3
  194. package/dist/core/storage/session/chunked-resume-projection.js +3 -3
  195. package/dist/core/storage/session/expanded-child-details.code.js +3 -3
  196. package/dist/core/storage/session/expanded-child-details.impl.js +3 -3
  197. package/dist/core/storage/session/expanded-child-details.js +3 -3
  198. package/dist/core/storage/session/fork-row-bytes.impl.js +3 -3
  199. package/dist/core/storage/session/fork-row-bytes.js +3 -3
  200. package/dist/core/storage/session/fork-row-index.impl.js +3 -3
  201. package/dist/core/storage/session/fork-row-index.js +3 -3
  202. package/dist/core/storage/session/fork-staging.code.js +176 -36
  203. package/dist/core/storage/session/fork-staging.code.js.map +1 -1
  204. package/dist/core/storage/session/fork-staging.impl.js +3 -3
  205. package/dist/core/storage/session/fork-staging.js +3 -3
  206. package/dist/core/storage/session/fork-window.code.js +3 -3
  207. package/dist/core/storage/session/fork-window.impl.js +3 -3
  208. package/dist/core/storage/session/fork-window.js +3 -3
  209. package/dist/core/storage/session/history-pages.impl.js +3 -3
  210. package/dist/core/storage/session/history-pages.js +3 -3
  211. package/dist/core/storage/session/jsonl-entry-projection.impl.js +3 -3
  212. package/dist/core/storage/session/jsonl-entry-projection.js +3 -3
  213. package/dist/core/storage/session/jsonl-session-store.impl.js +3 -3
  214. package/dist/core/storage/session/jsonl-session-store.js +3 -3
  215. package/dist/core/storage/session/memory-session-store.impl.js +3 -3
  216. package/dist/core/storage/session/memory-session-store.js +3 -3
  217. package/dist/core/storage/session/pinned-branch-resume.code.js +3 -3
  218. package/dist/core/storage/session/pinned-branch-resume.impl.js +3 -3
  219. package/dist/core/storage/session/pinned-branch-resume.js +3 -3
  220. package/dist/core/storage/session/released-history-files.code.js +2 -2
  221. package/dist/core/storage/session/released-history-files.impl.js +3 -3
  222. package/dist/core/storage/session/released-history-files.js +3 -3
  223. package/dist/core/storage/session/resident-fork-rows.impl.js +3 -3
  224. package/dist/core/storage/session/resident-fork-rows.js +3 -3
  225. package/dist/core/storage/session/session-resume.impl.js +3 -3
  226. package/dist/core/storage/session/session-resume.js +3 -3
  227. package/dist/core/storage/session/session-search-index.d.ts +5 -0
  228. package/dist/core/storage/session/snapshot-cut.impl.js +3 -3
  229. package/dist/core/storage/session/snapshot-cut.js +3 -3
  230. package/dist/core/storage/session/snapshot-history.code.js +3 -3
  231. package/dist/core/storage/session/snapshot-history.impl.js +3 -3
  232. package/dist/core/storage/session/snapshot-history.js +3 -3
  233. package/dist/core/storage/session/sql-chat-records.d.ts +15 -0
  234. package/dist/core/storage/session/sql-session-store.code.js +1 -1
  235. package/dist/core/storage/session/sql-session-store.d.ts +102 -5
  236. package/dist/core/storage/session/sql-session-store.impl.js +4 -4
  237. package/dist/core/storage/session/sql-session-store.js +4 -4
  238. package/dist/core/storage/session/tree-outline.impl.js +3 -3
  239. package/dist/core/storage/session/tree-outline.js +3 -3
  240. package/dist/core/storage/session/tree-presentation.code.js +1 -1
  241. package/dist/core/storage/session/tree-presentation.impl.js +3 -3
  242. package/dist/core/storage/session/tree-presentation.js +3 -3
  243. package/dist/core/storage/session/types.d.ts +14 -0
  244. package/dist/core/storage/sqlite-facade.d.ts +37 -5
  245. package/dist/core/storage/sqlite-facade.js +351 -18
  246. package/dist/core/storage/sqlite-facade.js.map +1 -1
  247. package/dist/core/storage/statement-sequence.d.ts +83 -0
  248. package/dist/core/storage/statement-sequence.js +21 -0
  249. package/dist/core/storage/statement-sequence.js.map +1 -1
  250. package/dist/core/storage/storage-status.code.js +1 -1
  251. package/dist/core/storage/storage-status.impl.js +3 -3
  252. package/dist/core/storage/storage-status.js +3 -3
  253. package/dist/core/storage/team.code.js +1 -1
  254. package/dist/core/storage/team.impl.js +3 -3
  255. package/dist/core/storage/team.js +3 -3
  256. package/dist/core/structured-output/index.code.js +1 -1
  257. package/dist/core/structured-output/index.impl.js +3 -3
  258. package/dist/core/structured-output/index.js +3 -3
  259. package/dist/core/tasks/task-completion-entry.code.js +1 -1
  260. package/dist/core/tasks/task-completion-entry.impl.js +3 -3
  261. package/dist/core/tasks/task-completion-entry.js +3 -3
  262. package/dist/core/tasks/task-file-history.code.js +3 -3
  263. package/dist/core/tasks/task-file-history.impl.js +3 -3
  264. package/dist/core/tasks/task-file-history.js +3 -3
  265. package/dist/core/tasks/task-reference-archive.code.js +4 -4
  266. package/dist/core/tasks/task-reference-archive.js +3 -3
  267. package/dist/core/tasks/task-reference-identity.js +3 -3
  268. package/dist/core/tasks/task-reference-stream.impl.js +3 -3
  269. package/dist/core/tasks/task-reference-stream.js +3 -3
  270. package/dist/core/tasks/task-unsaved-answer.impl.js +3 -3
  271. package/dist/core/tasks/task-unsaved-answer.js +3 -3
  272. package/dist/core/tasks/task-view-source.code.js +1 -1
  273. package/dist/core/tasks/task-view-source.impl.js +3 -3
  274. package/dist/core/tasks/task-view-source.js +3 -3
  275. package/dist/core/tools/bash.d.ts +8 -4
  276. package/dist/core/tools/history-session.d.ts +5 -0
  277. package/dist/core/tools/history-tasks.d.ts +123 -0
  278. package/dist/core/tools/kill.d.ts +5 -2
  279. package/dist/core/tools/powershell.d.ts +2 -2
  280. package/dist/core/tools/read-url.code.js +3 -3
  281. package/dist/core/tools/read-url.impl.js +3 -3
  282. package/dist/core/tools/read-url.js +3 -3
  283. package/dist/core/tools/read.d.ts +12 -2
  284. package/dist/core/tools/resource-selectors.d.ts +2 -0
  285. package/dist/core/tools/search.d.ts +12 -2
  286. package/dist/core/worktree-snapshot/blob-store.d.ts +14 -2
  287. package/dist/core/worktree-snapshot/blob-store.js +69 -16
  288. package/dist/core/worktree-snapshot/blob-store.js.map +1 -1
  289. package/dist/core/worktree-snapshot/errors.code.js +2 -2
  290. package/dist/core/worktree-snapshot/errors.impl.js +3 -3
  291. package/dist/core/worktree-snapshot/errors.js +3 -3
  292. package/dist/core/worktree-snapshot/session-index-reset.impl.js +3 -3
  293. package/dist/core/worktree-snapshot/session-index-reset.js +3 -3
  294. package/dist/extensions/codemode/execute.code.js +2 -2
  295. package/dist/extensions/codemode/execute.impl.js +3 -3
  296. package/dist/extensions/codemode/execute.js +3 -3
  297. package/dist/extensions/codemode/renderer.code.js +2 -2
  298. package/dist/extensions/codemode/renderer.impl.js +3 -3
  299. package/dist/extensions/codemode/renderer.js +3 -3
  300. package/dist/extensions/mcp/cli.code.js +3 -3
  301. package/dist/extensions/mcp/cli.impl.js +3 -3
  302. package/dist/extensions/mcp/cli.js +3 -3
  303. package/dist/extensions/mcp/cli.lazy.code.js +2 -2
  304. package/dist/extensions/mcp/cli.lazy.impl.js +3 -3
  305. package/dist/extensions/mcp/cli.lazy.js +3 -3
  306. package/dist/extensions/mcp/runtime.code.js +1 -1
  307. package/dist/extensions/mcp/runtime.impl.js +3 -3
  308. package/dist/extensions/mcp/runtime.js +3 -3
  309. package/dist/index.js +5 -5
  310. package/dist/main-first-time-setup.code.js +1 -1
  311. package/dist/main-first-time-setup.impl.js +3 -3
  312. package/dist/main-first-time-setup.js +3 -3
  313. package/dist/main.js +1 -1
  314. package/dist/modes/interactive/components/agent-panel.d.ts +1 -0
  315. package/dist/modes/interactive/components/stored-tree-view.code.js +2 -2
  316. package/dist/modes/interactive/components/stored-tree-view.impl.js +3 -3
  317. package/dist/modes/interactive/components/stored-tree-view.js +3 -3
  318. package/dist/modes/interactive/components/task-inspector.d.ts +2 -0
  319. package/dist/modes/interactive/components/user-message-selector-archive.code.js +1 -1
  320. package/dist/modes/interactive/components/user-message-selector-archive.impl.js +3 -3
  321. package/dist/modes/interactive/components/user-message-selector-archive.js +3 -3
  322. package/dist/modes/interactive/interactive-mode-helpers.d.ts +2 -2
  323. package/dist/modes/print-mode.js +1 -1
  324. package/dist/modes/rpc/agent-panel-bridge.d.ts +5 -0
  325. package/dist/package-manager-cli.code.js +6 -6
  326. package/dist/package-manager-cli.impl.js +3 -3
  327. package/dist/package-manager-cli.js +3 -3
  328. package/dist/rpc-entry.js +1 -1
  329. package/dist/startup-files.json +1 -1
  330. package/dist/startup-stages/0.js +1 -1
  331. package/dist/startup-stages/1.js +1 -1
  332. package/dist/startup-stages/10.js +1 -1
  333. package/dist/startup-stages/12.js +1 -1
  334. package/dist/startup-stages/2.js +8 -1
  335. package/dist/startup-stages/3.js +1 -6
  336. package/dist/startup-stages/5.js +1 -1
  337. package/dist/startup-stages/7.js +1 -5
  338. package/dist/utils/startup-database-spare.code.js +2 -2
  339. package/dist/utils/startup-database-spare.impl.js +3 -3
  340. package/dist/utils/startup-database-spare.js +3 -3
  341. package/dist/utils/tools-manager.code.js +1 -1
  342. package/dist/utils/tools-manager.impl.js +3 -3
  343. package/dist/utils/tools-manager.js +3 -3
  344. package/docs/background-tasks.md +123 -23
  345. package/docs/compaction.md +18 -0
  346. package/docs/docs.json +2 -0
  347. package/docs/environment-variables.md +1 -1
  348. package/docs/getting-started/installation.md +9 -2
  349. package/docs/guides/postgres-pgbouncer.md +339 -0
  350. package/docs/guides/postgres-tuning.md +311 -0
  351. package/docs/guides/resume-on-any-machine.md +2 -2
  352. package/docs/guides.md +2 -0
  353. package/docs/index.md +1 -1
  354. package/docs/libraries/agent-core.md +1 -1
  355. package/docs/libraries/ai.md +2 -2
  356. package/docs/libraries/codemode.md +1 -1
  357. package/docs/libraries/storage-libsql.md +6 -1
  358. package/docs/libraries/storage-postgres.md +11 -6
  359. package/docs/libraries/tui.md +1 -1
  360. package/docs/libraries.md +2 -2
  361. package/docs/programmatic.md +1 -1
  362. package/docs/quickstart.md +1 -1
  363. package/docs/sdk/storage.md +1 -1
  364. package/docs/sdk/web-server.md +1 -3
  365. package/docs/sdk.md +1 -7
  366. package/docs/sessions.md +58 -2
  367. package/docs/settings.md +20 -1
  368. package/docs/skills/authoring.md +1 -1
  369. package/docs/skills.md +79 -6
  370. package/docs/storage.md +262 -12
  371. package/docs/subagents/reference.md +2 -2
  372. package/docs/subagents.md +4 -3
  373. package/docs/tools.md +44 -10
  374. package/docs/windows.md +1 -1
  375. package/package.json +9 -9
  376. package/dist/_shared/sdk-RRLVN7ER.js.map +0 -1
  377. package/dist/_shared/startup-0-0-4VG2G44V.js.map +0 -1
  378. package/dist/_shared/startup-0-1-XTIL65D4.js.map +0 -1
  379. package/dist/_shared/startup-0-5-FD2P735I.js.map +0 -1
  380. package/dist/_shared/startup-8-1-4KANEHRA.js.map +0 -1
@@ -92,14 +92,22 @@ function refusalFor(ask: ReleasedAskRecord, messageId: string): ReleasedReplyDec
92
92
  return { kind: "refused", error: refusalOf(ask, messageId) };
93
93
  }
94
94
 
95
- /** The first live presence that matches, with the broker hosting it. */
95
+ /** The first live presence of the session `sessionId`, with the broker hosting it. */
96
96
  async function liveSession(
97
97
  state: Pick<ReleasedReplyState, "leases">,
98
- matches: (subject: RecipientPresenceSubject) => boolean,
98
+ sessionId: string,
99
99
  ): Promise<ReleasedReplyOwner | undefined> {
100
- for (const lease of await state.leases.listLive("presence", BROKER_LEASE_STALE_AFTER_MS)) {
100
+ const { leases } = state;
101
+ // Only the presences that may be the session's, by index, where the store can (#6560).
102
+ const live =
103
+ leases.listLiveFor === undefined
104
+ ? await leases.listLive("presence", BROKER_LEASE_STALE_AFTER_MS)
105
+ : await leases.listLiveFor(sessionId, BROKER_LEASE_STALE_AFTER_MS);
106
+ // Presences are stored with every string well formed (#6560).
107
+ const id = sessionId.toWellFormed();
108
+ for (const lease of live) {
101
109
  const subject = lease.subject as RecipientPresenceSubject;
102
- if (matches(subject)) {
110
+ if (subject.session.id === id) {
103
111
  return { identity: subject.targetIdentity, sessionId: subject.session.id, hostBrokerId: lease.holderId };
104
112
  }
105
113
  }
@@ -108,7 +116,7 @@ async function liveSession(
108
116
 
109
117
  /** The owner where it is connected now, or where it last was, so the reply waits there for it. */
110
118
  async function ownerOfSession(state: ReleasedReplyState, ownerSessionId: string): Promise<ReleasedReplyOwner | undefined> {
111
- const live = await liveSession(state, (subject) => subject.session.id === ownerSessionId);
119
+ const live = await liveSession(state, ownerSessionId);
112
120
  // A presence or record under the owner's id bound to another return address is not the owner (multi-node binding).
113
121
  if (live !== undefined && (await holdsSessionId(state.knownSessions, ownerSessionId, returnAddressOf(live.identity))))
114
122
  return live;
@@ -145,7 +153,11 @@ export async function ownerOfReleasedReplyRow(
145
153
  row: Pick<OutboxRow, "targetIdentity">,
146
154
  ): Promise<ReleasedReplyOwner> {
147
155
  const identity = row.targetIdentity;
148
- return (await liveSession(state, (subject) => subject.targetIdentity === identity)) ?? { identity, sessionId: "" };
156
+ // The live presence of the row's identity: the one lease under that key (#6560).
157
+ const read = await state.leases.read({ kind: "presence", targetIdentity: identity });
158
+ if (read.status !== "found" || read.lease.ageMs > BROKER_LEASE_STALE_AFTER_MS) return { identity, sessionId: "" };
159
+ const subject = read.lease.subject as RecipientPresenceSubject;
160
+ return { identity, sessionId: subject.session.id, hostBrokerId: read.lease.holderId };
149
161
  }
150
162
 
151
163
  async function ownerOfRow(state: ReleasedReplyState, messageId: string): Promise<ReleasedReplyOwner | undefined> {
@@ -1,4 +1,5 @@
1
1
  import { dialectOf, type SqliteDatabase } from "@bastani/atomic/storage";
2
+ import { catalogHasColumns } from "./sql-schema.js";
2
3
 
3
4
  function isLineTerminatorCode(code: number): boolean {
4
5
  return code === 0x0a || code === 0x0d || code === 0x2028 || code === 0x2029;
@@ -80,7 +81,7 @@ function isDuplicateColumn(error: unknown): boolean {
80
81
  * A statement the database refused for a privilege the role lacks: the PostgreSQL adapter's `missing-privilege`, which
81
82
  * the database facade reports as the cause of its `StorageUnavailableError`.
82
83
  */
83
- function isMissingPrivilege(error: unknown): boolean {
84
+ export function isMissingPrivilege(error: unknown): boolean {
84
85
  let at = error;
85
86
  for (let depth = 0; depth < 4 && typeof at === "object" && at !== null; depth++) {
86
87
  if ((at as { reason?: unknown }).reason === "missing-privilege") return true;
@@ -123,6 +124,8 @@ export async function addMissingColumns(
123
124
  withColumn?: string,
124
125
  ): Promise<void> {
125
126
  const dialect = dialectOf(database);
127
+ // An open that read the catalog and found every column there runs no transaction (#6560).
128
+ if (await catalogHasColumns(database, table, Object.keys(columns))) return;
126
129
  for (const [column, definition] of Object.entries(columns)) {
127
130
  const probe = dialect.columnExists(table, column);
128
131
  try {
@@ -10,7 +10,7 @@ import {
10
10
  } from "@bastani/atomic/storage";
11
11
  import { ENDED_CHILD_QUEUE_BYTES_TOTAL_MAX, EndedChildQueueFullError } from "./ended-child-wakes.js";
12
12
  import type { IntercomBrokerStateOptions } from "./multinode-state-store.js";
13
- import { ensureBrokerSchema } from "./sql-schema.js";
13
+ import { ensureBrokerSchema, withBrokerSchemaCatalog } from "./sql-schema.js";
14
14
 
15
15
  /**
16
16
  * #5999 durable wake queue: the messages queued for subagents that ended (to be resumed, or kept while paused), kept
@@ -287,8 +287,13 @@ class OrderedWrites {
287
287
  private brokenUntil = Number.NEGATIVE_INFINITY;
288
288
  private brokenBy: unknown;
289
289
 
290
+ /**
291
+ * @param domain The queue's table: its writes touch the queue's own tables alone, so they exclude one another, not
292
+ * every writer of a shared database (#6560).
293
+ */
290
294
  constructor(
291
295
  private readonly database: SqliteDatabase,
296
+ private readonly domain: string,
292
297
  private readonly lockWaitMs = ENDED_QUEUE_LOCK_WAIT_MS,
293
298
  ) {}
294
299
 
@@ -340,7 +345,7 @@ class OrderedWrites {
340
345
  }
341
346
  }
342
347
  return outcomes;
343
- }, { lockWaitMs: this.lockWaitMs });
348
+ }, { lockWaitMs: this.lockWaitMs, concurrency: { kind: "serial", domain: this.domain } });
344
349
  batch.forEach((item, index) => {
345
350
  const outcome = results[index]!;
346
351
  if (outcome.ok) item.resolve(outcome.value);
@@ -548,53 +553,17 @@ function failureForm(senderJson: string, requestJson: string | null): { readonly
548
553
  }
549
554
 
550
555
  /**
551
- * #5999: the queue on `database`, tables `<prefix>intercom_ended_child_queue`, `<prefix>intercom_ended_child_wakes` and
552
- * `<prefix>intercom_ended_child_meta`. `home` partitions the rows by broker home; `holder` is this broker instance.
556
+ * Creates the ended-child queue's tables unless the store's ledger says they are there, as its first open on a database
557
+ * does, and as `atomic storage migrate` does, so a runtime role that may not create tables finds them (#6560).
553
558
  */
554
- export async function openSqlEndedChildQueueStore(
555
- { database, prefix }: IntercomBrokerStateOptions,
556
- {
557
- home,
558
- holder,
559
- ownsDatabase = false,
560
- retire: retiring = false,
561
- lockWaitMs = ENDED_QUEUE_LOCK_WAIT_MS,
562
- servedSinceLastHolder,
563
- pid,
564
- compact = false,
565
- }: {
566
- readonly home: string;
567
- readonly holder: string;
568
- readonly ownsDatabase?: boolean;
569
- /** How long a write waits for another process's write lock (default {@link ENDED_QUEUE_LOCK_WAIT_MS}). */
570
- readonly lockWaitMs?: number;
571
- /**
572
- * Whether another broker can have served this home since the store's last holder, which kept nothing and told
573
- * senders their messages were lost: given the store's identity, says if this broker could not prove it did not.
574
- * Unproven, a store with messages is retired. Absent: never retired so.
575
- */
576
- readonly servedSinceLastHolder?: (storeId: string) => boolean;
577
- /** This broker's process id, recorded as the store's holder. */
578
- readonly pid?: string;
579
- /** A broker that kept the queue in memory told its sessions what this store kept was lost: drop it. */
580
- readonly retire?: boolean;
581
- /**
582
- * The database is this store's own file: once its queue drains, the file gives the space its messages took back,
583
- * a bounded step at a time (incremental auto-vacuum). A shared database keeps its own maintenance.
584
- */
585
- readonly compact?: boolean;
586
- },
587
- ): Promise<EndedChildQueueStore> {
588
- let retire = retiring;
559
+ export async function ensureEndedChildQueueSchema({ database, prefix }: IntercomBrokerStateOptions): Promise<void> {
589
560
  const valid = validateStoragePrefix(prefix, dialectOf(database).name);
590
561
  const queue = `${valid}intercom_ended_child_queue`;
591
- // The messages themselves, apart from the rows a broker updates (holder, wake, away, handed over): an update never
592
- // rewrites a message.
593
562
  const bodies = `${valid}intercom_ended_child_bodies`;
594
563
  const wakes = `${valid}intercom_ended_child_wakes`;
595
564
  const meta = `${valid}intercom_ended_child_meta`;
596
565
  const { types } = dialectOf(database);
597
- const createSchema = () => ensureBrokerSchema(database, prefix, "ended-child-queue", (tx) =>
566
+ await ensureBrokerSchema(database, prefix, "ended-child-queue", (tx) =>
598
567
  tx.exec(`
599
568
  CREATE TABLE IF NOT EXISTS ${queue}(
600
569
  seq ${types.serialKey},
@@ -636,6 +605,58 @@ export async function openSqlEndedChildQueueStore(
636
605
  );
637
606
  `),
638
607
  );
608
+ }
609
+
610
+ /**
611
+ * #5999: the queue on `database`, tables `<prefix>intercom_ended_child_queue`, `<prefix>intercom_ended_child_wakes` and
612
+ * `<prefix>intercom_ended_child_meta`. `home` partitions the rows by broker home; `holder` is this broker instance.
613
+ */
614
+ export async function openSqlEndedChildQueueStore(
615
+ { database, prefix }: IntercomBrokerStateOptions,
616
+ {
617
+ home,
618
+ holder,
619
+ ownsDatabase = false,
620
+ retire: retiring = false,
621
+ lockWaitMs = ENDED_QUEUE_LOCK_WAIT_MS,
622
+ servedSinceLastHolder,
623
+ pid,
624
+ compact = false,
625
+ }: {
626
+ readonly home: string;
627
+ readonly holder: string;
628
+ readonly ownsDatabase?: boolean;
629
+ /** How long a write waits for another process's write lock (default {@link ENDED_QUEUE_LOCK_WAIT_MS}). */
630
+ readonly lockWaitMs?: number;
631
+ /**
632
+ * Whether another broker can have served this home since the store's last holder, which kept nothing and told
633
+ * senders their messages were lost: given the store's identity, says if this broker could not prove it did not.
634
+ * Unproven, a store with messages is retired. Absent: never retired so.
635
+ */
636
+ readonly servedSinceLastHolder?: (storeId: string) => boolean;
637
+ /** This broker's process id, recorded as the store's holder. */
638
+ readonly pid?: string;
639
+ /** A broker that kept the queue in memory told its sessions what this store kept was lost: drop it. */
640
+ readonly retire?: boolean;
641
+ /**
642
+ * The database is this store's own file: once its queue drains, the file gives the space its messages took back,
643
+ * a bounded step at a time (incremental auto-vacuum). A shared database keeps its own maintenance.
644
+ */
645
+ readonly compact?: boolean;
646
+ },
647
+ ): Promise<EndedChildQueueStore> {
648
+ let retire = retiring;
649
+ const valid = validateStoragePrefix(prefix, dialectOf(database).name);
650
+ const queue = `${valid}intercom_ended_child_queue`;
651
+ // The messages themselves, apart from the rows a broker updates (holder, wake, away, handed over): an update never
652
+ // rewrites a message.
653
+ const bodies = `${valid}intercom_ended_child_bodies`;
654
+ const wakes = `${valid}intercom_ended_child_wakes`;
655
+ const meta = `${valid}intercom_ended_child_meta`;
656
+ // Set up when a home first opens the queue, long after the broker's other stores: checked against a read of the
657
+ // schema catalog of its own, so a database where another home set the queue up costs no transaction or lock (#6560).
658
+ const createSchema = () =>
659
+ withBrokerSchemaCatalog(database, prefix, () => ensureEndedChildQueueSchema({ database, prefix }));
639
660
  // The identity of a store already set up is read without a write, so a broker's start never waits for another
640
661
  // process's write lock on it (a reader of a write-ahead log is not blocked by a writer). A new one is set up first.
641
662
  const readMeta = async (): Promise<{ readonly id: string; readonly holderPid?: string } | undefined> => {
@@ -667,10 +688,10 @@ export async function openSqlEndedChildQueueStore(
667
688
  await tx.run(`INSERT INTO ${meta}(home, store_id) VALUES (?, ?) ON CONFLICT DO NOTHING`, home, randomUUID());
668
689
  const row = await tx.get<SqliteRow & { store_id: string }>(`SELECT store_id FROM ${meta} WHERE home = ?`, home);
669
690
  return row?.store_id as string;
670
- });
691
+ }, { concurrency: { kind: "serial", domain: queue } });
671
692
  }
672
693
  const keeper = id;
673
- const writes = new OrderedWrites(database, lockWaitMs);
694
+ const writes = new OrderedWrites(database, queue, lockWaitMs);
674
695
  let compacting: Promise<void> | undefined;
675
696
  let closing = false;
676
697
  const pragmaOf = async (executor: SqliteExecutor, name: string): Promise<number> => {
@@ -11,7 +11,7 @@ import type {
11
11
  InvalidStateInput,
12
12
  StateStoreInvalidReason,
13
13
  } from "./multinode-state-store.js";
14
- import { ensureBrokerSchema } from "./sql-schema.js";
14
+ import { ensureBrokerSchema, withBrokerSchemaCatalog } from "./sql-schema.js";
15
15
 
16
16
  type HeldRow = SqliteRow & {
17
17
  reservation_key: string;
@@ -35,9 +35,17 @@ function heldSendOf(row: HeldRow): HeldSend {
35
35
  * S3: `HeldSendStore` on the shared storage adapter's database, table `<prefix>intercom_held_sends`. Sends are keyed
36
36
  * by `reservationKeyFor(capability)`; the capability itself is never stored.
37
37
  */
38
- export async function openSqlHeldSendStore({ database, prefix }: IntercomBrokerStateOptions): Promise<HeldSendStore> {
38
+ export function openSqlHeldSendStore(options: IntercomBrokerStateOptions): Promise<HeldSendStore> {
39
+ // Its schema checks answer from one read of the catalog, shared with an open around it: a current schema costs
40
+ // no transaction and no lock, also when the store is opened on its own (#6560).
41
+ return withBrokerSchemaCatalog(options.database, options.prefix, () => openHeldSendStoreInCatalog(options));
42
+ }
43
+
44
+ async function openHeldSendStoreInCatalog({ database, prefix }: IntercomBrokerStateOptions): Promise<HeldSendStore> {
39
45
  const table = `${validateStoragePrefix(prefix, dialectOf(database).name)}intercom_held_sends`;
40
46
  const { types, nowMs } = dialectOf(database);
47
+ /** `take` reads and writes this table alone, so it excludes other takes, not every writer (#6560). */
48
+ const serial = { concurrency: { kind: "serial", domain: table } } as const;
41
49
  await ensureBrokerSchema(database, prefix, "held-sends", (tx) =>
42
50
  tx.exec(`
43
51
  CREATE TABLE IF NOT EXISTS ${table}(
@@ -84,7 +92,7 @@ export async function openSqlHeldSendStore({ database, prefix }: IntercomBrokerS
84
92
  const taken = await tx.all<HeldRow>(selectForReservation, reservationKey);
85
93
  await tx.run(`DELETE FROM ${table} WHERE reservation_key = ?`, reservationKey);
86
94
  return taken;
87
- });
95
+ }, serial);
88
96
  return { status: "taken", sends: rows.map(heldSendOf) };
89
97
  },
90
98
  async drop(messageId): Promise<HeldSendDropResult> {
@@ -13,7 +13,7 @@ import type {
13
13
  SessionIdReclaim,
14
14
  SessionIdReclaimResult,
15
15
  } from "./multinode-state-store.js";
16
- import { ensureBrokerSchema } from "./sql-schema.js";
16
+ import { ensureBrokerSchema, withBrokerSchemaCatalog } from "./sql-schema.js";
17
17
 
18
18
  type BindingRow = SqliteRow & { return_address: string; owner_token?: string | null; owner_broker?: string | null };
19
19
 
@@ -66,9 +66,16 @@ function stateFromRow(row: KnownRow): KnownSessionState {
66
66
  * `toLowerCase` form the lookup compares. Table `<prefix>intercom_session_bindings` binds each Intercom id to the return
67
67
  * address of the session that registered it (`""` for none).
68
68
  */
69
- export async function openSqlKnownSessionStore({
69
+ export function openSqlKnownSessionStore(options: IntercomBrokerStateOptions): Promise<KnownSessionStore> {
70
+ // Its schema checks answer from one read of the catalog, shared with an open around it: a current schema costs
71
+ // no transaction and no lock, also when the store is opened on its own (#6560).
72
+ return withBrokerSchemaCatalog(options.database, options.prefix, () => openKnownSessionStoreInCatalog(options));
73
+ }
74
+
75
+ async function openKnownSessionStoreInCatalog({
70
76
  database,
71
77
  prefix,
78
+ reader = database,
72
79
  }: IntercomBrokerStateOptions): Promise<KnownSessionStore> {
73
80
  const table = `${validateStoragePrefix(prefix, dialectOf(database).name)}intercom_known_sessions`;
74
81
  const bindings = `${validateStoragePrefix(prefix, dialectOf(database).name)}intercom_session_bindings`;
@@ -349,7 +356,8 @@ export async function openSqlKnownSessionStore({
349
356
  },
350
357
  async lookup(target, retentionMs): Promise<KnownSessionLookupResult> {
351
358
  if (target.length === 0) return { status: "invalid", reason: "empty-target" };
352
- const rows = await database.all<KnownRow>(
359
+ // Through the reader, which never waits behind this database's writes (#6560).
360
+ const rows = await reader.all<KnownRow>(
353
361
  // One reading of the clock, so a session found within the retention reports an age within it too.
354
362
  `WITH clock AS (SELECT ${nowMs} AS now)
355
363
  SELECT target_identity, intercom_session_id${aliasColumn}, name_json, atomic_session_id, group_name, groups_json,
@@ -375,7 +383,7 @@ export async function openSqlKnownSessionStore({
375
383
  ...(owned ? { owners } : {}),
376
384
  async binding(intercomSessionId, retentionMs): Promise<KnownSessionBindingResult> {
377
385
  if (intercomSessionId.length === 0) return { status: "invalid", reason: "empty-session-id" };
378
- const bound = await database.get<BindingRow>(
386
+ const bound = await reader.get<BindingRow>(
379
387
  `SELECT return_address FROM ${bindings} WHERE intercom_session_id = ? AND ${nowMs} - recorded_at <= ?`,
380
388
  intercomSessionId,
381
389
  retentionMs,
@@ -392,14 +400,18 @@ export async function openSqlKnownSessionStore({
392
400
  },
393
401
  async markLost(targetIdentities): Promise<void> {
394
402
  if (targetIdentities.length === 0) return;
395
- await database.transaction(async (tx) => {
396
- for (const identity of targetIdentities) {
397
- await tx.run(
398
- `UPDATE ${table} SET lost_at = ${nowMs} WHERE target_identity = ? AND lost_at IS NULL`,
399
- identity,
400
- );
401
- }
402
- });
403
+ // Each row's write is guarded on its own: only other `markLost`s, locking the same rows, are excluded (#6560).
404
+ await database.transaction(
405
+ async (tx) => {
406
+ for (const identity of targetIdentities) {
407
+ await tx.run(
408
+ `UPDATE ${table} SET lost_at = ${nowMs} WHERE target_identity = ? AND lost_at IS NULL`,
409
+ identity,
410
+ );
411
+ }
412
+ },
413
+ { concurrency: { kind: "serial", domain: table } },
414
+ );
403
415
  },
404
416
  async listLost(olderThanMs): Promise<KnownSessionState[]> {
405
417
  const rows = await database.all<KnownRow>(